]> git.mjollnir.org Git - moodle.git/commitdiff
admin MDL-19799 Upgraded print_header and build_navigation calls to use PAGE and...
authorsamhemelryk <samhemelryk>
Thu, 3 Sep 2009 06:59:25 +0000 (06:59 +0000)
committersamhemelryk <samhemelryk>
Thu, 3 Sep 2009 06:59:25 +0000 (06:59 +0000)
lib/adminlib.php
lib/moodlelib.php
lib/pagelib.php
lib/portfolio/exporter.php
lib/simpletest/filtersettingsperformancetester.php
lib/simpletest/getstringperformancetester.php
lib/upgradelib.php
lib/weblib.php
portfolio/add.php

index 3903bf0aed27aeb2ae44048d9488fe42ab132115..79b8f3555f8d7ff944e6c98edc4f5169dd22f8ef 100644 (file)
@@ -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, "&nbsp;", "&nbsp;");
+        $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();
 }
 
 /**
index abede6ec968e7f96d592f68d87888f757d102ae6..5dece66877d23d6eb07ae5bf94181150ae2a1af2 100644 (file)
@@ -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 {
index 3acf7bd5976cf06393430f7f8154f2accee83b43..4cf2cd2106d46aae8bb07e53e47e403e948c2f51 100644 (file)
@@ -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 .= '</tr></table>';
 
-        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();
     }
 }
 
index 2713743e1f241981054c5025e4d54c019fc2fc89..7a13499867c1fd2aca906eca818749107a8b5f33 100644 (file)
@@ -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();
index 04f9ab8c522bb62410ac95f12c932a678017fae3..99aa691807c2b7611711c5d2b8fc42b50ddb68f4 100644 (file)
@@ -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)) {
index 8bd49987f21d2f1d6f8f6b718a80455389558285..c01d19bc9dbdc82fe2b9c4677db3711415afd197 100644 (file)
@@ -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;
index d0a89bd9ce42d452f33fe4f2cf8b665c504d1cfe..ae59159b1469049a49095bc81f688c35edf6298b 100644 (file)
@@ -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, '&nbsp;', '&nbsp;');
+            $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);
index b5b6316d7f1e7010039839a790d05616b5bf7516..021f4cdbef7dc4ba530cd015473718292280361b 100644 (file)
@@ -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='&nbsp;', $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 = '<a href="'.$CFG->wwwroot.'/course/view.php?id='. $COURSE->id .'">'. $COURSE->shortname .'</a> ->';
-            $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');
index ee4b8b8304b22f08b22c08dbe83666ccc2c46a5c..5fdd841fb4650ef6eee4d5f7797d5a4a9b6ceb5a 100644 (file)
@@ -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);