mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
remove trailing spaces in the codebase
This commit is contained in:
parent
dc9286af6e
commit
4694763fa5
@ -2,20 +2,20 @@
|
||||
/**
|
||||
* AssetAdmin is the 'file store' section of the CMS.
|
||||
* It provides an interface for manipulating the File and Folder objects in the system.
|
||||
*
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage assets
|
||||
*/
|
||||
class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
||||
|
||||
private static $url_segment = 'assets';
|
||||
|
||||
|
||||
private static $url_rule = '/$Action/$ID';
|
||||
|
||||
|
||||
private static $menu_title = 'Files';
|
||||
|
||||
private static $tree_class = 'Folder';
|
||||
|
||||
|
||||
/**
|
||||
* Amount of results showing on a single page.
|
||||
*
|
||||
@ -23,14 +23,14 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
||||
* @var int
|
||||
*/
|
||||
private static $page_length = 15;
|
||||
|
||||
|
||||
/**
|
||||
* @config
|
||||
* @see Upload->allowedMaxFileSize
|
||||
* @var int
|
||||
*/
|
||||
private static $allowed_max_file_size;
|
||||
|
||||
|
||||
private static $allowed_actions = array(
|
||||
'addfolder',
|
||||
'delete',
|
||||
@ -45,7 +45,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
||||
'doSync',
|
||||
'filter',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Return fake-ID "root" if no ID is found (needed to upload files into the root-folder)
|
||||
*/
|
||||
@ -66,7 +66,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
||||
*/
|
||||
public function init() {
|
||||
parent::init();
|
||||
|
||||
|
||||
// Create base folder if it doesnt exist already
|
||||
if(!file_exists(ASSETS_PATH)) Filesystem::makeFolder(ASSETS_PATH);
|
||||
|
||||
@ -84,7 +84,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
||||
};
|
||||
JS
|
||||
);
|
||||
|
||||
|
||||
CMSBatchActionHandler::register('delete', 'AssetAdmin_DeleteBatchAction', 'Folder');
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ JS
|
||||
* Returns the files and subfolders contained in the currently selected folder,
|
||||
* defaulting to the root node. Doubles as search results, if any search parameters
|
||||
* are set through {@link SearchForm()}.
|
||||
*
|
||||
*
|
||||
* @return SS_List
|
||||
*/
|
||||
public function getList() {
|
||||
@ -122,7 +122,7 @@ JS
|
||||
));
|
||||
}
|
||||
|
||||
// Always show folders at the top
|
||||
// Always show folders at the top
|
||||
$list = $list->sort('(CASE WHEN "File"."ClassName" = \'Folder\' THEN 0 ELSE 1 END), "Name"');
|
||||
|
||||
// If a search is conducted, check for the "current folder" limitation.
|
||||
@ -138,7 +138,7 @@ JS
|
||||
$exts = File::config()->app_categories[$params['AppCategory']];
|
||||
$list = $list->filter('Name:PartialMatch', $exts);
|
||||
}
|
||||
|
||||
|
||||
// Date filter
|
||||
if(!empty($params['CreatedFrom'])) {
|
||||
$fromDate = new DateField(null, null, $params['CreatedFrom']);
|
||||
@ -187,14 +187,14 @@ JS
|
||||
'Created' => 'SS_Datetime->Nice'
|
||||
));
|
||||
$gridField->setAttribute(
|
||||
'data-url-folder-template',
|
||||
'data-url-folder-template',
|
||||
Controller::join_links($this->Link('show'), '%s')
|
||||
);
|
||||
|
||||
if(!$folder->hasMethod('canAddChildren') || ($folder->hasMethod('canAddChildren') && $folder->canAddChildren())) {
|
||||
// TODO Will most likely be replaced by GridField logic
|
||||
$addFolderBtn = new LiteralField(
|
||||
'AddFolderButton',
|
||||
'AddFolderButton',
|
||||
sprintf(
|
||||
'<a class="ss-ui-button font-icon-plus-circled cms-add-folder-link" data-icon="add" data-url="%s" href="%s">%s</a>',
|
||||
Controller::join_links($this->Link('AddForm'), '?' . http_build_query(array(
|
||||
@ -223,12 +223,12 @@ JS
|
||||
} else {
|
||||
$syncButton = null;
|
||||
}
|
||||
|
||||
|
||||
// Move existing fields to a "details" tab, unless they've already been tabbed out through extensions.
|
||||
// Required to keep Folder->getCMSFields() simple and reuseable,
|
||||
// without any dependencies into AssetAdmin (e.g. useful for "add folder" views).
|
||||
if(!$fields->hasTabset()) {
|
||||
$tabs = new TabSet('Root',
|
||||
$tabs = new TabSet('Root',
|
||||
$tabList = new Tab('ListView', _t('AssetAdmin.ListView', 'List View')),
|
||||
$tabTree = new Tab('TreeView', _t('AssetAdmin.TreeView', 'Tree View'))
|
||||
);
|
||||
@ -253,7 +253,7 @@ JS
|
||||
|
||||
// Add the upload field for new media
|
||||
if($currentPageID = $this->currentPageID()){
|
||||
Session::set("{$this->class}.currentPage", $currentPageID);
|
||||
Session::set("{$this->class}.currentPage", $currentPageID);
|
||||
}
|
||||
|
||||
$folder = $this->currentPage();
|
||||
@ -296,10 +296,10 @@ JS
|
||||
new LiteralField(
|
||||
'Tree',
|
||||
FormField::create_tag(
|
||||
'div',
|
||||
'div',
|
||||
array(
|
||||
'class' => 'cms-tree',
|
||||
'data-url-tree' => $this->Link('getsubtree'),
|
||||
'class' => 'cms-tree',
|
||||
'data-url-tree' => $this->Link('getsubtree'),
|
||||
'data-url-savetreenode' => $this->Link('savetreenode')
|
||||
),
|
||||
$this->SiteTreeAsUL()
|
||||
@ -315,11 +315,11 @@ JS
|
||||
$actions->removeByName('action_delete');
|
||||
if(($saveBtn || $deleteBtn) && $fields->fieldByName('Root.DetailsView')) {
|
||||
$fields->addFieldToTab(
|
||||
'Root.DetailsView',
|
||||
'Root.DetailsView',
|
||||
CompositeField::create($saveBtn,$deleteBtn)->addExtraClass('Actions')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$fields->setForm($form);
|
||||
@ -351,7 +351,7 @@ JS
|
||||
|
||||
public function delete($data, $form) {
|
||||
$className = $this->stat('tree_class');
|
||||
|
||||
|
||||
$record = DataObject::get_by_id($className, $data['ID']);
|
||||
if($record && !$record->canDelete()) return Security::permissionFailure();
|
||||
if(!$record || !$record->ID) throw new SS_HTTPResponse_Exception("Bad record ID #" . (int)$data['ID'], 404);
|
||||
@ -371,7 +371,7 @@ JS
|
||||
*/
|
||||
public function getSearchContext() {
|
||||
$context = singleton('File')->getDefaultSearchContext();
|
||||
|
||||
|
||||
// Namespace fields, for easier detection if a search is present
|
||||
foreach($context->getFields() as $field) $field->setName(sprintf('q[%s]', $field->getName()));
|
||||
foreach($context->getFilters() as $filter) $filter->setFullName(sprintf('q[%s]', $filter->getFullName()));
|
||||
@ -413,7 +413,7 @@ JS
|
||||
|
||||
return $context;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a form for filtering of files and assets gridfield.
|
||||
* Result filtering takes place in {@link getList()}.
|
||||
@ -431,7 +431,7 @@ JS
|
||||
->addExtraClass('ss-ui-action-constructive'),
|
||||
Object::create('ResetFormAction', 'clear', _t('CMSMain_left_ss.RESET', 'Reset'))
|
||||
);
|
||||
|
||||
|
||||
$form = new Form($this, 'filter', $fields, $actions);
|
||||
$form->setFormMethod('GET');
|
||||
$form->setFormAction(Controller::join_links($this->Link('show'), $folder->ID));
|
||||
@ -442,10 +442,10 @@ JS
|
||||
$form->setAttribute('data-gridfield', 'File');
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
||||
public function AddForm() {
|
||||
$folder = singleton('Folder');
|
||||
$form = CMSForm::create(
|
||||
$form = CMSForm::create(
|
||||
$this,
|
||||
'AddForm',
|
||||
new FieldList(
|
||||
@ -462,31 +462,31 @@ JS
|
||||
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
||||
// TODO Can't merge $FormAttributes in template at the moment
|
||||
$form->addExtraClass('add-form cms-add-form cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses());
|
||||
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new group and return its details suitable for ajax.
|
||||
*
|
||||
*
|
||||
* @todo Move logic into Folder class, and use LeftAndMain->doAdd() default implementation.
|
||||
*/
|
||||
public function doAdd($data, $form) {
|
||||
$class = $this->stat('tree_class');
|
||||
|
||||
|
||||
// check create permissions
|
||||
if(!singleton($class)->canCreate()) return Security::permissionFailure($this);
|
||||
|
||||
// check addchildren permissions
|
||||
if(
|
||||
singleton($class)->hasExtension('Hierarchy')
|
||||
singleton($class)->hasExtension('Hierarchy')
|
||||
&& isset($data['ParentID'])
|
||||
&& is_numeric($data['ParentID'])
|
||||
&& $data['ParentID']
|
||||
) {
|
||||
$parentRecord = DataObject::get_by_id($class, $data['ParentID']);
|
||||
if(
|
||||
$parentRecord->hasMethod('canAddChildren')
|
||||
$parentRecord->hasMethod('canAddChildren')
|
||||
&& !$parentRecord->canAddChildren()
|
||||
) return Security::permissionFailure($this);
|
||||
} else {
|
||||
@ -496,8 +496,8 @@ JS
|
||||
$parent = (isset($data['ParentID']) && is_numeric($data['ParentID'])) ? (int)$data['ParentID'] : 0;
|
||||
$name = (isset($data['Name'])) ? basename($data['Name']) : _t('AssetAdmin.NEWFOLDER',"NewFolder");
|
||||
if(!$parentRecord || !$parentRecord->ID) $parent = 0;
|
||||
|
||||
// Get the folder to be created
|
||||
|
||||
// Get the folder to be created
|
||||
if($parentRecord && $parentRecord->ID) $filename = $parentRecord->FullPath . $name;
|
||||
else $filename = ASSETS_PATH . '/' . $name;
|
||||
|
||||
@ -505,22 +505,22 @@ JS
|
||||
if(!file_exists(ASSETS_PATH)) {
|
||||
mkdir(ASSETS_PATH);
|
||||
}
|
||||
|
||||
|
||||
$record = new Folder();
|
||||
$record->ParentID = $parent;
|
||||
$record->Name = $record->Title = basename($filename);
|
||||
|
||||
// Ensure uniqueness
|
||||
// Ensure uniqueness
|
||||
$i = 2;
|
||||
$baseFilename = substr($record->Filename, 0, -1) . '-';
|
||||
while(file_exists($record->FullPath)) {
|
||||
$record->Filename = $baseFilename . $i . '/';
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
$record->Name = $record->Title = basename($record->Filename);
|
||||
$record->write();
|
||||
|
||||
|
||||
mkdir($record->FullPath);
|
||||
chmod($record->FullPath, Filesystem::config()->file_create_mask);
|
||||
|
||||
@ -545,17 +545,17 @@ JS
|
||||
$this->setCurrentPageID(null);
|
||||
return new Folder();
|
||||
}
|
||||
|
||||
|
||||
public function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $numChildrenMethod = null, $filterFunction = null, $minNodeCount = 30) {
|
||||
if (!$childrenMethod) $childrenMethod = 'ChildFolders';
|
||||
if (!$numChildrenMethod) $numChildrenMethod = 'numChildFolders';
|
||||
return parent::getSiteTreeFor($className, $rootID, $childrenMethod, $numChildrenMethod, $filterFunction, $minNodeCount);
|
||||
}
|
||||
|
||||
|
||||
public function getCMSTreeTitle() {
|
||||
return Director::absoluteBaseURL() . "assets";
|
||||
}
|
||||
|
||||
|
||||
public function SiteTreeAsUL() {
|
||||
return $this->getSiteTreeFor($this->stat('tree_class'), null, 'ChildFolders', 'numChildFolders');
|
||||
}
|
||||
@ -571,16 +571,16 @@ JS
|
||||
public function doSync() {
|
||||
$message = Filesystem::sync();
|
||||
$this->response->addHeader('X-Status', rawurlencode($message));
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* #################################
|
||||
* Garbage collection.
|
||||
* #################################
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Removes all unused thumbnails from the file store
|
||||
* and returns the status of the process to the user.
|
||||
@ -588,42 +588,42 @@ JS
|
||||
public function deleteunusedthumbnails($request) {
|
||||
// Protect against CSRF on destructive action
|
||||
if(!SecurityToken::inst()->checkRequest($request)) return $this->httpError(400);
|
||||
|
||||
|
||||
$count = 0;
|
||||
$thumbnails = $this->getUnusedThumbnails();
|
||||
|
||||
|
||||
if($thumbnails) {
|
||||
foreach($thumbnails as $thumbnail) {
|
||||
unlink(ASSETS_PATH . "/" . $thumbnail);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$message = _t(
|
||||
'AssetAdmin.THUMBSDELETED',
|
||||
'{count} unused thumbnails have been deleted',
|
||||
'AssetAdmin.THUMBSDELETED',
|
||||
'{count} unused thumbnails have been deleted',
|
||||
array('count' => $count)
|
||||
);
|
||||
$this->response->addHeader('X-Status', rawurlencode($message));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates array containg all unused thumbnails.
|
||||
*
|
||||
*
|
||||
* Array is created in three steps:
|
||||
* 1. Scan assets folder and retrieve all thumbnails
|
||||
* 2. Scan all HTMLField in system and retrieve thumbnails from them.
|
||||
* 3. Count difference between two sets (array_diff)
|
||||
*
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
private function getUnusedThumbnails() {
|
||||
$allThumbnails = array();
|
||||
$usedThumbnails = array();
|
||||
$dirIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(ASSETS_PATH));
|
||||
$classes = ClassInfo::subclassesFor('SiteTree');
|
||||
|
||||
|
||||
if($dirIterator) {
|
||||
foreach($dirIterator as $file) {
|
||||
if($file->isFile()) {
|
||||
@ -637,26 +637,26 @@ JS
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($classes) {
|
||||
foreach($classes as $className) {
|
||||
$SNG_class = singleton($className);
|
||||
$objects = DataObject::get($className);
|
||||
|
||||
|
||||
if($objects !== NULL) {
|
||||
foreach($objects as $object) {
|
||||
foreach($SNG_class->db() as $fieldName => $fieldType) {
|
||||
if($fieldType == 'HTMLText') {
|
||||
$url1 = HTTP::findByTagAndAttribute($object->$fieldName,array('img' => 'src'));
|
||||
|
||||
|
||||
if($url1 != NULL) {
|
||||
$usedThumbnails[] = substr($url1[0], strpos($url1[0], '/assets/') + 8);
|
||||
}
|
||||
|
||||
|
||||
if($object->latestPublished > 0) {
|
||||
$object = Versioned::get_latest_version($className, $object->ID);
|
||||
$url2 = HTTP::findByTagAndAttribute($object->$fieldName, array('img' => 'src'));
|
||||
|
||||
|
||||
if($url2 != NULL) {
|
||||
$usedThumbnails[] = substr($url2[0], strpos($url2[0], '/assets/') + 8);
|
||||
}
|
||||
@ -667,7 +667,7 @@ JS
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return array_diff($allThumbnails, $usedThumbnails);
|
||||
}
|
||||
|
||||
@ -711,12 +711,12 @@ JS
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* Delete multiple {@link Folder} records (and the associated filesystem nodes).
|
||||
* Usually used through the {@link AssetAdmin} interface.
|
||||
*
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage batchactions
|
||||
*/
|
||||
@ -731,10 +731,10 @@ class AssetAdmin_DeleteBatchAction extends CMSBatchAction {
|
||||
'modified'=>array(),
|
||||
'deleted'=>array()
|
||||
);
|
||||
|
||||
|
||||
foreach($records as $record) {
|
||||
$id = $record->ID;
|
||||
|
||||
|
||||
// Perform the action
|
||||
if($record->canDelete()) $record->delete();
|
||||
|
||||
|
@ -4,29 +4,29 @@
|
||||
*
|
||||
* This class creates a 2-frame layout - left-tree and right-form - to sit beneath the main
|
||||
* admin menu.
|
||||
*
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage controller
|
||||
* @todo Create some base classes to contain the generic functionality that will be replicated.
|
||||
*/
|
||||
class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionProvider {
|
||||
|
||||
|
||||
private static $url_segment = 'pages';
|
||||
|
||||
|
||||
private 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
|
||||
private static $url_priority = 39;
|
||||
|
||||
|
||||
private static $menu_title = 'Edit Page';
|
||||
|
||||
|
||||
private static $menu_priority = 10;
|
||||
|
||||
|
||||
private static $tree_class = "SiteTree";
|
||||
|
||||
|
||||
private static $subitem_class = "Member";
|
||||
|
||||
|
||||
/**
|
||||
* Amount of results showing on a single page.
|
||||
*
|
||||
@ -34,7 +34,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
* @var int
|
||||
*/
|
||||
private static $page_length = 15;
|
||||
|
||||
|
||||
private static $allowed_actions = array(
|
||||
'archive',
|
||||
'buildbrokenlinks',
|
||||
@ -65,20 +65,20 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
* @config
|
||||
*/
|
||||
private static $enabled_legacy_actions = array();
|
||||
|
||||
|
||||
public function init() {
|
||||
// set reading lang
|
||||
if(SiteTree::has_extension('Translatable') && !$this->getRequest()->isAjax()) {
|
||||
Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SiteTree')));
|
||||
}
|
||||
|
||||
|
||||
parent::init();
|
||||
|
||||
Versioned::reading_stage("Stage");
|
||||
|
||||
|
||||
Requirements::css(CMS_DIR . '/css/screen.css');
|
||||
Requirements::customCSS($this->generatePageIconsCss());
|
||||
|
||||
|
||||
Requirements::combine_files(
|
||||
'cmsmain.js',
|
||||
array_merge(
|
||||
@ -97,7 +97,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
|
||||
CMSBatchActionHandler::register('publish', 'CMSBatchAction_Publish');
|
||||
CMSBatchActionHandler::register('unpublish', 'CMSBatchAction_Unpublish');
|
||||
|
||||
|
||||
|
||||
// Check legacy actions
|
||||
$legacy = $this->config()->enabled_legacy_actions;
|
||||
@ -144,7 +144,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
public 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.
|
||||
@ -153,7 +153,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
if(!$page) {
|
||||
$page = $this->currentPage();
|
||||
}
|
||||
|
||||
|
||||
if($page) {
|
||||
$nav = SilverStripeNavigator::get_for_record($page);
|
||||
return $nav['items'];
|
||||
@ -305,10 +305,10 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
$this->extend('updateExtraTreeTools', $html);
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a Form for page searching for use in templates.
|
||||
*
|
||||
*
|
||||
* Can be modified from a decorator by a 'updateSearchForm' method
|
||||
*
|
||||
* @return Form
|
||||
@ -318,7 +318,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
$content = new TextField('q[Term]', _t('CMSSearch.FILTERLABELTEXT', 'Search'));
|
||||
$dateHeader = new HeaderField('q[Date]', _t('CMSSearch.PAGEFILTERDATEHEADING', 'Last edited'), 4);
|
||||
$dateFrom = new DateField(
|
||||
'q[LastEditedFrom]',
|
||||
'q[LastEditedFrom]',
|
||||
_t('CMSSearch.FILTERDATEFROM', 'From')
|
||||
);
|
||||
$dateFrom->setConfig('showcalendar', true);
|
||||
@ -328,17 +328,17 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
);
|
||||
$dateTo->setConfig('showcalendar', true);
|
||||
$pageFilter = new DropdownField(
|
||||
'q[FilterClass]',
|
||||
_t('CMSMain.PAGES', 'Page status'),
|
||||
'q[FilterClass]',
|
||||
_t('CMSMain.PAGES', 'Page status'),
|
||||
CMSSiteTreeFilter::get_all_filters()
|
||||
);
|
||||
$pageClasses = new DropdownField(
|
||||
'q[ClassName]',
|
||||
_t('CMSMain.PAGETYPEOPT', 'Page type', 'Dropdown for limiting search to a page type'),
|
||||
'q[ClassName]',
|
||||
_t('CMSMain.PAGETYPEOPT', 'Page type', 'Dropdown for limiting search to a page type'),
|
||||
$this->getPageTypes()
|
||||
);
|
||||
$pageClasses->setEmptyString(_t('CMSMain.PAGETYPEANYOPT','Any'));
|
||||
|
||||
|
||||
// Group the Datefields
|
||||
$dateGroup = new FieldGroup(
|
||||
$dateHeader,
|
||||
@ -346,7 +346,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
$dateTo
|
||||
);
|
||||
$dateGroup->setFieldHolderTemplate('FieldGroup_DefaultFieldHolder')->addExtraClass('stacked');
|
||||
|
||||
|
||||
// Create the Field list
|
||||
$fields = new FieldList(
|
||||
$content,
|
||||
@ -354,7 +354,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
$pageFilter,
|
||||
$pageClasses
|
||||
);
|
||||
|
||||
|
||||
// Create the Search and Reset action
|
||||
$actions = new FieldList(
|
||||
FormAction::create('doSearch', _t('CMSMain_left_ss.APPLY_FILTER', 'Search'))
|
||||
@ -366,7 +366,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
foreach($actions->dataFields() as $action) {
|
||||
$action->setUseButtonTag(true);
|
||||
}
|
||||
|
||||
|
||||
// Create the form
|
||||
$form = Form::create($this, 'SearchForm', $fields, $actions)
|
||||
->addExtraClass('cms-search-form')
|
||||
@ -374,19 +374,19 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
->setFormAction($this->Link())
|
||||
->disableSecurityToken()
|
||||
->unsetValidator();
|
||||
|
||||
|
||||
// Load the form with previously sent search data
|
||||
$form->loadDataFrom($this->getRequest()->getVars());
|
||||
|
||||
// Allow decorators to modify the form
|
||||
$this->extend('updateSearchForm', $form);
|
||||
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a sorted array suitable for a dropdown with pagetypes and their translated name
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getPageTypes() {
|
||||
@ -397,7 +397,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
asort($pageTypes);
|
||||
return $pageTypes;
|
||||
}
|
||||
|
||||
|
||||
public function doSearch($data, $form) {
|
||||
return $this->getsubtree($this->getRequest());
|
||||
}
|
||||
@ -421,7 +421,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
/**
|
||||
* Create serialized JSON string with site tree hints data to be injected into
|
||||
* 'data-hints' attribute of root node of jsTree.
|
||||
*
|
||||
*
|
||||
* @return String Serialized JSON
|
||||
*/
|
||||
public function SiteTreeHints() {
|
||||
@ -506,18 +506,18 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
if($instance->stat('need_permission') && !$this->can(singleton($class)->stat('need_permission'))) continue;
|
||||
|
||||
$addAction = $instance->i18n_singular_name();
|
||||
|
||||
|
||||
// Get description (convert 'Page' to 'SiteTree' for correct localization lookups)
|
||||
$description = _t((($class == 'Page') ? 'SiteTree' : $class) . '.DESCRIPTION');
|
||||
|
||||
if(!$description) {
|
||||
$description = $instance->uninherited('description');
|
||||
}
|
||||
|
||||
|
||||
if($class == 'Page' && !$description) {
|
||||
$description = singleton('SiteTree')->uninherited('description');
|
||||
}
|
||||
|
||||
|
||||
$result->push(new ArrayData(array(
|
||||
'ClassName' => $class,
|
||||
'AddAction' => $addAction,
|
||||
@ -527,9 +527,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
'Title' => singleton($class)->i18n_singular_name(),
|
||||
)));
|
||||
}
|
||||
|
||||
|
||||
$result = $result->sort('AddAction');
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -545,12 +545,12 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
|
||||
if($id instanceof $treeClass) {
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
else if($id && is_numeric($id)) {
|
||||
if($this->getRequest()->getVar('Version')) {
|
||||
$versionID = (int) $this->getRequest()->getVar('Version');
|
||||
}
|
||||
|
||||
|
||||
if($versionID) {
|
||||
$record = Versioned::get_version($treeClass, $id, $versionID);
|
||||
} else {
|
||||
@ -566,7 +566,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
$record = DataObject::get_by_id($treeClass, $id);
|
||||
if($record) Versioned::set_reading_mode('');
|
||||
}
|
||||
|
||||
|
||||
// Then, try getting a deleted record
|
||||
if(!$record) {
|
||||
$record = Versioned::get_latest_version($treeClass, $id);
|
||||
@ -577,7 +577,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
* we should not check their locale matches the Translatable::get_current_locale,
|
||||
* here as long as we all the HTTPRequest is init with right locale.
|
||||
* This bit breaks the all FileIFrameField functions if the field is used in CMS
|
||||
* and its relevent ajax calles, like loading the tree dropdown for TreeSelectorField.
|
||||
* and its relevent ajax calles, like loading the tree dropdown for TreeSelectorField.
|
||||
*/
|
||||
/* if($record && SiteTree::has_extension('Translatable') && $record->Locale && $record->Locale != Translatable::get_current_locale()) {
|
||||
$record = null;
|
||||
@ -589,7 +589,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
return $this->getNewItem($id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Int $id
|
||||
* @param FieldList $fields
|
||||
@ -599,7 +599,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
|
||||
if(!$id) $id = $this->currentPageID();
|
||||
$form = parent::getEditForm($id);
|
||||
|
||||
|
||||
// TODO Duplicate record fetching (see parent implementation)
|
||||
$record = $this->getRecord($id);
|
||||
if($record && !$record->canView()) return Security::permissionFailure($this);
|
||||
@ -626,14 +626,14 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
if($stageLink) $stageLinkField->setValue($stageLink);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Added in-line to the form, but plucked into different view by LeftAndMain.Preview.js upon load
|
||||
if(in_array('CMSPreviewable', class_implements($record)) && !$fields->fieldByName('SilverStripeNavigator')) {
|
||||
$navField = new LiteralField('SilverStripeNavigator', $this->getSilverStripeNavigator());
|
||||
$navField->setAllowHTML(true);
|
||||
$fields->push($navField);
|
||||
}
|
||||
|
||||
|
||||
// getAllCMSActions can be used to completely redefine the action list
|
||||
if($record->hasMethod('getAllCMSActions')) {
|
||||
$actions = $record->getAllCMSActions();
|
||||
@ -656,14 +656,14 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
// Use <button> to allow full jQuery UI styling
|
||||
$actionsFlattened = $actions->dataFields();
|
||||
if($actionsFlattened) foreach($actionsFlattened as $action) $action->setUseButtonTag(true);
|
||||
|
||||
|
||||
if($record->hasMethod('getCMSValidator')) {
|
||||
$validator = $record->getCMSValidator();
|
||||
} else {
|
||||
$validator = new RequiredFields();
|
||||
}
|
||||
|
||||
$form = CMSForm::create(
|
||||
|
||||
$form = CMSForm::create(
|
||||
$this, "EditForm", $fields, $actions, $validator
|
||||
)->setHTMLID('Form_EditForm');
|
||||
$form->setResponseNegotiator($this->getResponseNegotiator());
|
||||
@ -747,7 +747,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
->addHeader('Content-Type', 'application/json; charset=utf-8')
|
||||
->setBody(Convert::raw2json($disallowedChildren));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Safely reconstruct a selected filter from a given set of query parameters
|
||||
*
|
||||
@ -768,7 +768,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
* Returns the pages meet a certain criteria as {@see CMSSiteTreeFilter} or the subpages of a parent page
|
||||
* defaulting to no filter and show all pages in first level.
|
||||
* Doubles as search results, if any search parameters are set through {@link SearchForm()}.
|
||||
*
|
||||
*
|
||||
* @param array $params Search filter criteria
|
||||
* @param int $parentID Optional parent node to filter on (can't be combined with other search criteria)
|
||||
* @return SS_List
|
||||
@ -783,11 +783,11 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
return $list->filter("ParentID", $parentID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function ListViewForm() {
|
||||
$params = $this->getRequest()->requestVar('q');
|
||||
$list = $this->getList($params, $parentID = $this->getRequest()->requestVar('ParentID'));
|
||||
$gridFieldConfig = GridFieldConfig::create()->addComponents(
|
||||
$gridFieldConfig = GridFieldConfig::create()->addComponents(
|
||||
new GridFieldSortableHeader(),
|
||||
new GridFieldDataColumns(),
|
||||
new GridFieldPaginator(self::config()->page_length)
|
||||
@ -830,7 +830,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
return sprintf(
|
||||
'<a class="cms-panel-link list-children-link" data-pjax-target="ListViewForm,Breadcrumbs" href="%s">%s</a>',
|
||||
Controller::join_links(
|
||||
$controller->Link(),
|
||||
$controller->Link(),
|
||||
sprintf("?ParentID=%d&view=list", (int)$item->ID)
|
||||
),
|
||||
$num
|
||||
@ -848,8 +848,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
);
|
||||
}
|
||||
));
|
||||
|
||||
$listview = CMSForm::create(
|
||||
|
||||
$listview = CMSForm::create(
|
||||
$this,
|
||||
'ListViewForm',
|
||||
new FieldList($gridField),
|
||||
@ -859,14 +859,14 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
$listview->setResponseNegotiator($this->getResponseNegotiator());
|
||||
|
||||
$this->extend('updateListView', $listview);
|
||||
|
||||
|
||||
$listview->disableSecurityToken();
|
||||
return $listview;
|
||||
}
|
||||
|
||||
|
||||
public function currentPageID() {
|
||||
$id = parent::currentPageID();
|
||||
|
||||
|
||||
$this->extend('updateCurrentPageID', $id);
|
||||
|
||||
// Fall back to homepage record
|
||||
@ -877,10 +877,10 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
));
|
||||
if($homepageRecord) $id = $homepageRecord->ID;
|
||||
}
|
||||
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------//
|
||||
// Data saving handlers
|
||||
|
||||
@ -900,7 +900,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
if(!singleton($this->stat('tree_class'))->canCreate()) return Security::permissionFailure($this);
|
||||
$record = $this->getNewItem($id, false);
|
||||
}
|
||||
|
||||
|
||||
// TODO Coupling to SiteTree
|
||||
$record->HasBrokenLink = 0;
|
||||
$record->HasBrokenFile = 0;
|
||||
@ -921,11 +921,11 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
// save form data into record
|
||||
$form->saveInto($record);
|
||||
$record->write();
|
||||
|
||||
|
||||
// If the 'Save & Publish' button was clicked, also publish the page
|
||||
if (isset($data['publish']) && $data['publish'] == 1) {
|
||||
$record->doPublish();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->getResponseNegotiator()->respond($this->getRequest());
|
||||
}
|
||||
@ -944,7 +944,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
}
|
||||
throw new SS_HTTPResponse_Exception($response);
|
||||
}
|
||||
|
||||
|
||||
$newItem = new $className();
|
||||
|
||||
if( !$suffix ) {
|
||||
@ -977,25 +977,25 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
|
||||
# Some modules like subsites add extra fields that need to be set when the new item is created
|
||||
$this->extend('augmentNewSiteTreeItem', $newItem);
|
||||
|
||||
|
||||
return $newItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the page from live. This means a page in draft mode might still exist.
|
||||
*
|
||||
*
|
||||
* @see delete()
|
||||
*/
|
||||
public function deletefromlive($data, $form) {
|
||||
Versioned::reading_stage('Live');
|
||||
$record = DataObject::get_by_id("SiteTree", $data['ID']);
|
||||
if($record && !($record->canDelete() && $record->canDeleteFromLive())) return Security::permissionFailure($this);
|
||||
|
||||
|
||||
$descRemoved = '';
|
||||
$descendantsRemoved = 0;
|
||||
$recordTitle = $record->Title;
|
||||
$recordID = $record->ID;
|
||||
|
||||
|
||||
// before deleting the records, get the descendants of this tree
|
||||
if($record) {
|
||||
$descendantIDs = $record->getDescendantIDList();
|
||||
@ -1016,8 +1016,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
|
||||
if(isset($descendantsRemoved)) {
|
||||
$descRemoved = ' ' . _t(
|
||||
'CMSMain.DESCREMOVED',
|
||||
'and {count} descendants',
|
||||
'CMSMain.DESCREMOVED',
|
||||
'and {count} descendants',
|
||||
array('count' => $descendantsRemoved)
|
||||
);
|
||||
} else {
|
||||
@ -1028,13 +1028,13 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
'X-Status',
|
||||
rawurlencode(
|
||||
_t(
|
||||
'CMSMain.REMOVED',
|
||||
'CMSMain.REMOVED',
|
||||
'Deleted \'{title}\'{description} from live site',
|
||||
array('title' => $recordTitle, 'description' => $descRemoved)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Even if the record has been deleted from stage and live, it can be viewed in "archive mode"
|
||||
return $this->getResponseNegotiator()->respond($this->getRequest());
|
||||
}
|
||||
@ -1044,7 +1044,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
*/
|
||||
public function performPublish($record) {
|
||||
if($record && !$record->canPublish()) return Security::permissionFailure($this);
|
||||
|
||||
|
||||
$record->doPublish();
|
||||
}
|
||||
|
||||
@ -1052,16 +1052,16 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
* Reverts a page by publishing it to live.
|
||||
* Use {@link restorepage()} if you want to restore a page
|
||||
* which was deleted from draft without publishing.
|
||||
*
|
||||
*
|
||||
* @uses SiteTree->doRevertToLive()
|
||||
*/
|
||||
public function revert($data, $form) {
|
||||
if(!isset($data['ID'])) return new SS_HTTPResponse("Please pass an ID in the form content", 400);
|
||||
|
||||
|
||||
$id = (int) $data['ID'];
|
||||
$restoredPage = Versioned::get_latest_version("SiteTree", $id);
|
||||
if(!$restoredPage) return new SS_HTTPResponse("SiteTree #$id not found", 400);
|
||||
|
||||
|
||||
$record = Versioned::get_one_by_stage('SiteTree', 'Live', array(
|
||||
'"SiteTree_Live"."ID"' => $id
|
||||
));
|
||||
@ -1072,7 +1072,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
if(!$record || !$record->ID) throw new SS_HTTPResponse_Exception("Bad record ID #$id", 404);
|
||||
|
||||
$record->doRevertToLive();
|
||||
|
||||
|
||||
$this->response->addHeader(
|
||||
'X-Status',
|
||||
rawurlencode(_t(
|
||||
@ -1082,10 +1082,10 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
array('title' => $record->Title)
|
||||
))
|
||||
);
|
||||
|
||||
|
||||
return $this->getResponseNegotiator()->respond($this->getRequest());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete the current page from draft stage.
|
||||
* @see deletefromlive()
|
||||
@ -1096,7 +1096,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
$record = DataObject::get_by_id("SiteTree", $id);
|
||||
if($record && !$record->canDelete()) return Security::permissionFailure();
|
||||
if(!$record || !$record->ID) throw new SS_HTTPResponse_Exception("Bad record ID #$id", 404);
|
||||
|
||||
|
||||
// Delete record
|
||||
$record->delete();
|
||||
|
||||
@ -1104,7 +1104,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
'X-Status',
|
||||
rawurlencode(sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"), $record->Title))
|
||||
);
|
||||
|
||||
|
||||
// Even if the record has been deleted from stage and live, it can be viewed in "archive mode"
|
||||
return $this->getResponseNegotiator()->respond($this->getRequest());
|
||||
}
|
||||
@ -1139,24 +1139,24 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
|
||||
public function publish($data, $form) {
|
||||
$data['publish'] = '1';
|
||||
|
||||
|
||||
return $this->save($data, $form);
|
||||
}
|
||||
|
||||
public function unpublish($data, $form) {
|
||||
$className = $this->stat('tree_class');
|
||||
$record = DataObject::get_by_id($className, $data['ID']);
|
||||
|
||||
|
||||
if($record && !$record->canDeleteFromLive()) return Security::permissionFailure($this);
|
||||
if(!$record || !$record->ID) throw new SS_HTTPResponse_Exception("Bad record ID #" . (int)$data['ID'], 404);
|
||||
|
||||
|
||||
$record->doUnpublish();
|
||||
|
||||
|
||||
$this->response->addHeader(
|
||||
'X-Status',
|
||||
rawurlencode(_t('CMSMain.REMOVEDPAGE',"Removed '{title}' from the published site", array('title' => $record->Title)))
|
||||
);
|
||||
|
||||
|
||||
return $this->getResponseNegotiator()->respond($this->getRequest());
|
||||
}
|
||||
|
||||
@ -1180,13 +1180,13 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
*/
|
||||
public function doRollback($data, $form) {
|
||||
$this->extend('onBeforeRollback', $data['ID']);
|
||||
|
||||
|
||||
$id = (isset($data['ID'])) ? (int) $data['ID'] : null;
|
||||
$version = (isset($data['Version'])) ? (int) $data['Version'] : null;
|
||||
|
||||
$record = DataObject::get_by_id($this->stat('tree_class'), $id);
|
||||
if($record && !$record->canEdit()) return Security::permissionFailure($this);
|
||||
|
||||
|
||||
if($version) {
|
||||
$record->doRollbackTo($version);
|
||||
$message = _t(
|
||||
@ -1202,14 +1202,14 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
}
|
||||
|
||||
$this->response->addHeader('X-Status', rawurlencode($message));
|
||||
|
||||
|
||||
// Can be used in different contexts: In normal page edit view, in which case the redirect won't have any effect.
|
||||
// Or in history view, in which case a revert causes the CMS to re-load the edit view.
|
||||
// The X-Pjax header forces a "full" content refresh on redirect.
|
||||
$url = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $record->ID);
|
||||
$this->response->addHeader('X-ControllerURL', $url);
|
||||
$this->getRequest()->addHeader('X-Pjax', 'Content');
|
||||
$this->response->addHeader('X-Pjax', 'Content');
|
||||
$this->response->addHeader('X-Pjax', 'Content');
|
||||
|
||||
return $this->getResponseNegotiator()->respond($this->getRequest());
|
||||
}
|
||||
@ -1220,7 +1220,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
public function batchactions() {
|
||||
return new CMSBatchActionHandler($this, 'batchactions');
|
||||
}
|
||||
|
||||
|
||||
public function BatchActionParameters() {
|
||||
$batchActions = CMSBatchActionHandler::config()->batch_actions;
|
||||
|
||||
@ -1238,7 +1238,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
$pageHtml = '';
|
||||
foreach($forms as $urlSegment => $html) {
|
||||
$pageHtml .= "<div class=\"params\" id=\"BatchActionParameters_$urlSegment\">$html</div>\n\n";
|
||||
}
|
||||
}
|
||||
return new LiteralField("BatchActionParameters", '<div id="BatchActionParameters" style="display:none">'.$pageHtml.'</div>');
|
||||
}
|
||||
/**
|
||||
@ -1247,14 +1247,14 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
public function BatchActionList() {
|
||||
return $this->batchactions()->batchActionList();
|
||||
}
|
||||
|
||||
|
||||
public function buildbrokenlinks($request) {
|
||||
// Protect against CSRF on destructive action
|
||||
if(!SecurityToken::inst()->checkRequest($request)) return $this->httpError(400);
|
||||
|
||||
|
||||
increase_time_limit_to();
|
||||
increase_memory_limit_to();
|
||||
|
||||
|
||||
if($this->urlParams['ID']) {
|
||||
$newPageSet[] = DataObject::get_by_id("Page", $this->urlParams['ID']);
|
||||
} else {
|
||||
@ -1289,20 +1289,20 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
|
||||
increase_time_limit_to();
|
||||
increase_memory_limit_to();
|
||||
|
||||
|
||||
$response = "";
|
||||
|
||||
if(isset($this->requestParams['confirm'])) {
|
||||
// Protect against CSRF on destructive action
|
||||
if(!SecurityToken::inst()->checkRequest($request)) return $this->httpError(400);
|
||||
|
||||
|
||||
$start = 0;
|
||||
$pages = DataObject::get("SiteTree", "", "", "", "$start,30");
|
||||
$count = 0;
|
||||
while($pages) {
|
||||
foreach($pages as $page) {
|
||||
if($page && !$page->canPublish()) return Security::permissionFailure($this);
|
||||
|
||||
|
||||
$page->doPublish();
|
||||
$page->destroy();
|
||||
unset($page);
|
||||
@ -1334,10 +1334,10 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
. $tokenHtml .
|
||||
'</form>';
|
||||
}
|
||||
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Restore a completely deleted page from the SiteTree_versions table.
|
||||
*/
|
||||
@ -1345,29 +1345,29 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
if(!isset($data['ID']) || !is_numeric($data['ID'])) {
|
||||
return new SS_HTTPResponse("Please pass an ID in the form content", 400);
|
||||
}
|
||||
|
||||
|
||||
$id = (int)$data['ID'];
|
||||
$restoredPage = Versioned::get_latest_version("SiteTree", $id);
|
||||
if(!$restoredPage) return new SS_HTTPResponse("SiteTree #$id not found", 400);
|
||||
|
||||
|
||||
$restoredPage = $restoredPage->doRestoreToStage();
|
||||
|
||||
|
||||
$this->response->addHeader(
|
||||
'X-Status',
|
||||
rawurlencode(_t(
|
||||
'CMSMain.RESTORED',
|
||||
"Restored '{title}' successfully",
|
||||
"Restored '{title}' successfully",
|
||||
array('title' => $restoredPage->Title)
|
||||
))
|
||||
);
|
||||
|
||||
|
||||
return $this->getResponseNegotiator()->respond($this->getRequest());
|
||||
}
|
||||
|
||||
public function duplicate($request) {
|
||||
// Protect against CSRF on destructive action
|
||||
if(!SecurityToken::inst()->checkRequest($request)) return $this->httpError(400);
|
||||
|
||||
|
||||
if(($id = $this->urlParams['ID']) && is_numeric($id)) {
|
||||
$page = DataObject::get_by_id("SiteTree", $id);
|
||||
if($page && (!$page->canEdit() || !$page->canCreate(null, array('Parent' => $page->Parent())))) {
|
||||
@ -1376,26 +1376,26 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
if(!$page || !$page->ID) throw new SS_HTTPResponse_Exception("Bad record ID #$id", 404);
|
||||
|
||||
$newPage = $page->duplicate();
|
||||
|
||||
|
||||
// ParentID can be hard-set in the URL. This is useful for pages with multiple parents
|
||||
if(isset($_GET['parentID']) && is_numeric($_GET['parentID'])) {
|
||||
$newPage->ParentID = $_GET['parentID'];
|
||||
$newPage->write();
|
||||
}
|
||||
|
||||
|
||||
$this->response->addHeader(
|
||||
'X-Status',
|
||||
rawurlencode(_t(
|
||||
'CMSMain.DUPLICATED',
|
||||
"Duplicated '{title}' successfully",
|
||||
"Duplicated '{title}' successfully",
|
||||
array('title' => $newPage->Title)
|
||||
))
|
||||
);
|
||||
$url = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $newPage->ID);
|
||||
$this->response->addHeader('X-ControllerURL', $url);
|
||||
$this->getRequest()->addHeader('X-Pjax', 'Content');
|
||||
$this->response->addHeader('X-Pjax', 'Content');
|
||||
|
||||
$this->response->addHeader('X-Pjax', 'Content');
|
||||
|
||||
return $this->getResponseNegotiator()->respond($this->getRequest());
|
||||
} else {
|
||||
return new SS_HTTPResponse("CMSMain::duplicate() Bad ID: '$id'", 400);
|
||||
@ -1419,21 +1419,21 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
'X-Status',
|
||||
rawurlencode(_t(
|
||||
'CMSMain.DUPLICATEDWITHCHILDREN',
|
||||
"Duplicated '{title}' and children successfully",
|
||||
"Duplicated '{title}' and children successfully",
|
||||
array('title' => $newPage->Title)
|
||||
))
|
||||
);
|
||||
$url = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $newPage->ID);
|
||||
$this->response->addHeader('X-ControllerURL', $url);
|
||||
$this->getRequest()->addHeader('X-Pjax', 'Content');
|
||||
$this->response->addHeader('X-Pjax', 'Content');
|
||||
|
||||
$this->response->addHeader('X-Pjax', 'Content');
|
||||
|
||||
return $this->getResponseNegotiator()->respond($this->getRequest());
|
||||
} else {
|
||||
return new SS_HTTPResponse("CMSMain::duplicatewithchildren() Bad ID: '$id'", 400);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function providePermissions() {
|
||||
$title = _t("CMSPagesController.MENUTITLE", LeftAndMain::menu_title_for_class('CMSPagesController'));
|
||||
return array(
|
||||
|
@ -50,7 +50,7 @@ class CMSPageAddController extends CMSPageEditController {
|
||||
new SelectionGroup_Item(
|
||||
'child',
|
||||
$parentField = new TreeDropdownField(
|
||||
"ParentID",
|
||||
"ParentID",
|
||||
"",
|
||||
'SiteTree',
|
||||
'ID',
|
||||
@ -61,8 +61,8 @@ class CMSPageAddController extends CMSPageEditController {
|
||||
)
|
||||
),
|
||||
$typeField = new OptionsetField(
|
||||
"PageType",
|
||||
sprintf($numericLabelTmpl, 2, _t('CMSMain.ChoosePageType', 'Choose page type')),
|
||||
"PageType",
|
||||
sprintf($numericLabelTmpl, 2, _t('CMSMain.ChoosePageType', 'Choose page type')),
|
||||
$pageTypes,
|
||||
'Page'
|
||||
),
|
||||
@ -71,7 +71,7 @@ class CMSPageAddController extends CMSPageEditController {
|
||||
sprintf(
|
||||
'<p class="message notice message-restricted">%s</p>',
|
||||
_t(
|
||||
'CMSMain.AddPageRestriction',
|
||||
'CMSMain.AddPageRestriction',
|
||||
'Note: Some page types are not allowed for this selection'
|
||||
)
|
||||
)
|
||||
@ -79,7 +79,7 @@ class CMSPageAddController extends CMSPageEditController {
|
||||
);
|
||||
$parentField->setSearchFunction(function ($sourceObject, $labelField, $search) {
|
||||
return DataObject::get(
|
||||
$sourceObject,
|
||||
$sourceObject,
|
||||
sprintf(
|
||||
"\"MenuTitle\" LIKE '%%%s%%' OR \"Title\" LIKE '%%%s%%'",
|
||||
Convert::raw2sql($search),
|
||||
@ -88,10 +88,10 @@ class CMSPageAddController extends CMSPageEditController {
|
||||
);
|
||||
});
|
||||
|
||||
// TODO Re-enable search once it allows for HTML title display,
|
||||
// TODO Re-enable search once it allows for HTML title display,
|
||||
// see http://open.silverstripe.org/ticket/7455
|
||||
// $parentField->setShowSearch(true);
|
||||
|
||||
|
||||
$parentModeField->addExtraClass('parent-mode');
|
||||
|
||||
// CMSMain->currentPageID() automatically sets the homepage,
|
||||
@ -102,7 +102,7 @@ class CMSPageAddController extends CMSPageEditController {
|
||||
} else {
|
||||
$parentModeField->setValue('top');
|
||||
}
|
||||
|
||||
|
||||
$actions = new FieldList(
|
||||
FormAction::create("doAdd", _t('CMSMain.Create',"Create"))
|
||||
->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')
|
||||
@ -111,10 +111,10 @@ class CMSPageAddController extends CMSPageEditController {
|
||||
->addExtraClass('ss-ui-action-destructive ss-ui-action-cancel')
|
||||
->setUseButtonTag(true)
|
||||
);
|
||||
|
||||
|
||||
$this->extend('updatePageOptions', $fields);
|
||||
|
||||
$form = CMSForm::create(
|
||||
|
||||
$form = CMSForm::create(
|
||||
$this, "AddForm", $fields, $actions
|
||||
)->setHTMLID('Form_AddForm');
|
||||
$form->setAttribute('data-hints', $this->SiteTreeHints());
|
||||
@ -140,7 +140,7 @@ class CMSPageAddController extends CMSPageEditController {
|
||||
|
||||
if(is_numeric($parentID) && $parentID > 0) $parentObj = DataObject::get_by_id("SiteTree", $parentID);
|
||||
else $parentObj = null;
|
||||
|
||||
|
||||
if(!$parentObj || !$parentObj->ID) $parentID = 0;
|
||||
|
||||
if(!singleton($className)->canCreate(Member::currentUser(), array('Parent' => $parentObj))) {
|
||||
@ -163,11 +163,11 @@ class CMSPageAddController extends CMSPageEditController {
|
||||
$editController->setCurrentPageID($record->ID);
|
||||
|
||||
Session::set(
|
||||
"FormInfo.Form_EditForm.formError.message",
|
||||
"FormInfo.Form_EditForm.formError.message",
|
||||
_t('CMSMain.PageAdded', 'Successfully created page')
|
||||
);
|
||||
Session::set("FormInfo.Form_EditForm.formError.type", 'good');
|
||||
|
||||
|
||||
return $this->redirect(Controller::join_links(singleton('CMSPageEditController')->Link('show'), $record->ID));
|
||||
}
|
||||
|
||||
|
@ -12,14 +12,14 @@ class CMSPageHistoryController extends CMSMain {
|
||||
private static $menu_title = 'History';
|
||||
private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
|
||||
private static $session_namespace = 'CMSMain';
|
||||
|
||||
|
||||
private static $allowed_actions = array(
|
||||
'VersionsForm',
|
||||
'CompareVersionsForm',
|
||||
'show',
|
||||
'compare'
|
||||
);
|
||||
|
||||
|
||||
private static $url_handlers = array(
|
||||
'$Action/$ID/$VersionID/$OtherVersionID' => 'handleAction'
|
||||
);
|
||||
@ -37,14 +37,14 @@ class CMSPageHistoryController extends CMSMain {
|
||||
});
|
||||
return $negotiator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function show($request) {
|
||||
$form = $this->ShowVersionForm($request->param('VersionID'));
|
||||
|
||||
|
||||
$negotiator = $this->getResponseNegotiator();
|
||||
$controller = $this;
|
||||
$negotiator->setCallback('CurrentForm', function() use(&$controller, &$form) {
|
||||
@ -56,14 +56,14 @@ class CMSPageHistoryController extends CMSMain {
|
||||
|
||||
return $negotiator->respond($request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param SS_HTTPRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function compare($request) {
|
||||
$form = $this->CompareVersionsForm(
|
||||
$request->param('VersionID'),
|
||||
$request->param('VersionID'),
|
||||
$request->param('OtherVersionID')
|
||||
);
|
||||
|
||||
@ -88,13 +88,13 @@ class CMSPageHistoryController extends CMSMain {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the read only version of the edit form. Detaches all {@link FormAction}
|
||||
* Returns the read only version of the edit form. Detaches all {@link FormAction}
|
||||
* instances attached since only action relates to revert.
|
||||
*
|
||||
* Permission checking is done at the {@link CMSMain::getEditForm()} level.
|
||||
*
|
||||
*
|
||||
* @param int $id ID of the record to show
|
||||
* @param array $fields optional
|
||||
* @param int $versionID
|
||||
@ -104,10 +104,10 @@ class CMSPageHistoryController extends CMSMain {
|
||||
*/
|
||||
public function getEditForm($id = null, $fields = null, $versionID = null, $compareID = null) {
|
||||
if(!$id) $id = $this->currentPageID();
|
||||
|
||||
|
||||
$record = $this->getRecord($id, $versionID);
|
||||
$versionID = ($record) ? $record->Version : $versionID;
|
||||
|
||||
|
||||
$form = parent::getEditForm($record, ($record) ? $record->getCMSFields() : null);
|
||||
// Respect permission failures from parent implementation
|
||||
if(!($form instanceof Form)) return $form;
|
||||
@ -118,14 +118,14 @@ class CMSPageHistoryController extends CMSMain {
|
||||
$form->setActions(new FieldList(
|
||||
$revert = FormAction::create('doRollback', _t('CMSPageHistoryController.REVERTTOTHISVERSION', 'Revert to this version'))->setUseButtonTag(true)
|
||||
));
|
||||
|
||||
|
||||
$fields = $form->Fields();
|
||||
$fields->removeByName("Status");
|
||||
$fields->push(new HiddenField("ID"));
|
||||
$fields->push(new HiddenField("Version"));
|
||||
|
||||
$fields = $fields->makeReadonly();
|
||||
|
||||
|
||||
$fields = $fields->makeReadonly();
|
||||
|
||||
if($compareID) {
|
||||
$link = Controller::join_links(
|
||||
$this->Link('show'),
|
||||
@ -133,7 +133,7 @@ class CMSPageHistoryController extends CMSMain {
|
||||
);
|
||||
|
||||
$view = _t('CMSPageHistoryController.VIEW',"view");
|
||||
|
||||
|
||||
$message = _t(
|
||||
'CMSPageHistoryController.COMPARINGVERSION',
|
||||
"Comparing versions {version1} and {version2}.",
|
||||
@ -142,7 +142,7 @@ class CMSPageHistoryController extends CMSMain {
|
||||
'version2' => sprintf('%s (<a href="%s">%s</a>)', $compareID, Controller::join_links($link, $compareID), $view)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$revert->setReadonly(true);
|
||||
} else {
|
||||
if($record->isLatestVersion()) {
|
||||
@ -155,8 +155,8 @@ class CMSPageHistoryController extends CMSMain {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$fields->addFieldToTab('Root.Main',
|
||||
|
||||
$fields->addFieldToTab('Root.Main',
|
||||
new LiteralField('CurrentlyViewingMessage', $this->customise(array(
|
||||
'Content' => $message,
|
||||
'Classes' => 'notice'
|
||||
@ -169,23 +169,23 @@ class CMSPageHistoryController extends CMSMain {
|
||||
"ID" => $id,
|
||||
"Version" => $versionID,
|
||||
));
|
||||
|
||||
|
||||
if(($record && $record->isLatestVersion())) {
|
||||
$revert->setReadonly(true);
|
||||
}
|
||||
|
||||
|
||||
$form->removeExtraClass('cms-content');
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Version select form. Main interface between selecting versions to view
|
||||
* Version select form. Main interface between selecting versions to view
|
||||
* and comparing multiple versions.
|
||||
*
|
||||
*
|
||||
* Because we can reload the page directly to a compare view (history/compare/1/2/3)
|
||||
* this form has to adapt to those parameters as well.
|
||||
* this form has to adapt to those parameters as well.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
@ -197,7 +197,7 @@ class CMSPageHistoryController extends CMSMain {
|
||||
$action = $this->getRequest()->param('Action');
|
||||
$versionID = $this->getRequest()->param('VersionID');
|
||||
$otherVersionID = $this->getRequest()->param('OtherVersionID');
|
||||
|
||||
|
||||
$showUnpublishedChecked = 0;
|
||||
$compareModeChecked = ($action == "compare");
|
||||
|
||||
@ -208,19 +208,19 @@ class CMSPageHistoryController extends CMSMain {
|
||||
if($versions) {
|
||||
foreach($versions as $k => $version) {
|
||||
$active = false;
|
||||
|
||||
|
||||
if($version->Version == $versionID || $version->Version == $otherVersionID) {
|
||||
$active = true;
|
||||
|
||||
|
||||
if(!$version->WasPublished) $showUnpublishedChecked = 1;
|
||||
}
|
||||
|
||||
$version->Active = ($active);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$vd = new ViewableData();
|
||||
|
||||
|
||||
$versionsHtml = $vd->customise(array(
|
||||
'Versions' => $versions
|
||||
))->renderWith('CMSPageHistoryController_versions');
|
||||
@ -246,14 +246,14 @@ class CMSPageHistoryController extends CMSMain {
|
||||
'doCompare', _t('CMSPageHistoryController.COMPAREVERSIONS','Compare Versions')
|
||||
),
|
||||
new FormAction(
|
||||
'doShowVersion', _t('CMSPageHistoryController.SHOWVERSION','Show Version')
|
||||
'doShowVersion', _t('CMSPageHistoryController.SHOWVERSION','Show Version')
|
||||
)
|
||||
);
|
||||
|
||||
// Use <button> to allow full jQuery UI styling
|
||||
foreach($actions->dataFields() as $action) $action->setUseButtonTag(true);
|
||||
|
||||
$form = CMSForm::create(
|
||||
$form = CMSForm::create(
|
||||
$this,
|
||||
'VersionsForm',
|
||||
$fields,
|
||||
@ -263,15 +263,15 @@ class CMSPageHistoryController extends CMSMain {
|
||||
$form->loadDataFrom($this->getRequest()->requestVars());
|
||||
$hiddenID->setValue($id);
|
||||
$form->unsetValidator();
|
||||
|
||||
|
||||
$form
|
||||
->addExtraClass('cms-versions-form') // placeholder, necessary for $.metadata() to work
|
||||
->setAttribute('data-link-tmpl-compare', Controller::join_links($this->Link('compare'), '%s', '%s', '%s'))
|
||||
->setAttribute('data-link-tmpl-show', Controller::join_links($this->Link('show'), '%s', '%s'));
|
||||
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process the {@link VersionsForm} compare function between two pages.
|
||||
*
|
||||
@ -283,7 +283,7 @@ class CMSPageHistoryController extends CMSMain {
|
||||
public function doCompare($data, $form) {
|
||||
$versions = $data['Versions'];
|
||||
if(count($versions) < 2) return null;
|
||||
|
||||
|
||||
$id = $this->currentPageID();
|
||||
$version1 = array_shift($versions);
|
||||
$version2 = array_shift($versions);
|
||||
@ -295,11 +295,11 @@ class CMSPageHistoryController extends CMSMain {
|
||||
return $this->customise(array(
|
||||
"EditForm" => $form
|
||||
))->renderWith(array(
|
||||
$this->class . '_EditForm',
|
||||
$this->class . '_EditForm',
|
||||
'LeftAndMain_Content'
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
// non javascript, redirect the user to the page
|
||||
$this->redirect(Controller::join_links(
|
||||
$this->Link('compare'),
|
||||
@ -316,21 +316,21 @@ class CMSPageHistoryController extends CMSMain {
|
||||
* @param Form
|
||||
*
|
||||
* @return html
|
||||
*/
|
||||
*/
|
||||
public function doShowVersion($data, $form) {
|
||||
$versionID = null;
|
||||
|
||||
if(isset($data['Versions']) && is_array($data['Versions'])) {
|
||||
|
||||
if(isset($data['Versions']) && is_array($data['Versions'])) {
|
||||
$versionID = array_shift($data['Versions']);
|
||||
}
|
||||
|
||||
|
||||
if(!$versionID) return;
|
||||
|
||||
|
||||
if($request->isAjax()) {
|
||||
return $this->customise(array(
|
||||
"EditForm" => $this->ShowVersionForm($versionID)
|
||||
))->renderWith(array(
|
||||
$this->class . '_EditForm',
|
||||
$this->class . '_EditForm',
|
||||
'LeftAndMain_Content'
|
||||
));
|
||||
}
|
||||
@ -354,7 +354,7 @@ class CMSPageHistoryController extends CMSMain {
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $versionID
|
||||
* @param int $otherVersionID
|
||||
@ -370,10 +370,10 @@ class CMSPageHistoryController extends CMSMain {
|
||||
}
|
||||
|
||||
if(!$toVersion || !$toVersion) return false;
|
||||
|
||||
|
||||
$id = $this->currentPageID();
|
||||
$page = DataObject::get_by_id("SiteTree", $id);
|
||||
|
||||
|
||||
if($page && !$page->canView()) {
|
||||
return Security::permissionFailure($this);
|
||||
}
|
||||
@ -382,11 +382,11 @@ class CMSPageHistoryController extends CMSMain {
|
||||
|
||||
$fromVersionRecord = Versioned::get_version('SiteTree', $id, $fromVersion);
|
||||
$toVersionRecord = Versioned::get_version('SiteTree', $id, $toVersion);
|
||||
|
||||
|
||||
if(!$fromVersionRecord) {
|
||||
user_error("Can't find version $fromVersion of page $id", E_USER_ERROR);
|
||||
}
|
||||
|
||||
|
||||
if(!$toVersionRecord) {
|
||||
user_error("Can't find version $toVersion of page $id", E_USER_ERROR);
|
||||
}
|
||||
@ -395,23 +395,23 @@ class CMSPageHistoryController extends CMSMain {
|
||||
$form = $this->getEditForm($id, null, null, true);
|
||||
$form->setActions(new FieldList());
|
||||
$form->addExtraClass('compare');
|
||||
|
||||
|
||||
// Comparison views shouldn't be editable.
|
||||
// Its important to convert fields *before* loading data,
|
||||
// as the comparison output is HTML and not valid values for the various field types
|
||||
$readonlyFields = $form->Fields()->makeReadonly();
|
||||
$form->setFields($readonlyFields);
|
||||
|
||||
|
||||
$form->loadDataFrom($record);
|
||||
$form->loadDataFrom(array(
|
||||
"ID" => $id,
|
||||
"Version" => $fromVersion,
|
||||
));
|
||||
|
||||
|
||||
foreach($form->Fields()->dataFields() as $field) {
|
||||
$field->dontEscape = true;
|
||||
}
|
||||
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ class CMSPageSettingsController extends CMSMain {
|
||||
private static $url_priority = 42;
|
||||
private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
|
||||
private static $session_namespace = 'CMSMain';
|
||||
|
||||
|
||||
public function getEditForm($id = null, $fields = null) {
|
||||
$record = $this->getRecord($id ? $id : $this->currentPageID());
|
||||
|
||||
|
||||
return parent::getEditForm($record, ($record) ? $record->getSettingsFields() : null);
|
||||
}
|
||||
|
||||
|
@ -4,11 +4,11 @@
|
||||
* @package cms
|
||||
*/
|
||||
class CMSPagesController extends CMSMain {
|
||||
|
||||
|
||||
private static $url_segment = 'pages';
|
||||
private static $url_rule = '/$Action/$ID/$OtherID';
|
||||
private static $url_priority = 40;
|
||||
private static $menu_title = 'Pages';
|
||||
private static $menu_title = 'Pages';
|
||||
private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
|
||||
private static $session_namespace = 'CMSMain';
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Base class for filtering the subtree for certain node statuses.
|
||||
*
|
||||
*
|
||||
* The simplest way of building a CMSSiteTreeFilter is to create a pagesToBeShown() method that
|
||||
* returns an Iterator of maps, each entry containing the 'ID' and 'ParentID' of the pages to be
|
||||
* included in the tree. The result of a DB::query() can then be returned directly.
|
||||
@ -9,7 +9,7 @@
|
||||
* If you wish to make a more complex tree, you can overload includeInTree($page) to return true/
|
||||
* false depending on whether the given page should be included. Note that you will need to include
|
||||
* parent helper pages yourself.
|
||||
*
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage content
|
||||
*/
|
||||
@ -20,10 +20,10 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil
|
||||
* Caution: Unescaped data.
|
||||
*/
|
||||
protected $params = array();
|
||||
|
||||
|
||||
/**
|
||||
* List of filtered items and all their parents
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_cache_ids = null;
|
||||
@ -37,14 +37,14 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil
|
||||
* @var array
|
||||
*/
|
||||
protected $_cache_highlight_ids = null;
|
||||
|
||||
|
||||
/**
|
||||
* @var Array
|
||||
*/
|
||||
protected $_cache_expanded = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var String
|
||||
* @var String
|
||||
*/
|
||||
protected $childrenMethod = null;
|
||||
|
||||
@ -55,38 +55,38 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil
|
||||
|
||||
/**
|
||||
* Returns a sorted array of all implementators of CMSSiteTreeFilter, suitable for use in a dropdown.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_all_filters() {
|
||||
// get all filter instances
|
||||
$filters = ClassInfo::subclassesFor('CMSSiteTreeFilter');
|
||||
|
||||
|
||||
// remove abstract CMSSiteTreeFilter class
|
||||
array_shift($filters);
|
||||
|
||||
|
||||
// add filters to map
|
||||
$filterMap = array();
|
||||
foreach($filters as $filter) {
|
||||
$filterMap[$filter] = $filter::title();
|
||||
}
|
||||
|
||||
|
||||
// Ensure that 'all pages' filter is on top position and everything else is sorted alphabetically
|
||||
uasort($filterMap, function($a, $b) {
|
||||
return ($a === CMSSiteTreeFilter_Search::title())
|
||||
? -1
|
||||
: strcasecmp($a, $b);
|
||||
});
|
||||
|
||||
|
||||
return $filterMap;
|
||||
}
|
||||
|
||||
|
||||
public function __construct($params = null) {
|
||||
if($params) $this->params = $params;
|
||||
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
public function getChildrenMethod() {
|
||||
return $this->childrenMethod;
|
||||
}
|
||||
@ -120,7 +120,7 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil
|
||||
public function pagesIncluded() {
|
||||
return $this->mapIDs($this->getFilteredPages());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Populate the IDs of the pages returned by pagesIncluded(), also including
|
||||
* the necessary parent helper pages.
|
||||
@ -129,10 +129,10 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil
|
||||
$parents = array();
|
||||
$this->_cache_ids = array();
|
||||
$this->_cache_highlight_ids = array();
|
||||
|
||||
|
||||
if($pages = $this->pagesIncluded()) {
|
||||
|
||||
// And keep a record of parents we don't need to get
|
||||
|
||||
// And keep a record of parents we don't need to get
|
||||
// parents of themselves, as well as IDs to mark
|
||||
foreach($pages as $pageArr) {
|
||||
$parents[$pageArr['ParentID']] = true;
|
||||
@ -152,7 +152,7 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function isPageIncluded($page) {
|
||||
if($this->_cache_ids === NULL) {
|
||||
$this->populateIDs();
|
||||
@ -160,10 +160,10 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil
|
||||
|
||||
return !empty($this->_cache_ids[$page->ID]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies the default filters to a specified DataList of pages
|
||||
*
|
||||
*
|
||||
* @param DataList $query Unfiltered query
|
||||
* @return DataList Filtered query
|
||||
*/
|
||||
@ -208,10 +208,10 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Maps a list of pages to an array of associative arrays with ID and ParentID keys
|
||||
*
|
||||
*
|
||||
* @param DataList $pages
|
||||
* @return array
|
||||
*/
|
||||
@ -272,7 +272,7 @@ class CMSSiteTreeFilter_PublishedPages extends CMSSiteTreeFilter {
|
||||
* Works a bit different than the other filters:
|
||||
* Shows all pages *including* those deleted from stage and live.
|
||||
* It does not filter out pages still existing in the different stages.
|
||||
*
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage content
|
||||
*/
|
||||
@ -287,11 +287,11 @@ class CMSSiteTreeFilter_DeletedPages extends CMSSiteTreeFilter {
|
||||
* @var string
|
||||
*/
|
||||
protected $numChildrenMethod = 'numHistoricalChildren';
|
||||
|
||||
|
||||
static public function title() {
|
||||
return _t('CMSSiteTreeFilter_DeletedPages.Title', "All pages, including archived");
|
||||
}
|
||||
|
||||
|
||||
public function getFilteredPages() {
|
||||
$pages = Versioned::get_including_deleted('SiteTree');
|
||||
$pages = $this->applyDefaultFilters($pages);
|
||||
@ -301,40 +301,40 @@ class CMSSiteTreeFilter_DeletedPages extends CMSSiteTreeFilter {
|
||||
|
||||
/**
|
||||
* Gets all pages which have changed on stage.
|
||||
*
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage content
|
||||
*/
|
||||
class CMSSiteTreeFilter_ChangedPages extends CMSSiteTreeFilter {
|
||||
|
||||
|
||||
static public function title() {
|
||||
return _t('CMSSiteTreeFilter_ChangedPages.Title', "Modified pages");
|
||||
}
|
||||
|
||||
|
||||
public function getFilteredPages() {
|
||||
$pages = Versioned::get_by_stage('SiteTree', 'Stage');
|
||||
$pages = $this->applyDefaultFilters($pages)
|
||||
->leftJoin('SiteTree_Live', '"SiteTree_Live"."ID" = "SiteTree"."ID"')
|
||||
->where('"SiteTree"."Version" <> "SiteTree_Live"."Version"');
|
||||
return $pages;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters pages which have a status "Removed from Draft".
|
||||
*
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage content
|
||||
*/
|
||||
class CMSSiteTreeFilter_StatusRemovedFromDraftPages extends CMSSiteTreeFilter {
|
||||
|
||||
|
||||
static public function title() {
|
||||
return _t('CMSSiteTreeFilter_StatusRemovedFromDraftPages.Title', 'Live but removed from draft');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filters out all pages who's status is set to "Removed from draft".
|
||||
*
|
||||
*
|
||||
* @return SS_List
|
||||
*/
|
||||
public function getFilteredPages() {
|
||||
@ -345,24 +345,24 @@ class CMSSiteTreeFilter_StatusRemovedFromDraftPages extends CMSSiteTreeFilter {
|
||||
return $page->getIsDeletedFromStage() && $page->getExistsOnLive();
|
||||
});
|
||||
return $pages;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters pages which have a status "Draft".
|
||||
*
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage content
|
||||
*/
|
||||
class CMSSiteTreeFilter_StatusDraftPages extends CMSSiteTreeFilter {
|
||||
|
||||
|
||||
static public function title() {
|
||||
return _t('CMSSiteTreeFilter_StatusDraftPages.Title', 'Draft pages');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filters out all pages who's status is set to "Draft".
|
||||
*
|
||||
*
|
||||
* @see {@link SiteTree::getStatusFlags()}
|
||||
* @return SS_List
|
||||
*/
|
||||
@ -374,12 +374,12 @@ class CMSSiteTreeFilter_StatusDraftPages extends CMSSiteTreeFilter {
|
||||
return (!$page->getIsDeletedFromStage() && $page->getIsAddedToStage());
|
||||
});
|
||||
return $pages;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters pages which have a status "Deleted".
|
||||
*
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage content
|
||||
*/
|
||||
@ -394,14 +394,14 @@ class CMSSiteTreeFilter_StatusDeletedPages extends CMSSiteTreeFilter {
|
||||
* @var string
|
||||
*/
|
||||
protected $numChildrenMethod = 'numHistoricalChildren';
|
||||
|
||||
|
||||
static public function title() {
|
||||
return _t('CMSSiteTreeFilter_StatusDeletedPages.Title', 'Archived pages');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filters out all pages who's status is set to "Deleted".
|
||||
*
|
||||
*
|
||||
* @see {@link SiteTree::getStatusFlags()}
|
||||
* @return SS_List
|
||||
*/
|
||||
@ -414,7 +414,7 @@ class CMSSiteTreeFilter_StatusDeletedPages extends CMSSiteTreeFilter {
|
||||
return $page->getIsDeletedFromStage() && !$page->getExistsOnLive();
|
||||
});
|
||||
return $pages;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -426,11 +426,11 @@ class CMSSiteTreeFilter_Search extends CMSSiteTreeFilter {
|
||||
static public function title() {
|
||||
return _t('CMSSiteTreeFilter_Search.Title', "All pages");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retun an array of maps containing the keys, 'ID' and 'ParentID' for each page to be displayed
|
||||
* in the search.
|
||||
*
|
||||
*
|
||||
* @return SS_List
|
||||
*/
|
||||
public function getFilteredPages() {
|
||||
|
@ -12,7 +12,7 @@
|
||||
*
|
||||
* Subclasses of ContentController are generally instantiated by ModelAsController; this will create
|
||||
* a controller based on the URLSegment action variable, by looking in the SiteTree table.
|
||||
*
|
||||
*
|
||||
* @todo Can this be used for anything other than SiteTree controllers?
|
||||
*
|
||||
* @package cms
|
||||
@ -29,7 +29,7 @@ class ContentController extends Controller {
|
||||
'deleteinstallfiles', // secured through custom code
|
||||
'LoginForm'
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* The ContentController will take the URLSegment parameter from the URL and use that to look
|
||||
* up a SiteTree record.
|
||||
@ -41,12 +41,12 @@ class ContentController extends Controller {
|
||||
$dataRecord->URLSegment = get_class($this);
|
||||
$dataRecord->ID = -1;
|
||||
}
|
||||
|
||||
|
||||
$this->dataRecord = $dataRecord;
|
||||
$this->failover = $this->dataRecord;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the link to this controller, but force the expanded link to be returned so that form methods and
|
||||
* similar will function properly.
|
||||
@ -57,10 +57,10 @@ class ContentController extends Controller {
|
||||
public function Link($action = null) {
|
||||
return $this->data()->Link(($action ? $action : true));
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------//
|
||||
// These flexible data methods remove the need for custom code to do simple stuff
|
||||
|
||||
|
||||
/**
|
||||
* Return the children of a given page. The parent reference can either be a page link or an ID.
|
||||
*
|
||||
@ -69,14 +69,14 @@ class ContentController extends Controller {
|
||||
*/
|
||||
public function ChildrenOf($parentRef) {
|
||||
$parent = SiteTree::get_by_link($parentRef);
|
||||
|
||||
|
||||
if(!$parent && is_numeric($parentRef)) {
|
||||
$parent = DataObject::get_by_id('SiteTree', $parentRef);
|
||||
}
|
||||
|
||||
|
||||
if($parent) return $parent->Children();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $link
|
||||
* @return SiteTree
|
||||
@ -87,10 +87,10 @@ class ContentController extends Controller {
|
||||
|
||||
public function init() {
|
||||
parent::init();
|
||||
|
||||
|
||||
// If we've accessed the homepage as /home/, then we should redirect to /.
|
||||
if($this->dataRecord && $this->dataRecord instanceof SiteTree
|
||||
&& RootURLController::should_be_on_root($this->dataRecord) && (!isset($this->urlParams['Action']) || !$this->urlParams['Action'] )
|
||||
&& RootURLController::should_be_on_root($this->dataRecord) && (!isset($this->urlParams['Action']) || !$this->urlParams['Action'] )
|
||||
&& !$_POST && !$_FILES && !$this->redirectedTo() ) {
|
||||
$getVars = $_GET;
|
||||
unset($getVars['url']);
|
||||
@ -99,7 +99,7 @@ class ContentController extends Controller {
|
||||
$this->redirect($url, 301);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if($this->dataRecord) $this->dataRecord->extend('contentcontrollerInit', $this);
|
||||
else singleton('SiteTree')->extend('contentcontrollerInit', $this);
|
||||
|
||||
@ -112,17 +112,17 @@ class ContentController extends Controller {
|
||||
|
||||
// Draft/Archive security check - only CMS users should be able to look at stage/archived content
|
||||
if(
|
||||
$this->URLSegment != 'Security'
|
||||
&& !Session::get('unsecuredDraftSite')
|
||||
$this->URLSegment != 'Security'
|
||||
&& !Session::get('unsecuredDraftSite')
|
||||
&& (
|
||||
Versioned::current_archived_date()
|
||||
Versioned::current_archived_date()
|
||||
|| (Versioned::current_stage() && Versioned::current_stage() != 'Live')
|
||||
)
|
||||
) {
|
||||
if(!$this->dataRecord->canView()) {
|
||||
Session::clear('currentStage');
|
||||
Session::clear('archiveDate');
|
||||
|
||||
|
||||
$permissionMessage = sprintf(
|
||||
_t(
|
||||
"ContentController.DRAFT_SITE_ACCESS_RESTRICTION",
|
||||
@ -136,13 +136,13 @@ class ContentController extends Controller {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Use theme from the site config
|
||||
if(($config = SiteConfig::current_site_config()) && $config->Theme) {
|
||||
Config::inst()->update('SSViewer', 'theme', $config->Theme);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This acts the same as {@link Controller::handleRequest()}, but if an action cannot be found this will attempt to
|
||||
* fall over to a child controller in order to provide functionality for nested URLs.
|
||||
@ -156,7 +156,7 @@ class ContentController extends Controller {
|
||||
$child = null;
|
||||
$action = $request->param('Action');
|
||||
$this->setDataModel($model);
|
||||
|
||||
|
||||
// If nested URLs are enabled, and there is no action handler for the current request then attempt to pass
|
||||
// control to a child controller. This allows for the creation of chains of controllers which correspond to a
|
||||
// nested URL.
|
||||
@ -170,12 +170,12 @@ class ContentController extends Controller {
|
||||
))->first();
|
||||
if(class_exists('Translatable')) Translatable::enable_locale_filter();
|
||||
}
|
||||
|
||||
|
||||
// we found a page with this URLSegment.
|
||||
if($child) {
|
||||
$request->shiftAllParams();
|
||||
$request->shift();
|
||||
|
||||
|
||||
$response = ModelAsController::controller_for($child)->handleRequest($request, $model);
|
||||
} else {
|
||||
// If a specific locale is requested, and it doesn't match the page found by URLSegment,
|
||||
@ -191,7 +191,7 @@ class ContentController extends Controller {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Director::set_current_page($this->data());
|
||||
|
||||
try {
|
||||
@ -200,16 +200,16 @@ class ContentController extends Controller {
|
||||
Director::set_current_page(null);
|
||||
} catch(SS_HTTPResponse_Exception $e) {
|
||||
$this->popCurrent();
|
||||
|
||||
|
||||
Director::set_current_page(null);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @uses ErrorPage::response_for()
|
||||
*/
|
||||
@ -229,7 +229,7 @@ class ContentController extends Controller {
|
||||
global $project;
|
||||
return $project;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the associated database record
|
||||
*/
|
||||
@ -254,13 +254,13 @@ class ContentController extends Controller {
|
||||
} else {
|
||||
$parent = $this->data();
|
||||
$stack = array($parent);
|
||||
|
||||
|
||||
if($parent) {
|
||||
while($parent = $parent->Parent) {
|
||||
array_unshift($stack, $parent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isset($stack[$level-2])) $result = $stack[$level-2]->Children();
|
||||
}
|
||||
|
||||
@ -298,12 +298,12 @@ class ContentController extends Controller {
|
||||
$items = '';
|
||||
$message = '';
|
||||
|
||||
if(Director::isDev() || Permission::check('CMS_ACCESS_CMSMain') || Permission::check('VIEW_DRAFT_CONTENT')) {
|
||||
if(Director::isDev() || Permission::check('CMS_ACCESS_CMSMain') || Permission::check('VIEW_DRAFT_CONTENT')) {
|
||||
if($this->dataRecord) {
|
||||
Requirements::css(CMS_DIR . '/css/SilverStripeNavigator.css');
|
||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');
|
||||
Requirements::javascript(CMS_DIR . '/javascript/SilverStripeNavigator.js');
|
||||
|
||||
|
||||
$return = $nav = SilverStripeNavigator::get_for_record($this->dataRecord);
|
||||
$items = $return['items'];
|
||||
$message = $return['message'];
|
||||
@ -322,7 +322,7 @@ class ContentController extends Controller {
|
||||
);
|
||||
}
|
||||
$viewPageIn = _t('ContentController.VIEWPAGEIN', 'View Page in:');
|
||||
|
||||
|
||||
return <<<HTML
|
||||
<div id="SilverStripeNavigator">
|
||||
<div class="holder">
|
||||
@ -331,7 +331,7 @@ class ContentController extends Controller {
|
||||
</div>
|
||||
|
||||
<div id="switchView" class="bottomTabs">
|
||||
$viewPageIn
|
||||
$viewPageIn
|
||||
$items
|
||||
</div>
|
||||
</div>
|
||||
@ -349,7 +349,7 @@ HTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function SiteConfig() {
|
||||
if(method_exists($this->dataRecord, 'getSiteConfig')) {
|
||||
return $this->dataRecord->getSiteConfig();
|
||||
@ -363,10 +363,10 @@ HTML;
|
||||
* Inspects the associated {@link dataRecord} for a {@link SiteTree->Locale} value if present,
|
||||
* and falls back to {@link Translatable::get_current_locale()} or {@link i18n::default_locale()},
|
||||
* depending if Translatable is enabled.
|
||||
*
|
||||
*
|
||||
* Suitable for insertion into lang= and xml:lang=
|
||||
* attributes in HTML or XHTML output.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ContentLocale() {
|
||||
@ -377,9 +377,9 @@ HTML;
|
||||
} else {
|
||||
$locale = i18n::get_locale();
|
||||
}
|
||||
|
||||
|
||||
return i18n::convert_rfc1766($locale);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -430,20 +430,20 @@ HTML;
|
||||
$fourohfour->write();
|
||||
$fourohfour->publish("Stage", "Live");
|
||||
}
|
||||
|
||||
|
||||
// TODO Allow this to work when allow_url_fopen=0
|
||||
if(isset($_SESSION['StatsID']) && $_SESSION['StatsID']) {
|
||||
$url = 'http://ss2stat.silverstripe.com/Installation/installed?ID=' . $_SESSION['StatsID'];
|
||||
@file_get_contents($url);
|
||||
}
|
||||
|
||||
|
||||
global $project;
|
||||
$data = new ArrayData(array(
|
||||
'Project' => Convert::raw2xml($project),
|
||||
'Username' => Convert::raw2xml(Session::get('username')),
|
||||
'Password' => Convert::raw2xml(Session::get('password')),
|
||||
));
|
||||
|
||||
|
||||
return array(
|
||||
"Title" => _t("ContentController.INSTALL_SUCCESS", "Installation Successful!"),
|
||||
"Content" => $data->renderWith('Install_successfullyinstalled'),
|
||||
@ -452,7 +452,7 @@ HTML;
|
||||
|
||||
public function deleteinstallfiles() {
|
||||
if(!Permission::check("ADMIN")) return Security::permissionFailure($this);
|
||||
|
||||
|
||||
$title = new Varchar("Title");
|
||||
$content = new HTMLText('Content');
|
||||
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
/**
|
||||
* Enhances error handling for a controller with ErrorPage generated output
|
||||
*
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage controller
|
||||
*/
|
||||
class ErrorPageControllerExtension extends Extension {
|
||||
|
||||
|
||||
public function onBeforeHTTPError($statusCode, $request) {
|
||||
$response = ErrorPage::response_for($statusCode);
|
||||
if($response) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Extension to include custom page icons
|
||||
*
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage controller
|
||||
*/
|
||||
@ -14,16 +14,16 @@ class LeftAndMainPageIconsExtension extends Extension {
|
||||
/**
|
||||
* Include CSS for page icons. We're not using the JSTree 'types' option
|
||||
* because it causes too much performance overhead just to add some icons.
|
||||
*
|
||||
* @return String CSS
|
||||
*
|
||||
* @return String CSS
|
||||
*/
|
||||
public function generatePageIconsCss() {
|
||||
$css = '';
|
||||
|
||||
$classes = ClassInfo::subclassesFor('SiteTree');
|
||||
$css = '';
|
||||
|
||||
$classes = ClassInfo::subclassesFor('SiteTree');
|
||||
foreach($classes as $class) {
|
||||
$obj = singleton($class);
|
||||
$iconSpec = $obj->stat('icon');
|
||||
$obj = singleton($class);
|
||||
$iconSpec = $obj->stat('icon');
|
||||
|
||||
if(!$iconSpec) continue;
|
||||
|
||||
@ -33,9 +33,9 @@ class LeftAndMainPageIconsExtension extends Extension {
|
||||
// Legacy support: Add file extension if none exists
|
||||
if(!pathinfo($iconFile, PATHINFO_EXTENSION)) $iconFile .= '-file.gif';
|
||||
|
||||
$iconPathInfo = pathinfo($iconFile);
|
||||
|
||||
// Base filename
|
||||
$iconPathInfo = pathinfo($iconFile);
|
||||
|
||||
// Base filename
|
||||
$baseFilename = $iconPathInfo['dirname'] . '/' . $iconPathInfo['filename'];
|
||||
$fileExtension = $iconPathInfo['extension'];
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
class ModelAsController extends Controller implements NestedController {
|
||||
private static $extensions = array('OldPageRedirector');
|
||||
|
||||
|
||||
/**
|
||||
* Get the appropriate {@link ContentController} for handling a {@link SiteTree} object, link it to the object and
|
||||
* return it.
|
||||
@ -31,15 +31,15 @@ class ModelAsController extends Controller implements NestedController {
|
||||
if($action && class_exists($controller . '_' . ucfirst($action))) {
|
||||
$controller = $controller . '_' . ucfirst($action);
|
||||
}
|
||||
|
||||
|
||||
return class_exists($controller) ? Injector::inst()->create($controller, $sitetree) : $sitetree;
|
||||
}
|
||||
|
||||
|
||||
public function init() {
|
||||
singleton('SiteTree')->extend('modelascontrollerInit', $this);
|
||||
parent::init();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @uses ModelAsController::getNestedController()
|
||||
* @param SS_HTTPRequest $request
|
||||
@ -49,7 +49,7 @@ class ModelAsController extends Controller implements NestedController {
|
||||
public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
|
||||
$this->setRequest($request);
|
||||
$this->setDataModel($model);
|
||||
|
||||
|
||||
$this->pushCurrent();
|
||||
|
||||
// Create a response just in case init() decides to redirect
|
||||
@ -67,64 +67,64 @@ class ModelAsController extends Controller implements NestedController {
|
||||
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
||||
$this->response->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
||||
$this->popCurrent();
|
||||
|
||||
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$result = $this->getNestedController();
|
||||
|
||||
|
||||
if($result instanceof RequestHandler) {
|
||||
$result = $result->handleRequest($this->getRequest(), $model);
|
||||
} else if(!($result instanceof SS_HTTPResponse)) {
|
||||
user_error("ModelAsController::getNestedController() returned bad object type '" .
|
||||
user_error("ModelAsController::getNestedController() returned bad object type '" .
|
||||
get_class($result)."'", E_USER_WARNING);
|
||||
}
|
||||
} catch(SS_HTTPResponse_Exception $responseException) {
|
||||
$result = $responseException->getResponse();
|
||||
}
|
||||
|
||||
|
||||
$this->popCurrent();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return ContentController
|
||||
* @throws Exception If URLSegment not passed in as a request parameter.
|
||||
*/
|
||||
public function getNestedController() {
|
||||
$request = $this->getRequest();
|
||||
|
||||
|
||||
if(!$URLSegment = $request->param('URLSegment')) {
|
||||
throw new Exception('ModelAsController->getNestedController(): was not passed a URLSegment value.');
|
||||
}
|
||||
|
||||
|
||||
// Find page by link, regardless of current locale settings
|
||||
if(class_exists('Translatable')) Translatable::disable_locale_filter();
|
||||
|
||||
|
||||
// Select child page
|
||||
$conditions = array('"SiteTree"."URLSegment"' => rawurlencode($URLSegment));
|
||||
if(SiteTree::config()->nested_urls) {
|
||||
$conditions[] = array('"SiteTree"."ParentID"' => 0);
|
||||
}
|
||||
$sitetree = DataObject::get_one('SiteTree', $conditions);
|
||||
|
||||
|
||||
// Check translation module
|
||||
// @todo Refactor out module specific code
|
||||
if(class_exists('Translatable')) Translatable::enable_locale_filter();
|
||||
|
||||
|
||||
if(!$sitetree) {
|
||||
$response = ErrorPage::response_for(404);
|
||||
$this->httpError(404, $response ? $response : 'The requested page could not be found.');
|
||||
}
|
||||
|
||||
|
||||
// Enforce current locale setting to the loaded SiteTree object
|
||||
if(class_exists('Translatable') && $sitetree->Locale) Translatable::set_current_locale($sitetree->Locale);
|
||||
|
||||
|
||||
if(isset($_REQUEST['debug'])) {
|
||||
Debug::message("Using record #$sitetree->ID of type $sitetree->class with link {$sitetree->Link()}");
|
||||
}
|
||||
|
||||
|
||||
return self::controller_for($sitetree, $this->getRequest()->param('Action'));
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ class ModelAsController extends Controller implements NestedController {
|
||||
static public function find_old_page($URLSegment, $parent = null, $ignoreNestedURLs = false) {
|
||||
Deprecation::notice('4.0', 'Use OldPageRedirector::find_old_page instead');
|
||||
if ($parent) {
|
||||
$parent = SiteTree::get()->byId($parent);
|
||||
$parent = SiteTree::get()->byId($parent);
|
||||
}
|
||||
$url = OldPageRedirector::find_old_page(array($URLSegment), $parent);
|
||||
return SiteTree::get_by_link($url);
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Interface that is implemented by controllers that are designed to hand control over to another controller.
|
||||
* Interface that is implemented by controllers that are designed to hand control over to another controller.
|
||||
* ModelAsController, which selects up a SiteTree object and passes control over to a suitable subclass of ContentController, is a good
|
||||
* example of this.
|
||||
* @package cms
|
||||
|
@ -39,7 +39,7 @@ class OldPageRedirector extends Extension {
|
||||
* @return string|boolean False, or the new URL
|
||||
*/
|
||||
static public function find_old_page($params, $parent = null, $redirect = false) {
|
||||
$parent = is_numeric($parent) ? SiteTree::get()->byId($parent) : $parent;
|
||||
$parent = is_numeric($parent) ? SiteTree::get()->byId($parent) : $parent;
|
||||
$params = (array)$params;
|
||||
$URL = rawurlencode(array_shift($params));
|
||||
if (empty($URL)) { return false; }
|
||||
|
@ -4,23 +4,23 @@
|
||||
* @subpackage control
|
||||
*/
|
||||
class RootURLController extends Controller {
|
||||
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected static $is_at_root = false;
|
||||
|
||||
|
||||
/**
|
||||
* @config
|
||||
* @var string
|
||||
*/
|
||||
private static $default_homepage_link = 'home';
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected static $cached_homepage_link;
|
||||
|
||||
|
||||
/**
|
||||
* Get the full form (e.g. /home/) relative link to the home page for the current HTTP_HOST value. Note that the
|
||||
* link is trimmed of leading and trailing slashes before returning to ensure consistency.
|
||||
@ -41,7 +41,7 @@ class RootURLController extends Controller {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!self::$cached_homepage_link) {
|
||||
// TODO Move to 'translatable' module
|
||||
if (
|
||||
@ -55,10 +55,10 @@ class RootURLController extends Controller {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return self::$cached_homepage_link;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the URL Segment used for your homepage when it is created by dev/build.
|
||||
* This allows you to use home page URLs other than the default "home".
|
||||
@ -81,7 +81,7 @@ class RootURLController extends Controller {
|
||||
Deprecation::notice('4.0', 'Use the "RootURLController.default_homepage_link" config setting instead');
|
||||
return Config::inst()->get('RootURLController', 'default_homepage_link');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns TRUE if a request to a certain page should be redirected to the site root (i.e. if the page acts as the
|
||||
* home page).
|
||||
@ -95,17 +95,17 @@ class RootURLController extends Controller {
|
||||
class_exists('Translatable') && $page->hasExtension('Translatable') && $page->Locale && $page->Locale != Translatable::default_locale()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resets the cached homepage link value - useful for testing.
|
||||
*/
|
||||
static public function reset() {
|
||||
self::$cached_homepage_link = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param SS_HTTPRequest $request
|
||||
* @param DataModel|null $model
|
||||
@ -114,24 +114,24 @@ class RootURLController extends Controller {
|
||||
public function handleRequest(SS_HTTPRequest $request, DataModel $model = null) {
|
||||
self::$is_at_root = true;
|
||||
$this->setDataModel($model);
|
||||
|
||||
|
||||
$this->pushCurrent();
|
||||
$this->init();
|
||||
|
||||
|
||||
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
||||
$this->response = new SS_HTTPResponse();
|
||||
$this->response->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
|
||||
$request->setUrl(self::get_homepage_link() . '/');
|
||||
$request->match('$URLSegment//$Action', true);
|
||||
$controller = new ModelAsController();
|
||||
|
||||
$result = $controller->handleRequest($request, $model);
|
||||
|
||||
|
||||
$this->popCurrent();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,21 +4,21 @@
|
||||
* for CMS authors, usually for {@link SiteTree} objects with "stage" and "live" links.
|
||||
* Useful both in the CMS and alongside the page template (for logged in authors).
|
||||
* The class can be used for any {@link DataObject} subclass implementing the {@link CMSPreviewable} interface.
|
||||
*
|
||||
*
|
||||
* New item types can be defined by extending the {@link SilverStripeNavigatorItem} class,
|
||||
* for example the "cmsworkflow" module defines a new "future state" item with a date selector
|
||||
* to view embargoed data at a future point in time. So the item doesn't always have to be a simple link.
|
||||
*
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage content
|
||||
*/
|
||||
class SilverStripeNavigator extends ViewableData {
|
||||
|
||||
|
||||
/**
|
||||
* @var DataObject
|
||||
*/
|
||||
protected $record;
|
||||
|
||||
|
||||
/**
|
||||
* @param DataObject $record
|
||||
* @throws InvalidArgumentException if record doesn't implement CMSPreviewable
|
||||
@ -30,7 +30,7 @@ class SilverStripeNavigator extends ViewableData {
|
||||
get_class($record)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
$this->record = $record;
|
||||
}
|
||||
|
||||
@ -39,26 +39,26 @@ class SilverStripeNavigator extends ViewableData {
|
||||
*/
|
||||
public function getItems() {
|
||||
$items = array();
|
||||
|
||||
|
||||
$classes = ClassInfo::subclassesFor('SilverStripeNavigatorItem');
|
||||
array_shift($classes);
|
||||
|
||||
|
||||
// Sort menu items according to priority
|
||||
$i = 0;
|
||||
foreach($classes as $class) {
|
||||
// Skip base class
|
||||
if($class == 'SilverStripeNavigatorItem') continue;
|
||||
|
||||
|
||||
$i++;
|
||||
$item = new $class($this->record);
|
||||
if(!$item->canView()) continue;
|
||||
|
||||
|
||||
// This funny litle formula ensures that the first item added with the same priority will be left-most.
|
||||
$priority = $item->getPriority() * 100 - 1;
|
||||
|
||||
|
||||
// Ensure that we can have duplicates with the same (default) priority
|
||||
while(isset($items[$priority])) $priority++;
|
||||
|
||||
|
||||
$items[$priority] = $item;
|
||||
}
|
||||
ksort($items);
|
||||
@ -66,7 +66,7 @@ class SilverStripeNavigator extends ViewableData {
|
||||
// Drop the keys and let the ArrayList handle the numbering, so $First, $Last and others work properly.
|
||||
return new ArrayList(array_values($items));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return DataObject
|
||||
*/
|
||||
@ -83,13 +83,13 @@ class SilverStripeNavigator extends ViewableData {
|
||||
$message = '';
|
||||
$navigator = new SilverStripeNavigator($record);
|
||||
$items = $navigator->getItems();
|
||||
foreach($items as $item) {
|
||||
foreach($items as $item) {
|
||||
$text = $item->getHTML();
|
||||
if($text) $html .= $text;
|
||||
$newMessage = $item->getMessage();
|
||||
if($newMessage && $item->isActive()) $message = $newMessage;
|
||||
}
|
||||
|
||||
|
||||
return array(
|
||||
'items' => $html,
|
||||
'message' => $message
|
||||
@ -101,24 +101,24 @@ class SilverStripeNavigator extends ViewableData {
|
||||
* Navigator items are links that appear in the $SilverStripeNavigator bar.
|
||||
* To add an item, extend this class - it will be automatically picked up.
|
||||
* When instanciating items manually, please ensure to call {@link canView()}.
|
||||
*
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage content
|
||||
*/
|
||||
class SilverStripeNavigatorItem extends ViewableData {
|
||||
|
||||
|
||||
/**
|
||||
* @param DataObject
|
||||
*/
|
||||
protected $record;
|
||||
|
||||
|
||||
/**
|
||||
* @param DataObject
|
||||
*/
|
||||
public function __construct($record) {
|
||||
$this->record = $record;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return String HTML, mostly a link - but can be more complex as well.
|
||||
* For example, a "future state" item might show a date selector.
|
||||
@ -130,7 +130,7 @@ class SilverStripeNavigatorItem extends ViewableData {
|
||||
* Get the Title of an item
|
||||
*/
|
||||
public function getTitle() {}
|
||||
|
||||
|
||||
/**
|
||||
* Machine-friendly name.
|
||||
*/
|
||||
@ -142,44 +142,44 @@ class SilverStripeNavigatorItem extends ViewableData {
|
||||
* Optional link to a specific view of this record.
|
||||
* Not all items are simple links, please use {@link getHTML()}
|
||||
* to represent an item in markup unless you know what you're doing.
|
||||
*
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public function getLink() {}
|
||||
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public function getMessage() {}
|
||||
|
||||
|
||||
/**
|
||||
* @return DataObject
|
||||
*/
|
||||
public function getRecord() {
|
||||
return $this->record;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Int
|
||||
*/
|
||||
public function getPriority() {
|
||||
return $this->stat('priority');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* As items might convey different record states like a "stage" or "live" table,
|
||||
* an item can be active (showing the record in this state).
|
||||
*
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filters items based on member permissions or other criteria,
|
||||
* such as if a state is generally available for the current record.
|
||||
*
|
||||
*
|
||||
* @param Member
|
||||
* @return Boolean
|
||||
*/
|
||||
@ -189,12 +189,12 @@ class SilverStripeNavigatorItem extends ViewableData {
|
||||
|
||||
/**
|
||||
* Counts as "archived" if the current record is a different version from both live and draft.
|
||||
*
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isArchived() {
|
||||
if(!$this->record->hasExtension('Versioned')) return false;
|
||||
|
||||
|
||||
if(!isset($this->record->_cached_isArchived)) {
|
||||
$baseTable = ClassInfo::baseDataClass($this->record->class);
|
||||
$currentDraft = Versioned::get_one_by_stage($baseTable, 'Stage', array(
|
||||
@ -203,9 +203,9 @@ class SilverStripeNavigatorItem extends ViewableData {
|
||||
$currentLive = Versioned::get_one_by_stage($baseTable, 'Live', array(
|
||||
"\"$baseTable\".\"ID\"" => $this->record->ID
|
||||
));
|
||||
|
||||
|
||||
$this->record->_cached_isArchived = (
|
||||
(!$currentDraft || ($currentDraft && $this->record->Version != $currentDraft->Version))
|
||||
(!$currentDraft || ($currentDraft && $this->record->Version != $currentDraft->Version))
|
||||
&& (!$currentLive || ($currentLive && $this->record->Version != $currentLive->Version))
|
||||
);
|
||||
}
|
||||
@ -220,8 +220,8 @@ class SilverStripeNavigatorItem extends ViewableData {
|
||||
*/
|
||||
class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem {
|
||||
/** @config */
|
||||
private static $priority = 10;
|
||||
|
||||
private static $priority = 10;
|
||||
|
||||
public function getHTML() {
|
||||
return sprintf(
|
||||
'<a href="%s">%s</a>',
|
||||
@ -229,19 +229,19 @@ class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem {
|
||||
_t('ContentController.CMS', 'CMS')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function getTitle() {
|
||||
return _t('ContentController.CMS', 'CMS', 'Used in navigation. Should be a short label');
|
||||
return _t('ContentController.CMS', 'CMS', 'Used in navigation. Should be a short label');
|
||||
}
|
||||
|
||||
|
||||
public function getLink() {
|
||||
return $this->record->CMSEditLink();
|
||||
}
|
||||
|
||||
|
||||
public function isActive() {
|
||||
return (Controller::curr() instanceof LeftAndMain);
|
||||
}
|
||||
|
||||
|
||||
public function canView($member = null) {
|
||||
return (
|
||||
// Don't show in CMS
|
||||
@ -272,37 +272,37 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem {
|
||||
public function getTitle() {
|
||||
return _t('ContentController.DRAFT', 'Draft', 'Used for the Switch between draft and published view mode. Needs to be a short label');
|
||||
}
|
||||
|
||||
|
||||
public function getMessage() {
|
||||
return "<div id=\"SilverStripeNavigatorMessage\" title=\"". _t('ContentControl.NOTEWONTBESHOWN', 'Note: this message will not be shown to your visitors') ."\">". _t('ContentController.DRAFTSITE', 'Draft Site') ."</div>";
|
||||
}
|
||||
|
||||
|
||||
public function getLink() {
|
||||
$date = Versioned::current_archived_date();
|
||||
return Controller::join_links(
|
||||
$this->record->PreviewLink(),
|
||||
$this->record->PreviewLink(),
|
||||
'?stage=Stage',
|
||||
$date ? '?archiveDate=' . $date : null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function canView($member = null) {
|
||||
return (
|
||||
$this->record->hasExtension('Versioned')
|
||||
$this->record->hasExtension('Versioned')
|
||||
&& $this->getDraftPage()
|
||||
// Don't follow redirects in preview, they break the CMS editing form
|
||||
&& !($this->record instanceof RedirectorPage)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function isActive() {
|
||||
return (
|
||||
Versioned::current_stage() == 'Stage'
|
||||
Versioned::current_stage() == 'Stage'
|
||||
&& !(ClassInfo::exists('SiteTreeFutureState') && SiteTreeFutureState::get_future_datetime())
|
||||
&& !$this->isArchived()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
protected function getDraftPage() {
|
||||
$baseTable = ClassInfo::baseDataClass($this->record->class);
|
||||
return Versioned::get_one_by_stage($baseTable, 'Stage', array(
|
||||
@ -330,31 +330,31 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem {
|
||||
public function getTitle() {
|
||||
return _t('ContentController.PUBLISHED', 'Published', 'Used for the Switch between draft and published view mode. Needs to be a short label');
|
||||
}
|
||||
|
||||
|
||||
public function getMessage() {
|
||||
return "<div id=\"SilverStripeNavigatorMessage\" title=\"". _t('ContentControl.NOTEWONTBESHOWN', 'Note: this message will not be shown to your visitors') ."\">". _t('ContentController.PUBLISHEDSITE', 'Published Site') ."</div>";
|
||||
}
|
||||
|
||||
|
||||
public function getLink() {
|
||||
return Controller::join_links($this->record->PreviewLink(), '?stage=Live');
|
||||
}
|
||||
|
||||
|
||||
public function canView($member = null) {
|
||||
return (
|
||||
$this->record->hasExtension('Versioned')
|
||||
$this->record->hasExtension('Versioned')
|
||||
&& $this->getLivePage()
|
||||
// Don't follow redirects in preview, they break the CMS editing form
|
||||
&& !($this->record instanceof RedirectorPage)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function isActive() {
|
||||
return (
|
||||
(!Versioned::current_stage() || Versioned::current_stage() == 'Live')
|
||||
&& !$this->isArchived()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
protected function getLivePage() {
|
||||
$baseTable = ClassInfo::baseDataClass($this->record->class);
|
||||
return Versioned::get_one_by_stage($baseTable, 'Live', array(
|
||||
@ -375,31 +375,31 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem {
|
||||
$this->recordLink = $this->record->AbsoluteLink();
|
||||
return "<a class=\"ss-ui-button". ($this->isActive() ? ' current' : '') ."\" href=\"$this->recordLink?archiveDate={$this->record->LastEdited}\" target=\"_blank\">". _t('ContentController.ARCHIVEDSITE', 'Preview version') ."</a>";
|
||||
}
|
||||
|
||||
|
||||
public function getTitle() {
|
||||
return _t('SilverStripeNavigator.ARCHIVED', 'Archived');
|
||||
}
|
||||
|
||||
public function getMessage() {
|
||||
|
||||
public function getMessage() {
|
||||
if($date = Versioned::current_archived_date()) {
|
||||
$dateObj = DBField::create_field('Datetime', $date);
|
||||
return "<div id=\"SilverStripeNavigatorMessage\" title=\"". _t('ContentControl.NOTEWONTBESHOWN', 'Note: this message will not be shown to your visitors') ."\">". _t('ContentController.ARCHIVEDSITEFROM', 'Archived site from') ."<br>" . $dateObj->Nice() . "</div>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getLink() {
|
||||
return $this->record->PreviewLink() . '?archiveDate=' . urlencode($this->record->LastEdited);
|
||||
}
|
||||
|
||||
|
||||
public function canView($member = null) {
|
||||
return (
|
||||
$this->record->hasExtension('Versioned')
|
||||
$this->record->hasExtension('Versioned')
|
||||
&& $this->isArchived()
|
||||
// Don't follow redirects in preview, they break the CMS editing form
|
||||
&& !($this->record instanceof RedirectorPage)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function isActive() {
|
||||
return $this->isArchived();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user