mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
Compare commits
8 Commits
fb6c993aef
...
53548d6c0d
Author | SHA1 | Date | |
---|---|---|---|
|
53548d6c0d | ||
|
b985f052cf | ||
|
df82162291 | ||
|
e2ca1cb77d | ||
|
dca4404f0f | ||
|
4b3e1f09bf | ||
|
24bb95d3bf | ||
|
d8748ff5f9 |
@ -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;
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\CMS\Controllers;
|
||||
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
class CMSPageSettingsController extends CMSMain
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
@ -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',
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user