From e6855d1aa0979e727cfe9dbbe2c2983c2384a0b8 Mon Sep 17 00:00:00 2001 From: samhemelryk Date: Mon, 7 Sep 2009 03:20:35 +0000 Subject: [PATCH] mod-glossary MDL-19809 Updated print_header and build_navigation to OUTPUT and PAGE equivalents --- mod/glossary/comment.php | 15 +++++++-------- mod/glossary/comments.php | 8 ++++---- mod/glossary/deleteentry.php | 8 +++----- mod/glossary/edit.php | 7 +++---- mod/glossary/editcategories.php | 16 ++++++---------- mod/glossary/export.php | 9 ++++----- mod/glossary/exportentry.php | 8 ++++---- mod/glossary/import.php | 10 +++++----- mod/glossary/index.php | 8 +++----- mod/glossary/print.php | 2 +- mod/glossary/report.php | 3 ++- mod/glossary/showentry.php | 14 ++++++-------- mod/glossary/view.php | 17 +++++++---------- 13 files changed, 55 insertions(+), 70 deletions(-) diff --git a/mod/glossary/comment.php b/mod/glossary/comment.php index 98fadf0908..ecb7b13177 100644 --- a/mod/glossary/comment.php +++ b/mod/glossary/comment.php @@ -207,6 +207,7 @@ function glossary_comment_edit() { ////////////////////////////////// function glossary_comment_print_header($course, $cm, $glossary, $entry, $action) { + global $PAGE, $OUTPUT; switch ($action){ case 'add': $straction = get_string('addingcomment','glossary'); @@ -222,14 +223,12 @@ function glossary_comment_print_header($course, $cm, $glossary, $entry, $action) $strglossary = get_string('modulename', 'glossary'); $strcomments = get_string('comments', 'glossary'); - $navlinks = array(); - $navlinks[] = array('name' => $strcomments, 'link' => "comments.php?id=$cm->id&eid=$entry->id", 'type' => 'title'); - $navlinks[] = array('name' => $straction, 'link' => '', 'type' => 'action'); - $navigation = build_navigation($navlinks, $cm); - - print_header_simple(format_string($glossary->name), '', $navigation, - '', '', true, update_module_button($cm->id, $course->id, $strglossary), - navmenu($course, $cm)); + $PAGE->navbar->add($strcomments, new moodle_url($CFG->wwwroot.'/mod/glossary/comments.php', array('id'=>$cm->id,'eid'=>$entry->id))); + $PAGE->navbar->add($straction); + $PAGE->set_title(format_string($glossary->name)); + $PAGE->set_button(update_module_button($cm->id, $course->id, $strglossary)); + echo $OUTPUT->header(); + /// print original glossary entry for any comment action (add, update, delete) glossary_print_entry($course, $cm, $glossary, $entry, 'approval', '', false); } diff --git a/mod/glossary/comments.php b/mod/glossary/comments.php index 6bf4ed51ef..84bb3f1db9 100644 --- a/mod/glossary/comments.php +++ b/mod/glossary/comments.php @@ -40,10 +40,10 @@ $strcomments = get_string("comments", "glossary"); $straddcomment = get_string("addcomment", "glossary"); - $navigation = build_navigation($strcomments, $cm); - print_header_simple(strip_tags("$strcomments: $entry->concept"), "", $navigation, - "", "", true, update_module_button($cm->id, $course->id, $strglossary), - navmenu($course, $cm)); + $PAGE->navbar->add($strcomments); + $PAGE->set_title(strip_tags("$strcomments: $entry->concept")); + $PAGE->set_button(update_module_button($cm->id, $course->id, $strglossary)); + echo $OUTPUT->header(); /// original glossary entry diff --git a/mod/glossary/deleteentry.php b/mod/glossary/deleteentry.php index 6a61cd21fa..92435d3a22 100644 --- a/mod/glossary/deleteentry.php +++ b/mod/glossary/deleteentry.php @@ -38,8 +38,6 @@ $strareyousuredelete = get_string("areyousuredelete","glossary"); - $navigation = build_navigation('', $cm); - if (($entry->userid != $USER->id) and !$manageentries) { // guest id is never matched, no need for special check here print_error('nopermissiontodelentry'); } @@ -92,9 +90,9 @@ redirect("view.php?id=$cm->id&mode=$prevmode&hook=$hook"); } else { // the operation has not been confirmed yet so ask the user to do so - print_header_simple(format_string($glossary->name), "", $navigation, - "", "", true, update_module_button($cm->id, $course->id, $strglossary), - navmenu($course, $cm)); + $PAGE->set_title(format_string($glossary->name)); + $PAGE->set_button(update_module_button($cm->id, $course->id, $strglossary)); + echo $OUTPUT->header(); $areyousure = "".format_string($entry->concept)."

$strareyousuredelete

"; $linkyes = 'deleteentry.php'; $linkno = 'view.php'; diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index 70ff623de8..77f6df21e4 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -165,10 +165,9 @@ if ($mform->is_cancelled()){ $stredit = empty($entry->id) ? get_string('addentry', 'glossary') : get_string('edit'); -$navigation = build_navigation($stredit, $cm); -print_header_simple(format_string($glossary->name), "", $navigation, "", - "", true, "", navmenu($course, $cm)); - +$PAGE->navbar->add($stredit); +$PAGE->set_title(format_string($glossary->name)); +echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($glossary->name)); $mform->display(); diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php index 4c63875c5d..166200d07e 100644 --- a/mod/glossary/editcategories.php +++ b/mod/glossary/editcategories.php @@ -47,16 +47,12 @@ $strglossaries = get_string("modulenameplural", "glossary"); $strglossary = get_string("modulename", "glossary"); - $navlinks = array(); - $navlinks[] = array('name' => $strglossaries, 'link' => "index.php?id=$course->id", 'type' => 'activity'); - $navlinks[] = array('name' => format_string($glossary->name), 'link' => "view.php?id=$cm->id&tab=GLOSSARY_CATEGORY_VIEW", 'type' => 'activityinstance'); - $navlinks[] = array('name' => get_string("categories","glossary"), 'link' => '', 'type' => 'title'); - - $navigation = build_navigation($navlinks); - - print_header_simple(format_string($glossary->name), "", $navigation, - "", "", true, update_module_button($cm->id, $course->id, $strglossary), - navmenu($course, $cm)); + $PAGE->navbar->add($strglossaries, new moodle_url($CFG->wwwroot.'/mod/glossary/index.php', array('id'=>$course->id))); + $PAGE->navbar->add(format_string($glossary->name), new moodle_url($CFG->wwwroot.'/mod/glossary/view.php', array('id'=>$cm->id,'tab'=>'GLOSSARY_CATEGORY_VIEW'))); + $PAGE->navbar->add(get_string("categories","glossary")); + $PAGE->set_title(format_string($glossary->name)); + $PAGE->set_button(update_module_button($cm->id, $course->id, $strglossary)); + echo $OUTPUT->header(); if ( $hook >0 ) { diff --git a/mod/glossary/export.php b/mod/glossary/export.php index e39e7bbfd4..abf2d7a256 100644 --- a/mod/glossary/export.php +++ b/mod/glossary/export.php @@ -37,13 +37,12 @@ $strexportfile = get_string("exportfile", "glossary"); $strexportentries = get_string('exportentriestoxml', 'glossary'); - $navigation = build_navigation($strexportentries, $cm); - print_header_simple(format_string($glossary->name), "",$navigation, - "", "", true, update_module_button($cm->id, $course->id, $strglossary), - navmenu($course, $cm)); + $PAGE->navbar->add($strexportentries); + $PAGE->set_title(format_string($glossary->name)); + $PAGE->set_button(update_module_button($cm->id, $course->id, $strglossary)); + echo $OUTPUT->header(); echo $OUTPUT->heading($strexportentries); - echo $OUTPUT->box_start('glossarydisplay generalbox'); ?>
diff --git a/mod/glossary/exportentry.php b/mod/glossary/exportentry.php index 20e4d145a6..bee7a4dc87 100644 --- a/mod/glossary/exportentry.php +++ b/mod/glossary/exportentry.php @@ -58,11 +58,10 @@ $entryalreadyexist = get_string('entryalreadyexist','glossary'); $entryexported = get_string('entryexported','glossary'); - $navigation = build_navigation('', $cm); - if (!$mainglossary->allowduplicatedentries) { if ($DB->get_record('glossary_entries', array('glossaryid'=>$mainglossary->id, 'lower(concept)'=>moodle_strtolower($entry->concept)))) { - print_header_simple(format_string($glossary->name), '', $navigation, '', '', true, '', navmenu($course, $cm)); + $PAGE->set_title(format_string($glossary->name)); + echo $OUTPUT->header(); echo $OUTPUT->notification(get_string('errconceptalreadyexists', 'glossary')); echo $OUTPUT->continue_button($returnurl); echo $OUTPUT->box_end(); @@ -72,7 +71,8 @@ } if (!data_submitted() or !$confirm or !confirm_sesskey()) { - print_header_simple(format_string($glossary->name), '', $navigation, '', '', true, '', navmenu($course, $cm)); + $PAGE->set_title(format_string($glossary->name)); + echo $OUTPUT->header(); echo '
'; $areyousure = '

'.format_string($entry->concept).'

'.get_string('areyousureexport','glossary').'
'.format_string($mainglossary->name).'?'; $linkyes = 'exportentry.php'; diff --git a/mod/glossary/import.php b/mod/glossary/import.php index 417ed1b9af..45b1ba1838 100644 --- a/mod/glossary/import.php +++ b/mod/glossary/import.php @@ -44,11 +44,11 @@ $strsearch = get_string("search"); $strimportentries = get_string('importentriesfromxml', 'glossary'); - $navigation = build_navigation($strimportentries, $cm); - print_header_simple(format_string($glossary->name), "", $navigation, - "", "", true, update_module_button($cm->id, $course->id, $strglossary), - navmenu($course, $cm)); - + $PAGE->navbar->add($strimportentries); + $PAGE->set_title(format_string($glossary->name)); + $PAGE->set_button(update_module_button($cm->id, $course->id, $strglossary)); + + echo $OUTPUT->header(); echo $OUTPUT->heading($strimportentries); if ( !$step ) { diff --git a/mod/glossary/index.php b/mod/glossary/index.php index 2a2be4e195..e4c30a4101 100644 --- a/mod/glossary/index.php +++ b/mod/glossary/index.php @@ -28,11 +28,9 @@ /// Print the header - $navlinks = array(); - $navlinks[] = array('name' => $strglossarys, 'link' => "index.php?id=$course->id", 'type' => 'activity'); - $navigation = build_navigation($navlinks); - - print_header_simple("$strglossarys", "", $navigation, "", "", true, "", navmenu($course)); + $PAGE->navbar->add($strglossarys, "index.php?id=$course->id"); + $PAGE->set_title($strglossarys); + echo $OUTPUT->header(); /// Get all the appropriate data diff --git a/mod/glossary/print.php b/mod/glossary/print.php index fcafdc7b22..c7e7f77403 100644 --- a/mod/glossary/print.php +++ b/mod/glossary/print.php @@ -30,7 +30,7 @@ $entriesbypage = $CFG->glossary_entbypage; } - print_header(); + echo $OUTPUT->header(); require_course_login($course, true, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); diff --git a/mod/glossary/report.php b/mod/glossary/report.php index 2dc173449a..533d81b993 100644 --- a/mod/glossary/report.php +++ b/mod/glossary/report.php @@ -48,7 +48,8 @@ $strname = get_string('name'); $strtime = get_string('time'); - print_header("$strratings: $entry->concept"); + $PAGE->set_title("$strratings: $entry->concept"); + echo $OUTPUT->header(); if (!$ratings = glossary_get_ratings($entry->id, $sqlsort)) { print_error('ratingno', 'glossary'); diff --git a/mod/glossary/showentry.php b/mod/glossary/showentry.php index d534a870c0..9861568654 100644 --- a/mod/glossary/showentry.php +++ b/mod/glossary/showentry.php @@ -48,16 +48,14 @@ $strsearch = get_string("search"); $CFG->framename = "newwindow"; - $navlinks = array(); - $navlinks[] = array('name' => $strglossaries, 'link' => '', 'type' => 'activity'); - $navlinks[] = array('name' => $strsearch, 'link' => '', 'type' => 'title'); - - $navigation = build_navigation($navlinks); - - print_header(strip_tags("$course->shortname: $strglossaries $strsearch"), $course->fullname, $navigation, "", "", true, " ", " "); + $PAGE->navbar->add($strglossaries); + $PAGE->navbar->add($strsearch); + $PAGE->set_title(strip_tags("$course->shortname: $strglossaries $strsearch")); + $PAGE->set_heading($course->fullname); + echo $OUTPUT->header(); } else { - print_header(); // Needs to be something here to allow linking back to the whole glossary + echo $OUTPUT->header(); // Needs to be something here to allow linking back to the whole glossary } if ($entries) { diff --git a/mod/glossary/view.php b/mod/glossary/view.php index b272382aae..622b25b08f 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -115,7 +115,7 @@ require_login($course->id); } if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $context)) { - print_header(); + echo $OUTPUT->header(); notice(get_string("activityiscurrentlyhidden")); } add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id&tab=$tab", $glossary->id, $cm->id); @@ -226,18 +226,15 @@ $strwaitingapproval = get_string('waitingapproval', 'glossary'); /// If we are in approval mode, prit special header + $PAGE->set_title(format_string($glossary->name)); + $PAGE->set_button(update_module_button($cm->id, $course->id, $strglossary)); if ($tab == GLOSSARY_APPROVAL_VIEW) { require_capability('mod/glossary:approve', $context); - - $navigation = build_navigation($strwaitingapproval, $cm); - print_header_simple(format_string($glossary->name), "", $navigation, "", "", true, - update_module_button($cm->id, $course->id, $strglossary), navmenu($course, $cm)); - + $PAGE->navbar->add($strwaitingapproval); + echo $OUTPUT->header(); echo $OUTPUT->heading($strwaitingapproval); - } else { /// Print standard header - $navigation = build_navigation('', $cm); - print_header_simple(format_string($glossary->name), "", $navigation, "", "", true, - update_module_button($cm->id, $course->id, $strglossary), navmenu($course, $cm)); + } else { /// Print standard header + echo $OUTPUT->header(); } /// All this depends if whe have $showcommonelements -- 2.39.5