Skip to content

Commit

Permalink
FIX sourceRecords to return SS_List, style changes (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
raissanorth authored and robbieaverill committed Dec 4, 2017
1 parent 3c6afc7 commit 60fb92c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
}],
"extra": {
"expose": [
"javascript"
"javascript",
"css"
],
"branch-alias": {
"dev-master": "3.x-dev"
Expand Down
8 changes: 8 additions & 0 deletions css/sitewidecontentreport.css
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;
}
3 changes: 2 additions & 1 deletion lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lang/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
24 changes: 18 additions & 6 deletions src/SitewideContentReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

/**
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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)');
}

Expand Down Expand Up @@ -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)) {
Expand All @@ -177,6 +188,7 @@ public function getCMSFields()
$fields->push(HeaderField::create('FilesTitle', _t(__CLASS__ . '.Files', 'Files'), 3));
$fields->push($this->getReportField('Files'));


return $fields;
}

Expand All @@ -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(),
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit 60fb92c

Please sign in to comment.