Skip to content

Commit

Permalink
Merge branch '5' into 6.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	code/Controllers/CMSMain.php
#	code/Controllers/CMSPagesController.php
#	yarn.lock
  • Loading branch information
GuySartorelli committed Dec 10, 2024
2 parents 35942c3 + 5c1f28a commit 10d8593
Show file tree
Hide file tree
Showing 11 changed files with 312 additions and 34 deletions.
218 changes: 192 additions & 26 deletions code/Controllers/CMSMain.php

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions code/Controllers/CMSPageAddController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Convert;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\FormAction;
Expand All @@ -23,6 +24,9 @@
use SilverStripe\Security\Security;
use SilverStripe\SiteConfig\SiteConfig;

/**
* @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Forms\CMSMainAddForm
*/
class CMSPageAddController extends CMSPageEditController
{

Expand All @@ -40,6 +44,16 @@ class CMSPageAddController extends CMSPageEditController
'doCancel'
];

public function __construct()
{
Deprecation::noticeWithNoReplacment(
'5.4.0',
'Will be replaced with SilverStripe\CMS\Forms\CMSMainAddForm',
Deprecation::SCOPE_CLASS
);
parent::__construct();
}

/**
* @return Form
*/
Expand Down Expand Up @@ -136,7 +150,7 @@ public function AddForm()

$parentModeField->addExtraClass('parent-mode');

// CMSMain->currentPageID() automatically sets the homepage,
// CMSMain->currentRecordID() automatically sets the homepage,
// which we need to counteract in the default selection (which should default to root, ID=0)
if ($parentID = $this->getRequest()->getVar('ParentID')) {
$parentModeField->setValue('child');
Expand Down Expand Up @@ -222,7 +236,7 @@ public function doAdd(array $data, Form $form): HTTPResponse

$editController = CMSPageEditController::singleton();
$editController->setRequest($this->getRequest());
$editController->setCurrentPageID($record->ID);
$editController->setCurrentRecordID($record->ID);

$session = $this->getRequest()->getSession();
$session->set(
Expand Down
2 changes: 1 addition & 1 deletion code/Controllers/CMSPageSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CMSPageSettingsController extends CMSMain

public function getEditForm($id = null, $fields = null)
{
$record = $this->getRecord($id ?: $this->currentPageID());
$record = $this->getRecord($id ?: $this->currentRecordID());

return parent::getEditForm($id, ($record) ? $record->getSettingsFields() : null);
}
Expand Down
14 changes: 14 additions & 0 deletions code/Controllers/CMSPagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\Controller;
use SilverStripe\Model\List\ArrayList;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\DataObject;
use SilverStripe\Model\ArrayData;
use stdClass;

/**
* @deprecated 5.4.0 Will be combined back into SilverStripe\CMS\Controllers\CMSMain
*/
class CMSPagesController extends CMSMain
{

Expand All @@ -22,6 +26,16 @@ class CMSPagesController extends CMSMain

private static $required_permission_codes = 'CMS_ACCESS_CMSMain';

public function __construct()
{
Deprecation::noticeWithNoReplacment(
'5.4.0',
'Will be combined back into ' . CMSMain::class,
Deprecation::SCOPE_CLASS
);
parent::__construct();
}

public function LinkPreview()
{
return false;
Expand Down
9 changes: 9 additions & 0 deletions code/Controllers/CMSSiteTreeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Convert;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Forms\DateField;
use SilverStripe\ORM\DataList;
use SilverStripe\Model\List\SS_List;
Expand Down Expand Up @@ -113,8 +114,12 @@ public function getNumChildrenMethod()
return $this->numChildrenMethod;
}

/**
* @deprecated 5.4.0 Will be renamed to getRecordClasses()
*/
public function getPageClasses($page)
{
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be renamed to getRecordClasses()');
if ($this->_cache_ids === null) {
$this->populateIDs();
}
Expand Down Expand Up @@ -178,8 +183,12 @@ protected function populateIDs()
}
}

/**
* @deprecated 5.4.0 Will be renamed to isRecordIncluded()
*/
public function isPageIncluded($page)
{
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be renamed to isRecordIncluded()');
if ($this->_cache_ids === null) {
$this->populateIDs();
}
Expand Down
29 changes: 27 additions & 2 deletions code/Controllers/LeftAndMainPageIconsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,34 @@
use SilverStripe\Core\Extension;
use SilverStripe\Core\Flushable;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Deprecation;
use SilverStripe\View\Requirements;

/**
* Extension to include custom page icons
*
* @extends Extension<LeftAndMain>
* @deprecated 5.4.0 Will be renamed to SilverStripe\CMS\Controllers\LeftAndMainRecordIconsExtension
*/
class LeftAndMainPageIconsExtension extends Extension implements Flushable
{
public function __construct()
{
Deprecation::noticeWithNoReplacment(
'5.4.0',
'Will be renamed to SilverStripe\CMS\Controllers\LeftAndMainRecordIconsExtension',
Deprecation::SCOPE_CLASS
);
parent::__construct();
}

/**
* @throws InvalidArgumentException
* @throws ReflectionException
*/
protected function onInit()
{
Requirements::customCSS($this->generatePageIconsCss(), CMSMain::PAGE_ICONS_ID);
Requirements::customCSS($this->generateRecordIconsCss(), CMSMain::CMS_RECORD_ICONS_ID);
}

/**
Expand All @@ -39,16 +51,29 @@ public static function flush()
Injector::inst()->get(CacheInterface::class . '.SiteTree_PageIcons')->clear();
}


/**
* Include CSS for page icons. We're not using the JSTree 'types' option
* because it causes too much performance overhead just to add some icons.
*
* @return string CSS
* @throws InvalidArgumentException
* @throws ReflectionException
* @deprecated 5.4.0 Use generateRecordIconsCss() instead.
*/
public function generatePageIconsCss()
{
Deprecation::notice('5.4.0', 'Use generateRecordIconsCss() instead.');
return $this->generateRecordIconsCss();
}

/**
* Include CSS for page icons. We're not using the JSTree 'types' option
* because it causes too much performance overhead just to add some icons.
*
* @throws InvalidArgumentException
* @throws ReflectionException
*/
public function generateRecordIconsCss(): string
{
/** @var CacheInterface $cache */
$cache = Injector::inst()->get(CacheInterface::class . '.SiteTree_PageIcons');
Expand Down
3 changes: 3 additions & 0 deletions code/Model/CurrentPageIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@

/**
* This interface lets us set up objects that will tell us what the current page is.
* @deprecated 5.4.0 Will be renamed to SilverStripe\CMS\Model\CurrentRecordIdentifier
*/
interface CurrentPageIdentifier
{

/**
* Get the current page ID.
* @return int
* @deprecated 5.4.0 Will be renamed to currentRecordID()
*/
public function currentPageID();

/**
* Check if the given DataObject is the current page.
* @param DataObject $page The page to check.
* @return boolean
* @deprecated 5.4.0 Will be renamed to isCurrentRecord()
*/
public function isCurrentPage(DataObject $page);
}
3 changes: 3 additions & 0 deletions code/Model/RedirectorPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class RedirectorPage extends Page
{
private static string $class_description = 'Redirects requests to another location';

/**
* @deprecated 5.4.0 Will be renamed to cms_icon_class
*/
private static $icon_class = 'font-icon-p-redirect';

private static $show_stage_link = false;
Expand Down
41 changes: 41 additions & 0 deletions code/Model/SiteTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
*
* @config
* @var array
* @deprecated 5.4.0 Use canCreate() instead.
*/
private static $need_permission = null;

Expand Down Expand Up @@ -312,13 +313,15 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
* @see LeftAndMainPageIconsExtension::generatePageIconsCss()
* @config
* @var string
* @deprecated 5.4.0 Will be renamed to cms_icon
*/
private static $icon = null;

/**
* Class attached to page icons in the CMS page tree. Also supports font-icon set.
* @config
* @var string
* @deprecated 5.4.0 Will be renamed to cms_icon_class
*/
private static $icon_class = 'font-icon-page';

Expand Down Expand Up @@ -523,6 +526,7 @@ public static function get_by_link($link, $cache = true)
* Return a subclass map of SiteTree that shouldn't be hidden through {@link SiteTree::$hide_pagetypes}
*
* @return array
* @deprecated 5.4.0 Will be replaced with updateAllowedSubClasses()
*/
public static function page_type_classes()
{
Expand Down Expand Up @@ -940,19 +944,29 @@ public function getParent()
/**
* @param CacheInterface $cache
* @return $this
* @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Controllers\CMSMain::setCreatableChildrenCache()
*/
public function setCreatableChildrenCache(CacheInterface $cache)
{
Deprecation::noticeWithNoReplacment(
'5.4.0',
'Will be replaced with ' . CMSMain::class . '::setCreatableChildrenCache()'
);
$this->creatableChildrenCache = $cache;

return $this;
}

/**
* @return CacheInterface $cache
* @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Controllers\CMSMain::getCreatableChildrenCache()
*/
public function getCreatableChildrenCache()
{
Deprecation::noticeWithNoReplacment(
'5.4.0',
'Will be replaced with ' . CMSMain::class . '::getCreatableChildrenCache()'
);
return $this->creatableChildrenCache;
}

Expand Down Expand Up @@ -1267,9 +1281,11 @@ public function getSiteConfig()

/**
* @return PermissionChecker
* @deprecated 5.4.0 Will be replaced with a non-static method with the same name.
*/
public static function getPermissionChecker()
{
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with a non-static method with the same name.');
return Injector::inst()->get(PermissionChecker::class.'.sitetree');
}

Expand Down Expand Up @@ -1691,9 +1707,14 @@ protected function onAfterDelete()
* Flushes the member specific cache for creatable children
*
* @param array $memberIDs
* @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Controllers\CMSMain::clearCache()
*/
public function flushMemberCache($memberIDs = null)
{
Deprecation::noticeWithNoReplacment(
'5.4.0',
'Will be replaced with ' . CMSMain::class . '::clearCache()'
);
$cache = SiteTree::singleton()->getCreatableChildrenCache();

if (!$memberIDs) {
Expand Down Expand Up @@ -2625,9 +2646,14 @@ protected function getClassDropdown()
* Gets a list of the page types that can be created under this specific page, including font icons
*
* @return array
* @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Controllers\CMSMain::getCreatableSubClasses()
*/
public function creatableChildPages()
{
Deprecation::noticeWithNoReplacment(
'5.4.0',
'Will be replaced with ' . CMSMain::class . '::getCreatableSubClasses()'
);
// Build the list of candidate children
$cache = SiteTree::singleton()->getCreatableChildrenCache();
$cacheKey = $this->generateChildrenCacheKey(Security::getCurrentUser() ? Security::getCurrentUser()->ID : 0);
Expand Down Expand Up @@ -2689,9 +2715,14 @@ public function setMenuTitle($value)
* Returns the CSS class used for the page icon in the site tree.
*
* @return string
* @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Controllers\CMSMain::getRecordIconCssClass()
*/
public function getIconClass()
{
Deprecation::noticeWithNoReplacment(
'5.4.0',
'Will be replaced with ' . CMSMain::class . '::getRecordIconCssClass()'
);
if ($this->config()->get('icon')) {
return '';
}
Expand Down Expand Up @@ -2928,9 +2959,14 @@ public function plural_name()
* Generate link to this page's icon
*
* @return string
* @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Controllers\CMSMain::getRecordIconUrl()
*/
public function getPageIconURL()
{
Deprecation::noticeWithNoReplacment(
'5.4.0',
'Will be replaced with ' . CMSMain::class . '::getRecordIconUrl()'
);
$icon = $this->config()->get('icon');
if (!$icon) {
return null;
Expand Down Expand Up @@ -3023,9 +3059,14 @@ protected function updateDependentPages()
*
* @param int $memberID
* @return string
* @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Controllers\CMSMain::generateChildrenCacheKey()
*/
protected function generateChildrenCacheKey($memberID)
{
Deprecation::noticeWithNoReplacment(
'5.4.0',
'Will be replaced with ' . CMSMain::class . '::generateChildrenCacheKey()'
);
return md5($memberID . '_' . __CLASS__);
}

Expand Down
3 changes: 3 additions & 0 deletions code/Model/VirtualPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class VirtualPage extends Page
{
private static string $class_description = 'Displays the content of another page';

/**
* @deprecated 5.4.0 Will be renamed to cms_icon_class
*/
private static $icon_class = 'font-icon-p-virtual';

public static $virtualFields;
Expand Down
Loading

0 comments on commit 10d8593

Please sign in to comment.