|
|
@ -330,12 +330,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
$conditions[] = array('"SiteTree"."ParentID"' => 0);
|
|
|
|
$conditions[] = array('"SiteTree"."ParentID"' => 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** @var SiteTree $sitetree */
|
|
|
|
/** @var SiteTree $sitetree */
|
|
|
|
$sitetree = DataObject::get_one(__CLASS__, $conditions, $cache);
|
|
|
|
$sitetree = DataObject::get_one(self::class, $conditions, $cache);
|
|
|
|
|
|
|
|
|
|
|
|
/// Fall back on a unique URLSegment for b/c.
|
|
|
|
/// Fall back on a unique URLSegment for b/c.
|
|
|
|
if( !$sitetree
|
|
|
|
if( !$sitetree
|
|
|
|
&& self::config()->nested_urls
|
|
|
|
&& self::config()->nested_urls
|
|
|
|
&& $sitetree = DataObject::get_one(__CLASS__, array(
|
|
|
|
&& $sitetree = DataObject::get_one(self::class, array(
|
|
|
|
'"SiteTree"."URLSegment"' => $URLSegment
|
|
|
|
'"SiteTree"."URLSegment"' => $URLSegment
|
|
|
|
), $cache)
|
|
|
|
), $cache)
|
|
|
|
) {
|
|
|
|
) {
|
|
|
@ -400,7 +400,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
public static function page_type_classes() {
|
|
|
|
public static function page_type_classes() {
|
|
|
|
$classes = ClassInfo::getValidSubClasses();
|
|
|
|
$classes = ClassInfo::getValidSubClasses();
|
|
|
|
|
|
|
|
|
|
|
|
$baseClassIndex = array_search(__CLASS__, $classes);
|
|
|
|
$baseClassIndex = array_search(self::class, $classes);
|
|
|
|
if($baseClassIndex !== false) {
|
|
|
|
if($baseClassIndex !== false) {
|
|
|
|
unset($classes[$baseClassIndex]);
|
|
|
|
unset($classes[$baseClassIndex]);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -449,8 +449,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
|
|
|
|
|
|
|
|
/** @var SiteTree $page */
|
|
|
|
/** @var SiteTree $page */
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
!($page = DataObject::get_by_id(__CLASS__, $arguments['id'])) // Get the current page by ID.
|
|
|
|
!($page = DataObject::get_by_id(self::class, $arguments['id'])) // Get the current page by ID.
|
|
|
|
&& !($page = Versioned::get_latest_version(__CLASS__, $arguments['id'])) // Attempt link to old version.
|
|
|
|
&& !($page = Versioned::get_latest_version(self::class, $arguments['id'])) // Attempt link to old version.
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return null; // There were no suitable matches at all.
|
|
|
|
return null; // There were no suitable matches at all.
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -531,7 +531,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
$parent = $this->Parent();
|
|
|
|
$parent = $this->Parent();
|
|
|
|
// If page is removed select parent from version history (for archive page view)
|
|
|
|
// If page is removed select parent from version history (for archive page view)
|
|
|
|
if((!$parent || !$parent->exists()) && $this->getIsDeletedFromStage()) {
|
|
|
|
if((!$parent || !$parent->exists()) && $this->getIsDeletedFromStage()) {
|
|
|
|
$parent = Versioned::get_latest_version(__CLASS__, $this->ParentID);
|
|
|
|
$parent = Versioned::get_latest_version(self::class, $this->ParentID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$base = $parent->RelativeLink($this->URLSegment);
|
|
|
|
$base = $parent->RelativeLink($this->URLSegment);
|
|
|
|
} elseif(!$action && $this->URLSegment == RootURLController::get_homepage_link()) {
|
|
|
|
} elseif(!$action && $this->URLSegment == RootURLController::get_homepage_link()) {
|
|
|
@ -562,7 +562,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
$oldReadingMode = Versioned::get_reading_mode();
|
|
|
|
$oldReadingMode = Versioned::get_reading_mode();
|
|
|
|
Versioned::set_stage(Versioned::LIVE);
|
|
|
|
Versioned::set_stage(Versioned::LIVE);
|
|
|
|
/** @var SiteTree $live */
|
|
|
|
/** @var SiteTree $live */
|
|
|
|
$live = Versioned::get_one_by_stage(__CLASS__, Versioned::LIVE, array(
|
|
|
|
$live = Versioned::get_one_by_stage(self::class, Versioned::LIVE, array(
|
|
|
|
'"SiteTree"."ID"' => $this->ID
|
|
|
|
'"SiteTree"."ID"' => $this->ID
|
|
|
|
));
|
|
|
|
));
|
|
|
|
if($live) {
|
|
|
|
if($live) {
|
|
|
@ -1070,7 +1070,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
// Check parent (custom canCreate option for SiteTree)
|
|
|
|
// Check parent (custom canCreate option for SiteTree)
|
|
|
|
// Block children not allowed for this parent type
|
|
|
|
// Block children not allowed for this parent type
|
|
|
|
$parent = isset($context['Parent']) ? $context['Parent'] : null;
|
|
|
|
$parent = isset($context['Parent']) ? $context['Parent'] : null;
|
|
|
|
if($parent && !in_array(get_class($this), $parent->allowedChildren())) {
|
|
|
|
if($parent && !in_array(static::class, $parent->allowedChildren())) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1170,7 +1170,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static public function prepopulate_permission_cache($permission = 'CanEditType', $ids, $batchCallback = null) {
|
|
|
|
static public function prepopulate_permission_cache($permission = 'CanEditType', $ids, $batchCallback = null) {
|
|
|
|
if(!$batchCallback) {
|
|
|
|
if(!$batchCallback) {
|
|
|
|
$batchCallback = __CLASS__ . "::can_{$permission}_multiple";
|
|
|
|
$batchCallback = self::class . "::can_{$permission}_multiple";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(is_callable($batchCallback)) {
|
|
|
|
if(is_callable($batchCallback)) {
|
|
|
@ -1447,7 +1447,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
$tags[] = FormField::create_tag('title', array(), $this->obj('Title')->forTemplate());
|
|
|
|
$tags[] = FormField::create_tag('title', array(), $this->obj('Title')->forTemplate());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$generator = trim(Config::inst()->get(__CLASS__, 'meta_generator'));
|
|
|
|
$generator = trim(Config::inst()->get(self::class, 'meta_generator'));
|
|
|
|
if (!empty($generator)) {
|
|
|
|
if (!empty($generator)) {
|
|
|
|
$tags[] = FormField::create_tag('meta', array(
|
|
|
|
$tags[] = FormField::create_tag('meta', array(
|
|
|
|
'name' => 'generator',
|
|
|
|
'name' => 'generator',
|
|
|
@ -1513,7 +1513,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
parent::requireDefaultRecords();
|
|
|
|
parent::requireDefaultRecords();
|
|
|
|
|
|
|
|
|
|
|
|
// default pages
|
|
|
|
// default pages
|
|
|
|
if(get_class($this) == __CLASS__ && $this->config()->create_default_pages) {
|
|
|
|
if(static::class == self::class && $this->config()->create_default_pages) {
|
|
|
|
if(!SiteTree::get_by_link(RootURLController::config()->default_homepage_link)) {
|
|
|
|
if(!SiteTree::get_by_link(RootURLController::config()->default_homepage_link)) {
|
|
|
|
$homepage = new Page();
|
|
|
|
$homepage = new Page();
|
|
|
|
$homepage->Title = _t('SiteTree.DEFAULTHOMETITLE', 'Home');
|
|
|
|
$homepage->Title = _t('SiteTree.DEFAULTHOMETITLE', 'Home');
|
|
|
@ -2160,7 +2160,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
* @return array
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function fieldLabels($includerelations = true) {
|
|
|
|
public function fieldLabels($includerelations = true) {
|
|
|
|
$cacheKey = get_class($this) . '_' . $includerelations;
|
|
|
|
$cacheKey = static::class . '_' . $includerelations;
|
|
|
|
if(!isset(self::$_cache_field_labels[$cacheKey])) {
|
|
|
|
if(!isset(self::$_cache_field_labels[$cacheKey])) {
|
|
|
|
$labels = parent::fieldLabels($includerelations);
|
|
|
|
$labels = parent::fieldLabels($includerelations);
|
|
|
|
$labels['Title'] = _t('SiteTree.PAGETITLE', "Page name");
|
|
|
|
$labels['Title'] = _t('SiteTree.PAGETITLE', "Page name");
|
|
|
@ -2231,7 +2231,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
$live = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::LIVE, array(
|
|
|
|
$live = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::LIVE, array(
|
|
|
|
'"SiteTree"."ID"' => $this->ID
|
|
|
|
'"SiteTree"."ID"' => $this->ID
|
|
|
|
));
|
|
|
|
));
|
|
|
|
$infoTemplate = SSViewer::get_templates_by_class(get_class($this), '_Information', __CLASS__);
|
|
|
|
$infoTemplate = SSViewer::get_templates_by_class(static::class, '_Information', self::class);
|
|
|
|
$moreOptions->push(
|
|
|
|
$moreOptions->push(
|
|
|
|
new LiteralField('Information',
|
|
|
|
new LiteralField('Information',
|
|
|
|
$this->customise(array(
|
|
|
|
$this->customise(array(
|
|
|
@ -2244,7 +2244,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
$moreOptions->push(AddToCampaignHandler_FormAction::create());
|
|
|
|
$moreOptions->push(AddToCampaignHandler_FormAction::create());
|
|
|
|
|
|
|
|
|
|
|
|
// "readonly"/viewing version that isn't the current version of the record
|
|
|
|
// "readonly"/viewing version that isn't the current version of the record
|
|
|
|
$stageOrLiveRecord = Versioned::get_one_by_stage(get_class($this), Versioned::get_stage(), array(
|
|
|
|
$stageOrLiveRecord = Versioned::get_one_by_stage(static::class, Versioned::get_stage(), array(
|
|
|
|
'"SiteTree"."ID"' => $this->ID
|
|
|
|
'"SiteTree"."ID"' => $this->ID
|
|
|
|
));
|
|
|
|
));
|
|
|
|
if($stageOrLiveRecord && $stageOrLiveRecord->Version != $this->Version) {
|
|
|
|
if($stageOrLiveRecord && $stageOrLiveRecord->Version != $this->Version) {
|
|
|
@ -2430,7 +2430,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
$this->write();
|
|
|
|
$this->write();
|
|
|
|
|
|
|
|
|
|
|
|
/** @var SiteTree $result */
|
|
|
|
/** @var SiteTree $result */
|
|
|
|
$result = DataObject::get_by_id(__CLASS__, $this->ID);
|
|
|
|
$result = DataObject::get_by_id(self::class, $this->ID);
|
|
|
|
|
|
|
|
|
|
|
|
// Need to update pages linking to this one as no longer broken
|
|
|
|
// Need to update pages linking to this one as no longer broken
|
|
|
|
foreach($result->DependentPages(false) as $page) {
|
|
|
|
foreach($result->DependentPages(false) as $page) {
|
|
|
@ -2722,7 +2722,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
$controller = ContentController::class;
|
|
|
|
$controller = ContentController::class;
|
|
|
|
|
|
|
|
|
|
|
|
//go through the ancestry for this class looking for
|
|
|
|
//go through the ancestry for this class looking for
|
|
|
|
$ancestry = ClassInfo::ancestry(get_class($this));
|
|
|
|
$ancestry = ClassInfo::ancestry(static::class);
|
|
|
|
// loop over the array going from the deepest descendant (ie: the current class) to SiteTree
|
|
|
|
// loop over the array going from the deepest descendant (ie: the current class) to SiteTree
|
|
|
|
while ($class = array_pop($ancestry)) {
|
|
|
|
while ($class = array_pop($ancestry)) {
|
|
|
|
//we don't need to go any deeper than the SiteTree class
|
|
|
|
//we don't need to go any deeper than the SiteTree class
|
|
|
@ -2746,7 +2746,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
* @return string
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function CMSTreeClasses($numChildrenMethod="numChildren") {
|
|
|
|
public function CMSTreeClasses($numChildrenMethod="numChildren") {
|
|
|
|
$classes = sprintf('class-%s', get_class($this));
|
|
|
|
$classes = sprintf('class-%s', static::class);
|
|
|
|
if($this->HasBrokenFile || $this->HasBrokenLink) {
|
|
|
|
if($this->HasBrokenFile || $this->HasBrokenLink) {
|
|
|
|
$classes .= " BrokenLink";
|
|
|
|
$classes .= " BrokenLink";
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2897,9 +2897,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
// Convert 'Page' to 'SiteTree' for correct localization lookups
|
|
|
|
// Convert 'Page' to 'SiteTree' for correct localization lookups
|
|
|
|
/** @skipUpgrade */
|
|
|
|
/** @skipUpgrade */
|
|
|
|
// @todo When we namespace translations, change 'SiteTree' to FQN of the class
|
|
|
|
// @todo When we namespace translations, change 'SiteTree' to FQN of the class
|
|
|
|
$class = (get_class($this) == 'Page' || get_class($this) === __CLASS__)
|
|
|
|
$class = (static::class == 'Page' || static::class === self::class)
|
|
|
|
? 'SiteTree'
|
|
|
|
? 'SiteTree'
|
|
|
|
: get_class($this);
|
|
|
|
: static::class;
|
|
|
|
return _t($class.'.SINGULARNAME', $this->singular_name());
|
|
|
|
return _t($class.'.SINGULARNAME', $this->singular_name());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2915,7 +2915,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|
|
|
if(isset($entities['Page.SINGULARNAME'])) $entities['Page.SINGULARNAME'][3] = CMS_DIR;
|
|
|
|
if(isset($entities['Page.SINGULARNAME'])) $entities['Page.SINGULARNAME'][3] = CMS_DIR;
|
|
|
|
if(isset($entities['Page.PLURALNAME'])) $entities['Page.PLURALNAME'][3] = CMS_DIR;
|
|
|
|
if(isset($entities['Page.PLURALNAME'])) $entities['Page.PLURALNAME'][3] = CMS_DIR;
|
|
|
|
|
|
|
|
|
|
|
|
$entities[get_class($this) . '.DESCRIPTION'] = array(
|
|
|
|
$entities[static::class . '.DESCRIPTION'] = array(
|
|
|
|
$this->stat('description'),
|
|
|
|
$this->stat('description'),
|
|
|
|
'Description of the page type (shown in the "add page" dialog)'
|
|
|
|
'Description of the page type (shown in the "add page" dialog)'
|
|
|
|
);
|
|
|
|
);
|
|
|
|