From: stronk7 Date: Tue, 27 Jul 2004 17:19:47 +0000 (+0000) Subject: Bulk changes to support plugin-formats in glossaries. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a359c29b791d25a27d9010a5e84d127b337d634b;p=moodle.git Bulk changes to support plugin-formats in glossaries. See the TODO.txt to get details about pending tasks. The db upgrade should work fine (not tested under postgresql). The plugin architecture is finished too. See Bug 936. (http://moodle.org/bugs/bug.php?op=show&bugid=936) --- diff --git a/mod/glossary/TODO.txt b/mod/glossary/TODO.txt index 874b90ebb9..c390b3a5ad 100644 --- a/mod/glossary/TODO.txt +++ b/mod/glossary/TODO.txt @@ -13,3 +13,9 @@ Things that are in the inkpot yet: * Show (or do not) the group breaks. * Default view for automatic links, entry view, etc. * What else? Post in http://moodle.org/mod/forum/view.php?id=742 + +News about plugin-formats TODO (Updated: Jul 23, 2004 - Eloy) + +*Review every format (only dictionary has been polished just now). +*Include a template format to make things easier for new formats. +*Include support for a customised print view in each format. diff --git a/mod/glossary/config.html b/mod/glossary/config.html index 8de4ace692..57ac5bf72d 100644 --- a/mod/glossary/config.html +++ b/mod/glossary/config.html @@ -194,69 +194,35 @@ fid = 0; - $displayformat->relatedview = 0; - $displayformat->visible = 1; - $displayformat->id = insert_record("glossary_displayformats",$displayformat); - } - if ( !$displayformat = get_record("glossary_displayformats","fid",1) ) { - unset($displayformat); - $displayformat->fid = 1; - $displayformat->relatedview = 1; - $displayformat->visible = 1; - $displayformat->id = insert_record("glossary_displayformats",$displayformat); - } + + //Update and get available formats + $recformats = glossary_get_available_formats(); $formats = array(); - $formats[0] = get_string("displayformatdefault", "glossary"); - $formats[1] = get_string("displayformatcontinuous", "glossary"); - $basedir = opendir("$CFG->dirroot/mod/glossary/formats"); - while ($dir = readdir($basedir)) { - $firstchar = substr($dir, 0, 1); - if ($firstchar == "." or $dir == "CVS" or $dir == "_vti_cnf") { - continue; - } - if (filetype("$CFG->dirroot/mod/glossary/formats/$dir") == "dir") { - continue; - } - if ( $pos = strpos($dir, ".") ) { - $dir = substr($dir, 0, $pos ); - if ($dir != 0 and $dir != 1) { // excluding basic formats - if ( !$displayformat = get_record("glossary_displayformats","fid",$dir) ) { - unset($displayformat); - $displayformat->fid = $dir; - $displayformat->relatedview = $dir; - $displayformat->visible = 1; - $displayformat->id = insert_record("glossary_displayformats",$displayformat); - } - $formats[$dir] = get_string("displayformat$dir", "glossary"); - } - } + //Take names + foreach ($recformats as $format) { + $formats[$format->id] = get_string("displayformat$format->name", "glossary"); } asort($formats); echo ''; - for ($i = 0; $i < count($formats); $i++) { - if ( $formats[$i] ) { - $format = get_record("glossary_displayformats","fid",$i); - echo ''; - echo ''; - $eicon = "wwwroot/mod/glossary/formats.php?id=$i&mode=edit\">"; - if ( $format->visible ) { - $vtitle = get_string("hide"); - $vicon = "hide.gif"; - } else { - $vtitle = get_string("show"); - $vicon = "show.gif"; - } - $vicon = "wwwroot/mod/glossary/formats.php?id=$i&mode=visible\">"; - - echo ''; - echo ''; + foreach ($formats as $formatid=>$formatname) { + $recformat = get_record('glossary_formats','id',$formatid); + echo ''; + echo ''; + $eicon = "wwwroot/mod/glossary/formats.php?id=$formatid&mode=edit\">"; + if ( $recformat->visible ) { + $vtitle = get_string("hide"); + $vicon = "hide.gif"; + } else { + $vtitle = get_string("show"); + $vicon = "show.gif"; } + $vicon = "wwwroot/mod/glossary/formats.php?id=$formatid&mode=visible\">"; + + echo ''; + echo ''; } echo '
' . $formats[$i] . ' ' . $eicon . '  ' . $vicon . '
' . $formatname . '' . $eicon . '  ' . $vicon . '
'; @@ -268,21 +234,26 @@

glossary_enablerssfeeds: enablerssfeeds == 0) { + if (!isset($CFG->enablerssfeeds) || $CFG->enablerssfeeds == 0) { print_string("no"); } else { unset($options); $options[0] = get_string("no"); $options[1] = get_string("yes"); - choose_from_menu ($options, "glossary_enablerssfeeds", $CFG->glossary_enablerssfeeds, "", "", ""); + $glossary_enablerssfeeds = false; + if (isset($CFG->glossary_enablerssfeeds) && $CFG->glossary_enablerssfeeds == 1) { + $glossary_enablerssfeeds = true; + } + + choose_from_menu ($options, "glossary_enablerssfeeds", $glossary_enablerssfeeds, "", "", ""); } ?> enablerssfeeds == 0) { + if (!isset($CFG->enablerssfeeds) || $CFG->enablerssfeeds == 0) { print_string("configenablerssfeedsdisabled"); } ?> diff --git a/mod/glossary/db/mysql.php b/mod/glossary/db/mysql.php index 3d12b04115..9475154bae 100644 --- a/mod/glossary/db/mysql.php +++ b/mod/glossary/db/mysql.php @@ -274,6 +274,67 @@ function glossary_upgrade($oldversion) { if ( $oldversion < 2004072300) { table_column("glossary_alias", "alias", "alias", "VARCHAR", "255", "", "", "NOT NULL"); } + + if ( $oldversion < 2004072400) { + + //Create new table glossary_formats to store format info + execute_sql("CREATE TABLE `{$CFG->prefix}glossary_formats` ( + `id` INT(10) unsigned NOT NULL auto_increment, + `name` VARCHAR(50) NOT NULL, + `popupformatname` VARCHAR(50) NOT NULL, + `visible` TINYINT(2) UNSIGNED NOT NULL default '1', + `showgroup` TINYINT(2) UNSIGNED NOT NULL default '1', + `defaultmode` VARCHAR(50) NOT NULL default '', + `defaulthook` VARCHAR(50) NOT NULL default '', + `sortkey` VARCHAR(50) NOT NULL default '', + `sortorder` VARCHAR(50) NOT NULL default '', + PRIMARY KEY (`id`) + ) TYPE=MyISAM COMMENT='Setting of the display formats'"); + + //Define current 0-6 format names + $formatnames = array('dictionary','continuous','fullwithauthor','encyclopedia', + 'faq','fullwithoutauthor','entrylist'); + + //Fill the new table from the old one (only 'valid', 0-6, formats) + if ($formats = get_records('glossary_displayformats')) { + foreach ($formats as $format) { + //Format names + if ($format->fid >= 0 && $format->fid <= 6) { + $format->name = $formatnames[$format->fid]; + } + + //Format popupformatname + $format->popupformatname = 'dictionary'; //Default format + if ($format->relatedview >= 0 && $format->relatedview <= 6) { + $format->popupformatname = $formatnames[$format->relatedview]; + } + + //Insert the new record + //Only if $format->name is set (ie. formats 0-6) + if ($format->name) { + insert_record('glossary_formats',$format); + } + + } + } + + //Drop the old formats table + execute_sql("DROP TABLE `{$CFG->prefix}glossary_displayformats`"); + + //Modify the glossary->displayformat field + table_column('glossary', 'displayformat', 'displayformat', 'VARCHAR', '50', '', 'dictionary', 'NOT NULL'); + + //Update glossary->displayformat field + if ($glossaries = get_records('glossary')) { + foreach($glossaries as $glossary) { + $displayformat = 'dictionary'; //Default format + if ($glossary->displayformat >= 0 && $glossary->displayformat <= 6) { + $displayformat = $formatnames[$glossary->displayformat]; + } + set_field('glossary','displayformat',$displayformat,'id',$glossary->id); + } + } + } return true; } diff --git a/mod/glossary/db/mysql.sql b/mod/glossary/db/mysql.sql index 6fd23f6a26..b55b314fa1 100644 --- a/mod/glossary/db/mysql.sql +++ b/mod/glossary/db/mysql.sql @@ -15,7 +15,7 @@ CREATE TABLE prefix_glossary ( intro text NOT NULL, studentcanpost tinyint(2) unsigned NOT NULL default '0', allowduplicatedentries tinyint(2) unsigned NOT NULL default '0', - displayformat tinyint(2) unsigned NOT NULL default '0', + displayformat varchar(50) NOT NULL default 'dictionary', mainglossary tinyint(2) unsigned NOT NULL default '0', showspecial tinyint(2) unsigned NOT NULL default '1', showalphabet tinyint(2) unsigned NOT NULL default '1', @@ -104,20 +104,16 @@ CREATE TABLE prefix_glossary_comments ( PRIMARY KEY (id) ) TYPE=MyISAM COMMENT='comments on glossary entries'; -CREATE TABLE prefix_glossary_displayformats ( +CREATE TABLE prefix_glossary_formats ( id int(10) unsigned NOT NULL auto_increment, - fid int(10) unsigned NOT NULL default '0', + name varchar(50) NOT NULL, + popupformatname varchar(50) NOT NULL, visible tinyint(2) unsigned NOT NULL default '1', - - relatedview tinyint(3) NOT NULL default '-1', showgroup tinyint(2) unsigned NOT NULL default '1', - defaultmode varchar(50) NOT NULL default '', defaulthook varchar(50) NOT NULL default '', - sortkey varchar(50) NOT NULL default '', sortorder varchar(50) NOT NULL default '', - PRIMARY KEY (id) ) TYPE=MyISAM COMMENT='Setting of the display formats'; diff --git a/mod/glossary/db/postgres7.php b/mod/glossary/db/postgres7.php index afa4ba491b..1c9e6f7340 100644 --- a/mod/glossary/db/postgres7.php +++ b/mod/glossary/db/postgres7.php @@ -37,7 +37,68 @@ function glossary_upgrade($oldversion) { table_column("glossary_alias", "alias", "alias", "VARCHAR", "255", "", "", "NOT NULL"); } - return true; + if ( $oldversion < 2004072400) { + + //Create new table glossary_formats to store format info + execute_sql("CREATE TABLE `{$CFG->prefix}glossary_formats` ( + `id` INT(10) unsigned NOT NULL auto_increment, + `name` VARCHAR(50) NOT NULL, + `popupformatname` VARCHAR(50) NOT NULL, + `visible` int2 UNSIGNED NOT NULL default '1', + `showgroup int2 UNSIGNED NOT NULL default '1', + `defaultmode` VARCHAR(50) NOT NULL default '', + `defaulthook` VARCHAR(50) NOT NULL default '', + `sortkey` VARCHAR(50) NOT NULL default '', + `sortorder` VARCHAR(50) NOT NULL default '', + PRIMARY KEY (`id`) + ) TYPE=MyISAM COMMENT='Setting of the display formats'"); + + //Define current 0-6 format names + $formatnames = array('dictionary','continuous','fullwithauthor','encyclopedia', + 'faq','fullwithoutauthor','entrylist'); + + //Fill the new table from the old one (only 'valid', 0-6, formats) + if ($formats = get_records('glossary_displayformats')) { + foreach ($formats as $format) { + //Format names + if ($format->fid >= 0 && $format->fid <= 6) { + $format->name = $formatnames[$format->fid]; + } + + //Format popupformatname + $format->popupformatname = 'dictionary'; //Default format + if ($format->relatedview >= 0 && $format->relatedview <= 6) { + $format->popupformatname = $formatnames[$format->relatedview]; + } + + //Insert the new record + //Only if $format->name is set (ie. formats 0-6) + if ($format->name) { + insert_record('glossary_formats',$format); + } + + } + } + + //Drop the old formats table + execute_sql("DROP TABLE `{$CFG->prefix}glossary_displayformats`"); + + //Modify the glossary->displayformat field + table_column('glossary', 'displayformat', 'displayformat', 'VARCHAR', '50', '', 'dictionary', 'NOT NULL'); + + //Update glossary->displayformat field + if ($glossaries = get_records('glossary')) { + foreach($glossaries as $glossary) { + $displayformat = 'dictionary'; //Default format + if ($glossary->displayformat >= 0 && $glossary->displayformat <= 6) { + $displayformat = $formatnames[$glossary->displayformat]; + } + set_field('glossary','displayformat',$displayformat,'id',$glossary->id); + } + } + } + + return true; } ?> diff --git a/mod/glossary/db/postgres7.sql b/mod/glossary/db/postgres7.sql index 8d7a61f085..5d1f637e52 100644 --- a/mod/glossary/db/postgres7.sql +++ b/mod/glossary/db/postgres7.sql @@ -15,7 +15,7 @@ CREATE TABLE prefix_glossary ( intro text NOT NULL default '', studentcanpost int2 NOT NULL default '0', allowduplicatedentries int2 NOT NULL default '0', - displayformat int2 NOT NULL default '0', + displayformat varchar(50) NOT NULL default 'dictionary', mainglossary int2 NOT NULL default '0', showspecial int2 NOT NULL default '1', showalphabet int2 NOT NULL default '1', @@ -108,29 +108,25 @@ CREATE TABLE prefix_glossary_comments ( ); # -# Table structure for table `glossary_displayformats` +# Table structure for table `glossary_formats` # -CREATE TABLE prefix_glossary_displayformats ( +CREATE TABLE prefix_glossary_formats ( id SERIAL, - fid int4 NOT NULL default '0', + name varchar(50) NOT NULL, + popupformatname varchar(50) NOT NULL, visible int2 NOT NULL default '1', - - relatedview int4 NOT NULL default '-1', showgroup int2 NOT NULL default '1', - defaultmode varchar(50) NOT NULL default '', defaulthook varchar(50) NOT NULL default '', - sortkey varchar(50) NOT NULL default '', sortorder varchar(50) NOT NULL default '', - PRIMARY KEY (id) ); # -# Table structure for table `forum_ratings` +# Table structure for table `glossary_ratings` # CREATE TABLE prefix_glossary_ratings ( diff --git a/mod/glossary/formats.php b/mod/glossary/formats.php index 5982c0a0a3..0c4e7ab394 100644 --- a/mod/glossary/formats.php +++ b/mod/glossary/formats.php @@ -16,10 +16,8 @@ error("Site isn't defined!"); } - if ( !$displayformat = get_record("glossary_displayformats","fid",$id) ) { - unset($displayformat); - $displayformat->fid = $id; - $displayformat->id = insert_record("glossary_displayformats",$displayformat); + if ( !$displayformat = get_record("glossary_formats","id",$id) ) { + error ("Invalid Glossary Format"); } $form = data_submitted(); @@ -30,20 +28,20 @@ } else { $displayformat->visible = 1; } - update_record("glossary_displayformats",$displayformat); + update_record("glossary_formats",$displayformat); } - redirect($_SERVER["HTTP_REFERER"]); + redirect("../../admin/module.php?module=glossary#formats"); die; } elseif ( $mode == 'edit' and $form) { - $displayformat->relatedview = $form->relatedview; + $displayformat->popupformatname = $form->popupformatname; $displayformat->showgroup = $form->showgroup; $displayformat->defaultmode = $form->defaultmode; $displayformat->defaulthook = $form->defaulthook; $displayformat->sortkey = $form->sortkey; $displayformat->sortorder = $form->sortorder; - update_record("glossary_displayformats",$displayformat); + update_record("glossary_formats",$displayformat); redirect("../../admin/module.php?module=glossary#formats"); die; } @@ -74,57 +72,34 @@ ?> - + name,"glossary"); ?> - -

Related Display Format: + -

-

Default Mode: + -

Default Sort Key: +

Include Group Breaks: + //get and update available formats + $recformats = glossary_get_available_formats(); + + $formats = array(); + + //Take names + foreach ($recformats as $format) { + $formats[$format->name] = get_string("displayformat$format->name", "glossary"); + } + //Sort it + asort($formats); + + choose_from_menu($formats,'displayformat',$form->displayformat,''); + ?> + @@ -326,7 +314,8 @@ if (!$mainglossary or $mainglossary->id == $form->instance ) { enablerssfeeds && $CFG->glossary_enablerssfeeds) { + if (isset($CFG->enablerssfeeds) && isset($CFG->glossary_enablerssfeeds) && + $CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds) { echo ""; echo "

".get_string("rsstype").":

"; echo ""; diff --git a/mod/glossary/print.php b/mod/glossary/print.php index 6d50702d29..b89165bc2f 100644 --- a/mod/glossary/print.php +++ b/mod/glossary/print.php @@ -1,5 +1,7 @@ entbypage ) { $entriesbypage = $CFG->glossary_entbypage; } + print_header(strip_tags("$course->shortname: $glossary->name")); + if ($CFG->forcelogin) { require_login(); } @@ -40,6 +43,28 @@ } } +/// setting the default values for the display mode of the current glossary +/// only if the glossary is viewed by the first time + if ( $dp = get_record('glossary_formats','name', $glossary->displayformat) ) { + $printpivot = $dp->showgroup; + if ( $mode == '' and $hook == '' and $show == '') { + $mode = $dp->defaultmode; + $hook = $dp->defaulthook; + $sortkey = $dp->sortkey; + $sortorder = $dp->sortorder; + } + } else { + $printpivot = 1; + if ( $mode == '' and $hook == '' and $show == '') { + $mode = 'letter'; + $hook = 'ALL'; + } + } + + if ( $displayformat == -1 ) { + $displayformat = $glossary->displayformat; + } + /// stablishing flag variables if ( $sortorder = strtolower($sortorder) ) { if ($sortorder != 'asc' and $sortorder != 'desc') { @@ -118,12 +143,11 @@ if ( $hook == 'SPECIAL' ) { $alphabet = explode(",", get_string("alphabet")); } - $tableisopen = 0; $site = get_record("course","id",1); echo '

' . userdate(time()) . '

'; echo '' . $site->fullname . '
'; - echo get_string("course") . ': ' . $course->fullname . '
'; + echo get_string("course") . ': ' . $course->fullname . ' ('. $course->shortname . ')
'; echo get_string("modulename","glossary") . ': ' . $glossary->name . '

'; if ( $allentries ) { foreach ($allentries as $entry) { @@ -178,49 +202,31 @@ /// ok, if it's a valid entry.. Print it. if ( $showentry ) { - if ( !$tableisopen ) { - echo ''; - $tableisopen = 1; - } if ( $currentpivot != strtoupper($pivot) ) { // print the group break if apply if ( $printpivot ) { $currentpivot = strtoupper($pivot); - echo ''; $pivottoshow = $currentpivot; if ( isset($entry->uid) ) { - // printing the user icon if defined (only when browsing authors) - echo ''; - echo ''; + echo "

$pivottoshow

" ; } } - echo ''; - echo ''; - echo ''; + echo '

'; } } } - if ($tableisopen) { - echo '
'; $user = get_record("user","id",$entry->uid); $pivottoshow = fullname($user, isteacher($course->id)); - } else { - echo ''; } - echo "$pivottoshow" ; - echo '
'. $entry->concept . ': '; + echo ''. strip_tags($entry->concept) . ': '; + $options->para = false; + $definition = format_text('' . strip_tags($entry->definition) . '', $entry->format,$options); - if ( $entry->attachment) { - glossary_print_entry_attachment($entry); - } - echo strip_tags($entry->definition); + echo ($definition); - echo '

'; - } - echo '

' . userdate(time()) . '
'; echo ''; ?> diff --git a/mod/glossary/restorelib.php b/mod/glossary/restorelib.php index 92164286d1..fbb555075e 100644 --- a/mod/glossary/restorelib.php +++ b/mod/glossary/restorelib.php @@ -79,6 +79,26 @@ } } + //To mantain backwards compatibility (pre 1.4) we have to check the displayformat field + //If it's numeric (0-6) we have to convert it to its new formatname. + //Define current 0-6 format names + $formatnames = array('dictionary','continuous','fullwithauthor','encyclopedia', + 'faq','fullwithoutauthor','entrylist'); + //If it's numeric, we are restoring a pre 1.4 course, do the conversion + if (is_numeric($glossary->displayformat)) { + $displayformat = 'dictionary'; //Default format + if ($glossary->displayformat >= 0 && $glossary->displayformat <= 6) { + $displayformat = $formatnames[$glossary->displayformat]; + } + $glossary->displayformat = $displayformat; + } + + //Now check that the displayformat exists in the server, else default to dictionary + $formats = get_list_of_plugins('mod/glossary/formats'); + if (!in_array($glossary->displayformat,$formats)) { + $glossary->displayformat = 'dictionary'; + } + //The structure is equal to the db, so insert the glossary $newid = insert_record ("glossary",$glossary); diff --git a/mod/glossary/showentry.php b/mod/glossary/showentry.php index 5728175642..d8fe45765f 100644 --- a/mod/glossary/showentry.php +++ b/mod/glossary/showentry.php @@ -11,6 +11,22 @@ require_login(); } + if ($eid) { + $entries[] = get_record("glossary_entries", "id", $eid); + + } else if ($concept) { + $entries = get_records_sql("select e.* from {$CFG->prefix}glossary_entries e, {$CFG->prefix}glossary g". + " where e.glossaryid = g.id and". + " (e.casesensitive != 0 and ucase(concept) = '" . strtoupper(trim($concept)). "' or". + " e.casesensitive = 0 and concept = '$concept') and". + " (g.course = $courseid or g.globalglossary) and". + " e.usedynalink != 0 and g.usedynalink != 0"); + } + + foreach ($entries as $entry) { + $glossary = get_record('glossary','id',$entry->glossaryid); + } + if (!empty($courseid)) { $course = get_record("course", "id", $courseid); if ($course->category) { @@ -29,24 +45,10 @@ "$strglossaries -> $strsearch", "", "", true, " ", " "); } - } else { print_header(); // Needs to be something here to allow linking back to the whole glossary } - - if ($eid) { - $entries[] = get_record("glossary_entries", "id", $eid); - - } else if ($concept) { - $entries = get_records_sql("select e.* from {$CFG->prefix}glossary_entries e, {$CFG->prefix}glossary g". - " where e.glossaryid = g.id and". - " (e.casesensitive != 0 and ucase(concept) = '" . strtoupper(trim($concept)). "' or". - " e.casesensitive = 0 and concept = '$concept') and". - " (g.course = $courseid or g.globalglossary) and". - " e.usedynalink != 0 and g.usedynalink != 0"); - } - if ($entries) { glossary_print_dynaentry($courseid, $entries, $displayformat); } diff --git a/mod/glossary/sql.php b/mod/glossary/sql.php index a7073d53a8..fbfc2b98cf 100644 --- a/mod/glossary/sql.php +++ b/mod/glossary/sql.php @@ -51,11 +51,7 @@ ge.id = gec.entryid AND gc.id = gec.categoryid AND (ge.approved != 0 $userid)"; - if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) { - $sqlorderby = ' ORDER BY gc.name, ge.timecreated'; - } else { - $sqlorderby = ' ORDER BY gc.name, ge.concept'; - } + $sqlorderby = ' ORDER BY gc.name, ge.concept'; } elseif ($hook == GLOSSARY_SHOW_NOT_CATEGORISED ) { diff --git a/mod/glossary/tabs.html b/mod/glossary/tabs.html index 4ec828ba5a..241bd7b89d 100644 --- a/mod/glossary/tabs.html +++ b/mod/glossary/tabs.html @@ -38,13 +38,10 @@ $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&mode=date"; - if ( $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS ) { + $data[GLOSSARY_STANDARD_VIEW]->link = "view.php?id=$id&mode=letter"; + $data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&mode=cat"; + $data[GLOSSARY_AUTHOR_VIEW]->link = "view.php?id=$id&mode=author"; - $data[GLOSSARY_STANDARD_VIEW]->link = "view.php?id=$id&mode=letter"; - $data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&mode=cat"; - $data[GLOSSARY_AUTHOR_VIEW]->link = "view.php?id=$id&mode=author"; - - } if (isteacher($course->id)) { $data[GLOSSARY_APPROVAL_VIEW]->caption = get_string("waitingapproval", "glossary"); diff --git a/mod/glossary/version.php b/mod/glossary/version.php index 4778508f1f..5d4b605712 100644 --- a/mod/glossary/version.php +++ b/mod/glossary/version.php @@ -5,7 +5,7 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2004072300; // The current module version (Date: YYYYMMDDXX) +$module->version = 2004072700; // The current module version (Date: YYYYMMDDXX) $module->requires = 2004052501; // Requires this Moodle version $module->cron = 0; // Period for cron to check this module (secs) diff --git a/mod/glossary/view.php b/mod/glossary/view.php index c3af03db50..bea8ebd2f2 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -70,7 +70,7 @@ /// setting the default values for the display mode of the current glossary /// only if the glossary is viewed by the first time - if ( $dp = get_record("glossary_displayformats","fid", $glossary->displayformat) ) { + if ( $dp = get_record('glossary_formats','name', $glossary->displayformat) ) { $printpivot = $dp->showgroup; if ( $mode == '' and $hook == '' and $show == '') { $mode = $dp->defaultmode; @@ -89,9 +89,6 @@ if ( $displayformat == -1 ) { $displayformat = $glossary->displayformat; } - if ( $displayformat == GLOSSARY_FORMAT_CONTINUOUS ) { - $mode = 'date'; - } if ( $show ) { $mode = 'term'; @@ -140,10 +137,8 @@ case 'entry': /// Looking for a certain entry id $tab = GLOSSARY_STANDARD_VIEW; - if ( $dp = get_record("glossary_displayformats","fid", $glossary->displayformat) ) { - if ( $dp->relatedview >= 0 ) { - $displayformat = $dp->relatedview; - } + if ( $dp = get_record("glossary_formats","name", $glossary->displayformat) ) { + $displayformat = $dp->popupformatname; } break; @@ -225,7 +220,8 @@ navmenu($course, $cm)); //If rss are activated at site and glossary level and this glossary has rss defined, show link - if ($CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds && $glossary->rsstype and $glossary->rssarticles) { + if (isset($CFG->enablerssfeeds) && isset($CFG->glossary_enablerssfeeds) && + $CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds && $glossary->rsstype and $glossary->rssarticles) { echo '
'; $tooltiptext = get_string("rsssubscriberss","glossary",$glossary->name); rss_print_link($course->id, $USER->id, "glossary", $glossary->id, $tooltiptext); @@ -235,7 +231,7 @@ echo '

' . stripslashes_safe($glossary->name); if ( $isuserframe and $mode != 'search') { /// the "Print" icon - echo " id&mode=$mode&hook=$hook&sortkey=$sortkey&sortorder=$sortorder&offset=$offset\">"; + echo " id&mode=$mode&hook=$hook&sortkey=$sortkey&sortorder=$sortorder&offset=$offset\">"; echo ''; } echo '

'; @@ -281,7 +277,6 @@ $currentpivot = ''; $ratingsmenuused = NULL; $paging = NULL; - $tableisopen = 0; if ( $hook == 'SPECIAL' ) { $alphabet = explode(",", get_string("alphabet")); } @@ -391,10 +386,6 @@ // print the group break if apply if ( $printpivot ) { - if ( $tableisopen ) { - print_simple_box_end(); - $tableisopen = 0; - } $currentpivot = strtoupper($pivot); echo '

'; @@ -416,22 +407,9 @@ echo " $pivottoshow" ; echo '

'; - if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS OR - $glossary->displayformat == GLOSSARY_FORMAT_SIMPLE ) { - print_simple_box_start("center","95%","#ffffff","5","generalbox"); - $tableisopen = 1; - } } } - if ( !$tableisopen ) { - if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS OR - $glossary->displayformat == GLOSSARY_FORMAT_SIMPLE ) { - print_simple_box_start("center","95%","#ffffff","5","generalbox"); - $tableisopen = 1; - } - } - $concept = $entry->concept; $definition = $entry->definition; @@ -449,13 +427,6 @@ $entriesshown++; } } - if ( $tableisopen ) { - if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS OR - $glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) { - print_simple_box_end(); - $tableisopen = 0; - } - } } if ( !$entriesshown ) { print_simple_box('
' . get_string("noentries","glossary") . '
',"center","95%");