mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
ENHANCEMENT Query ajaxExpansion on tree nodes without node limitation on serverside (see Hierarchy->markPartialTree()) to avoid "missing" nodes during the selection
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@81458 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
119121b0f2
commit
fece6769fe
@ -496,7 +496,7 @@ class LeftAndMain extends Controller {
|
|||||||
* @param $childrenMethod The method to call to get the children of the tree. For example,
|
* @param $childrenMethod The method to call to get the children of the tree. For example,
|
||||||
* Children, AllChildrenIncludingDeleted, or AllHistoricalChildren
|
* Children, AllChildrenIncludingDeleted, or AllHistoricalChildren
|
||||||
*/
|
*/
|
||||||
function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $filterFunction = null) {
|
function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $filterFunction = null, $minNodeCount = 30) {
|
||||||
// Default childrenMethod
|
// Default childrenMethod
|
||||||
if (!$childrenMethod) $childrenMethod = 'AllChildrenIncludingDeleted';
|
if (!$childrenMethod) $childrenMethod = 'AllChildrenIncludingDeleted';
|
||||||
|
|
||||||
@ -505,19 +505,27 @@ class LeftAndMain extends Controller {
|
|||||||
|
|
||||||
// Mark the nodes of the tree to return
|
// Mark the nodes of the tree to return
|
||||||
if ($filterFunction) $obj->setMarkingFilterFunction($filterFunction);
|
if ($filterFunction) $obj->setMarkingFilterFunction($filterFunction);
|
||||||
$obj->markPartialTree(30, $this, $childrenMethod);
|
|
||||||
|
$obj->markPartialTree($minNodeCount, $this, $childrenMethod);
|
||||||
|
|
||||||
// Ensure current page is exposed
|
// Ensure current page is exposed
|
||||||
if($p = $this->currentPage()) $obj->markToExpose($p);
|
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
|
||||||
$siteTree = $obj->getChildrenAsUL("", '
|
$titleEval = '
|
||||||
"<li id=\"record-$child->ID\" class=\"" . $child->CMSTreeClasses($extraArg) . "\">" .
|
"<li id=\"record-$child->ID\" class=\"" . $child->CMSTreeClasses($extraArg) . "\">" .
|
||||||
"<a href=\"" . Director::link(substr($extraArg->Link(),0,-1), "show", $child->ID) . "\" class=\"" . $child->CMSTreeClasses($extraArg) . "\" title=\"' . _t('LeftAndMain.PAGETYPE','Page type: ') . '".$child->class."\" >" .
|
"<a href=\"" . Director::link(substr($extraArg->Link(),0,-1), "show", $child->ID) . "\" class=\"" . $child->CMSTreeClasses($extraArg) . "\" title=\"' . _t('LeftAndMain.PAGETYPE','Page type: ') . '".$child->class."\" >" .
|
||||||
($child->TreeTitle()) .
|
($child->TreeTitle()) .
|
||||||
"</a>"
|
"</a>"
|
||||||
'
|
';
|
||||||
,$this, true, $childrenMethod);
|
$siteTree = $obj->getChildrenAsUL(
|
||||||
|
"",
|
||||||
|
$titleEval,
|
||||||
|
$this,
|
||||||
|
true,
|
||||||
|
$childrenMethod,
|
||||||
|
$minNodeCount
|
||||||
|
);
|
||||||
|
|
||||||
// Wrap the root if needs be.
|
// Wrap the root if needs be.
|
||||||
|
|
||||||
@ -539,9 +547,16 @@ class LeftAndMain extends Controller {
|
|||||||
* Get a subtree underneath the request param 'ID'.
|
* Get a subtree underneath the request param 'ID'.
|
||||||
* If ID = 0, then get the whole tree.
|
* If ID = 0, then get the whole tree.
|
||||||
*/
|
*/
|
||||||
public function getsubtree() {
|
public function getsubtree($request) {
|
||||||
// Get the tree
|
// Get the tree
|
||||||
$tree = $this->getSiteTreeFor($this->stat('tree_class'), $_REQUEST['ID']);
|
$minNodeCount = (is_numeric($request->getVar('minNodeCount'))) ? $request->getVar('minNodeCount') : NULL;
|
||||||
|
$tree = $this->getSiteTreeFor(
|
||||||
|
$this->stat('tree_class'),
|
||||||
|
$request->getVar('ID'),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$minNodeCount
|
||||||
|
);
|
||||||
|
|
||||||
// Trim off the outer tag
|
// Trim off the outer tag
|
||||||
$tree = ereg_replace('^[ \t\r\n]*<ul[^>]*>','', $tree);
|
$tree = ereg_replace('^[ \t\r\n]*<ul[^>]*>','', $tree);
|
||||||
|
@ -219,8 +219,15 @@ TreeNodeAPI.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var args = {ajax:1, ID:this.getIdx()};
|
var args = {ajax:1, ID:this.getIdx()};
|
||||||
|
|
||||||
|
// Add current locale for any subtree selection
|
||||||
if ($('LangSelector')) args.locale = $('LangSelector').value;
|
if ($('LangSelector')) args.locale = $('LangSelector').value;
|
||||||
|
|
||||||
|
// If the tree is selectable, we have to show all available children without
|
||||||
|
// artificial limitations from the serverside (minNodeCount). This is a measure
|
||||||
|
// to ensure no unexpanded nodes are missed in batch selection
|
||||||
|
if(Element.hasClassName('sitetree', 'multiselect')) args.minNodeCount = 0;
|
||||||
|
|
||||||
url = this.tree.url(args);
|
url = this.tree.url(args);
|
||||||
|
|
||||||
new Ajax.Request(url, {
|
new Ajax.Request(url, {
|
||||||
|
Loading…
Reference in New Issue
Block a user