From 4b3f4ba01cedc2f61fd013b375c18b2d7e158e21 Mon Sep 17 00:00:00 2001 From: Christopher Joe Date: Tue, 13 Sep 2016 10:47:02 +1200 Subject: [PATCH 1/2] move BackLinkHTMLList to template --- code/Model/SiteTreeFileExtension.php | 21 +++------------ lang/en.yml | 3 +++ .../SiteTreeFileExtension_description.ss | 27 +++++++++++++++++++ 3 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 templates/SilverStripe/CMS/Model/Includes/SiteTreeFileExtension_description.ss diff --git a/code/Model/SiteTreeFileExtension.php b/code/Model/SiteTreeFileExtension.php index 2fd0f41a..f6b2fcd8 100644 --- a/code/Model/SiteTreeFileExtension.php +++ b/code/Model/SiteTreeFileExtension.php @@ -10,6 +10,7 @@ use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\ManyManyList; use SilverStripe\ORM\Versioning\Versioned; +use SilverStripe\View\SSViewer; use Subsite; /** @@ -57,25 +58,9 @@ class SiteTreeFileExtension extends DataExtension { * @return string */ public function BackLinkHTMLList() { - $html = '' . _t( - 'SiteTreeFileExtension.BACKLINK_LIST_DESCRIPTION', - 'This list shows all pages where the file has been added through a WYSIWYG editor.' - ) . ''; + $viewer = new SSViewer(["type" => "Includes", __CLASS__ . "_description"]); - $html .= ''; - - return $html; + return $viewer->process($this->owner)->forTemplate(); } /** diff --git a/lang/en.yml b/lang/en.yml index 0b44e1b7..b0057ee6 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -421,6 +421,9 @@ en: many_many_ImageTracking: 'Image Tracking' many_many_LinkTracking: 'Link Tracking' SiteTreeFileExtension: + TITLE_INDEX: '#' + TITLE_USED_ON: 'Used On' + TITLE_TYPE: 'Type' BACKLINK_LIST_DESCRIPTION: 'This list shows all pages where the file has been added through a WYSIWYG editor.' EDIT: Edit SiteTreeURLSegmentField: diff --git a/templates/SilverStripe/CMS/Model/Includes/SiteTreeFileExtension_description.ss b/templates/SilverStripe/CMS/Model/Includes/SiteTreeFileExtension_description.ss new file mode 100644 index 00000000..0a3c993c --- /dev/null +++ b/templates/SilverStripe/CMS/Model/Includes/SiteTreeFileExtension_description.ss @@ -0,0 +1,27 @@ +<% if $BackLinkTracking %> + + + + + + + + + + <% loop $BackLinkTracking %> + + + + + + <% end_loop %> + +
<% _t('SiteTreeFileExtension.TITLE_INDEX', '#') %><% _t('SiteTreeFileExtension.TITLE_USED_ON', 'Used on') %><% _t('SiteTreeFileExtension.TITLE_TYPE', 'Type') %>
$Pos$MenuTitle + $i18n_singular_name + <% if $isPublished %> + Published + <% else %> + Draft + <% end_if %> +
+<% end_if %> From 4f19113c5cce68ae6806c13d87c4f916bcc977ba Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Tue, 20 Sep 2016 12:08:20 +1200 Subject: [PATCH 2/2] API Use new DBField::getSchemaValue() --- code/Model/SiteTreeFileExtension.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/Model/SiteTreeFileExtension.php b/code/Model/SiteTreeFileExtension.php index f6b2fcd8..2996612e 100644 --- a/code/Model/SiteTreeFileExtension.php +++ b/code/Model/SiteTreeFileExtension.php @@ -39,6 +39,10 @@ class SiteTreeFileExtension extends DataExtension { 'BackLinkTracking' ); + private static $casting = array( + 'BackLinkHTMLList' => 'HTMLFragment' + ); + public function updateCMSFields(FieldList $fields) { $fields->insertAfter( 'LastEdited', @@ -60,7 +64,7 @@ class SiteTreeFileExtension extends DataExtension { public function BackLinkHTMLList() { $viewer = new SSViewer(["type" => "Includes", __CLASS__ . "_description"]); - return $viewer->process($this->owner)->forTemplate(); + return $viewer->process($this->owner); } /**