From bce3e3dca58e672cfdf85d5f294f37943c2aa029 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Mon, 11 Jul 2011 01:02:06 +0200 Subject: [PATCH] MDL-28048 glossary - add multilang support to categories --- mod/glossary/edit_form.php | 8 ++++++++ mod/glossary/editcategories.php | 8 ++++++-- mod/glossary/lib.php | 8 ++++++-- mod/glossary/print.php | 7 ++++++- mod/glossary/view.php | 7 ++++++- 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/mod/glossary/edit_form.php b/mod/glossary/edit_form.php index 414bc47879d..ce8443e6762 100644 --- a/mod/glossary/edit_form.php +++ b/mod/glossary/edit_form.php @@ -18,6 +18,11 @@ class mod_glossary_entry_form extends moodleform { $definitionoptions = $this->_customdata['definitionoptions']; $attachmentoptions = $this->_customdata['attachmentoptions']; + $context = get_context_instance(CONTEXT_MODULE, $cm->id); + // Prepare format_string/text options + $fmtoptions = array( + 'context' => $context); + //------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); @@ -30,6 +35,9 @@ class mod_glossary_entry_form extends moodleform { $mform->addRule('definition_editor', get_string('required'), 'required', null, 'client'); if ($categories = $DB->get_records_menu('glossary_categories', array('glossaryid'=>$glossary->id), 'name ASC', 'id, name')){ + foreach ($categories as $id => $name) { + $categories[$id] = format_string($name, true, $fmtoptions); + } $categories = array(0 => get_string('notcategorised', 'glossary')) + $categories; $categoriesEl = $mform->addElement('select', 'categories', get_string('categories', 'glossary'), $categories); $categoriesEl->setMultiple(true); diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php index 1c45a33325d..3a78f5c0948 100644 --- a/mod/glossary/editcategories.php +++ b/mod/glossary/editcategories.php @@ -79,6 +79,10 @@ $PAGE->set_title(format_string($glossary->name)); $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); +// Prepare format_string/text options +$fmtoptions = array( + 'context' => $context); + if ( $hook >0 ) { if ( $action == "edit" ) { @@ -118,7 +122,7 @@ if ( $hook >0 ) { echo "

" . get_string("delete"). " " . get_string("category","glossary"). "

"; echo $OUTPUT->box_start('generalbox boxaligncenter errorboxcontent boxwidthnarrow'); - echo "
".format_text($category->name, FORMAT_PLAIN)."
"; + echo "
".format_string($category->name, true, $fmtoptions)."
"; $num_entries = $DB->count_records("glossary_entries_categories", array("categoryid"=>$category->id)); if ( $num_entries ) { @@ -215,7 +219,7 @@ if ( $action ) { ".format_text($category->name, FORMAT_PLAIN)." ($num_entries " . get_string("entries","glossary") . ")"; + echo "".format_string($category->name, true, $fmtoptions)." ($num_entries " . get_string("entries","glossary") . ")"; ?> diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 6a83858e7b1..57e191e376d 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -1645,6 +1645,10 @@ function glossary_print_categories_menu($cm, $glossary, $hook, $category) { $context = get_context_instance(CONTEXT_MODULE, $cm->id); + // Prepare format_string/text options + $fmtoptions = array( + 'context' => $context); + echo ''; echo ''; @@ -1674,7 +1678,7 @@ function glossary_print_categories_menu($cm, $glossary, $hook, $category) { $selected = $url; } } - $menu[$url] = clean_text($currentcategory->name); //Only clean, not filters + $menu[$url] = format_string($currentcategory->name, true, $fmtoptions); } } if ( !$selected ) { @@ -1682,7 +1686,7 @@ function glossary_print_categories_menu($cm, $glossary, $hook, $category) { } if ( $category ) { - echo format_text($category->name, FORMAT_PLAIN); + echo format_string($category->name, true, $fmtoptions); } else { if ( $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) { diff --git a/mod/glossary/print.php b/mod/glossary/print.php index 5c0aa5bd666..013c70e5583 100644 --- a/mod/glossary/print.php +++ b/mod/glossary/print.php @@ -54,6 +54,10 @@ if ( !$entriesbypage = $glossary->entbypage ) { require_course_login($course, true, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); +// Prepare format_string/text options +$fmtoptions = array( + 'context' => $context); + $PAGE->set_pagelayout('print'); $PAGE->set_title(get_string("modulenameplural", "glossary")); $PAGE->set_heading($course->fullname); @@ -178,9 +182,11 @@ if ( $allentries ) { // Setting the pivot for the current entry $pivot = $entry->glossarypivot; $upperpivot = $textlib->strtoupper($pivot); + $pivottoshow = $textlib->strtoupper(format_string($pivot, true, $fmtoptions)); // Reduce pivot to 1cc if necessary if ( !$fullpivot ) { $upperpivot = $textlib->substr($upperpivot, 0, 1); + $pivottoshow = $textlib->substr($pivottoshow, 0, 1); } // If there's group break @@ -190,7 +196,6 @@ if ( $allentries ) { if ( $printpivot ) { $currentpivot = $upperpivot; - $pivottoshow = $currentpivot; if ( isset($entry->userispivot) ) { // printing the user icon if defined (only when browsing authors) $user = $DB->get_record("user", array("id"=>$entry->userid)); diff --git a/mod/glossary/view.php b/mod/glossary/view.php index bad1c245000..0024dea09d6 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -50,6 +50,10 @@ if (!empty($id)) { require_course_login($course->id, true, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); +// Prepare format_string/text options +$fmtoptions = array( + 'context' => $context); + require_once($CFG->dirroot . '/comment/lib.php'); comment::init(); @@ -417,9 +421,11 @@ if ($allentries) { // Setting the pivot for the current entry $pivot = $entry->glossarypivot; $upperpivot = $textlib->strtoupper($pivot); + $pivottoshow = $textlib->strtoupper(format_string($pivot, true, $fmtoptions)); // Reduce pivot to 1cc if necessary if ( !$fullpivot ) { $upperpivot = $textlib->substr($upperpivot, 0, 1); + $pivottoshow = $textlib->substr($pivottoshow, 0, 1); } // if there's a group break @@ -433,7 +439,6 @@ if ($allentries) { echo '
'; echo ''; - $pivottoshow = $currentpivot; if ( isset($entry->userispivot) ) { // printing the user icon if defined (only when browsing authors) echo '
'; -- 2.17.1