mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1579 from tractorcow/pulls/3.4/fix-settings-border
BUG Fix extra border in page settings
This commit is contained in:
commit
a6fae9b35b
@ -174,7 +174,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private static $icon = null;
|
private static $icon = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @config
|
* @config
|
||||||
* @var string Description of the class functionality, typically shown to a user
|
* @var string Description of the class functionality, typically shown to a user
|
||||||
@ -187,7 +187,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
"Versioned('Stage', 'Live')",
|
"Versioned('Stage', 'Live')",
|
||||||
"SiteTreeLinkTracking"
|
"SiteTreeLinkTracking"
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $searchable_fields = array(
|
private static $searchable_fields = array(
|
||||||
'Title',
|
'Title',
|
||||||
'Content',
|
'Content',
|
||||||
@ -196,22 +196,22 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
private static $field_labels = array(
|
private static $field_labels = array(
|
||||||
'URLSegment' => 'URL'
|
'URLSegment' => 'URL'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @config
|
* @config
|
||||||
*/
|
*/
|
||||||
private static $nested_urls = true;
|
private static $nested_urls = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @config
|
* @config
|
||||||
*/
|
*/
|
||||||
private static $create_default_pages = true;
|
private static $create_default_pages = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This controls whether of not extendCMSFields() is called by getCMSFields.
|
* This controls whether of not extendCMSFields() is called by getCMSFields.
|
||||||
*/
|
*/
|
||||||
private static $runCMSFieldsExtensions = true;
|
private static $runCMSFieldsExtensions = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache for canView/Edit/Publish/Delete permissions.
|
* Cache for canView/Edit/Publish/Delete permissions.
|
||||||
* Keyed by permission type (e.g. 'edit'), with an array
|
* Keyed by permission type (e.g. 'edit'), with an array
|
||||||
@ -235,7 +235,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
private static $meta_generator = 'SilverStripe - http://silverstripe.org';
|
private static $meta_generator = 'SilverStripe - http://silverstripe.org';
|
||||||
|
|
||||||
protected $_cache_statusFlags = null;
|
protected $_cache_statusFlags = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if the system should avoid orphaned pages
|
* Determines if the system should avoid orphaned pages
|
||||||
* by deleting all children when the their parent is deleted (TRUE),
|
* by deleting all children when the their parent is deleted (TRUE),
|
||||||
@ -248,7 +248,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
Deprecation::notice('4.0', 'Use the "SiteTree.enforce_strict_hierarchy" config setting instead');
|
Deprecation::notice('4.0', 'Use the "SiteTree.enforce_strict_hierarchy" config setting instead');
|
||||||
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', $to);
|
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', $to);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated 4.0 Use the "SiteTree.enforce_strict_hierarchy" config setting instead
|
* @deprecated 4.0 Use the "SiteTree.enforce_strict_hierarchy" config setting instead
|
||||||
* @return boolean
|
* @return boolean
|
||||||
@ -268,7 +268,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
Deprecation::notice('4.0', 'Use the "SiteTree.nested_urls" config setting instead');
|
Deprecation::notice('4.0', 'Use the "SiteTree.nested_urls" config setting instead');
|
||||||
return Config::inst()->get('SiteTree', 'nested_urls');
|
return Config::inst()->get('SiteTree', 'nested_urls');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated 4.0 Use the "SiteTree.nested_urls" config setting instead
|
* @deprecated 4.0 Use the "SiteTree.nested_urls" config setting instead
|
||||||
*/
|
*/
|
||||||
@ -276,7 +276,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
Deprecation::notice('4.0', 'Use the "SiteTree.nested_urls" config setting instead');
|
Deprecation::notice('4.0', 'Use the "SiteTree.nested_urls" config setting instead');
|
||||||
Config::inst()->update('SiteTree', 'nested_urls', true);
|
Config::inst()->update('SiteTree', 'nested_urls', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated 4.0 Use the "SiteTree.nested_urls" config setting instead
|
* @deprecated 4.0 Use the "SiteTree.nested_urls" config setting instead
|
||||||
*/
|
*/
|
||||||
@ -284,7 +284,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
Deprecation::notice('4.0', 'Use the "SiteTree.nested_urls" config setting instead');
|
Deprecation::notice('4.0', 'Use the "SiteTree.nested_urls" config setting instead');
|
||||||
Config::inst()->update('SiteTree', 'nested_urls', false);
|
Config::inst()->update('SiteTree', 'nested_urls', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the (re)creation of default pages on /dev/build
|
* Set the (re)creation of default pages on /dev/build
|
||||||
*
|
*
|
||||||
@ -306,7 +306,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
Deprecation::notice('4.0', 'Use the "SiteTree.create_default_pages" config setting instead');
|
Deprecation::notice('4.0', 'Use the "SiteTree.create_default_pages" config setting instead');
|
||||||
return Config::inst()->get('SiteTree', 'create_default_pages');
|
return Config::inst()->get('SiteTree', 'create_default_pages');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the {@link SiteTree} object that maps to a link.
|
* Fetches the {@link SiteTree} object that maps to a link.
|
||||||
*
|
*
|
||||||
@ -326,9 +326,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
} else {
|
} else {
|
||||||
$link = RootURLController::get_homepage_link();
|
$link = RootURLController::get_homepage_link();
|
||||||
}
|
}
|
||||||
|
|
||||||
$parts = preg_split('|/+|', $link);
|
$parts = preg_split('|/+|', $link);
|
||||||
|
|
||||||
// Grab the initial root level page to traverse down from.
|
// Grab the initial root level page to traverse down from.
|
||||||
$URLSegment = array_shift($parts);
|
$URLSegment = array_shift($parts);
|
||||||
$conditions = array('"SiteTree"."URLSegment"' => rawurlencode($URLSegment));
|
$conditions = array('"SiteTree"."URLSegment"' => rawurlencode($URLSegment));
|
||||||
@ -336,7 +336,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$conditions[] = array('"SiteTree"."ParentID"' => 0);
|
$conditions[] = array('"SiteTree"."ParentID"' => 0);
|
||||||
}
|
}
|
||||||
$sitetree = DataObject::get_one('SiteTree', $conditions, $cache);
|
$sitetree = DataObject::get_one('SiteTree', $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
|
||||||
@ -346,21 +346,21 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
) {
|
) {
|
||||||
return $page;
|
return $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to grab an alternative page from extensions.
|
// Attempt to grab an alternative page from extensions.
|
||||||
if(!$sitetree) {
|
if(!$sitetree) {
|
||||||
$parentID = self::config()->nested_urls ? 0 : null;
|
$parentID = self::config()->nested_urls ? 0 : null;
|
||||||
|
|
||||||
if($alternatives = singleton('SiteTree')->extend('alternateGetByLink', $URLSegment, $parentID)) {
|
if($alternatives = singleton('SiteTree')->extend('alternateGetByLink', $URLSegment, $parentID)) {
|
||||||
foreach($alternatives as $alternative) if($alternative) $sitetree = $alternative;
|
foreach($alternatives as $alternative) if($alternative) $sitetree = $alternative;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$sitetree) return false;
|
if(!$sitetree) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we have any more URL parts to parse.
|
// Check if we have any more URL parts to parse.
|
||||||
if(!self::config()->nested_urls || !count($parts)) return $sitetree;
|
if(!self::config()->nested_urls || !count($parts)) return $sitetree;
|
||||||
|
|
||||||
// Traverse down the remaining URL segments and grab the relevant SiteTree objects.
|
// Traverse down the remaining URL segments and grab the relevant SiteTree objects.
|
||||||
foreach($parts as $segment) {
|
foreach($parts as $segment) {
|
||||||
$next = DataObject::get_one('SiteTree', array(
|
$next = DataObject::get_one('SiteTree', array(
|
||||||
@ -369,24 +369,24 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
),
|
),
|
||||||
$cache
|
$cache
|
||||||
);
|
);
|
||||||
|
|
||||||
if(!$next) {
|
if(!$next) {
|
||||||
$parentID = (int) $sitetree->ID;
|
$parentID = (int) $sitetree->ID;
|
||||||
|
|
||||||
if($alternatives = singleton('SiteTree')->extend('alternateGetByLink', $segment, $parentID)) {
|
if($alternatives = singleton('SiteTree')->extend('alternateGetByLink', $segment, $parentID)) {
|
||||||
foreach($alternatives as $alternative) if($alternative) $next = $alternative;
|
foreach($alternatives as $alternative) if($alternative) $next = $alternative;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$next) return false;
|
if(!$next) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sitetree->destroy();
|
$sitetree->destroy();
|
||||||
$sitetree = $next;
|
$sitetree = $next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sitetree;
|
return $sitetree;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a subclass map of SiteTree that shouldn't be hidden through {@link SiteTree::$hide_ancestor}
|
* Return a subclass map of SiteTree that shouldn't be hidden through {@link SiteTree::$hide_ancestor}
|
||||||
*
|
*
|
||||||
@ -426,7 +426,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
return $classes;
|
return $classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace a "[sitetree_link id=n]" shortcode with a link to the page with the corresponding ID.
|
* Replace a "[sitetree_link id=n]" shortcode with a link to the page with the corresponding ID.
|
||||||
*
|
*
|
||||||
@ -437,7 +437,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*/
|
*/
|
||||||
static public function link_shortcode_handler($arguments, $content = null, $parser = null) {
|
static public function link_shortcode_handler($arguments, $content = null, $parser = null) {
|
||||||
if(!isset($arguments['id']) || !is_numeric($arguments['id'])) return;
|
if(!isset($arguments['id']) || !is_numeric($arguments['id'])) return;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!($page = DataObject::get_by_id('SiteTree', $arguments['id'])) // Get the current page by ID.
|
!($page = DataObject::get_by_id('SiteTree', $arguments['id'])) // Get the current page by ID.
|
||||||
&& !($page = Versioned::get_latest_version('SiteTree', $arguments['id'])) // Attempt link to old version.
|
&& !($page = Versioned::get_latest_version('SiteTree', $arguments['id'])) // Attempt link to old version.
|
||||||
@ -447,7 +447,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
|
|
||||||
$link = Convert::raw2att($page->Link());
|
$link = Convert::raw2att($page->Link());
|
||||||
|
|
||||||
if($content) {
|
if($content) {
|
||||||
return sprintf('<a href="%s">%s</a>', $link, $parser->parse($content));
|
return sprintf('<a href="%s">%s</a>', $link, $parser->parse($content));
|
||||||
} else {
|
} else {
|
||||||
@ -467,7 +467,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function Link($action = null) {
|
public function Link($action = null) {
|
||||||
return Controller::join_links(Director::baseURL(), $this->RelativeLink($action));
|
return Controller::join_links(Director::baseURL(), $this->RelativeLink($action));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the absolute URL for this page, including protocol and host.
|
* Get the absolute URL for this page, including protocol and host.
|
||||||
*
|
*
|
||||||
@ -481,7 +481,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
return Director::absoluteURL($this->Link($action));
|
return Director::absoluteURL($this->Link($action));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base link used for previewing. Defaults to absolute URL, in order to account for domain changes, e.g. on multi
|
* Base link used for previewing. Defaults to absolute URL, in order to account for domain changes, e.g. on multi
|
||||||
* site setups. Does not contain hints about the stage, see {@link SilverStripeNavigator} for details.
|
* site setups. Does not contain hints about the stage, see {@link SilverStripeNavigator} for details.
|
||||||
@ -496,7 +496,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
return $this->AbsoluteLink($action);
|
return $this->AbsoluteLink($action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the link for this {@link SiteTree} object relative to the SilverStripe root.
|
* Return the link for this {@link SiteTree} object relative to the SilverStripe root.
|
||||||
*
|
*
|
||||||
@ -525,9 +525,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
} else {
|
} else {
|
||||||
$base = $this->URLSegment;
|
$base = $this->URLSegment;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->extend('updateRelativeLink', $base, $action);
|
$this->extend('updateRelativeLink', $base, $action);
|
||||||
|
|
||||||
// Legacy support: If $action === true, retain URLSegment for homepages,
|
// Legacy support: If $action === true, retain URLSegment for homepages,
|
||||||
// but don't append any action
|
// but don't append any action
|
||||||
if($action === true) $action = null;
|
if($action === true) $action = null;
|
||||||
@ -559,7 +559,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
Versioned::reading_stage($oldStage);
|
Versioned::reading_stage($oldStage);
|
||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a link to edit this page in the CMS.
|
* Generates a link to edit this page in the CMS.
|
||||||
*
|
*
|
||||||
@ -568,8 +568,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function CMSEditLink() {
|
public function CMSEditLink() {
|
||||||
return Controller::join_links(singleton('CMSPageEditController')->Link('show'), $this->ID);
|
return Controller::join_links(singleton('CMSPageEditController')->Link('show'), $this->ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a CSS identifier generated from this page's link.
|
* Return a CSS identifier generated from this page's link.
|
||||||
*
|
*
|
||||||
@ -578,7 +578,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function ElementName() {
|
public function ElementName() {
|
||||||
return str_replace('/', '-', trim($this->RelativeLink(true), '/'));
|
return str_replace('/', '-', trim($this->RelativeLink(true), '/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this is the currently active page being used to handle this request.
|
* Returns true if this is the currently active page being used to handle this request.
|
||||||
*
|
*
|
||||||
@ -587,7 +587,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function isCurrent() {
|
public function isCurrent() {
|
||||||
return $this->ID ? $this->ID == Director::get_current_page()->ID : $this === Director::get_current_page();
|
return $this->ID ? $this->ID == Director::get_current_page()->ID : $this === Director::get_current_page();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this page is in the currently active section (e.g. it is either current or one of its children is
|
* Check if this page is in the currently active section (e.g. it is either current or one of its children is
|
||||||
* currently being viewed).
|
* currently being viewed).
|
||||||
@ -599,7 +599,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
Director::get_current_page() instanceof SiteTree && in_array($this->ID, Director::get_current_page()->getAncestors()->column())
|
Director::get_current_page() instanceof SiteTree && in_array($this->ID, Director::get_current_page()->getAncestors()->column())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the parent of this page has been removed (or made otherwise unavailable), and is still referenced by
|
* Check if the parent of this page has been removed (or made otherwise unavailable), and is still referenced by
|
||||||
* this child. Any such orphaned page may still require access via the CMS, but should not be shown as accessible
|
* this child. Any such orphaned page may still require access via the CMS, but should not be shown as accessible
|
||||||
@ -610,12 +610,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function isOrphaned() {
|
public function isOrphaned() {
|
||||||
// Always false for root pages
|
// Always false for root pages
|
||||||
if(empty($this->ParentID)) return false;
|
if(empty($this->ParentID)) return false;
|
||||||
|
|
||||||
// Parent must exist and not be an orphan itself
|
// Parent must exist and not be an orphan itself
|
||||||
$parent = $this->Parent();
|
$parent = $this->Parent();
|
||||||
return !$parent || !$parent->exists() || $parent->isOrphaned();
|
return !$parent || !$parent->exists() || $parent->isOrphaned();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return "link" or "current" depending on if this is the {@link SiteTree::isCurrent()} current page.
|
* Return "link" or "current" depending on if this is the {@link SiteTree::isCurrent()} current page.
|
||||||
*
|
*
|
||||||
@ -624,7 +624,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function LinkOrCurrent() {
|
public function LinkOrCurrent() {
|
||||||
return $this->isCurrent() ? 'current' : 'link';
|
return $this->isCurrent() ? 'current' : 'link';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return "link" or "section" depending on if this is the {@link SiteTree::isSeciton()} current section.
|
* Return "link" or "section" depending on if this is the {@link SiteTree::isSeciton()} current section.
|
||||||
*
|
*
|
||||||
@ -633,7 +633,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function LinkOrSection() {
|
public function LinkOrSection() {
|
||||||
return $this->isSection() ? 'section' : 'link';
|
return $this->isSection() ? 'section' : 'link';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return "link", "current" or "section" depending on if this page is the current page, or not on the current page
|
* Return "link", "current" or "section" depending on if this page is the current page, or not on the current page
|
||||||
* but in the current section.
|
* but in the current section.
|
||||||
@ -649,7 +649,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
return 'link';
|
return 'link';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this page is in the given current section.
|
* Check if this page is in the given current section.
|
||||||
*
|
*
|
||||||
@ -674,18 +674,18 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* @return self The duplicated object
|
* @return self The duplicated object
|
||||||
*/
|
*/
|
||||||
public function duplicate($doWrite = true) {
|
public function duplicate($doWrite = true) {
|
||||||
|
|
||||||
$page = parent::duplicate(false);
|
$page = parent::duplicate(false);
|
||||||
$page->Sort = 0;
|
$page->Sort = 0;
|
||||||
$this->invokeWithExtensions('onBeforeDuplicate', $page);
|
$this->invokeWithExtensions('onBeforeDuplicate', $page);
|
||||||
|
|
||||||
if($doWrite) {
|
if($doWrite) {
|
||||||
$page->write();
|
$page->write();
|
||||||
|
|
||||||
$page = $this->duplicateManyManyRelations($this, $page);
|
$page = $this->duplicateManyManyRelations($this, $page);
|
||||||
}
|
}
|
||||||
$this->invokeWithExtensions('onAfterDuplicate', $page);
|
$this->invokeWithExtensions('onAfterDuplicate', $page);
|
||||||
|
|
||||||
return $page;
|
return $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -722,7 +722,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$newSiteTree->Sort = 0;
|
$newSiteTree->Sort = 0;
|
||||||
$newSiteTree->write();
|
$newSiteTree->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a breadcrumb trail to this page. Excludes "hidden" pages (with ShowInMenus=0) by default.
|
* Return a breadcrumb trail to this page. Excludes "hidden" pages (with ShowInMenus=0) by default.
|
||||||
*
|
*
|
||||||
@ -754,7 +754,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function getBreadcrumbItems($maxDepth = 20, $stopAtPageType = false, $showHidden = false) {
|
public function getBreadcrumbItems($maxDepth = 20, $stopAtPageType = false, $showHidden = false) {
|
||||||
$page = $this;
|
$page = $this;
|
||||||
$pages = array();
|
$pages = array();
|
||||||
|
|
||||||
while(
|
while(
|
||||||
$page
|
$page
|
||||||
&& (!$maxDepth || count($pages) < $maxDepth)
|
&& (!$maxDepth || count($pages) < $maxDepth)
|
||||||
@ -763,7 +763,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if($showHidden || $page->ShowInMenus || ($page->ID == $this->ID)) {
|
if($showHidden || $page->ShowInMenus || ($page->ID == $this->ID)) {
|
||||||
$pages[] = $page;
|
$pages[] = $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = $page->Parent;
|
$page = $page->Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,7 +786,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$this->setField("ParentID", $item);
|
$this->setField("ParentID", $item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the parent of this page.
|
* Get the parent of this page.
|
||||||
*
|
*
|
||||||
@ -837,12 +837,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($member && Permission::checkMember($member, "ADMIN")) return true;
|
if($member && Permission::checkMember($member, "ADMIN")) return true;
|
||||||
|
|
||||||
if(is_string($perm) && method_exists($this, 'can' . ucfirst($perm))) {
|
if(is_string($perm) && method_exists($this, 'can' . ucfirst($perm))) {
|
||||||
$method = 'can' . ucfirst($perm);
|
$method = 'can' . ucfirst($perm);
|
||||||
return $this->$method($member);
|
return $this->$method($member);
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = $this->extend('can', $member);
|
$results = $this->extend('can', $member);
|
||||||
if($results && is_array($results)) if(!min($results)) return false;
|
if($results && is_array($results)) if(!min($results)) return false;
|
||||||
|
|
||||||
@ -876,11 +876,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($member && Permission::checkMember($member, "ADMIN")) return true;
|
if($member && Permission::checkMember($member, "ADMIN")) return true;
|
||||||
|
|
||||||
// Standard mechanism for accepting permission changes from extensions
|
// Standard mechanism for accepting permission changes from extensions
|
||||||
$extended = $this->extendedCan('canAddChildren', $member);
|
$extended = $this->extendedCan('canAddChildren', $member);
|
||||||
if($extended !== null) return $extended;
|
if($extended !== null) return $extended;
|
||||||
|
|
||||||
return $this->canEdit($member) && $this->stat('allowed_children') != 'none';
|
return $this->canEdit($member) && $this->stat('allowed_children') != 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -907,14 +907,14 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
// admin override
|
// admin override
|
||||||
if($member && Permission::checkMember($member, array("ADMIN", "SITETREE_VIEW_ALL"))) return true;
|
if($member && Permission::checkMember($member, array("ADMIN", "SITETREE_VIEW_ALL"))) return true;
|
||||||
|
|
||||||
// Orphaned pages (in the current stage) are unavailable, except for admins via the CMS
|
// Orphaned pages (in the current stage) are unavailable, except for admins via the CMS
|
||||||
if($this->isOrphaned()) return false;
|
if($this->isOrphaned()) return false;
|
||||||
|
|
||||||
// Standard mechanism for accepting permission changes from extensions
|
// Standard mechanism for accepting permission changes from extensions
|
||||||
$extended = $this->extendedCan('canView', $member);
|
$extended = $this->extendedCan('canView', $member);
|
||||||
if($extended !== null) return $extended;
|
if($extended !== null) return $extended;
|
||||||
|
|
||||||
// check for empty spec
|
// check for empty spec
|
||||||
if(!$this->CanViewType || $this->CanViewType == 'Anyone') return true;
|
if(!$this->CanViewType || $this->CanViewType == 'Anyone') return true;
|
||||||
|
|
||||||
@ -923,12 +923,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if($this->ParentID) return $this->Parent()->canView($member);
|
if($this->ParentID) return $this->Parent()->canView($member);
|
||||||
else return $this->getSiteConfig()->canViewPages($member);
|
else return $this->getSiteConfig()->canViewPages($member);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for any logged-in users
|
// check for any logged-in users
|
||||||
if($this->CanViewType == 'LoggedInUsers' && $member) {
|
if($this->CanViewType == 'LoggedInUsers' && $member) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for specific groups
|
// check for specific groups
|
||||||
if($member && is_numeric($member)) $member = DataObject::get_by_id('Member', $member);
|
if($member && is_numeric($member)) $member = DataObject::get_by_id('Member', $member);
|
||||||
if(
|
if(
|
||||||
@ -936,7 +936,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
&& $member
|
&& $member
|
||||||
&& $member->inGroups($this->ViewerGroups())
|
&& $member->inGroups($this->ViewerGroups())
|
||||||
) return true;
|
) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -960,18 +960,18 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if($member instanceof Member) $memberID = $member->ID;
|
if($member instanceof Member) $memberID = $member->ID;
|
||||||
else if(is_numeric($member)) $memberID = $member;
|
else if(is_numeric($member)) $memberID = $member;
|
||||||
else $memberID = Member::currentUserID();
|
else $memberID = Member::currentUserID();
|
||||||
|
|
||||||
if($memberID && Permission::checkMember($memberID, array("ADMIN", "SITETREE_EDIT_ALL"))) {
|
if($memberID && Permission::checkMember($memberID, array("ADMIN", "SITETREE_EDIT_ALL"))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Standard mechanism for accepting permission changes from extensions
|
// Standard mechanism for accepting permission changes from extensions
|
||||||
$extended = $this->extendedCan('canDelete', $memberID);
|
$extended = $this->extendedCan('canDelete', $memberID);
|
||||||
if($extended !== null) return $extended;
|
if($extended !== null) return $extended;
|
||||||
|
|
||||||
// Regular canEdit logic is handled by can_edit_multiple
|
// Regular canEdit logic is handled by can_edit_multiple
|
||||||
$results = self::can_delete_multiple(array($this->ID), $memberID);
|
$results = self::can_delete_multiple(array($this->ID), $memberID);
|
||||||
|
|
||||||
// If this page no longer exists in stage/live results won't contain the page.
|
// If this page no longer exists in stage/live results won't contain the page.
|
||||||
// Fail-over to false
|
// Fail-over to false
|
||||||
return isset($results[$this->ID]) ? $results[$this->ID] : false;
|
return isset($results[$this->ID]) ? $results[$this->ID] : false;
|
||||||
@ -1049,9 +1049,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if($member instanceof Member) $memberID = $member->ID;
|
if($member instanceof Member) $memberID = $member->ID;
|
||||||
else if(is_numeric($member)) $memberID = $member;
|
else if(is_numeric($member)) $memberID = $member;
|
||||||
else $memberID = Member::currentUserID();
|
else $memberID = Member::currentUserID();
|
||||||
|
|
||||||
if($memberID && Permission::checkMember($memberID, array("ADMIN", "SITETREE_EDIT_ALL"))) return true;
|
if($memberID && Permission::checkMember($memberID, array("ADMIN", "SITETREE_EDIT_ALL"))) return true;
|
||||||
|
|
||||||
// Standard mechanism for accepting permission changes from extensions
|
// Standard mechanism for accepting permission changes from extensions
|
||||||
$extended = $this->extendedCan('canEdit', $memberID);
|
$extended = $this->extendedCan('canEdit', $memberID);
|
||||||
if($extended !== null) return $extended;
|
if($extended !== null) return $extended;
|
||||||
@ -1063,7 +1063,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// If this page no longer exists in stage/live results won't contain the page.
|
// If this page no longer exists in stage/live results won't contain the page.
|
||||||
// Fail-over to false
|
// Fail-over to false
|
||||||
return isset($results[$this->ID]) ? $results[$this->ID] : false;
|
return isset($results[$this->ID]) ? $results[$this->ID] : false;
|
||||||
|
|
||||||
// Default for unsaved pages
|
// Default for unsaved pages
|
||||||
} else {
|
} else {
|
||||||
return $this->getSiteConfig()->canEditPages($member);
|
return $this->getSiteConfig()->canEditPages($member);
|
||||||
@ -1085,7 +1085,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*/
|
*/
|
||||||
public function canPublish($member = null) {
|
public function canPublish($member = null) {
|
||||||
if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) $member = Member::currentUser();
|
if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) $member = Member::currentUser();
|
||||||
|
|
||||||
if($member && Permission::checkMember($member, "ADMIN")) return true;
|
if($member && Permission::checkMember($member, "ADMIN")) return true;
|
||||||
|
|
||||||
// Standard mechanism for accepting permission changes from extensions
|
// Standard mechanism for accepting permission changes from extensions
|
||||||
@ -1095,7 +1095,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// Normal case - fail over to canEdit()
|
// Normal case - fail over to canEdit()
|
||||||
return $this->canEdit($member);
|
return $this->canEdit($member);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canDeleteFromLive($member = null) {
|
public function canDeleteFromLive($member = null) {
|
||||||
// Standard mechanism for accepting permission changes from extensions
|
// Standard mechanism for accepting permission changes from extensions
|
||||||
$extended = $this->extendedCan('canDeleteFromLive', $member);
|
$extended = $this->extendedCan('canDeleteFromLive', $member);
|
||||||
@ -1103,19 +1103,19 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
return $this->canPublish($member);
|
return $this->canPublish($member);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stub method to get the site config, unless the current class can provide an alternate.
|
* Stub method to get the site config, unless the current class can provide an alternate.
|
||||||
*
|
*
|
||||||
* @return SiteConfig
|
* @return SiteConfig
|
||||||
*/
|
*/
|
||||||
public function getSiteConfig() {
|
public function getSiteConfig() {
|
||||||
|
|
||||||
if($this->hasMethod('alternateSiteConfig')) {
|
if($this->hasMethod('alternateSiteConfig')) {
|
||||||
$altConfig = $this->alternateSiteConfig();
|
$altConfig = $this->alternateSiteConfig();
|
||||||
if($altConfig) return $altConfig;
|
if($altConfig) return $altConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SiteConfig::current_site_config();
|
return SiteConfig::current_site_config();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1130,7 +1130,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) $batchCallback = "SiteTree::can_{$permission}_multiple";
|
if(!$batchCallback) $batchCallback = "SiteTree::can_{$permission}_multiple";
|
||||||
|
|
||||||
if(is_callable($batchCallback)) {
|
if(is_callable($batchCallback)) {
|
||||||
call_user_func($batchCallback, $ids, Member::currentUserID(), false);
|
call_user_func($batchCallback, $ids, Member::currentUserID(), false);
|
||||||
} else {
|
} else {
|
||||||
@ -1163,7 +1163,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
// Sanitise the IDs
|
// Sanitise the IDs
|
||||||
$ids = array_filter($ids, 'is_numeric');
|
$ids = array_filter($ids, 'is_numeric');
|
||||||
|
|
||||||
// This is the name used on the permission cache
|
// This is the name used on the permission cache
|
||||||
// converts something like 'CanEditType' to 'edit'.
|
// converts something like 'CanEditType' to 'edit'.
|
||||||
$cacheKey = strtolower(substr($typeField, 3, -4)) . "-$memberID";
|
$cacheKey = strtolower(substr($typeField, 3, -4)) . "-$memberID";
|
||||||
@ -1175,7 +1175,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// Look in the cache for values
|
// Look in the cache for values
|
||||||
if($useCached && isset(self::$cache_permissions[$cacheKey])) {
|
if($useCached && isset(self::$cache_permissions[$cacheKey])) {
|
||||||
$cachedValues = array_intersect_key(self::$cache_permissions[$cacheKey], $result);
|
$cachedValues = array_intersect_key(self::$cache_permissions[$cacheKey], $result);
|
||||||
|
|
||||||
// If we can't find everything in the cache, then look up the remainder separately
|
// If we can't find everything in the cache, then look up the remainder separately
|
||||||
$uncachedValues = array_diff_key($result, self::$cache_permissions[$cacheKey]);
|
$uncachedValues = array_diff_key($result, self::$cache_permissions[$cacheKey]);
|
||||||
if($uncachedValues) {
|
if($uncachedValues) {
|
||||||
@ -1183,7 +1183,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
return $cachedValues;
|
return $cachedValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a member doesn't have a certain permission then they can't edit anything
|
// If a member doesn't have a certain permission then they can't edit anything
|
||||||
if(!$memberID || ($globalPermission && !Permission::checkMember($memberID, $globalPermission))) {
|
if(!$memberID || ($globalPermission && !Permission::checkMember($memberID, $globalPermission))) {
|
||||||
return $result;
|
return $result;
|
||||||
@ -1195,18 +1195,18 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// If page can't be viewed, don't grant edit permissions to do - implement can_view_multiple(), so this can
|
// If page can't be viewed, don't grant edit permissions to do - implement can_view_multiple(), so this can
|
||||||
// be enabled
|
// be enabled
|
||||||
//$ids = array_keys(array_filter(self::can_view_multiple($ids, $memberID)));
|
//$ids = array_keys(array_filter(self::can_view_multiple($ids, $memberID)));
|
||||||
|
|
||||||
// Get the groups that the given member belongs to
|
// Get the groups that the given member belongs to
|
||||||
$groupIDs = DataObject::get_by_id('Member', $memberID)->Groups()->column("ID");
|
$groupIDs = DataObject::get_by_id('Member', $memberID)->Groups()->column("ID");
|
||||||
$SQL_groupList = implode(", ", $groupIDs);
|
$SQL_groupList = implode(", ", $groupIDs);
|
||||||
if (!$SQL_groupList) $SQL_groupList = '0';
|
if (!$SQL_groupList) $SQL_groupList = '0';
|
||||||
|
|
||||||
$combinedStageResult = array();
|
$combinedStageResult = array();
|
||||||
|
|
||||||
foreach(array('Stage', 'Live') as $stage) {
|
foreach(array('Stage', 'Live') as $stage) {
|
||||||
// Start by filling the array with the pages that actually exist
|
// Start by filling the array with the pages that actually exist
|
||||||
$table = ($stage=='Stage') ? "SiteTree" : "SiteTree_$stage";
|
$table = ($stage=='Stage') ? "SiteTree" : "SiteTree_$stage";
|
||||||
|
|
||||||
if($ids) {
|
if($ids) {
|
||||||
$idQuery = "SELECT \"ID\" FROM \"$table\" WHERE \"ID\" IN ($idPlaceholders)";
|
$idQuery = "SELECT \"ID\" FROM \"$table\" WHERE \"ID\" IN ($idPlaceholders)";
|
||||||
$stageIds = DB::prepared_query($idQuery, $ids)->column();
|
$stageIds = DB::prepared_query($idQuery, $ids)->column();
|
||||||
@ -1214,7 +1214,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$stageIds = array();
|
$stageIds = array();
|
||||||
}
|
}
|
||||||
$result = array_fill_keys($stageIds, false);
|
$result = array_fill_keys($stageIds, false);
|
||||||
|
|
||||||
// Get the uninherited permissions
|
// Get the uninherited permissions
|
||||||
$uninheritedPermissions = Versioned::get_by_stage("SiteTree", $stage)
|
$uninheritedPermissions = Versioned::get_by_stage("SiteTree", $stage)
|
||||||
->where(array(
|
->where(array(
|
||||||
@ -1224,7 +1224,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
=> $ids
|
=> $ids
|
||||||
))
|
))
|
||||||
->leftJoin($groupJoinTable, "\"$groupJoinTable\".\"SiteTreeID\" = \"SiteTree\".\"ID\" AND \"$groupJoinTable\".\"GroupID\" IN ($SQL_groupList)");
|
->leftJoin($groupJoinTable, "\"$groupJoinTable\".\"SiteTreeID\" = \"SiteTree\".\"ID\" AND \"$groupJoinTable\".\"GroupID\" IN ($SQL_groupList)");
|
||||||
|
|
||||||
if($uninheritedPermissions) {
|
if($uninheritedPermissions) {
|
||||||
// Set all the relevant items in $result to true
|
// Set all the relevant items in $result to true
|
||||||
$result = array_fill_keys($uninheritedPermissions->column('ID'), true) + $result;
|
$result = array_fill_keys($uninheritedPermissions->column('ID'), true) + $result;
|
||||||
@ -1264,9 +1264,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$combinedStageResult = $combinedStageResult + $result;
|
$combinedStageResult = $combinedStageResult + $result;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1306,11 +1306,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$deletable = array();
|
$deletable = array();
|
||||||
$result = array_fill_keys($ids, false);
|
$result = array_fill_keys($ids, false);
|
||||||
$cacheKey = "delete-$memberID";
|
$cacheKey = "delete-$memberID";
|
||||||
|
|
||||||
// Look in the cache for values
|
// Look in the cache for values
|
||||||
if($useCached && isset(self::$cache_permissions[$cacheKey])) {
|
if($useCached && isset(self::$cache_permissions[$cacheKey])) {
|
||||||
$cachedValues = array_intersect_key(self::$cache_permissions[$cacheKey], $result);
|
$cachedValues = array_intersect_key(self::$cache_permissions[$cacheKey], $result);
|
||||||
|
|
||||||
// If we can't find everything in the cache, then look up the remainder separately
|
// If we can't find everything in the cache, then look up the remainder separately
|
||||||
$uncachedValues = array_diff_key($result, self::$cache_permissions[$cacheKey]);
|
$uncachedValues = array_diff_key($result, self::$cache_permissions[$cacheKey]);
|
||||||
if($uncachedValues) {
|
if($uncachedValues) {
|
||||||
@ -1323,7 +1323,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// You can only delete pages that you can edit
|
// You can only delete pages that you can edit
|
||||||
$editableIDs = array_keys(array_filter(self::can_edit_multiple($ids, $memberID)));
|
$editableIDs = array_keys(array_filter(self::can_edit_multiple($ids, $memberID)));
|
||||||
if($editableIDs) {
|
if($editableIDs) {
|
||||||
|
|
||||||
// You can only delete pages whose children you can delete
|
// You can only delete pages whose children you can delete
|
||||||
$editablePlaceholders = DB::placeholders($editableIDs);
|
$editablePlaceholders = DB::placeholders($editableIDs);
|
||||||
$childRecords = SiteTree::get()->where(array(
|
$childRecords = SiteTree::get()->where(array(
|
||||||
@ -1334,7 +1334,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
// Find out the children that can be deleted
|
// Find out the children that can be deleted
|
||||||
$deletableChildren = self::can_delete_multiple($children->keys(), $memberID);
|
$deletableChildren = self::can_delete_multiple($children->keys(), $memberID);
|
||||||
|
|
||||||
// Get a list of all the parents that have no undeletable children
|
// Get a list of all the parents that have no undeletable children
|
||||||
$deletableParents = array_fill_keys($editableIDs, true);
|
$deletableParents = array_fill_keys($editableIDs, true);
|
||||||
foreach($deletableChildren as $id => $canDelete) {
|
foreach($deletableChildren as $id => $canDelete) {
|
||||||
@ -1357,7 +1357,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
} else {
|
} else {
|
||||||
$deletable = array();
|
$deletable = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the array of deletable IDs into a map of the original IDs with true/false as the value
|
// Convert the array of deletable IDs into a map of the original IDs with true/false as the value
|
||||||
return array_fill_keys($deletable, true) + array_fill_keys($ids, false);
|
return array_fill_keys($deletable, true) + array_fill_keys($ids, false);
|
||||||
}
|
}
|
||||||
@ -1409,7 +1409,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if($this->ExtraMeta) {
|
if($this->ExtraMeta) {
|
||||||
$tags .= $this->ExtraMeta . "\n";
|
$tags .= $this->ExtraMeta . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Permission::check('CMS_ACCESS_CMSMain')
|
if(Permission::check('CMS_ACCESS_CMSMain')
|
||||||
&& in_array('CMSPreviewable', class_implements($this))
|
&& in_array('CMSPreviewable', class_implements($this))
|
||||||
&& !$this instanceof ErrorPage
|
&& !$this instanceof ErrorPage
|
||||||
@ -1444,7 +1444,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*/
|
*/
|
||||||
public function requireDefaultRecords() {
|
public function requireDefaultRecords() {
|
||||||
parent::requireDefaultRecords();
|
parent::requireDefaultRecords();
|
||||||
|
|
||||||
// default pages
|
// default pages
|
||||||
if($this->class == 'SiteTree' && $this->config()->create_default_pages) {
|
if($this->class == 'SiteTree' && $this->config()->create_default_pages) {
|
||||||
if(!SiteTree::get_by_link(Config::inst()->get('RootURLController', 'default_homepage_link'))) {
|
if(!SiteTree::get_by_link(Config::inst()->get('RootURLController', 'default_homepage_link'))) {
|
||||||
@ -1479,7 +1479,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
DB::alteration_message('Contact Us page created', 'created');
|
DB::alteration_message('Contact Us page created', 'created');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// schema migration
|
// schema migration
|
||||||
// @todo Move to migration task once infrastructure is implemented
|
// @todo Move to migration task once infrastructure is implemented
|
||||||
if($this->class == 'SiteTree') {
|
if($this->class == 'SiteTree') {
|
||||||
@ -1519,7 +1519,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// If after sanitising there is no URLSegment, give it a reasonable default
|
// If after sanitising there is no URLSegment, give it a reasonable default
|
||||||
if(!$this->URLSegment) $this->URLSegment = "page-$this->ID";
|
if(!$this->URLSegment) $this->URLSegment = "page-$this->ID";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that this object has a non-conflicting URLSegment value.
|
// Ensure that this object has a non-conflicting URLSegment value.
|
||||||
$count = 2;
|
$count = 2;
|
||||||
while(!$this->validURLSegment()) {
|
while(!$this->validURLSegment()) {
|
||||||
@ -1542,15 +1542,15 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$this->migrateVersion($this->Version);
|
$this->migrateVersion($this->Version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function syncLinkTracking() {
|
public function syncLinkTracking() {
|
||||||
$this->extend('augmentSyncLinkTracking');
|
$this->extend('augmentSyncLinkTracking');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onAfterWrite() {
|
public function onAfterWrite() {
|
||||||
// Need to flush cache to avoid outdated versionnumber references
|
// Need to flush cache to avoid outdated versionnumber references
|
||||||
$this->flushCache();
|
$this->flushCache();
|
||||||
|
|
||||||
$linkedPages = $this->VirtualPages();
|
$linkedPages = $this->VirtualPages();
|
||||||
if($linkedPages) {
|
if($linkedPages) {
|
||||||
// The only way after a write() call to determine if it was triggered by a writeWithoutVersion(),
|
// The only way after a write() call to determine if it was triggered by a writeWithoutVersion(),
|
||||||
@ -1563,13 +1563,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
else $page->write();
|
else $page->write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::onAfterWrite();
|
parent::onAfterWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onBeforeDelete() {
|
public function onBeforeDelete() {
|
||||||
parent::onBeforeDelete();
|
parent::onBeforeDelete();
|
||||||
|
|
||||||
// If deleting this page, delete all its children.
|
// If deleting this page, delete all its children.
|
||||||
if(SiteTree::config()->enforce_strict_hierarchy && $children = $this->AllChildren()) {
|
if(SiteTree::config()->enforce_strict_hierarchy && $children = $this->AllChildren()) {
|
||||||
foreach($children as $child) {
|
foreach($children as $child) {
|
||||||
@ -1577,18 +1577,18 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onAfterDelete() {
|
public function onAfterDelete() {
|
||||||
// Need to flush cache to avoid outdated versionnumber references
|
// Need to flush cache to avoid outdated versionnumber references
|
||||||
$this->flushCache();
|
$this->flushCache();
|
||||||
|
|
||||||
// Need to mark pages depending to this one as broken
|
// Need to mark pages depending to this one as broken
|
||||||
$dependentPages = $this->DependentPages();
|
$dependentPages = $this->DependentPages();
|
||||||
if($dependentPages) foreach($dependentPages as $page) {
|
if($dependentPages) foreach($dependentPages as $page) {
|
||||||
// $page->write() calls syncLinkTracking, which does all the hard work for us.
|
// $page->write() calls syncLinkTracking, which does all the hard work for us.
|
||||||
$page->write();
|
$page->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::onAfterDelete();
|
parent::onAfterDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1596,7 +1596,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
parent::flushCache($persistent);
|
parent::flushCache($persistent);
|
||||||
$this->_cache_statusFlags = null;
|
$this->_cache_statusFlags = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function validate() {
|
protected function validate() {
|
||||||
$result = parent::validate();
|
$result = parent::validate();
|
||||||
|
|
||||||
@ -1608,7 +1608,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$allowed = $parent->allowedChildren();
|
$allowed = $parent->allowedChildren();
|
||||||
$subject = ($this instanceof VirtualPage && $this->CopyContentFromID) ? $this->CopyContentFrom() : $this;
|
$subject = ($this instanceof VirtualPage && $this->CopyContentFromID) ? $this->CopyContentFrom() : $this;
|
||||||
if(!in_array($subject->ClassName, $allowed)) {
|
if(!in_array($subject->ClassName, $allowed)) {
|
||||||
|
|
||||||
$result->error(
|
$result->error(
|
||||||
_t(
|
_t(
|
||||||
'SiteTree.PageTypeNotAllowed',
|
'SiteTree.PageTypeNotAllowed',
|
||||||
@ -1631,10 +1631,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
'CAN_BE_ROOT'
|
'CAN_BE_ROOT'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this object has a URLSegment value that does not conflict with any other objects. This method
|
* Returns true if this object has a URLSegment value that does not conflict with any other objects. This method
|
||||||
* checks for:
|
* checks for:
|
||||||
@ -1650,11 +1650,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if($controller instanceof Controller && $controller->hasAction($this->URLSegment)) return false;
|
if($controller instanceof Controller && $controller->hasAction($this->URLSegment)) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!self::config()->nested_urls || !$this->ParentID) {
|
if(!self::config()->nested_urls || !$this->ParentID) {
|
||||||
if(class_exists($this->URLSegment) && is_subclass_of($this->URLSegment, 'RequestHandler')) return false;
|
if(class_exists($this->URLSegment) && is_subclass_of($this->URLSegment, 'RequestHandler')) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filters by url, id, and parent
|
// Filters by url, id, and parent
|
||||||
$filter = array('"SiteTree"."URLSegment"' => $this->URLSegment);
|
$filter = array('"SiteTree"."URLSegment"' => $this->URLSegment);
|
||||||
if($this->ID) {
|
if($this->ID) {
|
||||||
@ -1663,7 +1663,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if(self::config()->nested_urls) {
|
if(self::config()->nested_urls) {
|
||||||
$filter['"SiteTree"."ParentID"'] = $this->ParentID ? $this->ParentID : 0;
|
$filter['"SiteTree"."ParentID"'] = $this->ParentID ? $this->ParentID : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$votes = array_filter(
|
$votes = array_filter(
|
||||||
(array)$this->extend('augmentValidURLSegment'),
|
(array)$this->extend('augmentValidURLSegment'),
|
||||||
function($v) {return !is_null($v);}
|
function($v) {return !is_null($v);}
|
||||||
@ -1678,7 +1678,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
return !($existingPage);
|
return !($existingPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a URL segment based on the title provided.
|
* Generate a URL segment based on the title provided.
|
||||||
*
|
*
|
||||||
@ -1693,16 +1693,16 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function generateURLSegment($title){
|
public function generateURLSegment($title){
|
||||||
$filter = URLSegmentFilter::create();
|
$filter = URLSegmentFilter::create();
|
||||||
$t = $filter->filter($title);
|
$t = $filter->filter($title);
|
||||||
|
|
||||||
// Fallback to generic page name if path is empty (= no valid, convertable characters)
|
// Fallback to generic page name if path is empty (= no valid, convertable characters)
|
||||||
if(!$t || $t == '-' || $t == '-1') $t = "page-$this->ID";
|
if(!$t || $t == '-' || $t == '-1') $t = "page-$this->ID";
|
||||||
|
|
||||||
// Hook for extensions
|
// Hook for extensions
|
||||||
$this->extend('updateURLSegment', $t, $title);
|
$this->extend('updateURLSegment', $t, $title);
|
||||||
|
|
||||||
return $t;
|
return $t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the URL segment for the latest draft version of this page.
|
* Gets the URL segment for the latest draft version of this page.
|
||||||
*
|
*
|
||||||
@ -1714,7 +1714,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
));
|
));
|
||||||
return ($stageRecord) ? $stageRecord->URLSegment : null;
|
return ($stageRecord) ? $stageRecord->URLSegment : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the URL segment for the currently published version of this page.
|
* Gets the URL segment for the currently published version of this page.
|
||||||
*
|
*
|
||||||
@ -1726,7 +1726,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
));
|
));
|
||||||
return ($liveRecord) ? $liveRecord->URLSegment : null;
|
return ($liveRecord) ? $liveRecord->URLSegment : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rewrite a file URL on this page, after its been renamed. Triggers the onRenameLinkedAsset action on extensions.
|
* Rewrite a file URL on this page, after its been renamed. Triggers the onRenameLinkedAsset action on extensions.
|
||||||
*/
|
*/
|
||||||
@ -1750,7 +1750,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if($numReplaced) {
|
if($numReplaced) {
|
||||||
$query = sprintf('UPDATE "%s" SET "%s" = ? WHERE "ID" = ?', $table, $fieldName);
|
$query = sprintf('UPDATE "%s" SET "%s" = ? WHERE "ID" = ?', $table, $fieldName);
|
||||||
DB::prepared_query($query, array($published[$fieldName], $this->ID));
|
DB::prepared_query($query, array($published[$fieldName], $this->ID));
|
||||||
|
|
||||||
// Tell static caching to update itself
|
// Tell static caching to update itself
|
||||||
if($table == 'SiteTree_Live') {
|
if($table == 'SiteTree_Live') {
|
||||||
$publishedClass = $origPublished['ClassName'];
|
$publishedClass = $origPublished['ClassName'];
|
||||||
@ -1762,7 +1762,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the pages that depend on this page. This includes virtual pages, pages that link to it, etc.
|
* Returns the pages that depend on this page. This includes virtual pages, pages that link to it, etc.
|
||||||
*
|
*
|
||||||
@ -1774,7 +1774,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$origDisableSubsiteFilter = Subsite::$disable_subsite_filter;
|
$origDisableSubsiteFilter = Subsite::$disable_subsite_filter;
|
||||||
Subsite::disable_subsite_filter(true);
|
Subsite::disable_subsite_filter(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Content links
|
// Content links
|
||||||
$items = new ArrayList();
|
$items = new ArrayList();
|
||||||
|
|
||||||
@ -1787,7 +1787,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
$items->merge($linkList);
|
$items->merge($linkList);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Virtual pages
|
// Virtual pages
|
||||||
if($includeVirtuals) {
|
if($includeVirtuals) {
|
||||||
$virtuals = $this->VirtualPages();
|
$virtuals = $this->VirtualPages();
|
||||||
@ -1816,7 +1816,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(class_exists('Subsite')) Subsite::disable_subsite_filter($origDisableSubsiteFilter);
|
if(class_exists('Subsite')) Subsite::disable_subsite_filter($origDisableSubsiteFilter);
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1826,10 +1826,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* @return DataList
|
* @return DataList
|
||||||
*/
|
*/
|
||||||
public function VirtualPages() {
|
public function VirtualPages() {
|
||||||
|
|
||||||
// Ignore new records
|
// Ignore new records
|
||||||
if(!$this->ID) return null;
|
if(!$this->ID) return null;
|
||||||
|
|
||||||
// Check subsite virtual pages
|
// Check subsite virtual pages
|
||||||
// @todo Refactor out subsite module specific code
|
// @todo Refactor out subsite module specific code
|
||||||
if(class_exists('Subsite')) {
|
if(class_exists('Subsite')) {
|
||||||
@ -1837,14 +1837,14 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
'"VirtualPage"."CopyContentFromID"' => $this->ID
|
'"VirtualPage"."CopyContentFromID"' => $this->ID
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check existing virtualpages
|
// Check existing virtualpages
|
||||||
if(class_exists('VirtualPage')) {
|
if(class_exists('VirtualPage')) {
|
||||||
return VirtualPage::get()->where(array(
|
return VirtualPage::get()->where(array(
|
||||||
'"VirtualPage"."CopyContentFromID"' => $this->ID
|
'"VirtualPage"."CopyContentFromID"' => $this->ID
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1904,7 +1904,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
$dependentNote = '';
|
$dependentNote = '';
|
||||||
$dependentTable = new LiteralField('DependentNote', '<p></p>');
|
$dependentTable = new LiteralField('DependentNote', '<p></p>');
|
||||||
|
|
||||||
// Create a table for showing pages linked to this one
|
// Create a table for showing pages linked to this one
|
||||||
$dependentPages = $this->DependentPages();
|
$dependentPages = $this->DependentPages();
|
||||||
$dependentPagesCount = $dependentPages->Count();
|
$dependentPagesCount = $dependentPages->Count();
|
||||||
@ -1915,7 +1915,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
'DependentLinkType' => _t('SiteTree.DependtPageColumnLinkType', 'Link type'),
|
'DependentLinkType' => _t('SiteTree.DependtPageColumnLinkType', 'Link type'),
|
||||||
);
|
);
|
||||||
if(class_exists('Subsite')) $dependentColumns['Subsite.Title'] = singleton('Subsite')->i18n_singular_name();
|
if(class_exists('Subsite')) $dependentColumns['Subsite.Title'] = singleton('Subsite')->i18n_singular_name();
|
||||||
|
|
||||||
$dependentNote = new LiteralField('DependentNote', '<p>' . _t('SiteTree.DEPENDENT_NOTE', 'The following pages depend on this page. This includes virtual pages, redirector pages, and pages with content links.') . '</p>');
|
$dependentNote = new LiteralField('DependentNote', '<p>' . _t('SiteTree.DEPENDENT_NOTE', 'The following pages depend on this page. This includes virtual pages, redirector pages, and pages with content links.') . '</p>');
|
||||||
$dependentTable = GridField::create(
|
$dependentTable = GridField::create(
|
||||||
'DependentPages',
|
'DependentPages',
|
||||||
@ -1941,12 +1941,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$baseLink = Controller::join_links (
|
$baseLink = Controller::join_links (
|
||||||
Director::absoluteBaseURL(),
|
Director::absoluteBaseURL(),
|
||||||
(self::config()->nested_urls && $this->ParentID ? $this->Parent()->RelativeLink(true) : null)
|
(self::config()->nested_urls && $this->ParentID ? $this->Parent()->RelativeLink(true) : null)
|
||||||
);
|
);
|
||||||
|
|
||||||
$urlsegment = SiteTreeURLSegmentField::create("URLSegment", $this->fieldLabel('URLSegment'))
|
$urlsegment = SiteTreeURLSegmentField::create("URLSegment", $this->fieldLabel('URLSegment'))
|
||||||
->setURLPrefix($baseLink)
|
->setURLPrefix($baseLink)
|
||||||
->setDefaultURL($this->generateURLSegment(_t(
|
->setDefaultURL($this->generateURLSegment(_t(
|
||||||
@ -1959,7 +1959,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$helpText .= _t('SiteTreeURLSegmentField.HelpChars', ' Special characters are automatically converted or removed.');
|
$helpText .= _t('SiteTreeURLSegmentField.HelpChars', ' Special characters are automatically converted or removed.');
|
||||||
}
|
}
|
||||||
$urlsegment->setHelpText($helpText);
|
$urlsegment->setHelpText($helpText);
|
||||||
|
|
||||||
$fields = new FieldList(
|
$fields = new FieldList(
|
||||||
$rootTab = new TabSet("Root",
|
$rootTab = new TabSet("Root",
|
||||||
$tabMain = new Tab('Main',
|
$tabMain = new Tab('Main',
|
||||||
@ -1981,7 +1981,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
$htmlField->addExtraClass('stacked');
|
$htmlField->addExtraClass('stacked');
|
||||||
|
|
||||||
// Help text for MetaData on page content editor
|
// Help text for MetaData on page content editor
|
||||||
$metaFieldDesc
|
$metaFieldDesc
|
||||||
->setRightTitle(
|
->setRightTitle(
|
||||||
@ -2003,7 +2003,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// Conditional dependent pages tab
|
// Conditional dependent pages tab
|
||||||
if($dependentPagesCount) $tabDependent->setTitle(_t('SiteTree.TABDEPENDENT', "Dependent pages") . " ($dependentPagesCount)");
|
if($dependentPagesCount) $tabDependent->setTitle(_t('SiteTree.TABDEPENDENT', "Dependent pages") . " ($dependentPagesCount)");
|
||||||
else $fields->removeFieldFromTab('Root', 'Dependent');
|
else $fields->removeFieldFromTab('Root', 'Dependent');
|
||||||
|
|
||||||
$tabMain->setTitle(_t('SiteTree.TABCONTENT', "Main Content"));
|
$tabMain->setTitle(_t('SiteTree.TABCONTENT', "Main Content"));
|
||||||
|
|
||||||
if($this->ObsoleteClassName) {
|
if($this->ObsoleteClassName) {
|
||||||
@ -2032,15 +2032,15 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
'/^Root\.Content\.Main$/' => 'Root.Main',
|
'/^Root\.Content\.Main$/' => 'Root.Main',
|
||||||
'/^Root\.Content\.([^.]+)$/' => 'Root.\\1',
|
'/^Root\.Content\.([^.]+)$/' => 'Root.\\1',
|
||||||
));
|
));
|
||||||
|
|
||||||
if(self::$runCMSFieldsExtensions) {
|
if(self::$runCMSFieldsExtensions) {
|
||||||
$this->extend('updateCMSFields', $fields);
|
$this->extend('updateCMSFields', $fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns fields related to configuration aspects on this record, e.g. access control. See {@link getCMSFields()}
|
* Returns fields related to configuration aspects on this record, e.g. access control. See {@link getCMSFields()}
|
||||||
* for content-related fields.
|
* for content-related fields.
|
||||||
@ -2054,7 +2054,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
|
$groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
|
||||||
}
|
}
|
||||||
asort($groupsMap);
|
asort($groupsMap);
|
||||||
|
|
||||||
$fields = new FieldList(
|
$fields = new FieldList(
|
||||||
$rootTab = new TabSet("Root",
|
$rootTab = new TabSet("Root",
|
||||||
$tabBehaviour = new Tab('Settings',
|
$tabBehaviour = new Tab('Settings',
|
||||||
@ -2064,7 +2064,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$this->getClassDropdown()
|
$this->getClassDropdown()
|
||||||
),
|
),
|
||||||
$parentTypeSelector = new CompositeField(
|
$parentTypeSelector = new CompositeField(
|
||||||
new OptionsetField("ParentType", _t("SiteTree.PAGELOCATION", "Page location"), array(
|
$parentType = new OptionsetField("ParentType", _t("SiteTree.PAGELOCATION", "Page location"), array(
|
||||||
"root" => _t("SiteTree.PARENTTYPE_ROOT", "Top-level page"),
|
"root" => _t("SiteTree.PARENTTYPE_ROOT", "Top-level page"),
|
||||||
"subpage" => _t("SiteTree.PARENTTYPE_SUBPAGE", "Sub-page underneath a parent page"),
|
"subpage" => _t("SiteTree.PARENTTYPE_SUBPAGE", "Sub-page underneath a parent page"),
|
||||||
)),
|
)),
|
||||||
@ -2099,17 +2099,18 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$parentType->addExtraClass('noborder');
|
||||||
$visibility->setTitle($this->fieldLabel('Visibility'));
|
$visibility->setTitle($this->fieldLabel('Visibility'));
|
||||||
|
|
||||||
|
|
||||||
// This filter ensures that the ParentID dropdown selection does not show this node,
|
// This filter ensures that the ParentID dropdown selection does not show this node,
|
||||||
// or its descendents, as this causes vanishing bugs
|
// or its descendents, as this causes vanishing bugs
|
||||||
$parentIDField->setFilterFunction(create_function('$node', "return \$node->ID != {$this->ID};"));
|
$parentIDField->setFilterFunction(create_function('$node', "return \$node->ID != {$this->ID};"));
|
||||||
$parentTypeSelector->addExtraClass('parentTypeSelector');
|
$parentTypeSelector->addExtraClass('parentTypeSelector');
|
||||||
|
|
||||||
$tabBehaviour->setTitle(_t('SiteTree.TABBEHAVIOUR', "Behavior"));
|
$tabBehaviour->setTitle(_t('SiteTree.TABBEHAVIOUR', "Behavior"));
|
||||||
|
|
||||||
// Make page location fields read-only if the user doesn't have the appropriate permission
|
// Make page location fields read-only if the user doesn't have the appropriate permission
|
||||||
if(!Permission::check("SITETREE_REORGANISE")) {
|
if(!Permission::check("SITETREE_REORGANISE")) {
|
||||||
$fields->makeFieldReadonly('ParentType');
|
$fields->makeFieldReadonly('ParentType');
|
||||||
@ -2119,14 +2120,14 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$fields->makeFieldReadonly('ParentID');
|
$fields->makeFieldReadonly('ParentID');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$viewersOptionsSource = array();
|
$viewersOptionsSource = array();
|
||||||
$viewersOptionsSource["Inherit"] = _t('SiteTree.INHERIT', "Inherit from parent page");
|
$viewersOptionsSource["Inherit"] = _t('SiteTree.INHERIT', "Inherit from parent page");
|
||||||
$viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
|
$viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
|
||||||
$viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
|
$viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
|
||||||
$viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
|
$viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
|
||||||
$viewersOptionsField->setSource($viewersOptionsSource);
|
$viewersOptionsField->setSource($viewersOptionsSource);
|
||||||
|
|
||||||
$editorsOptionsSource = array();
|
$editorsOptionsSource = array();
|
||||||
$editorsOptionsSource["Inherit"] = _t('SiteTree.INHERIT', "Inherit from parent page");
|
$editorsOptionsSource["Inherit"] = _t('SiteTree.INHERIT', "Inherit from parent page");
|
||||||
$editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS");
|
$editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS");
|
||||||
@ -2140,7 +2141,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
} else {
|
} else {
|
||||||
$fields->removeByName('ViewerGroups');
|
$fields->removeByName('ViewerGroups');
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields->makeFieldReadonly($editorsOptionsField);
|
$fields->makeFieldReadonly($editorsOptionsField);
|
||||||
if($this->CanEditType == 'OnlyTheseUsers') {
|
if($this->CanEditType == 'OnlyTheseUsers') {
|
||||||
$fields->makeFieldReadonly($editorGroupsField);
|
$fields->makeFieldReadonly($editorGroupsField);
|
||||||
@ -2148,14 +2149,14 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$fields->removeByName('EditorGroups');
|
$fields->removeByName('EditorGroups');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self::$runCMSFieldsExtensions) {
|
if(self::$runCMSFieldsExtensions) {
|
||||||
$this->extend('updateSettingsFields', $fields);
|
$this->extend('updateSettingsFields', $fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $includerelations A boolean value to indicate if the labels returned should include relation fields
|
* @param bool $includerelations A boolean value to indicate if the labels returned should include relation fields
|
||||||
* @return array
|
* @return array
|
||||||
@ -2185,7 +2186,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$labels['LinkChangeNote'] = _t (
|
$labels['LinkChangeNote'] = _t (
|
||||||
'SiteTree.LINKCHANGENOTE', 'Changing this page\'s link will also affect the links of all child pages.'
|
'SiteTree.LINKCHANGENOTE', 'Changing this page\'s link will also affect the links of all child pages.'
|
||||||
);
|
);
|
||||||
|
|
||||||
if($includerelations){
|
if($includerelations){
|
||||||
$labels['Parent'] = _t('SiteTree.has_one_Parent', 'Parent Page', 'The parent page in the site hierarchy');
|
$labels['Parent'] = _t('SiteTree.has_one_Parent', 'Parent Page', 'The parent page in the site hierarchy');
|
||||||
$labels['LinkTracking'] = _t('SiteTree.many_many_LinkTracking', 'Link Tracking');
|
$labels['LinkTracking'] = _t('SiteTree.many_many_LinkTracking', 'Link Tracking');
|
||||||
@ -2290,7 +2291,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
} else {
|
} else {
|
||||||
// Determine if we should force a restore to root (where once it was a subpage)
|
// Determine if we should force a restore to root (where once it was a subpage)
|
||||||
$restoreToRoot = $this->isParentArchived();
|
$restoreToRoot = $this->isParentArchived();
|
||||||
|
|
||||||
// "restore"
|
// "restore"
|
||||||
$title = $restoreToRoot
|
$title = $restoreToRoot
|
||||||
? _t('CMSMain.RESTORE_TO_ROOT','Restore draft at top level')
|
? _t('CMSMain.RESTORE_TO_ROOT','Restore draft at top level')
|
||||||
@ -2329,7 +2330,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
->addExtraClass('delete ss-ui-action-destructive')
|
->addExtraClass('delete ss-ui-action-destructive')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// "save", supports an alternate state that is still clickable, but notifies the user that the action is not needed.
|
// "save", supports an alternate state that is still clickable, but notifies the user that the action is not needed.
|
||||||
$majorActions->push(
|
$majorActions->push(
|
||||||
FormAction::create('save', _t('SiteTree.BUTTONSAVED', 'Saved'))
|
FormAction::create('save', _t('SiteTree.BUTTONSAVED', 'Saved'))
|
||||||
@ -2354,15 +2355,15 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$publish->addExtraClass('ss-ui-alternate');
|
$publish->addExtraClass('ss-ui-alternate');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$actions = new FieldList(array($majorActions, $rootTabSet));
|
$actions = new FieldList(array($majorActions, $rootTabSet));
|
||||||
|
|
||||||
// Hook for extensions to add/remove actions.
|
// Hook for extensions to add/remove actions.
|
||||||
$this->extend('updateCMSActions', $actions);
|
$this->extend('updateCMSActions', $actions);
|
||||||
|
|
||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish this page.
|
* Publish this page.
|
||||||
*
|
*
|
||||||
@ -2372,7 +2373,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*/
|
*/
|
||||||
public function doPublish() {
|
public function doPublish() {
|
||||||
if (!$this->canPublish()) return false;
|
if (!$this->canPublish()) return false;
|
||||||
|
|
||||||
$original = Versioned::get_one_by_stage("SiteTree", "Live", array(
|
$original = Versioned::get_one_by_stage("SiteTree", "Live", array(
|
||||||
'"SiteTree"."ID"' => $this->ID
|
'"SiteTree"."ID"' => $this->ID
|
||||||
));
|
));
|
||||||
@ -2389,7 +2390,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
WHERE EXISTS (SELECT "SiteTree"."Sort" FROM "SiteTree" WHERE "SiteTree_Live"."ID" = "SiteTree"."ID") AND "ParentID" = ?',
|
WHERE EXISTS (SELECT "SiteTree"."Sort" FROM "SiteTree" WHERE "SiteTree_Live"."ID" = "SiteTree"."ID") AND "ParentID" = ?',
|
||||||
array($this->ParentID)
|
array($this->ParentID)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Publish any virtual pages that might need publishing
|
// Publish any virtual pages that might need publishing
|
||||||
$linkedPages = $this->VirtualPages();
|
$linkedPages = $this->VirtualPages();
|
||||||
if($linkedPages) foreach($linkedPages as $page) {
|
if($linkedPages) foreach($linkedPages as $page) {
|
||||||
@ -2397,7 +2398,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$page->write();
|
$page->write();
|
||||||
if($page->getExistsOnLive()) $page->doPublish();
|
if($page->getExistsOnLive()) $page->doPublish();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need to update pages linking to this one as no longer broken, on the live site
|
// Need to update pages linking to this one as no longer broken, on the live site
|
||||||
$origMode = Versioned::get_reading_mode();
|
$origMode = Versioned::get_reading_mode();
|
||||||
Versioned::reading_stage('Live');
|
Versioned::reading_stage('Live');
|
||||||
@ -2406,13 +2407,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$page->write();
|
$page->write();
|
||||||
}
|
}
|
||||||
Versioned::set_reading_mode($origMode);
|
Versioned::set_reading_mode($origMode);
|
||||||
|
|
||||||
// Handle activities undertaken by extensions
|
// Handle activities undertaken by extensions
|
||||||
$this->invokeWithExtensions('onAfterPublish', $original);
|
$this->invokeWithExtensions('onAfterPublish', $original);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unpublish this page - remove it from the live site
|
* Unpublish this page - remove it from the live site
|
||||||
*
|
*
|
||||||
@ -2422,9 +2423,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function doUnpublish() {
|
public function doUnpublish() {
|
||||||
if(!$this->canDeleteFromLive()) return false;
|
if(!$this->canDeleteFromLive()) return false;
|
||||||
if(!$this->ID) return false;
|
if(!$this->ID) return false;
|
||||||
|
|
||||||
$this->invokeWithExtensions('onBeforeUnpublish', $this);
|
$this->invokeWithExtensions('onBeforeUnpublish', $this);
|
||||||
|
|
||||||
$origStage = Versioned::current_stage();
|
$origStage = Versioned::current_stage();
|
||||||
Versioned::reading_stage('Live');
|
Versioned::reading_stage('Live');
|
||||||
|
|
||||||
@ -2457,7 +2458,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Revert the draft changes: replace the draft content with the content on live
|
* Revert the draft changes: replace the draft content with the content on live
|
||||||
*/
|
*/
|
||||||
@ -2475,7 +2476,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// $page->write() calls syncLinkTracking, which does all the hard work for us.
|
// $page->write() calls syncLinkTracking, which does all the hard work for us.
|
||||||
$page->write();
|
$page->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->invokeWithExtensions('onAfterRevertToLive', $this);
|
$this->invokeWithExtensions('onAfterRevertToLive', $this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2494,7 +2495,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restore the content in the active copy of this SiteTree page to the stage site.
|
* Restore the content in the active copy of this SiteTree page to the stage site.
|
||||||
*
|
*
|
||||||
@ -2507,7 +2508,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if($this->isParentArchived()) {
|
if($this->isParentArchived()) {
|
||||||
$this->ParentID = 0;
|
$this->ParentID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if no record can be found on draft stage (meaning it has been "deleted from draft" before),
|
// if no record can be found on draft stage (meaning it has been "deleted from draft" before),
|
||||||
// create an empty record
|
// create an empty record
|
||||||
if(!DB::prepared_query("SELECT \"ID\" FROM \"SiteTree\" WHERE \"ID\" = ?", array($this->ID))->value()) {
|
if(!DB::prepared_query("SELECT \"ID\" FROM \"SiteTree\" WHERE \"ID\" = ?", array($this->ID))->value()) {
|
||||||
@ -2516,12 +2517,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
DB::prepared_query("INSERT INTO \"SiteTree\" (\"ID\") VALUES (?)", array($this->ID));
|
DB::prepared_query("INSERT INTO \"SiteTree\" (\"ID\") VALUES (?)", array($this->ID));
|
||||||
if(method_exists($conn, 'allowPrimaryKeyEditing')) $conn->allowPrimaryKeyEditing('SiteTree', false);
|
if(method_exists($conn, 'allowPrimaryKeyEditing')) $conn->allowPrimaryKeyEditing('SiteTree', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
$oldStage = Versioned::current_stage();
|
$oldStage = Versioned::current_stage();
|
||||||
Versioned::reading_stage('Stage');
|
Versioned::reading_stage('Stage');
|
||||||
$this->forceChange();
|
$this->forceChange();
|
||||||
$this->write();
|
$this->write();
|
||||||
|
|
||||||
$result = DataObject::get_by_id($this->class, $this->ID);
|
$result = DataObject::get_by_id($this->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
|
||||||
@ -2529,11 +2530,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// $page->write() calls syncLinkTracking, which does all the hard work for us.
|
// $page->write() calls syncLinkTracking, which does all the hard work for us.
|
||||||
$page->write();
|
$page->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
Versioned::reading_stage($oldStage);
|
Versioned::reading_stage($oldStage);
|
||||||
|
|
||||||
$this->invokeWithExtensions('onAfterRestoreToStage', $this);
|
$this->invokeWithExtensions('onAfterRestoreToStage', $this);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2566,7 +2567,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if(!$member) {
|
if(!$member) {
|
||||||
$member = Member::currentUser();
|
$member = Member::currentUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Standard mechanism for accepting permission changes from extensions
|
// Standard mechanism for accepting permission changes from extensions
|
||||||
$extended = $this->extendedCan('canArchive', $member);
|
$extended = $this->extendedCan('canArchive', $member);
|
||||||
if($extended !== null) {
|
if($extended !== null) {
|
||||||
@ -2636,7 +2637,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$classes = self::page_type_classes();
|
$classes = self::page_type_classes();
|
||||||
$currentClass = null;
|
$currentClass = null;
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach($classes as $class) {
|
foreach($classes as $class) {
|
||||||
$instance = singleton($class);
|
$instance = singleton($class);
|
||||||
@ -2646,7 +2647,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if($instance instanceof HiddenClass) continue;
|
if($instance instanceof HiddenClass) continue;
|
||||||
if(!$instance->canCreate(null, array('Parent' => $this->ParentID ? $this->Parent() : null))) continue;
|
if(!$instance->canCreate(null, array('Parent' => $this->ParentID ? $this->Parent() : null))) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($perms = $instance->stat('need_permission')) {
|
if($perms = $instance->stat('need_permission')) {
|
||||||
if(!$this->can($perms)) continue;
|
if(!$this->can($perms)) continue;
|
||||||
}
|
}
|
||||||
@ -2663,7 +2664,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$result[$class] = $result[$class] . " ({$class})";
|
$result[$class] = $result[$class] . " ({$class})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort alphabetically, and put current on top
|
// sort alphabetically, and put current on top
|
||||||
asort($result);
|
asort($result);
|
||||||
if($currentClass) {
|
if($currentClass) {
|
||||||
@ -2673,7 +2674,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$result[$currentClass] = $currentPageTypeName;
|
$result[$currentClass] = $currentPageTypeName;
|
||||||
$result = array_reverse($result);
|
$result = array_reverse($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2702,7 +2703,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $allowedChildren;
|
return $allowedChildren;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2757,7 +2758,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$this->setField("MenuTitle", $value);
|
$this->setField("MenuTitle", $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A flag provides the user with additional data about the current page status, for example a "removed from draft"
|
* A flag provides the user with additional data about the current page status, for example a "removed from draft"
|
||||||
* status. Each page can have more than one status flag. Returns a map of a unique key to a (localized) title for
|
* status. Each page can have more than one status flag. Returns a map of a unique key to a (localized) title for
|
||||||
@ -2804,7 +2805,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
$this->_cache_statusFlags = $flags;
|
$this->_cache_statusFlags = $flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_cache_statusFlags;
|
return $this->_cache_statusFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2841,7 +2842,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
Convert::raw2xml($data['text'])
|
Convert::raw2xml($data['text'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $treeTitle;
|
return $treeTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2901,7 +2902,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if(!$this->ShowInMenus) {
|
if(!$this->ShowInMenus) {
|
||||||
$classes .= " notinmenu";
|
$classes .= " notinmenu";
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Add integration
|
//TODO: Add integration
|
||||||
/*
|
/*
|
||||||
if($this->hasExtension('Translatable') && $controller->Locale != Translatable::default_locale() && !$this->isTranslation())
|
if($this->hasExtension('Translatable') && $controller->Locale != Translatable::default_locale() && !$this->isTranslation())
|
||||||
@ -2911,7 +2912,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
return $classes;
|
return $classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares current draft with live version, and returns true if no draft version of this page exists but the page
|
* Compares current draft with live version, and returns true if no draft version of this page exists but the page
|
||||||
* is still published (eg, after triggering "Delete from draft site" in the CMS).
|
* is still published (eg, after triggering "Delete from draft site" in the CMS).
|
||||||
@ -2921,13 +2922,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function getIsDeletedFromStage() {
|
public function getIsDeletedFromStage() {
|
||||||
if(!$this->ID) return true;
|
if(!$this->ID) return true;
|
||||||
if($this->isNew()) return false;
|
if($this->isNew()) return false;
|
||||||
|
|
||||||
$stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $this->ID);
|
$stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $this->ID);
|
||||||
|
|
||||||
// Return true for both completely deleted pages and for pages just deleted from stage
|
// Return true for both completely deleted pages and for pages just deleted from stage
|
||||||
return !($stageVersion);
|
return !($stageVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if this page exists on the live site
|
* Return true if this page exists on the live site
|
||||||
*
|
*
|
||||||
@ -2946,16 +2947,16 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function getIsModifiedOnStage() {
|
public function getIsModifiedOnStage() {
|
||||||
// New unsaved pages could be never be published
|
// New unsaved pages could be never be published
|
||||||
if($this->isNew()) return false;
|
if($this->isNew()) return false;
|
||||||
|
|
||||||
$stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $this->ID);
|
$stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $this->ID);
|
||||||
$liveVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->ID);
|
$liveVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->ID);
|
||||||
|
|
||||||
$isModified = ($stageVersion && $stageVersion != $liveVersion);
|
$isModified = ($stageVersion && $stageVersion != $liveVersion);
|
||||||
$this->extend('getIsModifiedOnStage', $isModified);
|
$this->extend('getIsModifiedOnStage', $isModified);
|
||||||
|
|
||||||
return $isModified;
|
return $isModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares current draft with live version, and returns true if no live version exists, meaning the page was never
|
* Compares current draft with live version, and returns true if no live version exists, meaning the page was never
|
||||||
* published.
|
* published.
|
||||||
@ -2965,13 +2966,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function getIsAddedToStage() {
|
public function getIsAddedToStage() {
|
||||||
// New unsaved pages could be never be published
|
// New unsaved pages could be never be published
|
||||||
if($this->isNew()) return false;
|
if($this->isNew()) return false;
|
||||||
|
|
||||||
$stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $this->ID);
|
$stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $this->ID);
|
||||||
$liveVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->ID);
|
$liveVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->ID);
|
||||||
|
|
||||||
return ($stageVersion && !$liveVersion);
|
return ($stageVersion && !$liveVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stops extendCMSFields() being called on getCMSFields(). This is useful when you need access to fields added by
|
* Stops extendCMSFields() being called on getCMSFields(). This is useful when you need access to fields added by
|
||||||
* subclasses of SiteTree in a extension. Call before calling parent::getCMSFields(), and reenable afterwards.
|
* subclasses of SiteTree in a extension. Call before calling parent::getCMSFields(), and reenable afterwards.
|
||||||
@ -2979,7 +2980,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
static public function disableCMSFieldsExtensions() {
|
static public function disableCMSFieldsExtensions() {
|
||||||
self::$runCMSFieldsExtensions = false;
|
self::$runCMSFieldsExtensions = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reenables extendCMSFields() being called on getCMSFields() after it has been disabled by
|
* Reenables extendCMSFields() being called on getCMSFields() after it has been disabled by
|
||||||
* disableCMSFieldsExtensions().
|
* disableCMSFieldsExtensions().
|
||||||
@ -3022,7 +3023,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the translated Singular name.
|
* Return the translated Singular name.
|
||||||
*
|
*
|
||||||
@ -3033,7 +3034,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$class = ($this->class == 'Page') ? 'SiteTree' : $this->class;
|
$class = ($this->class == 'Page') ? 'SiteTree' : $this->class;
|
||||||
return _t($class.'.SINGULARNAME', $this->singular_name());
|
return _t($class.'.SINGULARNAME', $this->singular_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overloaded to also provide entities for 'Page' class which is usually located in custom code, hence textcollector
|
* Overloaded to also provide entities for 'Page' class which is usually located in custom code, hence textcollector
|
||||||
* picks it up for the wrong folder.
|
* picks it up for the wrong folder.
|
||||||
@ -3042,9 +3043,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*/
|
*/
|
||||||
public function provideI18nEntities() {
|
public function provideI18nEntities() {
|
||||||
$entities = parent::provideI18nEntities();
|
$entities = parent::provideI18nEntities();
|
||||||
|
|
||||||
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[$this->class . '.DESCRIPTION'] = array(
|
$entities[$this->class . '.DESCRIPTION'] = array(
|
||||||
$this->stat('description'),
|
$this->stat('description'),
|
||||||
@ -3072,7 +3073,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public static function reset() {
|
public static function reset() {
|
||||||
self::$cache_permissions = array();
|
self::$cache_permissions = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function on_db_reset() {
|
static public function on_db_reset() {
|
||||||
self::$cache_permissions = array();
|
self::$cache_permissions = array();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user