diff --git a/composer.json b/composer.json index d221715..f435a4e 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ }], "extra": { "expose": [ - "javascript" + "javascript", + "css" ], "branch-alias": { "dev-master": "3.x-dev" diff --git a/css/sitewidecontentreport.css b/css/sitewidecontentreport.css new file mode 100644 index 0000000..9bfe721 --- /dev/null +++ b/css/sitewidecontentreport.css @@ -0,0 +1,8 @@ +.gridfieldbasiccontentreport.field { + border-bottom: 1px solid #D2D5D8; + margin: 24px 0; +} + +.gridfieldbasiccontentreport.field:last-of-type { + border-bottom-style: none; +} \ No newline at end of file diff --git a/lang/en.yml b/lang/en.yml index f44c6af..ad56699 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -2,7 +2,8 @@ en: SilverStripe\SiteWideContentReport\SitewideContentReport: AccessFromAllSubsites: '(accessible by all subsites)' Created: 'Date created' - Description: 'All pages and files across all Subsites' + Description: 'All pages and files across the system' + DescriptionIncludingSubsites: 'All pages and files across all Subsites' Directory: Directory Draft: Draft FileType: 'File type' diff --git a/lang/es.yml b/lang/es.yml index ae4155b..38565ae 100644 --- a/lang/es.yml +++ b/lang/es.yml @@ -2,7 +2,7 @@ es: SilverStripe\SiteWideContentReport\SitewideContentReport: AccessFromAllSubsites: '(accesible desde todos los sub sitios)' Created: Creado - Description: 'Todas las páginas y archivo en todos los sub sitios' + Description: 'Todas las páginas y archivo' Directory: Directorio Draft: Borrador FileType: 'Tipo de archivo' diff --git a/src/SitewideContentReport.php b/src/SitewideContentReport.php index 617b4e5..ff141e2 100644 --- a/src/SitewideContentReport.php +++ b/src/SitewideContentReport.php @@ -48,7 +48,11 @@ public function title() */ public function description() { - return _t(__CLASS__ . '.Description', 'All pages and files across all Subsites'); + if (class_exists(Subsite::class)) { + return _t(__CLASS__ . '.DescriptionIncludingSubsites', 'All pages and files across all Subsites'); + } else { + return _t(__CLASS__ . '.Description', 'All pages and files across the system'); + } } /** @@ -77,6 +81,12 @@ public function sourceRecords() } } + public function getCount($params = array()) + { + $records = $this->sourceRecords(); + return $records['Pages']->count() + $records['Files']->count(); + } + /** * Returns columns for the grid fields on this report. * @@ -112,12 +122,12 @@ public function columns($itemType = 'Pages') 'title' => _t(__CLASS__ . '.Stage', 'Stage'), 'formatting' => function ($value, $item) { // Stage only - if (!$item->getExistsOnLive()) { + if (!$item->isPublished()) { return _t(__CLASS__ . '.Draft', 'Draft'); } // Pending changes - if ($item->getIsModifiedOnStage()) { + if ($item->isModifiedOnDraft()) { return _t(__CLASS__ . '.PublishedWithChanges', 'Published (with changes)'); } @@ -158,6 +168,7 @@ public function columns($itemType = 'Pages') public function getCMSFields() { Requirements::javascript('silverstripe/sitewidecontent-report: javascript/sitewidecontentreport.js'); + Requirements::css('silverstripe/sitewidecontent-report: css/sitewidecontentreport.css'); $fields = parent::getCMSFields(); if (class_exists(Subsite::class)) { @@ -177,6 +188,7 @@ public function getCMSFields() $fields->push(HeaderField::create('FilesTitle', _t(__CLASS__ . '.Files', 'Files'), 3)); $fields->push($this->getReportField('Files')); + return $fields; } @@ -193,7 +205,7 @@ public function getReportField($itemType = 'Pages') $params = isset($_REQUEST['filters']) ? $_REQUEST['filters'] : array(); $items = $this->sourceRecords($params, null, null); - $gridField = new GridFieldBasicContentReport('Report-'.$itemType, false, $items[$itemType]); + $gridField = new GridFieldBasicContentReport('Report-' . $itemType, false, $items[$itemType]); $gridFieldConfig = GridFieldConfig::create()->addComponents( new GridFieldToolbarHeader(), @@ -290,8 +302,8 @@ public function getReportField($itemType = 'Pages') * Returns the columns for the export and print functionality. * * @param GridField $gridField - * @param string $itemType (i.e 'Pages' or 'Files') - * @param array $exportColumns + * @param string $itemType (i.e 'Pages' or 'Files') + * @param array $exportColumns * * @return array */