diff --git a/_config.php b/_config.php index ca38bc80..2f11a349 100644 --- a/_config.php +++ b/_config.php @@ -37,6 +37,7 @@ ShortcodeParser::get('default')->register('sitetree_link', array('SiteTree', 'li Object::add_extension('File', 'SiteTreeFileExtension'); // TODO Remove once we can configure CMSMenu through static, nested configuration files +CMSMenu::remove_menu_item('CMSMain'); CMSMenu::remove_menu_item('CMSPageEditController'); CMSMenu::remove_menu_item('CMSPageSettingsController'); CMSMenu::remove_menu_item('CMSPageHistoryController'); diff --git a/code/controllers/CMSMain.php b/code/controllers/CMSMain.php index 3e98e225..6ee8efa0 100644 --- a/code/controllers/CMSMain.php +++ b/code/controllers/CMSMain.php @@ -11,13 +11,13 @@ */ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionProvider { - static $url_segment = 'page'; + static $url_segment = 'pages'; static $url_rule = '/$Action/$ID/$OtherID'; // Maintain a lower priority than other administration sections // so that Director does not think they are actions of CMSMain - static $url_priority = 40; + static $url_priority = 39; static $menu_title = 'Edit Page'; @@ -43,9 +43,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr 'SiteTreeAsUL', 'getshowdeletedsubtree', 'batchactions', - 'ListView', - 'getListView', - 'listchildren', + 'treeview', + 'listview', + 'ListViewForm', ); public function init() { @@ -78,7 +78,24 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr CMSBatchActionHandler::register('delete', 'CMSBatchAction_Delete'); CMSBatchActionHandler::register('deletefromlive', 'CMSBatchAction_DeleteFromLive'); } - + + function index($request) { + // In case we're not showing a specific record, explicitly remove any session state, + // to avoid it being highlighted in the tree, and causing an edit form to show. + if(!$request->param('Action')) $this->setCurrentPageId(null); + + return parent::index($request); + } + + protected function getResponseNegotiator() { + $negotiator = parent::getResponseNegotiator(); + $controller = $this; + $negotiator->setCallback('ListViewForm', function() use(&$controller) { + return $controller->ListViewForm()->forTemplate(); + }); + return $negotiator; + } + /** * If this is set to true, the "switchView" context in the * template is shown, with links to the staging and publish site. @@ -123,6 +140,62 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr "$action" ); } + + public function LinkPages() { + return singleton('CMSPagesController')->Link(); + } + + public function LinkTreeView() { + return $this->LinkWithSearch(singleton('CMSMain')->Link('treeview')); + } + + public function LinkListView() { + return $this->LinkWithSearch(singleton('CMSMain')->Link('listview')); + } + + public function LinkGalleryView() { + return $this->LinkWithSearch(singleton('CMSMain')->Link('galleryview')); + } + + public function LinkPageEdit() { + if($id = $this->currentPageID()) { + return $this->LinkWithSearch( + Controller::join_links(singleton('CMSPageEditController')->Link('show'), $id) + ); + } + } + + public function LinkPageSettings() { + if($id = $this->currentPageID()) { + return $this->LinkWithSearch( + Controller::join_links(singleton('CMSPageSettingsController')->Link('show'), $id) + ); + } + } + + public function LinkPageHistory() { + if($id = $this->currentPageID()) { + return $this->LinkWithSearch( + Controller::join_links(singleton('CMSPageHistoryController')->Link('show'), $id) + ); + } + } + + protected function LinkWithSearch($link) { + // Whitelist to avoid side effects + $params = array( + 'q' => (array)$this->request->getVar('q'), + 'ParentID' => $this->request->getVar('ParentID') + ); + return Controller::join_links( + $link, + array_filter(array_values($params)) ? '?' . http_build_query($params) : null + ); + } + + function LinkPageAdd() { + return singleton("CMSPageAddController")->Link(); + } /** * @return string @@ -155,6 +228,13 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr return $html; } + + /** + * @return boolean + */ + public function TreeIsFiltered() { + return $this->request->getVar('q'); + } function SearchForm() { // get all page types in a dropdown-compatible format @@ -177,19 +257,19 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr ); $fields = new FieldList( - new TextField('Term', _t('CMSSearch.FILTERLABELTEXT', 'Content')), + new TextField('q[Term]', _t('CMSSearch.FILTERLABELTEXT', 'Content')), $dateGroup = new FieldGroup( - new HeaderField('Date', _t('CMSSearch.FILTERDATEHEADING', 'Date'), 4), - $dateFrom = new DateField('LastEditedFrom', _t('CMSSearch.FILTERDATEFROM', 'From')), - $dateTo = new DateField('LastEditedTo', _t('CMSSearch.FILTERDATETO', 'To')) + new HeaderField('q[Date]', _t('CMSSearch.FILTERDATEHEADING', 'Date'), 4), + $dateFrom = new DateField('q[LastEditedFrom]', _t('CMSSearch.FILTERDATEFROM', 'From')), + $dateTo = new DateField('q[LastEditedTo]', _t('CMSSearch.FILTERDATETO', 'To')) ), new DropdownField( - 'FilterClass', + 'q[FilterClass]', _t('CMSMain.PAGES', 'Pages'), $filterMap ), new DropdownField( - 'ClassName', + 'q[ClassName]', _t('CMSMain.PAGETYPEOPT','Page Type', 'Dropdown for limiting search to a page type'), $pageTypes, null, @@ -211,11 +291,14 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr // Use + +
+ <% if TreeIsFiltered %> +
+ <% _t('CMSMain.TreeFiltered', 'Filtered tree.') %> + + <% _t('CMSMain.TreeFilteredClear', 'Clear filter') %> + +
+ <% end_if %> + +
+ $SiteTreeAsUL +
+
diff --git a/templates/Includes/CMSPageHistoryController_Tools.ss b/templates/Includes/CMSPageHistoryController_Tools.ss index de7766bb..1a4671c1 100644 --- a/templates/Includes/CMSPageHistoryController_Tools.ss +++ b/templates/Includes/CMSPageHistoryController_Tools.ss @@ -1,9 +1,4 @@
-
-
-

<% _t('CMSPageHistoryController.History','History') %>

-
-
$VersionsForm diff --git a/templates/Includes/CMSPageSettingsController_Tools.ss b/templates/Includes/CMSPageSettingsController_Tools.ss deleted file mode 100644 index 3b7b1752..00000000 --- a/templates/Includes/CMSPageSettingsController_Tools.ss +++ /dev/null @@ -1 +0,0 @@ -<% include CMSPageEditController_Tools %> \ No newline at end of file diff --git a/templates/Includes/CMSPagesController_Content.ss b/templates/Includes/CMSPagesController_Content.ss index f8341c53..a45e662c 100644 --- a/templates/Includes/CMSPagesController_Content.ss +++ b/templates/Includes/CMSPagesController_Content.ss @@ -9,10 +9,10 @@