Merge branch 'MDL-25596' of git://github.com/samhemelryk/moodle

This commit is contained in:
Petr Skoda
2011-01-10 14:41:04 +01:00
3 changed files with 37 additions and 5 deletions
+7 -1
View File
@@ -107,7 +107,13 @@ class block_navigation extends block_base {
if (!empty($CFG->navcourselimit)) {
$limit = $CFG->navcourselimit;
}
$arguments = array('id'=>$this->instance->id, 'instance'=>$this->instance->id, 'candock'=>$this->instance_can_be_docked(), 'courselimit'=>$limit);
$arguments = array(
'id' => $this->instance->id,
'instance' => $this->instance->id,
'candock' => $this->instance_can_be_docked(),
'courselimit' => $limit,
'expansionlimit' => $this->config->expansionlimit
);
$this->page->requires->yui_module(array('core_dock', 'moodle-block_navigation-navigation'), 'M.block_navigation.init_add_tree', array($arguments));
}
+10 -4
View File
@@ -21,13 +21,16 @@ class block_navigation_renderer extends plugin_renderer_base {
// array of nested li elements
$lis = array();
foreach ($items as $item) {
if (!$item->display) {
if (!$item->display && !$item->contains_active_node()) {
continue;
}
$content = $item->get_content();
$title = $item->get_title();
$isbranch = ($item->type !== $expansionlimit && ($item->children->count() > 0 || ($item->nodetype == navigation_node::NODETYPE_BRANCH && $item->children->count()==0 && (isloggedin() || $item->type <= navigation_node::TYPE_CATEGORY))));
$hasicon = ((!$isbranch || $item->type == navigation_node::TYPE_ACTIVITY)&& $item->icon instanceof renderable);
$isexpandable = (empty($expansionlimit) || ($item->type > navigation_node::TYPE_ACTIVITY || $item->type < $expansionlimit) || ($item->contains_active_node() && $item->children->count() > 0));
$isbranch = $isexpandable && ($item->children->count() > 0 || ($item->has_children() && (isloggedin() || $item->type <= navigation_node::TYPE_CATEGORY)));
$hasicon = ((!$isbranch || $item->type == navigation_node::TYPE_ACTIVITY )&& $item->icon instanceof renderable);
if ($hasicon) {
$icon = $this->output->render($item->icon);
@@ -91,7 +94,10 @@ class block_navigation_renderer extends plugin_renderer_base {
if (!empty($item->id)) {
$divattr['id'] = $item->id;
}
$content = html_writer::tag('p', $content, $divattr) . $this->navigation_node($item->children, array(), $expansionlimit, $options, $depth+1);
$content = html_writer::tag('p', $content, $divattr);
if ($isexpandable) {
$content .= $this->navigation_node($item->children, array(), $expansionlimit, $options, $depth+1);
}
if (!empty($item->preceedwithhr) && $item->preceedwithhr===true) {
$content = html_writer::empty_tag('hr') . $content;
}
+20
View File
@@ -1,5 +1,11 @@
YUI.add('moodle-block_navigation-navigation', function(Y){
var EXPANSIONLIMIT_EVERYTHING = 0,
EXPANSIONLIMIT_COURSE = 20,
EXPANSIONLIMIT_SECTION = 30,
EXPANSIONLIMIT_ACTIVITY = 40;
/**
* Navigation tree class.
*
@@ -119,6 +125,12 @@ Y.extend(TREE, Y.Base, TREE.prototype, {
accordian : {
validator : Y.Lang.isBool,
value : false
},
expansionlimit : {
value : 0,
setter : function(val) {
return parseInt(val);
}
}
}
});
@@ -161,7 +173,15 @@ BRANCH.prototype = {
this.set(i, config.overrides[i]);
}
}
// Get the node for this branch
this.node = Y.one('#', this.get('id'));
// Now check whether the branch is not expandable because of the expansionlimit
var expansionlimit = this.get('tree').get('expansionlimit');
var type = this.get('type');
if (expansionlimit != EXPANSIONLIMIT_EVERYTHING && type >= expansionlimit && type <= EXPANSIONLIMIT_ACTIVITY) {
this.set('expandable', false);
this.set('haschildren', false);
}
},
/**
* Draws the branch within the tree.