mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Compare commits
8 Commits
4be3523a2c
...
0307fa6cb0
Author | SHA1 | Date | |
---|---|---|---|
|
0307fa6cb0 | ||
|
2bea868994 | ||
|
b985f052cf | ||
|
df82162291 | ||
|
e2ca1cb77d | ||
|
4b3e1f09bf | ||
|
24bb95d3bf | ||
|
d8748ff5f9 |
@ -60,7 +60,7 @@ class ModelAsController extends Controller implements NestedController
|
|||||||
Director::absoluteBaseURL(),
|
Director::absoluteBaseURL(),
|
||||||
'dev/build',
|
'dev/build',
|
||||||
'?' . http_build_query([
|
'?' . http_build_query([
|
||||||
'returnURL' => isset($_GET['url']) ? $_GET['url'] : null,
|
'BackURL' => isset($_GET['url']) ? $_GET['url'] : null,
|
||||||
])
|
])
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ class ModelAsController extends Controller implements NestedController
|
|||||||
|
|
||||||
// If the database has not yet been created, redirect to the build page.
|
// If the database has not yet been created, redirect to the build page.
|
||||||
if (!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
if (!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
||||||
$this->getResponse()->redirect(Controller::join_links(Director::absoluteBaseURL(), 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null)));
|
$this->getResponse()->redirect(Controller::join_links(Director::absoluteBaseURL(), 'dev/build?BackURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null)));
|
||||||
$this->popCurrent();
|
$this->popCurrent();
|
||||||
|
|
||||||
return $this->getResponse();
|
return $this->getResponse();
|
||||||
|
@ -78,7 +78,7 @@ class RootURLController extends Controller implements Resettable
|
|||||||
Director::absoluteBaseURL(),
|
Director::absoluteBaseURL(),
|
||||||
'dev/build',
|
'dev/build',
|
||||||
'?' . http_build_query([
|
'?' . http_build_query([
|
||||||
'returnURL' => isset($_GET['url']) ? $_GET['url'] : null,
|
'BackURL' => isset($_GET['url']) ? $_GET['url'] : null,
|
||||||
])
|
])
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ class RootURLController extends Controller implements Resettable
|
|||||||
|
|
||||||
if (!$this->getResponse()->isFinished()) {
|
if (!$this->getResponse()->isFinished()) {
|
||||||
if (!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
if (!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
||||||
$this->getResponse()->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
$this->getResponse()->redirect(Director::absoluteBaseURL() . 'dev/build?BackURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
||||||
return $this->getResponse();
|
return $this->getResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2747,8 +2747,6 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
protected function getClassDropdown()
|
protected function getClassDropdown()
|
||||||
{
|
{
|
||||||
$classes = SiteTree::page_type_classes();
|
$classes = SiteTree::page_type_classes();
|
||||||
$currentClass = null;
|
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($classes as $class) {
|
foreach ($classes as $class) {
|
||||||
$instance = singleton($class);
|
$instance = singleton($class);
|
||||||
@ -2774,20 +2772,15 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$pageTypeName = $instance->i18n_singular_name();
|
$result[$class] = $instance->i18n_singular_name();
|
||||||
|
|
||||||
$currentClass = $class;
|
|
||||||
$result[$class] = $pageTypeName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort alphabetically, and put current on top
|
// Sort alphabetically, and put current on top
|
||||||
asort($result);
|
asort($result);
|
||||||
if ($currentClass) {
|
if (isset($result[$this->ClassName])) {
|
||||||
$currentPageTypeName = $result[$currentClass];
|
$currentPageTypeName = $result[$this->ClassName];
|
||||||
unset($result[$currentClass]);
|
unset($result[$this->ClassName]);
|
||||||
$result = array_reverse($result ?? []);
|
$result = [$this->ClassName => $currentPageTypeName] + $result;
|
||||||
$result[$currentClass] = $currentPageTypeName;
|
|
||||||
$result = array_reverse($result ?? []);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -1272,7 +1272,7 @@ class SiteTreeTest extends SapphireTest
|
|||||||
#[DataProvider('allowedChildrenProvider')]
|
#[DataProvider('allowedChildrenProvider')]
|
||||||
public function testAllowedChildren($className, $expected, $assertionMessage)
|
public function testAllowedChildren($className, $expected, $assertionMessage)
|
||||||
{
|
{
|
||||||
$class = new $className;
|
$class = new $className();
|
||||||
$this->assertEquals($expected, $class->allowedChildren(), $assertionMessage);
|
$this->assertEquals($expected, $class->allowedChildren(), $assertionMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1351,6 +1351,9 @@ class SiteTreeTest extends SapphireTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function testClassDropdown()
|
public function testClassDropdown()
|
||||||
{
|
{
|
||||||
$sitetree = new SiteTree();
|
$sitetree = new SiteTree();
|
||||||
@ -1372,7 +1375,18 @@ class SiteTreeTest extends SapphireTest
|
|||||||
|
|
||||||
$this->assertArrayNotHasKey(SiteTreeTest_NotRoot::class, $method->invoke($rootPage));
|
$this->assertArrayNotHasKey(SiteTreeTest_NotRoot::class, $method->invoke($rootPage));
|
||||||
$this->assertArrayHasKey(SiteTreeTest_NotRoot::class, $method->invoke($nonRootPage));
|
$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);
|
Security::setCurrentUser(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user