mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Resolve issues with namespacing
This commit is contained in:
parent
5bf364bedb
commit
4dfa4f4473
@ -12,7 +12,6 @@ mappings:
|
|||||||
CMSPageHistoryController: SilverStripe\CMS\Controllers\CMSPageHistoryController
|
CMSPageHistoryController: SilverStripe\CMS\Controllers\CMSPageHistoryController
|
||||||
CMSPagesController: SilverStripe\CMS\Controllers\CMSPagesController
|
CMSPagesController: SilverStripe\CMS\Controllers\CMSPagesController
|
||||||
CMSPageSettingsController: SilverStripe\CMS\Controllers\CMSPageSettingsController
|
CMSPageSettingsController: SilverStripe\CMS\Controllers\CMSPageSettingsController
|
||||||
CMSSettingsController: SilverStripe\CMS\Controllers\CMSSettingsController
|
|
||||||
CMSSiteTreeFilter: SilverStripe\CMS\Controllers\CMSSiteTreeFilter
|
CMSSiteTreeFilter: SilverStripe\CMS\Controllers\CMSSiteTreeFilter
|
||||||
CMSSiteTreeFilter_PublishedPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_PublishedPages
|
CMSSiteTreeFilter_PublishedPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_PublishedPages
|
||||||
CMSSiteTreeFilter_DeletedPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_DeletedPages
|
CMSSiteTreeFilter_DeletedPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_DeletedPages
|
||||||
@ -26,7 +25,6 @@ mappings:
|
|||||||
ErrorPageFileExtension: SilverStripe\CMS\Controllers\ErrorPageFileExtension
|
ErrorPageFileExtension: SilverStripe\CMS\Controllers\ErrorPageFileExtension
|
||||||
LeftAndMainPageIconsExtension: SilverStripe\CMS\Controllers\LeftAndMainPageIconsExtension
|
LeftAndMainPageIconsExtension: SilverStripe\CMS\Controllers\LeftAndMainPageIconsExtension
|
||||||
ModelAsController: SilverStripe\CMS\Controllers\ModelAsController
|
ModelAsController: SilverStripe\CMS\Controllers\ModelAsController
|
||||||
NestedController: SilverStripe\CMS\Controllers\NestedController
|
|
||||||
OldPageRedirector: SilverStripe\CMS\Controllers\OldPageRedirector
|
OldPageRedirector: SilverStripe\CMS\Controllers\OldPageRedirector
|
||||||
RootURLController: SilverStripe\CMS\Controllers\RootURLController
|
RootURLController: SilverStripe\CMS\Controllers\RootURLController
|
||||||
SilverStripeNavigator: SilverStripe\CMS\Controllers\SilverStripeNavigator
|
SilverStripeNavigator: SilverStripe\CMS\Controllers\SilverStripeNavigator
|
||||||
@ -35,7 +33,6 @@ mappings:
|
|||||||
SilverStripeNavigatorItem_StageLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_StageLink
|
SilverStripeNavigatorItem_StageLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_StageLink
|
||||||
SilverStripeNavigatorItem_LiveLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_LiveLink
|
SilverStripeNavigatorItem_LiveLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_LiveLink
|
||||||
SilverStripeNavigatorItem_ArchiveLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_ArchiveLink
|
SilverStripeNavigatorItem_ArchiveLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_ArchiveLink
|
||||||
Folder_UnusedAssetsField: SilverStripe\CMS\Forms\Folder_UnusedAssetsField
|
|
||||||
SiteTreeURLSegmentField: SilverStripe\CMS\Forms\SiteTreeURLSegmentField
|
SiteTreeURLSegmentField: SilverStripe\CMS\Forms\SiteTreeURLSegmentField
|
||||||
SiteTreeURLSegmentField_Readonly: SilverStripe\CMS\Forms\SiteTreeURLSegmentField_Readonly
|
SiteTreeURLSegmentField_Readonly: SilverStripe\CMS\Forms\SiteTreeURLSegmentField_Readonly
|
||||||
CurrentPageIdentifier: SilverStripe\CMS\Model\CurrentPageIdentifier
|
CurrentPageIdentifier: SilverStripe\CMS\Model\CurrentPageIdentifier
|
||||||
@ -65,3 +62,6 @@ mappings:
|
|||||||
SideReport_RecentlyEdited: SilverStripe\CMS\Reports\SideReport_RecentlyEdited
|
SideReport_RecentlyEdited: SilverStripe\CMS\Reports\SideReport_RecentlyEdited
|
||||||
ContentControllerSearchExtension: SilverStripe\CMS\Search\ContentControllerSearchExtension
|
ContentControllerSearchExtension: SilverStripe\CMS\Search\ContentControllerSearchExtension
|
||||||
SearchForm: SilverStripe\CMS\Search\SearchForm
|
SearchForm: SilverStripe\CMS\Search\SearchForm
|
||||||
|
MigrateSiteTreeLinkingTask: SilverStripe\CMS\Tasks\MigrateSiteTreeLinkingTask
|
||||||
|
RemoveOrphanedPagesTask: SilverStripe\CMS\Tasks\RemoveOrphanedPagesTask
|
||||||
|
SiteTreeMaintenanceTask: SilverStripe\CMS\Tasks\SiteTreeMaintenanceTask
|
||||||
|
16
_config.php
16
_config.php
@ -10,16 +10,18 @@ define('CMS_PATH', BASE_PATH . '/' . CMS_DIR);
|
|||||||
/**
|
/**
|
||||||
* Register the default internal shortcodes.
|
* Register the default internal shortcodes.
|
||||||
*/
|
*/
|
||||||
ShortcodeParser::get('default')->register('sitetree_link', array('SilverStripe\\CMS\\Model\\SiteTree', 'link_shortcode_handler'));
|
ShortcodeParser::get('default')->register(
|
||||||
|
'sitetree_link',
|
||||||
|
array('SilverStripe\\CMS\\Model\\SiteTree', 'link_shortcode_handler')
|
||||||
|
);
|
||||||
|
|
||||||
File::add_extension('SilverStripe\\CMS\\Model\\SiteTreeFileExtension');
|
File::add_extension('SilverStripe\\CMS\\Model\\SiteTreeFileExtension');
|
||||||
|
|
||||||
// TODO Remove once we can configure CMSMenu through static, nested configuration files
|
// TODO Remove once we can configure CMSMenu through static, nested configuration files
|
||||||
CMSMenu::remove_menu_item('SilverStripe\\CMS\\Controllers\\CMSMain');
|
CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSMain');
|
||||||
CMSMenu::remove_menu_item('SilverStripe\\CMS\\Controllers\\CMSPageEditController');
|
CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageEditController');
|
||||||
CMSMenu::remove_menu_item('SilverStripe\\CMS\\Controllers\\CMSPageSettingsController');
|
CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageSettingsController');
|
||||||
CMSMenu::remove_menu_item('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController');
|
CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController');
|
||||||
CMSMenu::remove_menu_item('CMSPageReportsController');
|
CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageAddController');
|
||||||
CMSMenu::remove_menu_item('SilverStripe\\CMS\\Controllers\\CMSPageAddController');
|
|
||||||
|
|
||||||
CMSMenu::remove_menu_item("SiteConfigLeftAndMain");
|
CMSMenu::remove_menu_item("SiteConfigLeftAndMain");
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
AdminRootController:
|
AdminRootController:
|
||||||
default_panel: 'CMSPagesController'
|
default_panel: 'SilverStripe\CMS\Controllers\CMSPagesController'
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
LeftAndMain:
|
LeftAndMain:
|
||||||
extensions:
|
extensions:
|
||||||
- LeftAndMainPageIconsExtension
|
- SilverStripe\CMS\Controllers\LeftAndMainPageIconsExtension
|
||||||
Controller:
|
Controller:
|
||||||
extensions:
|
extensions:
|
||||||
- ErrorPageControllerExtension
|
- SilverStripe\CMS\Controllers\ErrorPageControllerExtension
|
||||||
Form:
|
Form:
|
||||||
extensions:
|
extensions:
|
||||||
- ErrorPageControllerExtension
|
- SilverStripe\CMS\Controllers\ErrorPageControllerExtension
|
||||||
File:
|
File:
|
||||||
extensions:
|
extensions:
|
||||||
- ErrorPageFileExtension
|
- SilverStripe\CMS\Controllers\ErrorPageFileExtension
|
||||||
|
6
_config/injector.yml
Normal file
6
_config/injector.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
Name: cmsinjector
|
||||||
|
---
|
||||||
|
Injector:
|
||||||
|
SiteTreeLinkTracking_Parser:
|
||||||
|
class: SilverStripe\CMS\Model\SiteTreeLinkTracking_Parser
|
6
_config/legacy.yml
Normal file
6
_config/legacy.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
Name: cmslegacy
|
||||||
|
---
|
||||||
|
SilverStripe\ORM\DatabaseAdmin:
|
||||||
|
classname_value_remapping:
|
||||||
|
SiteTree: 'SilverStripe\CMS\Model\SiteTree'
|
@ -5,10 +5,10 @@ After: '#rootroutes'
|
|||||||
---
|
---
|
||||||
Director:
|
Director:
|
||||||
rules:
|
rules:
|
||||||
'': 'RootURLController'
|
'': 'SilverStripe\CMS\Controllers\RootURLController'
|
||||||
'RemoveOrphanedPagesTask//$Action/$ID/$OtherID': 'RemoveOrphanedPagesTask'
|
'RemoveOrphanedPagesTask//$Action/$ID/$OtherID': 'SilverStripe\CMS\Tasks\RemoveOrphanedPagesTask'
|
||||||
'SiteTreeMaintenanceTask//$Action/$ID/$OtherID': 'SiteTreeMaintenanceTask'
|
'SiteTreeMaintenanceTask//$Action/$ID/$OtherID': 'SilverStripe\CMS\Tasks\SiteTreeMaintenanceTask'
|
||||||
'$URLSegment//$Action/$ID/$OtherID': 'ModelAsController'
|
'$URLSegment//$Action/$ID/$OtherID': 'SilverStripe\CMS\Controllers\ModelAsController'
|
||||||
---
|
---
|
||||||
Name: legacycmsroutes
|
Name: legacycmsroutes
|
||||||
After: '#adminroutes'
|
After: '#adminroutes'
|
||||||
|
@ -199,7 +199,8 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
|||||||
|
|
||||||
// Remove legacy previewable behaviour.
|
// Remove legacy previewable behaviour.
|
||||||
$form->removeExtraClass('cms-previewable');
|
$form->removeExtraClass('cms-previewable');
|
||||||
$form->Fields()->removeByName('SilverStripe\\CMS\\Controllers\\SilverStripeNavigator');
|
/** @skipUpgrade */
|
||||||
|
$form->Fields()->removeByName('SilverStripeNavigator');
|
||||||
|
|
||||||
// File listing
|
// File listing
|
||||||
$gridFieldConfig = GridFieldConfig::create()->addComponents(
|
$gridFieldConfig = GridFieldConfig::create()->addComponents(
|
||||||
@ -633,7 +634,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
|||||||
|
|
||||||
// The root element should explicitly point to the root node.
|
// The root element should explicitly point to the root node.
|
||||||
// Uses session state for current record otherwise.
|
// Uses session state for current record otherwise.
|
||||||
$items[0]->Link = Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\AssetAdmin')->Link('show'), 0);
|
$items[0]->Link = Controller::join_links($this->Link('show'), 0);
|
||||||
|
|
||||||
// If a search is in progress, don't show the path
|
// If a search is in progress, don't show the path
|
||||||
if($this->getRequest()->requestVar('q')) {
|
if($this->getRequest()->requestVar('q')) {
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Controllers;
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
|
use ResetFormAction;
|
||||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\ORM\HiddenClass;
|
use SilverStripe\ORM\HiddenClass;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
@ -17,6 +19,7 @@ use SilverStripe\Security\PermissionProvider;
|
|||||||
use LeftAndMain;
|
use LeftAndMain;
|
||||||
|
|
||||||
|
|
||||||
|
use SS_HTTPRequest;
|
||||||
use Translatable;
|
use Translatable;
|
||||||
use Requirements;
|
use Requirements;
|
||||||
use CMSBatchActionHandler;
|
use CMSBatchActionHandler;
|
||||||
@ -91,6 +94,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
private static $subitem_class = "SilverStripe\\Security\\Member";
|
private static $subitem_class = "SilverStripe\\Security\\Member";
|
||||||
|
|
||||||
|
private static $session_namespace = 'SilverStripe\\CMS\\Controllers\\CMSMain';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Amount of results showing on a single page.
|
* Amount of results showing on a single page.
|
||||||
*
|
*
|
||||||
@ -230,7 +235,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function LinkPages() {
|
public function LinkPages() {
|
||||||
return singleton('SilverStripe\\CMS\\Controllers\\CMSPagesController')->Link();
|
return CMSPagesController::singleton()->Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LinkPagesWithSearch() {
|
public function LinkPagesWithSearch() {
|
||||||
@ -238,37 +243,43 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function LinkTreeView() {
|
public function LinkTreeView() {
|
||||||
return $this->LinkWithSearch(singleton('SilverStripe\\CMS\\Controllers\\CMSMain')->Link('treeview'));
|
return $this->LinkWithSearch($this->Link('treeview'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LinkListView() {
|
public function LinkListView() {
|
||||||
return $this->LinkWithSearch(singleton('SilverStripe\\CMS\\Controllers\\CMSMain')->Link('listview'));
|
return $this->LinkWithSearch($this->Link('listview'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LinkGalleryView() {
|
public function LinkGalleryView() {
|
||||||
return $this->LinkWithSearch(singleton('SilverStripe\\CMS\\Controllers\\CMSMain')->Link('galleryview'));
|
return $this->LinkWithSearch($this->Link('galleryview'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LinkPageEdit($id = null) {
|
public function LinkPageEdit($id = null) {
|
||||||
if(!$id) $id = $this->currentPageID();
|
if(!$id) {
|
||||||
|
$id = $this->currentPageID();
|
||||||
|
}
|
||||||
return $this->LinkWithSearch(
|
return $this->LinkWithSearch(
|
||||||
Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'), $id)
|
Controller::join_links(CMSPageEditController::singleton()->Link('show'), $id)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LinkPageSettings() {
|
public function LinkPageSettings() {
|
||||||
if($id = $this->currentPageID()) {
|
if($id = $this->currentPageID()) {
|
||||||
return $this->LinkWithSearch(
|
return $this->LinkWithSearch(
|
||||||
Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageSettingsController')->Link('show'), $id)
|
Controller::join_links(CMSPageSettingsController::singleton()->Link('show'), $id)
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LinkPageHistory() {
|
public function LinkPageHistory() {
|
||||||
if($id = $this->currentPageID()) {
|
if($id = $this->currentPageID()) {
|
||||||
return $this->LinkWithSearch(
|
return $this->LinkWithSearch(
|
||||||
Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController')->Link('show'), $id)
|
Controller::join_links(CMSPageHistoryController::singleton()->Link('show'), $id)
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +298,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function LinkPageAdd($extra = null, $placeholders = null) {
|
public function LinkPageAdd($extra = null, $placeholders = null) {
|
||||||
$link = singleton("SilverStripe\\CMS\\Controllers\\CMSPageAddController")->Link();
|
$link = CMSPageAddController::singleton()->Link();
|
||||||
$this->extend('updateLinkPageAdd', $link);
|
$this->extend('updateLinkPageAdd', $link);
|
||||||
|
|
||||||
if($extra) {
|
if($extra) {
|
||||||
@ -403,16 +414,18 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$actions = new FieldList(
|
$actions = new FieldList(
|
||||||
FormAction::create('doSearch', _t('CMSMain_left_ss.APPLY_FILTER', 'Search'))
|
FormAction::create('doSearch', _t('CMSMain_left_ss.APPLY_FILTER', 'Search'))
|
||||||
->addExtraClass('ss-ui-action-constructive'),
|
->addExtraClass('ss-ui-action-constructive'),
|
||||||
Object::create('ResetFormAction', 'clear', _t('CMSMain_left_ss.CLEAR_FILTER', 'Clear'))
|
ResetFormAction::create('clear', _t('CMSMain_left_ss.CLEAR_FILTER', 'Clear'))
|
||||||
);
|
);
|
||||||
|
|
||||||
// Use <button> to allow full jQuery UI styling on the all of the Actions
|
// Use <button> to allow full jQuery UI styling on the all of the Actions
|
||||||
foreach($actions->dataFields() as $action) {
|
foreach($actions->dataFields() as $action) {
|
||||||
|
/** @var FormAction $action */
|
||||||
$action->setUseButtonTag(true);
|
$action->setUseButtonTag(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the form
|
// Create the form
|
||||||
$form = Form::create($this, 'SilverStripe\\CMS\\Search\\SearchForm', $fields, $actions)
|
/** @skipUpgrade */
|
||||||
|
$form = Form::create($this, 'SearchForm', $fields, $actions)
|
||||||
->addExtraClass('cms-search-form')
|
->addExtraClass('cms-search-form')
|
||||||
->setFormMethod('GET')
|
->setFormMethod('GET')
|
||||||
->setFormAction($this->Link())
|
->setFormAction($this->Link())
|
||||||
@ -436,7 +449,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
protected function getPageTypes() {
|
protected function getPageTypes() {
|
||||||
$pageTypes = array();
|
$pageTypes = array();
|
||||||
foreach(SiteTree::page_type_classes() as $pageTypeClass) {
|
foreach(SiteTree::page_type_classes() as $pageTypeClass) {
|
||||||
$pageTypes[$pageTypeClass] = _t($pageTypeClass.'.SINGULARNAME', $pageTypeClass);
|
$pageTypes[$pageTypeClass] = SiteTree::singleton($pageTypeClass)->i18n_singular_name();
|
||||||
}
|
}
|
||||||
asort($pageTypes);
|
asort($pageTypes);
|
||||||
return $pageTypes;
|
return $pageTypes;
|
||||||
@ -472,14 +485,14 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$json = '';
|
$json = '';
|
||||||
$classes = SiteTree::page_type_classes();
|
$classes = SiteTree::page_type_classes();
|
||||||
|
|
||||||
$cacheCanCreate = array();
|
$cacheCanCreate = array();
|
||||||
foreach($classes as $class) $cacheCanCreate[$class] = singleton($class)->canCreate();
|
foreach($classes as $class) $cacheCanCreate[$class] = singleton($class)->canCreate();
|
||||||
|
|
||||||
// Generate basic cache key. Too complex to encompass all variations
|
// Generate basic cache key. Too complex to encompass all variations
|
||||||
$cache = SS_Cache::factory('CMSMain_SiteTreeHints');
|
$cache = SS_Cache::factory('CMSMain_SiteTreeHints');
|
||||||
$cacheKey = md5(implode('_', array(Member::currentUserID(), implode(',', $cacheCanCreate), implode(',', $classes))));
|
$cacheKey = md5(implode('_', array(Member::currentUserID(), implode(',', $cacheCanCreate), implode(',', $classes))));
|
||||||
if($this->getRequest()->getVar('flush')) $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
|
if($this->getRequest()->getVar('flush')) $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
|
||||||
$json = $cache->load($cacheKey);
|
$json = $cache->load($cacheKey);
|
||||||
if(!$json) {
|
if(!$json) {
|
||||||
$def['Root'] = array();
|
$def['Root'] = array();
|
||||||
$def['Root']['disallowedChildren'] = array();
|
$def['Root']['disallowedChildren'] = array();
|
||||||
@ -544,22 +557,27 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
foreach($classes as $class) {
|
foreach($classes as $class) {
|
||||||
$instance = singleton($class);
|
$instance = singleton($class);
|
||||||
|
|
||||||
if($instance instanceof HiddenClass) continue;
|
if($instance instanceof HiddenClass) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// skip this type if it is restricted
|
// skip this type if it is restricted
|
||||||
if($instance->stat('need_permission') && !$this->can(singleton($class)->stat('need_permission'))) continue;
|
if($instance->stat('need_permission') && !$this->can(singleton($class)->stat('need_permission'))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$addAction = $instance->i18n_singular_name();
|
$addAction = $instance->i18n_singular_name();
|
||||||
|
|
||||||
// Get description (convert 'Page' to 'SiteTree' for correct localization lookups)
|
// Get description (convert 'Page' to 'SiteTree' for correct localization lookups)
|
||||||
$description = _t((($class == 'Page') ? 'SilverStripe\\CMS\\Model\\SiteTree' : $class) . '.DESCRIPTION');
|
$i18nClass = ($class == 'Page') ? 'SilverStripe\\CMS\\Model\\SiteTree' : $class;
|
||||||
|
$description = _t($i18nClass . '.DESCRIPTION');
|
||||||
|
|
||||||
if(!$description) {
|
if(!$description) {
|
||||||
$description = $instance->uninherited('description');
|
$description = $instance->uninherited('description');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($class == 'Page' && !$description) {
|
if($class == 'Page' && !$description) {
|
||||||
$description = singleton('SilverStripe\\CMS\\Model\\SiteTree')->uninherited('description');
|
$description = SiteTree::singleton()->uninherited('description');
|
||||||
}
|
}
|
||||||
|
|
||||||
$result->push(new ArrayData(array(
|
$result->push(new ArrayData(array(
|
||||||
@ -674,8 +692,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Added in-line to the form, but plucked into different view by LeftAndMain.Preview.js upon load
|
// Added in-line to the form, but plucked into different view by LeftAndMain.Preview.js upon load
|
||||||
if($record instanceof CMSPreviewable && !$fields->fieldByName('SilverStripe\\CMS\\Controllers\\SilverStripeNavigator')) {
|
/** @skipUpgrade */
|
||||||
$navField = new LiteralField('SilverStripe\\CMS\\Controllers\\SilverStripeNavigator', $this->getSilverStripeNavigator());
|
if($record instanceof CMSPreviewable && !$fields->fieldByName('SilverStripeNavigator')) {
|
||||||
|
$navField = new LiteralField('SilverStripeNavigator', $this->getSilverStripeNavigator());
|
||||||
$navField->setAllowHTML(true);
|
$navField->setAllowHTML(true);
|
||||||
$fields->push($navField);
|
$fields->push($navField);
|
||||||
}
|
}
|
||||||
@ -878,7 +897,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
return sprintf(
|
return sprintf(
|
||||||
'<a class="action-detail" href="%s">%s</a>',
|
'<a class="action-detail" href="%s">%s</a>',
|
||||||
Controller::join_links(
|
Controller::join_links(
|
||||||
singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'),
|
CMSPageEditController::singleton()->Link('show'),
|
||||||
(int)$item->ID
|
(int)$item->ID
|
||||||
),
|
),
|
||||||
$item->TreeTitle // returns HTML, does its own escaping
|
$item->TreeTitle // returns HTML, does its own escaping
|
||||||
@ -1133,7 +1152,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
*/
|
*/
|
||||||
public function delete($data, $form) {
|
public function delete($data, $form) {
|
||||||
$id = $data['ID'];
|
$id = $data['ID'];
|
||||||
$record = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $id);
|
$record = SiteTree::get()->byID($id);
|
||||||
if($record && !$record->canDelete()) {
|
if($record && !$record->canDelete()) {
|
||||||
return Security::permissionFailure();
|
return Security::permissionFailure();
|
||||||
}
|
}
|
||||||
@ -1164,7 +1183,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
public function archive($data, $form) {
|
public function archive($data, $form) {
|
||||||
$id = $data['ID'];
|
$id = $data['ID'];
|
||||||
/** @var SiteTree $record */
|
/** @var SiteTree $record */
|
||||||
$record = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $id);
|
$record = SiteTree::get()->byID($id);
|
||||||
if(!$record || !$record->exists()) {
|
if(!$record || !$record->exists()) {
|
||||||
throw new SS_HTTPResponse_Exception("Bad record ID #$id", 404);
|
throw new SS_HTTPResponse_Exception("Bad record ID #$id", 404);
|
||||||
}
|
}
|
||||||
@ -1260,7 +1279,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
// Can be used in different contexts: In normal page edit view, in which case the redirect won't have any effect.
|
// Can be used in different contexts: In normal page edit view, in which case the redirect won't have any effect.
|
||||||
// Or in history view, in which case a revert causes the CMS to re-load the edit view.
|
// Or in history view, in which case a revert causes the CMS to re-load the edit view.
|
||||||
// The X-Pjax header forces a "full" content refresh on redirect.
|
// The X-Pjax header forces a "full" content refresh on redirect.
|
||||||
$url = Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'), $record->ID);
|
$url = Controller::join_links(CMSPageEditController::singleton()->Link('show'), $record->ID);
|
||||||
$this->getResponse()->addHeader('X-ControllerURL', $url);
|
$this->getResponse()->addHeader('X-ControllerURL', $url);
|
||||||
$this->getRequest()->addHeader('X-Pjax', 'Content');
|
$this->getRequest()->addHeader('X-Pjax', 'Content');
|
||||||
$this->getResponse()->addHeader('X-Pjax', 'Content');
|
$this->getResponse()->addHeader('X-Pjax', 'Content');
|
||||||
@ -1327,7 +1346,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
if(!SecurityToken::inst()->checkRequest($request)) return $this->httpError(400);
|
if(!SecurityToken::inst()->checkRequest($request)) return $this->httpError(400);
|
||||||
|
|
||||||
$start = 0;
|
$start = 0;
|
||||||
$pages = DataObject::get("SilverStripe\\CMS\\Model\\SiteTree", "", "", "", "$start,30");
|
$pages = SiteTree::get()->limit("$start,30");
|
||||||
$count = 0;
|
$count = 0;
|
||||||
while($pages) {
|
while($pages) {
|
||||||
foreach($pages as $page) {
|
foreach($pages as $page) {
|
||||||
@ -1341,9 +1360,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$count++;
|
$count++;
|
||||||
$response .= "<li>$count</li>";
|
$response .= "<li>$count</li>";
|
||||||
}
|
}
|
||||||
if($pages->Count() > 29) {
|
if($pages->count() > 29) {
|
||||||
$start += 30;
|
$start += 30;
|
||||||
$pages = DataObject::get("SilverStripe\\CMS\\Model\\SiteTree", "", "", "", "$start,30");
|
$pages = SiteTree::get()->limit("$start,30");
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1401,7 +1420,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
if(!SecurityToken::inst()->checkRequest($request)) return $this->httpError(400);
|
if(!SecurityToken::inst()->checkRequest($request)) return $this->httpError(400);
|
||||||
|
|
||||||
if(($id = $this->urlParams['ID']) && is_numeric($id)) {
|
if(($id = $this->urlParams['ID']) && is_numeric($id)) {
|
||||||
$page = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $id);
|
$page = SiteTree::get()->byID($id);
|
||||||
if($page && (!$page->canEdit() || !$page->canCreate(null, array('Parent' => $page->Parent())))) {
|
if($page && (!$page->canEdit() || !$page->canCreate(null, array('Parent' => $page->Parent())))) {
|
||||||
return Security::permissionFailure($this);
|
return Security::permissionFailure($this);
|
||||||
}
|
}
|
||||||
@ -1423,7 +1442,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
array('title' => $newPage->Title)
|
array('title' => $newPage->Title)
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
$url = Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'), $newPage->ID);
|
$url = Controller::join_links(CMSPageEditController::singleton()->Link('show'), $newPage->ID);
|
||||||
$this->getResponse()->addHeader('X-ControllerURL', $url);
|
$this->getResponse()->addHeader('X-ControllerURL', $url);
|
||||||
$this->getRequest()->addHeader('X-Pjax', 'Content');
|
$this->getRequest()->addHeader('X-Pjax', 'Content');
|
||||||
$this->getResponse()->addHeader('X-Pjax', 'Content');
|
$this->getResponse()->addHeader('X-Pjax', 'Content');
|
||||||
@ -1439,7 +1458,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
if(!SecurityToken::inst()->checkRequest($request)) return $this->httpError(400);
|
if(!SecurityToken::inst()->checkRequest($request)) return $this->httpError(400);
|
||||||
increase_time_limit_to();
|
increase_time_limit_to();
|
||||||
if(($id = $this->urlParams['ID']) && is_numeric($id)) {
|
if(($id = $this->urlParams['ID']) && is_numeric($id)) {
|
||||||
$page = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $id);
|
$page = SiteTree::get()->byID($id);
|
||||||
if($page && (!$page->canEdit() || !$page->canCreate(null, array('Parent' => $page->Parent())))) {
|
if($page && (!$page->canEdit() || !$page->canCreate(null, array('Parent' => $page->Parent())))) {
|
||||||
return Security::permissionFailure($this);
|
return Security::permissionFailure($this);
|
||||||
}
|
}
|
||||||
@ -1455,7 +1474,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
array('title' => $newPage->Title)
|
array('title' => $newPage->Title)
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
$url = Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'), $newPage->ID);
|
$url = Controller::join_links(CMSPageEditController::singleton()->Link('show'), $newPage->ID);
|
||||||
$this->getResponse()->addHeader('X-ControllerURL', $url);
|
$this->getResponse()->addHeader('X-ControllerURL', $url);
|
||||||
$this->getRequest()->addHeader('X-Pjax', 'Content');
|
$this->getRequest()->addHeader('X-Pjax', 'Content');
|
||||||
$this->getResponse()->addHeader('X-Pjax', 'Content');
|
$this->getResponse()->addHeader('X-Pjax', 'Content');
|
||||||
|
@ -178,10 +178,15 @@ class CMSPageAddController extends CMSPageEditController {
|
|||||||
if($page) $parentID = $page->ID;
|
if($page) $parentID = $page->ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_numeric($parentID) && $parentID > 0) $parentObj = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $parentID);
|
if(is_numeric($parentID) && $parentID > 0) {
|
||||||
else $parentObj = null;
|
$parentObj = SiteTree::get()->byID($parentID);
|
||||||
|
} else {
|
||||||
|
$parentObj = null;
|
||||||
|
}
|
||||||
|
|
||||||
if(!$parentObj || !$parentObj->ID) $parentID = 0;
|
if(!$parentObj || !$parentObj->ID) {
|
||||||
|
$parentID = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(!singleton($className)->canCreate(Member::currentUser(), array('Parent' => $parentObj))) {
|
if(!singleton($className)->canCreate(Member::currentUser(), array('Parent' => $parentObj))) {
|
||||||
return Security::permissionFailure($this);
|
return Security::permissionFailure($this);
|
||||||
@ -197,7 +202,7 @@ class CMSPageAddController extends CMSPageEditController {
|
|||||||
return $this->getResponseNegotiator()->respond($this->getRequest());
|
return $this->getResponseNegotiator()->respond($this->getRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
$editController = singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController');
|
$editController = CMSPageEditController::singleton();
|
||||||
$editController->setCurrentPageID($record->ID);
|
$editController->setCurrentPageID($record->ID);
|
||||||
|
|
||||||
Session::set(
|
Session::set(
|
||||||
@ -206,11 +211,10 @@ class CMSPageAddController extends CMSPageEditController {
|
|||||||
);
|
);
|
||||||
Session::set("FormInfo.Form_EditForm.formError.type", 'good');
|
Session::set("FormInfo.Form_EditForm.formError.type", 'good');
|
||||||
|
|
||||||
return $this->redirect(Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'), $record->ID));
|
return $this->redirect(Controller::join_links($editController->Link('show'), $record->ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function doCancel($data, $form) {
|
public function doCancel($data, $form) {
|
||||||
return $this->redirect(singleton('SilverStripe\\CMS\\Controllers\\CMSMain')->Link());
|
return $this->redirect(CMSMain::singleton()->Link());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,11 @@ namespace SilverStripe\CMS\Controllers;
|
|||||||
class CMSPageEditController extends CMSMain {
|
class CMSPageEditController extends CMSMain {
|
||||||
|
|
||||||
private static $url_segment = 'pages/edit';
|
private static $url_segment = 'pages/edit';
|
||||||
|
|
||||||
private static $url_rule = '/$Action/$ID/$OtherID';
|
private static $url_rule = '/$Action/$ID/$OtherID';
|
||||||
|
|
||||||
private static $url_priority = 41;
|
private static $url_priority = 41;
|
||||||
|
|
||||||
private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
|
private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
|
||||||
private static $session_namespace = 'SilverStripe\\CMS\\Controllers\\CMSMain';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Controllers;
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
use Form;
|
use Form;
|
||||||
@ -11,6 +13,8 @@ use FormAction;
|
|||||||
use HiddenField;
|
use HiddenField;
|
||||||
use Controller;
|
use Controller;
|
||||||
use LiteralField;
|
use LiteralField;
|
||||||
|
use SS_HTTPRequest;
|
||||||
|
use SS_HTTPResponse;
|
||||||
use ViewableData;
|
use ViewableData;
|
||||||
use CheckboxField;
|
use CheckboxField;
|
||||||
|
|
||||||
@ -21,11 +25,14 @@ use CheckboxField;
|
|||||||
class CMSPageHistoryController extends CMSMain {
|
class CMSPageHistoryController extends CMSMain {
|
||||||
|
|
||||||
private static $url_segment = 'pages/history';
|
private static $url_segment = 'pages/history';
|
||||||
|
|
||||||
private static $url_rule = '/$Action/$ID/$VersionID/$OtherVersionID';
|
private static $url_rule = '/$Action/$ID/$VersionID/$OtherVersionID';
|
||||||
|
|
||||||
private static $url_priority = 42;
|
private static $url_priority = 42;
|
||||||
|
|
||||||
private static $menu_title = 'History';
|
private static $menu_title = 'History';
|
||||||
|
|
||||||
private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
|
private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
|
||||||
private static $session_namespace = 'SilverStripe\\CMS\\Controllers\\CMSMain';
|
|
||||||
|
|
||||||
private static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
'VersionsForm',
|
'VersionsForm',
|
||||||
@ -172,7 +179,7 @@ class CMSPageHistoryController extends CMSMain {
|
|||||||
|
|
||||||
$fields->addFieldToTab('Root.Main',
|
$fields->addFieldToTab('Root.Main',
|
||||||
new LiteralField('CurrentlyViewingMessage', $this->customise(array(
|
new LiteralField('CurrentlyViewingMessage', $this->customise(array(
|
||||||
'Content' => $message,
|
'Content' => DBField::create_field('HTMLFragment', $message),
|
||||||
'Classes' => 'notice'
|
'Classes' => 'notice'
|
||||||
))->renderWith(array('CMSMain_notice'))),
|
))->renderWith(array('CMSMain_notice'))),
|
||||||
"Title"
|
"Title"
|
||||||
@ -237,7 +244,7 @@ class CMSPageHistoryController extends CMSMain {
|
|||||||
|
|
||||||
$versionsHtml = $vd->customise(array(
|
$versionsHtml = $vd->customise(array(
|
||||||
'Versions' => $versions
|
'Versions' => $versions
|
||||||
))->renderWith('CMSPageHistoryController_versions');
|
))->renderWith($this->getTemplatesWithSuffix('_versions'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = new FieldList(
|
$fields = new FieldList(
|
||||||
@ -265,9 +272,11 @@ class CMSPageHistoryController extends CMSMain {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Use <button> to allow full jQuery UI styling
|
// Use <button> to allow full jQuery UI styling
|
||||||
foreach($actions->dataFields() as $action) $action->setUseButtonTag(true);
|
foreach($actions->dataFields() as $action) {
|
||||||
|
/** @var FormAction $action */
|
||||||
|
$action->setUseButtonTag(true);
|
||||||
|
}
|
||||||
|
|
||||||
$negotiator = $this->getResponseNegotiator();
|
|
||||||
$form = Form::create(
|
$form = Form::create(
|
||||||
$this,
|
$this,
|
||||||
'VersionsForm',
|
'VersionsForm',
|
||||||
@ -289,16 +298,16 @@ class CMSPageHistoryController extends CMSMain {
|
|||||||
/**
|
/**
|
||||||
* Process the {@link VersionsForm} compare function between two pages.
|
* Process the {@link VersionsForm} compare function between two pages.
|
||||||
*
|
*
|
||||||
* @param array
|
* @param array $data
|
||||||
* @param Form
|
* @param Form $form
|
||||||
*
|
* @return SS_HTTPResponse|DBHTMLText
|
||||||
* @return html
|
|
||||||
*/
|
*/
|
||||||
public function doCompare($data, $form) {
|
public function doCompare($data, $form) {
|
||||||
$versions = $data['Versions'];
|
$versions = $data['Versions'];
|
||||||
if(count($versions) < 2) return null;
|
if(count($versions) < 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$id = $this->currentPageID();
|
|
||||||
$version1 = array_shift($versions);
|
$version1 = array_shift($versions);
|
||||||
$version2 = array_shift($versions);
|
$version2 = array_shift($versions);
|
||||||
|
|
||||||
@ -315,7 +324,7 @@ class CMSPageHistoryController extends CMSMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// non javascript, redirect the user to the page
|
// non javascript, redirect the user to the page
|
||||||
$this->redirect(Controller::join_links(
|
return $this->redirect(Controller::join_links(
|
||||||
$this->Link('compare'),
|
$this->Link('compare'),
|
||||||
$version1,
|
$version1,
|
||||||
$version2
|
$version2
|
||||||
@ -329,7 +338,7 @@ class CMSPageHistoryController extends CMSMain {
|
|||||||
* @param array
|
* @param array
|
||||||
* @param Form
|
* @param Form
|
||||||
*
|
*
|
||||||
* @return html
|
* @return DBHTMLText|SS_HTTPResponse
|
||||||
*/
|
*/
|
||||||
public function doShowVersion($data, $form) {
|
public function doShowVersion($data, $form) {
|
||||||
$versionID = null;
|
$versionID = null;
|
||||||
@ -338,8 +347,11 @@ class CMSPageHistoryController extends CMSMain {
|
|||||||
$versionID = array_shift($data['Versions']);
|
$versionID = array_shift($data['Versions']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$versionID) return;
|
if(!$versionID) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$request = $this->getRequest();
|
||||||
if($request->isAjax()) {
|
if($request->isAjax()) {
|
||||||
return $this->customise(array(
|
return $this->customise(array(
|
||||||
"EditForm" => $this->ShowVersionForm($versionID)
|
"EditForm" => $this->ShowVersionForm($versionID)
|
||||||
@ -350,7 +362,7 @@ class CMSPageHistoryController extends CMSMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// non javascript, redirect the user to the page
|
// non javascript, redirect the user to the page
|
||||||
$this->redirect(Controller::join_links(
|
return $this->redirect(Controller::join_links(
|
||||||
$this->Link('version'),
|
$this->Link('version'),
|
||||||
$versionID
|
$versionID
|
||||||
));
|
));
|
||||||
@ -383,12 +395,13 @@ class CMSPageHistoryController extends CMSMain {
|
|||||||
$fromVersion = $versionID;
|
$fromVersion = $versionID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$toVersion || !$toVersion) {
|
if(!$toVersion || !$fromVersion) {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $this->currentPageID();
|
$id = $this->currentPageID();
|
||||||
$page = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $id);
|
/** @var SiteTree $page */
|
||||||
|
$page = SiteTree::get()->byID($id);
|
||||||
|
|
||||||
if($page && $page->exists()) {
|
if($page && $page->exists()) {
|
||||||
if(!$page->canView()) {
|
if(!$page->canView()) {
|
||||||
@ -409,31 +422,30 @@ class CMSPageHistoryController extends CMSMain {
|
|||||||
user_error("Can't find version $toVersion of page $id", E_USER_ERROR);
|
user_error("Can't find version $toVersion of page $id", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($record)) {
|
if(!$record) {
|
||||||
$form = $this->getEditForm($id, null, null, true);
|
return null;
|
||||||
$form->setActions(new FieldList());
|
}
|
||||||
$form->addExtraClass('compare');
|
$form = $this->getEditForm($id, null, null, true);
|
||||||
|
$form->setActions(new FieldList());
|
||||||
|
$form->addExtraClass('compare');
|
||||||
|
|
||||||
// Comparison views shouldn't be editable.
|
// Comparison views shouldn't be editable.
|
||||||
// Its important to convert fields *before* loading data,
|
// Its important to convert fields *before* loading data,
|
||||||
// as the comparison output is HTML and not valid values for the various field types
|
// as the comparison output is HTML and not valid values for the various field types
|
||||||
$readonlyFields = $form->Fields()->makeReadonly();
|
$readonlyFields = $form->Fields()->makeReadonly();
|
||||||
$form->setFields($readonlyFields);
|
$form->setFields($readonlyFields);
|
||||||
|
|
||||||
$form->loadDataFrom($record);
|
$form->loadDataFrom($record);
|
||||||
$form->loadDataFrom(array(
|
$form->loadDataFrom(array(
|
||||||
"ID" => $id,
|
"ID" => $id,
|
||||||
"Version" => $fromVersion,
|
"Version" => $fromVersion,
|
||||||
));
|
));
|
||||||
|
|
||||||
foreach($form->Fields()->dataFields() as $field) {
|
foreach($form->Fields()->dataFields() as $field) {
|
||||||
$field->dontEscape = true;
|
$field->dontEscape = true;
|
||||||
}
|
|
||||||
|
|
||||||
return $form;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Breadcrumbs($unlinked = false) {
|
public function Breadcrumbs($unlinked = false) {
|
||||||
|
@ -8,10 +8,12 @@ namespace SilverStripe\CMS\Controllers;
|
|||||||
class CMSPageSettingsController extends CMSMain {
|
class CMSPageSettingsController extends CMSMain {
|
||||||
|
|
||||||
private static $url_segment = 'pages/settings';
|
private static $url_segment = 'pages/settings';
|
||||||
|
|
||||||
private static $url_rule = '/$Action/$ID/$OtherID';
|
private static $url_rule = '/$Action/$ID/$OtherID';
|
||||||
|
|
||||||
private static $url_priority = 42;
|
private static $url_priority = 42;
|
||||||
|
|
||||||
private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
|
private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
|
||||||
private static $session_namespace = 'SilverStripe\\CMS\\Controllers\\CMSMain';
|
|
||||||
|
|
||||||
public function getEditForm($id = null, $fields = null) {
|
public function getEditForm($id = null, $fields = null) {
|
||||||
$record = $this->getRecord($id ?: $this->currentPageID());
|
$record = $this->getRecord($id ?: $this->currentPageID());
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Controllers;
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
use Controller;
|
use Controller;
|
||||||
@ -13,11 +14,14 @@ use ArrayData;
|
|||||||
class CMSPagesController extends CMSMain {
|
class CMSPagesController extends CMSMain {
|
||||||
|
|
||||||
private static $url_segment = 'pages';
|
private static $url_segment = 'pages';
|
||||||
|
|
||||||
private static $url_rule = '/$Action/$ID/$OtherID';
|
private static $url_rule = '/$Action/$ID/$OtherID';
|
||||||
|
|
||||||
private static $url_priority = 40;
|
private static $url_priority = 40;
|
||||||
|
|
||||||
private static $menu_title = 'Pages';
|
private static $menu_title = 'Pages';
|
||||||
|
|
||||||
private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
|
private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
|
||||||
private static $session_namespace = 'SilverStripe\\CMS\\Controllers\\CMSMain';
|
|
||||||
|
|
||||||
public function LinkPreview() {
|
public function LinkPreview() {
|
||||||
return false;
|
return false;
|
||||||
@ -39,7 +43,7 @@ class CMSPagesController extends CMSMain {
|
|||||||
|
|
||||||
//special case for building the breadcrumbs when calling the listchildren Pages ListView action
|
//special case for building the breadcrumbs when calling the listchildren Pages ListView action
|
||||||
if($parentID = $this->getRequest()->getVar('ParentID')) {
|
if($parentID = $this->getRequest()->getVar('ParentID')) {
|
||||||
$page = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $parentID);
|
$page = SiteTree::get()->byID($parentID);
|
||||||
|
|
||||||
//build a reversed list of the parent tree
|
//build a reversed list of the parent tree
|
||||||
$pages = array();
|
$pages = array();
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace SilverStripe\CMS\Controllers;
|
|
||||||
|
|
||||||
use SiteConfigLeftAndMain;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 3.3.0
|
|
||||||
*
|
|
||||||
* @package cms
|
|
||||||
*/
|
|
||||||
class CMSSettingsController extends SiteConfigLeftAndMain {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @config
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private static $url_priority = 60;
|
|
||||||
|
|
||||||
}
|
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Controllers;
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use Object;
|
use Object;
|
||||||
use LeftAndMain_SearchFilter;
|
use LeftAndMain_SearchFilter;
|
||||||
@ -25,8 +28,10 @@ use DateField;
|
|||||||
abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFilter {
|
abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFilter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Array Search parameters, mostly properties on {@link SiteTree}.
|
* Search parameters, mostly properties on {@link SiteTree}.
|
||||||
* Caution: Unescaped data.
|
* Caution: Unescaped data.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $params = array();
|
protected $params = array();
|
||||||
|
|
||||||
@ -48,7 +53,7 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil
|
|||||||
protected $_cache_highlight_ids = null;
|
protected $_cache_highlight_ids = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $_cache_expanded = array();
|
protected $_cache_expanded = array();
|
||||||
|
|
||||||
@ -113,6 +118,8 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil
|
|||||||
if(!empty($this->_cache_highlight_ids[$page->ID])) {
|
if(!empty($this->_cache_highlight_ids[$page->ID])) {
|
||||||
return 'filtered-item';
|
return 'filtered-item';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -177,7 +184,7 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil
|
|||||||
* @return DataList Filtered query
|
* @return DataList Filtered query
|
||||||
*/
|
*/
|
||||||
protected function applyDefaultFilters($query) {
|
protected function applyDefaultFilters($query) {
|
||||||
$sng = singleton('SilverStripe\\CMS\\Model\\SiteTree');
|
$sng = SiteTree::singleton();
|
||||||
foreach($this->params as $name => $val) {
|
foreach($this->params as $name => $val) {
|
||||||
if(empty($val)) continue;
|
if(empty($val)) continue;
|
||||||
|
|
||||||
@ -221,7 +228,7 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil
|
|||||||
/**
|
/**
|
||||||
* Maps a list of pages to an array of associative arrays with ID and ParentID keys
|
* Maps a list of pages to an array of associative arrays with ID and ParentID keys
|
||||||
*
|
*
|
||||||
* @param DataList $pages
|
* @param SS_List $pages
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function mapIDs($pages) {
|
protected function mapIDs($pages) {
|
||||||
@ -270,7 +277,7 @@ class CMSSiteTreeFilter_PublishedPages extends CMSSiteTreeFilter {
|
|||||||
public function getFilteredPages() {
|
public function getFilteredPages() {
|
||||||
$pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree');
|
$pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree');
|
||||||
$pages = $this->applyDefaultFilters($pages);
|
$pages = $this->applyDefaultFilters($pages);
|
||||||
$pages = $pages->filterByCallback(function($page) {
|
$pages = $pages->filterByCallback(function(SiteTree $page) {
|
||||||
return $page->getExistsOnLive();
|
return $page->getExistsOnLive();
|
||||||
});
|
});
|
||||||
return $pages;
|
return $pages;
|
||||||
@ -349,7 +356,7 @@ class CMSSiteTreeFilter_StatusRemovedFromDraftPages extends CMSSiteTreeFilter {
|
|||||||
public function getFilteredPages() {
|
public function getFilteredPages() {
|
||||||
$pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree');
|
$pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree');
|
||||||
$pages = $this->applyDefaultFilters($pages);
|
$pages = $this->applyDefaultFilters($pages);
|
||||||
$pages = $pages->filterByCallback(function($page) {
|
$pages = $pages->filterByCallback(function(SiteTree $page) {
|
||||||
// If page is removed from stage but not live
|
// If page is removed from stage but not live
|
||||||
return $page->getIsDeletedFromStage() && $page->getExistsOnLive();
|
return $page->getIsDeletedFromStage() && $page->getExistsOnLive();
|
||||||
});
|
});
|
||||||
@ -378,7 +385,7 @@ class CMSSiteTreeFilter_StatusDraftPages extends CMSSiteTreeFilter {
|
|||||||
public function getFilteredPages() {
|
public function getFilteredPages() {
|
||||||
$pages = Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Stage');
|
$pages = Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Stage');
|
||||||
$pages = $this->applyDefaultFilters($pages);
|
$pages = $this->applyDefaultFilters($pages);
|
||||||
$pages = $pages->filterByCallback(function($page) {
|
$pages = $pages->filterByCallback(function(SiteTree $page) {
|
||||||
// If page exists on stage but not on live
|
// If page exists on stage but not on live
|
||||||
return (!$page->getIsDeletedFromStage() && $page->getIsAddedToStage());
|
return (!$page->getIsDeletedFromStage() && $page->getIsAddedToStage());
|
||||||
});
|
});
|
||||||
@ -418,7 +425,7 @@ class CMSSiteTreeFilter_StatusDeletedPages extends CMSSiteTreeFilter {
|
|||||||
$pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree');
|
$pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree');
|
||||||
$pages = $this->applyDefaultFilters($pages);
|
$pages = $this->applyDefaultFilters($pages);
|
||||||
|
|
||||||
$pages = $pages->filterByCallback(function($page) {
|
$pages = $pages->filterByCallback(function(SiteTree $page) {
|
||||||
// Doesn't exist on either stage or live
|
// Doesn't exist on either stage or live
|
||||||
return $page->getIsDeletedFromStage() && !$page->getExistsOnLive();
|
return $page->getIsDeletedFromStage() && !$page->getExistsOnLive();
|
||||||
});
|
});
|
||||||
|
@ -5,6 +5,7 @@ namespace SilverStripe\CMS\Controllers;
|
|||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\DataModel;
|
use SilverStripe\ORM\DataModel;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
use SilverStripe\ORM\FieldType\DBField;
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\ORM\SS_List;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
@ -67,11 +68,15 @@ class ContentController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* The ContentController will take the URLSegment parameter from the URL and use that to look
|
* The ContentController will take the URLSegment parameter from the URL and use that to look
|
||||||
* up a SiteTree record.
|
* up a SiteTree record.
|
||||||
|
*
|
||||||
|
* @param SiteTree $dataRecord
|
||||||
*/
|
*/
|
||||||
public function __construct($dataRecord = null) {
|
public function __construct($dataRecord = null) {
|
||||||
if(!$dataRecord) {
|
if(!$dataRecord) {
|
||||||
$dataRecord = new Page();
|
$dataRecord = new Page();
|
||||||
if($this->hasMethod("Title")) $dataRecord->Title = $this->Title();
|
if($this->hasMethod("Title")) {
|
||||||
|
$dataRecord->Title = $this->Title();
|
||||||
|
}
|
||||||
$dataRecord->URLSegment = get_class($this);
|
$dataRecord->URLSegment = get_class($this);
|
||||||
$dataRecord->ID = -1;
|
$dataRecord->ID = -1;
|
||||||
}
|
}
|
||||||
@ -110,7 +115,10 @@ class ContentController extends Controller {
|
|||||||
$parent = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $parentRef);
|
$parent = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $parentRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($parent) return $parent->Children();
|
if($parent) {
|
||||||
|
return $parent->Children();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,9 +133,11 @@ class ContentController extends Controller {
|
|||||||
parent::init();
|
parent::init();
|
||||||
|
|
||||||
// If we've accessed the homepage as /home/, then we should redirect to /.
|
// If we've accessed the homepage as /home/, then we should redirect to /.
|
||||||
if($this->dataRecord && $this->dataRecord instanceof SiteTree
|
if( $this->dataRecord instanceof SiteTree
|
||||||
&& RootURLController::should_be_on_root($this->dataRecord) && (!isset($this->urlParams['Action']) || !$this->urlParams['Action'] )
|
&& RootURLController::should_be_on_root($this->dataRecord)
|
||||||
&& !$_POST && !$_FILES && !$this->redirectedTo() ) {
|
&& (!isset($this->urlParams['Action']) || !$this->urlParams['Action'] )
|
||||||
|
&& !$_POST && !$_FILES && !$this->redirectedTo()
|
||||||
|
) {
|
||||||
$getVars = $_GET;
|
$getVars = $_GET;
|
||||||
unset($getVars['url']);
|
unset($getVars['url']);
|
||||||
if($getVars) $url = "?" . http_build_query($getVars);
|
if($getVars) $url = "?" . http_build_query($getVars);
|
||||||
@ -136,15 +146,19 @@ class ContentController extends Controller {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->dataRecord) $this->dataRecord->extend('contentcontrollerInit', $this);
|
if($this->dataRecord) {
|
||||||
else singleton('SilverStripe\\CMS\\Model\\SiteTree')->extend('contentcontrollerInit', $this);
|
$this->dataRecord->extend('contentcontrollerInit', $this);
|
||||||
|
} else {
|
||||||
|
SiteTree::singleton()->extend('contentcontrollerInit', $this);
|
||||||
|
}
|
||||||
|
|
||||||
if($this->redirectedTo()) return;
|
if($this->redirectedTo()) return;
|
||||||
|
|
||||||
// Check page permissions
|
// Check page permissions
|
||||||
/** @skipUpgrade */
|
/** @skipUpgrade */
|
||||||
if($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->canView()) {
|
if($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->canView()) {
|
||||||
return Security::permissionFailure($this);
|
Security::permissionFailure($this);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,6 +172,7 @@ class ContentController extends Controller {
|
|||||||
* @throws SS_HTTPResponse_Exception
|
* @throws SS_HTTPResponse_Exception
|
||||||
*/
|
*/
|
||||||
public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
|
public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
|
||||||
|
/** @var SiteTree $child */
|
||||||
$child = null;
|
$child = null;
|
||||||
$action = $request->param('Action');
|
$action = $request->param('Action');
|
||||||
$this->setDataModel($model);
|
$this->setDataModel($model);
|
||||||
@ -169,7 +184,7 @@ class ContentController extends Controller {
|
|||||||
// See ModelAdController->getNestedController() for similar logic
|
// See ModelAdController->getNestedController() for similar logic
|
||||||
if(class_exists('Translatable')) Translatable::disable_locale_filter();
|
if(class_exists('Translatable')) Translatable::disable_locale_filter();
|
||||||
// look for a page with this URLSegment
|
// look for a page with this URLSegment
|
||||||
$child = $this->model->SiteTree->filter(array(
|
$child = SiteTree::get()->filter(array(
|
||||||
'ParentID' => $this->ID,
|
'ParentID' => $this->ID,
|
||||||
'URLSegment' => rawurlencode($action)
|
'URLSegment' => rawurlencode($action)
|
||||||
))->first();
|
))->first();
|
||||||
@ -188,7 +203,11 @@ class ContentController extends Controller {
|
|||||||
// a potentially nested URL chain.
|
// a potentially nested URL chain.
|
||||||
if(class_exists('Translatable')) {
|
if(class_exists('Translatable')) {
|
||||||
$locale = $request->getVar('locale');
|
$locale = $request->getVar('locale');
|
||||||
if($locale && i18n::validate_locale($locale) && $this->dataRecord && $this->dataRecord->Locale != $locale) {
|
if( $locale
|
||||||
|
&& i18n::validate_locale($locale)
|
||||||
|
&& $this->dataRecord
|
||||||
|
&& $this->dataRecord->Locale != $locale
|
||||||
|
) {
|
||||||
$translation = $this->dataRecord->getTranslation($locale);
|
$translation = $this->dataRecord->getTranslation($locale);
|
||||||
if($translation) {
|
if($translation) {
|
||||||
$response = new SS_HTTPResponse();
|
$response = new SS_HTTPResponse();
|
||||||
@ -252,7 +271,7 @@ class ContentController extends Controller {
|
|||||||
$stack = array($parent);
|
$stack = array($parent);
|
||||||
|
|
||||||
if($parent) {
|
if($parent) {
|
||||||
while($parent = $parent->Parent) {
|
while(($parent = $parent->Parent()) && $parent->exists()) {
|
||||||
array_unshift($stack, $parent);
|
array_unshift($stack, $parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -339,11 +358,15 @@ HTML;
|
|||||||
} else {
|
} else {
|
||||||
if($date = Versioned::current_archived_date()) {
|
if($date = Versioned::current_archived_date()) {
|
||||||
Requirements::css(CMS_DIR . '/client/dist/styles/SilverStripeNavigator.css');
|
Requirements::css(CMS_DIR . '/client/dist/styles/SilverStripeNavigator.css');
|
||||||
|
/** @var DBDatetime $dateObj */
|
||||||
$dateObj = DBField::create_field('Datetime', $date);
|
$dateObj = DBField::create_field('Datetime', $date);
|
||||||
// $dateObj->setVal($date);
|
// $dateObj->setVal($date);
|
||||||
return "<div id=\"SilverStripeNavigatorMessage\">". _t('ContentController.ARCHIVEDSITEFROM') ."<br>" . $dateObj->Nice() . "</div>";
|
return "<div id=\"SilverStripeNavigatorMessage\">" .
|
||||||
|
_t('ContentController.ARCHIVEDSITEFROM') .
|
||||||
|
"<br>" . $dateObj->Nice() . "</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SiteConfig() {
|
public function SiteConfig() {
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
namespace SilverStripe\CMS\Controllers;
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
use Extension;
|
use Extension;
|
||||||
|
|
||||||
use SS_HTTPRequest;
|
use SS_HTTPRequest;
|
||||||
use SS_HTTPResponse_Exception;
|
use SS_HTTPResponse_Exception;
|
||||||
use SilverStripe\CMS\Model\ErrorPage;
|
use SilverStripe\CMS\Model\ErrorPage;
|
||||||
|
@ -33,19 +33,17 @@ class LeftAndMainPageIconsExtension extends Extension {
|
|||||||
$obj = singleton($class);
|
$obj = singleton($class);
|
||||||
$iconSpec = $obj->stat('icon');
|
$iconSpec = $obj->stat('icon');
|
||||||
|
|
||||||
if(!$iconSpec) continue;
|
if(!$iconSpec) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Legacy support: We no longer need separate icon definitions for folders etc.
|
// Legacy support: We no longer need separate icon definitions for folders etc.
|
||||||
$iconFile = (is_array($iconSpec)) ? $iconSpec[0] : $iconSpec;
|
$iconFile = (is_array($iconSpec)) ? $iconSpec[0] : $iconSpec;
|
||||||
|
|
||||||
// Legacy support: Add file extension if none exists
|
// Legacy support: Add file extension if none exists
|
||||||
if(!pathinfo($iconFile, PATHINFO_EXTENSION)) $iconFile .= '-file.gif';
|
if(!pathinfo($iconFile, PATHINFO_EXTENSION)) {
|
||||||
|
$iconFile .= '-file.gif';
|
||||||
$iconPathInfo = pathinfo($iconFile);
|
}
|
||||||
|
|
||||||
// Base filename
|
|
||||||
$baseFilename = $iconPathInfo['dirname'] . '/' . $iconPathInfo['filename'];
|
|
||||||
$fileExtension = $iconPathInfo['extension'];
|
|
||||||
|
|
||||||
$selector = ".page-icon.class-$class, li.class-$class > a .jstree-pageicon";
|
$selector = ".page-icon.class-$class, li.class-$class > a .jstree-pageicon";
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Controllers;
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
|
use NestedController;
|
||||||
use SilverStripe\ORM\DataModel;
|
use SilverStripe\ORM\DataModel;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
@ -29,6 +30,7 @@ use SilverStripe\CMS\Model\SiteTree;
|
|||||||
* @subpackage control
|
* @subpackage control
|
||||||
*/
|
*/
|
||||||
class ModelAsController extends Controller implements NestedController {
|
class ModelAsController extends Controller implements NestedController {
|
||||||
|
|
||||||
private static $extensions = array('SilverStripe\\CMS\\Controllers\\OldPageRedirector');
|
private static $extensions = array('SilverStripe\\CMS\\Controllers\\OldPageRedirector');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,7 +67,8 @@ class ModelAsController extends Controller implements NestedController {
|
|||||||
protected function beforeHandleRequest(SS_HTTPRequest $request, DataModel $model) {
|
protected function beforeHandleRequest(SS_HTTPRequest $request, DataModel $model) {
|
||||||
parent::beforeHandleRequest($request, $model);
|
parent::beforeHandleRequest($request, $model);
|
||||||
// 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('SilverStripe\\CMS\\Model\\SiteTree')) {
|
/** @skipUpgrade */
|
||||||
|
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
||||||
$this->getResponse()->redirect(Controller::join_links(
|
$this->getResponse()->redirect(Controller::join_links(
|
||||||
Director::absoluteBaseURL(),
|
Director::absoluteBaseURL(),
|
||||||
'dev/build',
|
'dev/build',
|
||||||
@ -92,7 +95,8 @@ 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('SilverStripe\\CMS\\Model\\SiteTree')) {
|
/** @skipUpgrade */
|
||||||
|
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?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
||||||
$this->popCurrent();
|
$this->popCurrent();
|
||||||
|
|
||||||
@ -135,6 +139,7 @@ class ModelAsController extends Controller implements NestedController {
|
|||||||
if(SiteTree::config()->nested_urls) {
|
if(SiteTree::config()->nested_urls) {
|
||||||
$conditions[] = array('"SiteTree"."ParentID"' => 0);
|
$conditions[] = array('"SiteTree"."ParentID"' => 0);
|
||||||
}
|
}
|
||||||
|
/** @var SiteTree $sitetree */
|
||||||
$sitetree = DataObject::get_one('SilverStripe\\CMS\\Model\\SiteTree', $conditions);
|
$sitetree = DataObject::get_one('SilverStripe\\CMS\\Model\\SiteTree', $conditions);
|
||||||
|
|
||||||
// Check translation module
|
// Check translation module
|
||||||
@ -166,7 +171,7 @@ class ModelAsController extends Controller implements NestedController {
|
|||||||
static public function find_old_page($URLSegment, $parent = null, $ignoreNestedURLs = false) {
|
static public function find_old_page($URLSegment, $parent = null, $ignoreNestedURLs = false) {
|
||||||
Deprecation::notice('4.0', 'Use OldPageRedirector::find_old_page instead');
|
Deprecation::notice('4.0', 'Use OldPageRedirector::find_old_page instead');
|
||||||
if ($parent) {
|
if ($parent) {
|
||||||
$parent = SiteTree::get()->byId($parent);
|
$parent = SiteTree::get()->byID($parent);
|
||||||
}
|
}
|
||||||
$url = OldPageRedirector::find_old_page(array($URLSegment), $parent);
|
$url = OldPageRedirector::find_old_page(array($URLSegment), $parent);
|
||||||
return SiteTree::get_by_link($url);
|
return SiteTree::get_by_link($url);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace SilverStripe\CMS\Controllers;
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
use SilverStripe\ORM\Queries\SQLSelect;
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use Extension;
|
use Extension;
|
||||||
use Director;
|
use Director;
|
||||||
use SS_HTTPRequest;
|
use SS_HTTPRequest;
|
||||||
@ -10,8 +11,6 @@ use SS_HTTPResponse;
|
|||||||
use Controller;
|
use Controller;
|
||||||
use SS_HTTPResponse_Exception;
|
use SS_HTTPResponse_Exception;
|
||||||
|
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
|
||||||
|
|
||||||
|
|
||||||
class OldPageRedirector extends Extension {
|
class OldPageRedirector extends Extension {
|
||||||
|
|
||||||
@ -25,7 +24,7 @@ class OldPageRedirector extends Extension {
|
|||||||
public function onBeforeHTTPError404($request) {
|
public function onBeforeHTTPError404($request) {
|
||||||
// We need to get the URL ourselves because $request->allParams() only has a max of 4 params
|
// We need to get the URL ourselves because $request->allParams() only has a max of 4 params
|
||||||
$params = preg_split('|/+|', $request->getURL());
|
$params = preg_split('|/+|', $request->getURL());
|
||||||
$cleanURL = trim(Director::makeRelative($request->getURL(false), '/'));
|
$cleanURL = trim(Director::makeRelative($request->getURL(false)), '/');
|
||||||
|
|
||||||
$getvars = $request->getVars();
|
$getvars = $request->getVars();
|
||||||
unset($getvars['url']);
|
unset($getvars['url']);
|
||||||
@ -57,14 +56,17 @@ class OldPageRedirector extends Extension {
|
|||||||
* @return string|boolean False, or the new URL
|
* @return string|boolean False, or the new URL
|
||||||
*/
|
*/
|
||||||
static public function find_old_page($params, $parent = null, $redirect = false) {
|
static public function find_old_page($params, $parent = null, $redirect = false) {
|
||||||
$parent = is_numeric($parent) ? SiteTree::get()->byId($parent) : $parent;
|
$parent = is_numeric($parent) ? SiteTree::get()->byID($parent) : $parent;
|
||||||
$params = (array)$params;
|
$params = (array)$params;
|
||||||
$URL = rawurlencode(array_shift($params));
|
$URL = rawurlencode(array_shift($params));
|
||||||
if (empty($URL)) { return false; }
|
if (empty($URL)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/** @var SiteTree $page */
|
||||||
if ($parent) {
|
if ($parent) {
|
||||||
$page = SiteTree::get()->filter(array('ParentID' => $parent->ID, 'URLSegment' => $URL))->First();
|
$page = SiteTree::get()->filter(array('ParentID' => $parent->ID, 'URLSegment' => $URL))->first();
|
||||||
} else {
|
} else {
|
||||||
$page = SiteTree::get()->filter(array('URLSegment' => $URL))->First();
|
$page = SiteTree::get()->filter(array('URLSegment' => $URL))->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$page) {
|
if (!$page) {
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Controllers;
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use SilverStripe\ORM\DataModel;
|
use SilverStripe\ORM\DataModel;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use Controller;
|
use Controller;
|
||||||
|
|
||||||
use SS_HTTPResponse;
|
use SS_HTTPResponse;
|
||||||
use Translatable;
|
use Translatable;
|
||||||
use Config;
|
use Config;
|
||||||
@ -13,7 +13,6 @@ use Deprecation;
|
|||||||
use SS_HTTPRequest;
|
use SS_HTTPRequest;
|
||||||
use ClassInfo;
|
use ClassInfo;
|
||||||
use Director;
|
use Director;
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,7 +108,10 @@ class RootURLController extends Controller {
|
|||||||
static public function should_be_on_root(SiteTree $page) {
|
static public function should_be_on_root(SiteTree $page) {
|
||||||
if(!self::$is_at_root && self::get_homepage_link() == trim($page->RelativeLink(true), '/')) {
|
if(!self::$is_at_root && self::get_homepage_link() == trim($page->RelativeLink(true), '/')) {
|
||||||
return !(
|
return !(
|
||||||
class_exists('Translatable') && $page->hasExtension('Translatable') && $page->Locale && $page->Locale != Translatable::default_locale()
|
class_exists('Translatable')
|
||||||
|
&& $page->hasExtension('Translatable')
|
||||||
|
&& $page->Locale
|
||||||
|
&& $page->Locale != Translatable::default_locale()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +130,8 @@ class RootURLController extends Controller {
|
|||||||
|
|
||||||
self::$is_at_root = true;
|
self::$is_at_root = true;
|
||||||
|
|
||||||
if(!DB::is_active() || !ClassInfo::hasTable('SilverStripe\\CMS\\Model\\SiteTree')) {
|
/** @skipUpgrade */
|
||||||
|
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
||||||
$this->getResponse()->redirect(Controller::join_links(
|
$this->getResponse()->redirect(Controller::join_links(
|
||||||
Director::absoluteBaseURL(),
|
Director::absoluteBaseURL(),
|
||||||
'dev/build',
|
'dev/build',
|
||||||
@ -149,7 +152,8 @@ class RootURLController extends Controller {
|
|||||||
$this->beforeHandleRequest($request, $model);
|
$this->beforeHandleRequest($request, $model);
|
||||||
|
|
||||||
if (!$this->getResponse()->isFinished()) {
|
if (!$this->getResponse()->isFinished()) {
|
||||||
if (!DB::is_active() || !ClassInfo::hasTable('SilverStripe\\CMS\\Model\\SiteTree')) {
|
/** @skipUpgrade */
|
||||||
|
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?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
||||||
return $this->getResponse();
|
return $this->getResponse();
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ use SilverStripe\ORM\DataObject;
|
|||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\ORM\SS_List;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\ORM\FieldType\DBField;
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
use ViewableData;
|
use ViewableData;
|
||||||
use CMSPreviewable;
|
use CMSPreviewable;
|
||||||
use ClassInfo;
|
use ClassInfo;
|
||||||
@ -123,6 +124,9 @@ abstract class SilverStripeNavigatorItem extends ViewableData {
|
|||||||
*/
|
*/
|
||||||
protected $record;
|
protected $record;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $recordLink;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DataObject|CMSPreviewable $record
|
* @param DataObject|CMSPreviewable $record
|
||||||
*/
|
*/
|
||||||
@ -218,7 +222,7 @@ abstract class SilverStripeNavigatorItem extends ViewableData {
|
|||||||
(!$currentDraft || ($currentDraft && $this->record->Version != $currentDraft->Version))
|
(!$currentDraft || ($currentDraft && $this->record->Version != $currentDraft->Version))
|
||||||
&& (!$currentLive || ($currentLive && $this->record->Version != $currentLive->Version))
|
&& (!$currentLive || ($currentLive && $this->record->Version != $currentLive->Version))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->record->_cached_isArchived;
|
return $this->record->_cached_isArchived;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Forms;
|
namespace SilverStripe\CMS\Forms;
|
||||||
|
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SS_HTTPRequest;
|
||||||
use TextField;
|
use TextField;
|
||||||
use Requirements;
|
use Requirements;
|
||||||
use Controller;
|
use Controller;
|
||||||
@ -50,6 +51,10 @@ class SiteTreeURLSegmentField extends TextField {
|
|||||||
return parent::Field($properties);
|
return parent::Field($properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param SS_HTTPRequest $request
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function suggest($request) {
|
public function suggest($request) {
|
||||||
if(!$request->getVar('value')) {
|
if(!$request->getVar('value')) {
|
||||||
return $this->httpError(405,
|
return $this->httpError(405,
|
||||||
@ -75,7 +80,9 @@ class SiteTreeURLSegmentField extends TextField {
|
|||||||
*/
|
*/
|
||||||
public function getPage() {
|
public function getPage() {
|
||||||
$idField = $this->getForm()->Fields()->dataFieldByName('ID');
|
$idField = $this->getForm()->Fields()->dataFieldByName('ID');
|
||||||
return ($idField && $idField->Value()) ? DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $idField->Value()) : singleton('SilverStripe\\CMS\\Model\\SiteTree');
|
return ($idField && $idField->Value())
|
||||||
|
? SiteTree::get()->byID($idField->Value())
|
||||||
|
: SiteTree::singleton();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,11 +2,9 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Logging;
|
namespace SilverStripe\CMS\Logging;
|
||||||
|
|
||||||
|
|
||||||
use SilverStripe\Framework\Logging\DebugViewFriendlyErrorFormatter;
|
use SilverStripe\Framework\Logging\DebugViewFriendlyErrorFormatter;
|
||||||
use SilverStripe\CMS\Model\ErrorPage;
|
use SilverStripe\CMS\Model\ErrorPage;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides {@see ErrorPage}-gnostic error handling
|
* Provides {@see ErrorPage}-gnostic error handling
|
||||||
*/
|
*/
|
||||||
|
@ -10,6 +10,7 @@ use SilverStripe\ORM\DataObject;
|
|||||||
* @subpackage model
|
* @subpackage model
|
||||||
*/
|
*/
|
||||||
interface CurrentPageIdentifier {
|
interface CurrentPageIdentifier {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current page ID.
|
* Get the current page ID.
|
||||||
* @return int
|
* @return int
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Model;
|
namespace SilverStripe\CMS\Model;
|
||||||
|
|
||||||
|
use FieldList;
|
||||||
use SilverStripe\Filesystem\Storage\GeneratedAssetHandler;
|
use SilverStripe\Filesystem\Storage\GeneratedAssetHandler;
|
||||||
use SilverStripe\ORM\DataModel;
|
use SilverStripe\ORM\DataModel;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
@ -43,6 +44,8 @@ class ErrorPage extends Page {
|
|||||||
"ShowInSearch" => 0
|
"ShowInSearch" => 0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private static $table_name = 'ErrorPage';
|
||||||
|
|
||||||
private static $allowed_children = array();
|
private static $allowed_children = array();
|
||||||
|
|
||||||
private static $description = 'Custom content for different error cases (e.g. "Page not found")';
|
private static $description = 'Custom content for different error cases (e.g. "Page not found")';
|
||||||
@ -83,6 +86,7 @@ class ErrorPage extends Page {
|
|||||||
*/
|
*/
|
||||||
public static function response_for($statusCode) {
|
public static function response_for($statusCode) {
|
||||||
// first attempt to dynamically generate the error page
|
// first attempt to dynamically generate the error page
|
||||||
|
/** @var ErrorPage $errorPage */
|
||||||
$errorPage = ErrorPage::get()
|
$errorPage = ErrorPage::get()
|
||||||
->filter(array(
|
->filter(array(
|
||||||
"ErrorCode" => $statusCode
|
"ErrorCode" => $statusCode
|
||||||
@ -107,6 +111,8 @@ class ErrorPage extends Page {
|
|||||||
$response->setBody($content);
|
$response->setBody($content);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,50 +120,62 @@ class ErrorPage extends Page {
|
|||||||
* instance of ErrorPage with a 404 and 500 error code. If there is not,
|
* instance of ErrorPage with a 404 and 500 error code. If there is not,
|
||||||
* one is created when the DB is built.
|
* one is created when the DB is built.
|
||||||
*/
|
*/
|
||||||
public function requireDefaultRecords() {
|
public function requireDefaultRecords()
|
||||||
|
{
|
||||||
parent::requireDefaultRecords();
|
parent::requireDefaultRecords();
|
||||||
|
|
||||||
if ($this->class === 'SilverStripe\\CMS\\Model\\ErrorPage' && SiteTree::config()->create_default_pages) {
|
// Only run on ErrorPage class directly, not subclasses
|
||||||
|
if ($this->class !== 'SilverStripe\\CMS\\Model\\ErrorPage' || !SiteTree::config()->create_default_pages) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$defaultPages = $this->getDefaultRecords();
|
$defaultPages = $this->getDefaultRecords();
|
||||||
|
|
||||||
foreach($defaultPages as $defaultData) {
|
foreach ($defaultPages as $defaultData) {
|
||||||
$code = $defaultData['ErrorCode'];
|
$this->requireDefaultRecordFixture($defaultData);
|
||||||
$page = ErrorPage::get()->filter('ErrorCode', $code)->first();
|
}
|
||||||
$pageExists = !empty($page);
|
}
|
||||||
if(!$pageExists) {
|
|
||||||
$page = new ErrorPage($defaultData);
|
|
||||||
$page->write();
|
|
||||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if static files are enabled
|
/**
|
||||||
if(!self::config()->enable_static_file) {
|
* Build default record from specification fixture
|
||||||
continue;
|
*
|
||||||
}
|
* @param array $defaultData
|
||||||
|
*/
|
||||||
|
protected function requireDefaultRecordFixture($defaultData) {
|
||||||
|
$code = $defaultData['ErrorCode'];
|
||||||
|
$page = ErrorPage::get()->filter('ErrorCode', $code)->first();
|
||||||
|
$pageExists = !empty($page);
|
||||||
|
if(!$pageExists) {
|
||||||
|
$page = new ErrorPage($defaultData);
|
||||||
|
$page->write();
|
||||||
|
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure this page has cached error content
|
// Check if static files are enabled
|
||||||
$success = true;
|
if(!self::config()->enable_static_file) {
|
||||||
if(!$page->hasStaticPage()) {
|
return;
|
||||||
// Update static content
|
}
|
||||||
$success = $page->writeStaticPage();
|
|
||||||
} elseif($pageExists) {
|
|
||||||
// If page exists and already has content, no alteration_message is displayed
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($success) {
|
// Ensure this page has cached error content
|
||||||
DB::alteration_message(
|
$success = true;
|
||||||
sprintf('%s error page created', $code),
|
if(!$page->hasStaticPage()) {
|
||||||
'created'
|
// Update static content
|
||||||
);
|
$success = $page->writeStaticPage();
|
||||||
} else {
|
} elseif($pageExists) {
|
||||||
DB::alteration_message(
|
// If page exists and already has content, no alteration_message is displayed
|
||||||
sprintf('%s error page could not be created. Please check permissions', $code),
|
return;
|
||||||
'error'
|
}
|
||||||
);
|
|
||||||
}
|
if($success) {
|
||||||
}
|
DB::alteration_message(
|
||||||
|
sprintf('%s error page created', $code),
|
||||||
|
'created'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
DB::alteration_message(
|
||||||
|
sprintf('%s error page could not be created. Please check permissions', $code),
|
||||||
|
'error'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Model;
|
namespace SilverStripe\CMS\Model;
|
||||||
|
|
||||||
use SilverStripe\ORM\DataObject;
|
|
||||||
use Page;
|
use Page;
|
||||||
use Requirements;
|
use Requirements;
|
||||||
use HeaderField;
|
use HeaderField;
|
||||||
@ -16,6 +15,11 @@ use Page_Controller;
|
|||||||
*
|
*
|
||||||
* @package cms
|
* @package cms
|
||||||
* @subpackage content
|
* @subpackage content
|
||||||
|
*
|
||||||
|
* @property string $RedirectionType Either 'Internal' or 'External'
|
||||||
|
* @property string $ExternalURL URL to redirect to if $RedirectionType is 'External'
|
||||||
|
* @property int $LinkToID
|
||||||
|
* @method SiteTree LinkTo() Page to link to if $RedirectionType is 'Internal'
|
||||||
*/
|
*/
|
||||||
class RedirectorPage extends Page {
|
class RedirectorPage extends Page {
|
||||||
private static $description = 'Redirects to an internal page or an external URL';
|
private static $description = 'Redirects to an internal page or an external URL';
|
||||||
@ -33,8 +37,7 @@ class RedirectorPage extends Page {
|
|||||||
"LinkTo" => "SilverStripe\\CMS\\Model\\SiteTree",
|
"LinkTo" => "SilverStripe\\CMS\\Model\\SiteTree",
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $many_many = array(
|
private static $table_name = 'RedirectorPage';
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns this page if the redirect is external, otherwise
|
* Returns this page if the redirect is external, otherwise
|
||||||
@ -83,38 +86,39 @@ class RedirectorPage extends Page {
|
|||||||
* Only return a value if there is a legal redirection destination.
|
* Only return a value if there is a legal redirection destination.
|
||||||
*/
|
*/
|
||||||
public function redirectionLink() {
|
public function redirectionLink() {
|
||||||
|
// Check external redirect
|
||||||
if($this->RedirectionType == 'External') {
|
if($this->RedirectionType == 'External') {
|
||||||
if($this->ExternalURL) {
|
return $this->ExternalURL ?: null;
|
||||||
return $this->ExternalURL;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$linkTo = $this->LinkToID ? DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $this->LinkToID) : null;
|
|
||||||
|
|
||||||
if($linkTo) {
|
|
||||||
// We shouldn't point to ourselves - that would create an infinite loop! Return null since we have a
|
|
||||||
// bad configuration
|
|
||||||
if($this->ID == $linkTo->ID) {
|
|
||||||
return null;
|
|
||||||
|
|
||||||
// If we're linking to another redirectorpage then just return the URLSegment, to prevent a cycle of redirector
|
|
||||||
// pages from causing an infinite loop. Instead, they will cause a 30x redirection loop in the browser, but
|
|
||||||
// this can be handled sufficiently gracefully by the browser.
|
|
||||||
} elseif($linkTo instanceof RedirectorPage) {
|
|
||||||
return $linkTo->regularLink();
|
|
||||||
|
|
||||||
// For all other pages, just return the link of the page.
|
|
||||||
} else {
|
|
||||||
return $linkTo->Link();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check internal redirect
|
||||||
|
/** @var SiteTree $linkTo */
|
||||||
|
$linkTo = $this->LinkToID ? SiteTree::get()->byID($this->LinkToID) : null;
|
||||||
|
if (empty($linkTo)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We shouldn't point to ourselves - that would create an infinite loop! Return null since we have a
|
||||||
|
// bad configuration
|
||||||
|
if($this->ID == $linkTo->ID) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we're linking to another redirectorpage then just return the URLSegment, to prevent a cycle of redirector
|
||||||
|
// pages from causing an infinite loop. Instead, they will cause a 30x redirection loop in the browser, but
|
||||||
|
// this can be handled sufficiently gracefully by the browser.
|
||||||
|
if($linkTo instanceof RedirectorPage) {
|
||||||
|
return $linkTo->regularLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
// For all other pages, just return the link of the page.
|
||||||
|
return $linkTo->Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function syncLinkTracking() {
|
public function syncLinkTracking() {
|
||||||
if ($this->RedirectionType == 'Internal') {
|
if ($this->RedirectionType == 'Internal') {
|
||||||
if($this->LinkToID) {
|
if($this->LinkToID) {
|
||||||
$this->HasBrokenLink = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $this->LinkToID) ? false : true;
|
$this->HasBrokenLink = SiteTree::get()->byID($this->LinkToID) ? false : true;
|
||||||
} else {
|
} else {
|
||||||
// An incomplete redirector page definitely has a broken link
|
// An incomplete redirector page definitely has a broken link
|
||||||
$this->HasBrokenLink = true;
|
$this->HasBrokenLink = true;
|
||||||
@ -188,9 +192,10 @@ class RedirectorPage_Controller extends Page_Controller {
|
|||||||
parent::init();
|
parent::init();
|
||||||
|
|
||||||
// Check we don't already have a redirect code set
|
// Check we don't already have a redirect code set
|
||||||
if(!$this->getResponse()->isFinished() && $link = $this->redirectionLink()) {
|
/** @var RedirectorPage $page */
|
||||||
|
$page = $this->data();
|
||||||
|
if(!$this->getResponse()->isFinished() && $link = $page->redirectionLink()) {
|
||||||
$this->redirect($link, 301);
|
$this->redirect($link, 301);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Model;
|
namespace SilverStripe\CMS\Model;
|
||||||
|
|
||||||
|
use GridFieldDataColumns;
|
||||||
|
use ShortcodeParser;
|
||||||
|
use SilverStripe\CMS\Controllers\CMSPageEditController;
|
||||||
|
use SilverStripe\CMS\Controllers\ContentController;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\Hierarchy\Hierarchy;
|
use SilverStripe\ORM\Hierarchy\Hierarchy;
|
||||||
use SilverStripe\ORM\ManyManyList;
|
use SilverStripe\ORM\ManyManyList;
|
||||||
@ -28,8 +32,6 @@ use SiteConfig;
|
|||||||
use FormField;
|
use FormField;
|
||||||
use Config;
|
use Config;
|
||||||
use Page;
|
use Page;
|
||||||
use UpgradeSiteTreePermissionSchemaTask;
|
|
||||||
use SS_HTTPRequest;
|
|
||||||
use URLSegmentFilter;
|
use URLSegmentFilter;
|
||||||
use SilverStripe\CMS\Controllers\ModelAsController;
|
use SilverStripe\CMS\Controllers\ModelAsController;
|
||||||
use Subsite;
|
use Subsite;
|
||||||
@ -81,6 +83,7 @@ use i18n;
|
|||||||
*
|
*
|
||||||
* @method ManyManyList ViewerGroups List of groups that can view this object.
|
* @method ManyManyList ViewerGroups List of groups that can view this object.
|
||||||
* @method ManyManyList EditorGroups List of groups that can edit this object.
|
* @method ManyManyList EditorGroups List of groups that can edit this object.
|
||||||
|
* @method SiteTree Parent()
|
||||||
*
|
*
|
||||||
* @mixin Hierarchy
|
* @mixin Hierarchy
|
||||||
* @mixin Versioned
|
* @mixin Versioned
|
||||||
@ -188,7 +191,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $has_many = array(
|
private static $has_many = array(
|
||||||
"VirtualPages" => "VirtualPage.CopyContentFrom"
|
"VirtualPages" => "SilverStripe\\CMS\\Model\\VirtualPage.CopyContentFrom"
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $owned_by = array(
|
private static $owned_by = array(
|
||||||
@ -214,6 +217,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
"CanEditType" => "Inherit"
|
"CanEditType" => "Inherit"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private static $table_name = 'SiteTree';
|
||||||
|
|
||||||
private static $versioning = array(
|
private static $versioning = array(
|
||||||
"Stage", "Live"
|
"Stage", "Live"
|
||||||
);
|
);
|
||||||
@ -326,31 +331,40 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if(self::config()->nested_urls) {
|
if(self::config()->nested_urls) {
|
||||||
$conditions[] = array('"SiteTree"."ParentID"' => 0);
|
$conditions[] = array('"SiteTree"."ParentID"' => 0);
|
||||||
}
|
}
|
||||||
$sitetree = DataObject::get_one('SilverStripe\\CMS\\Model\\SiteTree', $conditions, $cache);
|
/** @var SiteTree $sitetree */
|
||||||
|
$sitetree = DataObject::get_one(__CLASS__, $conditions, $cache);
|
||||||
|
|
||||||
/// Fall back on a unique URLSegment for b/c.
|
/// Fall back on a unique URLSegment for b/c.
|
||||||
if( !$sitetree
|
if( !$sitetree
|
||||||
&& self::config()->nested_urls
|
&& self::config()->nested_urls
|
||||||
&& $page = DataObject::get_one('SilverStripe\\CMS\\Model\\SiteTree', array(
|
&& $sitetree = DataObject::get_one(__CLASS__, array(
|
||||||
'"SiteTree"."URLSegment"' => $URLSegment
|
'"SiteTree"."URLSegment"' => $URLSegment
|
||||||
), $cache)
|
), $cache)
|
||||||
) {
|
) {
|
||||||
return $page;
|
return $sitetree;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to grab an alternative page from extensions.
|
// Attempt to grab an alternative page from extensions.
|
||||||
if(!$sitetree) {
|
if(!$sitetree) {
|
||||||
$parentID = self::config()->nested_urls ? 0 : null;
|
$parentID = self::config()->nested_urls ? 0 : null;
|
||||||
|
|
||||||
if($alternatives = singleton('SilverStripe\\CMS\\Model\\SiteTree')->extend('alternateGetByLink', $URLSegment, $parentID)) {
|
if($alternatives = static::singleton()->extend('alternateGetByLink', $URLSegment, $parentID)) {
|
||||||
foreach($alternatives as $alternative) if($alternative) $sitetree = $alternative;
|
foreach($alternatives as $alternative) {
|
||||||
|
if($alternative) {
|
||||||
|
$sitetree = $alternative;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$sitetree) return false;
|
if(!$sitetree) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we have any more URL parts to parse.
|
// Check if we have any more URL parts to parse.
|
||||||
if(!self::config()->nested_urls || !count($parts)) return $sitetree;
|
if(!self::config()->nested_urls || !count($parts)) {
|
||||||
|
return $sitetree;
|
||||||
|
}
|
||||||
|
|
||||||
// Traverse down the remaining URL segments and grab the relevant SiteTree objects.
|
// Traverse down the remaining URL segments and grab the relevant SiteTree objects.
|
||||||
foreach($parts as $segment) {
|
foreach($parts as $segment) {
|
||||||
@ -364,11 +378,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if(!$next) {
|
if(!$next) {
|
||||||
$parentID = (int) $sitetree->ID;
|
$parentID = (int) $sitetree->ID;
|
||||||
|
|
||||||
if($alternatives = singleton('SilverStripe\\CMS\\Model\\SiteTree')->extend('alternateGetByLink', $segment, $parentID)) {
|
if($alternatives = static::singleton()->extend('alternateGetByLink', $segment, $parentID)) {
|
||||||
foreach($alternatives as $alternative) if($alternative) $next = $alternative;
|
foreach($alternatives as $alternative) if($alternative) $next = $alternative;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$next) return false;
|
if(!$next) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sitetree->destroy();
|
$sitetree->destroy();
|
||||||
@ -421,21 +437,24 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
/**
|
/**
|
||||||
* Replace a "[sitetree_link id=n]" shortcode with a link to the page with the corresponding ID.
|
* Replace a "[sitetree_link id=n]" shortcode with a link to the page with the corresponding ID.
|
||||||
*
|
*
|
||||||
* @param array $arguments
|
* @param array $arguments
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @param TextParser $parser
|
* @param ShortcodeParser $parser
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
static public function link_shortcode_handler($arguments, $content = null, $parser = null) {
|
static public function link_shortcode_handler($arguments, $content = null, $parser = null) {
|
||||||
if(!isset($arguments['id']) || !is_numeric($arguments['id'])) return;
|
if(!isset($arguments['id']) || !is_numeric($arguments['id'])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!($page = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $arguments['id'])) // Get the current page by ID.
|
!($page = DataObject::get_by_id(__CLASS__, $arguments['id'])) // Get the current page by ID.
|
||||||
&& !($page = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $arguments['id'])) // Attempt link to old version.
|
&& !($page = Versioned::get_latest_version(__CLASS__, $arguments['id'])) // Attempt link to old version.
|
||||||
) {
|
) {
|
||||||
return null; // There were no suitable matches at all.
|
return null; // There were no suitable matches at all.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var SiteTree $page */
|
||||||
$link = Convert::raw2att($page->Link());
|
$link = Convert::raw2att($page->Link());
|
||||||
|
|
||||||
if($content) {
|
if($content) {
|
||||||
@ -510,8 +529,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if($this->ParentID && self::config()->nested_urls) {
|
if($this->ParentID && self::config()->nested_urls) {
|
||||||
$parent = $this->Parent();
|
$parent = $this->Parent();
|
||||||
// If page is removed select parent from version history (for archive page view)
|
// If page is removed select parent from version history (for archive page view)
|
||||||
if((!$parent || !$parent->exists()) && $this->IsDeletedFromStage) {
|
if((!$parent || !$parent->exists()) && $this->getIsDeletedFromStage()) {
|
||||||
$parent = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $this->ParentID);
|
$parent = Versioned::get_latest_version(__CLASS__, $this->ParentID);
|
||||||
}
|
}
|
||||||
$base = $parent->RelativeLink($this->URLSegment);
|
$base = $parent->RelativeLink($this->URLSegment);
|
||||||
} elseif(!$action && $this->URLSegment == RootURLController::get_homepage_link()) {
|
} elseif(!$action && $this->URLSegment == RootURLController::get_homepage_link()) {
|
||||||
@ -541,7 +560,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function getAbsoluteLiveLink($includeStageEqualsLive = true) {
|
public function getAbsoluteLiveLink($includeStageEqualsLive = true) {
|
||||||
$oldReadingMode = Versioned::get_reading_mode();
|
$oldReadingMode = Versioned::get_reading_mode();
|
||||||
Versioned::set_stage(Versioned::LIVE);
|
Versioned::set_stage(Versioned::LIVE);
|
||||||
$live = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::LIVE, array(
|
/** @var SiteTree $live */
|
||||||
|
$live = Versioned::get_one_by_stage(__CLASS__, Versioned::LIVE, array(
|
||||||
'"SiteTree"."ID"' => $this->ID
|
'"SiteTree"."ID"' => $this->ID
|
||||||
));
|
));
|
||||||
if($live) {
|
if($live) {
|
||||||
@ -564,7 +584,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*/
|
*/
|
||||||
public function CMSEditLink() {
|
public function CMSEditLink() {
|
||||||
$link = Controller::join_links(
|
$link = Controller::join_links(
|
||||||
singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'),
|
CMSPageEditController::singleton()->Link('show'),
|
||||||
$this->ID
|
$this->ID
|
||||||
);
|
);
|
||||||
return Director::absoluteURL($link);
|
return Director::absoluteURL($link);
|
||||||
@ -586,7 +606,14 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isCurrent() {
|
public function isCurrent() {
|
||||||
return $this->ID ? $this->ID == Director::get_current_page()->ID : $this === Director::get_current_page();
|
$currentPage = Director::get_current_page();
|
||||||
|
if ($currentPage instanceof ContentController) {
|
||||||
|
$currentPage = $currentPage->data();
|
||||||
|
}
|
||||||
|
if($currentPage instanceof SiteTree) {
|
||||||
|
return $currentPage === $this || $currentPage->ID === $this->ID;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -610,7 +637,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*/
|
*/
|
||||||
public function isOrphaned() {
|
public function isOrphaned() {
|
||||||
// Always false for root pages
|
// Always false for root pages
|
||||||
if(empty($this->ParentID)) return false;
|
if(empty($this->ParentID)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Parent must exist and not be an orphan itself
|
// Parent must exist and not be an orphan itself
|
||||||
$parent = $this->Parent();
|
$parent = $this->Parent();
|
||||||
@ -659,10 +688,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*/
|
*/
|
||||||
public function InSection($sectionName) {
|
public function InSection($sectionName) {
|
||||||
$page = Director::get_current_page();
|
$page = Director::get_current_page();
|
||||||
while($page) {
|
while($page && $page->exists()) {
|
||||||
if($sectionName == $page->URLSegment)
|
if($sectionName == $page->URLSegment) {
|
||||||
return true;
|
return true;
|
||||||
$page = $page->Parent;
|
}
|
||||||
|
$page = $page->Parent();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -680,17 +710,17 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
/**
|
/**
|
||||||
* Duplicates each child of this node recursively and returns the top-level duplicate node.
|
* Duplicates each child of this node recursively and returns the top-level duplicate node.
|
||||||
*
|
*
|
||||||
* @return self The duplicated object
|
* @return static The duplicated object
|
||||||
*/
|
*/
|
||||||
public function duplicateWithChildren() {
|
public function duplicateWithChildren() {
|
||||||
|
/** @var SiteTree $clone */
|
||||||
$clone = $this->duplicate();
|
$clone = $this->duplicate();
|
||||||
$children = $this->AllChildren();
|
$children = $this->AllChildren();
|
||||||
|
|
||||||
if($children) {
|
if($children) {
|
||||||
|
/** @var SiteTree $child */
|
||||||
foreach($children as $child) {
|
foreach($children as $child) {
|
||||||
$childClone = method_exists($child, 'duplicateWithChildren')
|
$childClone = $child->duplicateWithChildren();
|
||||||
? $child->duplicateWithChildren()
|
|
||||||
: $child->duplicate();
|
|
||||||
$childClone->ParentID = $clone->ID;
|
$childClone->ParentID = $clone->ID;
|
||||||
$childClone->write();
|
$childClone->write();
|
||||||
}
|
}
|
||||||
@ -705,6 +735,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* @param int $id ID of the new node's new parent
|
* @param int $id ID of the new node's new parent
|
||||||
*/
|
*/
|
||||||
public function duplicateAsChild($id) {
|
public function duplicateAsChild($id) {
|
||||||
|
/** @var SiteTree $newSiteTree */
|
||||||
$newSiteTree = $this->duplicate();
|
$newSiteTree = $this->duplicate();
|
||||||
$newSiteTree->ParentID = $id;
|
$newSiteTree->ParentID = $id;
|
||||||
$newSiteTree->Sort = 0;
|
$newSiteTree->Sort = 0;
|
||||||
@ -745,6 +776,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
while(
|
while(
|
||||||
$page
|
$page
|
||||||
|
&& $page->exists()
|
||||||
&& (!$maxDepth || count($pages) < $maxDepth)
|
&& (!$maxDepth || count($pages) < $maxDepth)
|
||||||
&& (!$stopAtPageType || $page->ClassName != $stopAtPageType)
|
&& (!$stopAtPageType || $page->ClassName != $stopAtPageType)
|
||||||
) {
|
) {
|
||||||
@ -752,7 +784,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$pages[] = $page;
|
$pages[] = $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = $page->Parent;
|
$page = $page->Parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ArrayList(array_reverse($pages));
|
return new ArrayList(array_reverse($pages));
|
||||||
@ -784,6 +816,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if ($parentID = $this->getField("ParentID")) {
|
if ($parentID = $this->getField("ParentID")) {
|
||||||
return DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $parentID);
|
return DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $parentID);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -798,7 +831,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$parts = [];
|
$parts = [];
|
||||||
while($item && $level > 0) {
|
while($item && $level > 0) {
|
||||||
$parts[] = $item->Title;
|
$parts[] = $item->Title;
|
||||||
$item = $item->Parent;
|
$item = $item->getParent();
|
||||||
$level--;
|
$level--;
|
||||||
}
|
}
|
||||||
return implode($separator, array_reverse($parts));
|
return implode($separator, array_reverse($parts));
|
||||||
@ -1135,7 +1168,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* to 'SiteTree::can_(permission)_multiple'
|
* to 'SiteTree::can_(permission)_multiple'
|
||||||
*/
|
*/
|
||||||
static public function prepopulate_permission_cache($permission = 'CanEditType', $ids, $batchCallback = null) {
|
static public function prepopulate_permission_cache($permission = 'CanEditType', $ids, $batchCallback = null) {
|
||||||
if(!$batchCallback) $batchCallback = "SiteTree::can_{$permission}_multiple";
|
if(!$batchCallback) {
|
||||||
|
$batchCallback = __CLASS__ . "::can_{$permission}_multiple";
|
||||||
|
}
|
||||||
|
|
||||||
if(is_callable($batchCallback)) {
|
if(is_callable($batchCallback)) {
|
||||||
call_user_func($batchCallback, $ids, Member::currentUserID(), false);
|
call_user_func($batchCallback, $ids, Member::currentUserID(), false);
|
||||||
@ -1203,15 +1238,20 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
//$ids = array_keys(array_filter(self::can_view_multiple($ids, $memberID)));
|
//$ids = array_keys(array_filter(self::can_view_multiple($ids, $memberID)));
|
||||||
|
|
||||||
// Get the groups that the given member belongs to
|
// Get the groups that the given member belongs to
|
||||||
$groupIDs = DataObject::get_by_id('SilverStripe\\Security\\Member', $memberID)->Groups()->column("ID");
|
/** @var Member $member */
|
||||||
|
$member = DataObject::get_by_id('SilverStripe\\Security\\Member', $memberID);
|
||||||
|
$groupIDs = $member->Groups()->column("ID");
|
||||||
$SQL_groupList = implode(", ", $groupIDs);
|
$SQL_groupList = implode(", ", $groupIDs);
|
||||||
if (!$SQL_groupList) $SQL_groupList = '0';
|
if (!$SQL_groupList) {
|
||||||
|
$SQL_groupList = '0';
|
||||||
|
}
|
||||||
|
|
||||||
$combinedStageResult = array();
|
$combinedStageResult = array();
|
||||||
|
|
||||||
foreach(array(Versioned::DRAFT, Versioned::LIVE) as $stage) {
|
foreach(array(Versioned::DRAFT, Versioned::LIVE) as $stage) {
|
||||||
// Start by filling the array with the pages that actually exist
|
// Start by filling the array with the pages that actually exist
|
||||||
$table = ($stage=='Stage') ? "SilverStripe\\CMS\\Model\\SiteTree" : "SiteTree_$stage";
|
/** @skipUpgrade */
|
||||||
|
$table = ($stage=='Stage') ? "SiteTree" : "SiteTree_$stage";
|
||||||
|
|
||||||
if($ids) {
|
if($ids) {
|
||||||
$idQuery = "SELECT \"ID\" FROM \"$table\" WHERE \"ID\" IN ($idPlaceholders)";
|
$idQuery = "SELECT \"ID\" FROM \"$table\" WHERE \"ID\" IN ($idPlaceholders)";
|
||||||
@ -1377,7 +1417,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function collateDescendants($condition, &$collator) {
|
public function collateDescendants($condition, &$collator) {
|
||||||
if($children = $this->Children()) {
|
$children = $this->Children();
|
||||||
|
if($children) {
|
||||||
foreach($children as $item) {
|
foreach($children as $item) {
|
||||||
|
|
||||||
if(eval("return $condition;")) {
|
if(eval("return $condition;")) {
|
||||||
@ -1388,6 +1429,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1404,7 +1446,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$tags[] = FormField::create_tag('title', array(), $this->obj('Title')->forTemplate());
|
$tags[] = FormField::create_tag('title', array(), $this->obj('Title')->forTemplate());
|
||||||
}
|
}
|
||||||
|
|
||||||
$generator = trim(Config::inst()->get('SilverStripe\\CMS\\Model\\SiteTree', 'meta_generator'));
|
$generator = trim(Config::inst()->get(__CLASS__, 'meta_generator'));
|
||||||
if (!empty($generator)) {
|
if (!empty($generator)) {
|
||||||
$tags[] = FormField::create_tag('meta', array(
|
$tags[] = FormField::create_tag('meta', array(
|
||||||
'name' => 'generator',
|
'name' => 'generator',
|
||||||
@ -1471,12 +1513,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
parent::requireDefaultRecords();
|
parent::requireDefaultRecords();
|
||||||
|
|
||||||
// default pages
|
// default pages
|
||||||
if($this->class == 'SilverStripe\\CMS\\Model\\SiteTree' && $this->config()->create_default_pages) {
|
if($this->class == __CLASS__ && $this->config()->create_default_pages) {
|
||||||
if(!SiteTree::get_by_link(Config::inst()->get('SilverStripe\\CMS\\Controllers\\RootURLController', 'default_homepage_link'))) {
|
if(!SiteTree::get_by_link(RootURLController::config()->default_homepage_link)) {
|
||||||
$homepage = new Page();
|
$homepage = new Page();
|
||||||
$homepage->Title = _t('SiteTree.DEFAULTHOMETITLE', 'Home');
|
$homepage->Title = _t('SiteTree.DEFAULTHOMETITLE', 'Home');
|
||||||
$homepage->Content = _t('SiteTree.DEFAULTHOMECONTENT', '<p>Welcome to SilverStripe! This is the default homepage. You can edit this page by opening <a href="admin/">the CMS</a>.</p><p>You can now access the <a href="http://docs.silverstripe.org">developer documentation</a>, or begin the <a href="http://www.silverstripe.org/learn/lessons">SilverStripe lessons</a>.</p>');
|
$homepage->Content = _t('SiteTree.DEFAULTHOMECONTENT', '<p>Welcome to SilverStripe! This is the default homepage. You can edit this page by opening <a href="admin/">the CMS</a>.</p><p>You can now access the <a href="http://docs.silverstripe.org">developer documentation</a>, or begin the <a href="http://www.silverstripe.org/learn/lessons">SilverStripe lessons</a>.</p>');
|
||||||
$homepage->URLSegment = Config::inst()->get('SilverStripe\\CMS\\Controllers\\RootURLController', 'default_homepage_link');
|
$homepage->URLSegment = RootURLController::config()->default_homepage_link;
|
||||||
$homepage->Sort = 1;
|
$homepage->Sort = 1;
|
||||||
$homepage->write();
|
$homepage->write();
|
||||||
$homepage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$homepage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
@ -1487,7 +1529,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if(DB::query("SELECT COUNT(*) FROM \"SiteTree\"")->value() == 1) {
|
if(DB::query("SELECT COUNT(*) FROM \"SiteTree\"")->value() == 1) {
|
||||||
$aboutus = new Page();
|
$aboutus = new Page();
|
||||||
$aboutus->Title = _t('SiteTree.DEFAULTABOUTTITLE', 'About Us');
|
$aboutus->Title = _t('SiteTree.DEFAULTABOUTTITLE', 'About Us');
|
||||||
$aboutus->Content = _t('SiteTree.DEFAULTABOUTCONTENT', '<p>You can fill this page out with your own content, or delete it and create your own pages.</p>');
|
$aboutus->Content = _t(
|
||||||
|
'SiteTree.DEFAULTABOUTCONTENT',
|
||||||
|
'<p>You can fill this page out with your own content, or delete it and create your own pages.</p>'
|
||||||
|
);
|
||||||
$aboutus->Sort = 2;
|
$aboutus->Sort = 2;
|
||||||
$aboutus->write();
|
$aboutus->write();
|
||||||
$aboutus->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$aboutus->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
@ -1496,7 +1541,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
$contactus = new Page();
|
$contactus = new Page();
|
||||||
$contactus->Title = _t('SiteTree.DEFAULTCONTACTTITLE', 'Contact Us');
|
$contactus->Title = _t('SiteTree.DEFAULTCONTACTTITLE', 'Contact Us');
|
||||||
$contactus->Content = _t('SiteTree.DEFAULTCONTACTCONTENT', '<p>You can fill this page out with your own content, or delete it and create your own pages.</p>');
|
$contactus->Content = _t(
|
||||||
|
'SiteTree.DEFAULTCONTACTCONTENT',
|
||||||
|
'<p>You can fill this page out with your own content, or delete it and create your own pages.</p>'
|
||||||
|
);
|
||||||
$contactus->Sort = 3;
|
$contactus->Sort = 3;
|
||||||
$contactus->write();
|
$contactus->write();
|
||||||
$contactus->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$contactus->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
@ -1572,6 +1620,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// If deleting this page, delete all its children.
|
// If deleting this page, delete all its children.
|
||||||
if(SiteTree::config()->enforce_strict_hierarchy && $children = $this->AllChildren()) {
|
if(SiteTree::config()->enforce_strict_hierarchy && $children = $this->AllChildren()) {
|
||||||
foreach($children as $child) {
|
foreach($children as $child) {
|
||||||
|
/** @var SiteTree $child */
|
||||||
$child->delete();
|
$child->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1605,9 +1654,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// No need to check for subclasses or instanceof, as allowedChildren() already
|
// No need to check for subclasses or instanceof, as allowedChildren() already
|
||||||
// deconstructs any inheritance trees already.
|
// deconstructs any inheritance trees already.
|
||||||
$allowed = $parent->allowedChildren();
|
$allowed = $parent->allowedChildren();
|
||||||
$subject = ($this instanceof VirtualPage && $this->CopyContentFromID) ? $this->CopyContentFrom() : $this;
|
$subject = ($this instanceof VirtualPage && $this->CopyContentFromID)
|
||||||
|
? $this->CopyContentFrom()
|
||||||
|
: $this;
|
||||||
if(!in_array($subject->ClassName, $allowed)) {
|
if(!in_array($subject->ClassName, $allowed)) {
|
||||||
|
|
||||||
$result->error(
|
$result->error(
|
||||||
_t(
|
_t(
|
||||||
'SiteTree.PageTypeNotAllowed',
|
'SiteTree.PageTypeNotAllowed',
|
||||||
@ -1778,7 +1828,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$items->merge($redirectorList);
|
$items->merge($redirectorList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(class_exists('Subsite')) Subsite::disable_subsite_filter($origDisableSubsiteFilter);
|
if(class_exists('Subsite')) {
|
||||||
|
Subsite::disable_subsite_filter($origDisableSubsiteFilter);
|
||||||
|
}
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
@ -1811,7 +1863,6 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* @return FieldList The fields to be displayed in the CMS
|
* @return FieldList The fields to be displayed in the CMS
|
||||||
*/
|
*/
|
||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
require_once("forms/Form.php");
|
|
||||||
// Status / message
|
// Status / message
|
||||||
// Create a status message for multiple parents
|
// Create a status message for multiple parents
|
||||||
if($this->ID && is_numeric($this->ID)) {
|
if($this->ID && is_numeric($this->ID)) {
|
||||||
@ -1819,24 +1870,24 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
$parentPageLinks = array();
|
$parentPageLinks = array();
|
||||||
|
|
||||||
if($linkedPages->Count() > 0) {
|
if($linkedPages->count() > 0) {
|
||||||
|
/** @var VirtualPage $linkedPage */
|
||||||
foreach($linkedPages as $linkedPage) {
|
foreach($linkedPages as $linkedPage) {
|
||||||
$parentPage = $linkedPage->Parent;
|
$parentPage = $linkedPage->Parent();
|
||||||
if($parentPage) {
|
if($parentPage && $parentPage->exists()) {
|
||||||
if($parentPage->ID) {
|
$link = Convert::raw2att($parentPage->CMSEditLink());
|
||||||
$parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/pages/edit/show/$linkedPage->ID\">{$parentPage->Title}</a>";
|
$title = Convert::raw2xml($parentPage->Title);
|
||||||
} else {
|
} else {
|
||||||
$parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/pages/edit/show/$linkedPage->ID\">" .
|
$link = CMSPageEditController::singleton()->Link('show');
|
||||||
_t('SiteTree.TOPLEVEL', 'Site Content (Top Level)') .
|
$title = _t('SiteTree.TOPLEVEL', 'Site Content (Top Level)');
|
||||||
"</a>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
$parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"{$link}\">{$title}</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$lastParent = array_pop($parentPageLinks);
|
$lastParent = array_pop($parentPageLinks);
|
||||||
$parentList = "'$lastParent'";
|
$parentList = "'$lastParent'";
|
||||||
|
|
||||||
if(count($parentPageLinks) > 0) {
|
if(count($parentPageLinks)) {
|
||||||
$parentList = "'" . implode("', '", $parentPageLinks) . "' and "
|
$parentList = "'" . implode("', '", $parentPageLinks) . "' and "
|
||||||
. $parentList;
|
. $parentList;
|
||||||
}
|
}
|
||||||
@ -1858,7 +1909,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
// Create a table for showing pages linked to this one
|
// Create a table for showing pages linked to this one
|
||||||
$dependentPages = $this->DependentPages();
|
$dependentPages = $this->DependentPages();
|
||||||
$dependentPagesCount = $dependentPages->Count();
|
$dependentPagesCount = $dependentPages->count();
|
||||||
if($dependentPagesCount) {
|
if($dependentPagesCount) {
|
||||||
$dependentColumns = array(
|
$dependentColumns = array(
|
||||||
'Title' => $this->fieldLabel('Title'),
|
'Title' => $this->fieldLabel('Title'),
|
||||||
@ -1873,7 +1924,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
false,
|
false,
|
||||||
$dependentPages
|
$dependentPages
|
||||||
);
|
);
|
||||||
$dependentTable->getConfig()->getComponentByType('GridFieldDataColumns')
|
/** @var GridFieldDataColumns $dataColumns */
|
||||||
|
$dataColumns = $dependentTable
|
||||||
|
->getConfig()
|
||||||
|
->getComponentByType('GridFieldDataColumns');
|
||||||
|
$dataColumns
|
||||||
->setDisplayFields($dependentColumns)
|
->setDisplayFields($dependentColumns)
|
||||||
->setFieldFormatting(array(
|
->setFieldFormatting(array(
|
||||||
'Title' => function($value, &$item) {
|
'Title' => function($value, &$item) {
|
||||||
@ -1904,7 +1959,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
'CMSMain.NEWPAGE',
|
'CMSMain.NEWPAGE',
|
||||||
array('pagetype' => $this->i18n_singular_name())
|
array('pagetype' => $this->i18n_singular_name())
|
||||||
)));
|
)));
|
||||||
$helpText = (self::config()->nested_urls && count($this->Children())) ? $this->fieldLabel('LinkChangeNote') : '';
|
$helpText = (self::config()->nested_urls && $this->Children()->count())
|
||||||
|
? $this->fieldLabel('LinkChangeNote')
|
||||||
|
: '';
|
||||||
if(!Config::inst()->get('URLSegmentFilter', 'default_allow_multibyte')) {
|
if(!Config::inst()->get('URLSegmentFilter', 'default_allow_multibyte')) {
|
||||||
$helpText .= $helpText ? '<br />' : '';
|
$helpText .= $helpText ? '<br />' : '';
|
||||||
$helpText .= _t('SiteTreeURLSegmentField.HelpChars', ' Special characters are automatically converted or removed.');
|
$helpText .= _t('SiteTreeURLSegmentField.HelpChars', ' Special characters are automatically converted or removed.');
|
||||||
@ -2062,7 +2119,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// Make page location fields read-only if the user doesn't have the appropriate permission
|
// Make page location fields read-only if the user doesn't have the appropriate permission
|
||||||
if(!Permission::check("SITETREE_REORGANISE")) {
|
if(!Permission::check("SITETREE_REORGANISE")) {
|
||||||
$fields->makeFieldReadonly('ParentType');
|
$fields->makeFieldReadonly('ParentType');
|
||||||
if($this->ParentType == 'root') {
|
if($this->getParentType() === 'root') {
|
||||||
$fields->removeByName('ParentID');
|
$fields->removeByName('ParentID');
|
||||||
} else {
|
} else {
|
||||||
$fields->makeFieldReadonly('ParentID');
|
$fields->makeFieldReadonly('ParentID');
|
||||||
@ -2376,7 +2433,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$this->forceChange();
|
$this->forceChange();
|
||||||
$this->write();
|
$this->write();
|
||||||
|
|
||||||
$result = DataObject::get_by_id($this->class, $this->ID);
|
/** @var SiteTree $result */
|
||||||
|
$result = DataObject::get_by_id(__CLASS__, $this->ID);
|
||||||
|
|
||||||
// Need to update pages linking to this one as no longer broken
|
// Need to update pages linking to this one as no longer broken
|
||||||
foreach($result->DependentPages(false) as $page) {
|
foreach($result->DependentPages(false) as $page) {
|
||||||
@ -2418,7 +2476,6 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
protected function getClassDropdown() {
|
protected function getClassDropdown() {
|
||||||
$classes = self::page_type_classes();
|
$classes = self::page_type_classes();
|
||||||
$currentClass = null;
|
$currentClass = null;
|
||||||
$result = array();
|
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach($classes as $class) {
|
foreach($classes as $class) {
|
||||||
@ -2498,10 +2555,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$default = $this->stat('default_child');
|
$default = $this->stat('default_child');
|
||||||
$allowed = $this->allowedChildren();
|
$allowed = $this->allowedChildren();
|
||||||
if($allowed) {
|
if($allowed) {
|
||||||
if(!$default || !in_array($default, $allowed))
|
if(!$default || !in_array($default, $allowed)) {
|
||||||
$default = reset($allowed);
|
$default = reset($allowed);
|
||||||
|
}
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2638,7 +2697,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function Level($level) {
|
public function Level($level) {
|
||||||
$parent = $this;
|
$parent = $this;
|
||||||
$stack = array($parent);
|
$stack = array($parent);
|
||||||
while($parent = $parent->Parent) {
|
while(($parent = $parent->Parent()) && $parent->exists()) {
|
||||||
array_unshift($stack, $parent);
|
array_unshift($stack, $parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2813,7 +2872,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*/
|
*/
|
||||||
public function i18n_singular_name() {
|
public function i18n_singular_name() {
|
||||||
// Convert 'Page' to 'SiteTree' for correct localization lookups
|
// Convert 'Page' to 'SiteTree' for correct localization lookups
|
||||||
$class = ($this->class == 'Page') ? 'SilverStripe\\CMS\\Model\\SiteTree' : $this->class;
|
/** @skipUpgrade */
|
||||||
|
// @todo When we namespace translations, change 'SiteTree' to FQN of the class
|
||||||
|
$class = ($this->class == 'Page' || $this->class === __CLASS__)
|
||||||
|
? 'SiteTree'
|
||||||
|
: $this->class;
|
||||||
return _t($class.'.SINGULARNAME', $this->singular_name());
|
return _t($class.'.SINGULARNAME', $this->singular_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Model;
|
namespace SilverStripe\CMS\Model;
|
||||||
|
|
||||||
|
use File;
|
||||||
use SilverStripe\ORM\ManyManyList;
|
use SilverStripe\ORM\ManyManyList;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
@ -27,7 +28,7 @@ use Subsite;
|
|||||||
class SiteTreeFileExtension extends DataExtension {
|
class SiteTreeFileExtension extends DataExtension {
|
||||||
|
|
||||||
private static $belongs_many_many = array(
|
private static $belongs_many_many = array(
|
||||||
'BackLinkTracking' => 'SiteTree.ImageTracking' // {@see SiteTreeLinkTracking}
|
'BackLinkTracking' => 'SilverStripe\\CMS\\Model\\SiteTree.ImageTracking' // {@see SiteTreeLinkTracking}
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,14 +43,14 @@ class SiteTreeFileExtension extends DataExtension {
|
|||||||
|
|
||||||
public function updateCMSFields(FieldList $fields) {
|
public function updateCMSFields(FieldList $fields) {
|
||||||
$fields->insertAfter(
|
$fields->insertAfter(
|
||||||
|
'LastEdited',
|
||||||
ReadonlyField::create(
|
ReadonlyField::create(
|
||||||
'BackLinkCount',
|
'BackLinkCount',
|
||||||
_t('AssetTableField.BACKLINKCOUNT', 'Used on:'),
|
_t('AssetTableField.BACKLINKCOUNT', 'Used on:'),
|
||||||
$this->BackLinkTracking()->Count() . ' ' . _t('AssetTableField.PAGES', 'page(s)')
|
$this->BackLinkTracking()->count() . ' ' . _t('AssetTableField.PAGES', 'page(s)')
|
||||||
)
|
)
|
||||||
->addExtraClass('cms-description-toggle')
|
->addExtraClass('cms-description-toggle')
|
||||||
->setDescription($this->BackLinkHTMLList()),
|
->setDescription($this->BackLinkHTMLList())
|
||||||
'LastEdited'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,12 +105,12 @@ class SiteTreeFileExtension extends DataExtension {
|
|||||||
/**
|
/**
|
||||||
* @todo Unnecessary shortcut for AssetTableField, coupled with cms module.
|
* @todo Unnecessary shortcut for AssetTableField, coupled with cms module.
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function BackLinkTrackingCount() {
|
public function BackLinkTrackingCount() {
|
||||||
$pages = $this->owner->BackLinkTracking();
|
$pages = $this->owner->BackLinkTracking();
|
||||||
if($pages) {
|
if($pages) {
|
||||||
return $pages->Count();
|
return $pages->count();
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ namespace SilverStripe\CMS\Model;
|
|||||||
* @subpackage model
|
* @subpackage model
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use DOMElement;
|
||||||
use SilverStripe\ORM\ManyManyList;
|
use SilverStripe\ORM\ManyManyList;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||||
@ -83,7 +84,7 @@ class SiteTreeLinkTracking extends DataExtension {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $belongs_many_many = array(
|
private static $belongs_many_many = array(
|
||||||
"BackLinkTracking" => "SiteTree.LinkTracking"
|
"BackLinkTracking" => "SilverStripe\\CMS\\Model\\SiteTree.LinkTracking"
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,7 +123,9 @@ class SiteTreeLinkTracking extends DataExtension {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$classStr = trim($link['DOMReference']->getAttribute('class'));
|
/** @var DOMElement $domReference */
|
||||||
|
$domReference = $link['DOMReference'];
|
||||||
|
$classStr = trim($domReference->getAttribute('class'));
|
||||||
if (!$classStr) {
|
if (!$classStr) {
|
||||||
$classes = array();
|
$classes = array();
|
||||||
} else {
|
} else {
|
||||||
@ -137,9 +140,9 @@ class SiteTreeLinkTracking extends DataExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($classes)) {
|
if (!empty($classes)) {
|
||||||
$link['DOMReference']->setAttribute('class', implode(' ', $classes));
|
$domReference->setAttribute('class', implode(' ', $classes));
|
||||||
} else {
|
} else {
|
||||||
$link['DOMReference']->removeAttribute('class');
|
$domReference->removeAttribute('class');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$record->$fieldName = $htmlValue->getContent();
|
$record->$fieldName = $htmlValue->getContent();
|
||||||
@ -249,10 +252,14 @@ class SiteTreeLinkTracking_Parser {
|
|||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
$links = $htmlValue->getElementsByTagName('a');
|
$links = $htmlValue->getElementsByTagName('a');
|
||||||
if(!$links) return $results;
|
if(!$links) {
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
foreach($links as $link) {
|
foreach($links as $link) {
|
||||||
if (!$link->hasAttribute('href')) continue;
|
if (!$link->hasAttribute('href')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$href = Director::makeRelative($link->getAttribute('href'));
|
$href = Director::makeRelative($link->getAttribute('href'));
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Model;
|
namespace SilverStripe\CMS\Model;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use SilverStripe\CMS\Controllers\ContentController;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use Page;
|
use Page;
|
||||||
@ -77,6 +79,8 @@ class VirtualPage extends Page {
|
|||||||
"VersionID" => "Int",
|
"VersionID" => "Int",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private static $table_name = 'VirtualPage';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the array of fields required for the page type.
|
* Generates the array of fields required for the page type.
|
||||||
*
|
*
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Tasks;
|
||||||
|
|
||||||
|
|
||||||
use SilverStripe\ORM\DataList;
|
use SilverStripe\ORM\DataList;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use BuildTask;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rewrites plain internal HTML links into shortcode form, using existing link tracking information.
|
* Rewrites plain internal HTML links into shortcode form, using existing link tracking information.
|
||||||
|
@ -1,11 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Tasks;
|
||||||
|
|
||||||
|
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\Security\Permission;
|
use SilverStripe\Security\Permission;
|
||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use Controller;
|
||||||
|
use Requirements;
|
||||||
|
use FieldList;
|
||||||
|
use HeaderField;
|
||||||
|
use LiteralField;
|
||||||
|
use CheckboxSetField;
|
||||||
|
use OptionsetField;
|
||||||
|
use Form;
|
||||||
|
use FormAction;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -67,6 +81,11 @@ in the other stage:<br />
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function Link($action = null)
|
||||||
|
{
|
||||||
|
return Controller::join_links('RemoveOrphanedPagesTask', $action, '/');
|
||||||
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');
|
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');
|
||||||
Requirements::customCSS('#OrphanIDs .middleColumn {width: auto;}');
|
Requirements::customCSS('#OrphanIDs .middleColumn {width: auto;}');
|
||||||
@ -110,7 +129,7 @@ in the other stage:<br />
|
|||||||
$source[$orphan->ID] = $label;
|
$source[$orphan->ID] = $label;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($orphans && $orphans->Count()) {
|
if($orphans && $orphans->count()) {
|
||||||
$fields->push(new CheckboxSetField('OrphanIDs', false, $source));
|
$fields->push(new CheckboxSetField('OrphanIDs', false, $source));
|
||||||
$fields->push(new LiteralField(
|
$fields->push(new LiteralField(
|
||||||
'SelectAllLiteral',
|
'SelectAllLiteral',
|
||||||
@ -169,7 +188,7 @@ in the other stage:<br />
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(!$orphans || !$orphans->Count()) {
|
if(!$orphans || !$orphans->count()) {
|
||||||
$form->makeReadonly();
|
$form->makeReadonly();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,15 +332,19 @@ in the other stage:<br />
|
|||||||
*/
|
*/
|
||||||
public function getOrphanedPages($class = 'SilverStripe\\CMS\\Model\\SiteTree', $filter = array(), $sort = null, $join = null, $limit = null) {
|
public function getOrphanedPages($class = 'SilverStripe\\CMS\\Model\\SiteTree', $filter = array(), $sort = null, $join = null, $limit = null) {
|
||||||
// Alter condition
|
// Alter condition
|
||||||
if(empty($filter)) $where = array();
|
$table = DataObject::getSchema()->tableName($class);
|
||||||
elseif(is_array($filter)) $where = $filter;
|
if(empty($filter)) {
|
||||||
else $where = array($filter);
|
$where = array();
|
||||||
$where[] = array("\"$class\".\"ParentID\" != ?" => 0);
|
} elseif(is_array($filter)) {
|
||||||
|
$where = $filter;
|
||||||
|
} else {
|
||||||
|
$where = array($filter);
|
||||||
|
}
|
||||||
|
$where[] = array("\"{$table}\".\"ParentID\" != ?" => 0);
|
||||||
$where[] = '"Parents"."ID" IS NULL';
|
$where[] = '"Parents"."ID" IS NULL';
|
||||||
|
|
||||||
$orphans = new ArrayList();
|
$orphans = new ArrayList();
|
||||||
foreach(array(Versioned::DRAFT, Versioned::LIVE) as $stage) {
|
foreach(array(Versioned::DRAFT, Versioned::LIVE) as $stage) {
|
||||||
$table = DataObject::getSchema()->tableName($class);
|
|
||||||
$table .= ($stage == Versioned::LIVE) ? '_Live' : '';
|
$table .= ($stage == Versioned::LIVE) ? '_Live' : '';
|
||||||
$stageOrphans = Versioned::get_by_stage(
|
$stageOrphans = Versioned::get_by_stage(
|
||||||
$class,
|
$class,
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Tasks;
|
||||||
|
|
||||||
|
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use Controller;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -37,4 +42,9 @@ class SiteTreeMaintenanceTask extends Controller {
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function Link($action = null)
|
||||||
|
{
|
||||||
|
return Controller::join_links('SiteTreeMaintenanceTask', $action, '/');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ use SilverStripe\BehatExtension\Context\SilverStripeContext,
|
|||||||
SilverStripe\Framework\Test\Behaviour\CmsUiContext,
|
SilverStripe\Framework\Test\Behaviour\CmsUiContext,
|
||||||
SilverStripe\Cms\Test\Behaviour,
|
SilverStripe\Cms\Test\Behaviour,
|
||||||
SilverStripe\ORM\Versioning\Versioned;
|
SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,7 +43,7 @@ class FeatureContext extends \SilverStripe\Framework\Test\Behaviour\FeatureConte
|
|||||||
foreach(\ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\SiteTree') as $id => $class) {
|
foreach(\ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\SiteTree') as $id => $class) {
|
||||||
$blueprint = \Injector::inst()->create('FixtureBlueprint', $class);
|
$blueprint = \Injector::inst()->create('FixtureBlueprint', $class);
|
||||||
$blueprint->addCallback('afterCreate', function($obj, $identifier, &$data, &$fixtures) {
|
$blueprint->addCallback('afterCreate', function($obj, $identifier, &$data, &$fixtures) {
|
||||||
/** @var \SiteTree $obj */
|
/** @var SiteTree $obj */
|
||||||
$obj->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$obj->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
});
|
});
|
||||||
$factory->define($class, $blueprint);
|
$factory->define($class, $blueprint);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
SiteTree:
|
SilverStripe\CMS\Model\SiteTree:
|
||||||
published:
|
published:
|
||||||
Title: Published
|
Title: Published
|
||||||
archived:
|
archived:
|
||||||
@ -9,7 +9,7 @@ SiteTree:
|
|||||||
Title: modified1
|
Title: modified1
|
||||||
archivedx:
|
archivedx:
|
||||||
Title: 'Archived: Child1'
|
Title: 'Archived: Child1'
|
||||||
Parent: =>SiteTree.archived
|
Parent: =>SilverStripe\CMS\Model\SiteTree.archived
|
||||||
archivedy:
|
archivedy:
|
||||||
Title: 'Archived: Child2'
|
Title: 'Archived: Child2'
|
||||||
Parent: =>SiteTree.archived
|
Parent: =>SilverStripe\CMS\Model\SiteTree.archived
|
||||||
|
@ -83,7 +83,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
$pageB->write();
|
$pageB->write();
|
||||||
|
|
||||||
// Check query
|
// Check query
|
||||||
$response = $this->get('CMSMain/childfilter?ParentID=' . $pageA->ID);
|
$response = $this->get('admin/pages/childfilter?ParentID=' . $pageA->ID);
|
||||||
$children = json_decode($response->getBody());
|
$children = json_decode($response->getBody());
|
||||||
$this->assertFalse($response->isError());
|
$this->assertFalse($response->isError());
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
|
|
||||||
// Test live, but not on draft filter
|
// Test live, but not on draft filter
|
||||||
$params = array(
|
$params = array(
|
||||||
'FilterClass' => 'SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter_StatusRemovedFromDraftPages'
|
'FilterClass' => 'SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter_StatusRemovedFromDraftPages'
|
||||||
);
|
);
|
||||||
$pages = $controller->getList($params);
|
$pages = $controller->getList($params);
|
||||||
$this->assertEquals(1, $pages->count());
|
$this->assertEquals(1, $pages->count());
|
||||||
@ -494,7 +494,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
|
|
||||||
// Test live pages filter
|
// Test live pages filter
|
||||||
$params = array(
|
$params = array(
|
||||||
'FilterClass' => 'CMSSIteTreeFilter_PublishedPages'
|
'FilterClass' => 'SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter_PublishedPages'
|
||||||
);
|
);
|
||||||
$pages = $controller->getList($params);
|
$pages = $controller->getList($params);
|
||||||
$this->assertEquals(2, $pages->count());
|
$this->assertEquals(2, $pages->count());
|
||||||
|
@ -135,7 +135,7 @@ SiteConfig_CreateTopLevelGroups:
|
|||||||
createtoplevelgroups1:
|
createtoplevelgroups1:
|
||||||
SiteConfigID: =>SiteConfig.siteconfig1
|
SiteConfigID: =>SiteConfig.siteconfig1
|
||||||
GroupID: =>SilverStripe\Security\Group.rooteditusers
|
GroupID: =>SilverStripe\Security\Group.rooteditusers
|
||||||
RedirectorPage:
|
SilverStripe\CMS\Model\RedirectorPage:
|
||||||
page5:
|
page5:
|
||||||
Title: Page 5
|
Title: Page 5
|
||||||
RedirectionType: External
|
RedirectionType: External
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ErrorPage:
|
SilverStripe\CMS\Model\ErrorPage:
|
||||||
404:
|
404:
|
||||||
Title: Page Not Found
|
Title: Page Not Found
|
||||||
URLSegment: page-not-found
|
URLSegment: page-not-found
|
||||||
|
@ -3,7 +3,7 @@ Page:
|
|||||||
Title: Redirection Dest
|
Title: Redirection Dest
|
||||||
URLSegment: redirection-dest
|
URLSegment: redirection-dest
|
||||||
|
|
||||||
RedirectorPage:
|
SilverStripe\CMS\Model\RedirectorPage:
|
||||||
goodexternal:
|
goodexternal:
|
||||||
Title: Good External
|
Title: Good External
|
||||||
URLSegment: good-external
|
URLSegment: good-external
|
||||||
@ -30,10 +30,10 @@ RedirectorPage:
|
|||||||
reflexive:
|
reflexive:
|
||||||
Title: Reflexive
|
Title: Reflexive
|
||||||
RedirectionType: Internal
|
RedirectionType: Internal
|
||||||
LinkTo: =>RedirectorPage.reflexive
|
LinkTo: =>SilverStripe\CMS\Model\RedirectorPage.reflexive
|
||||||
URLSegment: reflexive
|
URLSegment: reflexive
|
||||||
transitive:
|
transitive:
|
||||||
Title: Transitive
|
Title: Transitive
|
||||||
RedirectionType: Internal
|
RedirectionType: Internal
|
||||||
LinkTo: =>RedirectorPage.goodinternal
|
LinkTo: =>SilverStripe\CMS\Model\RedirectorPage.goodinternal
|
||||||
URLSegment: transitive
|
URLSegment: transitive
|
||||||
|
@ -10,7 +10,7 @@ class SiteTreeBacklinksTest extends SapphireTest {
|
|||||||
protected static $fixture_file = "SiteTreeBacklinksTest.yml";
|
protected static $fixture_file = "SiteTreeBacklinksTest.yml";
|
||||||
|
|
||||||
protected $requiredExtensions = array(
|
protected $requiredExtensions = array(
|
||||||
'SiteTree' => array('SiteTreeBacklinksTest_DOD'),
|
'SilverStripe\\CMS\\Model\\SiteTree' => array('SiteTreeBacklinksTest_DOD'),
|
||||||
);
|
);
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
@ -15,7 +15,7 @@ Page:
|
|||||||
Title: RedirectorPageToBrokenInteralPage
|
Title: RedirectorPageToBrokenInteralPage
|
||||||
LinkTo: =>Page.content
|
LinkTo: =>Page.content
|
||||||
|
|
||||||
ErrorPage:
|
SilverStripe\CMS\Model\ErrorPage:
|
||||||
404:
|
404:
|
||||||
Title: Page not Found
|
Title: Page not Found
|
||||||
ErrorCode: 404
|
ErrorCode: 404
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
SiteTree:
|
SilverStripe\CMS\Model\SiteTree:
|
||||||
home:
|
home:
|
||||||
Title: Home Page
|
Title: Home Page
|
||||||
about:
|
about:
|
||||||
|
@ -16,7 +16,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
protected static $fixture_file = "SiteTreePermissionsTest.yml";
|
protected static $fixture_file = "SiteTreePermissionsTest.yml";
|
||||||
|
|
||||||
protected $illegalExtensions = array(
|
protected $illegalExtensions = array(
|
||||||
'SiteTree' => array('SiteTreeSubsites')
|
'SilverStripe\\CMS\\Model\\SiteTree' => array('SiteTreeSubsites')
|
||||||
);
|
);
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
@ -22,7 +22,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
protected static $fixture_file = 'SiteTreeTest.yml';
|
protected static $fixture_file = 'SiteTreeTest.yml';
|
||||||
|
|
||||||
protected $illegalExtensions = array(
|
protected $illegalExtensions = array(
|
||||||
'SiteTree' => array('SiteTreeSubsites', 'Translatable')
|
'SilverStripe\\CMS\\Model\\SiteTree' => array('SiteTreeSubsites', 'Translatable')
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $extraDataObjects = array(
|
protected $extraDataObjects = array(
|
||||||
@ -724,19 +724,19 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
array('pagetype' => $sitetree->i18n_singular_name())
|
array('pagetype' => $sitetree->i18n_singular_name())
|
||||||
);
|
);
|
||||||
$sitetree->write();
|
$sitetree->write();
|
||||||
$this->assertEquals($sitetree->URLSegment, 'new-page',
|
$this->assertEquals('new-page', $sitetree->URLSegment,
|
||||||
'Sets based on default title on first save'
|
'Sets based on default title on first save'
|
||||||
);
|
);
|
||||||
|
|
||||||
$sitetree->Title = 'Changed';
|
$sitetree->Title = 'Changed';
|
||||||
$sitetree->write();
|
$sitetree->write();
|
||||||
$this->assertEquals($sitetree->URLSegment, 'changed',
|
$this->assertEquals('changed', $sitetree->URLSegment,
|
||||||
'Auto-updates when set to default title'
|
'Auto-updates when set to default title'
|
||||||
);
|
);
|
||||||
|
|
||||||
$sitetree->Title = 'Changed again';
|
$sitetree->Title = 'Changed again';
|
||||||
$sitetree->write();
|
$sitetree->write();
|
||||||
$this->assertEquals($sitetree->URLSegment, 'changed',
|
$this->assertEquals('changed', $sitetree->URLSegment,
|
||||||
'Does not auto-update once title has been changed'
|
'Does not auto-update once title has been changed'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -757,13 +757,13 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
|
|
||||||
$sitetree->Title = 'Changed';
|
$sitetree->Title = 'Changed';
|
||||||
$sitetree->write();
|
$sitetree->write();
|
||||||
$this->assertEquals($sitetree->URLSegment, 'changed',
|
$this->assertEquals('changed', $sitetree->URLSegment,
|
||||||
'Auto-updates when set to default title'
|
'Auto-updates when set to default title'
|
||||||
);
|
);
|
||||||
|
|
||||||
$sitetree->Title = 'Changed again';
|
$sitetree->Title = 'Changed again';
|
||||||
$sitetree->write();
|
$sitetree->write();
|
||||||
$this->assertEquals($sitetree->URLSegment, 'changed',
|
$this->assertEquals('changed', $sitetree->URLSegment,
|
||||||
'Does not auto-update once title has been changed'
|
'Does not auto-update once title has been changed'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1108,7 +1108,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testGetBreadcrumbItems() {
|
public function testGetBreadcrumbItems() {
|
||||||
$page = $this->objFromFixture("Page", "breadcrumbs");
|
$page = $this->objFromFixture("Page", "breadcrumbs");
|
||||||
$this->assertEquals($page->getBreadcrumbItems()->count(), 1, "Only display current page.");
|
$this->assertEquals(1, $page->getBreadcrumbItems()->count(), "Only display current page.");
|
||||||
|
|
||||||
// Test breadcrumb order
|
// Test breadcrumb order
|
||||||
$page = $this->objFromFixture("Page", "breadcrumbs5");
|
$page = $this->objFromFixture("Page", "breadcrumbs5");
|
||||||
|
@ -117,12 +117,12 @@ SiteTreeTest_Conflicted:
|
|||||||
parent:
|
parent:
|
||||||
Title: Parent
|
Title: Parent
|
||||||
|
|
||||||
ErrorPage:
|
SilverStripe\CMS\Model\ErrorPage:
|
||||||
404:
|
404:
|
||||||
Title: Page not Found
|
Title: Page not Found
|
||||||
ErrorCode: 404
|
ErrorCode: 404
|
||||||
|
|
||||||
RedirectorPage:
|
SilverStripe\CMS\Model\RedirectorPage:
|
||||||
external:
|
external:
|
||||||
Title: External
|
Title: External
|
||||||
URLSegment: external
|
URLSegment: external
|
||||||
|
@ -10,6 +10,8 @@ use SilverStripe\ORM\DataExtension;
|
|||||||
use SilverStripe\CMS\Model\VirtualPage;
|
use SilverStripe\CMS\Model\VirtualPage;
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use SilverStripe\CMS\Model\RedirectorPage;
|
use SilverStripe\CMS\Model\RedirectorPage;
|
||||||
|
use SilverStripe\CMS\Controllers\ModelAsController;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -30,11 +32,11 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
protected $illegalExtensions = array(
|
protected $illegalExtensions = array(
|
||||||
'SiteTree' => array('SiteTreeSubsites', 'Translatable')
|
'SilverStripe\\CMS\\Model\\SiteTree' => array('SiteTreeSubsites', 'Translatable')
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $requiredExtensions = array(
|
protected $requiredExtensions = array(
|
||||||
'SiteTree' => array('VirtualPageTest_PageExtension')
|
'SilverStripe\\CMS\\Model\\SiteTree' => array('VirtualPageTest_PageExtension')
|
||||||
);
|
);
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
@ -607,10 +609,10 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testMethod() {
|
public function testMethod() {
|
||||||
$virtualPage = $this->objFromFixture('VirtualPage', 'vp4');
|
$virtualPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp4');
|
||||||
$controller = ModelAsController::controller_for($virtualPage);
|
$controller = ModelAsController::controller_for($virtualPage);
|
||||||
|
|
||||||
$this->assertInstanceOf('VirtualPage_Controller', $controller);
|
$this->assertInstanceOf('SilverStripe\\CMS\\Model\\VirtualPage_Controller', $controller);
|
||||||
$this->assertTrue($controller->hasMethod('testMethod'));
|
$this->assertTrue($controller->hasMethod('testMethod'));
|
||||||
$this->assertEquals('hello', $controller->testMethod());
|
$this->assertEquals('hello', $controller->testMethod());
|
||||||
$this->assertTrue($controller->hasMethod('modelMethod'));
|
$this->assertTrue($controller->hasMethod('modelMethod'));
|
||||||
|
@ -49,7 +49,7 @@ VirtualPageTest_ClassA:
|
|||||||
pagea:
|
pagea:
|
||||||
Title: 'Page A'
|
Title: 'Page A'
|
||||||
Content: '<p>Content</p>'
|
Content: '<p>Content</p>'
|
||||||
VirtualPage:
|
SilverStripe\CMS\Model\VirtualPage:
|
||||||
vp1:
|
vp1:
|
||||||
Title: vp1
|
Title: vp1
|
||||||
CopyContentFrom: =>Page.master
|
CopyContentFrom: =>Page.master
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
SiteTree:
|
SilverStripe\CMS\Model\SiteTree:
|
||||||
after:
|
after:
|
||||||
Title: after
|
Title: after
|
||||||
before:
|
before:
|
||||||
Title: before
|
Title: before
|
||||||
|
@ -23,7 +23,7 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
protected static $fixture_file = 'SearchFormTest.yml';
|
protected static $fixture_file = 'SearchFormTest.yml';
|
||||||
|
|
||||||
protected $illegalExtensions = array(
|
protected $illegalExtensions = array(
|
||||||
'SiteTree' => array('SiteTreeSubsites', 'Translatable')
|
'SilverStripe\\CMS\\Model\\SiteTree' => array('SiteTreeSubsites', 'Translatable')
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $mockController;
|
protected $mockController;
|
||||||
|
@ -9,7 +9,7 @@ SilverStripe\Security\Member:
|
|||||||
Email: websiteuser@test.com
|
Email: websiteuser@test.com
|
||||||
Password: test
|
Password: test
|
||||||
Groups: =>SilverStripe\Security\Group.websiteusers
|
Groups: =>SilverStripe\Security\Group.websiteusers
|
||||||
SiteTree:
|
SilverStripe\CMS\Model\SiteTree:
|
||||||
searchformholder:
|
searchformholder:
|
||||||
URLSegment: searchformholder
|
URLSegment: searchformholder
|
||||||
Title: searchformholder
|
Title: searchformholder
|
||||||
@ -26,7 +26,7 @@ SiteTree:
|
|||||||
Title: restrictedViewOnlyWebsiteUsers
|
Title: restrictedViewOnlyWebsiteUsers
|
||||||
inheritRestrictedView:
|
inheritRestrictedView:
|
||||||
CanViewType: Inherit
|
CanViewType: Inherit
|
||||||
Parent: =>SiteTree.restrictedViewLoggedInUsers
|
Parent: =>SilverStripe\CMS\Model\SiteTree.restrictedViewLoggedInUsers
|
||||||
Title: inheritRestrictedView
|
Title: inheritRestrictedView
|
||||||
dontShowInSearchPage:
|
dontShowInSearchPage:
|
||||||
Title: dontShowInSearchPage
|
Title: dontShowInSearchPage
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\CMS\Tasks\MigrateSiteTreeLinkingTask;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
SiteTree:
|
SilverStripe\CMS\Model\SiteTree:
|
||||||
home:
|
home:
|
||||||
Title: Home Page
|
Title: Home Page
|
||||||
URLSegment: home
|
URLSegment: home
|
||||||
@ -11,7 +11,7 @@ SiteTree:
|
|||||||
Title: Staff
|
Title: Staff
|
||||||
URLSegment: staff
|
URLSegment: staff
|
||||||
Content: '<a href="home/">Home</a><a href="about">About</a>'
|
Content: '<a href="home/">Home</a><a href="about">About</a>'
|
||||||
Parent: =>SiteTree.about
|
Parent: =>SilverStripe\CMS\Model\SiteTree.about
|
||||||
action:
|
action:
|
||||||
Title: Action Link
|
Title: Action Link
|
||||||
URLSegment: action
|
URLSegment: action
|
||||||
@ -30,38 +30,38 @@ SiteTree:
|
|||||||
|
|
||||||
SiteTree_LinkTracking:
|
SiteTree_LinkTracking:
|
||||||
home_about:
|
home_about:
|
||||||
SiteTreeID: =>SiteTree.home
|
SiteTreeID: =>SilverStripe\CMS\Model\SiteTree.home
|
||||||
ChildID: =>SiteTree.about
|
ChildID: =>SilverStripe\CMS\Model\SiteTree.about
|
||||||
FieldName: Content
|
FieldName: Content
|
||||||
home_staff:
|
home_staff:
|
||||||
SiteTreeID: =>SiteTree.home
|
SiteTreeID: =>SilverStripe\CMS\Model\SiteTree.home
|
||||||
ChildID: =>SiteTree.staff
|
ChildID: =>SilverStripe\CMS\Model\SiteTree.staff
|
||||||
FieldName: Content
|
FieldName: Content
|
||||||
about_home:
|
about_home:
|
||||||
SiteTreeID: =>SiteTree.about
|
SiteTreeID: =>SilverStripe\CMS\Model\SiteTree.about
|
||||||
ChildID: =>SiteTree.home
|
ChildID: =>SilverStripe\CMS\Model\SiteTree.home
|
||||||
FieldName: Content
|
FieldName: Content
|
||||||
about_staff:
|
about_staff:
|
||||||
SiteTreeID: =>SiteTree.about
|
SiteTreeID: =>SilverStripe\CMS\Model\SiteTree.about
|
||||||
ChildID: =>SiteTree.staff
|
ChildID: =>SilverStripe\CMS\Model\SiteTree.staff
|
||||||
FieldName: Content
|
FieldName: Content
|
||||||
staff_home:
|
staff_home:
|
||||||
SiteTreeID: =>SiteTree.staff
|
SiteTreeID: =>SilverStripe\CMS\Model\SiteTree.staff
|
||||||
ChildID: =>SiteTree.home
|
ChildID: =>SilverStripe\CMS\Model\SiteTree.home
|
||||||
FieldName: Content
|
FieldName: Content
|
||||||
staff_about:
|
staff_about:
|
||||||
SiteTreeID: =>SiteTree.staff
|
SiteTreeID: =>SilverStripe\CMS\Model\SiteTree.staff
|
||||||
ChildID: =>SiteTree.about
|
ChildID: =>SilverStripe\CMS\Model\SiteTree.about
|
||||||
FieldName: Content
|
FieldName: Content
|
||||||
action_home:
|
action_home:
|
||||||
SiteTreeID: =>SiteTree.action
|
SiteTreeID: =>SilverStripe\CMS\Model\SiteTree.action
|
||||||
ChildID: =>SiteTree.home
|
ChildID: =>SilverStripe\CMS\Model\SiteTree.home
|
||||||
FieldName: Content
|
FieldName: Content
|
||||||
hash_link_home:
|
hash_link_home:
|
||||||
SiteTreeID: =>SiteTree.hash_link
|
SiteTreeID: =>SilverStripe\CMS\Model\SiteTree.hash_link
|
||||||
ChildID: =>SiteTree.home
|
ChildID: =>SilverStripe\CMS\Model\SiteTree.home
|
||||||
FieldName: Content
|
FieldName: Content
|
||||||
hash_link_about:
|
hash_link_about:
|
||||||
SiteTreeID: =>SiteTree.hash_link
|
SiteTreeID: =>SilverStripe\CMS\Model\SiteTree.hash_link
|
||||||
ChildID: =>SiteTree.about
|
ChildID: =>SilverStripe\CMS\Model\SiteTree.about
|
||||||
FieldName: Content
|
FieldName: Content
|
||||||
|
@ -88,7 +88,7 @@ class RemoveOrphanedPagesTaskTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
$child2_1_published_orphaned = $this->objFromFixture('Page', 'child2_1_published_orphaned');
|
$child2_1_published_orphaned = $this->objFromFixture('Page', 'child2_1_published_orphaned');
|
||||||
|
|
||||||
$task = singleton('RemoveOrphanedPagesTask');
|
$task = singleton('SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask');
|
||||||
$orphans = $task->getOrphanedPages();
|
$orphans = $task->getOrphanedPages();
|
||||||
$orphanIDs = $orphans->column('ID');
|
$orphanIDs = $orphans->column('ID');
|
||||||
sort($orphanIDs);
|
sort($orphanIDs);
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
Page:
|
Page:
|
||||||
parent1_published:
|
parent1_published:
|
||||||
Title: Parent1
|
Title: Parent1
|
||||||
child1_1_published:
|
child1_1_published:
|
||||||
Title: Child1.1
|
Title: Child1.1
|
||||||
Parent: =>Page.parent1_published
|
Parent: =>Page.parent1_published
|
||||||
child1_2_published:
|
child1_2_published:
|
||||||
Title: Child1.2
|
Title: Child1.2
|
||||||
Parent: =>Page.parent1_published
|
Parent: =>Page.parent1_published
|
||||||
child1_3_orphaned:
|
child1_3_orphaned:
|
||||||
Title: Child1.3
|
Title: Child1.3
|
||||||
Parent: =>Page.parent1_published
|
Parent: =>Page.parent1_published
|
||||||
child1_4_orphaned_published:
|
child1_4_orphaned_published:
|
||||||
Title: Child1.4
|
Title: Child1.4
|
||||||
Parent: =>Page.parent1_published
|
Parent: =>Page.parent1_published
|
||||||
grandchild1_1_1:
|
grandchild1_1_1:
|
||||||
Title: Grandchild1.1.1
|
Title: Grandchild1.1.1
|
||||||
Parent: =>Page.child1_1_published
|
Parent: =>Page.child1_1_published
|
||||||
grandchild1_1_2_published:
|
grandchild1_1_2_published:
|
||||||
Title: Grandchild1.1.2
|
Title: Grandchild1.1.2
|
||||||
Parent: =>Page.child1_1_published
|
Parent: =>Page.child1_1_published
|
||||||
grandchild1_1_3_orphaned:
|
grandchild1_1_3_orphaned:
|
||||||
Title: Grandchild1.1.3
|
Title: Grandchild1.1.3
|
||||||
Parent: =>Page.child1_1_published
|
Parent: =>Page.child1_1_published
|
||||||
grandchild1_1_4_orphaned_published:
|
grandchild1_1_4_orphaned_published:
|
||||||
Title: Grandchild1.1.4
|
Title: Grandchild1.1.4
|
||||||
Parent: =>Page.child1_1_published
|
Parent: =>Page.child1_1_published
|
||||||
parent2:
|
parent2:
|
||||||
Title: Parent2
|
Title: Parent2
|
||||||
child2_1_published_orphaned:
|
child2_1_published_orphaned:
|
||||||
Title: Child2.1
|
Title: Child2.1
|
||||||
Parent: =>Page.parent2
|
Parent: =>Page.parent2
|
||||||
|
Loading…
Reference in New Issue
Block a user