diff --git a/_config.php b/_config.php index c96a49fb..e10207cd 100644 --- a/_config.php +++ b/_config.php @@ -1,5 +1,7 @@ canCreate(); + $cacheCanCreate = array(); + foreach($classes as $class) $cacheCanCreate[$class] = singleton($class)->canCreate(); - // Generate basic cache key. Too complex to encompass all variations - $cache = SS_Cache::factory('CMSMain_SiteTreeHints'); - $cacheKey = md5(implode('_', array(Member::currentUserID(), implode(',', $cacheCanCreate), implode(',', $classes)))); - if($this->getRequest()->getVar('flush')) $cache->clean(Zend_Cache::CLEANING_MODE_ALL); - $json = $cache->load($cacheKey); + // Generate basic cache key. Too complex to encompass all variations + $cache = SS_Cache::factory('CMSMain_SiteTreeHints'); + $cacheKey = md5(implode('_', array(Member::currentUserID(), implode(',', $cacheCanCreate), implode(',', $classes)))); + if($this->getRequest()->getVar('flush')) $cache->clean(Zend_Cache::CLEANING_MODE_ALL); + $json = $cache->load($cacheKey); if(!$json) { $def['Root'] = array(); $def['Root']['disallowedChildren'] = array(); @@ -734,7 +738,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr $form->setValidationExemptActions(array('restore', 'revert', 'deletefromlive', 'delete', 'unpublish', 'rollback', 'doRollback')); // Announce the capability so the frontend can decide whether to allow preview or not. - if(in_array('CMSPreviewable', class_implements($record))) { + if ($record instanceof CMSPreviewable) { $form->addExtraClass('cms-previewable'); } diff --git a/code/Controllers/CMSSiteTreeFilter.php b/code/Controllers/CMSSiteTreeFilter.php index 90d7f219..38aa3416 100644 --- a/code/Controllers/CMSSiteTreeFilter.php +++ b/code/Controllers/CMSSiteTreeFilter.php @@ -7,9 +7,10 @@ use SilverStripe\ORM\DataList; use SilverStripe\ORM\SS_List; use SilverStripe\ORM\Versioning\Versioned; use Object; -use LeftAndMain_SearchFilter; use ClassInfo; use DateField; +use SilverStripe\Admin\LeftAndMain_SearchFilter; + /** * Base class for filtering the subtree for certain node statuses. diff --git a/code/Controllers/SilverStripeNavigator.php b/code/Controllers/SilverStripeNavigator.php index 4dcdae6f..50e0d66f 100644 --- a/code/Controllers/SilverStripeNavigator.php +++ b/code/Controllers/SilverStripeNavigator.php @@ -9,10 +9,11 @@ use SilverStripe\ORM\Versioning\Versioned; use SilverStripe\ORM\FieldType\DBField; use SilverStripe\Security\Member; use ViewableData; -use CMSPreviewable; use ClassInfo; -use LeftAndMain; use Controller; +use SilverStripe\Admin\CMSPreviewable; +use SilverStripe\Admin\LeftAndMain; + use SiteTreeFutureState; use SilverStripe\CMS\Model\RedirectorPage; @@ -222,7 +223,7 @@ abstract class SilverStripeNavigatorItem extends ViewableData { (!$currentDraft || ($currentDraft && $this->record->Version != $currentDraft->Version)) && (!$currentLive || ($currentLive && $this->record->Version != $currentLive->Version)) ); - } +} return $this->record->_cached_isArchived; } diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index 05c711a4..edc41e9a 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -19,7 +19,6 @@ use SilverStripe\Security\Permission; use SilverStripe\Security\Group; use SilverStripe\Security\PermissionProvider; use i18nEntityProvider; -use CMSPreviewable; use Director; use SilverStripe\CMS\Controllers\RootURLController; use ClassInfo; @@ -52,9 +51,11 @@ use TreeDropdownField; use FieldGroup; use CheckboxField; use ListboxField; -use AddToCampaignHandler_FormAction; use FormAction; use i18n; +use SilverStripe\Admin\AddToCampaignHandler_FormAction; +use SilverStripe\Admin\CMSPreviewable; + /** * Basic data-object representing all pages within the site tree. All page types that live within the hierarchy should @@ -352,13 +353,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid foreach($alternatives as $alternative) { if($alternative) { $sitetree = $alternative; - } + } } } if(!$sitetree) { return null; - } + } } // Check if we have any more URL parts to parse. @@ -437,8 +438,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid /** * Replace a "[sitetree_link id=n]" shortcode with a link to the page with the corresponding ID. * - * @param array $arguments - * @param string $content + * @param array $arguments + * @param string $content * @param ShortcodeParser $parser * @return string */ @@ -609,7 +610,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $currentPage = Director::get_current_page(); if ($currentPage instanceof ContentController) { $currentPage = $currentPage->data(); - } + } if($currentPage instanceof SiteTree) { return $currentPage === $this || $currentPage->ID === $this->ID; } @@ -1467,7 +1468,6 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } if(Permission::check('CMS_ACCESS_CMSMain') - && in_array('CMSPreviewable', class_implements($this)) && !$this instanceof ErrorPage && $this->ID > 0 ) { @@ -1552,7 +1552,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid DB::alteration_message('Contact Us page created', 'created'); } } - } + } protected function onBeforeWrite() { parent::onBeforeWrite(); @@ -1877,10 +1877,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid if($parentPage && $parentPage->exists()) { $link = Convert::raw2att($parentPage->CMSEditLink()); $title = Convert::raw2xml($parentPage->Title); - } else { + } else { $link = CMSPageEditController::singleton()->Link('show'); $title = _t('SiteTree.TOPLEVEL', 'Site Content (Top Level)'); - } + } $parentPageLinks[] = "{$title}"; } diff --git a/tests/controller/CMSMainTest.php b/tests/controller/CMSMainTest.php index ab00bafd..ccd6ef1a 100644 --- a/tests/controller/CMSMainTest.php +++ b/tests/controller/CMSMainTest.php @@ -6,6 +6,8 @@ use SilverStripe\ORM\Versioning\Versioned; use SilverStripe\ORM\HiddenClass; use SilverStripe\CMS\Controllers\CMSMain; use SilverStripe\CMS\Model\SiteTree; +use SilverStripe\Admin\CMSBatchActionHandler; + /**