- Adding a display format manager. It controls the behavior of the display format when the user enter the glossary and when an auto-link is shown.
- Adding support to the new fullname function.
$string['cnflinkentry'] = 'Define if an entry should be automatically linked by default';
$string['cnflinkglossaries'] = 'Define if a glossary should be automatically linked by default';
$string['cnfstudentcanpost'] = 'Define if the students can or cannot post entries by default';
+$string['cnfrelatedview'] = 'Select the display format to be used for automatic linking and entry view.';
+$string['cnfdefaultmode'] = 'Select the default frame to show when the glossary is first viewed.';
+$string['cnfdefaulthook'] = 'Select the default selection to show when the glossary is first viewed';
+$string['cnfsortkey'] = 'Select the sorting key by default.';
+$string['cnfsortorder'] = 'Select the sorting order by default.';
+$string['cnfshowgroup'] = 'Specify if the group break should be shown or not.';
$string['comment'] = 'Comment';
$string['commentdeleted'] = 'The comment has been deleted.';
$string['comments'] = 'Comments';
$string['descending'] = '(descending)';
$string['destination'] = 'Destination';
$string['displayformat'] = 'Display format';
+$string['displayformats'] = 'Display formats';
$string['displayformat2'] = 'Full with author';
$string['displayformat3'] = 'Encyclopedia';
$string['displayformat4'] = 'FAQ';
* Default view
* Default Order
* 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
- Allow grading of entries
<?php print_string("cnffullmatch", "glossary") ?>
</td>
</tr>
+<tr valign=top>
+ <td colspan = 3 align=center><a name=formats><strong>Display Formats Setup</strong></td>
+</tr>
+<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);
+ }
+
+ $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");
+ }
+ }
+ }
+ asort($formats);
+
+ echo '<table cellpadding="5" bgcolor="#FFFFFF" class="generaltab" width="40%" align="center" style="border-style: solid; border-width: 1px;">';
+ 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>';
+ }
+ }
+ echo '</table>';
+
+?>
+
+ </td>
+</tr>
<tr>
<td colspan=3 align=center>
- <input type="submit" value="<?php print_string("savechanges") ?>"></td>
+ <input type="submit" value="<?php print_string("savechanges") ?>"></td>
</tr>
</table>
execute_sql( "ALTER TABLE `{$CFG->prefix}glossary`
ADD `entbypage` TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' AFTER `globalglossary`" );
+ }
+
+ if ( $oldversion < 2003111800 ) {
+ execute_sql("CREATE TABLE `{$CFG->prefix}glossary_displayformats` (
+ `id` INT(10) unsigned NOT NULL auto_increment,
+ `fid` INT(10) UNSIGNED NOT NULL default '0',
+ `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'");
+
+ // Default format
+ execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats
+ (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
+ VALUES (0,0,'letter','ALL','CREATION','asc',1,1)");
+ // Continuous format
+ execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats
+ (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
+ VALUES (1,1,'date','ALL','CREATION','asc',0,1)");
+ // Full w/author View
+ execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats
+ (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
+ VALUES (2,2,'letter','ALL','CREATION','asc',1,1)");
+ // Encyclopedia
+ execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats
+ (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
+ VALUES (3,3,'letter','ALL','CREATION','asc',1,1)");
+ // FAQ View
+ execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats
+ (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
+ VALUES (4,4,'date','ALL','CREATION','asc',0,1)");
+ // Full w/o author View
+ execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats
+ (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
+ VALUES (5,5,'letter','ALL','CREATION','asc',1,1)");
+ // Entry list
+ execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats
+ (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
+ VALUES (6,0,'letter','ALL','CREATION','asc',1,1)");
+
}
return true;
}
PRIMARY KEY (id)
) TYPE=MyISAM COMMENT='comments on glossary entries';
+CREATE TABLE prefix_glossary_displayformats (
+ id int(10) unsigned NOT NULL auto_increment,
+ fid int(10) unsigned NOT NULL default '0',
+ 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';
+
#
# Dumping data for table `log_display`
#
$GLOSSARY_CONCEPT_IS_ENTRY = 0;
$GLOSSARY_CONCEPT_IS_CATEGORY = 1;
-// $glossarieslist = get_records_select("glossary", "usedynalink != 0 and (course = $courseid or global != 0)","id");
$glossarieslist = get_records_select("glossary", "usedynalink != 0 and (course = $courseid or globalglossary != 0)","globalglossary, id");
if ( $glossarieslist ) {
$glossaries = "";
}
$entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink != 0 and approved != 0 and concept != ''","$ebylenght glossaryid","id,glossaryid,concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY category,fullmatch");
- $categories = get_records_select("glossary_categories", "glossaryid IN ($glossaries) AND usedynalink != 0", "$cbylenght glossaryid,id","id,glossaryid,name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 fullmatch");
+ $categories = get_records_select("glossary_categories", "glossaryid IN ($glossaries) AND usedynalink != 0", "$cbylenght glossaryid","id,glossaryid,name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 fullmatch");
if ( $entries and $categories ) {
$concepts = array_merge($entries, $categories);
usort($concepts,'glossary_sort_entries_by_lenght');
$lastglossary = 0;
$lastcategory = 0;
foreach ( $concepts as $concept ) {
- if ( $lastglossary != $concept->glossaryid ) {
- $glossary = get_record("glossary","id",$concept->glossaryid);
- $lastglossary = $glossary->id;
- }
if ( $concept->category ) {
if ( $lastcategory != $concept->id ) {
$category = get_record("glossary_categories","id",$concept->id);
$lastcategory = $concept->id;
+ if ( $cm->instance != $category->glossaryid ) {
+ $cm = get_coursemodule_from_instance("glossary", $category->glossaryid, $courseid);
+ }
}
- $cm = get_coursemodule_from_instance("glossary", $glossary->id, $courseid);
+
$title = strip_tags("$glossary->name: " . get_string("category","glossary"). " $category->name");
$href_tag_begin = "<a class=\"autolink\" title=\"$title\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&mode=cat&hook=$concept->id\">";
} else {
+ if ( $lastglossary != $concept->glossaryid ) {
+ $glossary = get_record("glossary","id",$concept->glossaryid);
+ $lastglossary = $glossary->id;
+ }
+
$concepttitle = urlencode($concept->concept);
$title = strip_tags("$glossary->name: $concepttitle");
$href_tag_begin = "<a target=\"entry\" class=\"autolink\" title=\"$title\" href=\"$CFG->wwwroot/mod/glossary/showentry.php?courseid=$courseid&concept=$concepttitle\" ".
$currentconcept = str_replace("*", "\*", $currentconcept);
if ( $currentconcept = trim(strip_tags($currentconcept)) ) {
if ( !$concept->category ) {
- if ( $aliases = get_records("glossary_alias","entryid",$concept->id) ) {
+ if ( $aliases = get_records("glossary_alias","entryid",$concept->id, "alias") ) {
foreach ($aliases as $alias) {
- $currentconcept .= "|" . trim(strip_tags(str_replace("|", "\|", $alias->alias)));
+ $currentalias = str_replace("|", "\|", $alias->alias);
+ $currentalias = str_replace("'", "\'", $currentalias);
+ $currentalias = str_replace("*", "\*", $currentalias);
+ $currentconcept .= "|" . trim($currentalias);
}
}
}
if ($list_of_words_cp{strlen($list_of_words_cp)-1}=="|") {
$list_of_words_cp{strlen($list_of_words_cp)-1}="";
}
+
$list_of_words_cp = trim($list_of_words_cp);
if ($fullmatch) {
$invalidprefixs = "([a-zA-Z0-9])";
} else {
$text = eregi_replace("$list_of_words_cp", "$href_tag_begin"."\\1"."$href_tag_end", $text);
}
- $text = str_replace(array_keys($final),$final,$text);
+
+ if ( $final ) {
+ $text = str_replace(array_keys($final),$final,$text);
+ }
if ( $links ) {
$text = str_replace(array_keys($links),$links,$text);
}
if ( $excludes ) {
$text = str_replace(array_keys($excludes),$excludes,$text);
}
- if ( $fullmatch ) {
- if ( isset($words) ) {
- if ($words) {
- $text = str_replace(array_keys($words),$words,$text);
- }
+ if ( $fullmatch and isset($words) ) {
+ if ($words) {
+ $text = str_replace(array_keys($words),$words,$text);
}
}
return $text;
$newentry->casesensitive = $form->casesensitive;
$newentry->fullmatch = $form->fullmatch;
$newentry->timemodified = $timenow;
+ $newentry->approved = $glossary->defaultapproval or isteacher($course->id);
if ($form->concept == '' or trim($form->text) == '' ) {
$errors = get_string('fillfields','glossary');
if (! update_record("glossary_entries", $newentry)) {
error("Could not update your glossary");
} else {
- add_to_log($course->id, "glossary", "update entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", "$newentry->id");
+ add_to_log($course->id, "glossary", "update entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", $newentry->id);
}
} else {
error("Could not update this glossary entry because this concept already exist.");
$newentry->userid = $USER->id;
$newentry->timecreated = $timenow;
$newentry->sourceglossaryid = 0;
- $newentry->approved = $glossary->defaultapproval or isteacher($course->id);
$newentry->teacherentry = isteacher($course->id);
$permissiongranted = 1;
unset($newentry->attachment);
}
set_field("glossary_entries", "attachment", $newfilename, "id", $newentry->id);
- add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", "$newentry->id");
+ add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", $newentry->id);
}
} else {
error("Could not insert this glossary entry because this concept already exist.");
--- /dev/null
+<?PHP
+ /// This file allows to manage the default behave of the display formats
+
+ require_once("../../config.php");
+ require_once("lib.php");
+ global $CFG, $THEME;
+
+ require_variable($id);
+ optional_variable($mode);
+
+ require_login();
+ if ( !isadmin() ) {
+ error("You must be an admin to use this page.");
+ }
+ if (!$site = get_site()) {
+ 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);
+ }
+
+ $form = data_submitted();
+ if ( $mode == 'visible' ) {
+ if ( $displayformat ) {
+ if ( $displayformat->visible ) {
+ $displayformat->visible = 0;
+ } else {
+ $displayformat->visible = 1;
+ }
+ update_record("glossary_displayformats",$displayformat);
+ }
+ redirect($_SERVER["HTTP_REFERER"]);
+ die;
+ } elseif ( $mode == 'edit' and $form) {
+
+ $displayformat->relatedview = $form->relatedview;
+ $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);
+ redirect("../../admin/module.php?module=glossary#formats");
+ die;
+ }
+
+ $stradmin = get_string("administration");
+ $strconfiguration = get_string("configuration");
+ $strmanagemodules = get_string("managemodules");
+ $strmodulename = get_string("modulename", "glossary");
+ $strdisplayformats = get_string("displayformats","glossary");
+
+ print_header("$site->shortname: $strmodulename: $strconfiguration", $site->fullname,
+ "<a href=\"../../admin/index.php\">$stradmin</a> -> ".
+ "<a href=\"../../admin/configure.php\">$strconfiguration</a> -> ".
+ "<a href=\"../../admin/modules.php\">$strmanagemodules</a> -> <a href=\"../../admin/module.php?module=glossary\">$strmodulename</a> -> $strdisplayformats");
+
+ print_heading($strmodulename . ': ' . get_string("displayformats","glossary"));
+
+ echo '<table width="90%" align="center" bgcolor="#FFFFFF" class="generaltab" style="border-color: #000000; border-style: solid; border-width: 1px;">';
+ echo '<tr><td align=center>';
+ echo get_string("configwarning");
+ echo '</td></tr></table>';
+
+ $yes = get_string("yes");
+ $no = get_string("no");
+
+ echo '<form method="post" action="formats.php" name="form">';
+ echo '<table width="90%" align="center" bgcolor="' . $THEME->cellheading . '" class="generalbox">';
+ ?>
+ <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;
+ }
+ ?>
+ </strong></td>
+ </tr>
+ <tr valign=top>
+ <td align="right" width="20%">
+ <p>Related Display Format:</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";
+ }
+ ?>
+ </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>
+ <SELECT size=1 name=defaultmode>
+ <?php
+ $sletter = '';
+ $scat = '';
+ $sauthor = '';
+ $sdate = '';
+ switch ( strtolower($displayformat->defaultmode) ) {
+ case 'letter':
+ $sletter = ' SELECTED ';
+ break;
+
+ case 'cat':
+ $scat = ' SELECTED ';
+ break;
+
+ case 'date':
+ $sdate = ' SELECTED ';
+ break;
+
+ case 'author':
+ $sauthor = ' SELECTED ';
+ break;
+ }
+ ?>
+ <OPTION value="letter" <?PHP p($sletter)?>>letter</OPTION>
+ <OPTION value="cat" <?PHP p($scat)?>>cat</OPTION>
+ <OPTION value="date" <?PHP p($sdate)?>>date</OPTION>
+ <OPTION value="author" <?PHP p($sauthor)?>>author</OPTION>
+ </SELECT>
+ </td>
+ <td width="60%">
+ <?php print_string("cnfdefaultmode", "glossary") ?><br \><br \>
+ </td>
+ </tr>
+ <tr valign=top>
+ <td align="right" width="20%"><p>Default Hook:</td>
+ <td>
+ <SELECT size=1 name=defaulthook>
+ <?php
+ $sall = '';
+ $sspecial = '';
+ $sallcategories = '';
+ $snocategorised = '';
+ switch ( strtolower($displayformat->defaulthook) ) {
+ case 'all':
+ $sall = ' SELECTED ';
+ break;
+
+ case 'special':
+ $sspecial = ' SELECTED ';
+ break;
+
+ case '0':
+ $sallcategories = ' SELECTED ';
+ break;
+
+ case '-1':
+ $snocategorised = ' SELECTED ';
+ break;
+ }
+ ?>
+ <OPTION value="ALL" <?PHP p($sall)?>><?PHP p(get_string("allentries","glossary"))?></OPTION>
+ <OPTION value="SPECIAL" <?PHP p($sspecial)?>><?PHP p(get_string("special","glossary"))?></OPTION>
+ <OPTION value="0" <?PHP p($sallcategories)?>><?PHP p(get_string("allcategories","glossary"))?></OPTION>
+ <OPTION value="-1" <?PHP p($snocategorised)?>><?PHP p(get_string("notcategorised","glossary"))?></OPTION>
+ </SELECT>
+ </td>
+ <td width="60%">
+ <?php print_string("cnfdefaulthook", "glossary") ?><br \><br \>
+ </td>
+ </tr>
+ <tr valign=top>
+ <td align="right" width="20%"><p>Default Sort Key:</td>
+ <td>
+ <SELECT size=1 name=sortkey>
+ <?php
+ $sfname = '';
+ $slname = '';
+ $supdate = '';
+ $screation = '';
+ switch ( strtolower($displayformat->sortkey) ) {
+ case 'firstname':
+ $sfname = ' SELECTED ';
+ break;
+
+ case 'lastname':
+ $slname = ' SELECTED ';
+ break;
+
+ case 'creation':
+ $screation = ' SELECTED ';
+ break;
+
+ case 'update':
+ $supdate = ' SELECTED ';
+ break;
+ }
+ ?>
+ <OPTION value="CREATION" <?PHP p($screation)?>><?PHP p(get_string("sortbycreation","glossary"))?></OPTION>
+ <OPTION value="UPDATE" <?PHP p($supdate)?>><?PHP p(get_string("sortbylastupdate","glossary"))?></OPTION>
+ <OPTION value="FIRSTNAME" <?PHP p($sfname)?>><?PHP p(get_string("firstname"))?></OPTION>
+ <OPTION value="LASTNAME" <?PHP p($slname)?>><?PHP p(get_string("lastname"))?></OPTION>
+ </SELECT>
+ </td>
+ <td width="60%">
+ <?php print_string("cnfsortkey", "glossary") ?><br \><br \>
+ </td>
+ </tr>
+ <tr valign=top>
+ <td align="right" width="20%"><p>Default Sort Order:</td>
+ <td>
+ <SELECT size=1 name=sortorder>
+ <?php
+ $sasc = '';
+ $sdesc = '';
+ switch ( strtolower($displayformat->sortorder) ) {
+ case 'asc':
+ $sasc = ' SELECTED ';
+ break;
+
+ case 'desc':
+ $sdesc = ' SELECTED ';
+ break;
+ }
+ ?>
+ <OPTION value="asc" <?PHP p($sasc)?>><?PHP p(get_string("ascending","glossary"))?></OPTION>
+ <OPTION value="desc" <?PHP p($sdesc)?>><?PHP p(get_string("descending","glossary"))?></OPTION>
+ </SELECT>
+ </td>
+ <td width="60%">
+ <?php print_string("cnfsortorder", "glossary") ?><br \><br \>
+ </td>
+ </tr>
+ <tr valign=top>
+ <td align="right" width="20%"><p>Include Group Breaks:</td>
+ <td>
+ <SELECT size=1 name=showgroup>
+ <?php
+ $yselected = "";
+ $nselected = "";
+ if ($displayformat->showgroup) {
+ $yselected = " SELECTED ";
+ } else {
+ $nselected = " SELECTED ";
+ }
+ ?>
+ <OPTION value=1 <?php p($yselected) ?>><?php p($yes)?></OPTION>
+ <OPTION value=0 <?php p($nselected) ?>><?php p($no)?></OPTION>
+ </SELECT>
+ </td>
+ <td width="60%">
+ <?php print_string("cnfshowgroup", "glossary") ?><br \><br \>
+ </td>
+ </tr>
+ <tr>
+ <td colspan=3 align=center>
+ <input type="submit" value="<?php print_string("savechanges") ?>"></td>
+ </tr>
+ <input type="hidden" name=id value="<?php p($id) ?>">
+ <input type="hidden" name=mode value="edit">
+ <?PHP
+
+ print_simple_box_end();
+ echo '</form>';
+
+ print_footer();
+?>
glossary_print_entry_concept($entry);
echo "</b><br />";
- echo "<font size=\"2\">$strby $user->firstname $user->lastname</font>";
+ 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 "<b>";
glossary_print_entry_concept($entry);
echo "</b><br />";
- echo "<font size=\"2\">$strby $user->firstname $user->lastname</font>";
+ 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 "<td width=100% bgcolor=\"$colour\">";
if ($entry) {
- echo "<b><a href=\"view.php?id=$cm->id&mode=entry&hook=$entry->id&displayformat=2\">";
+ echo "<b><a href=\"view.php?id=$cm->id&mode=entry&hook=$entry->id\">";
glossary_print_entry_concept($entry);
echo '</a></b> ';
$currentcolor = $tabcolor;
$currentstyle = 'generaltab';
}
- echo "<td class=\"$currentstyle\" width=\"$tabwidth%\" bgcolor=\"$currentcolor\" align=\"center\"><b>";
+ echo "<td class=\"$currentstyle\" width=\"$tabwidth%\" bgcolor=\"$currentcolor\" align=\"center\" style=\"border-color: #000000; border-style: solid; border-width: 1px;\"><b>";
if ($tabproccessed != $currenttab and $data[$tabproccessed]->link) {
echo "<a href=\"" . $data[$tabproccessed]->link . "\">";
}
$currentcolor = $tabcolor;
$currentstyle = 'generaltab';
}
- echo "<td class=\"$currentstyle\" width=\"$tabwidth%\" bgcolor=\"$currentcolor\" align=\"center\"><b>";
+ echo "<td class=\"$currentstyle\" width=\"$tabwidth%\" bgcolor=\"$currentcolor\" align=\"center\" style=\"border-color: #000000; border-style: solid; border-width: 1px;\"><b>";
if ($tabproccessed != $currenttab and $data[$tabproccessed]->link) {
echo "<a href=\"" . $data[$tabproccessed]->link . "\">";
}
}
$dp = $displayformat;
// Hard-coded until the Display formats manager is done.
- if ( $dp == -1 and $glossary->displayformat == 6 ) {
- $dp = 2;
+ if ( $dprecord = get_record("glossary_displayformats","fid", $glossary->displayformat) ) {
+ if ( $dprecord->relatedview >= 0 ) {
+ $dp = $dprecord->relatedview;
+ }
}
glossary_print_entry($course, $cm, $glossary, $entry, "","",0,$dp);
}
if ( $pos = strpos($dir, ".") ) {
$dir = substr($dir, 0, $pos );
if ($dir != 0 and $dir != 1) { // excluding basic formats
- $formats[$dir] = get_string("displayformat$dir", "glossary");
+ $dp = get_record("glossary_displayformats","fid",$dir);
+ if ( !$dp or $dp->visible ) {
+ $formats[$dir] = get_string("displayformat$dir", "glossary");
+ }
}
}
}
break;
}
+ switch ( $sortkey ) {
+ case "CREATION":
+ $sortkey = "timecreated";
+ break;
+
+ case "UPDATE":
+ $sortkey = "timemodified";
+ default:
+ break;
+ }
+
include_once("sql.php");
$entriesshown = 0;
echo '<strong>' . $site->fullname . '</strong><br>';
echo get_string("course") . ': <strong>' . $course->fullname . '</strong><br \>';
echo get_string("modulename","glossary") . ': <strong>' . $glossary->name . '</strong><p>';
+ if ( $allentries ) {
+ foreach ($allentries as $entry) {
+ /// Setting the pivot for the current entry
+ $pivot = $entry->pivot;
+ if ( !$fullpivot ) {
+ $pivot = $pivot[0];
+ }
+
+ ///
+ /// Validating special cases not covered by the SQL statement
+ ///
- foreach ($allentries as $entry) {
- /// Setting the pivot for the current entry
- $pivot = $entry->pivot;
- if ( !$fullpivot ) {
- $pivot = $pivot[0];
- }
-
- ///
- /// Validating special cases not covered by the SQL statement
- ///
-
- /// if we're browsing by alphabet and the current concept does not begin with
- /// the letter we are look for.
- $showentry = 1;
- if ( $mode == 'letter' and $hook != 'SPECIAL' and $hook != 'ALL' ) {
- if ( substr($entry->concept, 0, strlen($hook)) != $hook ) {
- $showentry = 0;
- }
- }
-
- /// if we're browsing for letter, looking for special characters not covered
- /// in the alphabet
- if ( $showentry and $hook == 'SPECIAL' ) {
- $initial = $entry->concept[0];
- for ($i = 0; $i < count($alphabet); $i++) {
- $curletter = $alphabet[$i];
- if ( $curletter == $initial ) {
-
+ /// if we're browsing by alphabet and the current concept does not begin with
+ /// the letter we are look for.
+ $showentry = 1;
+ if ( $mode == 'letter' and $hook != 'SPECIAL' and $hook != 'ALL' ) {
+ if ( substr($entry->concept, 0, strlen($hook)) != $hook ) {
$showentry = 0;
- break;
}
- }
- }
-
- /// if we're browsing categories, looking for entries not categorised.
- if ( $showentry and $mode == 'cat' and $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
- if ( record_exists("glossary_entries_categories", "entryid", $entry->id)) {
- $showentry = 0;
}
- }
-
- /// if the entry is not approved, deal with it based on the current view and
- /// user.
- if ( $showentry and $mode != 'approval' ) {
- if ( !$entry->approved and isteacher($course->id, $entry->userid) ) {
- $showentry = 0;
- }
- }
-
- /// ok, if it's a valid entry.. Print it.
- if ( $showentry ) {
-
- if ( $currentpivot != strtoupper($pivot) ) {
-
- // print the group break if apply
- if ( $printpivot ) {
- $currentpivot = strtoupper($pivot);
- if ( !$tableisopen ) {
- echo '<table align="center" width="95%" bgcolor="#FFFFFF" style="border-style: solid; border-width: 1px;">';
- $tableisopen = 1;
- }
-
- 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;">';
- $pivottoshow = $entry->uname;
- } else {
- echo '<td colspan="2" align="center" style="border-style: solid; border-width: 1px;">';
+
+ /// if we're browsing for letter, looking for special characters not covered
+ /// in the alphabet
+ if ( $showentry and $hook == 'SPECIAL' ) {
+ $initial = $entry->concept[0];
+ for ($i = 0; $i < count($alphabet); $i++) {
+ $curletter = $alphabet[$i];
+ if ( $curletter == $initial ) {
+
+ $showentry = 0;
+ break;
}
-
- echo "<strong><i>$pivottoshow</i></strong>" ;
- echo '</td>';
- echo '</tr>';
}
+ }
+
+ /// if we're browsing categories, looking for entries not categorised.
+ if ( $showentry and $mode == 'cat' and $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
+ if ( record_exists("glossary_entries_categories", "entryid", $entry->id)) {
+ $showentry = 0;
+ }
}
-
- 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;">';
- if ( $entry->attachment) {
- glossary_print_entry_attachment($entry);
+ /// if the entry is not approved, deal with it based on the current view and
+ /// user.
+ if ( $showentry and $mode != 'approval' ) {
+ if ( !$entry->approved and isteacher($course->id, $entry->userid) ) {
+ $showentry = 0;
+ }
}
- echo strip_tags($entry->definition);
- echo '<br><br></tr>';
+ /// 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 '<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;">';
+
+ if ( $entry->attachment) {
+ glossary_print_entry_attachment($entry);
+ }
+ echo strip_tags($entry->definition);
+
+ echo '<br><br></tr>';
+ }
}
}
if ($tableisopen) {
/// fullpivot indicate if the whole pivot should be compared agasint the db or just the first letter
/// printpivot indicate if the pivot should be printed or not
$fullpivot = 1;
- $printpivot = 1;
$userid = '';
if ( $USER->id ) {
$where = "AND substr(ucase($usernamefield),1," . strlen($hook) . ") = '" . strtoupper($hook) . "'";
break;
case 'mysql':
- $usernametoshow = "CONCAT(CONCAT(u.firstname,' '), u.lastname)";
if ( $sortkey == 'FIRSTNAME' ) {
$usernamefield = "CONCAT(CONCAT(u.firstname,' '), u.lastname)";
} else {
$where = '';
}
- $sqlselect = "SELECT ge.id, $usernamefield pivot, $usernametoshow uname, u.id uid, ge.*";
+ $sqlselect = "SELECT ge.id, $usernamefield pivot, u.id uid, ge.*";
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}user u";
$sqlwhere = "WHERE ge.userid = u.id AND
(ge.approved != 0 $userid)
$where = 'AND substr(ucase(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\'';
break;
case 'mysql':
- $where = 'AND left(ucase(concept),' . strlen($hook) . ") = '$hook'";
+ $where = 'AND left(ucase(concept),' . strlen($hook) . ") = '" . strtoupper($hook) . "'";
break;
}
}
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2003111500; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2003111800; // The current module version (Date: YYYYMMDDXX)
$module->cron = 0; // Period for cron to check this module (secs)
$release = "0.5 development"; // User-friendly version number
}
} else {
$printpivot = 1;
+ if ( $mode == '' and $hook == '' and $show == '') {
+ $mode = 'letter';
+ $hook = 'ALL';
+ }
}
if ( $displayformat == -1 ) {