- Added a "All categories" link to the category drop-down box in Category view.
- Better display of categorized entries (more organized).
- SelectLetter, Special and All captions are now properly showed when some of the their flags are not set.
- Properly use of course module visibility (in case someone directly access the URL)
$string['displayformatdefault'] = "Simple, dictionary style";
$string['displayformat1'] = "Full without author.";
$string['displayformat2'] = "Full with author.";
+$string['editentry'] = "Edit entry";
+$string['editcategories'] = "Edit categories";
$string['entries'] = "Entries";
$string['entrieswithoutcategory'] = "Entries without category";
$string['entry'] = "Entry";
-$string['editentry'] = "Edit entry";
-$string['editcategories'] = "Edit categories";
-$string['entryalreadyexist'] = "Entry already exist.";
+$string['entryalreadyexist'] = "Entry already exists.";
$string['entrydeleted'] = "Entry deleted.";
$string['entryexported'] = "Entry succesfully exported.";
+$string['explainspecial'] = "<b>Special</b> will show all concepts that do not begin with a letter.<br>";
+$string['explainalphabet'] = "Select the letter you want to look for.<p>";
+$string['explainall'] = "<b>ALL</b> will show all entries in one page.";
$string['exporttomainglossary'] = "Export to main glossary";
$string['glossarytype'] = "Glossary Type";
$string['mainglossary'] = "Main glossary";
$string['modulename'] = "Glossary";
$string['modulenameplural'] = "Glossaries";
$string['newglossaryentries'] = "New glossary entries:";
-$string['nocategorized'] = "No categorized";
+$string['nocategorized'] = "Not categorized";
$string['noentries'] = "No entries found in this section";
$string['noentry'] = "No entry found.";
$string['searchconcept'] = "Search:";
$string['searchindefinition'] = "Search in concept AND definitions?";
-$string['secundaryglossary'] = "Secundary glossary";
-$string['selectletter'] = "Select the letter you want to look for.<p><b>Special</b> will show all concepts that does not begin with a letter.<br><b>ALL</b> will show all entries in one page.";
+$string['secundaryglossary'] = "Secondary glossary";
$string['showspecial'] = "Show 'Special' link";
$string['showalphabet'] = "Show alphabet";
$string['showall'] = "Show 'ALL' link";
$string['writtenby'] = "By";
?>
-
-<P ALIGN=CENTER><B>Allow duplicated entries</B></P>\r
-\r
-<P>You can specify if the system should or should not accept duplicated entries in the current glossary.\r
-\r
+<P ALIGN=CENTER><B>Allow duplicated entries</B></P>
+
+<P>You can specify if the system should or should not accept duplicated entries in the current glossary.
+
-<P ALIGN=CENTER><B>Display format</B></P>\r
-\r
-<P>The system has three builed-in formats to display entries. You can create your own format if you want.\r
-<p>The default view, is quite simple. It looks like a conventional dictionary.\r
-<p>The second view, shows the entry in a forum-like format, without the author's data.\r
-<p>And the third one, shows the entry also in a forum-like format but with the author's data.\r
-<hr>\r
-<p>If you want to create your own format, you should create a .PHP file and give it a number as its name. See into mod/glossary/formats which should be the next number.\r
-<p>Then, create a funcion called <b>glossary_print_entry_by_format($course, $cm, $glossary, $entry)</b> and dump all your creativity.\r
-<p>The last stemp is to insert a new entry in every language lack you use called <b>displayformat[number]</b>, and give it a meaninful description.
\ No newline at end of file
+<P ALIGN=CENTER><B>Display format</B></P>
+
+<P>The system has three built-in formats to display entries. You can create your own format if you want.
+<p>The default view is quite simple. It looks like a conventional dictionary.
+<p>The second view shows the entry in a forum-like format, without the author's data.
+<p>And the third one shows the entry also in a forum-like format but with the author's data.
+<hr>
+<p>If you want to create your own format, you should create a .PHP file and give it a number as its name. See into mod/glossary/formats which should be the next number.
+<p>Then, create a funcion called <b>glossary_print_entry_by_format($course, $cm, $glossary, $entry)</b> and dump all your creativity.
+<p>The last stemp is to insert a new entry in every language pack you use called <b>displayformat[number]</b>, and give it a meaningful description.
-<p>Glossary</p>\r
-\r
-<ul>\r
-\r
- <li><a href="help.php?module=glossary&file=studentcanpost.html">Students can post entries</a>\r
-\r
- <li><a href="help.php?module=glossary&file=allowduplicatedentries.html">Allow duplicated entries</a>\r
-\r
- <li><a href="help.php?module=glossary&file=displayformat.html">Display formats</a>\r
-\r
- <li><a href="help.php?module=glossary&file=mainglossary.html">Defining the main glossary of the course</a>\r
-\r
-\r
-</ul>\r
-\r
+<p>Glossary</p>
+
+<ul>
+
+ <li><a href="help.php?module=glossary&file=studentcanpost.html">Students can post entries</a>
+
+ <li><a href="help.php?module=glossary&file=allowduplicatedentries.html">Allow duplicated entries</a>
+
+ <li><a href="help.php?module=glossary&file=displayformat.html">Display formats</a>
+
+ <li><a href="help.php?module=glossary&file=mainglossary.html">Defining the main glossary of the course</a>
+
+
+</ul>
+
-<P ALIGN=CENTER><B>Defining the main glossary of the course</B></P>\r
-\r
-<P>The system allows to export entries from any secondary glossary to the main one of the course.\r
-<p>In order to do this, you should specify which glossary is the main one.\r
-<p>Note: You can have only one glossary by course.
\ No newline at end of file
+<P ALIGN=CENTER><B>Defining the main glossary of the course</B></P>
+
+<P>The system allows to export entries from any secondary glossary to the main one of the course.
+<p>In order to do this, you should specify which glossary is the main one.
+<p>Note: You can have only one main glossary per course.
-<P><IMG VALIGN=absmiddle SRC="<?php echo $CFG->wwwroot?>/mod/glossary/icon.gif"> <B>Glossary</B></P>\r
-<UL>\r
-<P>This resource allows to create and maintain a dictionary or a list of definitions.<br />\r
-The entries could be created by teachers or by students and can the show in different formats.<br />\r
-You can search terms. The glossary also allows to export entries from one glossary to other (the main one) within the same course.\r
-</UL>\r
+<P><IMG VALIGN=absmiddle SRC="<?php echo $CFG->wwwroot?>/mod/glossary/icon.gif"> <B>Glossary</B></P>
+<UL>
+<P>This resource allows to create and maintain a dictionary or a list of definitions.<br />
+The entries could be created by teachers or by students and can be shown in different formats.<br />
+You can search for terms. The glossary also allows to export entries from one glossary to another (the main one) within the same course.
+</UL>
\ No newline at end of file
-<P ALIGN=CENTER><B>Students can post entries</B></P>\r
-\r
-<P>You can specify if an user can or cannot add, edit or delete his/her own entries in this glossary.\r
-<p><b>Note:</b> A teacher could edit or delete any entry at any time.
\ No newline at end of file
+<P ALIGN=CENTER><B>Students can post entries</B></P>
+
+<P>You can specify whether a user can or cannot add, edit or delete his/her own entries in this glossary.
+<p><b>Note:</b> A teacher can edit or delete any entry at any time.
\ No newline at end of file
$string['entryalreadyexist'] = "Esta entrada ya existe.";
$string['entrydeleted'] = "Entrada borrada.";
$string['entryexported'] = "Entrada exportada con éxito.";
+$string['explainspecial'] = "<b>Especial</b> mostrará todos los conceptos que comiencen con símbolos.<br>";
+$string['explainalphabet'] = "Seleccione la letra que desea buscar.<p>";
+$string['explainall'] = "<b>TODAS</b> mostrará todas las entradas en una página.";
$string['exporttomainglossary'] = "Exportar todo el glosario";
$string['glossarytype'] = "Tipo de glosario";
$string['mainglossary'] = "Glosario principal";
$string['searchconcept'] = "Buscar:";
$string['searchindefinition'] = "¿Buscar en conceptos Y definiciones?";
$string['secundaryglossary'] = "Glosario secundario";
-$string['selectletter'] = "Seleccione la letra que desea buscar.<p><b>Especial</b> mostrará todos los conceptos que comiencen con símbolos.<br><b>TODAS</b> mostrará todas las entradas en una página.";
$string['showspecial'] = "Mostrar enlace 'Especial'";
$string['showalphabet'] = "Mostrar alfabeto";
$string['showall'] = "Mostrar enlace 'TODAS'";
if ( $oldversion < 2003092102 ) {
execute_sql("ALTER TABLE `{$CFG->prefix}glossary_entries_categories` DROP PRIMARY KEY ");
- execute_sql("ALTER TABLE `{$CFG->prefix}glossary_entries_categories` ADD `ID` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
+ execute_sql("ALTER TABLE `{$CFG->prefix}glossary_entries_categories` ADD `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
}
return true;
<td>
<?
$categories = get_records("glossary_categories","glossaryid",$glossary->id);
- echo "<select size=\"";
- if ( count($categories) > 7 ) {
- echo 7;
- }else {
- echo count($categories);
- }
- echo "\" name=\"categories[]\" multiple=\"yes\">";
+ echo "<select size=\"6\" name=\"categories[]\" multiple=\"yes\">";
+ echo "<option value=0>" . get_string("nocategorized","glossary") . "</optioon>";
foreach ( $categories as $category ) {
echo " <option ";
$PermissionGranted = 1;
if ( !$glossary->allowduplicatedentries ) {
- $dupentries = get_records("glossary_entries","UCASE(concept)", strtoupper($newentry->concept));
- if ($dupentries) {
+ $dupentries = get_records("glossary_entries","UCASE(concept)", strtoupper($newentry->concept));
+ if ($dupentries) {
foreach ($dupentries as $curentry) {
- if ( $curentry->id != $entry) {
- $PermissionGranted = 0;
+ if ( $glossary->id == $curentry->glossaryid ) {
+ if ( $curentry->id != $entry ) {
+ $PermissionGranted = 0;
+ }
}
}
- }
+ }
}
if ( $PermissionGranted ) {
$newentry->attachment = $_FILES["attachment"];
unset($newentry->attachment);
}
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&eid=$newentry->id", "$newentry->id");
- }
+ error("Could not update your glossary");
+ } else {
+ add_to_log($course->id, "glossary", "update entry", "view.php?id=$cm->id&eid=$newentry->id", "$newentry->id");
+ }
} else {
- error("Could not update this glossary entry because this concept already exist.");
+ error("Could not update this glossary entry because this concept already exist.");
}
} else {
$newentry->userid = $USER->id;
if ( $categories ) {
$newcategory->entryid = $newentry->id;
foreach ($categories as $category) {
- $newcategory->categoryid =$category;
- insert_record("glossary_entries_categories",$newcategory);
+ if ( $category > 0 ) {
+ $newcategory->categoryid =$category;
+ insert_record("glossary_entries_categories",$newcategory);
+ }
}
}
- redirect("view.php?id=$cm->id&eid=$newentry->id¤tview=$currentview&cat=$cat");
+ redirect("view.php?id=$cm->id&eid=$newentry->id");
die;
}
}
}
function glossary_print_entry($course, $cm, $glossary, $entry,$currentview="",$cat="") {
- global $THEME, $USET, $CFG;
+ global $THEME, $USER, $CFG;
$PermissionGranted = 0;
$formatfile = "$CFG->dirroot/mod/glossary/formats/$glossary->displayformat.php";
} else {
$CurrentColor = $TabColor;
}
- ?>
- <td width="<? p($TabWidth) ?>%" bgcolor="<? p($CurrentColor) ?>" align="center">
- <b><a href="<? p($data[$TabProccessed]->link) ?>"><? p($data[$TabProccessed]->caption) ?></a></b></td>
- <? if ($col < $TabsPerRow) { ?>
- <td width="<? p($TabSeparation) ?>" align="center"> </td>
- <? }
+
+ echo "<td width=\"$TabWidth%\" bgcolor=\"$CurrentColor\" align=\"center\"><b>";
+ if ($TabProccessed != $CurrentTab) {
+ echo "<a href=\"" . $data[$TabProccessed]->link . "\">";
+ }
+ echo $data[$TabProccessed]->caption;
+ if ($TabProccessed != $CurrentTab) {
+ echo "</a>";
+ }
+ echo "</b></td>";
+
+ if ( $col < $TabsPerRow ) {
+ echo "<td width=\"$TabSeparation\" align=\"center\"> </td>";
+ }
} else {
$CurrentColor = "";
}
} else {
$CurrentColor = $TabColor;
}
- ?>
- <td width="<? p($TabWidth) ?>%" bgcolor="<? p($CurrentColor) ?>" align="center">
- <b><a href="<? p($data[$TabProccessed]->link) ?>"><? p($data[$TabProccessed]->caption) ?></a></b></td>
- <? if ($col < $TabsPerRow) { ?>
- <td width="<? p($TabSeparation) ?>" align="center"> </td>
- <? }
+ echo "<td width=\"$TabWidth%\" bgcolor=\"$CurrentColor\" align=\"center\"><b>";
+ if ($TabProccessed != $CurrentTab) {
+ echo "<a href=\"" . $data[$TabProccessed]->link . "\">";
+ }
+ echo $data[$TabProccessed]->caption;
+ if ($TabProccessed != $CurrentTab) {
+ echo "</a>";
+ }
+ echo "</b></td>";
+
+ if ($col < $TabsPerRow) {
+ echo "<td width=\"$TabSeparation\" align=\"center\"> </td>";
+ }
} else {
if ($NumRows > 1) {
$CurrentColor = $TabColor;
$strspecial = get_string("special", "glossary");
$strallentries = get_string("allentries", "glossary");
- echo "<CENTER>$strselectletter";
+ if ($glossary->showalphabet) {
+ $output .= get_string("explainalphabet","glossary");
+ }
+ if ($glossary->showspecial) {
+ $output .= get_string("explainspecial","glossary");
+ }
+ if ($glossary->showall) {
+ $output .= get_string("explainall","glossary");
+ }
+
+ echo "<CENTER>$output<p>";
if ( $glossary->showspecial ) {
if ( $l == "SPECIAL" ) {
- echo "<p><b>$strspecial</b> | ";
+ echo "<b>$strspecial</b> | ";
} else {
- echo "<p><a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=SPECIAL\">$strspecial</a> | ";
+ echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=SPECIAL\">$strspecial</a> | ";
}
}
}
}
}
-function glossary_print_categories_menu($course, $cm, $glossary, $category) {
+function glossary_print_categories_menu($course, $cm, $glossary, $cat, $category) {
global $CFG, $THEME;
echo "<table border=0 width=100%>";
echo "<tr>";
if ( $category ) {
echo $category->name;
} else {
- echo get_string("entrieswithoutcategory","glossary");
+ if ( $cat < 0 ) {
+ echo get_string("entrieswithoutcategory","glossary");
+ $selected = "-1";
+ } elseif ( $cat == 0 ) {
+ echo get_string("allcategories","glossary");
+ $selected = "0";
+ }
}
echo "</b></td>";
echo "<td align=center width=20%>";
- $menu[0] = get_string("nocategorized","glossary");
+ $menu["0"] = get_string("allcategories","glossary");
+ $menu["-1"] = get_string("nocategorized","glossary");
+// $menu[""] = "-----------------------------------------";
$categories = get_records("glossary_categories", "glossaryid", $glossary->id, "name ASC");
if ( $categories ) {
}
}
- echo popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id¤tview=categories&cat=", $menu, "catmenu", $selected, get_string("jumpto"),
+ echo popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id¤tview=categories&cat=", $menu, "catmenu", $selected, "",
"", "", false);
echo "</td>";
}
require_login($course->id);
- if ( !$course->visible ) {
+ if (!$cm->visible and !isteacher($course->id)) {
notice(get_string("activityiscurrentlyhidden"));
}
$l = "";
$currentview = strtolower($currentview);
if ( $currentview ) {
- if ( $cat ) {
+ if ( $cat > 0 ) {
$category = get_record("glossary_categories","id",$cat);
- }
- if ( !$category ) {
- $cat = "";
+ if ( !$category ) {
+ $cat = "";
+ }
}
}
}
</form>
<?
echo "</td><td valign=top align=right width=50%>";
- if (isteacher($course->id) or $glossary->studentcanpost) {
+ if (isteacher($course->id) or ($glossary->studentcanpost) and !isguest($course->id)) {
$options = array ("id" => "$cm->id");
print_single_button("edit.php", $options, $straddentry );
}
print_tabbed_table_start($data, $CurrentTab, $tCFG);
echo "<center>";
if ( $currentview ) {
- glossary_print_categories_menu($course, $cm, $glossary, $category);
+ glossary_print_categories_menu($course, $cm, $glossary, $cat, $category);
+ $currentcategory = "";
} else {
glossary_print_alphabet_menu($cm, $glossary, $l);
$allentries = glossary_search_entries($searchterms, $glossary, $includedefinition);
} elseif ( $eid ) { // looking for an entry
$allentries = get_records("glossary_entries", "id", $eid);
- } else { // looking for terms that begin with a specify letter
+ } elseif ( $currentview and $cat == 0 ) { // Browsing all categories
+ $sql = "SELECT gec.id gecid, gc.name, gc.id CID, ge.*
+ FROM {$CFG->prefix}glossary_entries ge,
+ {$CFG->prefix}glossary_entries_categories gec,
+ {$CFG->prefix}glossary_categories gc
+ WHERE ge.glossaryid = '$glossary->id' AND
+ gec.entryid = ge.id AND
+ gc.id = gec.categoryid
+ ORDER BY gc.name, ge.concept";
+ $allentries = get_records_sql( $sql );
+ } else { // looking for terms that begin with a specify letter or entries with no category associated
$allentries = get_records("glossary_entries", "glossaryid", $glossary->id,"concept ASC");
}
$DumpToScreen = 1;
}
} else {
- if ( ! record_exists("glossary_entries_categories","entryid",$entry->id) ) {
- $DumpToScreen = 1;
- }
+ if ( $cat < 0 ) { // No categorized
+ if ( ! record_exists("glossary_entries_categories","entryid",$entry->id) ) {
+ $DumpToScreen = 1;
+ }
+ } else { // All categories
+ if ( $currentcategory != $entry->CID ) {
+ $currentcategory = $entry->CID;
+ if ( $glossary->displayformat == 0 ) {
+ if ( $DumpedDefinitions > 0) {
+ echo "</table></center><p>";
+ }
+ echo "\n<center><TABLE BORDER=0 CELLSPACING=0 width=95% valign=top cellpadding=10><tr><td align=center BGCOLOR=\"$THEME->cellheading2\">";
+ }
+ echo "<b>$entry->name</b>";
+ }
+
+ if ( $glossary->displayformat == 0 ) {
+ echo "\n</center></td></tr></TABLE></center>";
+ if ( $DumpedDefinitions > 0) {
+ echo "\n<center><TABLE BORDER=1 CELLSPACING=0 width=95% valign=top cellpadding=10>";
+ }
+ }
+
+ $DumpToScreen = 1;
+ }
}
} else {
$DumpToScreen = 1;