question MDL-19820 Updated print_header and build_navigation to OUTPUT and PAGE equiv...
authorsamhemelryk <samhemelryk>
Mon, 7 Sep 2009 02:36:39 +0000 (02:36 +0000)
committersamhemelryk <samhemelryk>
Mon, 7 Sep 2009 02:36:39 +0000 (02:36 +0000)
question/addquestion.php
question/category.php
question/contextmove.php
question/contextmoveq.php
question/export.php
question/import.php
question/preview.php
question/question.php

index 0f6599d..88c8a44 100644 (file)
@@ -78,21 +78,19 @@ if (!empty($appendqnumstring)) {
 
 $chooseqtype = get_string('chooseqtypetoadd', 'question');
 if ($cm !== null) {
-    $navlinks = array();
     if (stripos($returnurl, "$CFG->wwwroot/mod/{$cm->modname}/view.php")!== 0) {
         //don't need this link if returnurl returns to view.php
-        $navlinks[] = array('name' => get_string('editinga', 'moodle', get_string('modulename', $cm->modname)), 'link' => $returnurl, 'type' => 'title');
+        $PAGE->navbar->add(get_string('editinga', 'moodle', get_string('modulename', $cm->modname)),$returnurl);
     }
-    $navlinks[] = array('name' => $chooseqtype, 'link' => '', 'type' => 'title');
-    $navigation = build_navigation($navlinks, $cm);
-    print_header_simple($chooseqtype, '', $navigation, '', '', true, update_module_button($cm->id, $cm->course, get_string('modulename', $cm->modname)));
-
+    $PAGE->navbar->add($chooseqtype);
+    $PAGE->set_title($chooseqtype);
+    $PAGE->set_button(update_module_button($cm->id, $cm->course, get_string('modulename', $cm->modname)));
+    echo $OUTPUT->header();
 } else {
-    $navlinks = array();
-    $navlinks[] = array('name' => get_string('editquestions', 'question'), 'link' => $returnurl, 'type' => 'title');
-    $navlinks[] = array('name' => $chooseqtype, 'link' => '', 'type' => 'title');
-    $navigation = build_navigation($navlinks);
-    print_header_simple($chooseqtype, '', $navigation);
+    $PAGE->navbar->add(get_string('editquestions', 'question'),$returnurl);
+    $PAGE->navbar->add($chooseqtype);
+    $PAGE->set_title($chooseqtype);
+    echo $OUTPUT->header();
 }
 
 // Display a form to choose the question type.
index 345a7ad..1d71c3b 100644 (file)
         $thispageurl->remove_params('cat', 'category');
         redirect($thispageurl);
     }
-    $navlinks = array();
     if ($cm!==null) {
         // Page header
         $strupdatemodule = has_capability('moodle/course:manageactivities', $contexts->lowest())
             ? update_module_button($cm->id, $COURSE->id, get_string('modulename', $cm->modname))
             : "";
-        $navlinks[] = array('name' => get_string('modulenameplural', $cm->modname),
-                            'link' => "$CFG->wwwroot/mod/{$cm->modname}/index.php?id=$COURSE->id",
-                            'type' => 'activity');
-        $navlinks[] = array('name' => format_string($module->name),
-                            'link' => "$CFG->wwwroot/mod/{$cm->modname}/view.php?id={$cm->id}",
-                            'type' => 'title');
+        $PAGE->navbar->add(get_string('modulenameplural', $cm->modname), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/index.php', array('id'=>$COURSE->id)));
+        $PAGE->navbar->add(format_string($module->name), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/view.php', array('id'=>$cm->id)));
     } else {
         // Print basic page layout.
         $strupdatemodule = '';
     }
 
     if (!$param->edit){
-        $navlinks[] = array('name' => $streditingcategories, 'link' => '', 'type' => 'title');
+        $PAGE->navbar->add($streditingcategories);
     } else {
-        $navlinks[] = array('name' => $streditingcategories, 'link' => $thispageurl->out(), 'type' => 'title');
-        $navlinks[] = array('name' => get_string('editingcategory', 'question'), 'link' => '', 'type' => 'title');
+        $PAGE->navbar->add($streditingcategories, $thispageurl->out());
+        $PAGE->navbar->add(get_string('editingcategory', 'question'));
     }
 
-    $navigation = build_navigation($navlinks);
-    print_header_simple($streditingcategories, '', $navigation, "", "", true, $strupdatemodule);
+    $PAGE->set_title($streditingcategories);
+    $PAGE->set_button($strupdatemodule);
+    echo $OUTPUT->header();
 
     // print tabs
     if ($cm!==null) {
index 1662132..33f9381 100644 (file)
     }
 
     $streditingcategories = get_string('editcategories', 'quiz');
-    $crumbs = array();
     if ($cm!==null) {
         // Page header
         $strupdatemodule = has_capability('moodle/course:manageactivities', $contexts->lowest())
             ? update_module_button($cm->id, $COURSE->id, get_string('modulename', $cm->modname))
             : "";
-        $crumbs[] = array('name' => get_string('modulenameplural', $cm->modname),
-                            'link' => "$CFG->wwwroot/mod/{$cm->modname}/index.php?id=$COURSE->id",
-                            'type' => 'activity');
-        $crumbs[] = array('name' => format_string($module->name),
-                            'link' => "$CFG->wwwroot/mod/{$cm->modname}/view.php?id={$cm->id}",
-                            'type' => 'title');
+        $PAGE->navbar->add(get_string('modulenameplural', $cm->modname), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/index.php', array('id'=>$COURSE->id)));
+        $PAGE->navbar->add(format_string($module->name), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/view.php', array('id'=>$cm->id)));
     } else {
         // Print basic page layout.
         $strupdatemodule = '';
     }
 
-
-    $crumbs[] = array('name' => $streditingcategories, 'link' => $thispageurl->out(), 'type' => 'title');
-    $crumbs[] = array('name' => get_string('movingcategory', 'question'), 'link' => '', 'type' => 'title');
-
-    $navigation = build_navigation($crumbs);
-    print_header_simple($streditingcategories, '', $navigation, "", "", true, $strupdatemodule);
+    $PAGE->navbar->add($streditingcategories, $thispageurl->out());
+    $PAGE->navbar->add(get_string('movingcategory', 'question'));
+    $PAGE->set_title($streditingcategories);
+    $PAGE->set_button($strupdatemodule);
+    echo $OUTPUT->header();
 
     // print tabs
     if ($cm!==null) {
index 6620e07..e04adbf 100644 (file)
@@ -169,28 +169,23 @@ if ($contextmoveform->is_cancelled()){
 }
 
 $streditingcategories = get_string('editcategories', 'quiz');
-$crumbs = array();
 if ($cmid) {
     // Page header
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     $strupdatemodule = has_capability('moodle/course:manageactivities', $context)
         ? update_module_button($cm->id, $COURSE->id, get_string('modulename', $cm->modname))
         : "";
-    $crumbs[] = array('name' => get_string('modulenameplural', $cm->modname),
-                        'link' => "$CFG->wwwroot/mod/{$cm->modname}/index.php?id=$COURSE->id",
-                        'type' => 'activity');
-    $crumbs[] = array('name' => format_string($module->name),
-                        'link' => "$CFG->wwwroot/mod/{$cm->modname}/view.php?id={$cm->id}",
-                        'type' => 'title');
+    $PAGE->navbar->add(get_string('modulenameplural', $cm->modname), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/index.php', array('id'=>$COURSE->id)));
+    $PAGE->navbar->add(format_string($module->name), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/view.php', array('id'=>$cm->id)));
 } else {
     // Print basic page layout.
     $strupdatemodule = '';
 }
 $strmovingquestions = get_string('movingquestions', 'question');
-$crumbs[] = array('name' => $strmovingquestions, 'link' => '', 'type' => 'title');
-
-$navigation = build_navigation($crumbs);
-print_header_simple($strmovingquestions, '', $navigation, "", "", true, $strupdatemodule);
+$PAGE->navbar->add($strmovingquestions);
+$PAGE->set_title($strmovingquestions);
+$PAGE->set_button($strupdatemodule);
+echo $OUTPUT->header();
 
 // print tabs
 if ($cm!==null) {
index 84729ba..4f0dc72 100644 (file)
     }
 
     /// Header
+    $PAGE->set_title($strexportquestions);
     if ($cm!==null) {
         $strupdatemodule = has_capability('moodle/course:manageactivities', $contexts->lowest())
             ? update_module_button($cm->id, $COURSE->id, get_string('modulename', $cm->modname))
             : "";
-        $navlinks = array();
-        $navlinks[] = array('name' => get_string('modulenameplural', $cm->modname), 'link' => "$CFG->wwwroot/mod/{$cm->modname}/index.php?id=$COURSE->id", 'type' => 'activity');
-        $navlinks[] = array('name' => format_string($module->name), 'link' => "$CFG->wwwroot/mod/{$cm->modname}/view.php?id={$cm->id}", 'type' => 'title');
-        $navlinks[] = array('name' => $strexportquestions, 'link' => '', 'type' => 'title');
-        $navigation = build_navigation($navlinks);
-        print_header_simple($strexportquestions, '', $navigation, "", "", true, $strupdatemodule);
-
+        $PAGE->navbar->add(get_string('modulenameplural', $cm->modname), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/index.php', array('id'=>$COURSE->id)));
+        $PAGE->navbar->add(format_string($module->name), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/view.php', array('id'=>$cm->id)));
+        $PAGE->navbar->add($strexportquestions);
+        $PAGE->set_button($strupdatemodule);
+        echo $OUTPUT->header();
         $currenttab = 'edit';
         $mode = 'export';
         ${$cm->modname} = $module;
         include($CFG->dirroot."/mod/$cm->modname/tabs.php");
     } else {
         // Print basic page layout.
-        $navlinks = array();
-        $navlinks[] = array('name' => $strexportquestions, 'link' => '', 'type' => 'title');
-        $navigation = build_navigation($navlinks);
-
-        print_header_simple($strexportquestions, '', $navigation);
+        $PAGE->navbar->add($strexportquestions);
+        echo $OUTPUT->header();
         // print tabs
         $currenttab = 'export';
         include('tabs.php');
index f289745..775c67f 100644 (file)
         $strupdatemodule = has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $COURSE->id))
             ? update_module_button($cm->id, $COURSE->id, get_string('modulename', $cm->modname))
             : "";
-        $navlinks = array();
-        $navlinks[] = array('name' => get_string('modulenameplural', $cm->modname), 'link' => "$CFG->wwwroot/mod/{$cm->modname}/index.php?id=$COURSE->id", 'type' => 'activity');
-        $navlinks[] = array('name' => format_string($module->name), 'link' => "$CFG->wwwroot/mod/{$cm->modname}/view.php?id={$cm->id}", 'type' => 'title');
-        $navlinks[] = array('name' => $txt->importquestions, 'link' => '', 'type' => 'title');
-        $navigation = build_navigation($navlinks);
-        print_header_simple($txt->importquestions, '', $navigation, "", "", true, $strupdatemodule);
+        $PAGE->navbar->add(get_string('modulenameplural', $cm->modname), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/index.php', array('id'=>$COURSE->id)));
+        $PAGE->navbar->add(format_string($module->name), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/view.php', array('id'=>$cm->id)));
+        $PAGE->navbar->add($txt->importquestions);
+        $PAGE->set_title($txt->importquestions);
+        $PAGE->set_button($strupdatemodule);
+        echo $OUTPUT->header();
 
         $currenttab = 'edit';
         $mode = 'import';
         include($CFG->dirroot."/mod/$cm->modname/tabs.php");
     } else {
         // Print basic page layout.
-        $navlinks = array();
-        $navlinks[] = array('name' => $txt->importquestions, 'link' => '', 'type' => 'title');
-        $navigation = build_navigation($navlinks);
-
-        print_header_simple($txt->importquestions, '', $navigation);
+        $PAGE->navbar->add($txt->importquestions);
+        $PAGE->set_title($txt->importquestions);
+        echo $OUTPUT->header();
         // print tabs
         $currenttab = 'import';
         include('tabs.php');
index d02394e..d1d583d 100644 (file)
 
     $strpreview = get_string('preview', 'quiz').' '.format_string($questions[$id]->name);
     $questionlist = array($id);
-    $headtags = get_html_head_contributions($questionlist, $questions, $states[$historylength]);
-    print_header($strpreview, '', '', '', $headtags);
+    get_html_head_contributions($questionlist, $questions, $states[$historylength]);
+    $PAGE->set_title($strpreview);
+    echo $OUTPUT->header();
     echo $OUTPUT->heading($strpreview);
 
     if (!empty($quizid)) {
index 66bde35..7e574e3 100644 (file)
@@ -241,6 +241,7 @@ if ($mform->is_cancelled()){
 } else {
 
     $streditingquestion = $QTYPES[$question->qtype]->get_heading();
+    $PAGE->set_title($streditingquestion);
     if ($cm !== null) {
         $strmodule = get_string('modulename', $cm->modname);
         $strupdatemodule = has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $COURSE->id))
@@ -249,25 +250,21 @@ if ($mform->is_cancelled()){
 
         $streditingmodule = get_string('editinga', 'moodle', $strmodule);
 
-        $navlinks = array();
-        $navlinks[] = array('name' => get_string('modulenameplural', $cm->modname), 'link' => "$CFG->wwwroot/mod/{$cm->modname}/index.php?id=$cm->course", 'type' => 'activity');
-        $navlinks[] = array('name' => format_string($module->name), 'link' => "$CFG->wwwroot/mod/{$cm->modname}/view.php?id={$cm->id}", 'type' => 'title');
+        $PAGE->navbar->add(get_string('modulenameplural', $cm->modname), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/index.php', array('id'=>$cm->course)));
+        $PAGE->navbar->add(format_string($module->name), new moodle_url($CFG->wwwroot.'/mod/'.$cm->modname.'/view.php', array('id'=>$cm->id)));
         if (stripos($returnurl, "$CFG->wwwroot/mod/{$cm->modname}/view.php")!== 0){
             //don't need this link if returnurl returns to view.php
-            $navlinks[] = array('name' => $streditingmodule, 'link' => $returnurl, 'type' => 'title');
+            $PAGE->navbar->add($streditingmodule, $returnurl);
         }
-        $navlinks[] = array('name' => $streditingquestion, 'link' => '', 'type' => 'title');
-        $navigation = build_navigation($navlinks);
-        print_header_simple($streditingquestion, '', $navigation, '', '', true, $strupdatemodule);
+        $PAGE->navbar->add($streditingquestion);
+        $PAGE->set_button($strupdatemodule);
+        echo $OUTPUT->header();
 
     } else {
-        $navlinks = array();
-        $navlinks[] = array('name' => get_string('editquestions', "quiz"), 'link' => $returnurl, 'type' => 'title');
-        $navlinks[] = array('name' => $streditingquestion, 'link' => '', 'type' => 'title');
-        $strediting = '<a href="edit.php?courseid='.$COURSE->id.'">'.
-                get_string("editquestions", "quiz").'</a> -> '.$streditingquestion;
-        $navigation = build_navigation($navlinks);
-        print_header_simple($streditingquestion, '', $navigation, '', '');
+        $strediting = '<a href="edit.php?courseid='.$COURSE->id.'">'.get_string("editquestions", "quiz").'</a> -> '.$streditingquestion;
+        $PAGE->navbar->add(get_string('editquestions', "quiz"), $returnurl);
+        $PAGE->navbar->add($streditingquestion);
+        echo $OUTPUT->header();
     }
 
     // Display a heading, question editing form and possibly some extra content needed for