ENHANCEMENT Implementing CMSPreviewable in SiteTree

This commit is contained in:
Ingo Schommer 2011-07-21 20:01:00 +02:00
parent 00cc6dd628
commit ab3fe3e638

View File

@ -7,7 +7,7 @@
* In addition, it contains a number of static methods for querying the site tree. * In addition, it contains a number of static methods for querying the site tree.
* @package cms * @package cms
*/ */
class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvider { class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvider,CMSPreviewable {
/** /**
* Indicates what kind of children this page type can have. * Indicates what kind of children this page type can have.
@ -453,6 +453,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
} }
} }
/**
* @return String
*/
function CMSEditLink() {
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.
@ -1270,7 +1277,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
$tags .= $this->ExtraMeta . "\n"; $tags .= $this->ExtraMeta . "\n";
} }
if(Permission::check('CMS_ACCESS_CMSMain')) $tags .= "<meta name='x-page-id' content='{$this->ID}' />\n"; if(Permission::check('CMS_ACCESS_CMSMain') && in_array('CMSPreviewable', class_implements($this))) {
$tags .= "<meta name=\"x-page-id\" content=\"{$this->ID}\" />\n";
$tags .= "<meta name=\"x-cms-edit-link\" content=\"" . $this->CMSEditLink() . "\" />\n";
}
$this->extend('MetaTags', $tags); $this->extend('MetaTags', $tags);