From bb59c4807859db3abf6fbbec17e976a83dae4992 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Thu, 29 Oct 2009 02:50:47 +0000 Subject: [PATCH] MINOR categorized reports, fixed a few translations issues. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@90394 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CMSMain.php | 19 ++++++++++++++++--- code/SideReport.php | 34 ++++++++++++++++++++++++++++++++-- lang/en_US.php | 8 ++++---- 3 files changed, 52 insertions(+), 9 deletions(-) diff --git a/code/CMSMain.php b/code/CMSMain.php index fd91fd2d..238caa05 100755 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -670,11 +670,24 @@ JS; function ReportSelector() { $reports = ClassInfo::subclassesFor("SideReport"); - $options[""] = _t('CMSMain.CHOOSEREPORT',"(Choose a report)"); + // $options[""] = _t('CMSMain.CHOOSEREPORT',"(Choose a report)"); foreach($reports as $report) { - if($report != 'SideReport' && singleton($report)->canView()) $options[$report] = singleton($report)->title(); + if($report != 'SideReport' && singleton($report)->canView()) { + $options[singleton($report)->group()][singleton($report)->sort()][$report] = singleton($report)->title(); + } } - return new DropdownField("ReportSelector", _t('CMSMain.REPORT', 'Report'),$options); + + $finalOptions = array(); + foreach($options as $group => $weights) { + ksort($weights); + foreach($weights as $weight => $reports) { + foreach($reports as $class => $report) { + $finalOptions[$group][$class] = $report; + } + } + } + + return new GroupedDropdownField("ReportSelector", _t('CMSMain.REPORT', 'Report'),$finalOptions); } function ReportFormParameters() { $reports = ClassInfo::subclassesFor("SideReport"); diff --git a/code/SideReport.php b/code/SideReport.php index 81d8cd5c..30ed7d79 100755 --- a/code/SideReport.php +++ b/code/SideReport.php @@ -12,6 +12,14 @@ abstract class SideReport extends Object { abstract function fieldsToShow(); abstract function title(); + function group() { + return 'Other'; + } + + function sort() { + return 0; + } + function getHTML() { $records = $this->records(); $fieldsToShow = $this->fieldsToShow(); @@ -89,7 +97,13 @@ abstract class SideReport extends Object { */ class SideReport_EmptyPages extends SideReport { function title() { - return _t('SideReport.EMPTYPAGES',"Empty pages"); + return _t('SideReport.EMPTYPAGES',"Pages with no content"); + } + function group() { + return "Content reports"; + } + function sort() { + return 100; } function records($params = null) { return DataObject::get("SiteTree", "\"Content\" = '' OR \"Content\" IS NULL OR \"Content\" LIKE '

' OR \"Content\" LIKE '

 

'", '"Title"'); @@ -110,6 +124,12 @@ class SideReport_RecentlyEdited extends SideReport { function title() { return _t('SideReport.LAST2WEEKS',"Pages edited in the last 2 weeks"); } + function group() { + return "Content reports"; + } + function sort() { + return 200; + } function records($params = null) { $threshold = strtotime('-14 days', SS_Datetime::now()->Format('U')); return DataObject::get("SiteTree", "\"SiteTree\".\"LastEdited\" > '".date("Y-m-d H:i:s", $threshold)."'", "\"SiteTree\".\"LastEdited\" DESC"); @@ -123,7 +143,13 @@ class SideReport_RecentlyEdited extends SideReport { class SideReport_ToDo extends SideReport { function title() { - return _t('SideReport.TODO',"To do"); + return _t('SideReport.TODO',"Pages with To Do items"); + } + function group() { + return "Content reports"; + } + function sort() { + return 0; } function records($params = null) { return DataObject::get("SiteTree", "\"SiteTree\".\"ToDo\" IS NOT NULL AND \"SiteTree\".\"ToDo\" <> ''", "\"SiteTree\".\"LastEdited\" DESC"); @@ -154,6 +180,10 @@ class SideReport_BrokenLinks extends SideReport { return _t('SideReport.BROKENPAGEFILELINKS', 'Broken Page & File Links'); } + function group() { + return "Broken links reports"; + } + public function records() { return DataObject::get('SiteTree', '"HasBrokenLink" = 1 OR "HasBrokenFile" = 1'); } diff --git a/lang/en_US.php b/lang/en_US.php index 9ec45dcd..699bb699 100755 --- a/lang/en_US.php +++ b/lang/en_US.php @@ -67,9 +67,9 @@ $lang['en_US']['CMSBatchActions']['UNPUBLISHED_PAGES'] = 'Un-published %d pages' $lang['en_US']['CMSBatchActions']['UNPUBLISHING_PAGES'] = 'Un-publishing pages'; $lang['en_US']['CMSBatchActions']['UNPUBLISH_PAGES'] = 'Un-publish'; $lang['en_US']['CMSMain']['ACCESS'] = array( - 'Access to \'%s\'', + 'Access to %s', PR_MEDIUM, - 'Item in permission selection identifying the admin section, with title and classname. Example: Access to \'Files & Images\' (AssetAdmin)' + 'Item in permission selection identifying the admin section, with title and classname. Example: Access to Files & Images' ); $lang['en_US']['CMSMain']['ACCESSALLINTERFACES'] = 'Access to all CMS sections'; $lang['en_US']['CMSMain']['CANCEL'] = 'Cancel'; @@ -463,14 +463,14 @@ $lang['en_US']['SecurityAdmin_right.ss']['WELCOME2'] = array( 50 ); $lang['en_US']['SideReport']['BROKENPAGEFILELINKS'] = 'Broken Page & File Links'; -$lang['en_US']['SideReport']['EMPTYPAGES'] = 'Empty pages'; +$lang['en_US']['SideReport']['EMPTYPAGES'] = 'Pages with no content'; $lang['en_US']['SideReport']['LAST2WEEKS'] = 'Pages edited in the last 2 weeks'; $lang['en_US']['SideReport']['REPEMPTY'] = array( 'The %s report is empty.', PR_MEDIUM, '%s is a report title' ); -$lang['en_US']['SideReport']['TODO'] = 'To do'; +$lang['en_US']['SideReport']['TODO'] = 'Pages with To Do items'; $lang['en_US']['StaticExporter']['BASEURL'] = 'Base URL'; $lang['en_US']['StaticExporter']['EXPORTTO'] = 'Export to that folder'; $lang['en_US']['StaticExporter']['FOLDEREXPORT'] = 'Folder to export to';