mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR Moved tree filtering in LeftAndMain from SiteTreeAsUL() into getSiteTreeFor() to allow filtering the initial tree (via GET parameters), rather than just through getsubtree()
This commit is contained in:
parent
9b2b39aaaa
commit
0ef5d0b84f
@ -590,9 +590,21 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
* @return String Nested unordered list with links to each page
|
||||
*/
|
||||
function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $numChildrenMethod = null, $filterFunction = null, $minNodeCount = 30) {
|
||||
// Filter criteria
|
||||
$params = $this->request->getVar('q');
|
||||
if(isset($params['FilterClass']) && $filterClass = $params['FilterClass']){
|
||||
if(!is_subclass_of($filterClass, 'CMSSiteTreeFilter')) {
|
||||
throw new Exception(sprintf('Invalid filter class passed: %s', $filterClass));
|
||||
}
|
||||
$filter = new $filterClass($params);
|
||||
} else {
|
||||
$filter = null;
|
||||
}
|
||||
|
||||
// Default childrenMethod and numChildrenMethod
|
||||
if (!$childrenMethod) $childrenMethod = 'AllChildrenIncludingDeleted';
|
||||
if (!$numChildrenMethod) $numChildrenMethod = 'numChildren';
|
||||
if(!$childrenMethod) $childrenMethod = ($filter && $filter->getChildrenMethod()) ? $filter->getChildrenMethod() : 'AllChildrenIncludingDeleted';
|
||||
if(!$numChildrenMethod) $numChildrenMethod = 'numChildren';
|
||||
if(!$filterFunction) $filterFunction = ($filter) ? array($filter, 'isPageIncluded') : null;
|
||||
|
||||
// Get the tree root
|
||||
$record = ($rootID) ? $this->getRecord($rootID) : null;
|
||||
@ -657,22 +669,12 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
* If ID = 0, then get the whole tree.
|
||||
*/
|
||||
public function getsubtree($request) {
|
||||
if($filterClass = $request->requestVar('FilterClass')) {
|
||||
if(!is_subclass_of($filterClass, 'CMSSiteTreeFilter')) {
|
||||
throw new Exception(sprintf('Invalid filter class passed: %s', $filterClass));
|
||||
}
|
||||
|
||||
$filter = new $filterClass($request->requestVars());
|
||||
} else {
|
||||
$filter = null;
|
||||
}
|
||||
|
||||
$html = $this->getSiteTreeFor(
|
||||
$this->stat('tree_class'),
|
||||
$request->getVar('ID'),
|
||||
($filter) ? $filter->getChildrenMethod() : null,
|
||||
null,
|
||||
($filter) ? array($filter, 'isPageIncluded') : null,
|
||||
null,
|
||||
null,
|
||||
$request->getVar('minNodeCount')
|
||||
);
|
||||
|
||||
|
@ -213,7 +213,7 @@
|
||||
};
|
||||
|
||||
var handledform = $(e.target).is('.cms-edit-form') ? $(e.target)[0] : $(e.target).find('.cms-edit-form')[0];
|
||||
var id = $(handledform.ID).val();
|
||||
var id = handledform ? $(handledform.ID).val() : null;
|
||||
|
||||
// check if a form with a valid ID exists
|
||||
if(id) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user