Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Corrections in EN language. Thanks to Przemek!

- 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)
  • Loading branch information...
commit 914cb260dc0a5271ac2c019fc147d02dc6f0f584 1 parent a1f8ff8
willcast authored
View
15 lang/en/glossary.php
@@ -23,27 +23,29 @@
$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";
@@ -53,4 +55,3 @@
$string['writtenby'] = "By";
?>
-
View
8 lang/en/help/glossary/allowduplicatedentries.html
@@ -1,4 +1,4 @@
-<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>Allow duplicated entries</B></P>
+
+<P>You can specify if the system should or should not accept duplicated entries in the current glossary.
+
View
20 lang/en/help/glossary/displayformat.html
@@ -1,10 +1,10 @@
-<P ALIGN=CENTER><B>Display format</B></P>
-
-<P>The system has three builed-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 lack you use called <b>displayformat[number]</b>, and give it a meaninful description.
+<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.
View
30 lang/en/help/glossary/index.html
@@ -1,15 +1,15 @@
-<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>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>
+
View
10 lang/en/help/glossary/mainglossary.html
@@ -1,5 +1,5 @@
-<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 glossary by course.
+<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.
View
12 lang/en/help/glossary/mods.html
@@ -1,6 +1,6 @@
-<P><IMG VALIGN=absmiddle SRC="<?php echo $CFG->wwwroot?>/mod/glossary/icon.gif">&nbsp;<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 the show in different formats.<br />
-You can search terms. The glossary also allows to export entries from one glossary to other (the main one) within the same course.
-</UL>
+<P><IMG VALIGN=absmiddle SRC="<?php echo $CFG->wwwroot?>/mod/glossary/icon.gif">&nbsp;<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>
View
8 lang/en/help/glossary/studentcanpost.html
@@ -1,4 +1,4 @@
-<P ALIGN=CENTER><B>Students can post entries</B></P>
-
-<P>You can specify if an user can or cannot add, edit or delete his/her own entries in this glossary.
-<p><b>Note:</b> A teacher could edit or delete any entry at any time.
+<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.
View
4 lang/es/glossary.php
@@ -31,6 +31,9 @@
$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";
@@ -43,7 +46,6 @@
$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'";
View
2  mod/glossary/db/mysql.php
@@ -57,7 +57,7 @@ function glossary_upgrade($oldversion) {
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;
View
9 mod/glossary/edit.html
@@ -15,13 +15,8 @@
<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 ";
View
30 mod/glossary/edit.php
@@ -59,14 +59,16 @@
$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"];
@@ -76,12 +78,12 @@
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;
@@ -125,11 +127,13 @@
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&currentview=$currentview&cat=$cat");
+ redirect("view.php?id=$cm->id&eid=$newentry->id");
die;
}
}
View
73 mod/glossary/lib.php
@@ -169,7 +169,7 @@ function glossary_get_entries($glossaryid, $entrylist) {
}
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";
@@ -540,12 +540,20 @@ function print_tabbed_table_start($data, $CurrentTab, $tTHEME = NULL) {
} 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">&nbsp;</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\">&nbsp;</td>";
+ }
} else {
$CurrentColor = "";
}
@@ -566,12 +574,19 @@ function print_tabbed_table_start($data, $CurrentTab, $tTHEME = NULL) {
} 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">&nbsp;</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\">&nbsp;</td>";
+ }
} else {
if ($NumRows > 1) {
$CurrentColor = $TabColor;
@@ -610,13 +625,23 @@ function glossary_print_alphabet_menu($cm, $glossary, $l) {
$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> | ";
}
}
@@ -645,7 +670,7 @@ function glossary_print_alphabet_menu($cm, $glossary, $l) {
}
}
}
-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>";
@@ -663,11 +688,19 @@ function glossary_print_categories_menu($course, $cm, $glossary, $category) {
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 ) {
@@ -680,7 +713,7 @@ function glossary_print_categories_menu($course, $cm, $glossary, $category) {
}
}
- echo popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&currentview=categories&cat=", $menu, "catmenu", $selected, get_string("jumpto"),
+ echo popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&currentview=categories&cat=", $menu, "catmenu", $selected, "",
"", "", false);
echo "</td>";
View
55 mod/glossary/view.php
@@ -28,7 +28,7 @@
}
require_login($course->id);
- if ( !$course->visible ) {
+ if (!$cm->visible and !isteacher($course->id)) {
notice(get_string("activityiscurrentlyhidden"));
}
@@ -57,11 +57,11 @@
$l = "";
$currentview = strtolower($currentview);
if ( $currentview ) {
- if ( $cat ) {
+ if ( $cat > 0 ) {
$category = get_record("glossary_categories","id",$cat);
- }
- if ( !$category ) {
- $cat = "";
+ if ( !$category ) {
+ $cat = "";
+ }
}
}
}
@@ -97,7 +97,7 @@
</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 );
}
@@ -119,7 +119,8 @@
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);
@@ -137,7 +138,17 @@
$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");
}
@@ -179,9 +190,31 @@
$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;
Please sign in to comment.
Something went wrong with that request. Please try again.