mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1574 from open-sausages/pulls/4.0/namespace-cms
API namespace CMS
This commit is contained in:
commit
29fc7ade96
67
.upgrade.yml
Normal file
67
.upgrade.yml
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
mappings:
|
||||||
|
CMSBatchAction_Publish: SilverStripe\CMS\BatchActions\CMSBatchAction_Publish
|
||||||
|
CMSBatchAction_Unpublish: SilverStripe\CMS\BatchActions\CMSBatchAction_Unpublish
|
||||||
|
CMSBatchAction_Archive: SilverStripe\CMS\BatchActions\CMSBatchAction_Archive
|
||||||
|
CMSBatchAction_Restore: SilverStripe\CMS\BatchActions\CMSBatchAction_Restore
|
||||||
|
CMSBatchAction_Delete: SilverStripe\CMS\BatchActions\CMSBatchAction_Delete
|
||||||
|
AssetAdmin: SilverStripe\CMS\Controllers\AssetAdmin
|
||||||
|
AssetAdmin_DeleteBatchAction: SilverStripe\CMS\Controllers\AssetAdmin_DeleteBatchAction
|
||||||
|
CMSMain: SilverStripe\CMS\Controllers\CMSMain
|
||||||
|
CMSPageAddController: SilverStripe\CMS\Controllers\CMSPageAddController
|
||||||
|
CMSPageEditController: SilverStripe\CMS\Controllers\CMSPageEditController
|
||||||
|
CMSPageHistoryController: SilverStripe\CMS\Controllers\CMSPageHistoryController
|
||||||
|
CMSPagesController: SilverStripe\CMS\Controllers\CMSPagesController
|
||||||
|
CMSPageSettingsController: SilverStripe\CMS\Controllers\CMSPageSettingsController
|
||||||
|
CMSSiteTreeFilter: SilverStripe\CMS\Controllers\CMSSiteTreeFilter
|
||||||
|
CMSSiteTreeFilter_PublishedPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_PublishedPages
|
||||||
|
CMSSiteTreeFilter_DeletedPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_DeletedPages
|
||||||
|
CMSSiteTreeFilter_ChangedPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_ChangedPages
|
||||||
|
CMSSiteTreeFilter_StatusRemovedFromDraftPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_StatusRemovedFromDraftPages
|
||||||
|
CMSSiteTreeFilter_StatusDraftPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_StatusDraftPages
|
||||||
|
CMSSiteTreeFilter_StatusDeletedPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_StatusDeletedPages
|
||||||
|
CMSSiteTreeFilter_Search: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_Search
|
||||||
|
ContentController: SilverStripe\CMS\Controllers\ContentController
|
||||||
|
ErrorPageControllerExtension: SilverStripe\CMS\Controllers\ErrorPageControllerExtension
|
||||||
|
ErrorPageFileExtension: SilverStripe\CMS\Controllers\ErrorPageFileExtension
|
||||||
|
LeftAndMainPageIconsExtension: SilverStripe\CMS\Controllers\LeftAndMainPageIconsExtension
|
||||||
|
ModelAsController: SilverStripe\CMS\Controllers\ModelAsController
|
||||||
|
OldPageRedirector: SilverStripe\CMS\Controllers\OldPageRedirector
|
||||||
|
RootURLController: SilverStripe\CMS\Controllers\RootURLController
|
||||||
|
SilverStripeNavigator: SilverStripe\CMS\Controllers\SilverStripeNavigator
|
||||||
|
SilverStripeNavigatorItem: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem
|
||||||
|
SilverStripeNavigatorItem_CMSLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_CMSLink
|
||||||
|
SilverStripeNavigatorItem_StageLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_StageLink
|
||||||
|
SilverStripeNavigatorItem_LiveLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_LiveLink
|
||||||
|
SilverStripeNavigatorItem_ArchiveLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_ArchiveLink
|
||||||
|
SiteTreeURLSegmentField: SilverStripe\CMS\Forms\SiteTreeURLSegmentField
|
||||||
|
SiteTreeURLSegmentField_Readonly: SilverStripe\CMS\Forms\SiteTreeURLSegmentField_Readonly
|
||||||
|
CurrentPageIdentifier: SilverStripe\CMS\Model\CurrentPageIdentifier
|
||||||
|
ErrorPage: SilverStripe\CMS\Model\ErrorPage
|
||||||
|
ErrorPage_Controller: SilverStripe\CMS\Model\ErrorPage_Controller
|
||||||
|
RedirectorPage: SilverStripe\CMS\Model\RedirectorPage
|
||||||
|
RedirectorPage_Controller: SilverStripe\CMS\Model\RedirectorPage_Controller
|
||||||
|
SiteTree: SilverStripe\CMS\Model\SiteTree
|
||||||
|
SiteTreeExtension: SilverStripe\CMS\Model\SiteTreeExtension
|
||||||
|
SiteTreeFileExtension: SilverStripe\CMS\Model\SiteTreeFileExtension
|
||||||
|
SiteTreeFolderExtension: SilverStripe\CMS\Model\SiteTreeFolderExtension
|
||||||
|
SiteTreeLinkTracking: SilverStripe\CMS\Model\SiteTreeLinkTracking
|
||||||
|
SiteTreeLinkTracking_Parser: SilverStripe\CMS\Model\SiteTreeLinkTracking_Parser
|
||||||
|
VirtualPage: SilverStripe\CMS\Model\VirtualPage
|
||||||
|
VirtualPage_Controller: SilverStripe\CMS\Model\VirtualPage_Controller
|
||||||
|
BrokenFilesReport: SilverStripe\CMS\Reports\BrokenFilesReport
|
||||||
|
SideReport_BrokenFiles: SilverStripe\CMS\Reports\SideReport_BrokenFiles
|
||||||
|
BrokenLinksReport: SilverStripe\CMS\Reports\BrokenLinksReport
|
||||||
|
SideReport_BrokenLinks: SilverStripe\CMS\Reports\SideReport_BrokenLinks
|
||||||
|
BrokenRedirectorPagesReport: SilverStripe\CMS\Reports\BrokenRedirectorPagesReport
|
||||||
|
SideReport_BrokenRedirectorPages: SilverStripe\CMS\Reports\SideReport_BrokenRedirectorPages
|
||||||
|
BrokenVirtualPagesReport: SilverStripe\CMS\Reports\BrokenVirtualPagesReport
|
||||||
|
SideReport_BrokenVirtualPages: SilverStripe\CMS\Reports\SideReport_BrokenVirtualPages
|
||||||
|
EmptyPagesReport: SilverStripe\CMS\Reports\EmptyPagesReport
|
||||||
|
SideReport_EmptyPages: SilverStripe\CMS\Reports\SideReport_EmptyPages
|
||||||
|
RecentlyEditedReport: SilverStripe\CMS\Reports\RecentlyEditedReport
|
||||||
|
SideReport_RecentlyEdited: SilverStripe\CMS\Reports\SideReport_RecentlyEdited
|
||||||
|
ContentControllerSearchExtension: SilverStripe\CMS\Search\ContentControllerSearchExtension
|
||||||
|
SearchForm: SilverStripe\CMS\Search\SearchForm
|
||||||
|
MigrateSiteTreeLinkingTask: SilverStripe\CMS\Tasks\MigrateSiteTreeLinkingTask
|
||||||
|
RemoveOrphanedPagesTask: SilverStripe\CMS\Tasks\RemoveOrphanedPagesTask
|
||||||
|
SiteTreeMaintenanceTask: SilverStripe\CMS\Tasks\SiteTreeMaintenanceTask
|
18
_config.php
18
_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('SiteTree', 'link_shortcode_handler'));
|
ShortcodeParser::get('default')->register(
|
||||||
|
'sitetree_link',
|
||||||
|
array('SilverStripe\\CMS\\Model\\SiteTree', 'link_shortcode_handler')
|
||||||
|
);
|
||||||
|
|
||||||
File::add_extension('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('CMSMain');
|
CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSMain');
|
||||||
CMSMenu::remove_menu_item('CMSPageEditController');
|
CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageEditController');
|
||||||
CMSMenu::remove_menu_item('CMSPageSettingsController');
|
CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageSettingsController');
|
||||||
CMSMenu::remove_menu_item('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('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'
|
||||||
|
@ -6,4 +6,4 @@ Except:
|
|||||||
---
|
---
|
||||||
Injector:
|
Injector:
|
||||||
FriendlyErrorFormatter:
|
FriendlyErrorFormatter:
|
||||||
class: SilverStripe\Cms\Logging\ErrorPageErrorFormatter
|
class: SilverStripe\CMS\Logging\ErrorPageErrorFormatter
|
||||||
|
@ -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'
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\BatchActions;
|
||||||
|
|
||||||
|
|
||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\ORM\SS_List;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\Security\Permission;
|
use SilverStripe\Security\Permission;
|
||||||
|
use CMSBatchAction;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish items batch action.
|
* Publish items batch action.
|
||||||
@ -147,7 +152,7 @@ class CMSBatchAction_Delete extends CMSBatchAction {
|
|||||||
|
|
||||||
// check to see if the record exists on the live site,
|
// check to see if the record exists on the live site,
|
||||||
// if it doesn't remove the tree node
|
// if it doesn't remove the tree node
|
||||||
$liveRecord = Versioned::get_one_by_stage( 'SiteTree', 'Live', array(
|
$liveRecord = Versioned::get_one_by_stage( 'SilverStripe\\CMS\\Model\\SiteTree', 'Live', array(
|
||||||
'"SiteTree"."ID"' => $id
|
'"SiteTree"."ID"' => $id
|
||||||
));
|
));
|
||||||
if($liveRecord) {
|
if($liveRecord) {
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
use SilverStripe\Filesystem\Storage\AssetNameGenerator;
|
use SilverStripe\Filesystem\Storage\AssetNameGenerator;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
@ -7,6 +9,49 @@ use SilverStripe\ORM\DataObject;
|
|||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\ORM\SS_List;
|
||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
use SilverStripe\Security\PermissionProvider;
|
use SilverStripe\Security\PermissionProvider;
|
||||||
|
use LeftAndMain;
|
||||||
|
use Session;
|
||||||
|
use Requirements;
|
||||||
|
use CMSBatchActionHandler;
|
||||||
|
use File;
|
||||||
|
use DateField;
|
||||||
|
use HiddenField;
|
||||||
|
use GridFieldConfig;
|
||||||
|
use GridFieldToolbarHeader;
|
||||||
|
use GridFieldSortableHeader;
|
||||||
|
use GridFieldFilterHeader;
|
||||||
|
use GridFieldDataColumns;
|
||||||
|
use GridFieldPaginator;
|
||||||
|
use GridFieldEditButton;
|
||||||
|
use GridFieldDeleteAction;
|
||||||
|
use GridFieldDetailForm;
|
||||||
|
use GridFieldLevelup;
|
||||||
|
use GridField;
|
||||||
|
use Controller;
|
||||||
|
use LiteralField;
|
||||||
|
use TabSet;
|
||||||
|
use Tab;
|
||||||
|
use CompositeField;
|
||||||
|
use UploadField;
|
||||||
|
use FormField;
|
||||||
|
use SS_HTTPResponse;
|
||||||
|
use Convert;
|
||||||
|
use SS_HTTPResponse_Exception;
|
||||||
|
use HeaderField;
|
||||||
|
use FieldGroup;
|
||||||
|
use DropdownField;
|
||||||
|
use CheckboxField;
|
||||||
|
use FieldList;
|
||||||
|
use FormAction;
|
||||||
|
use Object;
|
||||||
|
use Form;
|
||||||
|
use TextField;
|
||||||
|
use Folder;
|
||||||
|
use Injector;
|
||||||
|
use Director;
|
||||||
|
use ArrayData;
|
||||||
|
use CMSBatchAction;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +120,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
|||||||
Requirements::javascript(CMS_DIR . "/client/dist/js/AssetAdmin.js");
|
Requirements::javascript(CMS_DIR . "/client/dist/js/AssetAdmin.js");
|
||||||
Requirements::add_i18n_javascript(CMS_DIR . '/client/lang', false, true);
|
Requirements::add_i18n_javascript(CMS_DIR . '/client/lang', false, true);
|
||||||
Requirements::css(CMS_DIR . '/client/dist/styles/bundle.css');
|
Requirements::css(CMS_DIR . '/client/dist/styles/bundle.css');
|
||||||
CMSBatchActionHandler::register('delete', 'AssetAdmin_DeleteBatchAction', 'Folder');
|
CMSBatchActionHandler::register('delete', 'SilverStripe\\CMS\\Controllers\\AssetAdmin_DeleteBatchAction', 'Folder');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -154,6 +199,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
|||||||
|
|
||||||
// Remove legacy previewable behaviour.
|
// Remove legacy previewable behaviour.
|
||||||
$form->removeExtraClass('cms-previewable');
|
$form->removeExtraClass('cms-previewable');
|
||||||
|
/** @skipUpgrade */
|
||||||
$form->Fields()->removeByName('SilverStripeNavigator');
|
$form->Fields()->removeByName('SilverStripeNavigator');
|
||||||
|
|
||||||
// File listing
|
// File listing
|
||||||
@ -588,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('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')) {
|
@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
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;
|
||||||
@ -12,6 +16,53 @@ use SilverStripe\Security\Security;
|
|||||||
use SilverStripe\Security\SecurityToken;
|
use SilverStripe\Security\SecurityToken;
|
||||||
use SilverStripe\Security\Permission;
|
use SilverStripe\Security\Permission;
|
||||||
use SilverStripe\Security\PermissionProvider;
|
use SilverStripe\Security\PermissionProvider;
|
||||||
|
use LeftAndMain;
|
||||||
|
|
||||||
|
|
||||||
|
use SS_HTTPRequest;
|
||||||
|
use Translatable;
|
||||||
|
use Requirements;
|
||||||
|
use CMSBatchActionHandler;
|
||||||
|
use Controller;
|
||||||
|
use AdminRootController;
|
||||||
|
use Director;
|
||||||
|
use Page;
|
||||||
|
|
||||||
|
use TextField;
|
||||||
|
use HeaderField;
|
||||||
|
use DateField;
|
||||||
|
use DropdownField;
|
||||||
|
use FieldGroup;
|
||||||
|
use FieldList;
|
||||||
|
use FormAction;
|
||||||
|
use Object;
|
||||||
|
use Form;
|
||||||
|
use SS_Cache;
|
||||||
|
use Zend_Cache;
|
||||||
|
use Convert;
|
||||||
|
use ArrayData;
|
||||||
|
use HiddenField;
|
||||||
|
use CMSPreviewable;
|
||||||
|
use LiteralField;
|
||||||
|
use RequiredFields;
|
||||||
|
use LabelField;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use GridFieldConfig;
|
||||||
|
use GridFieldSortableHeader;
|
||||||
|
use GridFieldDataColumns;
|
||||||
|
use GridFieldPaginator;
|
||||||
|
use GridFieldLevelup;
|
||||||
|
use GridField;
|
||||||
|
use SS_HTTPResponse_Exception;
|
||||||
|
use Session;
|
||||||
|
use AddToCampaignHandler;
|
||||||
|
use HTMLEditorField;
|
||||||
|
use SS_HTTPResponse;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SilverStripe\CMS\Model\RedirectorPage;
|
||||||
|
use SilverStripe\CMS\Model\CurrentPageIdentifier;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -39,10 +90,12 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
private static $menu_priority = 10;
|
private static $menu_priority = 10;
|
||||||
|
|
||||||
private static $tree_class = "SiteTree";
|
private static $tree_class = "SilverStripe\\CMS\\Model\\SiteTree";
|
||||||
|
|
||||||
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.
|
||||||
*
|
*
|
||||||
@ -88,7 +141,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
public function init() {
|
public function init() {
|
||||||
// set reading lang
|
// set reading lang
|
||||||
if(SiteTree::has_extension('Translatable') && !$this->getRequest()->isAjax()) {
|
if(SiteTree::has_extension('Translatable') && !$this->getRequest()->isAjax()) {
|
||||||
Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SiteTree')));
|
Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SilverStripe\\CMS\\Model\\SiteTree')));
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::init();
|
parent::init();
|
||||||
@ -109,11 +162,11 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
CMSBatchActionHandler::register('publish', 'CMSBatchAction_Publish');
|
CMSBatchActionHandler::register('publish', 'SilverStripe\\CMS\\BatchActions\\CMSBatchAction_Publish');
|
||||||
CMSBatchActionHandler::register('unpublish', 'CMSBatchAction_Unpublish');
|
CMSBatchActionHandler::register('unpublish', 'SilverStripe\\CMS\\BatchActions\\CMSBatchAction_Unpublish');
|
||||||
CMSBatchActionHandler::register('delete', 'CMSBatchAction_Delete');
|
CMSBatchActionHandler::register('delete', 'SilverStripe\\CMS\\BatchActions\\CMSBatchAction_Delete');
|
||||||
CMSBatchActionHandler::register('archive', 'CMSBatchAction_Archive');
|
CMSBatchActionHandler::register('archive', 'SilverStripe\\CMS\\BatchActions\\CMSBatchAction_Archive');
|
||||||
CMSBatchActionHandler::register('restore', 'CMSBatchAction_Restore');
|
CMSBatchActionHandler::register('restore', 'SilverStripe\\CMS\\BatchActions\\CMSBatchAction_Restore');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index($request) {
|
public function index($request) {
|
||||||
@ -182,7 +235,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function LinkPages() {
|
public function LinkPages() {
|
||||||
return singleton('CMSPagesController')->Link();
|
return CMSPagesController::singleton()->Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LinkPagesWithSearch() {
|
public function LinkPagesWithSearch() {
|
||||||
@ -190,37 +243,43 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function LinkTreeView() {
|
public function LinkTreeView() {
|
||||||
return $this->LinkWithSearch(singleton('CMSMain')->Link('treeview'));
|
return $this->LinkWithSearch($this->Link('treeview'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LinkListView() {
|
public function LinkListView() {
|
||||||
return $this->LinkWithSearch(singleton('CMSMain')->Link('listview'));
|
return $this->LinkWithSearch($this->Link('listview'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LinkGalleryView() {
|
public function LinkGalleryView() {
|
||||||
return $this->LinkWithSearch(singleton('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('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('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('CMSPageHistoryController')->Link('show'), $id)
|
Controller::join_links(CMSPageHistoryController::singleton()->Link('show'), $id)
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,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("CMSPageAddController")->Link();
|
$link = CMSPageAddController::singleton()->Link();
|
||||||
$this->extend('updateLinkPageAdd', $link);
|
$this->extend('updateLinkPageAdd', $link);
|
||||||
|
|
||||||
if($extra) {
|
if($extra) {
|
||||||
@ -276,8 +335,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
*/
|
*/
|
||||||
public function SiteTreeAsUL() {
|
public function SiteTreeAsUL() {
|
||||||
// Pre-cache sitetree version numbers for querying efficiency
|
// Pre-cache sitetree version numbers for querying efficiency
|
||||||
Versioned::prepopulate_versionnumber_cache("SiteTree", "Stage");
|
Versioned::prepopulate_versionnumber_cache("SilverStripe\\CMS\\Model\\SiteTree", "Stage");
|
||||||
Versioned::prepopulate_versionnumber_cache("SiteTree", "Live");
|
Versioned::prepopulate_versionnumber_cache("SilverStripe\\CMS\\Model\\SiteTree", "Live");
|
||||||
$html = $this->getSiteTreeFor($this->stat('tree_class'));
|
$html = $this->getSiteTreeFor($this->stat('tree_class'));
|
||||||
|
|
||||||
$this->extend('updateSiteTreeAsUL', $html);
|
$this->extend('updateSiteTreeAsUL', $html);
|
||||||
@ -291,7 +350,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
public function TreeIsFiltered() {
|
public function TreeIsFiltered() {
|
||||||
$query = $this->getRequest()->getVar('q');
|
$query = $this->getRequest()->getVar('q');
|
||||||
|
|
||||||
if (!$query || (count($query) === 1 && isset($query['FilterClass']) && $query['FilterClass'] === 'CMSSiteTreeFilter_Search')) {
|
if (!$query || (count($query) === 1 && isset($query['FilterClass']) && $query['FilterClass'] === 'SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter_Search')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,15 +414,17 @@ 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
|
||||||
|
/** @skipUpgrade */
|
||||||
$form = Form::create($this, 'SearchForm', $fields, $actions)
|
$form = Form::create($this, 'SearchForm', $fields, $actions)
|
||||||
->addExtraClass('cms-search-form')
|
->addExtraClass('cms-search-form')
|
||||||
->setFormMethod('GET')
|
->setFormMethod('GET')
|
||||||
@ -388,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;
|
||||||
@ -496,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') ? '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('SiteTree')->uninherited('description');
|
$description = SiteTree::singleton()->uninherited('description');
|
||||||
}
|
}
|
||||||
|
|
||||||
$result->push(new ArrayData(array(
|
$result->push(new ArrayData(array(
|
||||||
@ -626,6 +692,7 @@ 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
|
||||||
|
/** @skipUpgrade */
|
||||||
if($record instanceof CMSPreviewable && !$fields->fieldByName('SilverStripeNavigator')) {
|
if($record instanceof CMSPreviewable && !$fields->fieldByName('SilverStripeNavigator')) {
|
||||||
$navField = new LiteralField('SilverStripeNavigator', $this->getSilverStripeNavigator());
|
$navField = new LiteralField('SilverStripeNavigator', $this->getSilverStripeNavigator());
|
||||||
$navField->setAllowHTML(true);
|
$navField->setAllowHTML(true);
|
||||||
@ -747,7 +814,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
protected function getQueryFilter($params) {
|
protected function getQueryFilter($params) {
|
||||||
if(empty($params['FilterClass'])) return null;
|
if(empty($params['FilterClass'])) return null;
|
||||||
$filterClass = $params['FilterClass'];
|
$filterClass = $params['FilterClass'];
|
||||||
if(!is_subclass_of($filterClass, 'CMSSiteTreeFilter')) {
|
if(!is_subclass_of($filterClass, 'SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter')) {
|
||||||
throw new InvalidArgumentException("Invalid filter class passed: {$filterClass}");
|
throw new InvalidArgumentException("Invalid filter class passed: {$filterClass}");
|
||||||
}
|
}
|
||||||
return $filterClass::create($params);
|
return $filterClass::create($params);
|
||||||
@ -830,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('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
|
||||||
@ -1039,13 +1106,13 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
$id = (int) $data['ID'];
|
$id = (int) $data['ID'];
|
||||||
$restoredPage = Versioned::get_latest_version("SiteTree", $id);
|
$restoredPage = Versioned::get_latest_version("SilverStripe\\CMS\\Model\\SiteTree", $id);
|
||||||
if(!$restoredPage) {
|
if(!$restoredPage) {
|
||||||
throw new SS_HTTPResponse_Exception("SiteTree #$id not found", 400);
|
throw new SS_HTTPResponse_Exception("SiteTree #$id not found", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var SiteTree $record */
|
/** @var SiteTree $record */
|
||||||
$record = Versioned::get_one_by_stage('SiteTree', 'Live', array(
|
$record = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', array(
|
||||||
'"SiteTree_Live"."ID"' => $id
|
'"SiteTree_Live"."ID"' => $id
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -1085,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("SiteTree", $id);
|
$record = SiteTree::get()->byID($id);
|
||||||
if($record && !$record->canDelete()) {
|
if($record && !$record->canDelete()) {
|
||||||
return Security::permissionFailure();
|
return Security::permissionFailure();
|
||||||
}
|
}
|
||||||
@ -1116,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("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);
|
||||||
}
|
}
|
||||||
@ -1212,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('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');
|
||||||
@ -1279,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("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) {
|
||||||
@ -1293,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("SiteTree", "", "", "", "$start,30");
|
$pages = SiteTree::get()->limit("$start,30");
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1331,7 +1398,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
$id = (int)$data['ID'];
|
$id = (int)$data['ID'];
|
||||||
$restoredPage = Versioned::get_latest_version("SiteTree", $id);
|
$restoredPage = Versioned::get_latest_version("SilverStripe\\CMS\\Model\\SiteTree", $id);
|
||||||
if(!$restoredPage) return new SS_HTTPResponse("SiteTree #$id not found", 400);
|
if(!$restoredPage) return new SS_HTTPResponse("SiteTree #$id not found", 400);
|
||||||
|
|
||||||
$restoredPage = $restoredPage->doRestoreToStage();
|
$restoredPage = $restoredPage->doRestoreToStage();
|
||||||
@ -1353,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("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);
|
||||||
}
|
}
|
||||||
@ -1375,7 +1442,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
array('title' => $newPage->Title)
|
array('title' => $newPage->Title)
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
$url = Controller::join_links(singleton('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');
|
||||||
@ -1391,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("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);
|
||||||
}
|
}
|
||||||
@ -1407,7 +1474,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
array('title' => $newPage->Title)
|
array('title' => $newPage->Title)
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
$url = Controller::join_links(singleton('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');
|
@ -1,10 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\FieldType\DBField;
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
use SilverStripe\ORM\ValidationException;
|
use SilverStripe\ORM\ValidationException;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
|
use FieldList;
|
||||||
|
use LiteralField;
|
||||||
|
use SelectionGroup;
|
||||||
|
use SelectionGroup_Item;
|
||||||
|
use TreeDropdownField;
|
||||||
|
use OptionsetField;
|
||||||
|
use FormAction;
|
||||||
|
use Form;
|
||||||
|
|
||||||
|
use Session;
|
||||||
|
use Controller;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CMSPageAddController extends CMSPageEditController {
|
class CMSPageAddController extends CMSPageEditController {
|
||||||
|
|
||||||
@ -58,7 +74,7 @@ class CMSPageAddController extends CMSPageEditController {
|
|||||||
$parentField = new TreeDropdownField(
|
$parentField = new TreeDropdownField(
|
||||||
"ParentID",
|
"ParentID",
|
||||||
"",
|
"",
|
||||||
'SiteTree',
|
'SilverStripe\\CMS\\Model\\SiteTree',
|
||||||
'ID',
|
'ID',
|
||||||
'TreeTitle'
|
'TreeTitle'
|
||||||
),
|
),
|
||||||
@ -162,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("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);
|
||||||
@ -181,7 +202,7 @@ class CMSPageAddController extends CMSPageEditController {
|
|||||||
return $this->getResponseNegotiator()->respond($this->getRequest());
|
return $this->getResponseNegotiator()->respond($this->getRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
$editController = singleton('CMSPageEditController');
|
$editController = CMSPageEditController::singleton();
|
||||||
$editController->setCurrentPageID($record->ID);
|
$editController->setCurrentPageID($record->ID);
|
||||||
|
|
||||||
Session::set(
|
Session::set(
|
||||||
@ -190,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('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('CMSMain')->Link());
|
return $this->redirect(CMSMain::singleton()->Link());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,14 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
*/
|
*/
|
||||||
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 = 'CMSMain';
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,8 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\ORM\DataObject;
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
|
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 FieldList;
|
||||||
|
use FormAction;
|
||||||
|
use HiddenField;
|
||||||
|
use Controller;
|
||||||
|
use LiteralField;
|
||||||
|
use SS_HTTPRequest;
|
||||||
|
use SS_HTTPResponse;
|
||||||
|
use ViewableData;
|
||||||
|
use CheckboxField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -11,11 +25,14 @@ use SilverStripe\Security\Security;
|
|||||||
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 = 'CMSMain';
|
|
||||||
|
|
||||||
private static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
'VersionsForm',
|
'VersionsForm',
|
||||||
@ -162,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"
|
||||||
@ -227,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(
|
||||||
@ -255,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',
|
||||||
@ -279,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);
|
||||||
|
|
||||||
@ -305,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
|
||||||
@ -319,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;
|
||||||
@ -328,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)
|
||||||
@ -340,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
|
||||||
));
|
));
|
||||||
@ -373,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("SiteTree", $id);
|
/** @var SiteTree $page */
|
||||||
|
$page = SiteTree::get()->byID($id);
|
||||||
|
|
||||||
if($page && $page->exists()) {
|
if($page && $page->exists()) {
|
||||||
if(!$page->canView()) {
|
if(!$page->canView()) {
|
||||||
@ -388,8 +411,8 @@ class CMSPageHistoryController extends CMSMain {
|
|||||||
$record = $page->compareVersions($fromVersion, $toVersion);
|
$record = $page->compareVersions($fromVersion, $toVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fromVersionRecord = Versioned::get_version('SiteTree', $id, $fromVersion);
|
$fromVersionRecord = Versioned::get_version('SilverStripe\\CMS\\Model\\SiteTree', $id, $fromVersion);
|
||||||
$toVersionRecord = Versioned::get_version('SiteTree', $id, $toVersion);
|
$toVersionRecord = Versioned::get_version('SilverStripe\\CMS\\Model\\SiteTree', $id, $toVersion);
|
||||||
|
|
||||||
if(!$fromVersionRecord) {
|
if(!$fromVersionRecord) {
|
||||||
user_error("Can't find version $fromVersion of page $id", E_USER_ERROR);
|
user_error("Can't find version $fromVersion of page $id", E_USER_ERROR);
|
||||||
@ -399,7 +422,9 @@ 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) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
$form = $this->getEditForm($id, null, null, true);
|
$form = $this->getEditForm($id, null, null, true);
|
||||||
$form->setActions(new FieldList());
|
$form->setActions(new FieldList());
|
||||||
$form->addExtraClass('compare');
|
$form->addExtraClass('compare');
|
||||||
@ -423,9 +448,6 @@ class CMSPageHistoryController extends CMSMain {
|
|||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function Breadcrumbs($unlinked = false) {
|
public function Breadcrumbs($unlinked = false) {
|
||||||
$crumbs = parent::Breadcrumbs($unlinked);
|
$crumbs = parent::Breadcrumbs($unlinked);
|
||||||
$crumbs[0]->Title = _t('CMSPagesController.MENUTITLE');
|
$crumbs[0]->Title = _t('CMSPagesController.MENUTITLE');
|
@ -1,15 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
*/
|
*/
|
||||||
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 = '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());
|
@ -1,6 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use stdClass;
|
||||||
|
use Controller;
|
||||||
|
use ArrayData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -8,11 +14,14 @@ use SilverStripe\ORM\DataObject;
|
|||||||
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 = 'CMSMain';
|
|
||||||
|
|
||||||
public function LinkPreview() {
|
public function LinkPreview() {
|
||||||
return false;
|
return false;
|
||||||
@ -34,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('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();
|
||||||
@ -50,7 +59,7 @@ class CMSPagesController extends CMSMain {
|
|||||||
));
|
));
|
||||||
foreach($pages as $page) {
|
foreach($pages as $page) {
|
||||||
$params['ParentID'] = $page->ID;
|
$params['ParentID'] = $page->ID;
|
||||||
$item = new StdClass();
|
$item = new stdClass();
|
||||||
$item->Title = $page->Title;
|
$item->Title = $page->Title;
|
||||||
$item->Link = Controller::join_links($this->Link(), '?' . http_build_query($params));
|
$item->Link = Controller::join_links($this->Link(), '?' . http_build_query($params));
|
||||||
$items->push(new ArrayData($item));
|
$items->push(new ArrayData($item));
|
@ -1,6 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
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 LeftAndMain_SearchFilter;
|
||||||
|
use ClassInfo;
|
||||||
|
use DateField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for filtering the subtree for certain node statuses.
|
* Base class for filtering the subtree for certain node statuses.
|
||||||
@ -19,8 +28,10 @@ use SilverStripe\ORM\Versioning\Versioned;
|
|||||||
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();
|
||||||
|
|
||||||
@ -42,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();
|
||||||
|
|
||||||
@ -63,7 +74,7 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil
|
|||||||
*/
|
*/
|
||||||
public static function get_all_filters() {
|
public static function get_all_filters() {
|
||||||
// get all filter instances
|
// get all filter instances
|
||||||
$filters = ClassInfo::subclassesFor('CMSSiteTreeFilter');
|
$filters = ClassInfo::subclassesFor('SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter');
|
||||||
|
|
||||||
// remove abstract CMSSiteTreeFilter class
|
// remove abstract CMSSiteTreeFilter class
|
||||||
array_shift($filters);
|
array_shift($filters);
|
||||||
@ -107,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,7 +157,7 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil
|
|||||||
}
|
}
|
||||||
|
|
||||||
while(!empty($parents)) {
|
while(!empty($parents)) {
|
||||||
$q = Versioned::get_including_deleted('SiteTree', '"RecordID" in ('.implode(',',array_keys($parents)).')');
|
$q = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree', '"RecordID" in ('.implode(',',array_keys($parents)).')');
|
||||||
$list = $q->map('ID', 'ParentID');
|
$list = $q->map('ID', 'ParentID');
|
||||||
$parents = array();
|
$parents = array();
|
||||||
foreach($list as $id => $parentID) {
|
foreach($list as $id => $parentID) {
|
||||||
@ -171,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('SiteTree');
|
$sng = SiteTree::singleton();
|
||||||
foreach($this->params as $name => $val) {
|
foreach($this->params as $name => $val) {
|
||||||
if(empty($val)) continue;
|
if(empty($val)) continue;
|
||||||
|
|
||||||
@ -215,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) {
|
||||||
@ -262,9 +275,9 @@ class CMSSiteTreeFilter_PublishedPages extends CMSSiteTreeFilter {
|
|||||||
* @return SS_List
|
* @return SS_List
|
||||||
*/
|
*/
|
||||||
public function getFilteredPages() {
|
public function getFilteredPages() {
|
||||||
$pages = Versioned::get_including_deleted('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;
|
||||||
@ -296,7 +309,7 @@ class CMSSiteTreeFilter_DeletedPages extends CMSSiteTreeFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getFilteredPages() {
|
public function getFilteredPages() {
|
||||||
$pages = Versioned::get_including_deleted('SiteTree');
|
$pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree');
|
||||||
$pages = $this->applyDefaultFilters($pages);
|
$pages = $this->applyDefaultFilters($pages);
|
||||||
return $pages;
|
return $pages;
|
||||||
}
|
}
|
||||||
@ -315,7 +328,7 @@ class CMSSiteTreeFilter_ChangedPages extends CMSSiteTreeFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getFilteredPages() {
|
public function getFilteredPages() {
|
||||||
$pages = Versioned::get_by_stage('SiteTree', 'Stage');
|
$pages = Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Stage');
|
||||||
$pages = $this->applyDefaultFilters($pages)
|
$pages = $this->applyDefaultFilters($pages)
|
||||||
->leftJoin('SiteTree_Live', '"SiteTree_Live"."ID" = "SiteTree"."ID"')
|
->leftJoin('SiteTree_Live', '"SiteTree_Live"."ID" = "SiteTree"."ID"')
|
||||||
->where('"SiteTree"."Version" <> "SiteTree_Live"."Version"');
|
->where('"SiteTree"."Version" <> "SiteTree_Live"."Version"');
|
||||||
@ -341,9 +354,9 @@ class CMSSiteTreeFilter_StatusRemovedFromDraftPages extends CMSSiteTreeFilter {
|
|||||||
* @return SS_List
|
* @return SS_List
|
||||||
*/
|
*/
|
||||||
public function getFilteredPages() {
|
public function getFilteredPages() {
|
||||||
$pages = Versioned::get_including_deleted('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();
|
||||||
});
|
});
|
||||||
@ -370,9 +383,9 @@ class CMSSiteTreeFilter_StatusDraftPages extends CMSSiteTreeFilter {
|
|||||||
* @return SS_List
|
* @return SS_List
|
||||||
*/
|
*/
|
||||||
public function getFilteredPages() {
|
public function getFilteredPages() {
|
||||||
$pages = Versioned::get_by_stage('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());
|
||||||
});
|
});
|
||||||
@ -409,10 +422,10 @@ class CMSSiteTreeFilter_StatusDeletedPages extends CMSSiteTreeFilter {
|
|||||||
* @return SS_List
|
* @return SS_List
|
||||||
*/
|
*/
|
||||||
public function getFilteredPages() {
|
public function getFilteredPages() {
|
||||||
$pages = Versioned::get_including_deleted('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();
|
||||||
});
|
});
|
||||||
@ -438,7 +451,7 @@ class CMSSiteTreeFilter_Search extends CMSSiteTreeFilter {
|
|||||||
*/
|
*/
|
||||||
public function getFilteredPages() {
|
public function getFilteredPages() {
|
||||||
// Filter default records
|
// Filter default records
|
||||||
$pages = Versioned::get_by_stage('SiteTree', 'Stage');
|
$pages = Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Stage');
|
||||||
$pages = $this->applyDefaultFilters($pages);
|
$pages = $this->applyDefaultFilters($pages);
|
||||||
return $pages;
|
return $pages;
|
||||||
}
|
}
|
@ -1,8 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
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;
|
||||||
@ -12,7 +15,23 @@ use SilverStripe\Security\Security;
|
|||||||
use SilverStripe\Security\MemberAuthenticator;
|
use SilverStripe\Security\MemberAuthenticator;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\Security\Permission;
|
use SilverStripe\Security\Permission;
|
||||||
|
use Controller;
|
||||||
|
use Page;
|
||||||
|
|
||||||
|
use SiteConfig;
|
||||||
|
use Config;
|
||||||
|
use SS_HTTPRequest;
|
||||||
|
use Translatable;
|
||||||
|
use i18n;
|
||||||
|
use SS_HTTPResponse;
|
||||||
|
use SS_HTTPResponse_Exception;
|
||||||
|
use Director;
|
||||||
|
use Requirements;
|
||||||
|
use Convert;
|
||||||
|
use SSViewer;
|
||||||
|
use ArrayData;
|
||||||
|
use Session;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,7 +57,7 @@ class ContentController extends Controller {
|
|||||||
|
|
||||||
protected $dataRecord;
|
protected $dataRecord;
|
||||||
|
|
||||||
private static $extensions = array('OldPageRedirector');
|
private static $extensions = array('SilverStripe\\CMS\\Controllers\\OldPageRedirector');
|
||||||
|
|
||||||
private static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
'successfullyinstalled',
|
'successfullyinstalled',
|
||||||
@ -49,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;
|
||||||
}
|
}
|
||||||
@ -89,10 +112,13 @@ class ContentController extends Controller {
|
|||||||
$parent = SiteTree::get_by_link($parentRef);
|
$parent = SiteTree::get_by_link($parentRef);
|
||||||
|
|
||||||
if(!$parent && is_numeric($parentRef)) {
|
if(!$parent && is_numeric($parentRef)) {
|
||||||
$parent = DataObject::get_by_id('SiteTree', $parentRef);
|
$parent = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $parentRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($parent) return $parent->Children();
|
if($parent) {
|
||||||
|
return $parent->Children();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,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);
|
||||||
@ -118,15 +146,19 @@ class ContentController extends Controller {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->dataRecord) $this->dataRecord->extend('contentcontrollerInit', $this);
|
if($this->dataRecord) {
|
||||||
else singleton('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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,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);
|
||||||
@ -151,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();
|
||||||
@ -170,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();
|
||||||
@ -234,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,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() {
|
||||||
@ -382,11 +423,11 @@ HTML;
|
|||||||
|
|
||||||
$templates = array_merge(
|
$templates = array_merge(
|
||||||
// Find templates by dataRecord
|
// Find templates by dataRecord
|
||||||
SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SiteTree"),
|
SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SilverStripe\\CMS\\Model\\SiteTree"),
|
||||||
// Next, we need to add templates for all controllers
|
// Next, we need to add templates for all controllers
|
||||||
SSViewer::get_templates_by_class(get_class($this), $action, "Controller"),
|
SSViewer::get_templates_by_class(get_class($this), $action, "Controller"),
|
||||||
// Fail-over to the same for the "index" action
|
// Fail-over to the same for the "index" action
|
||||||
SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SiteTree"),
|
SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SilverStripe\\CMS\\Model\\SiteTree"),
|
||||||
SSViewer::get_templates_by_class(get_class($this), "", "Controller")
|
SSViewer::get_templates_by_class(get_class($this), "", "Controller")
|
||||||
);
|
);
|
||||||
|
|
@ -1,5 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
|
use Extension;
|
||||||
|
use SS_HTTPRequest;
|
||||||
|
use SS_HTTPResponse_Exception;
|
||||||
|
use SilverStripe\CMS\Model\ErrorPage;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enhances error handling for a controller with ErrorPage generated output
|
* Enhances error handling for a controller with ErrorPage generated output
|
||||||
*
|
*
|
@ -1,8 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\ORM\DataExtension;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Model\ErrorPage;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decorates {@see File} with ErrorPage support
|
* Decorates {@see File} with ErrorPage support
|
||||||
*/
|
*/
|
@ -1,4 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
|
use Extension;
|
||||||
|
use Requirements;
|
||||||
|
use ClassInfo;
|
||||||
|
use Director;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension to include custom page icons
|
* Extension to include custom page icons
|
||||||
*
|
*
|
||||||
@ -20,24 +28,22 @@ class LeftAndMainPageIconsExtension extends Extension {
|
|||||||
public function generatePageIconsCss() {
|
public function generatePageIconsCss() {
|
||||||
$css = '';
|
$css = '';
|
||||||
|
|
||||||
$classes = ClassInfo::subclassesFor('SiteTree');
|
$classes = ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\SiteTree');
|
||||||
foreach($classes as $class) {
|
foreach($classes as $class) {
|
||||||
$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";
|
||||||
|
|
@ -1,8 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
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;
|
||||||
|
use Controller;
|
||||||
|
|
||||||
|
use ClassInfo;
|
||||||
|
use Injector;
|
||||||
|
use SS_HTTPRequest;
|
||||||
|
use Director;
|
||||||
|
use RequestHandler;
|
||||||
|
use SS_HTTPResponse;
|
||||||
|
use SS_HTTPResponse_Exception;
|
||||||
|
use Exception;
|
||||||
|
use Translatable;
|
||||||
|
use Debug;
|
||||||
|
use Deprecation;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ModelAsController deals with mapping the initial request to the first {@link SiteTree}/{@link ContentController}
|
* ModelAsController deals with mapping the initial request to the first {@link SiteTree}/{@link ContentController}
|
||||||
@ -12,7 +30,8 @@ use SilverStripe\ORM\DataObject;
|
|||||||
* @subpackage control
|
* @subpackage control
|
||||||
*/
|
*/
|
||||||
class ModelAsController extends Controller implements NestedController {
|
class ModelAsController extends Controller implements NestedController {
|
||||||
private static $extensions = array('OldPageRedirector');
|
|
||||||
|
private static $extensions = array('SilverStripe\\CMS\\Controllers\\OldPageRedirector');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the appropriate {@link ContentController} for handling a {@link SiteTree} object, link it to the object and
|
* Get the appropriate {@link ContentController} for handling a {@link SiteTree} object, link it to the object and
|
||||||
@ -23,14 +42,14 @@ class ModelAsController extends Controller implements NestedController {
|
|||||||
* @return ContentController
|
* @return ContentController
|
||||||
*/
|
*/
|
||||||
public static function controller_for(SiteTree $sitetree, $action = null) {
|
public static function controller_for(SiteTree $sitetree, $action = null) {
|
||||||
if ($sitetree->class == 'SiteTree') {
|
if ($sitetree->class == 'SilverStripe\\CMS\\Model\\SiteTree') {
|
||||||
$controller = "ContentController";
|
$controller = "SilverStripe\\CMS\\Controllers\\ContentController";
|
||||||
} else {
|
} else {
|
||||||
$ancestry = ClassInfo::ancestry($sitetree->class);
|
$ancestry = ClassInfo::ancestry($sitetree->class);
|
||||||
while ($class = array_pop($ancestry)) {
|
while ($class = array_pop($ancestry)) {
|
||||||
if (class_exists($class . "_Controller")) break;
|
if (class_exists($class . "_Controller")) break;
|
||||||
}
|
}
|
||||||
$controller = ($class !== null) ? "{$class}_Controller" : "ContentController";
|
$controller = ($class !== null) ? "{$class}_Controller" : "SilverStripe\\CMS\\Controllers\\ContentController";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($action && class_exists($controller . '_' . ucfirst($action))) {
|
if($action && class_exists($controller . '_' . ucfirst($action))) {
|
||||||
@ -41,13 +60,14 @@ class ModelAsController extends Controller implements NestedController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
singleton('SiteTree')->extend('modelascontrollerInit', $this);
|
singleton('SilverStripe\\CMS\\Model\\SiteTree')->extend('modelascontrollerInit', $this);
|
||||||
parent::init();
|
parent::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
||||||
|
/** @skipUpgrade */
|
||||||
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
||||||
$this->getResponse()->redirect(Controller::join_links(
|
$this->getResponse()->redirect(Controller::join_links(
|
||||||
Director::absoluteBaseURL(),
|
Director::absoluteBaseURL(),
|
||||||
@ -75,6 +95,7 @@ class ModelAsController extends Controller implements NestedController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the database has not yet been created, redirect to the build page.
|
// If the database has not yet been created, redirect to the build page.
|
||||||
|
/** @skipUpgrade */
|
||||||
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
||||||
$this->getResponse()->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
$this->getResponse()->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
||||||
$this->popCurrent();
|
$this->popCurrent();
|
||||||
@ -118,7 +139,8 @@ 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);
|
||||||
}
|
}
|
||||||
$sitetree = DataObject::get_one('SiteTree', $conditions);
|
/** @var SiteTree $sitetree */
|
||||||
|
$sitetree = DataObject::get_one('SilverStripe\\CMS\\Model\\SiteTree', $conditions);
|
||||||
|
|
||||||
// Check translation module
|
// Check translation module
|
||||||
// @todo Refactor out module specific code
|
// @todo Refactor out module specific code
|
||||||
@ -149,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);
|
@ -1,6 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
use SilverStripe\ORM\Queries\SQLSelect;
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use Extension;
|
||||||
|
use Director;
|
||||||
|
use SS_HTTPRequest;
|
||||||
|
use SS_HTTPResponse;
|
||||||
|
use Controller;
|
||||||
|
use SS_HTTPResponse_Exception;
|
||||||
|
|
||||||
|
|
||||||
class OldPageRedirector extends Extension {
|
class OldPageRedirector extends Extension {
|
||||||
|
|
||||||
@ -14,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']);
|
||||||
@ -46,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) {
|
@ -1,7 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
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 SS_HTTPResponse;
|
||||||
|
use Translatable;
|
||||||
|
use Config;
|
||||||
|
use Deprecation;
|
||||||
|
use SS_HTTPRequest;
|
||||||
|
use ClassInfo;
|
||||||
|
use Director;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -55,7 +67,7 @@ class RootURLController extends Controller {
|
|||||||
) {
|
) {
|
||||||
self::$cached_homepage_link = $link;
|
self::$cached_homepage_link = $link;
|
||||||
} else {
|
} else {
|
||||||
self::$cached_homepage_link = Config::inst()->get('RootURLController', 'default_homepage_link');
|
self::$cached_homepage_link = Config::inst()->get('SilverStripe\\CMS\\Controllers\\RootURLController', 'default_homepage_link');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,7 +84,7 @@ class RootURLController extends Controller {
|
|||||||
*/
|
*/
|
||||||
static public function set_default_homepage_link($urlsegment = "home") {
|
static public function set_default_homepage_link($urlsegment = "home") {
|
||||||
Deprecation::notice('4.0', 'Use the "RootURLController.default_homepage_link" config setting instead');
|
Deprecation::notice('4.0', 'Use the "RootURLController.default_homepage_link" config setting instead');
|
||||||
Config::inst()->update('RootURLController', 'default_homepage_link', $urlsegment);
|
Config::inst()->update('SilverStripe\\CMS\\Controllers\\RootURLController', 'default_homepage_link', $urlsegment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,7 +95,7 @@ class RootURLController extends Controller {
|
|||||||
*/
|
*/
|
||||||
static public function get_default_homepage_link() {
|
static public function get_default_homepage_link() {
|
||||||
Deprecation::notice('4.0', 'Use the "RootURLController.default_homepage_link" config setting instead');
|
Deprecation::notice('4.0', 'Use the "RootURLController.default_homepage_link" config setting instead');
|
||||||
return Config::inst()->get('RootURLController', 'default_homepage_link');
|
return Config::inst()->get('SilverStripe\\CMS\\Controllers\\RootURLController', 'default_homepage_link');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,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()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,6 +130,7 @@ class RootURLController extends Controller {
|
|||||||
|
|
||||||
self::$is_at_root = true;
|
self::$is_at_root = true;
|
||||||
|
|
||||||
|
/** @skipUpgrade */
|
||||||
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
||||||
$this->getResponse()->redirect(Controller::join_links(
|
$this->getResponse()->redirect(Controller::join_links(
|
||||||
Director::absoluteBaseURL(),
|
Director::absoluteBaseURL(),
|
||||||
@ -136,6 +152,7 @@ class RootURLController extends Controller {
|
|||||||
$this->beforeHandleRequest($request, $model);
|
$this->beforeHandleRequest($request, $model);
|
||||||
|
|
||||||
if (!$this->getResponse()->isFinished()) {
|
if (!$this->getResponse()->isFinished()) {
|
||||||
|
/** @skipUpgrade */
|
||||||
if (!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
if (!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
||||||
$this->getResponse()->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
$this->getResponse()->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
||||||
return $this->getResponse();
|
return $this->getResponse();
|
@ -1,10 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\ORM\DataObject;
|
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 CMSPreviewable;
|
||||||
|
use ClassInfo;
|
||||||
|
use LeftAndMain;
|
||||||
|
use Controller;
|
||||||
|
|
||||||
|
use SiteTreeFutureState;
|
||||||
|
use SilverStripe\CMS\Model\RedirectorPage;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class representing links to different views of a record
|
* Utility class representing links to different views of a record
|
||||||
@ -40,8 +52,8 @@ class SilverStripeNavigator extends ViewableData {
|
|||||||
public function getItems() {
|
public function getItems() {
|
||||||
$items = array();
|
$items = array();
|
||||||
|
|
||||||
$classes = ClassInfo::subclassesFor('SilverStripeNavigatorItem');
|
$classes = ClassInfo::subclassesFor('SilverStripe\\CMS\\Controllers\\SilverStripeNavigatorItem');
|
||||||
unset($classes['SilverStripeNavigatorItem']);
|
unset($classes['SilverStripe\\CMS\\Controllers\\SilverStripeNavigatorItem']);
|
||||||
|
|
||||||
// Sort menu items according to priority
|
// Sort menu items according to priority
|
||||||
foreach($classes as $class) {
|
foreach($classes as $class) {
|
||||||
@ -112,6 +124,9 @@ abstract class SilverStripeNavigatorItem extends ViewableData {
|
|||||||
*/
|
*/
|
||||||
protected $record;
|
protected $record;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $recordLink;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DataObject|CMSPreviewable $record
|
* @param DataObject|CMSPreviewable $record
|
||||||
*/
|
*/
|
@ -1,6 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\ORM\DataObject;
|
namespace SilverStripe\CMS\Forms;
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SS_HTTPRequest;
|
||||||
|
use TextField;
|
||||||
|
use Requirements;
|
||||||
|
use Controller;
|
||||||
|
use Convert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to edit the SiteTree->URLSegment property, and suggest input based on the serverside rules
|
* Used to edit the SiteTree->URLSegment property, and suggest input based on the serverside rules
|
||||||
@ -44,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,
|
||||||
@ -69,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('SiteTree', $idField->Value()) : singleton('SiteTree');
|
return ($idField && $idField->Value())
|
||||||
|
? SiteTree::get()->byID($idField->Value())
|
||||||
|
: SiteTree::singleton();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Cms\Logging;
|
namespace SilverStripe\CMS\Logging;
|
||||||
|
|
||||||
use ErrorPage;
|
|
||||||
use SilverStripe\Framework\Logging\DebugViewFriendlyErrorFormatter;
|
use SilverStripe\Framework\Logging\DebugViewFriendlyErrorFormatter;
|
||||||
|
use SilverStripe\CMS\Model\ErrorPage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides {@see ErrorPage}-gnostic error handling
|
* Provides {@see ErrorPage}-gnostic error handling
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Model;
|
||||||
|
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,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
|
@ -1,9 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
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;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
|
use Page;
|
||||||
|
use Requirements;
|
||||||
|
use SilverStripe\CMS\Controllers\ModelAsController;
|
||||||
|
use SS_HTTPRequest;
|
||||||
|
use SS_HTTPResponse;
|
||||||
|
use DropdownField;
|
||||||
|
use File;
|
||||||
|
use Config;
|
||||||
|
use Director;
|
||||||
|
use Injector;
|
||||||
|
use Page_Controller;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ErrorPage holds the content for the page of an error response.
|
* ErrorPage holds the content for the page of an error response.
|
||||||
@ -29,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")';
|
||||||
@ -69,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
|
||||||
@ -93,6 +111,8 @@ class ErrorPage extends Page {
|
|||||||
$response->setBody($content);
|
$response->setBody($content);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,14 +120,28 @@ 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 === '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) {
|
||||||
|
$this->requireDefaultRecordFixture($defaultData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build default record from specification fixture
|
||||||
|
*
|
||||||
|
* @param array $defaultData
|
||||||
|
*/
|
||||||
|
protected function requireDefaultRecordFixture($defaultData) {
|
||||||
$code = $defaultData['ErrorCode'];
|
$code = $defaultData['ErrorCode'];
|
||||||
$page = ErrorPage::get()->filter('ErrorCode', $code)->first();
|
$page = ErrorPage::get()->filter('ErrorCode', $code)->first();
|
||||||
$pageExists = !empty($page);
|
$pageExists = !empty($page);
|
||||||
@ -119,7 +153,7 @@ class ErrorPage extends Page {
|
|||||||
|
|
||||||
// Check if static files are enabled
|
// Check if static files are enabled
|
||||||
if(!self::config()->enable_static_file) {
|
if(!self::config()->enable_static_file) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure this page has cached error content
|
// Ensure this page has cached error content
|
||||||
@ -129,7 +163,7 @@ class ErrorPage extends Page {
|
|||||||
$success = $page->writeStaticPage();
|
$success = $page->writeStaticPage();
|
||||||
} elseif($pageExists) {
|
} elseif($pageExists) {
|
||||||
// If page exists and already has content, no alteration_message is displayed
|
// If page exists and already has content, no alteration_message is displayed
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($success) {
|
if($success) {
|
||||||
@ -144,8 +178,6 @@ class ErrorPage extends Page {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of arrays, each of which defines properties for a new
|
* Returns an array of arrays, each of which defines properties for a new
|
@ -1,12 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\ORM\DataObject;
|
namespace SilverStripe\CMS\Model;
|
||||||
|
|
||||||
|
use Page;
|
||||||
|
use Requirements;
|
||||||
|
use HeaderField;
|
||||||
|
use OptionsetField;
|
||||||
|
use TreeDropdownField;
|
||||||
|
use TextField;
|
||||||
|
use Page_Controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A redirector page redirects when the page is visited.
|
* A redirector page redirects when the page is visited.
|
||||||
*
|
*
|
||||||
* @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';
|
||||||
@ -21,11 +34,10 @@ class RedirectorPage extends Page {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
"LinkTo" => "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
|
||||||
@ -74,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 {
|
// Check internal redirect
|
||||||
$linkTo = $this->LinkToID ? DataObject::get_by_id("SiteTree", $this->LinkToID) : null;
|
/** @var SiteTree $linkTo */
|
||||||
|
$linkTo = $this->LinkToID ? SiteTree::get()->byID($this->LinkToID) : null;
|
||||||
|
if (empty($linkTo)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if($linkTo) {
|
|
||||||
// We shouldn't point to ourselves - that would create an infinite loop! Return null since we have a
|
// We shouldn't point to ourselves - that would create an infinite loop! Return null since we have a
|
||||||
// bad configuration
|
// bad configuration
|
||||||
if($this->ID == $linkTo->ID) {
|
if($this->ID == $linkTo->ID) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// If we're linking to another redirectorpage then just return the URLSegment, to prevent a cycle of redirector
|
// 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
|
// 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.
|
// this can be handled sufficiently gracefully by the browser.
|
||||||
} elseif($linkTo instanceof RedirectorPage) {
|
if($linkTo instanceof RedirectorPage) {
|
||||||
return $linkTo->regularLink();
|
return $linkTo->regularLink();
|
||||||
|
}
|
||||||
|
|
||||||
// For all other pages, just return the link of the page.
|
// For all other pages, just return the link of the page.
|
||||||
} else {
|
|
||||||
return $linkTo->Link();
|
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('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;
|
||||||
@ -153,7 +166,7 @@ class RedirectorPage extends Page {
|
|||||||
new TreeDropdownField(
|
new TreeDropdownField(
|
||||||
"LinkToID",
|
"LinkToID",
|
||||||
_t('RedirectorPage.YOURPAGE', "Page on your website"),
|
_t('RedirectorPage.YOURPAGE', "Page on your website"),
|
||||||
"SiteTree"
|
"SilverStripe\\CMS\\Model\\SiteTree"
|
||||||
),
|
),
|
||||||
new TextField("ExternalURL", _t('RedirectorPage.OTHERURL', "Other website URL"))
|
new TextField("ExternalURL", _t('RedirectorPage.OTHERURL', "Other website URL"))
|
||||||
)
|
)
|
||||||
@ -179,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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
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;
|
||||||
@ -12,7 +18,43 @@ use SilverStripe\Security\Member;
|
|||||||
use SilverStripe\Security\Permission;
|
use SilverStripe\Security\Permission;
|
||||||
use SilverStripe\Security\Group;
|
use SilverStripe\Security\Group;
|
||||||
use SilverStripe\Security\PermissionProvider;
|
use SilverStripe\Security\PermissionProvider;
|
||||||
|
use i18nEntityProvider;
|
||||||
|
use CMSPreviewable;
|
||||||
|
use Director;
|
||||||
|
use SilverStripe\CMS\Controllers\RootURLController;
|
||||||
|
use ClassInfo;
|
||||||
|
use Convert;
|
||||||
|
use Controller;
|
||||||
|
use Deprecation;
|
||||||
|
use SSViewer;
|
||||||
|
use ArrayData;
|
||||||
|
use SiteConfig;
|
||||||
|
use FormField;
|
||||||
|
use Config;
|
||||||
|
use Page;
|
||||||
|
use URLSegmentFilter;
|
||||||
|
use SilverStripe\CMS\Controllers\ModelAsController;
|
||||||
|
use Subsite;
|
||||||
|
use LiteralField;
|
||||||
|
use GridField;
|
||||||
|
use SilverStripe\CMS\Forms\SiteTreeURLSegmentField;
|
||||||
|
use FieldList;
|
||||||
|
use TabSet;
|
||||||
|
use Tab;
|
||||||
|
use TextField;
|
||||||
|
use HTMLEditorField;
|
||||||
|
use ToggleCompositeField;
|
||||||
|
use TextareaField;
|
||||||
|
use DropdownField;
|
||||||
|
use CompositeField;
|
||||||
|
use OptionsetField;
|
||||||
|
use TreeDropdownField;
|
||||||
|
use FieldGroup;
|
||||||
|
use CheckboxField;
|
||||||
|
use ListboxField;
|
||||||
|
use AddToCampaignHandler_FormAction;
|
||||||
|
use FormAction;
|
||||||
|
use i18n;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic data-object representing all pages within the site tree. All page types that live within the hierarchy should
|
* Basic data-object representing all pages within the site tree. All page types that live within the hierarchy should
|
||||||
@ -41,6 +83,7 @@ use SilverStripe\Security\PermissionProvider;
|
|||||||
*
|
*
|
||||||
* @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
|
||||||
@ -64,7 +107,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* @config
|
* @config
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $allowed_children = array("SiteTree");
|
private static $allowed_children = array("SilverStripe\\CMS\\Model\\SiteTree");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default child class for this page.
|
* The default child class for this page.
|
||||||
@ -148,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(
|
||||||
@ -174,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"
|
||||||
);
|
);
|
||||||
@ -207,7 +252,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'SilverStripe\ORM\Hierarchy\Hierarchy',
|
'SilverStripe\ORM\Hierarchy\Hierarchy',
|
||||||
'SilverStripe\ORM\Versioning\Versioned',
|
'SilverStripe\ORM\Versioning\Versioned',
|
||||||
"SiteTreeLinkTracking"
|
"SilverStripe\\CMS\\Model\\SiteTreeLinkTracking"
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $searchable_fields = array(
|
private static $searchable_fields = array(
|
||||||
@ -286,35 +331,44 @@ 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('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('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('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) {
|
||||||
$next = DataObject::get_one('SiteTree', array(
|
$next = DataObject::get_one('SilverStripe\\CMS\\Model\\SiteTree', array(
|
||||||
'"SiteTree"."URLSegment"' => $segment,
|
'"SiteTree"."URLSegment"' => $segment,
|
||||||
'"SiteTree"."ParentID"' => $sitetree->ID
|
'"SiteTree"."ParentID"' => $sitetree->ID
|
||||||
),
|
),
|
||||||
@ -324,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('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();
|
||||||
@ -346,7 +402,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public static function page_type_classes() {
|
public static function page_type_classes() {
|
||||||
$classes = ClassInfo::getValidSubClasses();
|
$classes = ClassInfo::getValidSubClasses();
|
||||||
|
|
||||||
$baseClassIndex = array_search('SiteTree', $classes);
|
$baseClassIndex = array_search('SilverStripe\\CMS\\Model\\SiteTree', $classes);
|
||||||
if($baseClassIndex !== FALSE) unset($classes[$baseClassIndex]);
|
if($baseClassIndex !== FALSE) unset($classes[$baseClassIndex]);
|
||||||
|
|
||||||
$kill_ancestors = array();
|
$kill_ancestors = array();
|
||||||
@ -383,19 +439,22 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*
|
*
|
||||||
* @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('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('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) {
|
||||||
@ -470,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('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()) {
|
||||||
@ -501,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('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) {
|
||||||
@ -524,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('CMSPageEditController')->Link('show'),
|
CMSPageEditController::singleton()->Link('show'),
|
||||||
$this->ID
|
$this->ID
|
||||||
);
|
);
|
||||||
return Director::absoluteURL($link);
|
return Director::absoluteURL($link);
|
||||||
@ -546,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -570,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();
|
||||||
@ -619,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;
|
||||||
}
|
}
|
||||||
@ -640,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();
|
||||||
}
|
}
|
||||||
@ -665,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;
|
||||||
@ -705,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)
|
||||||
) {
|
) {
|
||||||
@ -712,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));
|
||||||
@ -742,8 +814,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*/
|
*/
|
||||||
public function getParent() {
|
public function getParent() {
|
||||||
if ($parentID = $this->getField("ParentID")) {
|
if ($parentID = $this->getField("ParentID")) {
|
||||||
return DataObject::get_by_id("SiteTree", $parentID);
|
return DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $parentID);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -758,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));
|
||||||
@ -1095,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);
|
||||||
@ -1163,14 +1238,19 @@ 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
|
||||||
|
/** @skipUpgrade */
|
||||||
$table = ($stage=='Stage') ? "SiteTree" : "SiteTree_$stage";
|
$table = ($stage=='Stage') ? "SiteTree" : "SiteTree_$stage";
|
||||||
|
|
||||||
if($ids) {
|
if($ids) {
|
||||||
@ -1182,7 +1262,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$result = array_fill_keys($stageIds, false);
|
$result = array_fill_keys($stageIds, false);
|
||||||
|
|
||||||
// Get the uninherited permissions
|
// Get the uninherited permissions
|
||||||
$uninheritedPermissions = Versioned::get_by_stage("SiteTree", $stage)
|
$uninheritedPermissions = Versioned::get_by_stage("SilverStripe\\CMS\\Model\\SiteTree", $stage)
|
||||||
->where(array(
|
->where(array(
|
||||||
"(\"$typeField\" = 'LoggedInUsers' OR
|
"(\"$typeField\" = 'LoggedInUsers' OR
|
||||||
(\"$typeField\" = 'OnlyTheseUsers' AND \"$groupJoinTable\".\"SiteTreeID\" IS NOT NULL))
|
(\"$typeField\" = 'OnlyTheseUsers' AND \"$groupJoinTable\".\"SiteTreeID\" IS NOT NULL))
|
||||||
@ -1198,7 +1278,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
|
|
||||||
// Get permissions that are inherited
|
// Get permissions that are inherited
|
||||||
$potentiallyInherited = Versioned::get_by_stage(
|
$potentiallyInherited = Versioned::get_by_stage(
|
||||||
"SiteTree",
|
"SilverStripe\\CMS\\Model\\SiteTree",
|
||||||
$stage,
|
$stage,
|
||||||
array("\"$typeField\" = 'Inherit' AND \"SiteTree\".\"ID\" IN ($idPlaceholders)" => $ids)
|
array("\"$typeField\" = 'Inherit' AND \"SiteTree\".\"ID\" IN ($idPlaceholders)" => $ids)
|
||||||
);
|
);
|
||||||
@ -1337,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;")) {
|
||||||
@ -1348,6 +1429,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1364,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('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',
|
||||||
@ -1431,12 +1513,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
parent::requireDefaultRecords();
|
parent::requireDefaultRecords();
|
||||||
|
|
||||||
// default pages
|
// default pages
|
||||||
if($this->class == 'SiteTree' && $this->config()->create_default_pages) {
|
if($this->class == __CLASS__ && $this->config()->create_default_pages) {
|
||||||
if(!SiteTree::get_by_link(Config::inst()->get('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('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);
|
||||||
@ -1447,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);
|
||||||
@ -1456,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);
|
||||||
@ -1532,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1565,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',
|
||||||
@ -1632,7 +1722,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check existence
|
// Check existence
|
||||||
$existingPage = DataObject::get_one('SiteTree', $filter);
|
$existingPage = DataObject::get_one('SilverStripe\\CMS\\Model\\SiteTree', $filter);
|
||||||
if ($existingPage) return false;
|
if ($existingPage) return false;
|
||||||
|
|
||||||
return !($existingPage);
|
return !($existingPage);
|
||||||
@ -1668,7 +1758,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getStageURLSegment() {
|
public function getStageURLSegment() {
|
||||||
$stageRecord = Versioned::get_one_by_stage('SiteTree', Versioned::DRAFT, array(
|
$stageRecord = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::DRAFT, array(
|
||||||
'"SiteTree"."ID"' => $this->ID
|
'"SiteTree"."ID"' => $this->ID
|
||||||
));
|
));
|
||||||
return ($stageRecord) ? $stageRecord->URLSegment : null;
|
return ($stageRecord) ? $stageRecord->URLSegment : null;
|
||||||
@ -1680,7 +1770,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getLiveURLSegment() {
|
public function getLiveURLSegment() {
|
||||||
$liveRecord = Versioned::get_one_by_stage('SiteTree', Versioned::LIVE, array(
|
$liveRecord = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::LIVE, array(
|
||||||
'"SiteTree"."ID"' => $this->ID
|
'"SiteTree"."ID"' => $this->ID
|
||||||
));
|
));
|
||||||
return ($liveRecord) ? $liveRecord->URLSegment : null;
|
return ($liveRecord) ? $liveRecord->URLSegment : null;
|
||||||
@ -1738,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;
|
||||||
}
|
}
|
||||||
@ -1771,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)) {
|
||||||
@ -1779,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;
|
||||||
}
|
}
|
||||||
@ -1818,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'),
|
||||||
@ -1833,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) {
|
||||||
@ -1864,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.');
|
||||||
@ -1979,7 +2076,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
"root" => _t("SiteTree.PARENTTYPE_ROOT", "Top-level page"),
|
"root" => _t("SiteTree.PARENTTYPE_ROOT", "Top-level page"),
|
||||||
"subpage" => _t("SiteTree.PARENTTYPE_SUBPAGE", "Sub-page underneath a parent page"),
|
"subpage" => _t("SiteTree.PARENTTYPE_SUBPAGE", "Sub-page underneath a parent page"),
|
||||||
)),
|
)),
|
||||||
$parentIDField = new TreeDropdownField("ParentID", $this->fieldLabel('ParentID'), 'SiteTree', 'ID', 'MenuTitle')
|
$parentIDField = new TreeDropdownField("ParentID", $this->fieldLabel('ParentID'), 'SilverStripe\\CMS\\Model\\SiteTree', 'ID', 'MenuTitle')
|
||||||
),
|
),
|
||||||
$visibility = new FieldGroup(
|
$visibility = new FieldGroup(
|
||||||
new CheckboxField("ShowInMenus", $this->fieldLabel('ShowInMenus')),
|
new CheckboxField("ShowInMenus", $this->fieldLabel('ShowInMenus')),
|
||||||
@ -2022,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');
|
||||||
@ -2136,7 +2233,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$rootTabSet->addExtraClass('ss-ui-action-tabset action-menus noborder');
|
$rootTabSet->addExtraClass('ss-ui-action-tabset action-menus noborder');
|
||||||
|
|
||||||
// Render page information into the "more-options" drop-up, on the top.
|
// Render page information into the "more-options" drop-up, on the top.
|
||||||
$live = Versioned::get_one_by_stage('SiteTree', Versioned::LIVE, array(
|
$live = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::LIVE, array(
|
||||||
'"SiteTree"."ID"' => $this->ID
|
'"SiteTree"."ID"' => $this->ID
|
||||||
));
|
));
|
||||||
$moreOptions->push(
|
$moreOptions->push(
|
||||||
@ -2284,7 +2381,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
public function onAfterRevertToLive() {
|
public function onAfterRevertToLive() {
|
||||||
// Use an alias to get the updates made by $this->publish
|
// Use an alias to get the updates made by $this->publish
|
||||||
/** @var SiteTree $stageSelf */
|
/** @var SiteTree $stageSelf */
|
||||||
$stageSelf = Versioned::get_by_stage('SiteTree', Versioned::DRAFT)->byID($this->ID);
|
$stageSelf = Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::DRAFT)->byID($this->ID);
|
||||||
$stageSelf->writeWithoutVersion();
|
$stageSelf->writeWithoutVersion();
|
||||||
|
|
||||||
// Need to update pages linking to this one as no longer broken
|
// Need to update pages linking to this one as no longer broken
|
||||||
@ -2301,7 +2398,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*/
|
*/
|
||||||
protected function isParentArchived() {
|
protected function isParentArchived() {
|
||||||
if($parentID = $this->ParentID) {
|
if($parentID = $this->ParentID) {
|
||||||
$parentPage = Versioned::get_latest_version("SiteTree", $parentID);
|
$parentPage = Versioned::get_latest_version("SilverStripe\\CMS\\Model\\SiteTree", $parentID);
|
||||||
if(!$parentPage || $parentPage->IsDeletedFromStage) {
|
if(!$parentPage || $parentPage->IsDeletedFromStage) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2326,9 +2423,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// create an empty record
|
// create an empty record
|
||||||
if(!DB::prepared_query("SELECT \"ID\" FROM \"SiteTree\" WHERE \"ID\" = ?", array($this->ID))->value()) {
|
if(!DB::prepared_query("SELECT \"ID\" FROM \"SiteTree\" WHERE \"ID\" = ?", array($this->ID))->value()) {
|
||||||
$conn = DB::get_conn();
|
$conn = DB::get_conn();
|
||||||
if(method_exists($conn, 'allowPrimaryKeyEditing')) $conn->allowPrimaryKeyEditing('SiteTree', true);
|
if(method_exists($conn, 'allowPrimaryKeyEditing')) $conn->allowPrimaryKeyEditing('SilverStripe\\CMS\\Model\\SiteTree', true);
|
||||||
DB::prepared_query("INSERT INTO \"SiteTree\" (\"ID\") VALUES (?)", array($this->ID));
|
DB::prepared_query("INSERT INTO \"SiteTree\" (\"ID\") VALUES (?)", array($this->ID));
|
||||||
if(method_exists($conn, 'allowPrimaryKeyEditing')) $conn->allowPrimaryKeyEditing('SiteTree', false);
|
if(method_exists($conn, 'allowPrimaryKeyEditing')) $conn->allowPrimaryKeyEditing('SilverStripe\\CMS\\Model\\SiteTree', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
$oldReadingMode = Versioned::get_reading_mode();
|
$oldReadingMode = Versioned::get_reading_mode();
|
||||||
@ -2336,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) {
|
||||||
@ -2378,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) {
|
||||||
@ -2458,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2598,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2665,7 +2764,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if(!$this->ID) return true;
|
if(!$this->ID) return true;
|
||||||
if($this->isNew()) return false;
|
if($this->isNew()) return false;
|
||||||
|
|
||||||
$stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', Versioned::DRAFT, $this->ID);
|
$stageVersion = Versioned::get_versionnumber_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::DRAFT, $this->ID);
|
||||||
|
|
||||||
// Return true for both completely deleted pages and for pages just deleted from stage
|
// Return true for both completely deleted pages and for pages just deleted from stage
|
||||||
return !($stageVersion);
|
return !($stageVersion);
|
||||||
@ -2690,8 +2789,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// New unsaved pages could be never be published
|
// New unsaved pages could be never be published
|
||||||
if($this->isNew()) return false;
|
if($this->isNew()) return false;
|
||||||
|
|
||||||
$stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $this->ID);
|
$stageVersion = Versioned::get_versionnumber_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Stage', $this->ID);
|
||||||
$liveVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->ID);
|
$liveVersion = Versioned::get_versionnumber_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', $this->ID);
|
||||||
|
|
||||||
$isModified = ($stageVersion && $stageVersion != $liveVersion);
|
$isModified = ($stageVersion && $stageVersion != $liveVersion);
|
||||||
$this->extend('getIsModifiedOnStage', $isModified);
|
$this->extend('getIsModifiedOnStage', $isModified);
|
||||||
@ -2709,8 +2808,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
// New unsaved pages could be never be published
|
// New unsaved pages could be never be published
|
||||||
if($this->isNew()) return false;
|
if($this->isNew()) return false;
|
||||||
|
|
||||||
$stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $this->ID);
|
$stageVersion = Versioned::get_versionnumber_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Stage', $this->ID);
|
||||||
$liveVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->ID);
|
$liveVersion = Versioned::get_versionnumber_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', $this->ID);
|
||||||
|
|
||||||
return ($stageVersion && !$liveVersion);
|
return ($stageVersion && !$liveVersion);
|
||||||
}
|
}
|
||||||
@ -2773,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') ? '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());
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Model;
|
||||||
|
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plug-ins for additional functionality in your SiteTree classes.
|
* Plug-ins for additional functionality in your SiteTree classes.
|
@ -1,9 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
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;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use FieldList;
|
||||||
|
use ReadonlyField;
|
||||||
|
use Convert;
|
||||||
|
use Subsite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension applied to {@see File} object to track links to {@see SiteTree} records.
|
* Extension applied to {@see File} object to track links to {@see SiteTree} records.
|
||||||
@ -21,7 +28,7 @@ use SilverStripe\ORM\DataExtension;
|
|||||||
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}
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,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'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,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;
|
||||||
}
|
}
|
||||||
@ -123,7 +130,7 @@ class SiteTreeFileExtension extends DataExtension {
|
|||||||
$brokenPageIDs = $this->owner->BackLinkTracking()->column("ID");
|
$brokenPageIDs = $this->owner->BackLinkTracking()->column("ID");
|
||||||
if($brokenPageIDs) {
|
if($brokenPageIDs) {
|
||||||
// This will syncLinkTracking on the same stage as this file
|
// This will syncLinkTracking on the same stage as this file
|
||||||
$brokenPages = DataObject::get('SiteTree')->byIDs($brokenPageIDs);
|
$brokenPages = DataObject::get('SilverStripe\\CMS\\Model\\SiteTree')->byIDs($brokenPageIDs);
|
||||||
foreach($brokenPages as $brokenPage) {
|
foreach($brokenPages as $brokenPage) {
|
||||||
$brokenPage->write();
|
$brokenPage->write();
|
||||||
}
|
}
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Model;
|
||||||
|
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\DataQuery;
|
use SilverStripe\ORM\DataQuery;
|
||||||
use SilverStripe\ORM\DataList;
|
use SilverStripe\ORM\DataList;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use ClassInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo Cleanup, refactor, test this class
|
* @todo Cleanup, refactor, test this class
|
||||||
@ -22,7 +25,7 @@ class SiteTreeFolderExtension extends DataExtension {
|
|||||||
$result = DB::query("SELECT DISTINCT \"FileID\" FROM \"SiteTree_ImageTracking\"");
|
$result = DB::query("SELECT DISTINCT \"FileID\" FROM \"SiteTree_ImageTracking\"");
|
||||||
$usedFiles = array();
|
$usedFiles = array();
|
||||||
$where = '';
|
$where = '';
|
||||||
$classes = ClassInfo::subclassesFor('SiteTree');
|
$classes = ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\SiteTree');
|
||||||
|
|
||||||
if($result->numRecords() > 0) {
|
if($result->numRecords() > 0) {
|
||||||
while($nextResult = $result->next()) {
|
while($nextResult = $result->next()) {
|
@ -1,17 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
* @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;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\ORM\DataExtension;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use Injector;
|
||||||
|
use SS_HTMLValue;
|
||||||
|
use Director;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds tracking of links in any HTMLText fields which reference SiteTree or File items.
|
* Adds tracking of links in any HTMLText fields which reference SiteTree or File items.
|
||||||
@ -75,12 +79,12 @@ class SiteTreeLinkTracking extends DataExtension {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $many_many = array(
|
private static $many_many = array(
|
||||||
"LinkTracking" => "SiteTree",
|
"LinkTracking" => "SilverStripe\\CMS\\Model\\SiteTree",
|
||||||
"ImageTracking" => "File" // {@see SiteTreeFileExtension}
|
"ImageTracking" => "File" // {@see SiteTreeFileExtension}
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $belongs_many_many = array(
|
private static $belongs_many_many = array(
|
||||||
"BackLinkTracking" => "SiteTree.LinkTracking"
|
"BackLinkTracking" => "SilverStripe\\CMS\\Model\\SiteTree.LinkTracking"
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,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 {
|
||||||
@ -134,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();
|
||||||
@ -246,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'));
|
||||||
|
|
||||||
@ -269,7 +279,7 @@ class SiteTreeLinkTracking_Parser {
|
|||||||
// Link to a page on this site.
|
// Link to a page on this site.
|
||||||
$matches = array();
|
$matches = array();
|
||||||
if(preg_match('/\[sitetree_link(?:\s*|%20|,)?id=(?<id>[0-9]+)\](#(?<anchor>.*))?/i', $href, $matches)) {
|
if(preg_match('/\[sitetree_link(?:\s*|%20|,)?id=(?<id>[0-9]+)\](#(?<anchor>.*))?/i', $href, $matches)) {
|
||||||
$page = DataObject::get_by_id('SiteTree', $matches['id']);
|
$page = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $matches['id']);
|
||||||
$broken = false;
|
$broken = false;
|
||||||
|
|
||||||
if (!$page) {
|
if (!$page) {
|
@ -1,8 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
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 Convert;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
|
use TreeDropdownField;
|
||||||
|
use ReadonlyTransformation;
|
||||||
|
use LiteralField;
|
||||||
|
use Page_Controller;
|
||||||
|
use SilverStripe\CMS\Controllers\ModelAsController;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Virtual Page creates an instance of a page, with the same fields that the original page had, but readonly.
|
* Virtual Page creates an instance of a page, with the same fields that the original page had, but readonly.
|
||||||
@ -56,7 +68,7 @@ class VirtualPage extends Page {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
"CopyContentFrom" => "SiteTree",
|
"CopyContentFrom" => "SilverStripe\\CMS\\Model\\SiteTree",
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $owns = array(
|
private static $owns = array(
|
||||||
@ -67,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.
|
||||||
*
|
*
|
||||||
@ -96,7 +110,7 @@ class VirtualPage extends Page {
|
|||||||
|
|
||||||
public function setCopyContentFromID($val) {
|
public function setCopyContentFromID($val) {
|
||||||
// Sanity check to prevent pages virtualising other virtual pages
|
// Sanity check to prevent pages virtualising other virtual pages
|
||||||
if($val && DataObject::get_by_id('SiteTree', $val) instanceof VirtualPage) {
|
if($val && DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $val) instanceof VirtualPage) {
|
||||||
$val = 0;
|
$val = 0;
|
||||||
}
|
}
|
||||||
return $this->setField("CopyContentFromID", $val);
|
return $this->setField("CopyContentFromID", $val);
|
||||||
@ -137,7 +151,7 @@ class VirtualPage extends Page {
|
|||||||
|
|
||||||
public function syncLinkTracking() {
|
public function syncLinkTracking() {
|
||||||
if($this->CopyContentFromID) {
|
if($this->CopyContentFromID) {
|
||||||
$this->HasBrokenLink = !(bool) DataObject::get_by_id('SiteTree', $this->CopyContentFromID);
|
$this->HasBrokenLink = !(bool) DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $this->CopyContentFromID);
|
||||||
} else {
|
} else {
|
||||||
$this->HasBrokenLink = true;
|
$this->HasBrokenLink = true;
|
||||||
}
|
}
|
||||||
@ -166,7 +180,7 @@ class VirtualPage extends Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unpublished source
|
// Unpublished source
|
||||||
if(!Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->CopyContentFromID)) {
|
if(!Versioned::get_versionnumber_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', $this->CopyContentFromID)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +198,7 @@ class VirtualPage extends Page {
|
|||||||
$copyContentFromField = new TreeDropdownField(
|
$copyContentFromField = new TreeDropdownField(
|
||||||
"CopyContentFromID",
|
"CopyContentFromID",
|
||||||
_t('VirtualPage.CHOOSE', "Linked Page"),
|
_t('VirtualPage.CHOOSE', "Linked Page"),
|
||||||
"SiteTree"
|
"SilverStripe\\CMS\\Model\\SiteTree"
|
||||||
);
|
);
|
||||||
// filter doesn't let you select children of virtual pages as as source page
|
// filter doesn't let you select children of virtual pages as as source page
|
||||||
//$copyContentFromField->setFilterFunction(create_function('$item', 'return !($item instanceof VirtualPage);'));
|
//$copyContentFromField->setFilterFunction(create_function('$item', 'return !($item instanceof VirtualPage);'));
|
||||||
@ -224,7 +238,7 @@ class VirtualPage extends Page {
|
|||||||
}
|
}
|
||||||
if(
|
if(
|
||||||
$this->CopyContentFromID
|
$this->CopyContentFromID
|
||||||
&& !Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->CopyContentFromID)
|
&& !Versioned::get_versionnumber_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', $this->CopyContentFromID)
|
||||||
) {
|
) {
|
||||||
$msgs[] = _t(
|
$msgs[] = _t(
|
||||||
'SITETREE.VIRTUALPAGEDRAFTWARNING',
|
'SITETREE.VIRTUALPAGEDRAFTWARNING',
|
@ -1,7 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Reports;
|
||||||
|
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SS_Report;
|
||||||
|
use ClassInfo;
|
||||||
|
use FieldList;
|
||||||
|
use CheckboxField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -20,9 +26,9 @@ class BrokenFilesReport extends SS_Report {
|
|||||||
public function sourceRecords($params = null) {
|
public function sourceRecords($params = null) {
|
||||||
// Get class names for page types that are not virtual pages or redirector pages
|
// Get class names for page types that are not virtual pages or redirector pages
|
||||||
$classes = array_diff(
|
$classes = array_diff(
|
||||||
ClassInfo::subclassesFor('SiteTree'),
|
ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\SiteTree'),
|
||||||
ClassInfo::subclassesFor('VirtualPage'),
|
ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\VirtualPage'),
|
||||||
ClassInfo::subclassesFor('RedirectorPage')
|
ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\RedirectorPage')
|
||||||
);
|
);
|
||||||
$classParams = DB::placeholders($classes);
|
$classParams = DB::placeholders($classes);
|
||||||
$classFilter = array(
|
$classFilter = array(
|
||||||
@ -30,7 +36,7 @@ class BrokenFilesReport extends SS_Report {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$stage = isset($params['OnLive']) ? 'Live' : 'Stage';
|
$stage = isset($params['OnLive']) ? 'Live' : 'Stage';
|
||||||
return Versioned::get_by_stage('SiteTree', $stage, $classFilter);
|
return Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', $stage, $classFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function columns() {
|
public function columns() {
|
||||||
@ -49,12 +55,3 @@ class BrokenFilesReport extends SS_Report {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 3.2..4.0
|
|
||||||
*/
|
|
||||||
class SideReport_BrokenFiles extends BrokenFilesReport {
|
|
||||||
public function __construct() {
|
|
||||||
Deprecation::notice('4.0', 'Use BrokenFilesReport instead');
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Reports;
|
||||||
|
|
||||||
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 SS_Report;
|
||||||
|
use ClassInfo;
|
||||||
|
use Controller;
|
||||||
|
use FieldList;
|
||||||
|
use DropdownField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content side-report listing pages with broken links
|
* Content side-report listing pages with broken links
|
||||||
@ -37,16 +44,16 @@ class BrokenLinksReport extends SS_Report {
|
|||||||
);
|
);
|
||||||
$isLive = !isset($params['CheckSite']) || $params['CheckSite'] == 'Published';
|
$isLive = !isset($params['CheckSite']) || $params['CheckSite'] == 'Published';
|
||||||
if ($isLive) {
|
if ($isLive) {
|
||||||
$ret = Versioned::get_by_stage('SiteTree', 'Live', $brokenFilter, $sort, $join, $limit);
|
$ret = Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', $brokenFilter, $sort, $join, $limit);
|
||||||
} else {
|
} else {
|
||||||
$ret = DataObject::get('SiteTree', $brokenFilter, $sort, $join, $limit);
|
$ret = DataObject::get('SilverStripe\\CMS\\Model\\SiteTree', $brokenFilter, $sort, $join, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
$returnSet = new ArrayList();
|
$returnSet = new ArrayList();
|
||||||
if ($ret) foreach($ret as $record) {
|
if ($ret) foreach($ret as $record) {
|
||||||
$reason = false;
|
$reason = false;
|
||||||
$isRedirectorPage = in_array($record->ClassName, ClassInfo::subclassesFor('RedirectorPage'));
|
$isRedirectorPage = in_array($record->ClassName, ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\RedirectorPage'));
|
||||||
$isVirtualPage = in_array($record->ClassName, ClassInfo::subclassesFor('VirtualPage'));
|
$isVirtualPage = in_array($record->ClassName, ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\VirtualPage'));
|
||||||
|
|
||||||
if ($isVirtualPage) {
|
if ($isVirtualPage) {
|
||||||
if ($record->HasBrokenLink) {
|
if ($record->HasBrokenLink) {
|
||||||
@ -89,7 +96,7 @@ class BrokenLinksReport extends SS_Report {
|
|||||||
$dateTitle = _t('BrokenLinksReport.ColumnDateLastPublished', 'Date last published');
|
$dateTitle = _t('BrokenLinksReport.ColumnDateLastPublished', 'Date last published');
|
||||||
}
|
}
|
||||||
|
|
||||||
$linkBase = singleton('CMSPageEditController')->Link('show');
|
$linkBase = singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show');
|
||||||
$fields = array(
|
$fields = array(
|
||||||
"Title" => array(
|
"Title" => array(
|
||||||
"title" => _t('BrokenLinksReport.PageName', 'Page name'),
|
"title" => _t('BrokenLinksReport.PageName', 'Page name'),
|
||||||
@ -144,14 +151,3 @@ class BrokenLinksReport extends SS_Report {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 3.2..4.0
|
|
||||||
*/
|
|
||||||
class SideReport_BrokenLinks extends BrokenLinksReport {
|
|
||||||
public function __construct() {
|
|
||||||
Deprecation::notice('4.0', 'Use BrokenLinksReport instead');
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Reports;
|
||||||
|
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SS_Report;
|
||||||
|
use ClassInfo;
|
||||||
|
use FieldList;
|
||||||
|
use CheckboxField;
|
||||||
|
use Deprecation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -18,13 +25,13 @@ class BrokenRedirectorPagesReport extends SS_Report {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function sourceRecords($params = null) {
|
public function sourceRecords($params = null) {
|
||||||
$classes = ClassInfo::subclassesFor('RedirectorPage');
|
$classes = ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\RedirectorPage');
|
||||||
$classParams = DB::placeholders($classes);
|
$classParams = DB::placeholders($classes);
|
||||||
$classFilter = array(
|
$classFilter = array(
|
||||||
"\"ClassName\" IN ($classParams) AND \"HasBrokenLink\" = 1" => $classes
|
"\"ClassName\" IN ($classParams) AND \"HasBrokenLink\" = 1" => $classes
|
||||||
);
|
);
|
||||||
$stage = isset($params['OnLive']) ? 'Live' : 'Stage';
|
$stage = isset($params['OnLive']) ? 'Live' : 'Stage';
|
||||||
return Versioned::get_by_stage('SiteTree', $stage, $classFilter);
|
return Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', $stage, $classFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function columns() {
|
public function columns() {
|
||||||
@ -42,13 +49,3 @@ class BrokenRedirectorPagesReport extends SS_Report {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 3.2..4.0
|
|
||||||
*/
|
|
||||||
class SideReport_BrokenRedirectorPages extends BrokenRedirectorPagesReport {
|
|
||||||
public function __construct() {
|
|
||||||
Deprecation::notice('4.0', 'Use BrokenRedirectorPagesReport instead');
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Reports;
|
||||||
|
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SS_Report;
|
||||||
|
use ClassInfo;
|
||||||
|
use FieldList;
|
||||||
|
use CheckboxField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -18,13 +24,13 @@ class BrokenVirtualPagesReport extends SS_Report {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function sourceRecords($params = null) {
|
public function sourceRecords($params = null) {
|
||||||
$classes = ClassInfo::subclassesFor('VirtualPage');
|
$classes = ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\VirtualPage');
|
||||||
$classParams = DB::placeholders($classes);
|
$classParams = DB::placeholders($classes);
|
||||||
$classFilter = array(
|
$classFilter = array(
|
||||||
"\"ClassName\" IN ($classParams) AND \"HasBrokenLink\" = 1" => $classes
|
"\"ClassName\" IN ($classParams) AND \"HasBrokenLink\" = 1" => $classes
|
||||||
);
|
);
|
||||||
$stage = isset($params['OnLive']) ? 'Live' : 'Stage';
|
$stage = isset($params['OnLive']) ? 'Live' : 'Stage';
|
||||||
return Versioned::get_by_stage('SiteTree', $stage, $classFilter);
|
return Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', $stage, $classFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function columns() {
|
public function columns() {
|
||||||
@ -42,13 +48,3 @@ class BrokenVirtualPagesReport extends SS_Report {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 3.2..4.0
|
|
||||||
*/
|
|
||||||
class SideReport_BrokenVirtualPages extends BrokenVirtualPagesReport {
|
|
||||||
public function __construct() {
|
|
||||||
Deprecation::notice('4.0', 'Use BrokenVirtualPagesReport instead');
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Reports;
|
||||||
|
|
||||||
|
use SS_Report;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use Deprecation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
* @subpackage reports
|
* @subpackage reports
|
||||||
@ -33,13 +39,3 @@ class EmptyPagesReport extends SS_Report {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 3.2..4.0
|
|
||||||
*/
|
|
||||||
class SideReport_EmptyPages extends EmptyPagesReport {
|
|
||||||
public function __construct() {
|
|
||||||
Deprecation::notice('4.0', 'Use EmptyPagesReport instead');
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Reports;
|
||||||
|
|
||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SS_Report;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -23,7 +26,7 @@ class RecentlyEditedReport extends SS_Report {
|
|||||||
|
|
||||||
public function sourceRecords($params = null) {
|
public function sourceRecords($params = null) {
|
||||||
$threshold = strtotime('-14 days', DBDatetime::now()->Format('U'));
|
$threshold = strtotime('-14 days', DBDatetime::now()->Format('U'));
|
||||||
return DataObject::get("SiteTree", "\"SiteTree\".\"LastEdited\" > '".date("Y-m-d H:i:s", $threshold)."'", "\"SiteTree\".\"LastEdited\" DESC");
|
return DataObject::get("SilverStripe\\CMS\\Model\\SiteTree", "\"SiteTree\".\"LastEdited\" > '".date("Y-m-d H:i:s", $threshold)."'", "\"SiteTree\".\"LastEdited\" DESC");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function columns() {
|
public function columns() {
|
||||||
@ -35,13 +38,3 @@ class RecentlyEditedReport extends SS_Report {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 3.2..4.0
|
|
||||||
*/
|
|
||||||
class SideReport_RecentlyEdited extends RecentlyEditedReport {
|
|
||||||
public function __construct() {
|
|
||||||
Deprecation::notice('4.0', 'Use RecentlyEditedReport instead');
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Search;
|
||||||
|
|
||||||
use SilverStripe\ORM\FieldType\DBField;
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
use Extension;
|
||||||
|
use FieldList;
|
||||||
|
use TextField;
|
||||||
|
use FormAction;
|
||||||
|
use FulltextSearchable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension to provide a search interface when applied to ContentController
|
* Extension to provide a search interface when applied to ContentController
|
||||||
@ -30,7 +37,7 @@ class ContentControllerSearchExtension extends Extension {
|
|||||||
$actions = new FieldList(
|
$actions = new FieldList(
|
||||||
new FormAction('results', _t('SearchForm.GO', 'Go'))
|
new FormAction('results', _t('SearchForm.GO', 'Go'))
|
||||||
);
|
);
|
||||||
$form = SearchForm::create($this->owner, 'SearchForm', $fields, $actions);
|
$form = SearchForm::create($this->owner, 'SilverStripe\\CMS\\Search\\SearchForm', $fields, $actions);
|
||||||
$form->classesToSearch(FulltextSearchable::get_searchable_classes());
|
$form->classesToSearch(FulltextSearchable::get_searchable_classes());
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
@ -1,7 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\Search;
|
||||||
|
|
||||||
|
use Controller;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use Form;
|
||||||
|
use FieldList;
|
||||||
|
use TextField;
|
||||||
|
use HiddenField;
|
||||||
|
use Translatable;
|
||||||
|
use FormAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard basic search form which conducts a fulltext search on all {@link SiteTree}
|
* Standard basic search form which conducts a fulltext search on all {@link SiteTree}
|
||||||
@ -28,7 +37,7 @@ class SearchForm extends Form {
|
|||||||
* Classes to search
|
* Classes to search
|
||||||
*/
|
*/
|
||||||
protected $classesToSearch = array(
|
protected $classesToSearch = array(
|
||||||
"SiteTree", "File"
|
"SilverStripe\\CMS\\Model\\SiteTree", "File"
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $casting = array(
|
private static $casting = array(
|
||||||
@ -50,7 +59,7 @@ class SearchForm extends Form {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(class_exists('Translatable') && singleton('SiteTree')->hasExtension('Translatable')) {
|
if(class_exists('Translatable') && singleton('SilverStripe\\CMS\\Model\\SiteTree')->hasExtension('Translatable')) {
|
||||||
$fields->push(new HiddenField('searchlocale', 'searchlocale', Translatable::get_current_locale()));
|
$fields->push(new HiddenField('searchlocale', 'searchlocale', Translatable::get_current_locale()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +86,7 @@ class SearchForm extends Form {
|
|||||||
public function forTemplate() {
|
public function forTemplate() {
|
||||||
$return = $this->renderWith(array_merge(
|
$return = $this->renderWith(array_merge(
|
||||||
(array)$this->getTemplate(),
|
(array)$this->getTemplate(),
|
||||||
array('SearchForm', 'Form')
|
array('SilverStripe\\CMS\\Search\\SearchForm', 'Form')
|
||||||
));
|
));
|
||||||
|
|
||||||
// Now that we're rendered, clear message
|
// Now that we're rendered, clear message
|
||||||
@ -91,11 +100,11 @@ class SearchForm extends Form {
|
|||||||
* Currently you can only choose from "SiteTree" and "File", but a future version might improve this.
|
* Currently you can only choose from "SiteTree" and "File", but a future version might improve this.
|
||||||
*/
|
*/
|
||||||
public function classesToSearch($classes) {
|
public function classesToSearch($classes) {
|
||||||
$illegalClasses = array_diff($classes, array('SiteTree', 'File'));
|
$illegalClasses = array_diff($classes, array('SilverStripe\\CMS\\Model\\SiteTree', 'File'));
|
||||||
if($illegalClasses) {
|
if($illegalClasses) {
|
||||||
user_error("SearchForm::classesToSearch() passed illegal classes '" . implode("', '", $illegalClasses) . "'. At this stage, only File and SiteTree are allowed", E_USER_WARNING);
|
user_error("SearchForm::classesToSearch() passed illegal classes '" . implode("', '", $illegalClasses) . "'. At this stage, only File and SiteTree are allowed", E_USER_WARNING);
|
||||||
}
|
}
|
||||||
$legalClasses = array_intersect($classes, array('SiteTree', 'File'));
|
$legalClasses = array_intersect($classes, array('SilverStripe\\CMS\\Model\\SiteTree', 'File'));
|
||||||
$this->classesToSearch = $legalClasses;
|
$this->classesToSearch = $legalClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +131,7 @@ class SearchForm extends Form {
|
|||||||
|
|
||||||
// set language (if present)
|
// set language (if present)
|
||||||
if(class_exists('Translatable')) {
|
if(class_exists('Translatable')) {
|
||||||
if(singleton('SiteTree')->hasExtension('Translatable') && isset($data['searchlocale'])) {
|
if(singleton('SilverStripe\\CMS\\Model\\SiteTree')->hasExtension('Translatable') && isset($data['searchlocale'])) {
|
||||||
if($data['searchlocale'] == "ALL") {
|
if($data['searchlocale'] == "ALL") {
|
||||||
Translatable::disable_locale_filter();
|
Translatable::disable_locale_filter();
|
||||||
} else {
|
} else {
|
||||||
@ -165,7 +174,7 @@ class SearchForm extends Form {
|
|||||||
|
|
||||||
// reset locale
|
// reset locale
|
||||||
if(class_exists('Translatable')) {
|
if(class_exists('Translatable')) {
|
||||||
if(singleton('SiteTree')->hasExtension('Translatable') && isset($data['searchlocale'])) {
|
if(singleton('SilverStripe\\CMS\\Model\\SiteTree')->hasExtension('Translatable') && isset($data['searchlocale'])) {
|
||||||
if($data['searchlocale'] == "ALL") {
|
if($data['searchlocale'] == "ALL") {
|
||||||
Translatable::enable_locale_filter();
|
Translatable::enable_locale_filter();
|
||||||
} else {
|
} else {
|
@ -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.
|
||||||
@ -20,7 +25,7 @@ class MigrateSiteTreeLinkingTask extends BuildTask {
|
|||||||
$pages = 0;
|
$pages = 0;
|
||||||
$links = 0;
|
$links = 0;
|
||||||
|
|
||||||
$linkedPages = new DataList('SiteTree');
|
$linkedPages = new DataList('SilverStripe\\CMS\\Model\\SiteTree');
|
||||||
$linkedPages = $linkedPages->innerJoin('SiteTree_LinkTracking', '"SiteTree_LinkTracking"."SiteTreeID" = "SiteTree"."ID"');
|
$linkedPages = $linkedPages->innerJoin('SiteTree_LinkTracking', '"SiteTree_LinkTracking"."SiteTreeID" = "SiteTree"."ID"');
|
||||||
if($linkedPages) foreach($linkedPages as $page) {
|
if($linkedPages) foreach($linkedPages as $page) {
|
||||||
$tracking = DB::prepared_query(
|
$tracking = DB::prepared_query(
|
||||||
@ -29,7 +34,7 @@ class MigrateSiteTreeLinkingTask extends BuildTask {
|
|||||||
)->map();
|
)->map();
|
||||||
|
|
||||||
foreach($tracking as $childID => $fieldName) {
|
foreach($tracking as $childID => $fieldName) {
|
||||||
$linked = DataObject::get_by_id('SiteTree', $childID);
|
$linked = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $childID);
|
||||||
|
|
||||||
// TOOD: Replace in all HTMLText fields
|
// TOOD: Replace in all HTMLText fields
|
||||||
$page->Content = preg_replace (
|
$page->Content = preg_replace (
|
@ -1,10 +1,26 @@
|
|||||||
<?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 Controller;
|
||||||
|
use Requirements;
|
||||||
|
use FieldList;
|
||||||
|
use HeaderField;
|
||||||
|
use LiteralField;
|
||||||
|
use CheckboxSetField;
|
||||||
|
use OptionsetField;
|
||||||
|
use Form;
|
||||||
|
use FormAction;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -55,7 +71,7 @@ in the other stage:<br />
|
|||||||
</p>
|
</p>
|
||||||
";
|
";
|
||||||
|
|
||||||
protected $orphanedSearchClass = 'SiteTree';
|
protected $orphanedSearchClass = 'SilverStripe\\CMS\\Model\\SiteTree';
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
parent::init();
|
parent::init();
|
||||||
@ -65,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;}');
|
||||||
@ -108,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',
|
||||||
@ -167,7 +188,7 @@ in the other stage:<br />
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(!$orphans || !$orphans->Count()) {
|
if(!$orphans || !$orphans->count()) {
|
||||||
$form->makeReadonly();
|
$form->makeReadonly();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,17 +330,21 @@ in the other stage:<br />
|
|||||||
* @param int|array $limit
|
* @param int|array $limit
|
||||||
* @return SS_List
|
* @return SS_List
|
||||||
*/
|
*/
|
||||||
public function getOrphanedPages($class = '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
|
||||||
@ -14,7 +19,7 @@ class SiteTreeMaintenanceTask extends Controller {
|
|||||||
|
|
||||||
public function makelinksunique() {
|
public function makelinksunique() {
|
||||||
$badURLs = "'" . implode("', '", DB::query("SELECT URLSegment, count(*) FROM SiteTree GROUP BY URLSegment HAVING count(*) > 1")->column()) . "'";
|
$badURLs = "'" . implode("', '", DB::query("SELECT URLSegment, count(*) FROM SiteTree GROUP BY URLSegment HAVING count(*) > 1")->column()) . "'";
|
||||||
$pages = DataObject::get("SiteTree", "\"SiteTree\".\"URLSegment\" IN ($badURLs)");
|
$pages = DataObject::get("SilverStripe\\CMS\\Model\\SiteTree", "\"SiteTree\".\"URLSegment\" IN ($badURLs)");
|
||||||
|
|
||||||
foreach($pages as $page) {
|
foreach($pages as $page) {
|
||||||
echo "<li>$page->Title: ";
|
echo "<li>$page->Title: ";
|
||||||
@ -37,4 +42,9 @@ class SiteTreeMaintenanceTask extends Controller {
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function Link($action = null)
|
||||||
|
{
|
||||||
|
return Controller::join_links('SiteTreeMaintenanceTask', $action, '/');
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 3.3.0
|
|
||||||
*
|
|
||||||
* @package cms
|
|
||||||
*/
|
|
||||||
class CMSSettingsController extends SiteConfigLeftAndMain {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @config
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private static $url_priority = 60;
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
<% include CMSPagesController_ContentToolActions %>
|
<% include SilverStripe\CMS\Controllers\CMSPagesController_ContentToolActions %>
|
||||||
|
|
||||||
<div class="ss-dialog cms-page-add-form-dialog cms-dialog-content" id="cms-page-add-form" title="<% _t('CMSMain.AddNew', 'Add new page') %>">
|
<div class="ss-dialog cms-page-add-form-dialog cms-dialog-content" id="cms-page-add-form" title="<% _t('CMSMain.AddNew', 'Add new page') %>">
|
||||||
$AddForm
|
$AddForm
|
@ -1,4 +1,4 @@
|
|||||||
<% include CMSPagesController_ContentToolActions View='Tree' %>
|
<% include SilverStripe\CMS\Controllers\CMSPagesController_ContentToolActions View='Tree' %>
|
||||||
|
|
||||||
<div class="ss-dialog cms-page-add-form-dialog cms-dialog-content" id="cms-page-add-form" title="<% _t('CMSMain.AddNew', 'Add new page') %>">
|
<div class="ss-dialog cms-page-add-form-dialog cms-dialog-content" id="cms-page-add-form" title="<% _t('CMSMain.AddNew', 'Add new page') %>">
|
||||||
$AddForm
|
$AddForm
|
@ -3,17 +3,17 @@
|
|||||||
$URL
|
$URL
|
||||||
</a>
|
</a>
|
||||||
<% if not $IsReadonly %>
|
<% if not $IsReadonly %>
|
||||||
<button type="button" class="btn btn-secondary-outline btn-sm edit">
|
<button role="button" type="button" class="btn ui-button-text-only ss-ui-button edit">
|
||||||
<% _t('URLSegmentField.Edit', 'Edit') %>
|
<% _t('URLSegmentField.Edit', 'Edit') %>
|
||||||
</button>
|
</button>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
</div>
|
</div>
|
||||||
<div class="edit-holder">
|
<div class="edit-holder">
|
||||||
<input $AttributesHTML />
|
<input $AttributesHTML />
|
||||||
<button type="button" class="btn btn-primary update">
|
<button role="button" data-icon="accept" type="button" class="btn ui-button-text-icon-primary ss-ui-button update">
|
||||||
<% _t('URLSegmentField.OK', 'OK') %>
|
<% _t('URLSegmentField.OK', 'OK') %>
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="btn btn-secondary cancel">
|
<button role="button" data-icon="cancel" type="button" class="btn ui-button-text-icon-secondary ss-ui-button cancel">
|
||||||
<% _t('URLSegmentField.Cancel', 'Cancel') %>
|
<% _t('URLSegmentField.Cancel', 'Cancel') %>
|
||||||
</button>
|
</button>
|
||||||
<% if $HelpText %><p class="form__field-description">$HelpText</p><% end_if %>
|
<% if $HelpText %><p class="form__field-description">$HelpText</p><% end_if %>
|
@ -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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,10 +40,10 @@ class FeatureContext extends \SilverStripe\Framework\Test\Behaviour\FeatureConte
|
|||||||
|
|
||||||
// Use blueprints which auto-publish all subclasses of SiteTree
|
// Use blueprints which auto-publish all subclasses of SiteTree
|
||||||
$factory = $fixtureContext->getFixtureFactory();
|
$factory = $fixtureContext->getFixtureFactory();
|
||||||
foreach(\ClassInfo::subclassesFor('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);
|
||||||
|
@ -26,7 +26,7 @@ class FixtureContext extends \SilverStripe\BehatExtension\Context\FixtureContext
|
|||||||
* @Given /^(?:(an|a|the) )"(?<type>[^"]+)" "(?<id>[^"]+)" (:?which )?redirects to (?:(an|a|the) )"(?<targetType>[^"]+)" "(?<targetId>[^"]+)"$/
|
* @Given /^(?:(an|a|the) )"(?<type>[^"]+)" "(?<id>[^"]+)" (:?which )?redirects to (?:(an|a|the) )"(?<targetType>[^"]+)" "(?<targetId>[^"]+)"$/
|
||||||
*/
|
*/
|
||||||
public function stepCreateRedirectorPage($type, $id, $targetType, $targetId) {
|
public function stepCreateRedirectorPage($type, $id, $targetType, $targetId) {
|
||||||
$class = 'RedirectorPage';
|
$class = 'SilverStripe\\CMS\\Model\\RedirectorPage';
|
||||||
$targetClass = $this->convertTypeToClass($targetType);
|
$targetClass = $this->convertTypeToClass($targetType);
|
||||||
|
|
||||||
$targetObj = $this->fixtureFactory->get($targetClass, $targetId);
|
$targetObj = $this->fixtureFactory->get($targetClass, $targetId);
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\CMS\Controllers\AssetAdmin;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@see AssetAdmin}
|
* Tests {@see AssetAdmin}
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\CMS\BatchActions\CMSBatchAction_Publish;
|
||||||
|
use SilverStripe\CMS\BatchActions\CMSBatchAction_Unpublish;
|
||||||
|
use SilverStripe\CMS\BatchActions\CMSBatchAction_Archive;
|
||||||
|
use SilverStripe\CMS\BatchActions\CMSBatchAction_Restore;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests CMS Specific subclasses of {@see CMSBatchAction}
|
* Tests CMS Specific subclasses of {@see CMSBatchAction}
|
||||||
@ -15,20 +21,20 @@ class CMSBatchActionsTest extends SapphireTest {
|
|||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
|
|
||||||
// published page
|
// published page
|
||||||
$published = $this->objFromFixture('SiteTree', 'published');
|
$published = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'published');
|
||||||
$published->publishSingle();
|
$published->publishSingle();
|
||||||
|
|
||||||
// Deleted / archived page
|
// Deleted / archived page
|
||||||
$archived = $this->objFromFixture('SiteTree', 'archived');
|
$archived = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archived');
|
||||||
$archived->doArchive(); // should archive all children
|
$archived->doArchive(); // should archive all children
|
||||||
|
|
||||||
// Unpublished
|
// Unpublished
|
||||||
$unpublished = $this->objFromFixture('SiteTree', 'unpublished');
|
$unpublished = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'unpublished');
|
||||||
$unpublished->publishSingle();
|
$unpublished->publishSingle();
|
||||||
$unpublished->doUnpublish();
|
$unpublished->doUnpublish();
|
||||||
|
|
||||||
// Modified
|
// Modified
|
||||||
$modified = $this->objFromFixture('SiteTree', 'modified');
|
$modified = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'modified');
|
||||||
$modified->publishSingle();
|
$modified->publishSingle();
|
||||||
$modified->Title = 'modified2';
|
$modified->Title = 'modified2';
|
||||||
$modified->write();
|
$modified->write();
|
||||||
@ -39,18 +45,18 @@ class CMSBatchActionsTest extends SapphireTest {
|
|||||||
*/
|
*/
|
||||||
public function testBatchPublishApplicable() {
|
public function testBatchPublishApplicable() {
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
$pages = Versioned::get_including_deleted('SiteTree');
|
$pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree');
|
||||||
$ids = $pages->column('ID');
|
$ids = $pages->column('ID');
|
||||||
$action = new CMSBatchAction_Publish();
|
$action = new CMSBatchAction_Publish();
|
||||||
|
|
||||||
// Test applicable pages
|
// Test applicable pages
|
||||||
$applicable = $action->applicablePages($ids);
|
$applicable = $action->applicablePages($ids);
|
||||||
$this->assertContains($this->idFromFixture('SiteTree', 'published'), $applicable);
|
$this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'published'), $applicable);
|
||||||
$this->assertNotContains($this->idFromFixture('SiteTree', 'archived'), $applicable);
|
$this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archived'), $applicable);
|
||||||
$this->assertNotContains($this->idFromFixture('SiteTree', 'archivedx'), $applicable);
|
$this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedx'), $applicable);
|
||||||
$this->assertNotContains($this->idFromFixture('SiteTree', 'archivedy'), $applicable);
|
$this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedy'), $applicable);
|
||||||
$this->assertContains($this->idFromFixture('SiteTree', 'unpublished'), $applicable);
|
$this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'unpublished'), $applicable);
|
||||||
$this->assertContains($this->idFromFixture('SiteTree', 'modified'), $applicable);
|
$this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'modified'), $applicable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -59,18 +65,18 @@ class CMSBatchActionsTest extends SapphireTest {
|
|||||||
*/
|
*/
|
||||||
public function testBatchUnpublishApplicable() {
|
public function testBatchUnpublishApplicable() {
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
$pages = Versioned::get_including_deleted('SiteTree');
|
$pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree');
|
||||||
$ids = $pages->column('ID');
|
$ids = $pages->column('ID');
|
||||||
$action = new CMSBatchAction_Unpublish();
|
$action = new CMSBatchAction_Unpublish();
|
||||||
|
|
||||||
// Test applicable page
|
// Test applicable page
|
||||||
$applicable = $action->applicablePages($ids);
|
$applicable = $action->applicablePages($ids);
|
||||||
$this->assertContains($this->idFromFixture('SiteTree', 'published'), $applicable);
|
$this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'published'), $applicable);
|
||||||
$this->assertNotContains($this->idFromFixture('SiteTree', 'archived'), $applicable);
|
$this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archived'), $applicable);
|
||||||
$this->assertNotContains($this->idFromFixture('SiteTree', 'archivedx'), $applicable);
|
$this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedx'), $applicable);
|
||||||
$this->assertNotContains($this->idFromFixture('SiteTree', 'archivedy'), $applicable);
|
$this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedy'), $applicable);
|
||||||
$this->assertNotContains($this->idFromFixture('SiteTree', 'unpublished'), $applicable);
|
$this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'unpublished'), $applicable);
|
||||||
$this->assertContains($this->idFromFixture('SiteTree', 'modified'), $applicable);
|
$this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'modified'), $applicable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,16 +84,16 @@ class CMSBatchActionsTest extends SapphireTest {
|
|||||||
*/
|
*/
|
||||||
public function testBatchArchiveApplicable() {
|
public function testBatchArchiveApplicable() {
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
$pages = Versioned::get_including_deleted('SiteTree');
|
$pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree');
|
||||||
$ids = $pages->column('ID');
|
$ids = $pages->column('ID');
|
||||||
$action = new CMSBatchAction_Archive();
|
$action = new CMSBatchAction_Archive();
|
||||||
|
|
||||||
// Test applicable pages
|
// Test applicable pages
|
||||||
$applicable = $action->applicablePages($ids);
|
$applicable = $action->applicablePages($ids);
|
||||||
$this->assertContains($this->idFromFixture('SiteTree', 'published'), $applicable);
|
$this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'published'), $applicable);
|
||||||
$this->assertNotContains($this->idFromFixture('SiteTree', 'archived'), $applicable);
|
$this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archived'), $applicable);
|
||||||
$this->assertContains($this->idFromFixture('SiteTree', 'unpublished'), $applicable);
|
$this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'unpublished'), $applicable);
|
||||||
$this->assertContains($this->idFromFixture('SiteTree', 'modified'), $applicable);
|
$this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'modified'), $applicable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,27 +101,27 @@ class CMSBatchActionsTest extends SapphireTest {
|
|||||||
*/
|
*/
|
||||||
public function testBatchRestoreApplicable() {
|
public function testBatchRestoreApplicable() {
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
$pages = Versioned::get_including_deleted('SiteTree');
|
$pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree');
|
||||||
$ids = $pages->column('ID');
|
$ids = $pages->column('ID');
|
||||||
$action = new CMSBatchAction_Restore();
|
$action = new CMSBatchAction_Restore();
|
||||||
|
|
||||||
// Test applicable pages
|
// Test applicable pages
|
||||||
$applicable = $action->applicablePages($ids);
|
$applicable = $action->applicablePages($ids);
|
||||||
$this->assertNotContains($this->idFromFixture('SiteTree', 'published'), $applicable);
|
$this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'published'), $applicable);
|
||||||
$this->assertContains($this->idFromFixture('SiteTree', 'archived'), $applicable);
|
$this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archived'), $applicable);
|
||||||
$this->assertContains($this->idFromFixture('SiteTree', 'archivedx'), $applicable);
|
$this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedx'), $applicable);
|
||||||
$this->assertContains($this->idFromFixture('SiteTree', 'archivedy'), $applicable);
|
$this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedy'), $applicable);
|
||||||
$this->assertNotContains($this->idFromFixture('SiteTree', 'unpublished'), $applicable);
|
$this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'unpublished'), $applicable);
|
||||||
$this->assertNotContains($this->idFromFixture('SiteTree', 'modified'), $applicable);
|
$this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'modified'), $applicable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBatchRestore() {
|
public function testBatchRestore() {
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
$pages = Versioned::get_including_deleted('SiteTree');
|
$pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree');
|
||||||
$action = new CMSBatchAction_Restore();
|
$action = new CMSBatchAction_Restore();
|
||||||
$archivedID = $this->idFromFixture('SiteTree', 'archived');
|
$archivedID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archived');
|
||||||
$archivedxID = $this->idFromFixture('SiteTree', 'archivedx');
|
$archivedxID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedx');
|
||||||
$archivedyID = $this->idFromFixture('SiteTree', 'archivedy');
|
$archivedyID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedy');
|
||||||
|
|
||||||
// Just restore one child
|
// Just restore one child
|
||||||
$list = $pages->filter('RecordID', $archivedxID);
|
$list = $pages->filter('RecordID', $archivedxID);
|
||||||
|
@ -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
|
||||||
|
@ -4,6 +4,9 @@ use SilverStripe\ORM\DB;
|
|||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\ORM\HiddenClass;
|
use SilverStripe\ORM\HiddenClass;
|
||||||
|
use SilverStripe\CMS\Controllers\CMSMain;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -34,7 +37,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
$user->logIn();
|
$user->logIn();
|
||||||
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
|
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
|
||||||
|
|
||||||
$rawHints = singleton('CMSMain')->SiteTreeHints();
|
$rawHints = singleton('SilverStripe\\CMS\\Controllers\\CMSMain')->SiteTreeHints();
|
||||||
$this->assertNotNull($rawHints);
|
$this->assertNotNull($rawHints);
|
||||||
|
|
||||||
$rawHints = preg_replace('/^"(.*)"$/', '$1', Convert::xml2raw($rawHints));
|
$rawHints = preg_replace('/^"(.*)"$/', '$1', Convert::xml2raw($rawHints));
|
||||||
@ -80,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());
|
||||||
|
|
||||||
@ -125,7 +128,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the latest version of the redirector page
|
// Get the latest version of the redirector page
|
||||||
$pageID = $this->idFromFixture('RedirectorPage', 'page5');
|
$pageID = $this->idFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage', 'page5');
|
||||||
$latestID = DB::prepared_query('select max("Version") from "RedirectorPage_versions" where "RecordID" = ?', array($pageID))->value();
|
$latestID = DB::prepared_query('select max("Version") from "RedirectorPage_versions" where "RecordID" = ?', array($pageID))->value();
|
||||||
$dsCount = DB::prepared_query('select count("Version") from "RedirectorPage_versions" where "RecordID" = ? and "Version"= ?', array($pageID, $latestID))->value();
|
$dsCount = DB::prepared_query('select count("Version") from "RedirectorPage_versions" where "RecordID" = ? and "Version"= ?', array($pageID, $latestID))->value();
|
||||||
$this->assertEquals(1, $dsCount, "Published page has no duplicate version records: it has " . $dsCount . " for version " . $latestID);
|
$this->assertEquals(1, $dsCount, "Published page has no duplicate version records: it has " . $dsCount . " for version " . $latestID);
|
||||||
@ -175,7 +178,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
* Mostly, this is just checking that the method doesn't return an error
|
* Mostly, this is just checking that the method doesn't return an error
|
||||||
*/
|
*/
|
||||||
public function testThatGetCMSFieldsWorksOnEveryPageType() {
|
public function testThatGetCMSFieldsWorksOnEveryPageType() {
|
||||||
$classes = ClassInfo::subclassesFor("SiteTree");
|
$classes = ClassInfo::subclassesFor("SilverStripe\\CMS\\Model\\SiteTree");
|
||||||
array_shift($classes);
|
array_shift($classes);
|
||||||
|
|
||||||
foreach ($classes as $class) {
|
foreach ($classes as $class) {
|
||||||
@ -186,7 +189,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
$page->Title = "Test $class page";
|
$page->Title = "Test $class page";
|
||||||
$page->write();
|
$page->write();
|
||||||
$page->flushCache();
|
$page->flushCache();
|
||||||
$page = DataObject::get_by_id("SiteTree", $page->ID);
|
$page = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $page->ID);
|
||||||
|
|
||||||
$this->assertTrue($page->getCMSFields() instanceof FieldList);
|
$this->assertTrue($page->getCMSFields() instanceof FieldList);
|
||||||
}
|
}
|
||||||
@ -195,7 +198,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
public function testCanPublishPageWithUnpublishedParentWithStrictHierarchyOff() {
|
public function testCanPublishPageWithUnpublishedParentWithStrictHierarchyOff() {
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
|
|
||||||
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', true);
|
||||||
$parentPage = $this->objFromFixture('Page', 'page3');
|
$parentPage = $this->objFromFixture('Page', 'page3');
|
||||||
$childPage = $this->objFromFixture('Page', 'page1');
|
$childPage = $this->objFromFixture('Page', 'page1');
|
||||||
|
|
||||||
@ -208,7 +211,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
$actions,
|
$actions,
|
||||||
'Can publish a page with an unpublished parent with strict hierarchy off'
|
'Can publish a page with an unpublished parent with strict hierarchy off'
|
||||||
);
|
);
|
||||||
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', false);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -225,10 +228,10 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
|
|
||||||
$response = $this->get('admin/pages/edit/show/' . $pageID);
|
$response = $this->get('admin/pages/edit/show/' . $pageID);
|
||||||
|
|
||||||
$livePage = Versioned::get_one_by_stage("SiteTree", "Live", array(
|
$livePage = Versioned::get_one_by_stage("SilverStripe\\CMS\\Model\\SiteTree", "Live", array(
|
||||||
'"SiteTree"."ID"' => $pageID
|
'"SiteTree"."ID"' => $pageID
|
||||||
));
|
));
|
||||||
$this->assertInstanceOf('SiteTree', $livePage);
|
$this->assertInstanceOf('SilverStripe\\CMS\\Model\\SiteTree', $livePage);
|
||||||
$this->assertTrue($livePage->canDelete());
|
$this->assertTrue($livePage->canDelete());
|
||||||
|
|
||||||
// Check that the 'restore' button exists as a simple way of checking that the correct page is returned.
|
// Check that the 'restore' button exists as a simple way of checking that the correct page is returned.
|
||||||
@ -469,7 +472,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
|
|
||||||
// Test deleted page filter
|
// Test deleted page filter
|
||||||
$params = array(
|
$params = array(
|
||||||
'FilterClass' => 'CMSSiteTreeFilter_StatusDeletedPages'
|
'FilterClass' => 'SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter_StatusDeletedPages'
|
||||||
);
|
);
|
||||||
$pages = $controller->getList($params);
|
$pages = $controller->getList($params);
|
||||||
$this->assertEquals(1, $pages->count());
|
$this->assertEquals(1, $pages->count());
|
||||||
@ -480,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' => '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());
|
||||||
@ -491,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,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\CMS\Controllers\CMSPageHistoryController;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_Search;
|
||||||
|
use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_ChangedPages;
|
||||||
|
use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_DeletedPages;
|
||||||
|
use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_StatusDraftPages;
|
||||||
|
use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_StatusRemovedFromDraftPages;
|
||||||
|
use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_StatusDeletedPages;
|
||||||
|
|
||||||
|
|
||||||
class CMSSiteTreeFilterTest extends SapphireTest {
|
class CMSSiteTreeFilterTest extends SapphireTest {
|
||||||
|
|
||||||
@ -94,7 +101,7 @@ class CMSSiteTreeFilterTest extends SapphireTest {
|
|||||||
$deletedPageID = $deletedPage->ID;
|
$deletedPageID = $deletedPage->ID;
|
||||||
$deletedPage->delete();
|
$deletedPage->delete();
|
||||||
$deletedPage = Versioned::get_one_by_stage(
|
$deletedPage = Versioned::get_one_by_stage(
|
||||||
'SiteTree',
|
'SilverStripe\\CMS\\Model\\SiteTree',
|
||||||
'Live',
|
'Live',
|
||||||
array('"SiteTree_Live"."ID"' => $deletedPageID)
|
array('"SiteTree_Live"."ID"' => $deletedPageID)
|
||||||
);
|
);
|
||||||
@ -110,7 +117,7 @@ class CMSSiteTreeFilterTest extends SapphireTest {
|
|||||||
public function testStatusDraftPagesFilter() {
|
public function testStatusDraftPagesFilter() {
|
||||||
$draftPage = $this->objFromFixture('Page', 'page4');
|
$draftPage = $this->objFromFixture('Page', 'page4');
|
||||||
$draftPage = Versioned::get_one_by_stage(
|
$draftPage = Versioned::get_one_by_stage(
|
||||||
'SiteTree',
|
'SilverStripe\\CMS\\Model\\SiteTree',
|
||||||
'Stage',
|
'Stage',
|
||||||
sprintf('"SiteTree"."ID" = %d', $draftPage->ID)
|
sprintf('"SiteTree"."ID" = %d', $draftPage->ID)
|
||||||
);
|
);
|
||||||
@ -146,7 +153,7 @@ class CMSSiteTreeFilterTest extends SapphireTest {
|
|||||||
$removedDraftPage->publishRecursive();
|
$removedDraftPage->publishRecursive();
|
||||||
$removedDraftPage->deleteFromStage('Stage');
|
$removedDraftPage->deleteFromStage('Stage');
|
||||||
$removedDraftPage = Versioned::get_one_by_stage(
|
$removedDraftPage = Versioned::get_one_by_stage(
|
||||||
'SiteTree',
|
'SilverStripe\\CMS\\Model\\SiteTree',
|
||||||
'Live',
|
'Live',
|
||||||
sprintf('"SiteTree"."ID" = %d', $removedDraftPage->ID)
|
sprintf('"SiteTree"."ID" = %d', $removedDraftPage->ID)
|
||||||
);
|
);
|
||||||
@ -173,7 +180,7 @@ class CMSSiteTreeFilterTest extends SapphireTest {
|
|||||||
// Can't use straight $blah->delete() as that blows it away completely and test fails
|
// Can't use straight $blah->delete() as that blows it away completely and test fails
|
||||||
$deletedPage->deleteFromStage(Versioned::LIVE);
|
$deletedPage->deleteFromStage(Versioned::LIVE);
|
||||||
$deletedPage->deleteFromStage(Versioned::DRAFT);
|
$deletedPage->deleteFromStage(Versioned::DRAFT);
|
||||||
$checkParentExists = Versioned::get_latest_version('SiteTree', $deletedPageID);
|
$checkParentExists = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $deletedPageID);
|
||||||
|
|
||||||
// Check deleted page is included
|
// Check deleted page is included
|
||||||
$f = new CMSSiteTreeFilter_StatusDeletedPages(array('Title' => 'Page'));
|
$f = new CMSSiteTreeFilter_StatusDeletedPages(array('Title' => 'Page'));
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\CMS\Controllers\ContentController;
|
||||||
|
|
||||||
|
|
||||||
class ContentControllerSearchExtensionTest extends SapphireTest {
|
class ContentControllerSearchExtensionTest extends SapphireTest {
|
||||||
|
|
||||||
@ -13,7 +15,7 @@ class ContentControllerSearchExtensionTest extends SapphireTest {
|
|||||||
$controller = new ContentController($page);
|
$controller = new ContentController($page);
|
||||||
$form = $controller->SearchForm();
|
$form = $controller->SearchForm();
|
||||||
|
|
||||||
if (get_class($form) == 'SearchForm') $this->assertEquals(array('File'), $form->getClassesToSearch());
|
if (get_class($form) == 'SilverStripe\\CMS\\Search\\SearchForm') $this->assertEquals(array('File'), $form->getClassesToSearch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUpOnce() {
|
public function setUpOnce() {
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\CMS\Controllers\RootURLController;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SilverStripe\CMS\Controllers\ContentController;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -20,7 +24,7 @@ class ContentControllerTest extends FunctionalTest {
|
|||||||
|
|
||||||
public function testNestedPages() {
|
public function testNestedPages() {
|
||||||
RootURLController::reset();
|
RootURLController::reset();
|
||||||
Config::inst()->update('SiteTree', 'nested_urls', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
|
||||||
|
|
||||||
$this->assertEquals('Home Page', $this->get('/')->getBody());
|
$this->assertEquals('Home Page', $this->get('/')->getBody());
|
||||||
$this->assertEquals('Home Page', $this->get('/home/index/')->getBody());
|
$this->assertEquals('Home Page', $this->get('/home/index/')->getBody());
|
||||||
@ -56,7 +60,7 @@ class ContentControllerTest extends FunctionalTest {
|
|||||||
public function testChildrenOf() {
|
public function testChildrenOf() {
|
||||||
$controller = new ContentController();
|
$controller = new ContentController();
|
||||||
|
|
||||||
Config::inst()->update('SiteTree', 'nested_urls', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
|
||||||
|
|
||||||
$this->assertEquals(1, $controller->ChildrenOf('/')->Count());
|
$this->assertEquals(1, $controller->ChildrenOf('/')->Count());
|
||||||
$this->assertEquals(1, $controller->ChildrenOf('/home/')->Count());
|
$this->assertEquals(1, $controller->ChildrenOf('/home/')->Count());
|
||||||
@ -72,7 +76,7 @@ class ContentControllerTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testDeepNestedURLs() {
|
public function testDeepNestedURLs() {
|
||||||
Config::inst()->update('SiteTree', 'nested_urls', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
|
||||||
|
|
||||||
$page = new Page();
|
$page = new Page();
|
||||||
$page->URLSegment = 'base-page';
|
$page->URLSegment = 'base-page';
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SilverStripe\CMS\Controllers\OldPageRedirector;
|
||||||
|
use SilverStripe\CMS\Controllers\RootURLController;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -24,7 +28,7 @@ class ModelAsControllerTest extends FunctionalTest {
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->orig['nested_urls'] = SiteTree::config()->nested_urls;
|
$this->orig['nested_urls'] = SiteTree::config()->nested_urls;
|
||||||
Config::inst()->update('SiteTree', 'nested_urls', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -299,7 +303,7 @@ class ModelAsControllerTest extends FunctionalTest {
|
|||||||
*/
|
*/
|
||||||
public function testChildOfDraft() {
|
public function testChildOfDraft() {
|
||||||
RootURLController::reset();
|
RootURLController::reset();
|
||||||
Config::inst()->update('SiteTree', 'nested_urls', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
|
||||||
|
|
||||||
$draft = new Page();
|
$draft = new Page();
|
||||||
$draft->Title = 'Root Leve Draft Page';
|
$draft->Title = 'Root Leve Draft Page';
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SilverStripe\CMS\Controllers\RootURLController;
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
@ -11,7 +14,7 @@ class RootURLControllerTest extends SapphireTest {
|
|||||||
|
|
||||||
SiteTree::config()->nested_urls = false;
|
SiteTree::config()->nested_urls = false;
|
||||||
$this->assertEquals('home', RootURLController::get_homepage_link());
|
$this->assertEquals('home', RootURLController::get_homepage_link());
|
||||||
Config::inst()->update('SiteTree', 'nested_urls', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
|
||||||
$this->assertEquals('home', RootURLController::get_homepage_link());
|
$this->assertEquals('home', RootURLController::get_homepage_link());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\Security\Permission;
|
use SilverStripe\Security\Permission;
|
||||||
|
use SilverStripe\CMS\Controllers\SilverStripeNavigator;
|
||||||
|
use SilverStripe\CMS\Controllers\SilverStripeNavigatorItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
@ -17,7 +20,7 @@ class SilverStripeNavigatorTest extends SapphireTest {
|
|||||||
|
|
||||||
$items = $navigator->getItems();
|
$items = $navigator->getItems();
|
||||||
$classes = array_map('get_class', $items->toArray());
|
$classes = array_map('get_class', $items->toArray());
|
||||||
$this->assertContains('SilverStripeNavigatorItem_StageLink', $classes,
|
$this->assertContains('SilverStripe\\CMS\\Controllers\\SilverStripeNavigatorItem_StageLink', $classes,
|
||||||
'Adds default classes'
|
'Adds default classes'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -26,11 +26,11 @@ class ErrorPageFileExtensionTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testErrorPage() {
|
public function testErrorPage() {
|
||||||
// Get and publish records
|
// Get and publish records
|
||||||
$notFoundPage = $this->objFromFixture('ErrorPage', '404');
|
$notFoundPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '404');
|
||||||
$notFoundPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$notFoundPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
$notFoundLink = $notFoundPage->Link();
|
$notFoundLink = $notFoundPage->Link();
|
||||||
|
|
||||||
$disallowedPage = $this->objFromFixture('ErrorPage', '403');
|
$disallowedPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '403');
|
||||||
$disallowedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$disallowedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
$disallowedLink = $disallowedPage->Link();
|
$disallowedLink = $disallowedPage->Link();
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\CMS\Model\ErrorPage;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -21,7 +23,7 @@ class ErrorPageTest extends FunctionalTest {
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
// Set temporary asset backend store
|
// Set temporary asset backend store
|
||||||
AssetStoreTest_SpyStore::activate('ErrorPageTest');
|
AssetStoreTest_SpyStore::activate('ErrorPageTest');
|
||||||
Config::inst()->update('ErrorPage', 'enable_static_file', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\ErrorPage', 'enable_static_file', true);
|
||||||
Config::inst()->update('Director', 'environment_type', 'live');
|
Config::inst()->update('Director', 'environment_type', 'live');
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
}
|
}
|
||||||
@ -32,7 +34,7 @@ class ErrorPageTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function test404ErrorPage() {
|
public function test404ErrorPage() {
|
||||||
$page = $this->objFromFixture('ErrorPage', '404');
|
$page = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '404');
|
||||||
// ensure that the errorpage exists as a physical file
|
// ensure that the errorpage exists as a physical file
|
||||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
|
|
||||||
@ -49,7 +51,7 @@ class ErrorPageTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testBehaviourOfShowInMenuAndShowInSearchFlags() {
|
public function testBehaviourOfShowInMenuAndShowInSearchFlags() {
|
||||||
$page = $this->objFromFixture('ErrorPage', '404');
|
$page = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '404');
|
||||||
|
|
||||||
/* Don't show the error page in the menus */
|
/* Don't show the error page in the menus */
|
||||||
$this->assertEquals($page->ShowInMenus, 0, 'Don\'t show the error page in the menus');
|
$this->assertEquals($page->ShowInMenus, 0, 'Don\'t show the error page in the menus');
|
||||||
@ -59,7 +61,7 @@ class ErrorPageTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testBehaviourOf403() {
|
public function testBehaviourOf403() {
|
||||||
$page = $this->objFromFixture('ErrorPage', '403');
|
$page = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '403');
|
||||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
|
|
||||||
$response = $this->get($page->RelativeLink());
|
$response = $this->get($page->RelativeLink());
|
||||||
@ -70,7 +72,7 @@ class ErrorPageTest extends FunctionalTest {
|
|||||||
|
|
||||||
public function testSecurityError() {
|
public function testSecurityError() {
|
||||||
// Generate 404 page
|
// Generate 404 page
|
||||||
$page = $this->objFromFixture('ErrorPage', '404');
|
$page = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '404');
|
||||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
|
|
||||||
// Test invalid action
|
// Test invalid action
|
||||||
@ -104,7 +106,7 @@ class ErrorPageTest extends FunctionalTest {
|
|||||||
* Test fallback to file generation API with enable_static_file disabled
|
* Test fallback to file generation API with enable_static_file disabled
|
||||||
*/
|
*/
|
||||||
public function testGeneratedFile() {
|
public function testGeneratedFile() {
|
||||||
Config::inst()->update('ErrorPage', 'enable_static_file', false);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\ErrorPage', 'enable_static_file', false);
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
|
|
||||||
$page = new ErrorPage();
|
$page = new ErrorPage();
|
||||||
|
@ -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
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\CMS\Model\VirtualPage;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests link tracking to files and images.
|
* Tests link tracking to files and images.
|
||||||
@ -157,8 +159,8 @@ class FileLinkTrackingTest extends SapphireTest {
|
|||||||
$file->write();
|
$file->write();
|
||||||
|
|
||||||
// Caching hack
|
// Caching hack
|
||||||
Versioned::prepopulate_versionnumber_cache('SiteTree', 'Stage', array($page->ID));
|
Versioned::prepopulate_versionnumber_cache('SilverStripe\\CMS\\Model\\SiteTree', 'Stage', array($page->ID));
|
||||||
Versioned::prepopulate_versionnumber_cache('SiteTree', 'Live', array($page->ID));
|
Versioned::prepopulate_versionnumber_cache('SilverStripe\\CMS\\Model\\SiteTree', 'Live', array($page->ID));
|
||||||
|
|
||||||
// Confirm that the page hasn't gone green.
|
// Confirm that the page hasn't gone green.
|
||||||
$this->assertFalse($page->getIsModifiedOnStage());
|
$this->assertFalse($page->getIsModifiedOnStage());
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Model\RedirectorPage;
|
||||||
|
use SilverStripe\CMS\Model\RedirectorPage_Controller;
|
||||||
|
|
||||||
class RedirectorPageTest extends FunctionalTest {
|
class RedirectorPageTest extends FunctionalTest {
|
||||||
protected static $fixture_file = 'RedirectorPageTest.yml';
|
protected static $fixture_file = 'RedirectorPageTest.yml';
|
||||||
protected static $use_draft_site = true;
|
protected static $use_draft_site = true;
|
||||||
@ -7,14 +10,14 @@ class RedirectorPageTest extends FunctionalTest {
|
|||||||
|
|
||||||
public function testGoodRedirectors() {
|
public function testGoodRedirectors() {
|
||||||
/* For good redirectors, the final destination URL will be returned */
|
/* For good redirectors, the final destination URL will be returned */
|
||||||
$this->assertEquals("http://www.google.com", $this->objFromFixture('RedirectorPage','goodexternal')->Link());
|
$this->assertEquals("http://www.google.com", $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage','goodexternal')->Link());
|
||||||
$this->assertEquals(Director::baseURL() . "redirection-dest/", $this->objFromFixture('RedirectorPage','goodinternal')->redirectionLink());
|
$this->assertEquals(Director::baseURL() . "redirection-dest/", $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage','goodinternal')->redirectionLink());
|
||||||
$this->assertEquals(Director::baseURL() . "redirection-dest/", $this->objFromFixture('RedirectorPage','goodinternal')->Link());
|
$this->assertEquals(Director::baseURL() . "redirection-dest/", $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage','goodinternal')->Link());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyRedirectors() {
|
public function testEmptyRedirectors() {
|
||||||
/* If a redirector page is misconfigured, then its link method will just return the usual URLSegment-generated value */
|
/* If a redirector page is misconfigured, then its link method will just return the usual URLSegment-generated value */
|
||||||
$page1 = $this->objFromFixture('RedirectorPage','badexternal');
|
$page1 = $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage','badexternal');
|
||||||
$this->assertEquals(Director::baseURL() . 'bad-external/', $page1->Link());
|
$this->assertEquals(Director::baseURL() . 'bad-external/', $page1->Link());
|
||||||
|
|
||||||
/* An error message will be shown if you visit it */
|
/* An error message will be shown if you visit it */
|
||||||
@ -22,7 +25,7 @@ class RedirectorPageTest extends FunctionalTest {
|
|||||||
$this->assertContains('message-setupWithoutRedirect', $content);
|
$this->assertContains('message-setupWithoutRedirect', $content);
|
||||||
|
|
||||||
/* This also applies for internal links */
|
/* This also applies for internal links */
|
||||||
$page2 = $this->objFromFixture('RedirectorPage','badinternal');
|
$page2 = $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage','badinternal');
|
||||||
$this->assertEquals(Director::baseURL() . 'bad-internal/', $page2->Link());
|
$this->assertEquals(Director::baseURL() . 'bad-internal/', $page2->Link());
|
||||||
$content = $this->get(Director::makeRelative($page2->Link()))->getBody();
|
$content = $this->get(Director::makeRelative($page2->Link()))->getBody();
|
||||||
$this->assertContains('message-setupWithoutRedirect', $content);
|
$this->assertContains('message-setupWithoutRedirect', $content);
|
||||||
@ -30,14 +33,14 @@ class RedirectorPageTest extends FunctionalTest {
|
|||||||
|
|
||||||
public function testReflexiveAndTransitiveInternalRedirectors() {
|
public function testReflexiveAndTransitiveInternalRedirectors() {
|
||||||
/* Reflexive redirectors are those that point to themselves. They should behave the same as an empty redirector */
|
/* Reflexive redirectors are those that point to themselves. They should behave the same as an empty redirector */
|
||||||
$page = $this->objFromFixture('RedirectorPage','reflexive');
|
$page = $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage','reflexive');
|
||||||
$this->assertEquals(Director::baseURL() . 'reflexive/', $page->Link());
|
$this->assertEquals(Director::baseURL() . 'reflexive/', $page->Link());
|
||||||
$content = $this->get(Director::makeRelative($page->Link()))->getBody();
|
$content = $this->get(Director::makeRelative($page->Link()))->getBody();
|
||||||
$this->assertContains('message-setupWithoutRedirect', $content);
|
$this->assertContains('message-setupWithoutRedirect', $content);
|
||||||
|
|
||||||
/* Transitive redirectors are those that point to another redirector page. They should send people to the URLSegment
|
/* Transitive redirectors are those that point to another redirector page. They should send people to the URLSegment
|
||||||
* of the destination page - the middle-stop, so to speak. That should redirect to the final destination */
|
* of the destination page - the middle-stop, so to speak. That should redirect to the final destination */
|
||||||
$page = $this->objFromFixture('RedirectorPage','transitive');
|
$page = $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage','transitive');
|
||||||
$this->assertEquals(Director::baseURL() . 'good-internal/', $page->Link());
|
$this->assertEquals(Director::baseURL() . 'good-internal/', $page->Link());
|
||||||
|
|
||||||
$this->autoFollowRedirection = false;
|
$this->autoFollowRedirection = false;
|
||||||
@ -46,7 +49,7 @@ class RedirectorPageTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testExternalURLGetsPrefixIfNotSet() {
|
public function testExternalURLGetsPrefixIfNotSet() {
|
||||||
$page = $this->objFromFixture('RedirectorPage', 'externalnoprefix');
|
$page = $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage', 'externalnoprefix');
|
||||||
$this->assertEquals($page->ExternalURL, 'http://google.com', 'onBeforeWrite has prefixed with http');
|
$this->assertEquals($page->ExternalURL, 'http://google.com', 'onBeforeWrite has prefixed with http');
|
||||||
$page->write();
|
$page->write();
|
||||||
$this->assertEquals($page->ExternalURL, 'http://google.com', 'onBeforeWrite will not double prefix if written again!');
|
$this->assertEquals($page->ExternalURL, 'http://google.com', 'onBeforeWrite will not double prefix if written again!');
|
||||||
@ -70,7 +73,7 @@ class RedirectorPageTest extends FunctionalTest {
|
|||||||
* Test that we can trigger a redirection before RedirectorPage_Controller::init() is called
|
* Test that we can trigger a redirection before RedirectorPage_Controller::init() is called
|
||||||
*/
|
*/
|
||||||
public function testRedirectRespectsFinishedResponse() {
|
public function testRedirectRespectsFinishedResponse() {
|
||||||
$page = $this->objFromFixture('RedirectorPage', 'goodinternal');
|
$page = $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage', 'goodinternal');
|
||||||
RedirectorPage_Controller::add_extension('RedirectorPageTest_RedirectExtension');
|
RedirectorPage_Controller::add_extension('RedirectorPageTest_RedirectExtension');
|
||||||
|
|
||||||
$response = $this->get($page->regularLink());
|
$response = $this->get($page->regularLink());
|
||||||
|
@ -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
|
||||||
|
@ -56,8 +56,8 @@ class SiteTreeActionsTest extends FunctionalTest {
|
|||||||
$page->deleteFromStage('Stage');
|
$page->deleteFromStage('Stage');
|
||||||
|
|
||||||
// Get the live version of the page
|
// Get the live version of the page
|
||||||
$page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID");
|
$page = Versioned::get_one_by_stage("SilverStripe\\CMS\\Model\\SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID");
|
||||||
$this->assertInstanceOf("SiteTree", $page);
|
$this->assertInstanceOf("SilverStripe\\CMS\\Model\\SiteTree", $page);
|
||||||
|
|
||||||
// Check that someone without the right permission can't delete the page
|
// Check that someone without the right permission can't delete the page
|
||||||
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'cmsnodeleteeditor');
|
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'cmsnodeleteeditor');
|
||||||
@ -108,8 +108,8 @@ class SiteTreeActionsTest extends FunctionalTest {
|
|||||||
$page->deleteFromStage('Stage');
|
$page->deleteFromStage('Stage');
|
||||||
|
|
||||||
// Get the live version of the page
|
// Get the live version of the page
|
||||||
$page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID");
|
$page = Versioned::get_one_by_stage("SilverStripe\\CMS\\Model\\SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID");
|
||||||
$this->assertInstanceOf('SiteTree', $page);
|
$this->assertInstanceOf('SilverStripe\\CMS\\Model\\SiteTree', $page);
|
||||||
|
|
||||||
$actions = $page->getCMSActions();
|
$actions = $page->getCMSActions();
|
||||||
|
|
||||||
|
@ -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() {
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\CMS\Model\VirtualPage;
|
||||||
|
use SilverStripe\CMS\Model\RedirectorPage;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@see SiteTreeLinkTracking} broken links feature: LinkTracking
|
* Tests {@see SiteTreeLinkTracking} broken links feature: LinkTracking
|
||||||
@ -94,10 +97,10 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
|
|||||||
$this->assertTrue($obj->publishRecursive());
|
$this->assertTrue($obj->publishRecursive());
|
||||||
// Confirm that it isn't marked as broken to begin with
|
// Confirm that it isn't marked as broken to begin with
|
||||||
$obj->flushCache();
|
$obj->flushCache();
|
||||||
$obj = DataObject::get_by_id("SiteTree", $obj->ID);
|
$obj = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $obj->ID);
|
||||||
$this->assertEquals(0, $obj->HasBrokenFile);
|
$this->assertEquals(0, $obj->HasBrokenFile);
|
||||||
|
|
||||||
$liveObj = Versioned::get_one_by_stage("SiteTree", "Live","\"SiteTree\".\"ID\" = $obj->ID");
|
$liveObj = Versioned::get_one_by_stage("SilverStripe\\CMS\\Model\\SiteTree", "Live","\"SiteTree\".\"ID\" = $obj->ID");
|
||||||
$this->assertEquals(0, $liveObj->HasBrokenFile);
|
$this->assertEquals(0, $liveObj->HasBrokenFile);
|
||||||
|
|
||||||
// Delete the file
|
// Delete the file
|
||||||
@ -105,12 +108,12 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
|
|||||||
|
|
||||||
// Confirm that it is marked as broken in stage
|
// Confirm that it is marked as broken in stage
|
||||||
$obj->flushCache();
|
$obj->flushCache();
|
||||||
$obj = DataObject::get_by_id("SiteTree", $obj->ID);
|
$obj = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $obj->ID);
|
||||||
$this->assertEquals(1, $obj->HasBrokenFile);
|
$this->assertEquals(1, $obj->HasBrokenFile);
|
||||||
|
|
||||||
// Publishing this page marks it as broken on live too
|
// Publishing this page marks it as broken on live too
|
||||||
$obj->publishRecursive();
|
$obj->publishRecursive();
|
||||||
$liveObj = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $obj->ID");
|
$liveObj = Versioned::get_one_by_stage("SilverStripe\\CMS\\Model\\SiteTree", "Live", "\"SiteTree\".\"ID\" = $obj->ID");
|
||||||
$this->assertEquals(1, $liveObj->HasBrokenFile);
|
$this->assertEquals(1, $liveObj->HasBrokenFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,41 +198,41 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
|
|||||||
|
|
||||||
// Unpublish the source page, confirm that the page 2 and RP has a broken link on published
|
// Unpublish the source page, confirm that the page 2 and RP has a broken link on published
|
||||||
$p->doUnpublish();
|
$p->doUnpublish();
|
||||||
$p2Live = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $p2->ID);
|
$p2Live = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $p2->ID);
|
||||||
$rpLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $rp->ID);
|
$rpLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $rp->ID);
|
||||||
$this->assertEquals(1, $p2Live->HasBrokenLink);
|
$this->assertEquals(1, $p2Live->HasBrokenLink);
|
||||||
$this->assertEquals(1, $rpLive->HasBrokenLink);
|
$this->assertEquals(1, $rpLive->HasBrokenLink);
|
||||||
|
|
||||||
// Delete the source page, confirm that the VP, RP and page 2 have broken links on draft
|
// Delete the source page, confirm that the VP, RP and page 2 have broken links on draft
|
||||||
$p->delete();
|
$p->delete();
|
||||||
$vp->flushCache();
|
$vp->flushCache();
|
||||||
$vp = DataObject::get_by_id('SiteTree', $vp->ID);
|
$vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID);
|
||||||
$p2->flushCache();
|
$p2->flushCache();
|
||||||
$p2 = DataObject::get_by_id('SiteTree', $p2->ID);
|
$p2 = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $p2->ID);
|
||||||
$rp->flushCache();
|
$rp->flushCache();
|
||||||
$rp = DataObject::get_by_id('SiteTree', $rp->ID);
|
$rp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $rp->ID);
|
||||||
$this->assertEquals(1, $p2->HasBrokenLink);
|
$this->assertEquals(1, $p2->HasBrokenLink);
|
||||||
$this->assertEquals(1, $vp->HasBrokenLink);
|
$this->assertEquals(1, $vp->HasBrokenLink);
|
||||||
$this->assertEquals(1, $rp->HasBrokenLink);
|
$this->assertEquals(1, $rp->HasBrokenLink);
|
||||||
|
|
||||||
// Restore the page to stage, confirm that this fixes the links
|
// Restore the page to stage, confirm that this fixes the links
|
||||||
$p = Versioned::get_latest_version('SiteTree', $pageID);
|
$p = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $pageID);
|
||||||
$p->doRestoreToStage();
|
$p->doRestoreToStage();
|
||||||
|
|
||||||
$p2->flushCache();
|
$p2->flushCache();
|
||||||
$p2 = DataObject::get_by_id('SiteTree', $p2->ID);
|
$p2 = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $p2->ID);
|
||||||
$vp->flushCache();
|
$vp->flushCache();
|
||||||
$vp = DataObject::get_by_id('SiteTree', $vp->ID);
|
$vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID);
|
||||||
$rp->flushCache();
|
$rp->flushCache();
|
||||||
$rp = DataObject::get_by_id('SiteTree', $rp->ID);
|
$rp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $rp->ID);
|
||||||
$this->assertFalse((bool)$p2->HasBrokenLink);
|
$this->assertFalse((bool)$p2->HasBrokenLink);
|
||||||
$this->assertFalse((bool)$vp->HasBrokenLink);
|
$this->assertFalse((bool)$vp->HasBrokenLink);
|
||||||
$this->assertFalse((bool)$rp->HasBrokenLink);
|
$this->assertFalse((bool)$rp->HasBrokenLink);
|
||||||
|
|
||||||
// Publish and confirm that the p2 and RP broken links are fixed on published
|
// Publish and confirm that the p2 and RP broken links are fixed on published
|
||||||
$this->assertTrue($p->publishRecursive());
|
$this->assertTrue($p->publishRecursive());
|
||||||
$p2Live = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $p2->ID);
|
$p2Live = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $p2->ID);
|
||||||
$rpLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $rp->ID);
|
$rpLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $rp->ID);
|
||||||
$this->assertFalse((bool)$p2Live->HasBrokenLink);
|
$this->assertFalse((bool)$p2Live->HasBrokenLink);
|
||||||
$this->assertFalse((bool)$rpLive->HasBrokenLink);
|
$this->assertFalse((bool)$rpLive->HasBrokenLink);
|
||||||
|
|
||||||
@ -273,25 +276,25 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
|
|||||||
$p->delete();
|
$p->delete();
|
||||||
|
|
||||||
$vp->flushCache();
|
$vp->flushCache();
|
||||||
$vp = DataObject::get_by_id('SiteTree', $vp->ID);
|
$vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID);
|
||||||
$p2->flushCache();
|
$p2->flushCache();
|
||||||
$p2 = DataObject::get_by_id('SiteTree', $p2->ID);
|
$p2 = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $p2->ID);
|
||||||
$rp->flushCache();
|
$rp->flushCache();
|
||||||
$rp = DataObject::get_by_id('SiteTree', $rp->ID);
|
$rp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $rp->ID);
|
||||||
$this->assertEquals(1, $p2->HasBrokenLink);
|
$this->assertEquals(1, $p2->HasBrokenLink);
|
||||||
$this->assertEquals(1, $vp->HasBrokenLink);
|
$this->assertEquals(1, $vp->HasBrokenLink);
|
||||||
$this->assertEquals(1, $rp->HasBrokenLink);
|
$this->assertEquals(1, $rp->HasBrokenLink);
|
||||||
|
|
||||||
// Call doRevertToLive and confirm that broken links are restored
|
// Call doRevertToLive and confirm that broken links are restored
|
||||||
$pLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $pID);
|
$pLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $pID);
|
||||||
$pLive->doRevertToLive();
|
$pLive->doRevertToLive();
|
||||||
|
|
||||||
$p2->flushCache();
|
$p2->flushCache();
|
||||||
$p2 = DataObject::get_by_id('SiteTree', $p2->ID);
|
$p2 = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $p2->ID);
|
||||||
$vp->flushCache();
|
$vp->flushCache();
|
||||||
$vp = DataObject::get_by_id('SiteTree', $vp->ID);
|
$vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID);
|
||||||
$rp->flushCache();
|
$rp->flushCache();
|
||||||
$rp = DataObject::get_by_id('SiteTree', $rp->ID);
|
$rp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $rp->ID);
|
||||||
$this->assertFalse((bool)$p2->HasBrokenLink);
|
$this->assertFalse((bool)$p2->HasBrokenLink);
|
||||||
$this->assertFalse((bool)$vp->HasBrokenLink);
|
$this->assertFalse((bool)$vp->HasBrokenLink);
|
||||||
$this->assertFalse((bool)$rp->HasBrokenLink);
|
$this->assertFalse((bool)$rp->HasBrokenLink);
|
||||||
|
@ -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,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
class SiteTreeHTMLEditorFieldTest extends FunctionalTest {
|
class SiteTreeHTMLEditorFieldTest extends FunctionalTest {
|
||||||
protected static $fixture_file = 'SiteTreeHTMLEditorFieldTest.yml';
|
protected static $fixture_file = 'SiteTreeHTMLEditorFieldTest.yml';
|
||||||
|
|
||||||
@ -24,11 +26,11 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testLinkTracking() {
|
public function testLinkTracking() {
|
||||||
$sitetree = $this->objFromFixture('SiteTree', 'home');
|
$sitetree = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'home');
|
||||||
$editor = new HTMLEditorField('Content');
|
$editor = new HTMLEditorField('Content');
|
||||||
|
|
||||||
$aboutID = $this->idFromFixture('SiteTree', 'about');
|
$aboutID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'about');
|
||||||
$contactID = $this->idFromFixture('SiteTree', 'contact');
|
$contactID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'contact');
|
||||||
|
|
||||||
$editor->setValue("<a href=\"[sitetree_link,id=$aboutID]\">Example Link</a>");
|
$editor->setValue("<a href=\"[sitetree_link,id=$aboutID]\">Example Link</a>");
|
||||||
$editor->saveInto($sitetree);
|
$editor->saveInto($sitetree);
|
||||||
@ -63,7 +65,7 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testFileLinkTracking() {
|
public function testFileLinkTracking() {
|
||||||
$sitetree = $this->objFromFixture('SiteTree', 'home');
|
$sitetree = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'home');
|
||||||
$editor = new HTMLEditorField('Content');
|
$editor = new HTMLEditorField('Content');
|
||||||
$fileID = $this->idFromFixture('File', 'example_file');
|
$fileID = $this->idFromFixture('File', 'example_file');
|
||||||
|
|
||||||
@ -120,7 +122,7 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testImageTracking() {
|
public function testImageTracking() {
|
||||||
$sitetree = $this->objFromFixture('SiteTree', 'home');
|
$sitetree = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'home');
|
||||||
$editor = new HTMLEditorField('Content');
|
$editor = new HTMLEditorField('Content');
|
||||||
$file = $this->objFromFixture('Image', 'example_image');
|
$file = $this->objFromFixture('Image', 'example_image');
|
||||||
|
|
||||||
@ -156,7 +158,7 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest {
|
|||||||
|
|
||||||
$editor->setValue(sprintf (
|
$editor->setValue(sprintf (
|
||||||
'<p><a href="[sitetree_link,id=%d]">Working Link</a></p>',
|
'<p><a href="[sitetree_link,id=%d]">Working Link</a></p>',
|
||||||
$this->idFromFixture('SiteTree', 'home')
|
$this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'home')
|
||||||
));
|
));
|
||||||
$sitetree->HasBrokenLink = false;
|
$sitetree->HasBrokenLink = false;
|
||||||
$editor->saveInto($sitetree);
|
$editor->saveInto($sitetree);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
SiteTree:
|
SilverStripe\CMS\Model\SiteTree:
|
||||||
home:
|
home:
|
||||||
Title: Home Page
|
Title: Home Page
|
||||||
about:
|
about:
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Model\SiteTreeLinkTracking_Parser;
|
||||||
|
|
||||||
class SiteTreeLinkTrackingTest extends SapphireTest {
|
class SiteTreeLinkTrackingTest extends SapphireTest {
|
||||||
|
|
||||||
protected function isBroken($content) {
|
protected function isBroken($content) {
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -14,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() {
|
||||||
@ -76,7 +78,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
$page->delete();
|
$page->delete();
|
||||||
|
|
||||||
// Re-fetch the page from the live site
|
// Re-fetch the page from the live site
|
||||||
$page = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".\"ID\" = $pageID");
|
$page = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', "\"SiteTree\".\"ID\" = $pageID");
|
||||||
|
|
||||||
// subadmin has edit rights on that page
|
// subadmin has edit rights on that page
|
||||||
$member = $this->objFromFixture('SilverStripe\\Security\\Member','subadmin');
|
$member = $this->objFromFixture('SilverStripe\\Security\\Member','subadmin');
|
||||||
@ -124,7 +126,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
$page->delete();
|
$page->delete();
|
||||||
|
|
||||||
// We'll need to resurrect the page from the version cache to test this case
|
// We'll need to resurrect the page from the version cache to test this case
|
||||||
$page = Versioned::get_latest_version('SiteTree', $pageID);
|
$page = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $pageID);
|
||||||
|
|
||||||
// subadmin had edit rights on that page, but now it's gone
|
// subadmin had edit rights on that page, but now it's gone
|
||||||
$member = $this->objFromFixture('SilverStripe\\Security\\Member','subadmin');
|
$member = $this->objFromFixture('SilverStripe\\Security\\Member','subadmin');
|
||||||
@ -390,7 +392,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
$page->deleteFromStage('Stage');
|
$page->deleteFromStage('Stage');
|
||||||
|
|
||||||
// Get the live version of the page
|
// Get the live version of the page
|
||||||
$page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID");
|
$page = Versioned::get_one_by_stage("SilverStripe\\CMS\\Model\\SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID");
|
||||||
$this->assertTrue(is_object($page), 'Versioned::get_one_by_stage() is returning an object');
|
$this->assertTrue(is_object($page), 'Versioned::get_one_by_stage() is returning an object');
|
||||||
|
|
||||||
// subadmin users
|
// subadmin users
|
||||||
|
@ -9,6 +9,9 @@ use SilverStripe\ORM\HiddenClass;
|
|||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\Security\Permission;
|
use SilverStripe\Security\Permission;
|
||||||
use SilverStripe\Security\Group;
|
use SilverStripe\Security\Group;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SilverStripe\CMS\Model\SiteTreeExtension;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -19,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(
|
||||||
@ -47,14 +50,14 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
|
|
||||||
// Disable the creation
|
// Disable the creation
|
||||||
SiteTree::config()->create_default_pages = false;
|
SiteTree::config()->create_default_pages = false;
|
||||||
singleton('SiteTree')->requireDefaultRecords();
|
singleton('SilverStripe\\CMS\\Model\\SiteTree')->requireDefaultRecords();
|
||||||
|
|
||||||
// The table should still be empty
|
// The table should still be empty
|
||||||
$this->assertEquals(DB::query('SELECT COUNT("ID") FROM "SiteTree"')->value(), 0);
|
$this->assertEquals(DB::query('SELECT COUNT("ID") FROM "SiteTree"')->value(), 0);
|
||||||
|
|
||||||
// Enable the creation
|
// Enable the creation
|
||||||
SiteTree::config()->create_default_pages = true;
|
SiteTree::config()->create_default_pages = true;
|
||||||
singleton('SiteTree')->requireDefaultRecords();
|
singleton('SilverStripe\\CMS\\Model\\SiteTree')->requireDefaultRecords();
|
||||||
|
|
||||||
// The table should now have three rows (home, about-us, contact-us)
|
// The table should now have three rows (home, about-us, contact-us)
|
||||||
$this->assertEquals(DB::query('SELECT COUNT("ID") FROM "SiteTree"')->value(), 3);
|
$this->assertEquals(DB::query('SELECT COUNT("ID") FROM "SiteTree"')->value(), 3);
|
||||||
@ -127,7 +130,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$child->Title = 'Page Title';
|
$child->Title = 'Page Title';
|
||||||
$child->setParent($parent);
|
$child->setParent($parent);
|
||||||
|
|
||||||
$this->assertInstanceOf("SiteTree", $child->Parent);
|
$this->assertInstanceOf("SilverStripe\\CMS\\Model\\SiteTree", $child->Parent);
|
||||||
$this->assertEquals("Section Title", $child->Parent->Title);
|
$this->assertEquals("Section Title", $child->Parent->Title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +157,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$oldMode = Versioned::get_reading_mode();
|
$oldMode = Versioned::get_reading_mode();
|
||||||
Versioned::set_stage(Versioned::LIVE);
|
Versioned::set_stage(Versioned::LIVE);
|
||||||
|
|
||||||
$checkSiteTree = DataObject::get_one("SiteTree", array(
|
$checkSiteTree = DataObject::get_one("SilverStripe\\CMS\\Model\\SiteTree", array(
|
||||||
'"SiteTree"."URLSegment"' => 'get-one-test-page'
|
'"SiteTree"."URLSegment"' => 'get-one-test-page'
|
||||||
));
|
));
|
||||||
$this->assertEquals("V1", $checkSiteTree->Title);
|
$this->assertEquals("V1", $checkSiteTree->Title);
|
||||||
@ -257,7 +260,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$page->delete();
|
$page->delete();
|
||||||
$this->assertTrue(!DataObject::get_by_id("Page", $pageID));
|
$this->assertTrue(!DataObject::get_by_id("Page", $pageID));
|
||||||
|
|
||||||
$deletedPage = Versioned::get_latest_version('SiteTree', $pageID);
|
$deletedPage = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $pageID);
|
||||||
$resultPage = $deletedPage->doRestoreToStage();
|
$resultPage = $deletedPage->doRestoreToStage();
|
||||||
|
|
||||||
$requeriedPage = DataObject::get_by_id("Page", $pageID);
|
$requeriedPage = DataObject::get_by_id("Page", $pageID);
|
||||||
@ -276,7 +279,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
// Check that if we restore while on the live site that the content still gets pushed to
|
// Check that if we restore while on the live site that the content still gets pushed to
|
||||||
// stage
|
// stage
|
||||||
Versioned::set_stage(Versioned::LIVE);
|
Versioned::set_stage(Versioned::LIVE);
|
||||||
$deletedPage = Versioned::get_latest_version('SiteTree', $page2ID);
|
$deletedPage = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $page2ID);
|
||||||
$deletedPage->doRestoreToStage();
|
$deletedPage->doRestoreToStage();
|
||||||
$this->assertFalse((bool)Versioned::get_one_by_stage("Page", "Live", "\"SiteTree\".\"ID\" = " . $page2ID));
|
$this->assertFalse((bool)Versioned::get_one_by_stage("Page", "Live", "\"SiteTree\".\"ID\" = " . $page2ID));
|
||||||
|
|
||||||
@ -292,7 +295,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$about = $this->objFromFixture('Page', 'about');
|
$about = $this->objFromFixture('Page', 'about');
|
||||||
$staff = $this->objFromFixture('Page', 'staff');
|
$staff = $this->objFromFixture('Page', 'staff');
|
||||||
$product = $this->objFromFixture('Page', 'product1');
|
$product = $this->objFromFixture('Page', 'product1');
|
||||||
$notFound = $this->objFromFixture('ErrorPage', '404');
|
$notFound = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '404');
|
||||||
|
|
||||||
SiteTree::config()->nested_urls = false;
|
SiteTree::config()->nested_urls = false;
|
||||||
|
|
||||||
@ -303,7 +306,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$this->assertEquals($product->ID, SiteTree::get_by_link($product->Link(), false)->ID);
|
$this->assertEquals($product->ID, SiteTree::get_by_link($product->Link(), false)->ID);
|
||||||
$this->assertEquals($notFound->ID, SiteTree::get_by_link($notFound->Link(), false)->ID);
|
$this->assertEquals($notFound->ID, SiteTree::get_by_link($notFound->Link(), false)->ID);
|
||||||
|
|
||||||
Config::inst()->update('SiteTree', 'nested_urls', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
|
||||||
|
|
||||||
$this->assertEquals($home->ID, SiteTree::get_by_link('/', false)->ID);
|
$this->assertEquals($home->ID, SiteTree::get_by_link('/', false)->ID);
|
||||||
$this->assertEquals($home->ID, SiteTree::get_by_link('/home/', false)->ID);
|
$this->assertEquals($home->ID, SiteTree::get_by_link('/home/', false)->ID);
|
||||||
@ -321,7 +324,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$about = $this->objFromFixture('Page', 'about');
|
$about = $this->objFromFixture('Page', 'about');
|
||||||
$staff = $this->objFromFixture('Page', 'staff');
|
$staff = $this->objFromFixture('Page', 'staff');
|
||||||
|
|
||||||
Config::inst()->update('SiteTree', 'nested_urls', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
|
||||||
|
|
||||||
$this->assertEquals('about-us/', $about->RelativeLink(), 'Matches URLSegment on top level without parameters');
|
$this->assertEquals('about-us/', $about->RelativeLink(), 'Matches URLSegment on top level without parameters');
|
||||||
$this->assertEquals('about-us/my-staff/', $staff->RelativeLink(), 'Matches URLSegment plus parent on second level without parameters');
|
$this->assertEquals('about-us/my-staff/', $staff->RelativeLink(), 'Matches URLSegment plus parent on second level without parameters');
|
||||||
@ -340,7 +343,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$parent = $this->objFromFixture('Page', 'about');
|
$parent = $this->objFromFixture('Page', 'about');
|
||||||
$child = $this->objFromFixture('Page', 'staff');
|
$child = $this->objFromFixture('Page', 'staff');
|
||||||
|
|
||||||
Config::inst()->update('SiteTree', 'nested_urls', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
|
||||||
|
|
||||||
$child->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$child->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
$parent->URLSegment = 'changed-on-live';
|
$parent->URLSegment = 'changed-on-live';
|
||||||
@ -354,7 +357,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testDeleteFromStageOperatesRecursively() {
|
public function testDeleteFromStageOperatesRecursively() {
|
||||||
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', false);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', false);
|
||||||
$pageAbout = $this->objFromFixture('Page', 'about');
|
$pageAbout = $this->objFromFixture('Page', 'about');
|
||||||
$pageStaff = $this->objFromFixture('Page', 'staff');
|
$pageStaff = $this->objFromFixture('Page', 'staff');
|
||||||
$pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate');
|
$pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate');
|
||||||
@ -364,7 +367,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$this->assertFalse(DataObject::get_by_id('Page', $pageAbout->ID));
|
$this->assertFalse(DataObject::get_by_id('Page', $pageAbout->ID));
|
||||||
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
|
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
|
||||||
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
|
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
|
||||||
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDeleteFromStageOperatesRecursivelyStrict() {
|
public function testDeleteFromStageOperatesRecursivelyStrict() {
|
||||||
@ -388,7 +391,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testDeleteFromLiveOperatesRecursively() {
|
public function testDeleteFromLiveOperatesRecursively() {
|
||||||
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', false);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', false);
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
|
|
||||||
$pageAbout = $this->objFromFixture('Page', 'about');
|
$pageAbout = $this->objFromFixture('Page', 'about');
|
||||||
@ -408,11 +411,11 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
|
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
|
||||||
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
|
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
|
||||||
Versioned::set_stage(Versioned::DRAFT);
|
Versioned::set_stage(Versioned::DRAFT);
|
||||||
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUnpublishDoesNotDeleteChildrenWithLooseHierachyOn() {
|
public function testUnpublishDoesNotDeleteChildrenWithLooseHierachyOn() {
|
||||||
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', false);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', false);
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
|
|
||||||
$pageAbout = $this->objFromFixture('Page', 'about');
|
$pageAbout = $this->objFromFixture('Page', 'about');
|
||||||
@ -430,7 +433,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
|
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
|
||||||
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
|
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
|
||||||
Versioned::set_stage(Versioned::DRAFT);
|
Versioned::set_stage(Versioned::DRAFT);
|
||||||
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDeleteFromLiveOperatesRecursivelyStrict() {
|
public function testDeleteFromLiveOperatesRecursivelyStrict() {
|
||||||
@ -509,20 +512,20 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
public function testCreatePermissions() {
|
public function testCreatePermissions() {
|
||||||
// Test logged out users cannot create
|
// Test logged out users cannot create
|
||||||
$this->logOut();
|
$this->logOut();
|
||||||
$this->assertFalse(singleton('SiteTree')->canCreate());
|
$this->assertFalse(singleton('SilverStripe\\CMS\\Model\\SiteTree')->canCreate());
|
||||||
|
|
||||||
// Login with another permission
|
// Login with another permission
|
||||||
$this->logInWithPermission('DUMMY');
|
$this->logInWithPermission('DUMMY');
|
||||||
$this->assertFalse(singleton('SiteTree')->canCreate());
|
$this->assertFalse(singleton('SilverStripe\\CMS\\Model\\SiteTree')->canCreate());
|
||||||
|
|
||||||
// Login with basic CMS permission
|
// Login with basic CMS permission
|
||||||
$perms = SiteConfig::config()->required_permission;
|
$perms = SiteConfig::config()->required_permission;
|
||||||
$this->logInWithPermission(reset($perms));
|
$this->logInWithPermission(reset($perms));
|
||||||
$this->assertTrue(singleton('SiteTree')->canCreate());
|
$this->assertTrue(singleton('SilverStripe\\CMS\\Model\\SiteTree')->canCreate());
|
||||||
|
|
||||||
// Test creation underneath a parent which this user doesn't have access to
|
// Test creation underneath a parent which this user doesn't have access to
|
||||||
$parent = $this->objFromFixture('Page', 'about');
|
$parent = $this->objFromFixture('Page', 'about');
|
||||||
$this->assertFalse(singleton('SiteTree')->canCreate(null, array('Parent' => $parent)));
|
$this->assertFalse(singleton('SilverStripe\\CMS\\Model\\SiteTree')->canCreate(null, array('Parent' => $parent)));
|
||||||
|
|
||||||
// Test creation underneath a parent which doesn't allow a certain child
|
// Test creation underneath a parent which doesn't allow a certain child
|
||||||
$parentB = new SiteTreeTest_ClassB();
|
$parentB = new SiteTreeTest_ClassB();
|
||||||
@ -632,10 +635,10 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testLinkShortcodeHandler() {
|
public function testLinkShortcodeHandler() {
|
||||||
$aboutPage = $this->objFromFixture('Page', 'about');
|
$aboutPage = $this->objFromFixture('Page', 'about');
|
||||||
$redirectPage = $this->objFromFixture('RedirectorPage', 'external');
|
$redirectPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage', 'external');
|
||||||
|
|
||||||
$parser = new ShortcodeParser();
|
$parser = new ShortcodeParser();
|
||||||
$parser->register('sitetree_link', array('SiteTree', 'link_shortcode_handler'));
|
$parser->register('sitetree_link', array('SilverStripe\\CMS\\Model\\SiteTree', 'link_shortcode_handler'));
|
||||||
|
|
||||||
$aboutShortcode = sprintf('[sitetree_link,id=%d]', $aboutPage->ID);
|
$aboutShortcode = sprintf('[sitetree_link,id=%d]', $aboutPage->ID);
|
||||||
$aboutEnclosed = sprintf('[sitetree_link,id=%d]Example Content[/sitetree_link]', $aboutPage->ID);
|
$aboutEnclosed = sprintf('[sitetree_link,id=%d]Example Content[/sitetree_link]', $aboutPage->ID);
|
||||||
@ -671,7 +674,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testIsCurrent() {
|
public function testIsCurrent() {
|
||||||
$aboutPage = $this->objFromFixture('Page', 'about');
|
$aboutPage = $this->objFromFixture('Page', 'about');
|
||||||
$errorPage = $this->objFromFixture('ErrorPage', '404');
|
$errorPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '404');
|
||||||
|
|
||||||
Director::set_current_page($aboutPage);
|
Director::set_current_page($aboutPage);
|
||||||
$this->assertTrue($aboutPage->isCurrent(), 'Assert that basic isSection checks works.');
|
$this->assertTrue($aboutPage->isCurrent(), 'Assert that basic isSection checks works.');
|
||||||
@ -683,7 +686,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
|
|
||||||
Director::set_current_page($aboutPage);
|
Director::set_current_page($aboutPage);
|
||||||
$this->assertTrue (
|
$this->assertTrue (
|
||||||
DataObject::get_one('SiteTree', array(
|
DataObject::get_one('SilverStripe\\CMS\\Model\\SiteTree', array(
|
||||||
'"SiteTree"."Title"' => 'About Us'
|
'"SiteTree"."Title"' => 'About Us'
|
||||||
))->isCurrent(),
|
))->isCurrent(),
|
||||||
'Assert that isCurrent works on another instance with the same ID.'
|
'Assert that isCurrent works on another instance with the same ID.'
|
||||||
@ -721,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'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -754,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'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -783,7 +786,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$sitetree->URLSegment = 'home';
|
$sitetree->URLSegment = 'home';
|
||||||
$this->assertFalse($sitetree->validURLSegment(), 'Conflicts are still recognised with a ParentID value');
|
$this->assertFalse($sitetree->validURLSegment(), 'Conflicts are still recognised with a ParentID value');
|
||||||
|
|
||||||
Config::inst()->update('SiteTree', 'nested_urls', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
|
||||||
|
|
||||||
$sitetree->ParentID = 0;
|
$sitetree->ParentID = 0;
|
||||||
$sitetree->URLSegment = 'home';
|
$sitetree->URLSegment = 'home';
|
||||||
@ -812,7 +815,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
* @covers SiteTree::validURLSegment
|
* @covers SiteTree::validURLSegment
|
||||||
*/
|
*/
|
||||||
public function testValidURLSegmentControllerConflicts() {
|
public function testValidURLSegmentControllerConflicts() {
|
||||||
Config::inst()->update('SiteTree', 'nested_urls', true);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
|
||||||
|
|
||||||
$sitetree = new SiteTree();
|
$sitetree = new SiteTree();
|
||||||
$sitetree->ParentID = $this->idFromFixture('SiteTreeTest_Conflicted', 'parent');
|
$sitetree->ParentID = $this->idFromFixture('SiteTreeTest_Conflicted', 'parent');
|
||||||
@ -850,13 +853,13 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
|
|
||||||
$sitetree->URLSegment = 'brötchen';
|
$sitetree->URLSegment = 'brötchen';
|
||||||
$sitetree->write();
|
$sitetree->write();
|
||||||
$sitetree = DataObject::get_by_id('SiteTree', $sitetree->ID, false);
|
$sitetree = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $sitetree->ID, false);
|
||||||
$this->assertEquals($sitetree->URLSegment, rawurlencode('brötchen'));
|
$this->assertEquals($sitetree->URLSegment, rawurlencode('brötchen'));
|
||||||
|
|
||||||
$sitetree->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$sitetree->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
$sitetree = DataObject::get_by_id('SiteTree', $sitetree->ID, false);
|
$sitetree = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $sitetree->ID, false);
|
||||||
$this->assertEquals($sitetree->URLSegment, rawurlencode('brötchen'));
|
$this->assertEquals($sitetree->URLSegment, rawurlencode('brötchen'));
|
||||||
$sitetreeLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' .$sitetree->ID, false);
|
$sitetreeLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' .$sitetree->ID, false);
|
||||||
$this->assertEquals($sitetreeLive->URLSegment, rawurlencode('brötchen'));
|
$this->assertEquals($sitetreeLive->URLSegment, rawurlencode('brötchen'));
|
||||||
|
|
||||||
Config::inst()->update('URLSegmentFilter', 'default_allow_multibyte', $origAllow);
|
Config::inst()->update('URLSegmentFilter', 'default_allow_multibyte', $origAllow);
|
||||||
@ -891,7 +894,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testPageTypeClasses() {
|
public function testPageTypeClasses() {
|
||||||
$classes = SiteTree::page_type_classes();
|
$classes = SiteTree::page_type_classes();
|
||||||
$this->assertNotContains('SiteTree', $classes, 'Page types do not include base class');
|
$this->assertNotContains('SilverStripe\\CMS\\Model\\SiteTree', $classes, 'Page types do not include base class');
|
||||||
$this->assertContains('Page', $classes, 'Page types do contain subclasses');
|
$this->assertContains('Page', $classes, 'Page types do contain subclasses');
|
||||||
|
|
||||||
// Testing what happens in an incorrect config value is set - hide_ancestor should be a string
|
// Testing what happens in an incorrect config value is set - hide_ancestor should be a string
|
||||||
@ -914,7 +917,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$allowedChildren = $page->allowedChildren();
|
$allowedChildren = $page->allowedChildren();
|
||||||
|
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
'VirtualPage',
|
'SilverStripe\\CMS\\Model\\VirtualPage',
|
||||||
$allowedChildren,
|
$allowedChildren,
|
||||||
'Includes core subclasses by default'
|
'Includes core subclasses by default'
|
||||||
);
|
);
|
||||||
@ -1072,7 +1075,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testMetaTagGeneratorDisabling() {
|
public function testMetaTagGeneratorDisabling() {
|
||||||
$generator = Config::inst()->get('SiteTree', 'meta_generator');
|
$generator = Config::inst()->get('SilverStripe\\CMS\\Model\\SiteTree', 'meta_generator');
|
||||||
|
|
||||||
$page = new SiteTreeTest_PageNode();
|
$page = new SiteTreeTest_PageNode();
|
||||||
|
|
||||||
@ -1083,7 +1086,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
'test default functionality - uses value from Config');
|
'test default functionality - uses value from Config');
|
||||||
|
|
||||||
// test proper escaping of quotes in attribute value
|
// test proper escaping of quotes in attribute value
|
||||||
Config::inst()->update('SiteTree', 'meta_generator', 'Generator with "quotes" in it');
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'meta_generator', 'Generator with "quotes" in it');
|
||||||
$meta = $page->MetaTags();
|
$meta = $page->MetaTags();
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
1,
|
1,
|
||||||
@ -1091,7 +1094,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
'test proper escaping of values from Config');
|
'test proper escaping of values from Config');
|
||||||
|
|
||||||
// test empty generator - no tag should appear at all
|
// test empty generator - no tag should appear at all
|
||||||
Config::inst()->update('SiteTree', 'meta_generator', '');
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'meta_generator', '');
|
||||||
$meta = $page->MetaTags();
|
$meta = $page->MetaTags();
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
0,
|
0,
|
||||||
@ -1099,13 +1102,13 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
'test blank value means no tag generated');
|
'test blank value means no tag generated');
|
||||||
|
|
||||||
// reset original value
|
// reset original value
|
||||||
Config::inst()->update('SiteTree', 'meta_generator', $generator);
|
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'meta_generator', $generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
@ -7,6 +7,12 @@ use SilverStripe\ORM\DB;
|
|||||||
use SilverStripe\ORM\ValidationException;
|
use SilverStripe\ORM\ValidationException;
|
||||||
use SilverStripe\ORM\FieldType\DBVarchar;
|
use SilverStripe\ORM\FieldType\DBVarchar;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use SilverStripe\CMS\Model\VirtualPage;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SilverStripe\CMS\Model\RedirectorPage;
|
||||||
|
use SilverStripe\CMS\Controllers\ModelAsController;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class VirtualPageTest extends FunctionalTest {
|
class VirtualPageTest extends FunctionalTest {
|
||||||
@ -26,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() {
|
||||||
@ -40,8 +46,8 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
$this->logInWithPermission("ADMIN");
|
$this->logInWithPermission("ADMIN");
|
||||||
|
|
||||||
// Add extra fields
|
// Add extra fields
|
||||||
Config::inst()->update('VirtualPage', 'initially_copied_fields', array('MyInitiallyCopiedField'));
|
Config::inst()->update('SilverStripe\\CMS\\Model\\VirtualPage', 'initially_copied_fields', array('MyInitiallyCopiedField'));
|
||||||
Config::inst()->update('VirtualPage', 'non_virtual_fields', array('MyNonVirtualField', 'MySharedNonVirtualField'));
|
Config::inst()->update('SilverStripe\\CMS\\Model\\VirtualPage', 'non_virtual_fields', array('MyNonVirtualField', 'MySharedNonVirtualField'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,8 +61,8 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
$master->Content = "<p>New content</p>";
|
$master->Content = "<p>New content</p>";
|
||||||
$master->write();
|
$master->write();
|
||||||
|
|
||||||
$vp1 = $this->objFromFixture('VirtualPage', 'vp1');
|
$vp1 = $this->objFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp1');
|
||||||
$vp2 = $this->objFromFixture('VirtualPage', 'vp2');
|
$vp2 = $this->objFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp2');
|
||||||
|
|
||||||
$this->assertEquals("New title", $vp1->Title);
|
$this->assertEquals("New title", $vp1->Title);
|
||||||
$this->assertEquals("New title", $vp2->Title);
|
$this->assertEquals("New title", $vp2->Title);
|
||||||
@ -81,16 +87,16 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
$master->Content = "<p>New content</p>";
|
$master->Content = "<p>New content</p>";
|
||||||
$master->write();
|
$master->write();
|
||||||
|
|
||||||
$vp1 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp1'));
|
$vp1 = DataObject::get_by_id("SilverStripe\\CMS\\Model\\VirtualPage", $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp1'));
|
||||||
$vp2 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp2'));
|
$vp2 = DataObject::get_by_id("SilverStripe\\CMS\\Model\\VirtualPage", $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp2'));
|
||||||
$this->assertTrue($vp1->publishRecursive());
|
$this->assertTrue($vp1->publishRecursive());
|
||||||
$this->assertTrue($vp2->publishRecursive());
|
$this->assertTrue($vp2->publishRecursive());
|
||||||
|
|
||||||
$master->publishRecursive();
|
$master->publishRecursive();
|
||||||
|
|
||||||
Versioned::set_stage(Versioned::LIVE);
|
Versioned::set_stage(Versioned::LIVE);
|
||||||
$vp1 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp1'));
|
$vp1 = DataObject::get_by_id("SilverStripe\\CMS\\Model\\VirtualPage", $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp1'));
|
||||||
$vp2 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp2'));
|
$vp2 = DataObject::get_by_id("SilverStripe\\CMS\\Model\\VirtualPage", $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp2'));
|
||||||
|
|
||||||
$this->assertNotNull($vp1);
|
$this->assertNotNull($vp1);
|
||||||
$this->assertNotNull($vp2);
|
$this->assertNotNull($vp2);
|
||||||
@ -148,13 +154,13 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
|
|
||||||
// The draft content of the virtual page should say 'draft content'
|
// The draft content of the virtual page should say 'draft content'
|
||||||
/** @var VirtualPage $vpDraft */
|
/** @var VirtualPage $vpDraft */
|
||||||
$vpDraft = Versioned::get_by_stage("VirtualPage", Versioned::DRAFT)->byID($vp->ID);
|
$vpDraft = Versioned::get_by_stage("SilverStripe\\CMS\\Model\\VirtualPage", Versioned::DRAFT)->byID($vp->ID);
|
||||||
$this->assertEquals('draft content', $vpDraft->CopyContentFrom()->Content);
|
$this->assertEquals('draft content', $vpDraft->CopyContentFrom()->Content);
|
||||||
$this->assertEquals('draft content', $vpDraft->Content);
|
$this->assertEquals('draft content', $vpDraft->Content);
|
||||||
|
|
||||||
// The published content of the virtual page should say 'published content'
|
// The published content of the virtual page should say 'published content'
|
||||||
/** @var VirtualPage $vpLive */
|
/** @var VirtualPage $vpLive */
|
||||||
$vpLive = Versioned::get_by_stage("VirtualPage", Versioned::LIVE)->byID($vp->ID);
|
$vpLive = Versioned::get_by_stage("SilverStripe\\CMS\\Model\\VirtualPage", Versioned::LIVE)->byID($vp->ID);
|
||||||
$this->assertEquals('published content', $vpLive->CopyContentFrom()->Content);
|
$this->assertEquals('published content', $vpLive->CopyContentFrom()->Content);
|
||||||
$this->assertEquals('published content', $vpLive->Content);
|
$this->assertEquals('published content', $vpLive->Content);
|
||||||
|
|
||||||
@ -162,7 +168,7 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
$vpDraft->publishRecursive();
|
$vpDraft->publishRecursive();
|
||||||
|
|
||||||
// Everything is published live
|
// Everything is published live
|
||||||
$vpLive = Versioned::get_by_stage("VirtualPage", Versioned::LIVE)->byID($vp->ID);
|
$vpLive = Versioned::get_by_stage("SilverStripe\\CMS\\Model\\VirtualPage", Versioned::LIVE)->byID($vp->ID);
|
||||||
$this->assertEquals('draft content', $vpLive->CopyContentFrom()->Content);
|
$this->assertEquals('draft content', $vpLive->CopyContentFrom()->Content);
|
||||||
$this->assertEquals('draft content', $vpLive->Content);
|
$this->assertEquals('draft content', $vpLive->Content);
|
||||||
}
|
}
|
||||||
@ -205,7 +211,7 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
// Delete the source page semi-manually, without triggering
|
// Delete the source page semi-manually, without triggering
|
||||||
// the cascade publish back to the virtual page.
|
// the cascade publish back to the virtual page.
|
||||||
Versioned::set_stage(Versioned::LIVE);
|
Versioned::set_stage(Versioned::LIVE);
|
||||||
$livePage = Versioned::get_by_stage('SiteTree', Versioned::LIVE)->byID($pID);
|
$livePage = Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::LIVE)->byID($pID);
|
||||||
$livePage->delete();
|
$livePage->delete();
|
||||||
Versioned::set_stage(Versioned::DRAFT);
|
Versioned::set_stage(Versioned::DRAFT);
|
||||||
|
|
||||||
@ -228,7 +234,7 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
|
|
||||||
public function testCanEdit() {
|
public function testCanEdit() {
|
||||||
$parentPage = $this->objFromFixture('Page', 'master3');
|
$parentPage = $this->objFromFixture('Page', 'master3');
|
||||||
$virtualPage = $this->objFromFixture('VirtualPage', 'vp3');
|
$virtualPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp3');
|
||||||
$bob = $this->objFromFixture('SilverStripe\\Security\\Member', 'bob');
|
$bob = $this->objFromFixture('SilverStripe\\Security\\Member', 'bob');
|
||||||
$andrew = $this->objFromFixture('SilverStripe\\Security\\Member', 'andrew');
|
$andrew = $this->objFromFixture('SilverStripe\\Security\\Member', 'andrew');
|
||||||
|
|
||||||
@ -246,7 +252,7 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
public function testCanView() {
|
public function testCanView() {
|
||||||
$parentPage = $this->objFromFixture('Page', 'master3');
|
$parentPage = $this->objFromFixture('Page', 'master3');
|
||||||
$parentPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$parentPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
$virtualPage = $this->objFromFixture('VirtualPage', 'vp3');
|
$virtualPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp3');
|
||||||
$virtualPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$virtualPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
$cindy = $this->objFromFixture('SilverStripe\\Security\\Member', 'cindy');
|
$cindy = $this->objFromFixture('SilverStripe\\Security\\Member', 'cindy');
|
||||||
$alice = $this->objFromFixture('SilverStripe\\Security\\Member', 'alice');
|
$alice = $this->objFromFixture('SilverStripe\\Security\\Member', 'alice');
|
||||||
@ -329,16 +335,16 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
|
|
||||||
// The draft VP still has the CopyContentFromID link
|
// The draft VP still has the CopyContentFromID link
|
||||||
$vp->flushCache();
|
$vp->flushCache();
|
||||||
$vp = DataObject::get_by_id('SiteTree', $vp->ID);
|
$vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID);
|
||||||
$this->assertEquals($p->ID, $vp->CopyContentFromID);
|
$this->assertEquals($p->ID, $vp->CopyContentFromID);
|
||||||
|
|
||||||
$vpLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $vp->ID);
|
$vpLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $vp->ID);
|
||||||
$this->assertNull($vpLive);
|
$this->assertNull($vpLive);
|
||||||
|
|
||||||
// Delete from draft, confirm that the virtual page has a broken link on the draft site
|
// Delete from draft, confirm that the virtual page has a broken link on the draft site
|
||||||
$p->delete();
|
$p->delete();
|
||||||
$vp->flushCache();
|
$vp->flushCache();
|
||||||
$vp = DataObject::get_by_id('SiteTree', $vp->ID);
|
$vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID);
|
||||||
$this->assertEquals(1, $vp->HasBrokenLink);
|
$this->assertEquals(1, $vp->HasBrokenLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,19 +366,19 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
$pID = $p->ID;
|
$pID = $p->ID;
|
||||||
$p->delete();
|
$p->delete();
|
||||||
$vp->flushCache();
|
$vp->flushCache();
|
||||||
$vp = DataObject::get_by_id('SiteTree', $vp->ID);
|
$vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID);
|
||||||
$this->assertEquals(1, $vp->HasBrokenLink);
|
$this->assertEquals(1, $vp->HasBrokenLink);
|
||||||
|
|
||||||
// Delete the source page form live, confirm that the virtual page has also been unpublished
|
// Delete the source page form live, confirm that the virtual page has also been unpublished
|
||||||
$pLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $pID);
|
$pLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $pID);
|
||||||
$this->assertTrue($pLive->doUnpublish());
|
$this->assertTrue($pLive->doUnpublish());
|
||||||
$vpLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $vp->ID);
|
$vpLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $vp->ID);
|
||||||
$this->assertNull($vpLive);
|
$this->assertNull($vpLive);
|
||||||
|
|
||||||
// Delete from draft, confirm that the virtual page has a broken link on the draft site
|
// Delete from draft, confirm that the virtual page has a broken link on the draft site
|
||||||
$pLive->delete();
|
$pLive->delete();
|
||||||
$vp->flushCache();
|
$vp->flushCache();
|
||||||
$vp = DataObject::get_by_id('SiteTree', $vp->ID);
|
$vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID);
|
||||||
$this->assertEquals(1, $vp->HasBrokenLink);
|
$this->assertEquals(1, $vp->HasBrokenLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,7 +471,7 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
$virtual->CopyContentFromID = $page->ID;
|
$virtual->CopyContentFromID = $page->ID;
|
||||||
$virtual->write();
|
$virtual->write();
|
||||||
|
|
||||||
$virtual = DataObject::get_by_id('VirtualPage', $virtual->ID, false);
|
$virtual = DataObject::get_by_id('SilverStripe\\CMS\\Model\\VirtualPage', $virtual->ID, false);
|
||||||
$virtual->CopyContentFromID = $notRootPage->ID;
|
$virtual->CopyContentFromID = $notRootPage->ID;
|
||||||
$virtual->flushCache();
|
$virtual->flushCache();
|
||||||
|
|
||||||
@ -505,7 +511,7 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
$nonVirtual->write(); // not publishing the page type change here
|
$nonVirtual->write(); // not publishing the page type change here
|
||||||
|
|
||||||
// Stage record is changed to the new type and no longer acts as a virtual page
|
// Stage record is changed to the new type and no longer acts as a virtual page
|
||||||
$nonVirtualStage = Versioned::get_one_by_stage('SiteTree', 'Stage', '"SiteTree"."ID" = ' . $nonVirtual->ID, false);
|
$nonVirtualStage = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Stage', '"SiteTree"."ID" = ' . $nonVirtual->ID, false);
|
||||||
$this->assertNotNull($nonVirtualStage);
|
$this->assertNotNull($nonVirtualStage);
|
||||||
$this->assertEquals('VirtualPageTest_ClassA', $nonVirtualStage->ClassName);
|
$this->assertEquals('VirtualPageTest_ClassA', $nonVirtualStage->ClassName);
|
||||||
$this->assertEquals('changed on new type', $nonVirtualStage->MySharedNonVirtualField);
|
$this->assertEquals('changed on new type', $nonVirtualStage->MySharedNonVirtualField);
|
||||||
@ -514,7 +520,7 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Virtual page on live keeps working as it should
|
// Virtual page on live keeps working as it should
|
||||||
$virtualLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree_Live"."ID" = ' . $virtual->ID, false);
|
$virtualLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree_Live"."ID" = ' . $virtual->ID, false);
|
||||||
$this->assertNotNull($virtualLive);
|
$this->assertNotNull($virtualLive);
|
||||||
$this->assertEquals('VirtualPageTest_VirtualPageSub', $virtualLive->ClassName);
|
$this->assertEquals('VirtualPageTest_VirtualPageSub', $virtualLive->ClassName);
|
||||||
$this->assertEquals('virtual published field', $virtualLive->MySharedNonVirtualField);
|
$this->assertEquals('virtual published field', $virtualLive->MySharedNonVirtualField);
|
||||||
@ -527,7 +533,7 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
|
|
||||||
// Virtual page only notices changes to virtualised fields (Title)
|
// Virtual page only notices changes to virtualised fields (Title)
|
||||||
$virtualLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree_Live"."ID" = ' . $virtual->ID, false);
|
$virtualLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree_Live"."ID" = ' . $virtual->ID, false);
|
||||||
$this->assertEquals('virtual published field', $virtualLive->MySharedNonVirtualField);
|
$this->assertEquals('virtual published field', $virtualLive->MySharedNonVirtualField);
|
||||||
$this->assertEquals('title changed on original', $virtualLive->Title);
|
$this->assertEquals('title changed on original', $virtualLive->Title);
|
||||||
}
|
}
|
||||||
@ -585,7 +591,7 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testVirtualPagePointingToRedirectorPage() {
|
public function testVirtualPagePointingToRedirectorPage() {
|
||||||
if (!class_exists('RedirectorPage')) {
|
if (!class_exists('SilverStripe\\CMS\\Model\\RedirectorPage')) {
|
||||||
$this->markTestSkipped('RedirectorPage required');
|
$this->markTestSkipped('RedirectorPage required');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -603,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'));
|
||||||
@ -674,6 +680,6 @@ class VirtualPageTest_PageExtension extends DataExtension implements TestOnly {
|
|||||||
class VirtualPageTest_PageWithAllowedChildren extends Page implements TestOnly {
|
class VirtualPageTest_PageWithAllowedChildren extends Page implements TestOnly {
|
||||||
private static $allowed_children = array(
|
private static $allowed_children = array(
|
||||||
'VirtualPageTest_ClassA',
|
'VirtualPageTest_ClassA',
|
||||||
'VirtualPage'
|
'SilverStripe\\CMS\\Model\\VirtualPage'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\CMS\Reports\RecentlyEditedReport;
|
||||||
|
use SilverStripe\CMS\Reports\BrokenLinksReport;
|
||||||
|
use SilverStripe\CMS\Reports\BrokenFilesReport;
|
||||||
|
use SilverStripe\CMS\Model\VirtualPage;
|
||||||
|
use SilverStripe\CMS\Reports\BrokenVirtualPagesReport;
|
||||||
|
use SilverStripe\CMS\Model\RedirectorPage;
|
||||||
|
use SilverStripe\CMS\Reports\BrokenRedirectorPagesReport;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -20,8 +28,8 @@ class CmsReportsTest extends SapphireTest {
|
|||||||
$afterThreshold = strtotime('-'.(self::$daysAgo-1).' days', strtotime('31-06-2009 00:00:00'));
|
$afterThreshold = strtotime('-'.(self::$daysAgo-1).' days', strtotime('31-06-2009 00:00:00'));
|
||||||
$beforeThreshold = strtotime('-'.(self::$daysAgo+1).' days', strtotime('31-06-2009 00:00:00'));
|
$beforeThreshold = strtotime('-'.(self::$daysAgo+1).' days', strtotime('31-06-2009 00:00:00'));
|
||||||
|
|
||||||
$after = $this->objFromFixture('SiteTree', 'after');
|
$after = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'after');
|
||||||
$before = $this->objFromFixture('SiteTree', 'before');
|
$before = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'before');
|
||||||
|
|
||||||
DB::query("UPDATE \"SiteTree\" SET \"Created\"='2009-01-01 00:00:00', \"LastEdited\"='".date('Y-m-d H:i:s', $afterThreshold)."' WHERE \"ID\"='".$after->ID."'");
|
DB::query("UPDATE \"SiteTree\" SET \"Created\"='2009-01-01 00:00:00', \"LastEdited\"='".date('Y-m-d H:i:s', $afterThreshold)."' WHERE \"ID\"='".$after->ID."'");
|
||||||
DB::query("UPDATE \"SiteTree\" SET \"Created\"='2009-01-01 00:00:00', \"LastEdited\"='".date('Y-m-d H:i:s', $beforeThreshold)."' WHERE \"ID\"='".$before->ID."'");
|
DB::query("UPDATE \"SiteTree\" SET \"Created\"='2009-01-01 00:00:00', \"LastEdited\"='".date('Y-m-d H:i:s', $beforeThreshold)."' WHERE \"ID\"='".$before->ID."'");
|
||||||
@ -53,8 +61,8 @@ class CmsReportsTest extends SapphireTest {
|
|||||||
public function testRecentlyEdited() {
|
public function testRecentlyEdited() {
|
||||||
DBDatetime::set_mock_now('31-06-2009 00:00:00');
|
DBDatetime::set_mock_now('31-06-2009 00:00:00');
|
||||||
|
|
||||||
$after = $this->objFromFixture('SiteTree', 'after');
|
$after = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'after');
|
||||||
$before = $this->objFromFixture('SiteTree', 'before');
|
$before = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'before');
|
||||||
|
|
||||||
$r = new RecentlyEditedReport();
|
$r = new RecentlyEditedReport();
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
SiteTree:
|
SilverStripe\CMS\Model\SiteTree:
|
||||||
after:
|
after:
|
||||||
Title: after
|
Title: after
|
||||||
before:
|
before:
|
||||||
|
@ -11,7 +11,7 @@ class CMSMainSearchFormTest extends FunctionalTest {
|
|||||||
http_build_query(array(
|
http_build_query(array(
|
||||||
'q' => array(
|
'q' => array(
|
||||||
'Title' => 'Page 10',
|
'Title' => 'Page 10',
|
||||||
'FilterClass' => 'CMSSiteTreeFilter_Search',
|
'FilterClass' => 'SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter_Search',
|
||||||
),
|
),
|
||||||
'action_doSearch' => true
|
'action_doSearch' => true
|
||||||
))
|
))
|
||||||
|
@ -4,6 +4,9 @@ use SilverStripe\ORM\DB;
|
|||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\MSSQL\MSSQLDatabase;
|
use SilverStripe\MSSQL\MSSQLDatabase;
|
||||||
use SilverStripe\PostgreSQL\PostgreSQLDatabase;
|
use SilverStripe\PostgreSQL\PostgreSQLDatabase;
|
||||||
|
use SilverStripe\CMS\Controllers\ContentController;
|
||||||
|
use SilverStripe\CMS\Search\SearchForm;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,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;
|
||||||
@ -43,7 +46,7 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$holderPage = $this->objFromFixture('SiteTree', 'searchformholder');
|
$holderPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'searchformholder');
|
||||||
$this->mockController = new ContentController($holderPage);
|
$this->mockController = new ContentController($holderPage);
|
||||||
|
|
||||||
$this->waitUntilIndexingFinished();
|
$this->waitUntilIndexingFinished();
|
||||||
@ -66,7 +69,7 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
public function testSearchFormTemplateCanBeChanged() {
|
public function testSearchFormTemplateCanBeChanged() {
|
||||||
if(!$this->checkFulltextSupport()) return;
|
if(!$this->checkFulltextSupport()) return;
|
||||||
|
|
||||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
$sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm');
|
||||||
|
|
||||||
$sf->setTemplate('BlankPage');
|
$sf->setTemplate('BlankPage');
|
||||||
|
|
||||||
@ -79,9 +82,9 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
public function testPublishedPagesMatchedByTitle() {
|
public function testPublishedPagesMatchedByTitle() {
|
||||||
if(!$this->checkFulltextSupport()) return;
|
if(!$this->checkFulltextSupport()) return;
|
||||||
|
|
||||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
$sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm');
|
||||||
|
|
||||||
$publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage');
|
$publishedPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'publicPublishedPage');
|
||||||
$publishedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$publishedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
|
|
||||||
$this->waitUntilIndexingFinished();
|
$this->waitUntilIndexingFinished();
|
||||||
@ -96,9 +99,9 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
public function testDoubleQuotesPublishedPagesMatchedByTitle() {
|
public function testDoubleQuotesPublishedPagesMatchedByTitle() {
|
||||||
if(!$this->checkFulltextSupport()) return;
|
if(!$this->checkFulltextSupport()) return;
|
||||||
|
|
||||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
$sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm');
|
||||||
|
|
||||||
$publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage');
|
$publishedPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'publicPublishedPage');
|
||||||
$publishedPage->Title = "finding butterflies";
|
$publishedPage->Title = "finding butterflies";
|
||||||
$publishedPage->write();
|
$publishedPage->write();
|
||||||
$publishedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$publishedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
@ -115,10 +118,10 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
public function testUnpublishedPagesNotIncluded() {
|
public function testUnpublishedPagesNotIncluded() {
|
||||||
if(!$this->checkFulltextSupport()) return;
|
if(!$this->checkFulltextSupport()) return;
|
||||||
|
|
||||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
$sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm');
|
||||||
|
|
||||||
$results = $sf->getResults(null, array('Search'=>'publicUnpublishedPage'));
|
$results = $sf->getResults(null, array('Search'=>'publicUnpublishedPage'));
|
||||||
$unpublishedPage = $this->objFromFixture('SiteTree', 'publicUnpublishedPage');
|
$unpublishedPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'publicUnpublishedPage');
|
||||||
$this->assertNotContains(
|
$this->assertNotContains(
|
||||||
$unpublishedPage->ID,
|
$unpublishedPage->ID,
|
||||||
$results->column('ID'),
|
$results->column('ID'),
|
||||||
@ -129,9 +132,9 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
public function testPagesRestrictedToLoggedinUsersNotIncluded() {
|
public function testPagesRestrictedToLoggedinUsersNotIncluded() {
|
||||||
if(!$this->checkFulltextSupport()) return;
|
if(!$this->checkFulltextSupport()) return;
|
||||||
|
|
||||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
$sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm');
|
||||||
|
|
||||||
$page = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers');
|
$page = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'restrictedViewLoggedInUsers');
|
||||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
$results = $sf->getResults(null, array('Search'=>'restrictedViewLoggedInUsers'));
|
$results = $sf->getResults(null, array('Search'=>'restrictedViewLoggedInUsers'));
|
||||||
$this->assertNotContains(
|
$this->assertNotContains(
|
||||||
@ -154,9 +157,9 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
public function testPagesRestrictedToSpecificGroupNotIncluded() {
|
public function testPagesRestrictedToSpecificGroupNotIncluded() {
|
||||||
if(!$this->checkFulltextSupport()) return;
|
if(!$this->checkFulltextSupport()) return;
|
||||||
|
|
||||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
$sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm');
|
||||||
|
|
||||||
$page = $this->objFromFixture('SiteTree', 'restrictedViewOnlyWebsiteUsers');
|
$page = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'restrictedViewOnlyWebsiteUsers');
|
||||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
$results = $sf->getResults(null, array('Search'=>'restrictedViewOnlyWebsiteUsers'));
|
$results = $sf->getResults(null, array('Search'=>'restrictedViewOnlyWebsiteUsers'));
|
||||||
$this->assertNotContains(
|
$this->assertNotContains(
|
||||||
@ -187,12 +190,12 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testInheritedRestrictedPagesNotIncluded() {
|
public function testInheritedRestrictedPagesNotIncluded() {
|
||||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
$sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm');
|
||||||
|
|
||||||
$parent = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers');
|
$parent = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'restrictedViewLoggedInUsers');
|
||||||
$parent->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$parent->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
|
|
||||||
$page = $this->objFromFixture('SiteTree', 'inheritRestrictedView');
|
$page = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'inheritRestrictedView');
|
||||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
$results = $sf->getResults(null, array('Search'=>'inheritRestrictedView'));
|
$results = $sf->getResults(null, array('Search'=>'inheritRestrictedView'));
|
||||||
$this->assertNotContains(
|
$this->assertNotContains(
|
||||||
@ -215,9 +218,9 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
public function testDisabledShowInSearchFlagNotIncludedForSiteTree() {
|
public function testDisabledShowInSearchFlagNotIncludedForSiteTree() {
|
||||||
if(!$this->checkFulltextSupport()) return;
|
if(!$this->checkFulltextSupport()) return;
|
||||||
|
|
||||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
$sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm');
|
||||||
|
|
||||||
$page = $this->objFromFixture('SiteTree', 'dontShowInSearchPage');
|
$page = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'dontShowInSearchPage');
|
||||||
$results = $sf->getResults(null, array('Search'=>'dontShowInSearchPage'));
|
$results = $sf->getResults(null, array('Search'=>'dontShowInSearchPage'));
|
||||||
$this->assertNotContains(
|
$this->assertNotContains(
|
||||||
$page->ID,
|
$page->ID,
|
||||||
@ -229,7 +232,7 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
public function testDisabledShowInSearchFlagNotIncludedForFiles() {
|
public function testDisabledShowInSearchFlagNotIncludedForFiles() {
|
||||||
if(!$this->checkFulltextSupport()) return;
|
if(!$this->checkFulltextSupport()) return;
|
||||||
|
|
||||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
$sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm');
|
||||||
|
|
||||||
$dontShowInSearchFile = $this->objFromFixture('File', 'dontShowInSearchFile');
|
$dontShowInSearchFile = $this->objFromFixture('File', 'dontShowInSearchFile');
|
||||||
$dontShowInSearchFile->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$dontShowInSearchFile->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
@ -258,9 +261,9 @@ class ZZZSearchFormTest extends FunctionalTest {
|
|||||||
$this->markTestSkipped("PostgreSQLDatabase doesn't support entity-encoded searches");
|
$this->markTestSkipped("PostgreSQLDatabase doesn't support entity-encoded searches");
|
||||||
}
|
}
|
||||||
|
|
||||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
$sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm');
|
||||||
|
|
||||||
$pageWithSpecialChars = $this->objFromFixture('SiteTree', 'pageWithSpecialChars');
|
$pageWithSpecialChars = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'pageWithSpecialChars');
|
||||||
$pageWithSpecialChars->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
$pageWithSpecialChars->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
|
|
||||||
$results = $sf->getResults(null, array('Search'=>'Brötchen'));
|
$results = $sf->getResults(null, array('Search'=>'Brötchen'));
|
||||||
|
@ -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
|
||||||
@ -25,11 +27,11 @@ class MigrateSiteTreeLinkingTaskTest extends SapphireTest {
|
|||||||
);
|
);
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
$homeID = $this->idFromFixture('SiteTree', 'home');
|
$homeID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'home');
|
||||||
$aboutID = $this->idFromFixture('SiteTree', 'about');
|
$aboutID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'about');
|
||||||
$staffID = $this->idFromFixture('SiteTree', 'staff');
|
$staffID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'staff');
|
||||||
$actionID = $this->idFromFixture('SiteTree', 'action');
|
$actionID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'action');
|
||||||
$hashID = $this->idFromFixture('SiteTree', 'hash_link');
|
$hashID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'hash_link');
|
||||||
|
|
||||||
$homeContent = sprintf (
|
$homeContent = sprintf (
|
||||||
'<a href="[sitetree_link,id=%d]">About</a><a href="[sitetree_link,id=%d]">Staff</a><a href="http://silverstripe.org/">External Link</a><a name="anchor"></a>',
|
'<a href="[sitetree_link,id=%d]">About</a><a href="[sitetree_link,id=%d]">Staff</a><a href="http://silverstripe.org/">External Link</a><a name="anchor"></a>',
|
||||||
@ -57,25 +59,25 @@ class MigrateSiteTreeLinkingTaskTest extends SapphireTest {
|
|||||||
|
|
||||||
$this->assertEquals (
|
$this->assertEquals (
|
||||||
$homeContent,
|
$homeContent,
|
||||||
DataObject::get_by_id('SiteTree', $homeID)->Content,
|
DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $homeID)->Content,
|
||||||
'HTML URLSegment links are rewritten.'
|
'HTML URLSegment links are rewritten.'
|
||||||
);
|
);
|
||||||
$this->assertEquals (
|
$this->assertEquals (
|
||||||
$aboutContent,
|
$aboutContent,
|
||||||
DataObject::get_by_id('SiteTree', $aboutID)->Content
|
DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $aboutID)->Content
|
||||||
);
|
);
|
||||||
$this->assertEquals (
|
$this->assertEquals (
|
||||||
$staffContent,
|
$staffContent,
|
||||||
DataObject::get_by_id('SiteTree', $staffID)->Content
|
DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $staffID)->Content
|
||||||
);
|
);
|
||||||
$this->assertEquals (
|
$this->assertEquals (
|
||||||
$actionContent,
|
$actionContent,
|
||||||
DataObject::get_by_id('SiteTree', $actionID)->Content,
|
DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $actionID)->Content,
|
||||||
'Links to actions on pages are rewritten correctly.'
|
'Links to actions on pages are rewritten correctly.'
|
||||||
);
|
);
|
||||||
$this->assertEquals (
|
$this->assertEquals (
|
||||||
$hashLinkContent,
|
$hashLinkContent,
|
||||||
DataObject::get_by_id('SiteTree', $hashID)->Content,
|
DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $hashID)->Content,
|
||||||
'Hash/anchor links are correctly handled.'
|
'Hash/anchor links are correctly handled.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user