mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Fix regressions from namespacing
Update template locations Add permission codes to cms sections Code, phpdoc, and typehint cleanup Split batch actions into files
This commit is contained in:
parent
2352127fe0
commit
041d12129a
@ -25,5 +25,3 @@ CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageEditControlle
|
|||||||
CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageSettingsController');
|
CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageSettingsController');
|
||||||
CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController');
|
CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController');
|
||||||
CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageAddController');
|
CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageAddController');
|
||||||
|
|
||||||
CMSMenu::remove_menu_item("SiteConfigLeftAndMain");
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
AdminRootController:
|
SilverStripe\Admin\AdminRootController:
|
||||||
default_panel: 'SilverStripe\CMS\Controllers\CMSPagesController'
|
default_panel: 'SilverStripe\CMS\Controllers\CMSPagesController'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
LeftAndMain:
|
SilverStripe\Admin\LeftAndMain:
|
||||||
extensions:
|
extensions:
|
||||||
- SilverStripe\CMS\Controllers\LeftAndMainPageIconsExtension
|
- SilverStripe\CMS\Controllers\LeftAndMainPageIconsExtension
|
||||||
Controller:
|
Controller:
|
||||||
|
34
code/BatchActions/CMSBatchAction_Archive.php
Normal file
34
code/BatchActions/CMSBatchAction_Archive.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\BatchActions;
|
||||||
|
|
||||||
|
use SilverStripe\Admin\CMSBatchAction;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Archives a page, removing it from both live and stage
|
||||||
|
*
|
||||||
|
* @package cms
|
||||||
|
* @subpackage batchaction
|
||||||
|
*/
|
||||||
|
class CMSBatchAction_Archive extends CMSBatchAction
|
||||||
|
{
|
||||||
|
|
||||||
|
public function getActionTitle()
|
||||||
|
{
|
||||||
|
return _t('CMSBatchActions.ARCHIVE', 'Archive');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run(SS_List $pages)
|
||||||
|
{
|
||||||
|
return $this->batchaction($pages, 'doArchive',
|
||||||
|
_t('CMSBatchActions.ARCHIVED_PAGES', 'Archived %d pages')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applicablePages($ids)
|
||||||
|
{
|
||||||
|
return $this->applicablePagesHelper($ids, 'canArchive', true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
55
code/BatchActions/CMSBatchAction_Delete.php
Normal file
55
code/BatchActions/CMSBatchAction_Delete.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\BatchActions;
|
||||||
|
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\Admin\CMSBatchAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete items batch action.
|
||||||
|
*
|
||||||
|
* @package cms
|
||||||
|
* @subpackage batchaction
|
||||||
|
*/
|
||||||
|
class CMSBatchAction_Delete extends CMSBatchAction {
|
||||||
|
public function getActionTitle() {
|
||||||
|
return _t('CMSBatchActions.DELETE_DRAFT_PAGES', 'Delete from draft site');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run(SS_List $pages) {
|
||||||
|
$status = array(
|
||||||
|
'modified'=>array(),
|
||||||
|
'deleted'=>array(),
|
||||||
|
'error'=>array()
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach($pages as $page) {
|
||||||
|
$id = $page->ID;
|
||||||
|
|
||||||
|
// Perform the action
|
||||||
|
if($page->canDelete()) $page->delete();
|
||||||
|
else $status['error'][$page->ID] = true;
|
||||||
|
|
||||||
|
// check to see if the record exists on the live site,
|
||||||
|
// if it doesn't remove the tree node
|
||||||
|
$liveRecord = Versioned::get_one_by_stage( 'SilverStripe\\CMS\\Model\\SiteTree', 'Live', array(
|
||||||
|
'"SiteTree"."ID"' => $id
|
||||||
|
));
|
||||||
|
if($liveRecord) {
|
||||||
|
$status['modified'][$liveRecord->ID] = array(
|
||||||
|
'TreeTitle' => $liveRecord->TreeTitle,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$status['deleted'][$id] = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response(_t('CMSBatchActions.DELETED_DRAFT_PAGES', 'Deleted %d pages from draft site, %d failures'), $status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applicablePages($ids) {
|
||||||
|
return $this->applicablePagesHelper($ids, 'canDelete', true, false);
|
||||||
|
}
|
||||||
|
}
|
32
code/BatchActions/CMSBatchAction_Publish.php
Normal file
32
code/BatchActions/CMSBatchAction_Publish.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\BatchActions;
|
||||||
|
|
||||||
|
use SilverStripe\Admin\CMSBatchAction;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Publish items batch action.
|
||||||
|
*
|
||||||
|
* @package cms
|
||||||
|
* @subpackage batchaction
|
||||||
|
*/
|
||||||
|
class CMSBatchAction_Publish extends CMSBatchAction
|
||||||
|
{
|
||||||
|
public function getActionTitle()
|
||||||
|
{
|
||||||
|
return _t('CMSBatchActions.PUBLISH_PAGES', 'Publish');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run(SS_List $pages)
|
||||||
|
{
|
||||||
|
return $this->batchaction($pages, 'publishRecursive',
|
||||||
|
_t('CMSBatchActions.PUBLISHED_PAGES', 'Published %d pages, %d failures')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applicablePages($ids)
|
||||||
|
{
|
||||||
|
return $this->applicablePagesHelper($ids, 'canPublish', true, false);
|
||||||
|
}
|
||||||
|
}
|
62
code/BatchActions/CMSBatchAction_Restore.php
Normal file
62
code/BatchActions/CMSBatchAction_Restore.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\BatchActions;
|
||||||
|
|
||||||
|
use SilverStripe\Admin\CMSBatchAction;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Batch restore of pages
|
||||||
|
* @package cms
|
||||||
|
* @subpackage batchaction
|
||||||
|
*/
|
||||||
|
class CMSBatchAction_Restore extends CMSBatchAction
|
||||||
|
{
|
||||||
|
|
||||||
|
public function getActionTitle()
|
||||||
|
{
|
||||||
|
return _t('CMSBatchActions.RESTORE', 'Restore');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run(SS_List $pages)
|
||||||
|
{
|
||||||
|
// Sort pages by depth
|
||||||
|
$pageArray = $pages->toArray();
|
||||||
|
// because of https://bugs.php.net/bug.php?id=50688
|
||||||
|
/** @var SiteTree $page */
|
||||||
|
foreach ($pageArray as $page) {
|
||||||
|
$page->getPageLevel();
|
||||||
|
}
|
||||||
|
usort($pageArray, function (SiteTree $a, SiteTree $b) {
|
||||||
|
return $a->getPageLevel() - $b->getPageLevel();
|
||||||
|
});
|
||||||
|
$pages = new ArrayList($pageArray);
|
||||||
|
|
||||||
|
// Restore
|
||||||
|
return $this->batchaction($pages, 'doRestoreToStage',
|
||||||
|
_t('CMSBatchActions.RESTORED_PAGES', 'Restored %d pages')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@see SiteTree::canEdit()}
|
||||||
|
*
|
||||||
|
* @param array $ids
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function applicablePages($ids)
|
||||||
|
{
|
||||||
|
// Basic permission check based on SiteTree::canEdit
|
||||||
|
if (!Permission::check(array("ADMIN", "SITETREE_EDIT_ALL"))) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get pages that exist in stage and remove them from the restore-able set
|
||||||
|
$stageIDs = Versioned::get_by_stage($this->managedClass, 'Stage')->column('ID');
|
||||||
|
return array_values(array_diff($ids, $stageIDs));
|
||||||
|
}
|
||||||
|
}
|
32
code/BatchActions/CMSBatchAction_Unpublish.php
Normal file
32
code/BatchActions/CMSBatchAction_Unpublish.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\CMS\BatchActions;
|
||||||
|
|
||||||
|
use SilverStripe\Admin\CMSBatchAction;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unpublish items batch action.
|
||||||
|
*
|
||||||
|
* @package cms
|
||||||
|
* @subpackage batchaction
|
||||||
|
*/
|
||||||
|
class CMSBatchAction_Unpublish extends CMSBatchAction
|
||||||
|
{
|
||||||
|
public function getActionTitle()
|
||||||
|
{
|
||||||
|
return _t('CMSBatchActions.UNPUBLISH_PAGES', 'Unpublish');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run(SS_List $pages)
|
||||||
|
{
|
||||||
|
return $this->batchaction($pages, 'doUnpublish',
|
||||||
|
_t('CMSBatchActions.UNPUBLISHED_PAGES', 'Unpublished %d pages')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applicablePages($ids)
|
||||||
|
{
|
||||||
|
return $this->applicablePagesHelper($ids, 'canUnpublish', false, true);
|
||||||
|
}
|
||||||
|
}
|
@ -1,175 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace SilverStripe\CMS\BatchActions;
|
|
||||||
|
|
||||||
|
|
||||||
use SilverStripe\ORM\SS_List;
|
|
||||||
use SilverStripe\ORM\ArrayList;
|
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
|
||||||
use SilverStripe\Security\Permission;
|
|
||||||
use SilverStripe\Admin\CMSBatchAction;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Publish items batch action.
|
|
||||||
*
|
|
||||||
* @package cms
|
|
||||||
* @subpackage batchaction
|
|
||||||
*/
|
|
||||||
class CMSBatchAction_Publish extends CMSBatchAction {
|
|
||||||
public function getActionTitle() {
|
|
||||||
return _t('CMSBatchActions.PUBLISH_PAGES', 'Publish');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function run(SS_List $pages) {
|
|
||||||
return $this->batchaction($pages, 'publishRecursive',
|
|
||||||
_t('CMSBatchActions.PUBLISHED_PAGES', 'Published %d pages, %d failures')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function applicablePages($ids) {
|
|
||||||
return $this->applicablePagesHelper($ids, 'canPublish', true, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unpublish items batch action.
|
|
||||||
*
|
|
||||||
* @package cms
|
|
||||||
* @subpackage batchaction
|
|
||||||
*/
|
|
||||||
class CMSBatchAction_Unpublish extends CMSBatchAction {
|
|
||||||
public function getActionTitle() {
|
|
||||||
return _t('CMSBatchActions.UNPUBLISH_PAGES', 'Unpublish');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function run(SS_List $pages) {
|
|
||||||
return $this->batchaction($pages, 'doUnpublish',
|
|
||||||
_t('CMSBatchActions.UNPUBLISHED_PAGES', 'Unpublished %d pages')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function applicablePages($ids) {
|
|
||||||
return $this->applicablePagesHelper($ids, 'canUnpublish', false, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Archives a page, removing it from both live and stage
|
|
||||||
*
|
|
||||||
* @package cms
|
|
||||||
* @subpackage batchaction
|
|
||||||
*/
|
|
||||||
class CMSBatchAction_Archive extends CMSBatchAction {
|
|
||||||
|
|
||||||
public function getActionTitle() {
|
|
||||||
return _t('CMSBatchActions.ARCHIVE', 'Archive');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function run(SS_List $pages) {
|
|
||||||
return $this->batchaction($pages, 'doArchive',
|
|
||||||
_t('CMSBatchActions.ARCHIVED_PAGES', 'Archived %d pages')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function applicablePages($ids) {
|
|
||||||
return $this->applicablePagesHelper($ids, 'canArchive', true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Batch restore of pages
|
|
||||||
* @package cms
|
|
||||||
* @subpackage batchaction
|
|
||||||
*/
|
|
||||||
class CMSBatchAction_Restore extends CMSBatchAction {
|
|
||||||
|
|
||||||
public function getActionTitle() {
|
|
||||||
return _t('CMSBatchActions.RESTORE', 'Restore');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function run(SS_List $pages) {
|
|
||||||
// Sort pages by depth
|
|
||||||
$pageArray = $pages->toArray();
|
|
||||||
// because of https://bugs.php.net/bug.php?id=50688
|
|
||||||
foreach($pageArray as $page) {
|
|
||||||
$page->getPageLevel();
|
|
||||||
}
|
|
||||||
usort($pageArray, function($a, $b) {
|
|
||||||
return $a->getPageLevel() - $b->getPageLevel();
|
|
||||||
});
|
|
||||||
$pages = new ArrayList($pageArray);
|
|
||||||
|
|
||||||
// Restore
|
|
||||||
return $this->batchaction($pages, 'doRestoreToStage',
|
|
||||||
_t('CMSBatchActions.RESTORED_PAGES', 'Restored %d pages')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@see SiteTree::canEdit()}
|
|
||||||
*
|
|
||||||
* @param array $ids
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function applicablePages($ids) {
|
|
||||||
// Basic permission check based on SiteTree::canEdit
|
|
||||||
if(!Permission::check(array("ADMIN", "SITETREE_EDIT_ALL"))) {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get pages that exist in stage and remove them from the restore-able set
|
|
||||||
$stageIDs = Versioned::get_by_stage($this->managedClass, 'Stage')->column('ID');
|
|
||||||
return array_values(array_diff($ids, $stageIDs));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete items batch action.
|
|
||||||
*
|
|
||||||
* @package cms
|
|
||||||
* @subpackage batchaction
|
|
||||||
*/
|
|
||||||
class CMSBatchAction_Delete extends CMSBatchAction {
|
|
||||||
public function getActionTitle() {
|
|
||||||
return _t('CMSBatchActions.DELETE_DRAFT_PAGES', 'Delete from draft site');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function run(SS_List $pages) {
|
|
||||||
$status = array(
|
|
||||||
'modified'=>array(),
|
|
||||||
'deleted'=>array(),
|
|
||||||
'error'=>array()
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach($pages as $page) {
|
|
||||||
$id = $page->ID;
|
|
||||||
|
|
||||||
// Perform the action
|
|
||||||
if($page->canDelete()) $page->delete();
|
|
||||||
else $status['error'][$page->ID] = true;
|
|
||||||
|
|
||||||
// check to see if the record exists on the live site,
|
|
||||||
// if it doesn't remove the tree node
|
|
||||||
$liveRecord = Versioned::get_one_by_stage( 'SilverStripe\\CMS\\Model\\SiteTree', 'Live', array(
|
|
||||||
'"SiteTree"."ID"' => $id
|
|
||||||
));
|
|
||||||
if($liveRecord) {
|
|
||||||
$status['modified'][$liveRecord->ID] = array(
|
|
||||||
'TreeTitle' => $liveRecord->TreeTitle,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$status['deleted'][$id] = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->response(_t('CMSBatchActions.DELETED_DRAFT_PAGES', 'Deleted %d pages from draft site, %d failures'), $status);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function applicablePages($ids) {
|
|
||||||
return $this->applicablePagesHelper($ids, 'canDelete', true, false);
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,16 +2,22 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Controllers;
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
|
use SearchContext;
|
||||||
|
use SearchFilter;
|
||||||
use SilverStripe\Filesystem\Storage\AssetNameGenerator;
|
use SilverStripe\Filesystem\Storage\AssetNameGenerator;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
|
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\ORM\DataObject;
|
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 SilverStripe\Admin\CMSBatchAction;
|
||||||
|
use SilverStripe\Admin\CMSBatchActionHandler;
|
||||||
|
use SilverStripe\Admin\LeftAndMain;
|
||||||
use Session;
|
use Session;
|
||||||
use Requirements;
|
use Requirements;
|
||||||
use CMSBatchActionHandler;
|
|
||||||
use File;
|
use File;
|
||||||
use DateField;
|
use DateField;
|
||||||
use HiddenField;
|
use HiddenField;
|
||||||
@ -28,6 +34,7 @@ use GridFieldLevelup;
|
|||||||
use GridField;
|
use GridField;
|
||||||
use Controller;
|
use Controller;
|
||||||
use LiteralField;
|
use LiteralField;
|
||||||
|
use SS_HTTPRequest;
|
||||||
use TabSet;
|
use TabSet;
|
||||||
use Tab;
|
use Tab;
|
||||||
use CompositeField;
|
use CompositeField;
|
||||||
@ -49,10 +56,6 @@ use Folder;
|
|||||||
use Injector;
|
use Injector;
|
||||||
use Director;
|
use Director;
|
||||||
use ArrayData;
|
use ArrayData;
|
||||||
use CMSBatchAction;
|
|
||||||
use SilverStripe\Admin\CMSBatchActionHandler;
|
|
||||||
use SilverStripe\Admin\LeftAndMain;
|
|
||||||
use SilverStripe\Admin\CMSBatchAction;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -97,6 +100,8 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
|||||||
'getsubtree'
|
'getsubtree'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private static $required_permission_codes = 'CMS_ACCESS_AssetAdmin';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return fake-ID "root" if no ID is found (needed to upload files into the root-folder)
|
* Return fake-ID "root" if no ID is found (needed to upload files into the root-folder)
|
||||||
*/
|
*/
|
||||||
@ -139,6 +144,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
|||||||
// Overwrite name filter to search both Name and Title attributes
|
// Overwrite name filter to search both Name and Title attributes
|
||||||
$context->removeFilterByName('Name');
|
$context->removeFilterByName('Name');
|
||||||
$params = $this->getRequest()->requestVar('q');
|
$params = $this->getRequest()->requestVar('q');
|
||||||
|
/** @var DataList $list */
|
||||||
$list = $context->getResults($params);
|
$list = $context->getResults($params);
|
||||||
|
|
||||||
// Don't filter list when a detail view is requested,
|
// Don't filter list when a detail view is requested,
|
||||||
@ -219,6 +225,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
|||||||
);
|
);
|
||||||
|
|
||||||
$gridField = GridField::create('File', $title, $this->getList(), $gridFieldConfig);
|
$gridField = GridField::create('File', $title, $this->getList(), $gridFieldConfig);
|
||||||
|
/** @var GridFieldDataColumns $columns */
|
||||||
$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
|
$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
|
||||||
$columns->setDisplayFields(array(
|
$columns->setDisplayFields(array(
|
||||||
'StripThumbnail' => '',
|
'StripThumbnail' => '',
|
||||||
@ -256,14 +263,14 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
|||||||
// Move existing fields to a "details" tab, unless they've already been tabbed out through extensions.
|
// Move existing fields to a "details" tab, unless they've already been tabbed out through extensions.
|
||||||
// Required to keep Folder->getCMSFields() simple and reuseable,
|
// Required to keep Folder->getCMSFields() simple and reuseable,
|
||||||
// without any dependencies into AssetAdmin (e.g. useful for "add folder" views).
|
// without any dependencies into AssetAdmin (e.g. useful for "add folder" views).
|
||||||
if(!$fields->hasTabset()) {
|
if(!$fields->hasTabSet()) {
|
||||||
$tabs = new TabSet('Root',
|
$tabs = new TabSet('Root',
|
||||||
$tabList = new Tab('ListView', _t('AssetAdmin.ListView', 'List View')),
|
$tabList = new Tab('ListView', _t('AssetAdmin.ListView', 'List View')),
|
||||||
$tabTree = new Tab('TreeView', _t('AssetAdmin.TreeView', 'Tree View'))
|
$tabTree = new Tab('TreeView', _t('AssetAdmin.TreeView', 'Tree View'))
|
||||||
);
|
);
|
||||||
$tabList->addExtraClass("content-listview cms-tabset-icon list");
|
$tabList->addExtraClass("content-listview cms-tabset-icon list");
|
||||||
$tabTree->addExtraClass("content-treeview cms-tabset-icon tree");
|
$tabTree->addExtraClass("content-treeview cms-tabset-icon tree");
|
||||||
if($fields->Count() && $folder && $folder->isInDB()) {
|
if($fields->count() && $folder && $folder->isInDB()) {
|
||||||
$tabs->push($tabDetails = new Tab('DetailsView', _t('AssetAdmin.DetailsView', 'Details')));
|
$tabs->push($tabDetails = new Tab('DetailsView', _t('AssetAdmin.DetailsView', 'Details')));
|
||||||
$tabDetails->addExtraClass("content-galleryview cms-tabset-icon edit");
|
$tabDetails->addExtraClass("content-galleryview cms-tabset-icon edit");
|
||||||
foreach($fields as $field) {
|
foreach($fields as $field) {
|
||||||
@ -373,6 +380,10 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
|||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param SS_HTTPRequest $request
|
||||||
|
* @return DBHTMLText
|
||||||
|
*/
|
||||||
public function addfolder($request) {
|
public function addfolder($request) {
|
||||||
$obj = $this->customise(array(
|
$obj = $this->customise(array(
|
||||||
'EditForm' => $this->AddForm()
|
'EditForm' => $this->AddForm()
|
||||||
@ -413,12 +424,14 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
|||||||
* @return SearchContext
|
* @return SearchContext
|
||||||
*/
|
*/
|
||||||
public function getSearchContext() {
|
public function getSearchContext() {
|
||||||
$context = singleton('File')->getDefaultSearchContext();
|
$context = File::singleton()->getDefaultSearchContext();
|
||||||
|
|
||||||
// Namespace fields, for easier detection if a search is present
|
// Namespace fields, for easier detection if a search is present
|
||||||
|
/** @var FormField $field */
|
||||||
foreach($context->getFields() as $field) {
|
foreach($context->getFields() as $field) {
|
||||||
$field->setName(sprintf('q[%s]', $field->getName()));
|
$field->setName(sprintf('q[%s]', $field->getName()));
|
||||||
}
|
}
|
||||||
|
/** @var SearchFilter $filter */
|
||||||
foreach($context->getFilters() as $filter) {
|
foreach($context->getFilters() as $filter) {
|
||||||
$filter->setFullName(sprintf('q[%s]', $filter->getFullName()));
|
$filter->setFullName(sprintf('q[%s]', $filter->getFullName()));
|
||||||
}
|
}
|
||||||
@ -529,6 +542,10 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
|||||||
* Add a new group and return its details suitable for ajax.
|
* Add a new group and return its details suitable for ajax.
|
||||||
*
|
*
|
||||||
* @todo Move logic into Folder class, and use LeftAndMain->doAdd() default implementation.
|
* @todo Move logic into Folder class, and use LeftAndMain->doAdd() default implementation.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @param Form $form
|
||||||
|
* @return SS_HTTPResponse|string
|
||||||
*/
|
*/
|
||||||
public function doAdd($data, $form) {
|
public function doAdd($data, $form) {
|
||||||
$class = $this->stat('tree_class');
|
$class = $this->stat('tree_class');
|
||||||
@ -539,6 +556,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check addchildren permissions
|
// check addchildren permissions
|
||||||
|
/** @var File $parentRecord */
|
||||||
if(
|
if(
|
||||||
singleton($class)->hasExtension('SilverStripe\ORM\Hierarchy\Hierarchy')
|
singleton($class)->hasExtension('SilverStripe\ORM\Hierarchy\Hierarchy')
|
||||||
&& isset($data['ParentID'])
|
&& isset($data['ParentID'])
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Controllers;
|
namespace SilverStripe\CMS\Controllers;
|
||||||
|
|
||||||
|
use FormField;
|
||||||
|
use Injector;
|
||||||
use ResetFormAction;
|
use ResetFormAction;
|
||||||
use SilverStripe\Admin\CMSPreviewable;
|
|
||||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\ORM\SS_List;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
@ -17,36 +18,33 @@ 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 SilverStripe\Admin\CMSBatchActionHandler;
|
|
||||||
use SilverStripe\Admin\AdminRootController;
|
use SilverStripe\Admin\AdminRootController;
|
||||||
use SilverStripe\Admin\AddToCampaignHandler;
|
|
||||||
use SilverStripe\Admin\LeftAndMain;
|
use SilverStripe\Admin\LeftAndMain;
|
||||||
|
use SilverStripe\Admin\CMSBatchActionHandler;
|
||||||
|
use SilverStripe\Admin\CMSPreviewable;
|
||||||
|
use SilverStripe\Admin\AddToCampaignHandler;
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
|
use SilverStripe\CMS\Model\RedirectorPage;
|
||||||
|
use SilverStripe\CMS\Model\CurrentPageIdentifier;
|
||||||
use SS_HTTPRequest;
|
use SS_HTTPRequest;
|
||||||
|
use TabSet;
|
||||||
use Translatable;
|
use Translatable;
|
||||||
use Requirements;
|
use Requirements;
|
||||||
use CMSBatchActionHandler;
|
|
||||||
use Controller;
|
use Controller;
|
||||||
use AdminRootController;
|
|
||||||
use Director;
|
use Director;
|
||||||
use Page;
|
use Page;
|
||||||
|
|
||||||
use TextField;
|
use TextField;
|
||||||
use HeaderField;
|
|
||||||
use DateField;
|
use DateField;
|
||||||
use DropdownField;
|
use DropdownField;
|
||||||
use FieldGroup;
|
use FieldGroup;
|
||||||
use FieldList;
|
use FieldList;
|
||||||
use FormAction;
|
use FormAction;
|
||||||
use Object;
|
|
||||||
use Form;
|
use Form;
|
||||||
use SS_Cache;
|
use SS_Cache;
|
||||||
use Zend_Cache;
|
use Zend_Cache;
|
||||||
use Convert;
|
use Convert;
|
||||||
use ArrayData;
|
use ArrayData;
|
||||||
use HiddenField;
|
use HiddenField;
|
||||||
use CMSPreviewable;
|
|
||||||
use LiteralField;
|
use LiteralField;
|
||||||
use RequiredFields;
|
use RequiredFields;
|
||||||
use LabelField;
|
use LabelField;
|
||||||
@ -59,16 +57,7 @@ use GridFieldLevelup;
|
|||||||
use GridField;
|
use GridField;
|
||||||
use SS_HTTPResponse_Exception;
|
use SS_HTTPResponse_Exception;
|
||||||
use Session;
|
use Session;
|
||||||
use AddToCampaignHandler;
|
|
||||||
use HTMLEditorField;
|
|
||||||
use SS_HTTPResponse;
|
use SS_HTTPResponse;
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
|
||||||
use SilverStripe\CMS\Model\RedirectorPage;
|
|
||||||
use SilverStripe\CMS\Model\CurrentPageIdentifier;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main "content" area of the CMS.
|
* The main "content" area of the CMS.
|
||||||
@ -79,6 +68,8 @@ use SilverStripe\CMS\Model\CurrentPageIdentifier;
|
|||||||
* @package cms
|
* @package cms
|
||||||
* @subpackage controller
|
* @subpackage controller
|
||||||
* @todo Create some base classes to contain the generic functionality that will be replicated.
|
* @todo Create some base classes to contain the generic functionality that will be replicated.
|
||||||
|
*
|
||||||
|
* @mixin LeftAndMainPageIconsExtension
|
||||||
*/
|
*/
|
||||||
class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionProvider {
|
class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionProvider {
|
||||||
|
|
||||||
@ -100,6 +91,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
private static $session_namespace = 'SilverStripe\\CMS\\Controllers\\CMSMain';
|
private static $session_namespace = 'SilverStripe\\CMS\\Controllers\\CMSMain';
|
||||||
|
|
||||||
|
private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Amount of results showing on a single page.
|
* Amount of results showing on a single page.
|
||||||
*
|
*
|
||||||
@ -176,7 +169,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
public function index($request) {
|
public function index($request) {
|
||||||
// In case we're not showing a specific record, explicitly remove any session state,
|
// In case we're not showing a specific record, explicitly remove any session state,
|
||||||
// to avoid it being highlighted in the tree, and causing an edit form to show.
|
// to avoid it being highlighted in the tree, and causing an edit form to show.
|
||||||
if(!$request->param('Action')) $this->setCurrentPageId(null);
|
if(!$request->param('Action')) {
|
||||||
|
$this->setCurrentPageID(null);
|
||||||
|
}
|
||||||
|
|
||||||
return parent::index($request);
|
return parent::index($request);
|
||||||
}
|
}
|
||||||
@ -203,6 +198,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
/**
|
/**
|
||||||
* Overloads the LeftAndMain::ShowView. Allows to pass a page as a parameter, so we are able
|
* Overloads the LeftAndMain::ShowView. Allows to pass a page as a parameter, so we are able
|
||||||
* to switch view also for archived versions.
|
* to switch view also for archived versions.
|
||||||
|
*
|
||||||
|
* @param SiteTree $page
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function SwitchView($page = null) {
|
public function SwitchView($page = null) {
|
||||||
if(!$page) {
|
if(!$page) {
|
||||||
@ -230,7 +228,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
public function Link($action = null) {
|
public function Link($action = null) {
|
||||||
$link = Controller::join_links(
|
$link = Controller::join_links(
|
||||||
AdminRootController::admin_url(),
|
AdminRootController::admin_url(),
|
||||||
$this->stat('url_segment', true), // in case we want to change the segment
|
$this->stat('url_segment'), // in case we want to change the segment
|
||||||
'/', // trailing slash needed if $action is null!
|
'/', // trailing slash needed if $action is null!
|
||||||
"$action"
|
"$action"
|
||||||
);
|
);
|
||||||
@ -404,7 +402,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$dateFrom,
|
$dateFrom,
|
||||||
$dateTo
|
$dateTo
|
||||||
);
|
);
|
||||||
$dateGroup->setTitle('Last Edited', _t('CMSSearch.PAGEFILTERDATEHEADING', 'Last edited'));
|
$dateGroup->setTitle(_t('CMSSearch.PAGEFILTERDATEHEADING', 'Last edited'));
|
||||||
|
|
||||||
// Create the Field list
|
// Create the Field list
|
||||||
$fields = new FieldList(
|
$fields = new FieldList(
|
||||||
@ -422,6 +420,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 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
|
||||||
|
/** @var FormAction $action */
|
||||||
foreach($actions->dataFields() as $action) {
|
foreach($actions->dataFields() as $action) {
|
||||||
/** @var FormAction $action */
|
/** @var FormAction $action */
|
||||||
$action->setUseButtonTag(true);
|
$action->setUseButtonTag(true);
|
||||||
@ -486,7 +485,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
* @return string Serialized JSON
|
* @return string Serialized JSON
|
||||||
*/
|
*/
|
||||||
public function SiteTreeHints() {
|
public function SiteTreeHints() {
|
||||||
$json = '';
|
|
||||||
$classes = SiteTree::page_type_classes();
|
$classes = SiteTree::page_type_classes();
|
||||||
|
|
||||||
$cacheCanCreate = array();
|
$cacheCanCreate = array();
|
||||||
@ -495,7 +493,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
// Generate basic cache key. Too complex to encompass all variations
|
// Generate basic cache key. Too complex to encompass all variations
|
||||||
$cache = SS_Cache::factory('CMSMain_SiteTreeHints');
|
$cache = SS_Cache::factory('CMSMain_SiteTreeHints');
|
||||||
$cacheKey = md5(implode('_', array(Member::currentUserID(), implode(',', $cacheCanCreate), implode(',', $classes))));
|
$cacheKey = md5(implode('_', array(Member::currentUserID(), implode(',', $cacheCanCreate), implode(',', $classes))));
|
||||||
if($this->getRequest()->getVar('flush')) $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
|
if($this->getRequest()->getVar('flush')) {
|
||||||
|
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
|
||||||
|
}
|
||||||
$json = $cache->load($cacheKey);
|
$json = $cache->load($cacheKey);
|
||||||
if(!$json) {
|
if(!$json) {
|
||||||
$def['Root'] = array();
|
$def['Root'] = array();
|
||||||
@ -710,7 +710,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$actions = $record->getCMSActions();
|
$actions = $record->getCMSActions();
|
||||||
|
|
||||||
// Find and remove action menus that have no actions.
|
// Find and remove action menus that have no actions.
|
||||||
if ($actions && $actions->Count()) {
|
if ($actions && $actions->count()) {
|
||||||
|
/** @var TabSet $tabset */
|
||||||
$tabset = $actions->fieldByName('ActionMenus');
|
$tabset = $actions->fieldByName('ActionMenus');
|
||||||
if ($tabset) {
|
if ($tabset) {
|
||||||
foreach ($tabset->getChildren() as $tab) {
|
foreach ($tabset->getChildren() as $tab) {
|
||||||
@ -724,7 +725,12 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
// Use <button> to allow full jQuery UI styling
|
// Use <button> to allow full jQuery UI styling
|
||||||
$actionsFlattened = $actions->dataFields();
|
$actionsFlattened = $actions->dataFields();
|
||||||
if($actionsFlattened) foreach($actionsFlattened as $action) $action->setUseButtonTag(true);
|
if($actionsFlattened) {
|
||||||
|
/** @var FormAction $action */
|
||||||
|
foreach($actionsFlattened as $action) {
|
||||||
|
$action->setUseButtonTag(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($record->hasMethod('getCMSValidator')) {
|
if($record->hasMethod('getCMSValidator')) {
|
||||||
$validator = $record->getCMSValidator();
|
$validator = $record->getCMSValidator();
|
||||||
@ -844,6 +850,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Form
|
||||||
|
*/
|
||||||
public function ListViewForm() {
|
public function ListViewForm() {
|
||||||
$params = $this->getRequest()->requestVar('q');
|
$params = $this->getRequest()->requestVar('q');
|
||||||
$list = $this->getList($params, $parentID = $this->getRequest()->requestVar('ParentID'));
|
$list = $this->getList($params, $parentID = $this->getRequest()->requestVar('ParentID'));
|
||||||
@ -860,6 +869,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
$gridField = new GridField('Page','Pages', $list, $gridFieldConfig);
|
$gridField = new GridField('Page','Pages', $list, $gridFieldConfig);
|
||||||
|
/** @var GridFieldDataColumns $columns */
|
||||||
$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
|
$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
|
||||||
|
|
||||||
// Don't allow navigating into children nodes on filtered lists
|
// Don't allow navigating into children nodes on filtered lists
|
||||||
@ -868,7 +878,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
'singular_name' => _t('SiteTree.PAGETYPE'),
|
'singular_name' => _t('SiteTree.PAGETYPE'),
|
||||||
'LastEdited' => _t('SiteTree.LASTUPDATED', 'Last Updated'),
|
'LastEdited' => _t('SiteTree.LASTUPDATED', 'Last Updated'),
|
||||||
);
|
);
|
||||||
$gridField->getConfig()->getComponentByType('GridFieldSortableHeader')->setFieldSorting(array('getTreeTitle' => 'Title'));
|
/** @var GridFieldSortableHeader $sortableHeader */
|
||||||
|
$sortableHeader = $gridField->getConfig()->getComponentByType('GridFieldSortableHeader');
|
||||||
|
$sortableHeader->setFieldSorting(array('getTreeTitle' => 'Title'));
|
||||||
$gridField->getState()->ParentID = $parentID;
|
$gridField->getState()->ParentID = $parentID;
|
||||||
|
|
||||||
if(!$params) {
|
if(!$params) {
|
||||||
@ -885,6 +897,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$controller = $this;
|
$controller = $this;
|
||||||
$columns->setFieldFormatting(array(
|
$columns->setFieldFormatting(array(
|
||||||
'listChildrenLink' => function($value, &$item) use($controller) {
|
'listChildrenLink' => function($value, &$item) use($controller) {
|
||||||
|
/** @var SiteTree $item */
|
||||||
$num = $item ? $item->numChildren() : null;
|
$num = $item ? $item->numChildren() : null;
|
||||||
if($num) {
|
if($num) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
@ -1029,12 +1042,17 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses LeftAndMainExtension->augmentNewSiteTreeItem()
|
* @uses LeftAndMainExtension->augmentNewSiteTreeItem()
|
||||||
|
*
|
||||||
|
* @param int|string $id
|
||||||
|
* @param bool $setID
|
||||||
|
* @return mixed|DataObject
|
||||||
|
* @throws SS_HTTPResponse_Exception
|
||||||
*/
|
*/
|
||||||
public function getNewItem($id, $setID = true) {
|
public function getNewItem($id, $setID = true) {
|
||||||
$parentClass = $this->stat('tree_class');
|
$parentClass = $this->stat('tree_class');
|
||||||
list($dummy, $className, $parentID, $suffix) = array_pad(explode('-',$id),4,null);
|
list($dummy, $className, $parentID, $suffix) = array_pad(explode('-',$id),4,null);
|
||||||
|
|
||||||
if(!is_subclass_of($className, $parentClass) && strcasecmp($className, $parentClass) != 0) {
|
if (!is_a($className, $parentClass, true)) {
|
||||||
$response = Security::permissionFailure($this);
|
$response = Security::permissionFailure($this);
|
||||||
if (!$response) {
|
if (!$response) {
|
||||||
$response = $this->getResponse();
|
$response = $this->getResponse();
|
||||||
@ -1042,8 +1060,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
throw new SS_HTTPResponse_Exception($response);
|
throw new SS_HTTPResponse_Exception($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
$newItem = new $className();
|
/** @var SiteTree $newItem */
|
||||||
|
$newItem = Injector::inst()->create($className);
|
||||||
if( !$suffix ) {
|
if( !$suffix ) {
|
||||||
$sessionTag = "NewItems." . $parentID . "." . $className;
|
$sessionTag = "NewItems." . $parentID . "." . $className;
|
||||||
if(Session::get($sessionTag)) {
|
if(Session::get($sessionTag)) {
|
||||||
@ -1236,7 +1254,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return SS_HTTPResponse
|
||||||
*/
|
*/
|
||||||
public function rollback() {
|
public function rollback() {
|
||||||
return $this->doRollback(array(
|
return $this->doRollback(array(
|
||||||
@ -1318,6 +1336,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$SNG_action = singleton($batchAction);
|
$SNG_action = singleton($batchAction);
|
||||||
if ($SNG_action->canView() && $fieldset = $SNG_action->getParameterFields()) {
|
if ($SNG_action->canView() && $fieldset = $SNG_action->getParameterFields()) {
|
||||||
$formHtml = '';
|
$formHtml = '';
|
||||||
|
/** @var FormField $field */
|
||||||
foreach($fieldset as $field) {
|
foreach($fieldset as $field) {
|
||||||
$formHtml .= $field->Field();
|
$formHtml .= $field->Field();
|
||||||
}
|
}
|
||||||
@ -1353,6 +1372,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$pages = SiteTree::get()->limit("$start,30");
|
$pages = SiteTree::get()->limit("$start,30");
|
||||||
$count = 0;
|
$count = 0;
|
||||||
while($pages) {
|
while($pages) {
|
||||||
|
/** @var SiteTree $page */
|
||||||
foreach($pages as $page) {
|
foreach($pages as $page) {
|
||||||
if($page && !$page->canPublish()) {
|
if($page && !$page->canPublish()) {
|
||||||
return Security::permissionFailure($this);
|
return Security::permissionFailure($this);
|
||||||
@ -1377,7 +1397,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$token = SecurityToken::inst();
|
$token = SecurityToken::inst();
|
||||||
$fields = new FieldList();
|
$fields = new FieldList();
|
||||||
$token->updateFieldSet($fields);
|
$token->updateFieldSet($fields);
|
||||||
$tokenField = $fields->First();
|
$tokenField = $fields->first();
|
||||||
$tokenHtml = ($tokenField) ? $tokenField->FieldHolder() : '';
|
$tokenHtml = ($tokenField) ? $tokenField->FieldHolder() : '';
|
||||||
$response .= '<h1>' . _t('CMSMain.PUBALLFUN','"Publish All" functionality') . '</h1>
|
$response .= '<h1>' . _t('CMSMain.PUBALLFUN','"Publish All" functionality') . '</h1>
|
||||||
<p>' . _t('CMSMain.PUBALLFUN2', 'Pressing this button will do the equivalent of going to every page and pressing "publish". It\'s
|
<p>' . _t('CMSMain.PUBALLFUN2', 'Pressing this button will do the equivalent of going to every page and pressing "publish". It\'s
|
||||||
@ -1395,6 +1415,10 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Restore a completely deleted page from the SiteTree_versions table.
|
* Restore a completely deleted page from the SiteTree_versions table.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @param Form $form
|
||||||
|
* @return SS_HTTPResponse
|
||||||
*/
|
*/
|
||||||
public function restore($data, $form) {
|
public function restore($data, $form) {
|
||||||
if(!isset($data['ID']) || !is_numeric($data['ID'])) {
|
if(!isset($data['ID']) || !is_numeric($data['ID'])) {
|
||||||
@ -1402,8 +1426,11 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
$id = (int)$data['ID'];
|
$id = (int)$data['ID'];
|
||||||
|
/** @var SiteTree $restoredPage */
|
||||||
$restoredPage = Versioned::get_latest_version("SilverStripe\\CMS\\Model\\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();
|
||||||
|
|
||||||
@ -1424,6 +1451,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)) {
|
||||||
|
/** @var SiteTree $page */
|
||||||
$page = SiteTree::get()->byID($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);
|
||||||
@ -1462,6 +1490,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)) {
|
||||||
|
/** @var SiteTree $page */
|
||||||
$page = SiteTree::get()->byID($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);
|
||||||
|
@ -11,11 +11,11 @@ use FieldList;
|
|||||||
use LiteralField;
|
use LiteralField;
|
||||||
use SelectionGroup;
|
use SelectionGroup;
|
||||||
use SelectionGroup_Item;
|
use SelectionGroup_Item;
|
||||||
|
use SS_HTTPResponse;
|
||||||
use TreeDropdownField;
|
use TreeDropdownField;
|
||||||
use OptionsetField;
|
use OptionsetField;
|
||||||
use FormAction;
|
use FormAction;
|
||||||
use Form;
|
use Form;
|
||||||
|
|
||||||
use Session;
|
use Session;
|
||||||
use Controller;
|
use Controller;
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
@ -151,8 +151,8 @@ class CMSPageAddController extends CMSPageEditController {
|
|||||||
$form->setValidationResponseCallback(function() use ($negotiator, $form) {
|
$form->setValidationResponseCallback(function() use ($negotiator, $form) {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
if($request->isAjax() && $negotiator) {
|
if($request->isAjax() && $negotiator) {
|
||||||
$this->setupFormErrors();
|
$form->setupFormErrors();
|
||||||
$result = $this->forTemplate();
|
$result = $form->forTemplate();
|
||||||
|
|
||||||
return $negotiator->respond($request, array(
|
return $negotiator->respond($request, array(
|
||||||
'CurrentForm' => function() use($result) {
|
'CurrentForm' => function() use($result) {
|
||||||
@ -167,6 +167,11 @@ class CMSPageAddController extends CMSPageEditController {
|
|||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
* @param Form $form
|
||||||
|
* @return SS_HTTPResponse
|
||||||
|
*/
|
||||||
public function doAdd($data, $form) {
|
public function doAdd($data, $form) {
|
||||||
$className = isset($data['PageType']) ? $data['PageType'] : "Page";
|
$className = isset($data['PageType']) ? $data['PageType'] : "Page";
|
||||||
$parentID = isset($data['ParentID']) ? (int)$data['ParentID'] : 0;
|
$parentID = isset($data['ParentID']) ? (int)$data['ParentID'] : 0;
|
||||||
|
@ -403,6 +403,7 @@ class CMSPageHistoryController extends CMSMain {
|
|||||||
/** @var SiteTree $page */
|
/** @var SiteTree $page */
|
||||||
$page = SiteTree::get()->byID($id);
|
$page = SiteTree::get()->byID($id);
|
||||||
|
|
||||||
|
$record = null;
|
||||||
if($page && $page->exists()) {
|
if($page && $page->exists()) {
|
||||||
if(!$page->canView()) {
|
if(!$page->canView()) {
|
||||||
return Security::permissionFailure($this);
|
return Security::permissionFailure($this);
|
||||||
|
@ -19,7 +19,6 @@ use Controller;
|
|||||||
use Page;
|
use Page;
|
||||||
|
|
||||||
use SiteConfig;
|
use SiteConfig;
|
||||||
use Config;
|
|
||||||
use SS_HTTPRequest;
|
use SS_HTTPRequest;
|
||||||
use Translatable;
|
use Translatable;
|
||||||
use i18n;
|
use i18n;
|
||||||
|
@ -4,10 +4,8 @@ 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;
|
use SilverStripe\CMS\Model\ErrorPage;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decorates {@see File} with ErrorPage support
|
* Decorates {@see File} with ErrorPage support
|
||||||
*/
|
*/
|
||||||
|
@ -7,7 +7,6 @@ use SilverStripe\ORM\DataModel;
|
|||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use Controller;
|
use Controller;
|
||||||
|
|
||||||
use ClassInfo;
|
use ClassInfo;
|
||||||
use Injector;
|
use Injector;
|
||||||
use SS_HTTPRequest;
|
use SS_HTTPRequest;
|
||||||
|
@ -4,6 +4,7 @@ namespace SilverStripe\CMS\Controllers;
|
|||||||
|
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
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;
|
||||||
@ -13,8 +14,6 @@ use ClassInfo;
|
|||||||
use Controller;
|
use Controller;
|
||||||
use SilverStripe\Admin\CMSPreviewable;
|
use SilverStripe\Admin\CMSPreviewable;
|
||||||
use SilverStripe\Admin\LeftAndMain;
|
use SilverStripe\Admin\LeftAndMain;
|
||||||
|
|
||||||
|
|
||||||
use SiteTreeFutureState;
|
use SiteTreeFutureState;
|
||||||
use SilverStripe\CMS\Model\RedirectorPage;
|
use SilverStripe\CMS\Model\RedirectorPage;
|
||||||
|
|
||||||
@ -393,6 +392,7 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem {
|
|||||||
|
|
||||||
public function getMessage() {
|
public function getMessage() {
|
||||||
if($date = Versioned::current_archived_date()) {
|
if($date = Versioned::current_archived_date()) {
|
||||||
|
/** @var DBDatetime $dateObj */
|
||||||
$dateObj = DBField::create_field('Datetime', $date);
|
$dateObj = DBField::create_field('Datetime', $date);
|
||||||
return "<div id=\"SilverStripeNavigatorMessage\" title=\"". _t('ContentControl.NOTEWONTBESHOWN', 'Note: this message will not be shown to your visitors') ."\">". _t('ContentController.ARCHIVEDSITEFROM', 'Archived site from') ."<br>" . $dateObj->Nice() . "</div>";
|
return "<div id=\"SilverStripeNavigatorMessage\" title=\"". _t('ContentControl.NOTEWONTBESHOWN', 'Note: this message will not be shown to your visitors') ."\">". _t('ContentController.ARCHIVEDSITEFROM', 'Archived site from') ."<br>" . $dateObj->Nice() . "</div>";
|
||||||
}
|
}
|
||||||
|
@ -82,8 +82,8 @@ use SilverStripe\Admin\CMSPreviewable;
|
|||||||
* @property string CanViewType Type of restriction for viewing this object.
|
* @property string CanViewType Type of restriction for viewing this object.
|
||||||
* @property string CanEditType Type of restriction for editing this object.
|
* @property string CanEditType Type of restriction for editing this object.
|
||||||
*
|
*
|
||||||
* @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()
|
* @method SiteTree Parent()
|
||||||
*
|
*
|
||||||
* @mixin Hierarchy
|
* @mixin Hierarchy
|
||||||
@ -403,8 +403,10 @@ 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('SilverStripe\\CMS\\Model\\SiteTree', $classes);
|
$baseClassIndex = array_search(__CLASS__, $classes);
|
||||||
if($baseClassIndex !== FALSE) unset($classes[$baseClassIndex]);
|
if($baseClassIndex !== false) {
|
||||||
|
unset($classes[$baseClassIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
$kill_ancestors = array();
|
$kill_ancestors = array();
|
||||||
|
|
||||||
@ -448,6 +450,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var SiteTree $page */
|
||||||
if (
|
if (
|
||||||
!($page = DataObject::get_by_id(__CLASS__, $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(__CLASS__, $arguments['id'])) // Attempt link to old version.
|
&& !($page = Versioned::get_latest_version(__CLASS__, $arguments['id'])) // Attempt link to old version.
|
||||||
@ -1925,9 +1928,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$dependentPages
|
$dependentPages
|
||||||
);
|
);
|
||||||
/** @var GridFieldDataColumns $dataColumns */
|
/** @var GridFieldDataColumns $dataColumns */
|
||||||
$dataColumns = $dependentTable
|
$dataColumns = $dependentTable->getConfig()->getComponentByType('GridFieldDataColumns');
|
||||||
->getConfig()
|
|
||||||
->getComponentByType('GridFieldDataColumns');
|
|
||||||
$dataColumns
|
$dataColumns
|
||||||
->setDisplayFields($dependentColumns)
|
->setDisplayFields($dependentColumns)
|
||||||
->setFieldFormatting(array(
|
->setFieldFormatting(array(
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<div class="cms-content-header north">
|
<div class="cms-content-header north">
|
||||||
<div class="cms-content-header-info">
|
<div class="cms-content-header-info">
|
||||||
<% with $Controller %>
|
<% with $Controller %>
|
||||||
<% include CMSBreadcrumbs %>
|
<% include SilverStripe\\Admin\\CMSBreadcrumbs %>
|
||||||
<% end_with %>
|
<% end_with %>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -4,21 +4,21 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="cms-content-header-nav">
|
<div class="cms-content-header-nav">
|
||||||
<% include CMSBreadcrumbs %>
|
<% include SilverStripe\\Admin\\CMSBreadcrumbs %>
|
||||||
|
|
||||||
<div class="cms-content-header-tabs">
|
<div class="cms-content-header-tabs">
|
||||||
<ul class="cms-tabset-nav-primary">
|
<ul class="cms-tabset-nav-primary">
|
||||||
<li class="content-treeview<% if class == 'CMSPageEditController' %> ui-tabs-active<% end_if %>">
|
<li class="content-treeview<% if $class == 'SilverStripe\\CMS\\Controllers\\CMSPageEditController' %> ui-tabs-active<% end_if %>">
|
||||||
<a href="$LinkPageEdit" class="cms-panel-link" title="Form_EditForm" data-href="$LinkPageEdit">
|
<a href="$LinkPageEdit" class="cms-panel-link" title="Form_EditForm" data-href="$LinkPageEdit">
|
||||||
<% _t('CMSMain.TabContent', 'Content') %>
|
<% _t('CMSMain.TabContent', 'Content') %>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="content-listview<% if class == 'CMSPageSettingsController' %> ui-tabs-active<% end_if %>">
|
<li class="content-listview<% if $class == 'SilverStripe\\CMS\\Controllers\\CMSPageSettingsController' %> ui-tabs-active<% end_if %>">
|
||||||
<a href="$LinkPageSettings" class="cms-panel-link" title="Form_EditForm" data-href="$LinkPageSettings">
|
<a href="$LinkPageSettings" class="cms-panel-link" title="Form_EditForm" data-href="$LinkPageSettings">
|
||||||
<% _t('CMSMain.TabSettings', 'Settings') %>
|
<% _t('CMSMain.TabSettings', 'Settings') %>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="content-listview<% if class == 'CMSPageHistoryController' %> ui-tabs-active<% end_if %>">
|
<li class="content-listview<% if $class == 'SilverStripe\\CMS\\Controllers\\CMSPageHistoryController' %> ui-tabs-active<% end_if %>">
|
||||||
<a href="$LinkPageHistory" class="cms-panel-link" title="Form_EditForm" data-href="$LinkPageHistory">
|
<a href="$LinkPageHistory" class="cms-panel-link" title="Form_EditForm" data-href="$LinkPageHistory">
|
||||||
<% _t('CMSMain.TabHistory', 'History') %>
|
<% _t('CMSMain.TabHistory', 'History') %>
|
||||||
</a>
|
</a>
|
||||||
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
<div class="cms-content-header-info">
|
<div class="cms-content-header-info">
|
||||||
<div class="section-heading">
|
<div class="section-heading">
|
||||||
<% include CMSSectionIcon %>
|
<% include SilverStripe\\Admin\\CMSSectionIcon %>
|
||||||
<span class="section-label"><a href="$LinkPages">{$MenuCurrentItem.Title}</a></span>
|
<span class="section-label"><a href="$LinkPages">{$MenuCurrentItem.Title}</a></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -28,7 +28,7 @@
|
|||||||
</a>
|
</a>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
<% include LeftAndMain_ViewModeSelector SelectID="preview-mode-dropdown-in-content" %>
|
<% include SilverStripe\\Admin\\LeftAndMain_ViewModeSelector SelectID="preview-mode-dropdown-in-content" %>
|
||||||
</div>
|
</div>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
</div>
|
</div>
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<div class="cms-content-header north">
|
<div class="cms-content-header north">
|
||||||
<div class="cms-content-header-info">
|
<div class="cms-content-header-info">
|
||||||
<% include CMSBreadcrumbs %>
|
<% include SilverStripe\\Admin\\CMSBreadcrumbs %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="cms-content-header-tabs">
|
<div class="cms-content-header-tabs">
|
Loading…
Reference in New Issue
Block a user