isAjax()) { Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SiteTree'))); } parent::init(); Requirements::css(CMS_DIR . '/css/screen.css'); Requirements::combine_files( 'cmsmain.js', array_merge( array( CMS_DIR . '/javascript/CMSMain.js', CMS_DIR . '/javascript/CMSMain.EditForm.js', CMS_DIR . '/javascript/CMSMain.AddForm.js', CMS_DIR . '/javascript/CMSPageHistoryController.js', CMS_DIR . '/javascript/CMSMain.Tree.js', CMS_DIR . '/javascript/SilverStripeNavigator.js' ), Requirements::add_i18n_javascript(CMS_DIR . '/javascript/lang', true, true) ) ); CMSBatchActionHandler::register('publish', 'CMSBatchAction_Publish'); CMSBatchActionHandler::register('unpublish', 'CMSBatchAction_Unpublish'); CMSBatchActionHandler::register('delete', 'CMSBatchAction_Delete'); CMSBatchActionHandler::register('deletefromlive', 'CMSBatchAction_DeleteFromLive'); } /** * If this is set to true, the "switchView" context in the * template is shown, with links to the staging and publish site. * * @return boolean */ function ShowSwitchView() { return true; } /** * Overloads the LeftAndMain::ShowView. Allows to pass a page as a parameter, so we are able * to switch view also for archived versions. */ function SwitchView($page = null) { if(!$page) { $page = $this->currentPage(); } if($page) { $nav = SilverStripeNavigator::get_for_record($page); return $nav['items']; } } //------------------------------------------------------------------------------------------// // Main controllers //------------------------------------------------------------------------------------------// // Main UI components /** * Override {@link LeftAndMain} Link to allow blank URL segment for CMSMain. * * @return string */ public function Link($action = null) { return Controller::join_links( $this->stat('url_base', true), $this->stat('url_segment', true), // in case we want to change the segment '/', // trailing slash needed if $action is null! "$action" ); } /** * @return string */ public function PreviewLink() { $record = $this->getRecord($this->currentPageID()); $baseLink = ($record && $record instanceof Page) ? $record->Link('?stage=Stage') : Director::absoluteBaseURL(); return $baseLink; } /** * Return the entire site tree as a nested set of ULs */ public function SiteTreeAsUL() { $html = ''; // Include custom CSS for tree icons inline, as the tree might be loaded // via Ajax, in which case we can't inject it into the HTML header easily through the HTTP response. $css = $this->generateTreeStylingCSS(); if($this->isAjax()) { $html .= "\n"; } else { Requirements::customCSS($css); } // Pre-cache sitetree version numbers for querying efficiency Versioned::prepopulate_versionnumber_cache("SiteTree", "Stage"); Versioned::prepopulate_versionnumber_cache("SiteTree", "Live"); $html .= $this->getSiteTreeFor($this->stat('tree_class')); return $html; } function SearchForm() { // get all page types in a dropdown-compatible format $pageTypes = SiteTree::page_type_classes(); array_unshift($pageTypes, _t('CMSMain.PAGETYPEANYOPT','Any')); $pageTypes = array_combine($pageTypes, $pageTypes); asort($pageTypes); // get all filter instances $filters = ClassInfo::subclassesFor('CMSSiteTreeFilter'); $filterMap = array(); // remove base class array_shift($filters); // add filters to map foreach($filters as $filter) { $filterMap[$filter] = call_user_func(array($filter, 'title')); } // ensure that 'all pages' filter is on top position uasort($filterMap, create_function('$a,$b', 'return ($a == "CMSSiteTreeFilter_Search") ? 1 : -1;') ); $fields = new FieldList( new TextField('Term', _t('CMSSearch.FILTERLABELTEXT', 'Content')), $dateGroup = new FieldGroup( $dateFrom = new DateField('LastEditedFrom', _t('CMSSearch.FILTERDATEFROM', 'From')), $dateTo = new DateField('LastEditedTo', _t('CMSSearch.FILTERDATETO', 'To')) ), new DropdownField( 'FilterClass', _t('CMSMain.PAGES', 'Pages'), $filterMap ), new DropdownField( 'ClassName', _t('CMSMain.PAGETYPEOPT','Page Type', PR_MEDIUM, 'Dropdown for limiting search to a page type'), $pageTypes, null, null, _t('CMSMain.PAGETYPEANYOPT','Any') ) // new TextField('MetaTags', _t('CMSMain.SearchMetaTags', 'Meta tags')) ); $dateGroup->subfieldParam = 'FieldHolder'; $dateFrom->setConfig('showcalendar', true); $dateTo->setConfig('showcalendar', true); $actions = new FieldList( Object::create('ResetFormAction', 'clear', _t('CMSMain_left.ss.CLEAR', 'Clear')) ->addExtraClass('ss-ui-action-minor'), FormAction::create('doSearch', _t('CMSMain_left.ss.SEARCH', 'Search')) ); // Use