mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
BUGFIX Fixed newly created Group records in SecurityAdmin not having "admin/security/show/" link by adding missing site tree handlers in SecurityAdmin_left.js
MINOR Reworked SecurityAdmin->SiteTreeAsUL() code to be tidier and easier to understand BUGFIX Fixed ajax deletion of Group records properly - the site tree items didn't disappear immediately after deleting MINOR Removed AssetAdmin->returnItemToUser() as it does the same thing as the parent class' LeftAndMain MINOR Removed unused AssetAdmin_left.js and AssetAdmin_right.js Requirements calls in AssetAdmin - these files no longer exist git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@74980 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
f6386a4c47
commit
33ce4d8824
@ -75,8 +75,6 @@ class AssetAdmin extends LeftAndMain {
|
|||||||
Requirements::css(SAPPHIRE_DIR . "/css/ComplexTableField.css");
|
Requirements::css(SAPPHIRE_DIR . "/css/ComplexTableField.css");
|
||||||
|
|
||||||
Requirements::javascript(CMS_DIR . "/javascript/AssetAdmin.js");
|
Requirements::javascript(CMS_DIR . "/javascript/AssetAdmin.js");
|
||||||
Requirements::javascript(CMS_DIR . "/javascript/AssetAdmin_left.js");
|
|
||||||
Requirements::javascript(CMS_DIR . "/javascript/AssetAdmin_right.js");
|
|
||||||
|
|
||||||
Requirements::javascript(CMS_DIR . "/javascript/CMSMain_upload.js");
|
Requirements::javascript(CMS_DIR . "/javascript/CMSMain_upload.js");
|
||||||
Requirements::javascript(CMS_DIR . "/javascript/Upload.js");
|
Requirements::javascript(CMS_DIR . "/javascript/Upload.js");
|
||||||
@ -518,25 +516,6 @@ JS;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the given tree item to the client.
|
|
||||||
* If called by ajax, this will be some javascript commands.
|
|
||||||
* Otherwise, it will redirect back.
|
|
||||||
*/
|
|
||||||
public function returnItemToUser($p) {
|
|
||||||
if($_REQUEST['ajax']) {
|
|
||||||
$parentID = (int) $p->ParentID;
|
|
||||||
return <<<JS
|
|
||||||
tree = $('sitetree');
|
|
||||||
var newNode = tree.createTreeNode($p->ID, "$p->Title", "$p->class");
|
|
||||||
tree.getTreeNodeByIdx($parentID).appendTreeNode(newNode);
|
|
||||||
newNode.selectTreeNode();
|
|
||||||
JS;
|
|
||||||
} else {
|
|
||||||
Director::redirectBack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a folder
|
* Delete a folder
|
||||||
*/
|
*/
|
||||||
@ -545,16 +524,13 @@ JS;
|
|||||||
$ids = split(' *, *', $_REQUEST['csvIDs']);
|
$ids = split(' *, *', $_REQUEST['csvIDs']);
|
||||||
$script = '';
|
$script = '';
|
||||||
foreach($ids as $id) {
|
foreach($ids as $id) {
|
||||||
|
|
||||||
if(is_numeric($id)) {
|
if(is_numeric($id)) {
|
||||||
$record = DataObject::get_by_id($this->stat('tree_class'), $id);
|
$record = DataObject::get_by_id($this->stat('tree_class'), $id);
|
||||||
if(!$record) {
|
if($record) {
|
||||||
Debug::message( "Record appears to be null" );
|
$script .= $this->deleteTreeNodeJS($record);
|
||||||
|
$record->delete();
|
||||||
|
$record->destroy();
|
||||||
}
|
}
|
||||||
$record->delete();
|
|
||||||
$record->destroy();
|
|
||||||
|
|
||||||
$script .= $this->deleteTreeNodeJS($record);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +496,7 @@ class LeftAndMain extends Controller {
|
|||||||
public function returnItemToUser($p) {
|
public function returnItemToUser($p) {
|
||||||
if(Director::is_ajax()) {
|
if(Director::is_ajax()) {
|
||||||
// Prepare the object for insertion.
|
// Prepare the object for insertion.
|
||||||
$parentID = (int)$p->ParentID;
|
$parentID = (int) $p->ParentID;
|
||||||
$id = $p->ID ? $p->ID : "new-$p->class-$p->ParentID";
|
$id = $p->ID ? $p->ID : "new-$p->class-$p->ParentID";
|
||||||
$treeTitle = Convert::raw2js($p->TreeTitle());
|
$treeTitle = Convert::raw2js($p->TreeTitle());
|
||||||
$hasChildren = (is_numeric($id) && $p->AllChildren() && $p->AllChildren()->Count()) ? ' unexpanded' : '';
|
$hasChildren = (is_numeric($id) && $p->AllChildren() && $p->AllChildren()->Count()) ? ' unexpanded' : '';
|
||||||
@ -506,7 +506,9 @@ class LeftAndMain extends Controller {
|
|||||||
var tree = $('sitetree');
|
var tree = $('sitetree');
|
||||||
var newNode = tree.createTreeNode("$id", "$treeTitle", "{$p->class}{$hasChildren}");
|
var newNode = tree.createTreeNode("$id", "$treeTitle", "{$p->class}{$hasChildren}");
|
||||||
node = tree.getTreeNodeByIdx($parentID);
|
node = tree.getTreeNodeByIdx($parentID);
|
||||||
if(!node){ node = tree.getTreeNodeByIdx(0); }
|
if(!node) {
|
||||||
|
node = tree.getTreeNodeByIdx(0);
|
||||||
|
}
|
||||||
node.open();
|
node.open();
|
||||||
node.appendTreeNode(newNode);
|
node.appendTreeNode(newNode);
|
||||||
newNode.selectTreeNode();
|
newNode.selectTreeNode();
|
||||||
@ -515,12 +517,10 @@ JS;
|
|||||||
|
|
||||||
return FormResponse::respond();
|
return FormResponse::respond();
|
||||||
} else {
|
} else {
|
||||||
Director::redirect("admin/show/" . $p->ID);
|
Director::redirect('admin/' . self::$url_segment . '/show/' . $p->ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save and Publish page handler
|
* Save and Publish page handler
|
||||||
*/
|
*/
|
||||||
|
@ -42,16 +42,20 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
Requirements::css(THIRDPARTY_DIR . "/greybox/greybox.css");
|
Requirements::css(THIRDPARTY_DIR . "/greybox/greybox.css");
|
||||||
Requirements::css(SAPPHIRE_DIR . "/css/ComplexTableField.css");
|
Requirements::css(SAPPHIRE_DIR . "/css/ComplexTableField.css");
|
||||||
|
|
||||||
Requirements::javascript(CMS_DIR . "/javascript/SecurityAdmin.js");
|
Requirements::javascript(CMS_DIR . '/javascript/SecurityAdmin_left.js');
|
||||||
Requirements::javascript(CMS_DIR . "/javascript/SecurityAdmin_left.js");
|
Requirements::javascript(CMS_DIR . '/javascript/SecurityAdmin_right.js');
|
||||||
Requirements::javascript(CMS_DIR . "/javascript/SecurityAdmin_right.js");
|
|
||||||
|
|
||||||
Requirements::javascript(THIRDPARTY_DIR . "/greybox/AmiJS.js");
|
Requirements::javascript(THIRDPARTY_DIR . "/greybox/AmiJS.js");
|
||||||
Requirements::javascript(THIRDPARTY_DIR . "/greybox/greybox.js");
|
Requirements::javascript(THIRDPARTY_DIR . "/greybox/greybox.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEditForm($id) {
|
public function getEditForm($id) {
|
||||||
$record = DataObject::get_by_id($this->stat('tree_class'), $id);
|
$record = null;
|
||||||
|
|
||||||
|
if($id && $id != 'root') {
|
||||||
|
$record = DataObject::get_by_id($this->stat('tree_class'), $id);
|
||||||
|
}
|
||||||
|
|
||||||
if(!$record) return false;
|
if(!$record) return false;
|
||||||
|
|
||||||
$fields = $record->getCMSFields();
|
$fields = $record->getCMSFields();
|
||||||
@ -194,24 +198,32 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the entire site tree as a nested set of ULs
|
* Return the entire site tree as a nested set of ULs.
|
||||||
|
* @return string Unordered list <UL> HTML
|
||||||
*/
|
*/
|
||||||
public function SiteTreeAsUL() {
|
public function SiteTreeAsUL() {
|
||||||
$obj = singleton($this->stat('tree_class'));
|
$obj = singleton($this->stat('tree_class'));
|
||||||
|
$obj->markPartialTree();
|
||||||
|
|
||||||
|
if($p = $this->currentPage()) $obj->markToExpose($p);
|
||||||
|
|
||||||
// getChildrenAsUL is a flexible and complex way of traversing the tree
|
// getChildrenAsUL is a flexible and complex way of traversing the tree
|
||||||
$siteTreeItem = $obj->getChildrenAsUL("",
|
$siteTreeList = $obj->getChildrenAsUL(
|
||||||
' "<li id=\"record-$child->ID\" class=\"$child->class " . ($child->Locked ? " nodelete" : "") . ' .
|
'',
|
||||||
' ($extraArg->isCurrentPage($child) ? " current" : "") . "\">" . ' .
|
'"<li id=\"record-$child->ID\" class=\"$child->class " . ($child->Locked ? " nodelete" : "") . $child->markingClasses() . ($extraArg->isCurrentPage($child) ? " current" : "") . "\">" . ' .
|
||||||
' "<a href=\"admin/security/show/$child->ID\" >" . $child->TreeTitle() . "</a>" ',$this);
|
'"<a href=\"" . Director::link(substr($extraArg->Link(),0,-1), "show", $child->ID) . "\" >" . $child->TreeTitle() . "</a>" ',
|
||||||
|
$this,
|
||||||
$siteTree = "<ul id=\"sitetree\" class=\"tree unformatted\">" .
|
true
|
||||||
"<li id=\"record-0\" class=\"Root\">" .
|
);
|
||||||
"<a href=\"admin/security/show/0\" ><strong>"._t('SecurityAdmin.SGROUPS',"Security groups")."</strong></a>"
|
|
||||||
. $siteTreeItem .
|
|
||||||
"</li>" .
|
|
||||||
"</ul>";
|
|
||||||
|
|
||||||
|
// Wrap the root if needs be
|
||||||
|
$rootLink = $this->Link() . 'show/root';
|
||||||
|
$rootTitle = _t('SecurityAdmin.SGROUPS', 'Security Groups');
|
||||||
|
if(!isset($rootID)) {
|
||||||
|
$siteTree = "<ul id=\"sitetree\" class=\"tree unformatted\"><li id=\"record-root\" class=\"Root\"><a href=\"$rootLink\"><strong>{$rootTitle}</strong></a>"
|
||||||
|
. $siteTreeList . "</li></ul>";
|
||||||
|
}
|
||||||
|
|
||||||
return $siteTree;
|
return $siteTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Configuration for the left hand tree
|
||||||
|
*/
|
||||||
|
if(typeof SiteTreeHandlers == 'undefined') SiteTreeHandlers = {};
|
||||||
SiteTreeHandlers.parentChanged_url = 'admin/security/ajaxupdateparent';
|
SiteTreeHandlers.parentChanged_url = 'admin/security/ajaxupdateparent';
|
||||||
SiteTreeHandlers.orderChanged_url = 'admin/security/ajaxupdatesort';
|
SiteTreeHandlers.orderChanged_url = 'admin/security/ajaxupdatesort';
|
||||||
SiteTreeHandlers.loadPage_url = 'admin/security/getitem';
|
SiteTreeHandlers.loadPage_url = 'admin/security/getitem';
|
||||||
|
SiteTreeHandlers.loadTree_url = 'admin/security/getsubtree';
|
||||||
|
SiteTreeHandlers.showRecord_url = 'admin/security/show/';
|
||||||
SiteTreeHandlers.controller_url = 'admin/security';
|
SiteTreeHandlers.controller_url = 'admin/security';
|
||||||
|
|
||||||
_HANDLER_FORMS['deletegroup'] = 'deletegroup_options';
|
_HANDLER_FORMS['deletegroup'] = 'deletegroup_options';
|
||||||
|
Loading…
Reference in New Issue
Block a user