From 1f1f44969a073635c4b236fa7d614466e34efebb Mon Sep 17 00:00:00 2001 From: Sacha Judd Date: Mon, 14 Jan 2019 13:16:30 +1300 Subject: [PATCH] NEW Add font-icon support for site tree --- code/Controllers/CMSPageAddController.php | 4 +++- code/Model/RedirectorPage.php | 2 ++ code/Model/SiteTree.php | 10 +++++++++- code/Model/VirtualPage.php | 2 ++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/code/Controllers/CMSPageAddController.php b/code/Controllers/CMSPageAddController.php index 1a529e53..afe89ecc 100644 --- a/code/Controllers/CMSPageAddController.php +++ b/code/Controllers/CMSPageAddController.php @@ -6,6 +6,7 @@ use SilverStripe\CMS\Model\SiteTree; use SilverStripe\Control\Controller; use SilverStripe\Control\Session; use SilverStripe\Control\HTTPResponse; +use SilverStripe\Core\Config\Config; use SilverStripe\Core\Convert; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; @@ -44,7 +45,8 @@ class CMSPageAddController extends CMSPageEditController $pageTypes = array(); foreach ($this->PageTypes() as $type) { $html = sprintf( - '%s%s', + '%s%s', + Config::inst()->get($type->getField('ClassName'), 'icon_class'), Convert::raw2htmlid($type->getField('ClassName')), $type->getField('AddAction'), $type->getField('Description') diff --git a/code/Model/RedirectorPage.php b/code/Model/RedirectorPage.php index 64ee1e9e..f3f96a9c 100644 --- a/code/Model/RedirectorPage.php +++ b/code/Model/RedirectorPage.php @@ -22,6 +22,8 @@ class RedirectorPage extends Page { private static $description = 'Redirects to an internal page or an external URL'; + private static $icon_class = 'font-icon-p-redirect'; + private static $db = array( "RedirectionType" => "Enum('Internal,External','Internal')", "ExternalURL" => "Varchar(2083)" // 2083 is the maximum length of a URL in Internet Explorer. diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index 6be2ed2e..fb729f8f 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -277,6 +277,13 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi */ private static $icon = null; + /** + * Class attached to page icons in the CMS page tree. Also supports font-icon set. + * @config + * @var string + */ + private static $icon_class = 'font-icon-page'; + private static $extensions = [ Hierarchy::class, Versioned::class, @@ -2747,7 +2754,8 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi $children = $this->creatableChildren(); $flags = $this->getStatusFlags(); $treeTitle = sprintf( - "%s", + "%s", + $this->config()->get('icon') ? '' : $this->config()->get('icon_class'), Convert::raw2htmlid(static::class), Convert::raw2att(json_encode($children)), Convert::raw2xml(str_replace(array("\n","\r"), "", $this->MenuTitle)) diff --git a/code/Model/VirtualPage.php b/code/Model/VirtualPage.php index 1b4a9231..6cd09e0c 100644 --- a/code/Model/VirtualPage.php +++ b/code/Model/VirtualPage.php @@ -29,6 +29,8 @@ class VirtualPage extends Page { private static $description = 'Displays the content of another page'; + private static $icon_class = 'font-icon-p-virtual'; + public static $virtualFields; /**