Skip to content

Commit

Permalink
MDL-39824 output: tidied up output before bootstrap cleaning
Browse files Browse the repository at this point in the history
Conflicts:
	lib/pagelib.php
  • Loading branch information
Sam Hemelryk committed Jun 9, 2013
1 parent 2d28b03 commit 00f906b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/blocklib.php
Expand Up @@ -341,7 +341,7 @@ protected function get_move_target_url($region, $weight) {
* output the blocks anyway, so we are not doing wasted effort.) * output the blocks anyway, so we are not doing wasted effort.)
* *
* @param string $region a block region that exists on this page. * @param string $region a block region that exists on this page.
* @param object $output a core_renderer. normally the global $OUTPUT. * @param core_renderer $output a core_renderer. normally the global $OUTPUT.
* @return boolean Whether there is anything in this region. * @return boolean Whether there is anything in this region.
*/ */
public function region_has_content($region, $output) { public function region_has_content($region, $output) {
Expand Down
11 changes: 7 additions & 4 deletions lib/outputrenderers.php
Expand Up @@ -921,7 +921,7 @@ public function course_content_header($onlyifnotcalledbefore = false) {
$functioncalled = true; $functioncalled = true;
$courseformat = course_get_format($this->page->course); $courseformat = course_get_format($this->page->course);
if (($obj = $courseformat->course_content_header()) !== null) { if (($obj = $courseformat->course_content_header()) !== null) {
return $courseformat->get_renderer($this->page)->render($obj); return html_writer::div($courseformat->get_renderer($this->page)->render($obj), 'course-content-header');
} }
return ''; return '';
} }
Expand All @@ -948,7 +948,7 @@ public function course_content_footer($onlyifnotcalledbefore = false) {
require_once($CFG->dirroot.'/course/lib.php'); require_once($CFG->dirroot.'/course/lib.php');
$courseformat = course_get_format($this->page->course); $courseformat = course_get_format($this->page->course);
if (($obj = $courseformat->course_content_footer()) !== null) { if (($obj = $courseformat->course_content_footer()) !== null) {
return $courseformat->get_renderer($this->page)->render($obj); return html_writer::div($courseformat->get_renderer($this->page)->render($obj), 'course-content-footer');
} }
return ''; return '';
} }
Expand Down Expand Up @@ -2675,10 +2675,13 @@ public function tree_block_contents($items, $attrs = array()) {
*/ */
public function navbar() { public function navbar() {
$items = $this->page->navbar->get_items(); $items = $this->page->navbar->get_items();
$itemcount = count($items);
if ($itemcount === 0) {
return '';
}


$htmlblocks = array(); $htmlblocks = array();
// Iterate the navarray and display each node // Iterate the navarray and display each node
$itemcount = count($items);
$separator = get_separator(); $separator = get_separator();
for ($i=0;$i < $itemcount;$i++) { for ($i=0;$i < $itemcount;$i++) {
$item = $items[$i]; $item = $items[$i];
Expand Down Expand Up @@ -2827,7 +2830,7 @@ protected function render_custom_menu(custom_menu $menu) {
$jscode = "(function(){{$jscode}})"; $jscode = "(function(){{$jscode}})";
$this->page->requires->yui_module('node-menunav', $jscode); $this->page->requires->yui_module('node-menunav', $jscode);
// Build the root nodes as required by YUI // Build the root nodes as required by YUI
$content = html_writer::start_tag('div', array('id'=>'custom_menu_'.$menucount, 'class'=>'yui3-menu yui3-menu-horizontal javascript-disabled')); $content = html_writer::start_tag('div', array('id'=>'custom_menu_'.$menucount, 'class'=>'yui3-menu yui3-menu-horizontal javascript-disabled custom-menu'));
$content .= html_writer::start_tag('div', array('class'=>'yui3-menu-content')); $content .= html_writer::start_tag('div', array('class'=>'yui3-menu-content'));
$content .= html_writer::start_tag('ul'); $content .= html_writer::start_tag('ul');
// Render each child // Render each child
Expand Down
3 changes: 2 additions & 1 deletion lib/pagelib.php
Expand Up @@ -51,7 +51,8 @@
* the forum or quiz table) that this page belongs to. Will be null * the forum or quiz table) that this page belongs to. Will be null
* if this page is not within a module. * if this page is not within a module.
* @property-read array $alternativeversions Mime type => object with ->url and ->title. * @property-read array $alternativeversions Mime type => object with ->url and ->title.
* @property-read blocks_manager $blocks The blocks manager object for this page. * @property-read block_manager $blocks The blocks manager object for this page.
* @property-read array $blockmanipulations
* @property-read string $bodyclasses A string to use within the class attribute on the body tag. * @property-read string $bodyclasses A string to use within the class attribute on the body tag.
* @property-read string $bodyid A string to use as the id of the body tag. * @property-read string $bodyid A string to use as the id of the body tag.
* @property-read string $button The HTML to go where the Turn editing on button normally goes. * @property-read string $button The HTML to go where the Turn editing on button normally goes.
Expand Down
25 changes: 21 additions & 4 deletions lib/weblib.php
Expand Up @@ -909,20 +909,37 @@ function close_window($delay = 0, $reloadopener = false) {
* @return string The link to user documentation for this current page * @return string The link to user documentation for this current page
*/ */
function page_doc_link($text='') { function page_doc_link($text='') {
global $CFG, $PAGE, $OUTPUT; global $OUTPUT, $PAGE;
$path = page_get_doc_link_path($PAGE);
if (!$path) {
return '';
}
return $OUTPUT->doc_link($path, $text);
}

/**
* Returns the path to use when constructing a link to the docs.
*
* @since 2.5.1 2.6
* @global stdClass $CFG
* @param moodle_page $page
* @return string
*/
function page_get_doc_link_path(moodle_page $page) {
global $CFG;


if (empty($CFG->docroot) || during_initial_install()) { if (empty($CFG->docroot) || during_initial_install()) {
return ''; return '';
} }
if (!has_capability('moodle/site:doclinks', $PAGE->context)) { if (!has_capability('moodle/site:doclinks', $page->context)) {
return ''; return '';
} }


$path = $PAGE->docspath; $path = $page->docspath;
if (!$path) { if (!$path) {
return ''; return '';
} }
return $OUTPUT->doc_link($path, $text); return $path;
} }




Expand Down

0 comments on commit 00f906b

Please sign in to comment.