From: samhemelryk Date: Thu, 3 Sep 2009 06:59:25 +0000 (+0000) Subject: admin MDL-19799 Upgraded print_header and build_navigation calls to use PAGE and... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=de6d81e6670a12c8eeb47721bd51a43420cff047;p=moodle.git admin MDL-19799 Upgraded print_header and build_navigation calls to use PAGE and OUTPUT equivilants --- diff --git a/lib/adminlib.php b/lib/adminlib.php index 3903bf0aed..79b8f3555f 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -5185,8 +5185,11 @@ function admin_externalpage_print_header($focus='') { // During initial install. $strinstallation = get_string('installation', 'install'); $strsettings = get_string('settings'); - $navigation = build_navigation(array(array('name'=>$strsettings, 'link'=>null, 'type'=>'misc'))); - print_header($strinstallation, $strinstallation, $navigation, "", "", false, " ", " "); + $PAGE->navbar->add($strsettings); + $PAGE->set_title($strinstallation); + $PAGE->set_heading($strinstallation); + $PAGE->set_cacheable(false); + echo $OUTPUT->header(); return; } @@ -5210,7 +5213,11 @@ function admin_externalpage_print_header($focus='') { $buttons = $OUTPUT->button(html_form::make_button($PAGE->url->out(false), $options, $caption, 'get')); } - print_header("$SITE->shortname: " . implode(": ",$visiblepathtosection), $SITE->fullname, array(), $focus, '', true, $buttons, ''); + $PAGE->set_title("$SITE->shortname: " . implode(": ",$visiblepathtosection)); + $PAGE->set_heading($SITE->fullname); + $PAGE->set_focuscontrol($focus); + $PAGE->set_button($buttons); + echo $OUTPUT->header(); } /** diff --git a/lib/moodlelib.php b/lib/moodlelib.php index abede6ec96..5dece66877 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2197,8 +2197,8 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null, $setwantsu default: /// Guests not allowed $strloggedinasguest = get_string('loggedinasguest'); - print_header_simple('', '', - build_navigation(array(array('name' => $strloggedinasguest, 'link' => null, 'type' => 'misc')))); + $PAGE->navbar->add($strloggedinasguest); + print_header_simple(); if (empty($USER->access['rsw'][$COURSE->context->path])) { // Normal guest notice(get_string('guestsnotallowed', '', format_string($COURSE->fullname)), get_login_url()); } else { diff --git a/lib/pagelib.php b/lib/pagelib.php index 3acf7bd597..4cf2cd2106 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -1598,7 +1598,7 @@ class page_generic_activity extends page_base { // people upgrading legacy code need to copy it. See // http://docs.moodle.org/en/Development:Migrating_your_code_code_to_the_2.0_rendering_API function print_header($title, $morenavlinks = NULL, $bodytags = '', $meta = '') { - global $USER, $CFG; + global $USER, $CFG, $PAGE, $OUTPUT; $this->init_full(); $replacements = array( @@ -1617,11 +1617,22 @@ class page_generic_activity extends page_base { } $buttons .= ''; - if (empty($morenavlinks)) { - $morenavlinks = array(); + if (!empty($morenavlinks) && is_array($morenavlinks)) { + foreach ($morenavlinks as $navitem) { + if (is_array($navitem) && array_key_exists('name', $navitem)) { + $link = null; + if (array_key_exists('link', $navitem)) { + $link = $navitem['link']; + } + $PAGE->navbar->add($navitem['name'], null, null, navigation_node::TYPE_CUSTOM, $link); + } + } } - $navigation = build_navigation($morenavlinks, $this->modulerecord); - print_header($title, $this->course->fullname, $navigation, '', $meta, true, $buttons, navmenu($this->course, $this->modulerecord), false, $bodytags); + + $PAGE->set_title($title); + $PAGE->set_heading($this->course->fullname); + $PAGE->set_button($buttons); + echo $OUTPUT->heading(); } } diff --git a/lib/portfolio/exporter.php b/lib/portfolio/exporter.php index 2713743e1f..7a13499867 100644 --- a/lib/portfolio/exporter.php +++ b/lib/portfolio/exporter.php @@ -126,8 +126,10 @@ class portfolio_exporter { * @param portfolio_caller_base subclass $caller portfolio caller (passed by reference) * @param string $callerfile path to callerfile (relative to dataroot) * @param string $navigation result of build_navigation (passed to print_header) + * deprecated argument as of Moodle 2.0, please use $PAGE methods + * instead. */ - public function __construct(&$instance, &$caller, $callerfile, $navigation) { + public function __construct(&$instance, &$caller, $callerfile, $navigation='') { $this->instance =& $instance; $this->caller =& $caller; if ($instance) { @@ -572,11 +574,13 @@ class portfolio_exporter { * @param string $headerstring key for a portfolio language string */ public function print_header($headingstr, $summary=true) { - global $OUTPUT; + global $OUTPUT, $PAGE; $titlestr = get_string('exporting', 'portfolio'); $headerstr = get_string('exporting', 'portfolio'); - print_header($titlestr, $headerstr, $this->navigation); + $PAGE->set_title($titlestr); + $PAGE->set_heading($headerstr); + echo $OUTPUT->header(); $hstr = get_string($headingstr, 'portfolio'); if (strpos($hstr, '[[') === 0) { $hstr = $headingstr; @@ -788,9 +792,12 @@ class portfolio_exporter { * through the usage of the backbutton */ public static function print_expired_export() { - global $CFG, $OUTPUT; + global $CFG, $OUTPUT, $PAGE; $title = get_string('exportexpired', 'portfolio'); - print_header($title, $title, build_navigation(get_string('exportexpired', 'portfolio'))); + $PAGE->navbar->add(get_string('exportexpired', 'portfolio')); + $PAGE->set_title($title); + $PAGE->set_heading($title); + echo $OUTPUT->header(); echo $OUTPUT->notification(get_string('exportexpireddesc', 'portfolio')); echo $OUTPUT->continue_button($CFG->wwwroot); echo $OUTPUT->footer(); diff --git a/lib/simpletest/filtersettingsperformancetester.php b/lib/simpletest/filtersettingsperformancetester.php index 04f9ab8c52..99aa691807 100644 --- a/lib/simpletest/filtersettingsperformancetester.php +++ b/lib/simpletest/filtersettingsperformancetester.php @@ -41,7 +41,10 @@ require_capability('moodle/site:config', $syscontext); $baseurl = $CFG->wwwroot . '/lib/simpletest/filtersettingsperformancetester.php'; $title = 'filter_get_active_in_context performance test'; -print_header($title, $title, build_navigation($title)); +$PAGE->navbar->add($title); +$PAGE->set_title($title); +$PAGE->set_heading($title); +echo $OUTPUT->header(); // Complain if we get this far and $CFG->unittestprefix is not set. if (empty($CFG->unittestprefix)) { diff --git a/lib/simpletest/getstringperformancetester.php b/lib/simpletest/getstringperformancetester.php index 8bd49987f2..c01d19bc9d 100644 --- a/lib/simpletest/getstringperformancetester.php +++ b/lib/simpletest/getstringperformancetester.php @@ -41,7 +41,10 @@ require_login(); require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); $title = 'get_string performance test'; -print_header($title, $title, build_navigation($title)); +$PAGE->navbar->add($title); +$PAGE->set_title($title); +$PAGE->set_heading($title); +echo $OUTPUT->header(); $installedlangs = get_list_of_languages(); $requiredlangs = $TEST_LANGUAGES; diff --git a/lib/upgradelib.php b/lib/upgradelib.php index d0a89bd9ce..ae59159b14 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -770,7 +770,7 @@ function upgrade_log($type, $plugin, $info, $details=null, $backtrace=null) { * @global object */ function upgrade_started($preinstall=false) { - global $CFG, $DB, $PAGE; + global $CFG, $DB, $PAGE, $OUTPUT; static $started = false; @@ -786,9 +786,11 @@ function upgrade_started($preinstall=false) { $strupgrade = get_string('upgradingversion', 'admin'); $PAGE->set_generaltype('maintenance'); upgrade_get_javascript(); - print_header($strupgrade.' - Moodle '.$CFG->target_release, $strupgrade, - build_navigation(array(array('name' => $strupgrade, 'link' => null, 'type' => 'misc'))), '', - '', false, ' ', ' '); + $PAGE->set_title($strupgrade.' - Moodle '.$CFG->target_release); + $PAGE->set_heading($strupgrade); + $PAGE->navbar->add($strupgrade); + $PAGE->set_cacheable(false); + echo $OUTPUT->header(); } ignore_user_abort(true); diff --git a/lib/weblib.php b/lib/weblib.php index b5b6316d7f..021f4cdbef 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -643,7 +643,7 @@ function break_up_long_words($string, $maxsize=20, $cutchar=' ') { return $output; } -/* +/** * Try and close the current window using JavaScript, either immediately, or after a delay. * * Echo's out the resulting XHTML & javascript @@ -658,7 +658,8 @@ function close_window($delay = 0, $reloadopener = false) { global $THEME, $PAGE, $OUTPUT; if (!$PAGE->headerprinted) { - print_header(get_string('closewindow')); + $PAGE->set_title(get_string('closewindow')); + echo $OUTPUT->header(); } else { print_container_end_all(false, $THEME->open_header_containers); } @@ -1813,23 +1814,26 @@ function send_headers($contenttype, $cacheable = true) { function print_header_simple($title='', $heading='', $navigation='', $focus='', $meta='', $cache=true, $button=' ', $menu='', $usexml=false, $bodytags='', $return=false) { - global $COURSE, $CFG; + global $COURSE, $CFG, $PAGE, $OUTPUT; - // if we have no navigation specified, build it - if( empty($navigation) ){ - $navigation = build_navigation(''); + if ($meta) { + throw new coding_exception('The $meta parameter to print_header is no longer supported. '. + 'You should be able to do everything you want with $PAGE->requires and other such mechanisms.'); } - - // If old style nav prepend course short name otherwise leave $navigation object alone - if (!is_newnav($navigation)) { - if ($COURSE->id != SITEID) { - $shortname = ''. $COURSE->shortname .' ->'; - $navigation = $shortname.' '.$navigation; - } + if ($usexml) { + throw new coding_exception('The $usexml parameter to print_header is no longer supported.'); } + if ($bodytags) { + throw new coding_exception('The $bodytags parameter to print_header is no longer supported.'); + } + + $PAGE->set_title($title); + $PAGE->set_heading($heading); + $PAGE->set_focuscontrol($focus); + $PAGE->set_cacheable(true); + $PAGE->set_button($button); - $output = print_header($COURSE->shortname .': '. $title, $COURSE->fullname .' '. $heading, $navigation, $focus, $meta, - $cache, $button, $menu, $usexml, $bodytags, true); + $output = $OUTPUT->header(); if ($return) { return $output; @@ -2725,7 +2729,8 @@ function notice ($message, $link='', $course=NULL) { if (!$PAGE->headerprinted) { //header not yet printed - print_header(get_string('notice')); + $PAGE->set_title(get_string('notice')); + echo $OUTPUT->header(); } else { print_container_end_all(false, $THEME->open_header_containers); } @@ -2922,7 +2927,9 @@ function print_maintenance_message() { $PAGE->set_pagetype('maintenance-message'); $PAGE->set_generaltype('maintenance'); - print_header(strip_tags($SITE->fullname), $SITE->fullname, 'home'); + $PAGE->set_title(strip_tags($SITE->fullname)); + $PAGE->set_heading($SITE->fullname); + echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('sitemaintenance', 'admin')); if (isset($CFG->maintenance_message) and !html_is_blank($CFG->maintenance_message)) { echo $OUTPUT->box_start('maintenance_message generalbox boxwidthwide boxaligncenter'); diff --git a/portfolio/add.php b/portfolio/add.php index ee4b8b8304..5fdd841fb4 100644 --- a/portfolio/add.php +++ b/portfolio/add.php @@ -171,11 +171,13 @@ if (!empty($dataid)) { // todo this will have to change when we have things exporting content outside the course context (eg blogs) require_login($course, false, $cm); - $extranav[] = array('type' => 'title', 'name' => get_string('exporting', 'portfolio')); - $navigation = build_navigation($extranav, $cm); + foreach ($extranav as $navitem) { + $PAGE->navbar->add($navitem['name']); + } + $PAGE->navbar->add(get_string('exporting', 'portfolio')); - // finally! set up the exporter object with the portfolio instance, caller information, and navigation elements - $exporter = new portfolio_exporter($instance, $caller, $callbackfile, $navigation); + // finally! set up the exporter object with the portfolio instance, and caller information elements + $exporter = new portfolio_exporter($instance, $caller, $callbackfile); // set the export-specific variables, and save. $exporter->set('user', $USER);