### Eclipse Workspace Patch 1.0
#P moodle19dev
Index: mod/glossary/mod_form.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/glossary/mod_form.php,v
retrieving revision 1.20.2.4
diff -u -r1.20.2.4 mod_form.php
--- mod/glossary/mod_form.php 26 Sep 2009 16:25:48 -0000 1.20.2.4
+++ mod/glossary/mod_form.php 28 Apr 2010 21:00:57 -0000
@@ -85,7 +85,19 @@
$mform->addElement('selectyesno', 'showalphabet', get_string('showalphabet', 'glossary'));
$mform->setDefault('showalphabet', 1);
$mform->setHelpButton('showalphabet', array('shows', get_string('showalphabet', 'glossary'), 'glossary'));
-
+ $mform->getElementValue('entbypage');
+/* ------------------------------------------------------------------------------------------------------------------------------------- */
+ $displayalphabetsgrp=array();
+ $languages = get_list_of_languages();
+ foreach ($languages as $language) {
+ if( preg_match( '!\(([^\)]+)\)!', $language, $match ) ) {
+ $shortlanguagename = $match[1];
+ }
+ $displayalphabetsgrp[] = &MoodleQuickForm::createElement('checkbox', $shortlanguagename, '', $language);
+ }
+ $mform->addGroup($displayalphabetsgrp, 'specialalphabetslist', 'Display special alphabets', '', true);
+/* ------------------------------------------------------------------------------------------------------------------------------------- */
+
$mform->addElement('selectyesno', 'showall', get_string('showall', 'glossary'));
$mform->setDefault('showall', 1);
$mform->setHelpButton('showall', array('shows', get_string('showall', 'glossary'), 'glossary'));
@@ -174,7 +186,7 @@
}
function data_preprocessing(&$default_values){
- if (empty($default_values['scale'])){
+ if (empty($default_values['scale'])){
$default_values['assessed'] = 0;
}
@@ -186,7 +198,23 @@
$default_values['ratingtime']=
($default_values['assesstimestart'] && $default_values['assesstimefinish']) ? 1 : 0;
}
- }
-
+
+ // DEV JR retrieve actual values of specialalphabets and inject them into each language available in course
+ $specialalphabetslist = array();
+ if (isset($default_values['specialalphabets'])) {
+ $specialalphabetslist = explode(",", $default_values['specialalphabets']);
+ }
+ $languages = get_list_of_languages();
+ foreach ($languages as $language) {
+ if( preg_match( '!\(([^\)]+)\)!', $language, $match ) ) {
+ $shortlanguagename = $match[1];
+ }
+ if (in_array($shortlanguagename, $specialalphabetslist)) {
+ $default_values['specialalphabetslist['.$shortlanguagename.']'] = 1;
+ } else {
+ $default_values['specialalphabetslist['.$shortlanguagename.']'] = 0;
+ }
+ }
+ }
}
?>
Index: mod/glossary/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/glossary/lib.php,v
retrieving revision 1.193.2.22
diff -u -r1.193.2.22 lib.php
--- mod/glossary/lib.php 22 Nov 2009 12:43:10 -0000 1.193.2.22
+++ mod/glossary/lib.php 28 Apr 2010 21:00:57 -0000
@@ -57,7 +57,10 @@
$glossary = stripslashes_recursive($glossary);
glossary_grade_item_update($glossary);
}
-
+
+ // Do the processing required after an add or an update.
+ glossary_after_add_or_update($glossary); // DEV JR
+
return $returnid;
}
@@ -102,10 +105,21 @@
$glossary = stripslashes_recursive($glossary);
glossary_grade_item_update($glossary);
}
-
+
+ glossary_after_add_or_update($glossary); // DEV JR
+
return $return;
}
+function glossary_after_add_or_update($glossary) { // DEV JR
+ // DEV JR for special alphabets listings
+ if (isset($glossary->specialalphabetslist)) {
+ $specialalphabets = implode (',', array_keys($glossary->specialalphabetslist));
+ } else {
+ $specialalphabets = '';
+ }
+ set_field('glossary', 'specialalphabets', $specialalphabets, 'id', $glossary->id);
+}
function glossary_delete_instance($id) {
/// Given an ID of an instance of this module,
@@ -1257,9 +1271,9 @@
glossary_print_special_links($cm, $glossary, $mode, $hook);
- glossary_print_alphabet_links($cm, $glossary, $mode, $hook, $sortkey, $sortorder);
+ glossary_print_alphabet_links($cm, $glossary, $mode, $hook, $sortkey, $sortorder);
- glossary_print_all_links($cm, $glossary, $mode, $hook);
+ //glossary_print_all_links($cm, $glossary, $mode, $hook); // moved to JR DEV multi-alphalist
} else {
glossary_print_sorting_links($cm, $mode, $sortkey,$sortorder);
}
@@ -1370,10 +1384,10 @@
}
function glossary_print_alphabet_links($cm, $glossary, $mode, $hook, $sortkey, $sortorder) {
-global $CFG;
+ global $CFG;
if ( $glossary->showalphabet) {
$alphabet = explode(",", get_string("alphabet"));
- $letters_by_line = 14;
+ $letters_by_line = 99; // DEV JR if more than one alphabet displayed, display alphalist on a single line
for ($i = 0; $i < count($alphabet); $i++) {
if ( $hook == $alphabet[$i] and $hook) {
echo "$alphabet[$i]";
@@ -1386,7 +1400,79 @@
echo '
';
}
}
- }
+ // moved from glossary_print_alphabet_menu
+ glossary_print_all_links($cm, $glossary, $mode, $hook);
+
+ // DEV JR
+ $alphabets = $glossary->specialalphabets;
+ if ($alphabets != '') {
+ $identifier = 'alphabet';
+ $alphalist = explode(",", $alphabets);
+ foreach ($alphalist as $alphabet) {
+ $location = '';
+ $alphabet .= '_utf8';
+ switch ($alphabet) {
+ case current_language():
+ break; // current language alphalist is already displayed
+ case 'en_utf8': // special case of English lang files are located in core files
+ $alphabet = '';
+ $location = $CFG->dirroot.'/lang/en_utf8/';
+ $langfile = $location.'/langconfig.php';
+ break;
+ default:
+ $location = $CFG->dataroot.'/lang/';
+ $langfile = $location.$alphabet.'/langconfig.php';
+ break;
+ }
+ if ($location != '') {
+ if (file_exists($langfile)) {
+ if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) {
+ if (eval($result) === FALSE) {
+ trigger_error('Lang error: '.$identifier.':'.$langfile, E_USER_NOTICE);
+ }
+ echo '
';
+ $alphabet_letters = explode(",", $resultstring);
+ $letters_by_line = 99; // DEV JR if more than one alphabet displayed, display alphalist on a single line
+ for ($i = 0; $i < count($alphabet_letters); $i++) {
+ if ( $hook == $alphabet_letters[$i] and $hook) {
+ echo "$alphabet_letters[$i]";
+ } else {
+ echo "wwwroot/mod/glossary/view.php?id=$cm->id&mode=$mode&hook=".urlencode($alphabet_letters[$i])."
+ &sortkey=$sortkey&sortorder=$sortorder\">$alphabet_letters[$i]";
+ }
+ if ((int) ($i % $letters_by_line) != 0 or $i == 0) {
+ echo ' | ';
+ } else {
+ echo '
';
+ }
+ }
+ $glossaryfile = $location.$alphabet.'/glossary.php';
+ $resultstring = '';
+ if ($result = get_string_from_file("allentries", $glossaryfile, "\$resultstring")) {
+ if (eval($result) === FALSE) {
+ trigger_error('Lang error: '.$identifier.':'.$langfile, E_USER_NOTICE);
+ }
+ }
+ $strallentries = $resultstring;
+ if ($result = get_string_from_file("explainall", $glossaryfile, "\$resultstring")) {
+ if (eval($result) === FALSE) {
+ trigger_error('Lang error: '.$identifier.':'.$langfile, E_USER_NOTICE);
+ }
+ }
+ $strexplainall = strip_tags($resultstring);
+ if ( $glossary->showall) {
+ if ( $hook == 'ALL' ) {
+ echo "$strallentries";
+ } else {
+ echo "wwwroot/mod/glossary/view.php?id=$cm->id&mode=$mode&hook=ALL\">$strallentries";
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
function glossary_print_sorting_links($cm, $mode, $sortkey = '',$sortorder = '') {