Compare commits

...

8 Commits

Author SHA1 Message Date
Guy Sartorelli
53548d6c0d
ENH Use symfony/validation logic 2024-09-25 10:26:32 +12:00
Guy Sartorelli
b985f052cf
Merge branch '5' into 6 2024-09-24 14:04:46 +12:00
Guy Sartorelli
df82162291
Merge pull request #3008 from creative-commoners/pulls/5/framework-version
DEP Increase minimum version of silverstripe/framework
2024-09-24 09:39:50 +12:00
Steve Boyd
e2ca1cb77d DEP Increase minimum version of silverstripe/framework 2024-09-23 15:15:02 +12:00
Guy Sartorelli
dca4404f0f
API Use new names for renamed classes (#3003) 2024-09-23 14:37:02 +12:00
Guy Sartorelli
4b3e1f09bf
ENH Don't use deprecated method (#3006) 2024-09-19 14:06:39 +12:00
Guy Sartorelli
24bb95d3bf
Merge pull request #3004 from sunnysideup/patch-21
FIX: put current page at top of ClassName dropdown (was broken)
2024-09-18 09:30:05 +12:00
Nicolaas @ Tappy @ Sunny Side Up
d8748ff5f9 FIX: return right order for getClassDropdown method 2024-09-15 17:06:28 +12:00
24 changed files with 58 additions and 70 deletions

View File

@ -2,7 +2,7 @@
namespace SilverStripe\CMS\BatchActions;
use SilverStripe\ORM\SS_List;
use SilverStripe\Model\List\SS_List;
use SilverStripe\Admin\CMSBatchAction;
use SilverStripe\Control\HTTPResponse;

View File

@ -4,7 +4,7 @@ namespace SilverStripe\CMS\BatchActions;
use SilverStripe\Admin\CMSBatchAction;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\ORM\SS_List;
use SilverStripe\Model\List\SS_List;
/**
* Publish items batch action.

View File

@ -4,7 +4,7 @@ namespace SilverStripe\CMS\BatchActions;
use SilverStripe\Admin\CMSBatchAction;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\ORM\SS_List;
use SilverStripe\Model\List\SS_List;
/**
* Unpublish items batch action.

View File

@ -48,7 +48,7 @@ use SilverStripe\Forms\LiteralField;
use SilverStripe\Forms\Tab;
use SilverStripe\Forms\TabSet;
use SilverStripe\Forms\TextField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\Model\List\ArrayList;
use SilverStripe\ORM\CMSPreviewable;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
@ -57,8 +57,8 @@ use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\ORM\HiddenClass;
use SilverStripe\ORM\Hierarchy\Hierarchy;
use SilverStripe\ORM\Hierarchy\MarkedSet;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\ValidationResult;
use SilverStripe\Model\List\SS_List;
use SilverStripe\Core\Validation\ValidationResult;
use SilverStripe\Security\InheritedPermissions;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
@ -70,7 +70,7 @@ use SilverStripe\Versioned\ChangeSet;
use SilverStripe\Versioned\ChangeSetItem;
use SilverStripe\Versioned\Versioned;
use SilverStripe\VersionedAdmin\Controllers\CMSPageHistoryViewerController;
use SilverStripe\View\ArrayData;
use SilverStripe\Model\ArrayData;
use SilverStripe\View\Requirements;
/**

View File

@ -18,7 +18,7 @@ use SilverStripe\Forms\SelectionGroup_Item;
use SilverStripe\Forms\TreeDropdownField;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\ValidationResult;
use SilverStripe\Core\Validation\ValidationResult;
use SilverStripe\Security\Member;
use SilverStripe\Security\Security;
use SilverStripe\SiteConfig\SiteConfig;

View File

@ -10,9 +10,9 @@ use SilverStripe\Control\Controller;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Forms\Form;
use SilverStripe\ORM\ArrayLib;
use SilverStripe\Core\ArrayLib;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\ORM\ValidationResult;
use SilverStripe\Core\Validation\ValidationResult;
/**
* @package cms

View File

@ -2,7 +2,7 @@
namespace SilverStripe\CMS\Controllers;
use SilverStripe\View\ArrayData;
use SilverStripe\Model\ArrayData;
class CMSPageSettingsController extends CMSMain
{

View File

@ -4,9 +4,9 @@ namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\Controller;
use SilverStripe\ORM\ArrayList;
use SilverStripe\Model\List\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\View\ArrayData;
use SilverStripe\Model\ArrayData;
use stdClass;
class CMSPagesController extends CMSMain

View File

@ -9,7 +9,7 @@ use SilverStripe\Core\Convert;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Forms\DateField;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\SS_List;
use SilverStripe\Model\List\SS_List;
use SilverStripe\Versioned\Versioned;
/**

View File

@ -3,7 +3,7 @@
namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\SS_List;
use SilverStripe\Model\List\SS_List;
use SilverStripe\Versioned\Versioned;
/**

View File

@ -3,7 +3,7 @@
namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\SS_List;
use SilverStripe\Model\List\SS_List;
use SilverStripe\Versioned\Versioned;
class CMSSiteTreeFilter_Search extends CMSSiteTreeFilter

View File

@ -3,7 +3,7 @@
namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\SS_List;
use SilverStripe\Model\List\SS_List;
use SilverStripe\Versioned\Versioned;
/**

View File

@ -3,7 +3,7 @@
namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\SS_List;
use SilverStripe\Model\List\SS_List;
use SilverStripe\Versioned\Versioned;
/**

View File

@ -3,7 +3,7 @@
namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\SS_List;
use SilverStripe\Model\List\SS_List;
use SilverStripe\Versioned\Versioned;
/**

View File

@ -14,11 +14,11 @@ use SilverStripe\Core\Convert;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Manifest\ModuleManifest;
use SilverStripe\i18n\i18n;
use SilverStripe\ORM\ArrayList;
use SilverStripe\Model\List\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\SS_List;
use SilverStripe\Model\List\SS_List;
use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator;
use SilverStripe\Security\Permission;
use SilverStripe\Security\Security;

View File

@ -7,6 +7,7 @@ use SilverStripe\Assets\File;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\HeaderField;
use SilverStripe\Forms\OptionsetField;
use SilverStripe\Forms\UrlField;
use SilverStripe\Versioned\Versioned;
/**
@ -47,6 +48,9 @@ class RedirectorPage extends Page
'RedirectionType',
'Content',
],
'fieldClasses' => [
'ExternalURL' => UrlField::class,
],
];
private static $table_name = 'RedirectorPage';
@ -171,35 +175,12 @@ class RedirectorPage extends Page
}
}
protected function onBeforeWrite()
{
parent::onBeforeWrite();
if ($this->ExternalURL && substr($this->ExternalURL ?? '', 0, 2) !== '//') {
$urlParts = parse_url($this->ExternalURL ?? '');
if ($urlParts) {
if (empty($urlParts['scheme'])) {
// no scheme, assume http
$this->ExternalURL = 'http://' . $this->ExternalURL;
} elseif (!in_array($urlParts['scheme'], [
'http',
'https',
])) {
// we only allow http(s) urls
$this->ExternalURL = '';
}
} else {
// malformed URL to reject
$this->ExternalURL = '';
}
}
}
public function getCMSFields()
{
$this->beforeUpdateCMSFields(function (FieldList $fields) {
// Remove all metadata fields, does not apply for redirector pages
$fields->removeByName('Metadata');
$fields->dataFieldByName('ExternalURL')?->setAllowRelativeProtocol(true);
$fields->addFieldsToTab(
'Root.Main',

View File

@ -49,7 +49,7 @@ use SilverStripe\Forms\TreeDropdownField;
use SilverStripe\Forms\TreeMultiselectField;
use SilverStripe\i18n\i18n;
use SilverStripe\i18n\i18nEntityProvider;
use SilverStripe\ORM\ArrayList;
use SilverStripe\Model\List\ArrayList;
use SilverStripe\ORM\CMSPreviewable;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
@ -58,7 +58,7 @@ use SilverStripe\ORM\HasManyList;
use SilverStripe\ORM\HiddenClass;
use SilverStripe\ORM\Hierarchy\Hierarchy;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\ORM\ValidationResult;
use SilverStripe\Core\Validation\ValidationResult;
use SilverStripe\Security\Group;
use SilverStripe\Security\InheritedPermissions;
use SilverStripe\Security\InheritedPermissionsExtension;
@ -71,7 +71,7 @@ use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\Versioned\RecursivePublishable;
use SilverStripe\Versioned\Versioned;
use SilverStripe\View\ArrayData;
use SilverStripe\Model\ArrayData;
use SilverStripe\View\HTML;
use SilverStripe\View\Parsers\HTMLValue;
use SilverStripe\View\Parsers\ShortcodeParser;
@ -2747,8 +2747,6 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
protected function getClassDropdown()
{
$classes = SiteTree::page_type_classes();
$currentClass = null;
$result = [];
foreach ($classes as $class) {
$instance = singleton($class);
@ -2774,20 +2772,15 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
}
}
$pageTypeName = $instance->i18n_singular_name();
$currentClass = $class;
$result[$class] = $pageTypeName;
$result[$class] = $instance->i18n_singular_name();
}
// sort alphabetically, and put current on top
// Sort alphabetically, and put current on top
asort($result);
if ($currentClass) {
$currentPageTypeName = $result[$currentClass];
unset($result[$currentClass]);
$result = array_reverse($result ?? []);
$result[$currentClass] = $currentPageTypeName;
$result = array_reverse($result ?? []);
if (isset($result[$this->ClassName])) {
$currentPageTypeName = $result[$this->ClassName];
unset($result[$this->ClassName]);
$result = [$this->ClassName => $currentPageTypeName] + $result;
}
return $result;

View File

@ -11,7 +11,7 @@ use SilverStripe\Forms\TextareaField;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\TreeDropdownField;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ValidationResult;
use SilverStripe\Core\Validation\ValidationResult;
use SilverStripe\Security\Member;
use SilverStripe\Versioned\Versioned;
use SilverStripe\View\HTML;

View File

@ -10,7 +10,7 @@ use SilverStripe\Control\Controller;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\ORM\ArrayList;
use SilverStripe\Model\List\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\Reports\Report;
use SilverStripe\Versioned\Versioned;

View File

@ -12,7 +12,7 @@ use SilverStripe\Forms\FormAction;
use SilverStripe\Forms\HiddenField;
use SilverStripe\Forms\TextField;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\SS_List;
use SilverStripe\Model\List\SS_List;
/**
* Standard basic search form which conducts a fulltext search on all {@link SiteTree}

View File

@ -4,7 +4,7 @@ namespace SilverStripe\CMS\Tests\Controllers;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\ValidationException;
use SilverStripe\Core\Validation\ValidationException;
class CMSMainTest_ClassA extends SiteTree implements TestOnly
{

View File

@ -4,7 +4,7 @@ namespace SilverStripe\CMS\Tests\Controllers;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\ValidationException;
use SilverStripe\Core\Validation\ValidationException;
class CMSMainTest_ClassB extends SiteTree implements TestOnly
{

View File

@ -24,7 +24,7 @@ use SilverStripe\i18n\i18n;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\ValidationException;
use SilverStripe\Core\Validation\ValidationException;
use SilverStripe\Security\Group;
use SilverStripe\Security\InheritedPermissions;
use SilverStripe\Security\Member;
@ -1272,7 +1272,7 @@ class SiteTreeTest extends SapphireTest
#[DataProvider('allowedChildrenProvider')]
public function testAllowedChildren($className, $expected, $assertionMessage)
{
$class = new $className;
$class = new $className();
$this->assertEquals($expected, $class->allowedChildren(), $assertionMessage);
}
@ -1351,6 +1351,9 @@ class SiteTreeTest extends SapphireTest
);
}
/**
* @return void
*/
public function testClassDropdown()
{
$sitetree = new SiteTree();
@ -1372,7 +1375,18 @@ class SiteTreeTest extends SapphireTest
$this->assertArrayNotHasKey(SiteTreeTest_NotRoot::class, $method->invoke($rootPage));
$this->assertArrayHasKey(SiteTreeTest_NotRoot::class, $method->invoke($nonRootPage));
foreach ([SiteTreeTest_ClassA::class, SiteTreeTest_ClassB::class] as $className) {
$otherPage = new $className();
$otherPage->write();
$result = $method->invoke(object: $otherPage);
$this->assertEquals(array_key_first($result), $className);
// remove the first element as this is not alphabetical
array_shift($result);
// create a sorted array
$resultSorted = $result;
asort($resultSorted);
$this->assertEquals($result, $resultSorted);
}
Security::setCurrentUser(null);
}

View File

@ -10,7 +10,7 @@ use SilverStripe\Control\ContentNegotiator;
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\FunctionalTest;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ValidationException;
use SilverStripe\Core\Validation\ValidationException;
use SilverStripe\Security\Member;
use SilverStripe\Subsites\Extensions\SiteTreeSubsites;
use SilverStripe\Versioned\Versioned;