From 892a91ae3e885c9b9a1b398905da06897cf1c090 Mon Sep 17 00:00:00 2001 From: Guy Marriott Date: Wed, 8 May 2019 16:13:33 +1200 Subject: [PATCH 1/3] FIX Only add page font icon classes if there's no icon image defined --- code/Controllers/CMSPageAddController.php | 17 ++++++++++++++--- .../LeftAndMainPageIconsExtension.php | 3 +++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/code/Controllers/CMSPageAddController.php b/code/Controllers/CMSPageAddController.php index afe89ecc..df7dac0d 100644 --- a/code/Controllers/CMSPageAddController.php +++ b/code/Controllers/CMSPageAddController.php @@ -43,15 +43,26 @@ class CMSPageAddController extends CMSPageEditController public function AddForm() { $pageTypes = array(); + $defaultIcon = Config::inst()->get(SiteTree::class, 'icon_class'); + foreach ($this->PageTypes() as $type) { + $class = $type->getField('ClassName'); + $icon = Config::inst()->get($class, 'icon_class') ?: $defaultIcon; + + // If the icon is the SiteTree default and there's some specific icon being provided by `getPageIconURL` + // then we don't need to add the icon class. Otherwise the class take precedence. + if ($icon === $defaultIcon && !empty(singleton($class)->getPageIconURL())) { + $icon = ''; + } + $html = sprintf( '%s%s', - Config::inst()->get($type->getField('ClassName'), 'icon_class'), - Convert::raw2htmlid($type->getField('ClassName')), + $icon, + Convert::raw2htmlid($class), $type->getField('AddAction'), $type->getField('Description') ); - $pageTypes[$type->getField('ClassName')] = DBField::create_field('HTMLFragment', $html); + $pageTypes[$class] = DBField::create_field('HTMLFragment', $html); } // Ensure generic page type shows on top if (isset($pageTypes['Page'])) { diff --git a/code/Controllers/LeftAndMainPageIconsExtension.php b/code/Controllers/LeftAndMainPageIconsExtension.php index 95db76c9..6cc5e74d 100644 --- a/code/Controllers/LeftAndMainPageIconsExtension.php +++ b/code/Controllers/LeftAndMainPageIconsExtension.php @@ -31,6 +31,9 @@ class LeftAndMainPageIconsExtension extends Extension $css = ''; $classes = ClassInfo::subclassesFor(SiteTree::class); foreach ($classes as $class) { + if (!empty(Config::inst()->get($class, 'icon_class', Config::UNINHERITED))) { + continue; + } $iconURL = SiteTree::singleton($class)->getPageIconURL(); if ($iconURL) { $cssClass = Convert::raw2htmlid($class); From c569cec4ea49612ddc9d430d7fe792971c93c586 Mon Sep 17 00:00:00 2001 From: Garion Herman Date: Fri, 31 May 2019 10:21:07 +1200 Subject: [PATCH 2/3] NEW Add updateHintsCacheKey extension point to fix invalid caching If a module augments the allowed pagetypes based on external conditions, the Hints Cache Key will not cover these conditions and may cause incorrect output. An example of this is Subsites, which allows each Subsite to have a different set of allowed pagetypes. --- code/Controllers/CMSMain.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/Controllers/CMSMain.php b/code/Controllers/CMSMain.php index 5f41b325..9fa20345 100644 --- a/code/Controllers/CMSMain.php +++ b/code/Controllers/CMSMain.php @@ -2272,7 +2272,11 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr */ protected function generateHintsCacheKey($memberID) { - return md5($memberID . '_' . __CLASS__); + $baseKey = $memberID . '_' . __CLASS__; + + $this->extend('updateHintsCacheKey', $baseKey); + + return md5($baseKey); } /** From 325d227fe070de5ba8f06ba3198f7444893f6fe6 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 31 May 2019 14:50:46 +1200 Subject: [PATCH 3/3] FIX Virtual page notice now uses Bootstrap 4 alerts --- code/Model/VirtualPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Model/VirtualPage.php b/code/Model/VirtualPage.php index 6cd09e0c..090ae7e7 100644 --- a/code/Model/VirtualPage.php +++ b/code/Model/VirtualPage.php @@ -279,7 +279,7 @@ class VirtualPage extends Page $fields->addFieldToTab("Root.Main", new LiteralField( 'VirtualPageMessage', - '
' . implode('. ', $msgs) . '.
' + '
' . implode('. ', $msgs) . '.
' ), 'CopyContentFromID'); });