Skip to content

Commit

Permalink
MDL-35655 Navigation - Generalized fetching method of navigation obje…
Browse files Browse the repository at this point in the history
…ct and renderer in navigation block
  • Loading branch information
itamart committed Sep 27, 2012
1 parent 5d6285c commit c8ed281
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions blocks/navigation/block_navigation.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -177,9 +177,10 @@ function get_content() {
$trimlength = (int)$this->config->trimlength; $trimlength = (int)$this->config->trimlength;
} }


// Initialise (only actually happens if it hasn't already been done yet // Get the navigation object or don't display the block if none provided.
$this->page->navigation->initialise(); if (!$navigation = $this->get_navigation()) {
$navigation = clone($this->page->navigation); return null;
}
$expansionlimit = null; $expansionlimit = null;
if (!empty($this->config->expansionlimit)) { if (!empty($this->config->expansionlimit)) {
$expansionlimit = $this->config->expansionlimit; $expansionlimit = $this->config->expansionlimit;
Expand All @@ -204,7 +205,7 @@ function get_content() {
$options['linkcategories'] = (!empty($this->config->linkcategories) && $this->config->linkcategories == 'yes'); $options['linkcategories'] = (!empty($this->config->linkcategories) && $this->config->linkcategories == 'yes');


// Grab the items to display // Grab the items to display
$renderer = $this->page->get_renderer('block_navigation'); $renderer = $this->page->get_renderer($this->blockname);
$this->content = new stdClass(); $this->content = new stdClass();
$this->content->text = $renderer->navigation_tree($navigation, $expansionlimit, $options); $this->content->text = $renderer->navigation_tree($navigation, $expansionlimit, $options);


Expand All @@ -214,6 +215,17 @@ function get_content() {
return $this->content; return $this->content;
} }


/**
* Returns the navigation
*
* @return navigation_node The navigation object to display
*/
protected function get_navigation() {
// Initialise (only actually happens if it hasn't already been done yet)
$this->page->navigation->initialise();
return clone($this->page->navigation);
}

/** /**
* Returns the attributes to set for this block * Returns the attributes to set for this block
* *
Expand Down

0 comments on commit c8ed281

Please sign in to comment.