Permalink
Browse files

ENHANCEMENT Implementing CMSPreviewable in SiteTree

  • Loading branch information...
1 parent 00cc6dd commit ab3fe3e6383a0477f478a38c78e856958e0e1a39 @chillu chillu committed Jul 21, 2011
Showing with 12 additions and 2 deletions.
  1. +12 −2 code/model/SiteTree.php
View
14 code/model/SiteTree.php
@@ -7,7 +7,7 @@
* In addition, it contains a number of static methods for querying the site tree.
* @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.
@@ -453,6 +453,13 @@ public function getAbsoluteLiveLink($includeStageEqualsLive = true) {
}
}
+ /**
+ * @return String
+ */
+ function CMSEditLink() {
+ return Controller::join_links(singleton('CMSPageEditController')->Link('show'), $this->ID);
+ }
+
/**
* Return a CSS identifier generated from this page's link.
@@ -1270,7 +1277,10 @@ public function MetaTags($includeTitle = true) {
$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);

0 comments on commit ab3fe3e

Please sign in to comment.