-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEW Move code from silverstripe/sitewidecontent-report
- Loading branch information
1 parent
a3a06d8
commit cfc9f7a
Showing
21 changed files
with
6,961 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@silverstripe/eslint-config/.eslintrc'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.sass-cache | ||
.DS_Store | ||
.DS_Store | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@silverstripe/eslint-config/.stylelintrc'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
Name: reports-sitewidecontenttaxonomy | ||
Only: | ||
moduleexists: silverstripe/taxonomy | ||
--- | ||
SilverStripe\Reports\SiteWideContentReport\SitewideContentReport: | ||
extensions: | ||
- SilverStripe\Reports\SiteWideContentReport\Model\SitewideContentTaxonomy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-env", | ||
"@babel/preset-react" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.gridfieldbasiccontentreport.field{border-bottom:1px solid #d2d5d8;margin:24px 0}.gridfieldbasiccontentreport.field:last-of-type{border-bottom-style:none} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.gridfieldbasiccontentreport.field { | ||
border-bottom: 1px solid #D2D5D8; | ||
margin: 24px 0; | ||
} | ||
|
||
.gridfieldbasiccontentreport.field:last-of-type { | ||
border-bottom-style: none; | ||
} |
24 changes: 24 additions & 0 deletions
24
code/SiteWideContentReport/Form/GridFieldBasicContentReport.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace SilverStripe\Reports\SiteWideContentReport\Form; | ||
|
||
use SilverStripe\Forms\GridField\GridField; | ||
use SilverStripe\ORM\DataObject; | ||
|
||
class GridFieldBasicContentReport extends GridField | ||
{ | ||
/** | ||
* @param int $total | ||
* @param int $index | ||
* @param DataObject $record | ||
* | ||
* @return array | ||
*/ | ||
protected function getRowAttributes($total, $index, $record) | ||
{ | ||
$attributes = parent::getRowAttributes($total, $index, $record); | ||
$this->extend('updateRowAttributes', $total, $index, $record, $attributes); | ||
|
||
return $attributes; | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
code/SiteWideContentReport/Model/SitewideContentTaxonomy.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
namespace SilverStripe\Reports\SiteWideContentReport\Model; | ||
|
||
use SilverStripe\Core\Config\Config; | ||
use SilverStripe\Core\Extension; | ||
use SilverStripe\Reports\SiteWideContentReport\SitewideContentReport; | ||
use SilverStripe\Taxonomy\TaxonomyTerm; | ||
|
||
/** | ||
* Provides taxonomy integration for sitewide content report. | ||
* | ||
* @extends Extension<SitewideContentReport> | ||
*/ | ||
class SitewideContentTaxonomy extends Extension | ||
{ | ||
/** | ||
* Name of field to get tags from. | ||
* | ||
* @config | ||
* | ||
* @var string | ||
*/ | ||
private static $tag_field = 'Terms'; | ||
|
||
/** | ||
* Update columns to include taxonomy details. | ||
* | ||
* @param string $itemType (i.e 'Pages' or 'Files') | ||
* @param array $columns Columns | ||
*/ | ||
protected function updateColumns($itemType, &$columns) | ||
{ | ||
if ($itemType !== 'Pages') { | ||
return; | ||
} | ||
|
||
// Check if pages has the tags field | ||
if (!SitewideContentTaxonomy::enabled()) { | ||
return; | ||
} | ||
|
||
// Set column | ||
$field = Config::inst()->get(__CLASS__, 'tag_field'); | ||
$columns['Terms'] = [ | ||
'printonly' => true, // Hide on page report | ||
'title' => _t('SilverStripe\\SiteWideContentReport\\SitewideContentReport.Tags', 'Tags'), | ||
'datasource' => function ($record) use ($field) { | ||
if ($record->hasMethod($field)) { | ||
$tags = $record->$field()->column('Name'); | ||
|
||
return implode(', ', $tags); | ||
} | ||
|
||
return ''; | ||
}, | ||
]; | ||
} | ||
|
||
/** | ||
* Check if this field is enabled. | ||
* | ||
* @return bool | ||
*/ | ||
public static function enabled() | ||
{ | ||
if (!class_exists(TaxonomyTerm::class)) { | ||
return false; | ||
} | ||
|
||
// Check if pages has the tags field | ||
$field = Config::inst()->get(__CLASS__, 'tag_field'); | ||
|
||
return singleton('Page')->hasMethod($field); | ||
} | ||
} |
Oops, something went wrong.