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)
* 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.
<tr>
<td colspan=3 align=center>
<?php
- if ( !$displayformat = get_record("glossary_displayformats","fid",0) ) {
- unset($displayformat);
- $displayformat->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 '<table cellpadding="5" bgcolor="#FFFFFF" class="generaltab" width="40%" align="center">';
- for ($i = 0; $i < count($formats); $i++) {
- if ( $formats[$i] ) {
- $format = get_record("glossary_displayformats","fid",$i);
- echo '<tr>';
- echo '<td>' . $formats[$i] . '</td>';
- $eicon = "<a title=\"" . get_string("edit") . "\" href=\"$CFG->wwwroot/mod/glossary/formats.php?id=$i&mode=edit\"><img border=\"0\" src=\"../pix/t/edit.gif\"></a>";
- if ( $format->visible ) {
- $vtitle = get_string("hide");
- $vicon = "hide.gif";
- } else {
- $vtitle = get_string("show");
- $vicon = "show.gif";
- }
- $vicon = "<a title=\"" . $vtitle . "\" href=\"$CFG->wwwroot/mod/glossary/formats.php?id=$i&mode=visible\"><img border=\"0\" src=\"../pix/t/" . $vicon . "\"></a>";
-
- echo '<td align="center"> ' . $eicon . ' ' . $vicon . '</td>';
- echo '</tr>';
+ foreach ($formats as $formatid=>$formatname) {
+ $recformat = get_record('glossary_formats','id',$formatid);
+ echo '<tr>';
+ echo '<td>' . $formatname . '</td>';
+ $eicon = "<a title=\"" . get_string("edit") . "\" href=\"$CFG->wwwroot/mod/glossary/formats.php?id=$formatid&mode=edit\"><img border=\"0\" src=\"../pix/t/edit.gif\"></a>";
+ if ( $recformat->visible ) {
+ $vtitle = get_string("hide");
+ $vicon = "hide.gif";
+ } else {
+ $vtitle = get_string("show");
+ $vicon = "show.gif";
}
+ $vicon = "<a title=\"" . $vtitle . "\" href=\"$CFG->wwwroot/mod/glossary/formats.php?id=$formatid&mode=visible\"><img border=\"0\" src=\"../pix/t/" . $vicon . "\"></a>";
+
+ echo '<td align="center" nowrap>' . $eicon . ' ' . $vicon . '</td>';
+ echo '</tr>';
}
echo '</table>';
<td align=right><p>glossary_enablerssfeeds:</td>
<td>
<?php
- if ($CFG->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, "", "", "");
}
?>
</td>
<td>
<?php
print_string("configenablerssfeeds","glossary");
- if ($CFG->enablerssfeeds == 0) {
+ if (!isset($CFG->enablerssfeeds) || $CFG->enablerssfeeds == 0) {
print_string("configenablerssfeedsdisabled");
}
?>
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;
}
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',
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';
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;
}
?>
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',
);
#
-# 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 (
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();
} 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;
}
?>
<tr>
<td colspan=3 align=center><strong>
- <?php
- switch ( $id ) {
- case 0:
- echo get_string('displayformatdefault',"glossary");
- break;
-
- case 1:
- echo get_string('displayformatcontinuous',"glossary");
- break;
- default:
- echo get_string('displayformat'.$id,"glossary");
- break;
- }
- ?>
+ <?php echo get_string('displayformat'.$displayformat->name,"glossary"); ?>
</strong></td>
</tr>
<tr valign=top>
- <td align="right" width="20%">
- <p>Related Display Format:</td>
+ <td align="right" width="20%"><?PHP print_string('popupformat','glossary'); ?></td>
<td>
- <SELECT size=1 name=relatedview>
- <OPTION value=0 <?php if ( $displayformat->relatedview == 0 ) {
- echo " SELECTED ";
- }
- ?>><?php p(get_string("displayformatdefault","glossary"))?></OPTION>
- <OPTION value=1 <?php if ( $displayformat->relatedview == 1 ) {
- echo " SELECTED ";
- }
- ?>><?php p(get_string("displayformatcontinuous","glossary"))?></OPTION>
<?PHP
- $i = 2;
- $dpname = get_string("displayformat".$i,"glossary");
- $file = "$CFG->dirroot/mod/glossary/formats/$i.php";
- while ( file_exists($file) ) {
- echo '<OPTION value="' . $i . '"';
- if ( $displayformat->relatedview == $i ) {
- echo " SELECTED ";
- }
- echo '> ' . get_string("displayformat".$i,"glossary") . '</OPTION>';
- $i++;
- $file = "$CFG->dirroot/mod/glossary/formats/$i.php";
+ //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,'popupformatname',$displayformat->popupformatname);
?>
- </SELECT>
</td>
<td width="60%">
<?php print_string("cnfrelatedview", "glossary") ?><br /><br />
</td>
</tr>
<tr valign=top>
- <td align="right" width="20%"><p>Default Mode:</td>
+ <td align="right" width="20%"><?PHP print_string('defaultmode','glossary'); ?></td>
<td>
<SELECT size=1 name=defaultmode>
<?php
</td>
</tr>
<tr valign=top>
- <td align="right" width="20%"><p>Default Hook:</td>
+ <td align="right" width="20%"><?PHP print_string('defaulthook','glossary'); ?></td>
<td>
<SELECT size=1 name=defaulthook>
<?php
</td>
</tr>
<tr valign=top>
- <td align="right" width="20%"><p>Default Sort Key:</td>
+ <td align="right" width="20%"><?PHP print_string('defaultsortkey','glossary'); ?></td>
<td>
<SELECT size=1 name=sortkey>
<?php
</td>
</tr>
<tr valign=top>
- <td align="right" width="20%"><p>Default Sort Order:</td>
+ <td align="right" width="20%"><?PHP print_string('defaultsortorder','glossary'); ?></td>
<td>
<SELECT size=1 name=sortorder>
<?php
<td align="right" width="20%"><p>Include Group Breaks:</td>
<td>
<SELECT size=1 name=showgroup>
- <?php
+ <?php
$yselected = "";
$nselected = "";
if ($displayformat->showgroup) {
--- /dev/null
+<?PHP // $Id$
+
+function glossary_show_entry_continuous($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL) {
+
+ global $THEME, $USER;
+
+ $return = false;
+ if ($entry) {
+ glossary_print_entry_approval($cm, $entry, $mode);
+ glossary_print_entry_attachment($entry,"html","right");
+ glossary_print_entry_concept($entry);
+ echo ": ";
+
+ glossary_print_entry_definition($entry);
+
+ $icons = '';
+ if ( $printicons ) {
+ $icons = glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode, $hook,"html");
+ }
+
+ echo '(';
+ if ( $icons ) {
+ echo $icons;
+ }
+ $return = glossary_print_entry_ratings($course, $entry, $ratings);
+
+ echo ')<br>';
+
+ }
+ return $return;
+
+}
+
+?>
--- /dev/null
+<?PHP // $Id$
+
+function glossary_show_entry_dictionary($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL) {
+
+ global $THEME, $CFG, $USER;
+
+ $colour = $THEME->cellheading2;
+
+ echo "\n<table border=0 width=95% cellspacing=0 valign=top cellpadding=3 class=forumpost align=center>\n";
+ echo "<tr>\n";
+ echo "<td width=\"100%\" valign=\"top\" bgcolor=\"#FFFFFF\">\n";
+ glossary_print_entry_approval($cm, $entry, $mode);
+ glossary_print_entry_attachment($entry,"html","right");
+ echo "<b>";
+ glossary_print_entry_concept($entry);
+ echo ":</b> ";
+ glossary_print_entry_definition($entry);
+ $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings);
+ echo "</td>\n";
+ echo "</tr>\n";
+ echo "</table>\n";
+
+ return $return;
+}
+
+?>
--- /dev/null
+<?PHP // $Id$
+
+function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL) {
+ global $THEME, $CFG, $USER;
+
+ $colour = $THEME->cellheading2;
+
+ $user = get_record("user", "id", $entry->userid);
+ $strby = get_string("writtenby", "glossary");
+
+ echo "\n<br /><table border=0 width=95% cellspacing=0 valign=top cellpadding=3 class=forumpost align=center>";
+
+ echo "\n<tr>";
+ echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostpicture\">";
+ $return = false;
+ if ($entry) {
+ print_user_picture($user->id, $course->id, $user->picture);
+ echo "</td>";
+ echo "<td align=\"top\" width=100% bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\">";
+ glossary_print_entry_approval($cm, $entry, $mode);
+ echo "<b>";
+ glossary_print_entry_concept($entry);
+ echo "</b><br />";
+ echo "<font size=\"2\">$strby " . fullname($user, isteacher($course->id)) . "</font>";
+ echo " <font size=1>(".get_string("lastedited").": ".
+ userdate($entry->timemodified).")</font>";
+ echo "</tr>";
+
+ echo "\n<tr>";
+ echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostside\"> </td>";
+ echo "\n<td width=100% align=\"top\" bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">";
+
+ if ($entry->attachment) {
+ $entry->course = $course->id;
+ if (strlen($entry->definition)%2) {
+ $align = "right";
+ } else {
+ $align = "left";
+ }
+ glossary_print_entry_attachment($entry,"",$align);
+ }
+ glossary_print_entry_definition($entry);
+
+ glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
+ echo ' ';
+ $return = glossary_print_entry_ratings($course, $entry, $ratings);
+
+ } else {
+ echo "<center>";
+ print_string("noentry", "glossary");
+ echo "</center>";
+ }
+ echo "</td></tr>";
+
+ echo "</table>\n";
+
+ return $return;
+}
+
+?>
--- /dev/null
+<?PHP // $Id$
+
+function glossary_show_entry_entrylist($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL) {
+ global $THEME, $USER;
+
+ $colour = "#FFFFFF";
+ $return = false;
+
+ echo "\n<table border=0 cellspacing=0 width=95% valign=top cellpadding=10>";
+
+ echo "\n<tr>";
+ echo "<td width=100% bgcolor=\"$colour\">";
+ if ($entry) {
+ echo "<b><a href=\"showentry.php?courseid=$course->id\&eid=$entry->id\&displayformat=dictionary\" target=\"_blank\" onClick=\"return openpopup('/mod/glossary/showentry.php?courseid=$course->id\&eid=$entry->id\&displayformat=dictionary', 'entry', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">";
+
+ glossary_print_entry_concept($entry);
+ echo '</a></b> ';
+ if ( $return = glossary_print_entry_commentslink($course, $cm, $glossary, $entry,$mode,$hook, 'html') ) {
+ echo "<font size=-1>($return)</font>";
+ }
+
+ echo '<br />';
+ } else {
+ echo "<center>";
+ print_string("noentry", "glossary");
+ echo "</center>";
+ }
+ echo "</td></tr>";
+
+ echo "</table>\n";
+ return $return;
+}
+
+?>
--- /dev/null
+<?PHP // $Id$
+
+function glossary_show_entry_faq($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL) {
+ global $THEME, $USER;
+ $return = false;
+ if ( $entry ) {
+ $colour = $THEME->cellheading2;
+
+ echo '<br /><table border=0 cellspacing=0 width=95% valign=top cellpadding=10 class=forumpost>';
+
+ echo '<tr>';
+ echo "<td width=100% bgcolor=\"$colour\">";
+ $entry->course = $course->id;
+ glossary_print_entry_approval($cm, $entry, $mode);
+ glossary_print_entry_attachment($entry,"html","right");
+
+ echo '<b>' . get_string("question","glossary") . ':</b> ';
+ glossary_print_entry_concept($entry) . '<br>';
+ echo ' <font size=1>' . get_string("lastedited").': '.userdate($entry->timemodified) . '</font></tr>';
+ echo "<tr><td width=100% bgcolor=\"$THEME->cellcontent\">";
+ echo '<b>' . get_string("answer","glossary") . ':</b> ';
+ glossary_print_entry_definition($entry);
+
+
+ glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook,$printicons);
+ echo ' ';
+ $return = glossary_print_entry_ratings($course, $entry, $ratings);
+ echo '</td></tr></table>';
+
+ } else {
+ echo '<center>';
+ print_string("noentry", "glossary");
+ echo '</center>';
+ }
+ return $return;
+}
+
+?>
--- /dev/null
+<?PHP // $Id$
+
+function glossary_show_entry_fullwithauthor($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL) {
+ global $THEME, $CFG, $USER;
+
+ $colour = $THEME->cellheading2;
+
+ $user = get_record("user", "id", $entry->userid);
+ $strby = get_string("writtenby", "glossary");
+
+ echo "\n<br /><table border=0 width=95% cellspacing=0 valign=top cellpadding=3 class=forumpost align=center>";
+
+ echo "\n<tr>";
+ echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostpicture\">";
+ $return = false;
+ if ($entry) {
+ print_user_picture($user->id, $course->id, $user->picture);
+
+ echo "</td>";
+ echo "<td valign=\"top\" width=100% bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\">";
+
+ glossary_print_entry_approval($cm, $entry, $mode);
+ glossary_print_entry_attachment($entry,"html","right");
+
+ echo "<b>";
+ glossary_print_entry_concept($entry);
+ echo "</b><br />";
+
+ echo "<font size=\"2\">$strby " . fullname($user, isteacher($course->id)) . "</font>";
+ echo " <font size=1>(".get_string("lastedited").": ".
+ userdate($entry->timemodified).")</font>";
+ echo "</tr>";
+
+ echo "\n<tr>";
+ echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostside\"> </td>";
+ echo "\n<td width=100% bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">";
+
+ glossary_print_entry_definition($entry);
+ glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
+ echo ' ';
+ $return = glossary_print_entry_ratings($course, $entry, $ratings);
+
+ } else {
+ echo "<center>";
+ print_string("noentry", "glossary");
+ echo "</center>";
+ }
+ echo "</td></tr>";
+
+ echo "</table>\n";
+ return $return;
+}
+
+?>
--- /dev/null
+<?PHP // $Id$
+
+function glossary_show_entry_fullwithoutauthor($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL) {
+ global $THEME, $USER;
+
+ $colour = $THEME->cellheading2;
+ $return = false;
+
+ echo "\n<br /><table border=0 width=95% cellspacing=0 valign=top cellpadding=3 class=forumpost align=center>";
+
+ echo "\n<tr>";
+ echo "<td width=100% bgcolor=\"$THEME->cellheading\">";
+ glossary_print_entry_approval($cm, $entry, $mode);
+ if ($entry) {
+ glossary_print_entry_attachment($entry,"html","right");
+ echo "<b>";
+ glossary_print_entry_concept($entry);
+ echo "</b><br />";
+ echo "<font size=1>".get_string("lastedited").": ".userdate($entry->timemodified)."</font>";
+ echo "</tr>";
+ echo "\n<tr><td width=100% bgcolor=\"$THEME->cellcontent\">";
+
+ glossary_print_entry_definition($entry);
+ glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook,$printicons);
+ echo ' ';
+ $return = glossary_print_entry_ratings($course, $entry, $ratings);
+ } else {
+ echo "<center>";
+ print_string("noentry", "glossary");
+ echo "</center>";
+ }
+ echo "</td></tr>";
+
+ echo "</table>\n";
+ return $return;
+}
+
+?>
define("GLOSSARY_EXPORT_VIEW", 6);
define("GLOSSARY_APPROVAL_VIEW", 7);
-define("GLOSSARY_FORMAT_SIMPLE", 0);
-define("GLOSSARY_FORMAT_CONTINUOUS", 1);
-
function glossary_add_instance($glossary) {
/// Given an object containing all the necessary data,
/// (defined by the form in mod.html) this function
global $CFG;
if ($entries = glossary_get_user_entries($glossary->id, $user->id)) {
- if ( $glossary->displayformat == GLOSSARY_FORMAT_SIMPLE or
- $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
- print_simple_box_start("center","70%");
- } else {
- echo '<table width="95%" border="0"><tr><td>';
- }
+ echo '<table width="95%" border="0"><tr><td>';
foreach ($entries as $entry) {
$cm = get_coursemodule_from_instance("glossary", $glossary->id, $course->id);
glossary_print_entry($course, $cm, $glossary, $entry,"","",0);
echo '<p>';
}
- if ( $glossary->displayformat == GLOSSARY_FORMAT_SIMPLE or
- $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
- print_simple_box_end();
- } else {
- echo '</td></tr></table>';
- }
+ echo '</td></tr></table>';
}
}
return false;
}
+ $entries = array();
+
foreach ($logs as $log) {
//Create a temp valid module structure (course,id)
$tempmod->course = $log->course;
/// Any other glossary functions go here. Each of them must have a name that
/// starts with glossary_
+//This function return an array of valid glossary_formats records
+//Everytime it's called, every existing format is checked, new formats
+//are included if detected and old formats are deleted and any glossary
+//using an invalid format is updated to the default (dictionary).
+function glossary_get_available_formats() {
+
+ global $CFG;
+
+ //Get available formats (plugin) and insert (if necessary) them into glossary_formats
+ $formats = get_list_of_plugins('mod/glossary/formats');
+ foreach ($formats as $format) {
+ //If the format file exists
+ if (file_exists($CFG->dirroot.'/mod/glossary/formats/'.$format.'/'.$format.'_format.php')) {
+ include_once($CFG->dirroot.'/mod/glossary/formats/'.$format.'/'.$format.'_format.php');
+ //If the function exists
+ if (function_exists('glossary_show_entry_'.$format)) {
+ //If the format doesn't exist in the table
+ if (!$rec = get_record('glossary_formats','name',$format)) {
+ //Insert the record in glossary_formats
+ $gf->name = $format;
+ $gf->popupformatname = $format;
+ $gf->visible = 1;
+ insert_record("glossary_formats",$gf);
+ }
+ }
+ }
+ }
+
+ //Delete non_existent formats from glossary_formats table
+ $formats = get_records("glossary_formats");
+ foreach ($formats as $format) {
+ $todelete = false;
+ //If the format file doesn't exists delete the record
+ if (!file_exists($CFG->dirroot.'/mod/glossary/formats/'.$format->name.'/'.$format->name.'_format.php')) {
+ $todelete = true;
+ } else {
+ include_once($CFG->dirroot.'/mod/glossary/formats/'.$format->name.'/'.$format->name.'_format.php');
+ //If the glossary_show_entry_XXXX doesn't exists delete the record
+ if (!function_exists('glossary_show_entry_'.$format->name)) {
+ $todelete = true;
+ }
+ }
+
+ if ($todelete) {
+ //Delete the format
+ delete_records('glossary_formats','name',$format->name);
+ //Reasign existing glossaries to default (dictionary) format
+ if ($glossaries = get_records('glossary','displayformat',$format->name)) {
+ foreach($glossaries as $glossary) {
+ set_field('glossary','displayformat','dictionary','id',$glossary->id);
+ }
+ }
+ }
+ }
+
+ //Now everything is ready in glossary_formats table
+ $formats = get_records("glossary_formats");
+
+ return $formats;
+}
+
function glossary_debug($debug,$text,$br=1) {
if ( $debug ) {
echo '<font color=red>' . $text . '</font>';
$displayformat = $glossary->displayformat;
}
if ($entry->approved or ($USER->id == $entry->userid) or ($mode == 'approval' and !$entry->approved) ) {
- $permissiongranted = 0;
- $formatfile = "$CFG->dirroot/mod/glossary/formats/$displayformat.php";
- $functionname = "glossary_print_entry_by_format";
-
- $basicformat = ($displayformat == GLOSSARY_FORMAT_SIMPLE or
- $displayformat == GLOSSARY_FORMAT_CONTINUOUS);
- if ( !$basicformat ) {
- if ( file_exists($formatfile) ) {
- include_once($formatfile);
- if (function_exists($functionname) ) {
- $permissiongranted = 1;
- }
- }
- } else {
- $permissiongranted = 1;
- }
-
- if ( !$basicformat and $permissiongranted or $displayformat >= 2) {
- $return = glossary_print_entry_by_format($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings);
- } else {
- switch ( $displayformat ) {
- case GLOSSARY_FORMAT_SIMPLE:
- $return = glossary_print_entry_by_default($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings);
- break;
- case GLOSSARY_FORMAT_CONTINUOUS:
- $return = glossary_print_entry_continuous($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings);
- break;
+ $formatfile = $CFG->dirroot.'/mod/glossary/formats/'.$displayformat.'/'.$displayformat.'_format.php';
+ $functionname = 'glossary_show_entry_'.$displayformat;
+
+ if (file_exists($formatfile)) {
+ include_once($formatfile);
+ if (function_exists($functionname)) {
+ $return = $functionname($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings);
}
}
}
- return $return;
+ return $return;
}
+
function glossary_print_entry_concept($entry) {
$options->para = false;
$text = format_text('<nolink>' . $entry->concept . '</nolink>', FORMAT_MOODLE, $options);
}
}
-function glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook,$printicons) {
+function glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook,$printicons,$ratings) {
$aliases = glossary_print_entry_aliases($course, $cm, $glossary, $entry, $mode, $hook,"html");
$icons = "";
if ( $printicons ) {
$icons = glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode, $hook,"html");
}
- if ( $aliases ) {
- echo '<table border="0" width="100%" align="center"><tr>' .
- '<td align="right" width="50%" valign=top><font size=1>' .
- get_string("aliases","glossary") . ': ' . $aliases . '</td>' .
- '<td align=right width="50%" valign=top>'.
- $icons .
- '</td></tr></table>';
- } else {
- echo "<p align=right>$icons";
+ if ($aliases || $printicons || $ratings) {
+ echo '<table border="0" width="100%" align="center">';
+ if ( $aliases ) {
+ echo '<tr><td align="center" valign="top"><font size=1>' .
+ get_string("aliases","glossary") . ': ' . $aliases . '</td></tr>';
+ }
+ if ($icons) {
+ echo '<tr><td align=right valign=top>'. $icons . '</td></tr>';
+ }
+ if ($ratings) {
+ echo '<tr><td align=right valign=top>';
+ $return = glossary_print_entry_ratings($course, $entry, $ratings);
+ echo '</td></tr>';
+ }
+ echo '</table>';
}
+ return $return;
}
function glossary_print_entry_attachment($entry,$format=NULL,$align="right") {
if ($entry->attachment) {
$glossary = get_record("glossary","id",$entry->glossaryid);
$entry->course = $glossary->course; //used inside print_attachment
- echo "<table border=0 align=$align><tr><td>";
+ echo "<table border=0 width=\"100%\"><tr><td align=\"$align\">\n";
echo glossary_print_attachments($entry,$format,$align);
- echo "</td></tr></table>";
+ echo "</td></tr></table>\n";
}
}
-function glossary_print_entry_approval($cm, $entry, $mode) {
+function glossary_print_entry_approval($cm, $entry, $mode,$align="right") {
if ( $mode == 'approval' and !$entry->approved ) {
+ echo "<table border=0 width=\"100%\"><tr><td align=\"$align\">\n";
echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&mode=$mode\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
+ echo "</td></tr></table>\n";
}
}
-function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$mode="",$hook="",$printicons=1, $ratings=NULL) {
- global $THEME, $USER;
-
- $colour = $THEME->cellheading2;
-
- echo "\n<TR>";
- echo "<TD WIDTH=100% valign=\"top\" BGCOLOR=\"#FFFFFF\">";
- glossary_print_entry_approval($cm, $entry, $mode);
- glossary_print_entry_attachment($entry,"html","right");
- echo "<b>";
- glossary_print_entry_concept($entry);
- echo ":</b> ";
- glossary_print_entry_definition($entry);
- glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
- echo ' ';
- $return = glossary_print_entry_ratings($course, $entry, $ratings);
- echo "</td>";
- echo "</TR>";
- return $return;
-}
-
-function glossary_print_entry_continuous($course, $cm, $glossary, $entry,$mode="",$hook="",$printicons=1, $ratings = NULL) {
- global $THEME, $USER;
- $return = false;
- if ($entry) {
- glossary_print_entry_approval($cm, $entry, $mode);
- glossary_print_entry_attachment($entry,"html","right");
- glossary_print_entry_concept($entry);
- echo " ";
-
- glossary_print_entry_definition($entry);
-
- $icons = '';
- if ( $printicons ) {
- $icons = glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode, $hook,"html");
- }
-
- echo '(';
- if ( $icons ) {
- echo $icons;
- }
- $return = glossary_print_entry_ratings($course, $entry, $ratings);
-
- echo ')<br>';
-
- }
- return $return;
-}
-
function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL) {
// It returns all entries from all glossaries that matches the specified criteria
// within a given $course. It performs an $extended search if necessary.
}
function glossary_print_approval_menu($cm, $glossary,$mode, $hook, $sortkey = '', $sortorder = '') {
- if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
+ if ($glossary->showalphabet) {
echo '<center>' . get_string("explainalphabet","glossary") . '<p>';
}
glossary_print_special_links($cm, $glossary, $mode, $hook);
function glossary_print_alphabet_menu($cm, $glossary, $mode, $hook, $sortkey='', $sortorder = '') {
if ( $mode != 'date' ) {
- if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
+ if ($glossary->showalphabet) {
echo '<center>' . get_string("explainalphabet","glossary") . '<p>';
}
}
function glossary_print_author_menu($cm, $glossary,$mode, $hook, $sortkey = '', $sortorder = '') {
- if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
+ if ($glossary->showalphabet) {
echo '<center>' . get_string("explainalphabet","glossary") . '<br />';
}
function glossary_print_all_links($cm, $glossary, $mode, $hook) {
global $CFG;
- if ( $glossary->showall and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
+ if ( $glossary->showall) {
$strallentries = get_string("allentries", "glossary");
if ( $hook == 'ALL' ) {
echo "<b>$strallentries</b>";
function glossary_print_special_links($cm, $glossary, $mode, $hook) {
global $CFG;
- if ( $glossary->showspecial and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS ) {
+ if ( $glossary->showspecial) {
$strspecial = get_string("special", "glossary");
if ( $hook == 'SPECIAL' ) {
echo "<b>$strspecial</b> | ";
function glossary_print_alphabet_links($cm, $glossary, $mode, $hook, $sortkey, $sortorder) {
global $CFG;
- if ( $glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS ) {
+ if ( $glossary->showalphabet) {
$alphabet = explode(",", get_string("alphabet"));
$letters_by_line = 14;
for ($i = 0; $i < count($alphabet); $i++) {
}
function glossary_print_entry_ratings($course, $entry, $ratings = NULL) {
-global $USER;
+
+ global $USER;
+
$ratingsmenuused = false;
if (!empty($ratings) and !empty($USER->id)) {
$useratings = true;
}
function glossary_print_dynaentry($courseid, $entries, $displayformat = -1) {
- global $THEME, $USER;
+ global $THEME, $USER,$CFG;
$colour = $THEME->cellheading2;
}
//If displayformat is present, override glossary->displayformat
- if ($displayformat == -1) {
+ if ($displayformat < 0) {
$dp = $glossary->displayformat;
- } else {
+ } else {
$dp = $displayformat;
}
- // Hard-coded until the Display formats manager is done.
- if ( $dprecord = get_record("glossary_displayformats","fid", $dp) ) {
- if ( $dprecord->relatedview >= 0 ) {
- $dp = $dprecord->relatedview;
- }
+ //Get popupformatname
+ $format = get_record('glossary_formats','name',$dp);
+ $displayformat = $format->popupformatname;
+
+ //Check displayformat variable and set to default if necessary
+ if (!$displayformat) {
+ $displayformat = 'dictionary';
}
- glossary_print_entry($course, $cm, $glossary, $entry, "","",0,$dp);
+ $formatfile = $CFG->dirroot.'/mod/glossary/formats/'.$displayformat.'/'.$displayformat.'_format.php';
+ $functionname = 'glossary_show_entry_'.$displayformat;
+
+ if (file_exists($formatfile)) {
+ include_once($formatfile);
+ if (function_exists($functionname)) {
+ $functionname($course, $cm, $glossary, $entry,'','','','');
+ }
+ }
}
}
echo "</td>";
<?PHP // $Id$
+include_once($CFG->dirroot.'/mod/glossary/lib.php');
+
if (!isset($form->studentcanpost)) {
$form->studentcanpost = $CFG->glossary_studentspost;
}
$form->mainglossary = 0;
}
if (!isset($form->displayformat)) {
- $form->displayformat = 0;
+ $form->displayformat = 'dictionary';
}
if ( !isset($form->globalglossary) ) {
$form->globalglossary = 0;
<TD align=right><P><B><?php echo get_string("displayformat", "glossary") ?>:</B></P></TD>
<TD>
<?php
- $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
- $dp = get_record("glossary_displayformats","fid",$dir);
- if ( !$dp or $dp->visible ) {
- $formats[$dir] = get_string("displayformat$dir", "glossary");
- }
- }
- }
- }
- asort($formats);
- choose_from_menu ($formats, "displayformat", $form->displayformat, "");
-
-?>
-
- </select> <?php helpbutton("displayformat", get_string("displayformat", "glossary"), "glossary") ?>
+ //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,'');
+ ?>
+ <?php helpbutton("displayformat", get_string("displayformat", "glossary"), "glossary") ?>
</TD>
</TR>
<TR valign=top>
</TR>
<?php
//Only show rss parameters if rss is activated at site and glossary levels
- if ($CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds) {
+ if (isset($CFG->enablerssfeeds) && isset($CFG->glossary_enablerssfeeds) &&
+ $CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds) {
echo "<tr valign=top>";
echo "<td align=right><p><b>".get_string("rsstype").":</b></p></td>";
echo "<td>";
<?php // $Id$
+ global $CFG;
+
require_once("../../config.php");
require_once("lib.php");
optional_variable($sortkey,"UPDATE"); // Sorting key
optional_variable($sortorder,"asc"); // Sorting order
optional_variable($offset); // number of entries to bypass
+ optional_variable($displayformat,-1);
- print_header();
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
error("Course module is incorrect");
}
- global $CFG;
if ( !$entriesbypage = $glossary->entbypage ) {
$entriesbypage = $CFG->glossary_entbypage;
}
+ print_header(strip_tags("$course->shortname: $glossary->name"));
+
if ($CFG->forcelogin) {
require_login();
}
}
}
+/// 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') {
if ( $hook == 'SPECIAL' ) {
$alphabet = explode(",", get_string("alphabet"));
}
- $tableisopen = 0;
$site = get_record("course","id",1);
echo '<p align="right"><font size=-1>' . userdate(time()) . '</font></p>';
echo '<strong>' . $site->fullname . '</strong><br>';
- echo get_string("course") . ': <strong>' . $course->fullname . '</strong><br />';
+ echo get_string("course") . ': <strong>' . $course->fullname . ' ('. $course->shortname . ')</strong><br />';
echo get_string("modulename","glossary") . ': <strong>' . $glossary->name . '</strong><p>';
if ( $allentries ) {
foreach ($allentries as $entry) {
/// ok, if it's a valid entry.. Print it.
if ( $showentry ) {
- if ( !$tableisopen ) {
- echo '<table align="center" width="95%" bgcolor="#FFFFFF" style="border-style: solid; border-width: 1px;">';
- $tableisopen = 1;
- }
if ( $currentpivot != strtoupper($pivot) ) {
// print the group break if apply
if ( $printpivot ) {
$currentpivot = strtoupper($pivot);
- echo '<tr>';
$pivottoshow = $currentpivot;
if ( isset($entry->uid) ) {
- // printing the user icon if defined (only when browsing authors)
- echo '<td colspan="2" align="left" style="border-style: solid; border-width: 1px;">';
$user = get_record("user","id",$entry->uid);
$pivottoshow = fullname($user, isteacher($course->id));
- } else {
- echo '<td colspan="2" align="center" style="border-style: solid; border-width: 1px;">';
}
- echo "<strong><i>$pivottoshow</i></strong>" ;
- echo '</td>';
- echo '</tr>';
+ echo "<p align=\"center\"><strong><i>$pivottoshow</i></strong></p>" ;
}
}
- echo '<tr>';
- echo '<td width="25%" align="right" valign="top"><b>'. $entry->concept . ': </b></td>';
- echo '<td width="75%" style="border-style: solid; border-width: 1px;">';
+ echo '<b>'. strip_tags($entry->concept) . ': </b>';
+ $options->para = false;
+ $definition = format_text('<nolink>' . strip_tags($entry->definition) . '</nolink>', $entry->format,$options);
- if ( $entry->attachment) {
- glossary_print_entry_attachment($entry);
- }
- echo strip_tags($entry->definition);
+ echo ($definition);
- echo '<br><br></tr>';
+ echo '<br><br>';
}
}
}
- if ($tableisopen) {
- echo '</table>';
- }
- echo '<center><font size=-1>' . userdate(time()) . '</font></center>';
echo '</body></html>';
?>
}
}
+ //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);
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) {
"$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);
}
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 ) {
$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");
/// 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)
/// 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;
if ( $displayformat == -1 ) {
$displayformat = $glossary->displayformat;
}
- if ( $displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
- $mode = 'date';
- }
if ( $show ) {
$mode = 'term';
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;
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 '<table width="100%" border="0" cellpadding="3" cellspacing="0"><tr valign="top"><td align="right">';
$tooltiptext = get_string("rsssubscriberss","glossary",$glossary->name);
rss_print_link($course->id, $USER->id, "glossary", $glossary->id, $tooltiptext);
echo '<p align="center"><font size="3"><b>' . stripslashes_safe($glossary->name);
if ( $isuserframe and $mode != 'search') {
/// the "Print" icon
- echo " <a title =\"". get_string("printerfriendly","glossary") . "\" target=\"_blank\" href=\"print.php?id=$cm->id&mode=$mode&hook=$hook&sortkey=$sortkey&sortorder=$sortorder&offset=$offset\">";
+ echo " <a title =\"". get_string("printerfriendly","glossary") . "\" target=\"printview\" href=\"print.php?id=$cm->id&mode=$mode&hook=$hook&sortkey=$sortkey&sortorder=$sortorder&offset=$offset\">";
echo '<img border=0 src="print.gif"/></a>';
}
echo '</b></font></p>';
$currentpivot = '';
$ratingsmenuused = NULL;
$paging = NULL;
- $tableisopen = 0;
if ( $hook == 'SPECIAL' ) {
$alphabet = explode(",", get_string("alphabet"));
}
// print the group break if apply
if ( $printpivot ) {
- if ( $tableisopen ) {
- print_simple_box_end();
- $tableisopen = 0;
- }
$currentpivot = strtoupper($pivot);
echo '<p>';
echo "<strong> $pivottoshow</strong>" ;
echo '</td></tr></table>';
- 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;
$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('<center>' . get_string("noentries","glossary") . '</center>',"center","95%");