$string['addentry'] = "Add entry";
$string['allentries'] = "ALL";
+$string['allcategories'] = "All Categories";
$string['allowduplicatedentries'] = "Duplicated entries allowed";
$string['alphabet'] = "A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z";
-$string['areyousuredelete'] = "Are you sure you want to delete this entry?";
+$string['areyousuredelete'] = "Are you sure you want to delete it?";
$string['attachment'] = "Attachment";
-$string['categoryview'] = "By Category";
+$string['back'] = "Back";
+$string['categories'] = "Categories";
+$string['categoryview'] = "By category";
+$string['category'] = "Category";
+$string['categorydeleted'] = "Category deleted";
$string['concept'] = "Concept";
$string['concepts'] = "Concepts";
$string['definition'] = "Definition";
$string['definitions'] = "Definitions";
$string['deleteentry'] = "Delete entry";
+$string['deletingnoneemptycategory'] = "If a non empty category is deleted, its relations with their entries will also be deleted. If you wish to delete the entries, you will have to do so manually.";
$string['displayformat'] = "Display format";
$string['displayformatdefault'] = "Simple, dictionary style";
$string['displayformat1'] = "Full without author.";
$string['displayformat2'] = "Full with author.";
+$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['entrydeleted'] = "Entry deleted.";
$string['entryexported'] = "Entry succesfully exported.";
$string['modulename'] = "Glossary";
$string['modulenameplural'] = "Glossaries";
$string['newglossaryentries'] = "New glossary entries:";
+$string['nocategorized'] = "No categorized";
$string['noentries'] = "No entries found in this section";
$string['noentry'] = "No entry found.";
$string['searchconcept'] = "Search:";
$string['addentry'] = "Agregar entrada";
$string['allentries'] = "TODAS";
+$string['allcategories'] = "Todas las categorías";
$string['allowduplicatedentries'] = "Permitir entradas duplicadas";
$string['alphabet'] = "A|B|C|D|E|F|G|H|I|J|K|L|M|N|Ñ|O|P|Q|R|S|T|U|V|W|X|Y|Z";
-$string['areyousuredelete'] = "¿Está seguro que desea borrar esta entrada?";
+$string['areyousuredelete'] = "¿Está seguro que desea borrarla?";
$string['attachment'] = "Adjunto";
+$string['back'] = "Volver";
+$string['categories'] = "Categorías";
$string['categoryview'] = "Vista por Categoría";
+$string['category'] = "Categoría";
+$string['categorydeleted'] = "Categoría eliminada";
$string['concept'] = "Concepto";
$string['concepts'] = "Conceptos";
$string['definition'] = "Definición";
$string['definitions'] = "Definiciones";
$string['deleteentry'] = "Borrar entrada";
+$string['deletingnoneemptycategory'] = "Si una categoría es eliminada por consiguiente su relación con las entradas también lo será. Si desea eliminar las entradas, tendrá que hacerlo manualmente.";
$string['displayformat'] = "Formato de muestra de entradas";
$string['displayformatdefault'] = "Simple, estilo diccionario";
$string['displayformat1'] = "Completo sin autor.";
$string['displayformat2'] = "Completo con autor.";
$string['editentry'] = "Editar entrada";
+$string['editcategories'] = "Editar categorías";
+$string['entries'] = "Entradas";
+$string['entrieswithoutcategory'] = "Entradas sin categoría";
+$string['entry'] = "Entrada";
$string['entryalreadyexist'] = "Esta entrada ya existe.";
$string['entrydeleted'] = "Entrada borrada.";
$string['entryexported'] = "Entrada exportada con éxito.";
$string['modulename'] = "Glosario";
$string['modulenameplural'] = "Glosarios";
$string['newglossaryentries'] = "Nuevas entradas en el glosario:";
+$string['nocategorized'] = "Sin categoría";
$string['noentries'] = "No se encontraro entradas en esta sección";
$string['noentry'] = "No se econtró ninguna entrada.";
$string['searchconcept'] = "Buscar:";
`entryid` INT(10) UNSIGNED NOT NULL default '0',
PRIMARY KEY (`categoryid`, `entryid`)
) TYPE=MyISAM COMMENT='categories of each glossary entry'");
-
- // creating a default category for every glossary
- execute_sql("INSERT INTO `{$CFG->prefix}glossary_categories` (`glossaryid`, `name`)
- SELECT `id`, '" . get_string("main","glossary") . "' FROM `{$CFG->prefix}glossary`");
-
-
- // setting the default category for every entry.
- execute_sql("INSERT INTO `{$CFG->prefix}glossary_entries_categories` (`categoryid`, `entryid`)
- SELECT c.id, e.id
- FROM `{$CFG->prefix}glossary_entries` e, `{$CFG->prefix}glossary_categories` c
- WHERE e.glossaryid = c.glossaryid");
-
+ }
+
+ if ( $oldversion < 2003092100 ) {
+ execute_sql("ALTER TABLE `{$CFG->prefix}glossary_entries_categories` CHANGE `categoryid` `categoryid` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL ");
}
return true;
#
CREATE TABLE prefix_glossary_entries_categories (
- categoryid int(10) unsigned NOT NULL default '1',
+ categoryid int(10) unsigned NOT NULL default '0',
entryid int(10) unsigned NOT NULL default '0',
PRIMARY KEY (categoryid, entryid)
) TYPE=MyISAM COMMENT='categories of each glossary entry';
--- /dev/null
+<?php
+
+function glossary_upgrade($oldversion) {
+/// This function does anything necessary to upgrade
+/// older versions to match current functionality
+
+ global $CFG;
+
+
+ return true;
+}
+
+?>
\ No newline at end of file
--- /dev/null
+# This file contains a complete database schema for all the
+# tables used by this module, written in SQL
+
+# It may also contain INSERT statements for particular data
+# that may be used, especially new entries in the table log_display
+
+#
+# Table structure for table `glossary`
+#
+
+CREATE TABLE prefix_glossary (
+ id SERIAL,
+ course int4 NOT NULL default '0',
+ name varchar(255) NOT NULL default '',
+ studentcanpost int2 NOT NULL default '0',
+ allowduplicatedentries int2 NOT NULL default '0',
+ displayformat int2 NOT NULL default '0',
+ mainglossary int2 NOT NULL default '0',
+ showspecial int2 NOT NULL default '1',
+ showalphabet int2 NOT NULL default '1',
+ showall int2 NOT NULL default '1',
+ timecreated int4 NOT NULL default '0',
+ timemodified int4 NOT NULL default '0',
+ PRIMARY KEY (id)
+);
+
+#
+# Table structure for table `glossary_entries`
+#
+
+CREATE TABLE prefix_glossary_entries (
+ id SERIAL,
+ glossaryid int4 NOT NULL default '0',
+ userid int4 NOT NULL default '0',
+ concept varchar(255) NOT NULL default '',
+ definition text NOT NULL,
+ format int2 NOT NULL default '0',
+ attachment VARCHAR(100) NOT NULL default '',
+ timecreated int4 NOT NULL default '0',
+ timemodified int4 NOT NULL default '0',
+ teacherentry int2 NOT NULL default '0',
+ PRIMARY KEY(id)
+);
+
+#
+# Table structure for table `glossary_cageories`
+#
+
+CREATE TABLE prefix_glossary_categories (
+ id SERIAL,
+ glossaryid int4 NOT NULL default '0',
+ name varchar(255) NOT NULL default '',
+ PRIMARY KEY (id)
+);
+
+#
+# Table structure for table `glossary_entries_category`
+#
+
+CREATE TABLE prefix_glossary_entries_categories (
+ categoryid int4 NOT NULL default '0',
+ entryid int4 NOT NULL default '0',
+ PRIMARY KEY (categoryid, entryid)
+);
+
+#
+# Dumping data for table `log_display`
+#
+
+INSERT INTO prefix_log_display VALUES ('glossary', 'add', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'update', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'view', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'view all', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'add entry', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'update entry', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'add category', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'update category', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'delete category', 'glossary', 'name');
+
<input type="hidden" name=mode value="delete">
<input type="hidden" name=go value="1">
<input type="hidden" name=entry value="<?php echo $entry ?>">
+<input type="hidden" name=currentview value="<?=$currentview ?>">
+<input type="hidden" name=cat value="<?=$cat ?>">
<input type="submit" value=" <?php print_string("yes")?> ">
<input type=button value=" <?php print_string("no")?> " onclick="javascript:history.go(-1);">
if ( isteacher($cm->id) or $glossary->studentcanpost ) {
if ($go) { // the operation was confirmed.
if ( $mode == "delete") {
+ glossary_delete_old_attachments($entry);
delete_records("glossary_entries","id", $entry);
print_simple_box_start("center","40%", "#FFBBBB");
echo "<center>$entrydeleted"; //CAMBIAR
echo "</center>";
print_simple_box_end();
- } elseif ($mode == "edit") {
}
print_footer($course);
- add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id", $entry);
- redirect("view.php?id=$cm->id");
+ add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id¤tview=$currentview&cat=$cat", $entry);
+ redirect("view.php?id=$cm->id¤tview=$currentview&cat=$cat");
} else { // the operation has not been confirmed yet so ask the user to do so
if ( $mode == "delete") {
print_simple_box_start("center","40%", "#FFBBBB");
- echo "<center><b>$entryfields->concept</b><br>$strareyousuredelete"; //CAMBIAR
- include("deleteentry.html");
- echo "</center>";
+ echo "<center><b>$entryfields->concept</b><br>$strareyousuredelete";
+
+ ?>
+ <form name="form" method="post" action="deleteentry.php">
+
+ <input type="hidden" name=id value="<?php p($cm->id) ?>">
+ <input type="hidden" name=mode value="delete">
+ <input type="hidden" name=go value="1">
+ <input type="hidden" name=entry value="<?php p($entry) ?>">
+ <input type="hidden" name=currentview value=<? p($currentview) ?>>
+ <input type="hidden" name=cat=<? p($cat) ?>>
+
+ <input type="submit" value=" <?php print_string("yes")?> ">
+ <input type=button value=" <?php print_string("no")?> " onclick="javascript:history.go(-1);">
+
+ </form>
+ </center>
+ <?
print_simple_box_end();
- } elseif ($mode == "edit") {
}
}
} else {
<INPUT type="text" name="concept" size=30 value="<? p($form->concept) ?>">
</td>
</tr>
+<tr valign=top>
+ <td align=right><p><b><?php echo get_string("categories","glossary") ?>:</b></p></td>
+ <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\">";
+
+ foreach ( $categories as $category ) {
+ echo " <option ";
+
+ if ( record_exists("glossary_entries_categories","entryid",$entry->id,"categoryid",$category->id) ) {
+ echo "selected " ;
+ }
+ echo "value=\"$category->id\">$category->name</option>\n";
+ }
+ ?>
+ </select>
+ </td>
+</tr>
<tr valign=top>
<td align=right><p><b><? echo get_string("definition","glossary") ?>:</b></p>
<font size="1">
$form->format = $defaultformat;
}
choose_from_menu(format_text_menu(), "format", $entry->format, "");
- if ($entry->id) {
- echo "<input type=\"hidden\" name=entry value=\"$entry->id\">";
- }
echo "</p>";
?>
</td>
<tr>
<td colspan=2>
<p align=center>
+ <? if ($entry->id) {
+ echo "<input type=\"hidden\" name=entry value=\"$entry->id\">";
+ }
+ ?>
<input type="hidden" name=id value="<?=$cm->id ?>">
+ <input type="hidden" name=currentview value="<?=$currentview ?>">
+ <input type="hidden" name=cat value="<?=$cat ?>">
+
<input type="submit" value="<? print_string("savechanges") ?>">
<input type="reset" value="<? print_string("revert") ?>">
</P>
require_variable($id); // Course Module ID
optional_variable($e); // EntryID
+optional_variable($currentview); // categories if by category?
+optional_variable($cat); // CategoryID
+
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
}
set_field("glossary_entries", "attachment", $newfilename, "id", $newentry->id);
- add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&eid=$newentry->id", "$newentry->id");
+ add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&eid=$newentry->id¤tview=$currentview&cat=$cat", "$newentry->id");
}
} else {
error("Could not insert this glossary entry because this concept already exist.");
}
}
- redirect("view.php?id=$cm->id&eid=$newentry->id");
+ delete_records("glossary_entries_categories","entryid",$entry);
+
+ if ( $categories ) {
+ $newcategory->entryid = $newentry->id;
+ foreach ($categories as $category) {
+ $newcategory->categoryid =$category;
+ insert_record("glossary_entries_categories",$newcategory);
+ }
+ }
+ redirect("view.php?id=$cm->id&eid=$newentry->id¤tview=$currentview&cat=$cat");
die;
}
}
--- /dev/null
+<?
+ global $CFG, $THEME;
+ require_once("../../config.php");
+
+?>
+
+<FORM name="form" method="post" <?=$onsubmit ?> action="editcategories.php">
+<table class=generalbox cellpadding=5 bgcolor="<? p($THEME->cellheading)?>">
+<tr valign=top>
+ <td align=right><p><b><?php echo get_string("name") ?>:</b></p></td>
+ <td>
+ <INPUT type="text" name="name" size=30 value="<?=$name ?>">
+ </td>
+</tr>
+<td colspan=2>
+ <p align=center>
+ <input type="hidden" name=id value="<?=$cm->id ?>">
+ <input type="hidden" name=action value="<?=$action?>">
+ <input type="hidden" name=confirm value=1>
+ <input type="hidden" name=cat value=<? p($cat) ?>>
+ <input type="submit" value="<? print_string("savechanges") ?>">
+ <input type="reset" value="<? print_string("back","glossary") ?>" onclick="javascript:history.go(-1);">
+ </P>
+</td>
+</tr>
+</table>
+</p>
+
+
+</form>
--- /dev/null
+<?PHP // $Id$
+
+/// This page allows to edit entries categories for a particular instance of glossary
+
+ require_once("../../config.php");
+ require_once("lib.php");
+
+ require_variable($id); // Course Module ID, or
+ optional_variable($cat); // category ID
+ optional_variable($action); // what to do
+ optional_variable($confirm); // confirm the action
+
+ optional_variable($name); // confirm the action
+
+ $action = strtolower($action);
+
+ if (! $cm = get_record("course_modules", "id", $id)) {
+ error("Course Module ID was incorrect");
+ }
+
+ if (! $course = get_record("course", "id", $cm->course)) {
+ error("Course is misconfigured");
+ }
+
+ if (! $glossary = get_record("glossary", "id", $cm->instance)) {
+ error("Course module is incorrect");
+ }
+
+ require_login($course->id);
+
+ if ( !isteacher($course->id) ) {
+ error("You must be a teacher to use this page.");
+ }
+
+// add_to_log($course->id, "glossary", "edit categories", "view.php?id=$cm->id", "$glossary->id");
+
+ if ($course->category) {
+ $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
+ }
+
+ $strglossaries = get_string("modulenameplural", "glossary");
+ $strglossary = get_string("modulename", "glossary");
+
+ print_header("$course->shortname: $glossary->name", "$course->fullname",
+ "$navigation <A HREF=index.php?id=$course->id>$strglossaries</A> -> $glossary->name",
+ "", "", true, update_module_button($cm->id, $course->id, $strglossary),
+ navmenu($course, $cm));
+
+ if ( $cat ) {
+ $category = get_record("glossary_categories","id",$cat);
+
+ if ( $action == "edit" ) {
+ if ( $confirm ) {
+ $action = "";
+ $CategoryObject->id = $cat;
+ $CategoryObject->name = $name;
+
+ if ( !update_record("glossary_categories", $CategoryObject) ) {
+ error("Weird error. The category was not updated.");
+
+ redirect("editcategories.php?id=$cm->id");
+ }
+
+ } else {
+ echo "<p align=\"center\">" . get_string("edit"). " " . get_string("category","glossary") . "<font size=\"3\">";
+
+ $name = $category->name;
+ require "editcategories.html";
+ print_footer();
+ die;
+ }
+ } elseif ( $action == "delete" ) {
+ if ( $confirm ) {
+
+ delete_records("glossary_entries_categories","categoryid", $cat);
+ delete_records("glossary_categories","id", $cat);
+
+ print_simple_box_start("center","40%", "#FFBBBB");
+ echo "<center>" . get_string("categorydeleted","glossary") ."</center>";
+ echo "</center>";
+ print_simple_box_end();
+
+ print_footer($course);
+
+ add_to_log($course->id, "glossary", "delete category", "editcategories.php?id=$cm->id", $cat);
+
+ redirect("editcategories.php?id=$cm->id");
+ } else {
+ echo "<p align=\"center\">" . get_string("delete"). " " . get_string("category","glossary") . "<font size=\"3\">";
+
+ print_simple_box_start("center","40%", "#FFBBBB");
+ echo "<center><b>$category->name</b><br>";
+
+ $num_entries = count_records("glossary_entries_categories","categoryid",$category->id);
+ if ( $num_entries ) {
+ print_string("deletingnoneemptycategory","glossary");
+ }
+ echo "<p>";
+ print_string("areyousuredelete","glossary");
+
+ ?>
+ <form name="form" method="post" action="editcategories.php">
+
+ <input type="hidden" name=id value="<?php p($cm->id) ?>">
+ <input type="hidden" name=action value="delete">
+ <input type="hidden" name=confirm value="1">
+ <input type="hidden" name=cat value="<?php echo $cat ?>">
+ <table border=0 widTH=100><tr><td align=right width=50%>
+ <input type="submit" value=" <?php print_string("yes")?> ">
+ </form>
+ </td><td align=left width=50%>
+ <?
+ unset($options);
+ $options = array ("id" => $id);
+ print_single_button("editcategories.php", $options, get_string("no") );
+ echo "</td></tr></table>";
+ echo "</center>";
+ print_simple_box_end();
+ }
+ }
+ } elseif ( $action == "add" ) {
+ if ( $confirm ) {
+ $dupcategory = get_record("glossary_categories","lcase(name)",strtolower($name));
+ if ( $dupcategory ) {
+ echo "<p align=\"center\">" . get_string("add"). " " . get_string("category","glossary") . "<font size=\"3\">";
+
+ print_simple_box_start("center","40%", "#FFBBBB");
+ echo "<center>" . get_string("duplicatedcategory","glossary") ."</center>";
+ echo "</center>";
+ print_simple_box_end();
+
+ print_footer($course);
+
+ redirect("editcategories.php?id=$cm->id&action=add&&name=$name");
+
+ } else {
+ $action = "";
+ $CategoryObject->name = $name;
+ $CategoryObject->glossaryid = $glossary->id;
+
+ if ( ! $CategoryObject->id = insert_record("glossary_categories", $CategoryObject) ) {
+ error("Weird error. The category was not inserted.");
+
+ redirect("editcategories.php?id=$cm->id");
+ } else {
+ add_to_log($course->id, "glossary", "add category", "editcategories.php?id=$cm->id", $cat);
+ }
+ }
+ } else {
+ echo "<p align=\"center\">" . get_string("add"). " " . get_string("category","glossary") . "<font size=\"3\">";
+ $name="";
+ require "editcategories.html";
+ }
+ }
+
+ if ( $action ) {
+
+ print_footer();
+ die;
+ }
+
+?>
+
+
+<p align="center"><? p(get_string("edit")) ?> <? p(get_string("categories","glossary")) ?><font size="3">
+
+<FORM name="theform" method="post" <?=$onsubmit ?> action="editcategories.php">
+<table width="40%" class=generalbox cellpadding=5 bgcolor="<? p($THEME->cellheading)?>">
+ <tr>
+ <td width="90%" align="center"><b>
+ <? p(get_string("categories","glossary")) ?></b></td>
+ <td width="10%" align="center"><b>
+ <? p(get_string("action")) ?></b></td>
+ </tr>
+ <tr><td width=100% colspan=2 bgcolor="<? p($THEME->cellheading2)?>">
+
+ <table width=100%>
+<?
+ $categories = get_records("glossary_categories","glossaryid",$glossary->id,"name ASC");
+
+ if ( $categories ) {
+ foreach ($categories as $category) {
+ $num_entries = count_records("glossary_entries_categories","categoryid",$category->id);
+ ?>
+ <tr bgcolor="<? p($THEME->cellheading2)?>">
+ <td width="90%" align="left">
+ <?
+ echo "<b>$category->name</b> <font size=-1>($num_entries " . get_string("entries","glossary") . ")</font>";
+ ?>
+ </td>
+ <td width="10%" align="center"><b>
+ <?
+ echo "<a href=\"editcategories.php?id=$cm->id&action=delete&cat=$category->id\"><img alt=\"" . get_string("delete") . "\"src=\"../../pix/t/delete.gif\" height=11 width=11 border=0></a> ";
+ echo "<a href=\"editcategories.php?id=$cm->id&action=edit&cat=$category->id\"><img alt=\"" . get_string("edit") . "\" src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
+ ?>
+ </b></td>
+ </tr>
+
+ <?
+ }
+ }
+?>
+ </table>
+
+ </td>
+ <tr>
+ <td width=100% colspan=2 align=center bgcolor="<? p($THEME->cellheading2)?>">
+ <?
+
+ $options['id'] = $cm->id;
+ $options['action'] = "add";
+
+ echo "<table border=0><tr><td align=right>";
+ echo print_single_button("editcategories.php", $options, get_string("add") . " " . get_string("category","glossary"), "get");
+ echo "</td><td align=left>";
+ unset($options['action']);
+ $options['currentview'] = "categories";
+ echo print_single_button("view.php", $options, get_string("back","glossary") );
+ echo "</td></tr>";
+ echo "</tablee>";
+
+ ?>
+ </td>
+ </tr>
+ </table>
+
+</table>
+</p>
+
+
+</form>
+
+<? print_footer() ?>
require_variable($id); // course module ID
require_variable($entry); // Entry ID
optional_variable($confirm); // confirmation
+ optional_variable($currentview);
+ optional_variable($cat);
+
global $THEME, $USER, $CFG;
$PermissionGranted = 1;
echo "<center>";
notice_yesno ("<center><h2>$entry->concept</h2><p align=center>Seguro que desea agregar esta entrada a<br><b>$mainglossary->name</b>?",
- "exportentry.php?id=$id&entry=$entry->id&confirm=1",
- "view.php?id=$cm->id&eid=".$entry->id );
+ "exportentry.php?id=$id¤tview=$currentview&cat=$cat&entry=$entry->id&confirm=1",
+ "view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id );
} else {
if ( ! $mainglossary->allowduplicatedentries ) {
}
}
- add_to_log($course->id, "glossary", "add entry",
- "view.php?id=$cm->id&eid=".$entry->id, "$newentry->id");
+ add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id, "$newentry->id");
- print_continue("view.php?id=$cm->id&eid=".$entry->id);
+ print_continue("view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id);
print_simple_box_end();
print_footer();
- redirect("view.php?id=$cm->id&eid=".$entry->id);
+ redirect("view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id);
die;
}
} else {
echo "<p align=center><font size=3>$entryalreadyexist</font></p></font>";
echo "<p align=center>";
- print_continue("view.php?id=$cm->id&eid=".$entry->id);
+ print_continue("view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id);
print_simple_box_end();
}
print_simple_box_start("center", "60%", "#FFBBBB");
echo "<p align=center><font size=3>A weird error was found while trying to export this entry. Operation cancelled.</font></p></font>";
- print_continue("view.php?id=$cm->id&eid=".$entry->id);
+ print_continue("view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id);
print_simple_box_end();
}
<?PHP // $Id$
-function glossary_print_entry_by_format($course, $cm, $glossary, $entry) {
+function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$currentview="",$cat="") {
global $THEME, $USER;
// if ($entry->timemarked < $entry->modified) {
if ($entry) {
echo format_text($entry->definition, $entry->format);
- glossary_print_entry_icons($course, $cm, $glossary, $entry);
+ glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview,$cat);
} else {
echo "<center>";
<?PHP // $Id$
require_once("lib.php");
-function glossary_print_entry_by_format($course, $cm, $glossary, $entry) {
+function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$currentview="",$cat="") {
global $THEME, $CFG, $USER;
// if ($entry->timemarked < $entry->modified) {
if ($entry) {
echo format_text($entry->definition, $entry->format);
- glossary_print_entry_icons($course, $cm, $glossary, $entry);
+ glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview,$cat);
} else {
echo "<center>";
require_once("$CFG->dirroot/files/mimetypes.php");
+$tCFG->TabTableBGColor = $THEME->cellcontent2;
+$tCFG->TabTableWidth = "70%";
+$tCFG->ActiveTabColor = $THEME->cellcontent2;
+$tCFG->InactiveTabColor = $THEME->cellheading2;
+$tCFG->TabsPerRow = 5;
+$tCFG->TabSeparation = 4;
+
function glossary_add_instance($glossary) {
/// Given an object containing all the necessary data,
/// (defined by the form in mod.html) this function
AND id IN ($entrylist)");
}
-function glossary_print_entry($course, $cm, $glossary, $entry) {
+function glossary_print_entry($course, $cm, $glossary, $entry,$currentview="",$cat="") {
global $THEME, $USET, $CFG;
$PermissionGranted = 0;
}
if ( $glossary->displayformat > 0 and $PermissionGranted ) {
- glossary_print_entry_by_format($course, $cm, $glossary, $entry);
+ glossary_print_entry_by_format($course, $cm, $glossary, $entry,$currentview,$cat);
} else {
- glossary_print_entry_by_default($course, $cm, $glossary, $entry);
+ glossary_print_entry_by_default($course, $cm, $glossary, $entry,$currentview,$cat);
}
}
-function glossary_print_entry_by_default($course, $cm, $glossary, $entry) {
+function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$currentview="",$cat="") {
global $THEME, $USER;
$colour = $THEME->cellheading2;
}
echo "<b>$entry->concept</b>: ";
echo format_text($entry->definition, $entry->format);
- glossary_print_entry_icons($course, $cm, $glossary, $entry);
+ glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview,$cat);
echo "</td>";
echo "</TR>";
}
-function glossary_print_entry_icons($course, $cm, $glossary, $entry) {
+function glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview="",$cat="") {
global $THEME, $USER;
if (isteacher($course->id) or $glossary->studentcanpost and $entry->userid == $USER->id) {
$mainglossary = get_record("glossary","mainglossary",1,"course",$course->id);
if ( $mainglossary ) {
- echo "<a href=\"exportentry.php?id=$cm->id&entry=$entry->id\"><img alt=\"" . get_string("exporttomainglossary","glossary") . "\"src=\"export.gif\" height=11 width=11 border=0></a> ";
+ echo "<a href=\"exportentry.php?id=$cm->id&entry=$entry->id¤tview=$currentview&cat=$cat\"><img alt=\"" . get_string("exporttomainglossary","glossary") . "\"src=\"export.gif\" height=11 width=11 border=0></a> ";
}
}
- echo "<a href=\"deleteentry.php?id=$cm->id&mode=delete&entry=$entry->id\"><img alt=\"" . get_string("delete") . "\"src=\"../../pix/t/delete.gif\" height=11 width=11 border=0></a> ";
- echo "<a href=\"edit.php?id=$cm->id&e=$entry->id\"><img alt=\"" . get_string("edit") . "\" src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
+ echo "<a href=\"deleteentry.php?id=$cm->id&mode=delete&entry=$entry->id¤tview=$currentview&cat=$cat\"><img alt=\"" . get_string("delete") . "\"src=\"../../pix/t/delete.gif\" height=11 width=11 border=0></a> ";
+ echo "<a href=\"edit.php?id=$cm->id&e=$entry->id¤tview=$currentview&cat=$cat\"><img alt=\"" . get_string("edit") . "\" src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
}
}
echo "</center><p></td></tr></table></center>";
}
+function glossary_print_alphabet_menu($cm, $glossary, $l) {
+global $CFG, $THEME;
+ $strselectletter = get_string("selectletter", "glossary");
+ $strspecial = get_string("special", "glossary");
+ $strallentries = get_string("allentries", "glossary");
+
+ echo "<CENTER>$strselectletter";
+
+ if ( $glossary->showspecial ) {
+ if ( $l == "SPECIAL" ) {
+ echo "<p><b>$strspecial</b> | ";
+ } else {
+ echo "<p><a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=SPECIAL\">$strspecial</a> | ";
+ }
+ }
+
+ if ( $glossary->showalphabet ) {
+ $alphabet = explode("|", get_string("alphabet","glossary"));
+ $letters_by_line = 14;
+ for ($i = 0; $i < count($alphabet); $i++) {
+ if ( $l == $alphabet[$i] ) {
+ echo "<b>$alphabet[$i]</b>";
+ } else {
+ echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=$alphabet[$i]\">$alphabet[$i]</a>";
+ }
+ if ((int) ($i % $letters_by_line) != 0 or $i == 0) {
+ echo " | ";
+ } else {
+ echo "<br>";
+ }
+ }
+ }
+
+ if ( $glossary->showall ) {
+ if ( $l == "ALL" ) {
+ echo "<b>$strallentries</b></p>";
+ } else {
+ echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=ALL\">$strallentries</a></p>";
+ }
+ }
+}
+function glossary_print_categories_menu($course, $cm, $glossary, $category) {
+global $CFG, $THEME;
+ echo "<table border=0 width=100%>";
+ echo "<tr>";
+
+ echo "<td align=center width=20%>";
+ if ( isteacher($course->id) ) {
+ $options['id'] = $cm->id;
+ $options['cat'] = $cat;
+ echo print_single_button("editcategories.php", $options, get_string("editcategories","glossary"), "get");
+ }
+ echo "</td>";
+
+ echo "<td align=center width=60%>";
+ echo "<b>";
+ if ( $category ) {
+ echo $category->name;
+ } else {
+ echo get_string("entrieswithoutcategory","glossary");
+ }
+ echo "</b></td>";
+ echo "<td align=center width=20%>";
+ $menu[0] = get_string("nocategorized","glossary");
+
+ $categories = get_records("glossary_categories", "glossaryid", $glossary->id, "name ASC");
+ if ( $categories ) {
+ foreach ($categories as $currentcategory) {
+ $url = $currentcategory->id;
+ if ($currentcategory->id == $category->id) {
+ $selected = $url;
+ }
+ $menu[$url] = $currentcategory->name;
+ }
+ }
+
+ echo popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id¤tview=categories&cat=", $menu, "catmenu", $selected, get_string("jumpto"),
+ "", "", false);
+
+ echo "</td>";
+ echo "</tr>";
+
+ echo "<tr><td colspan=3><hr></td></tr>";
+ echo "</table>";
+}
?>
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2003091800; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2003092100; // The current module version (Date: YYYYMMDDXX)
$module->cron = 0; // Period for cron to check this module (secs)
$release = "0.3.1 development"; // User-friendly version number
optional_variable($currentview); // browsing entries by categories?
optional_variable($cat); // categoryID
- if ($l == "" and $search == "" and $eid == "") {
- $l = "A";
+ if (! $cm = get_record("course_modules", "id", $id)) {
+ error("Course Module ID was incorrect");
}
-
- if ( $currentview ) {
- $currentview = strtolower($currentview);
- if ( !$currentview ) {
- $currentview = "";
- } else {
- if ( !$cat ) {
- $cat = 1;
- }
- $category = get_record("glossary_categories","id",$cat);
- }
+
+ if (! $course = get_record("course", "id", $cm->course)) {
+ error("Course is misconfigured");
}
- $search = trim(strip_tags($search));
+ if (! $glossary = get_record("glossary", "id", $cm->instance)) {
+ error("Course module is incorrect");
+ }
+
+ require_login($course->id);
+ if ( !$course->visible ) {
+ notice(get_string("activityiscurrentlyhidden"));
+ }
+ add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id", "$glossary->id");
+
+ $search = trim(strip_tags($search));
if ($search and !$entryid ) {
$l = "";
$searchterms = explode(" ", $search); // Search for words independently
}
}
$search = trim(implode(" ", $searchterms));
+ $currentview = "";
} elseif ( $eid ) {
- $search = "";
+ $search = "";
}
-
- if (! $cm = get_record("course_modules", "id", $id)) {
- error("Course Module ID was incorrect");
- }
-
- if (! $course = get_record("course", "id", $cm->course)) {
- error("Course is misconfigured");
+ if ($l == "" and $search == "" and ($eid == "" or $eid == 0) ) {
+ $l = "A";
+ } elseif ( $eid ) {
+ $l = "";
}
-
- if (! $glossary = get_record("glossary", "id", $cm->instance)) {
- error("Course module is incorrect");
+ if ( $currentview ) {
+ $l = "";
+ $currentview = strtolower($currentview);
+ if ( $currentview ) {
+ if ( $cat ) {
+ $category = get_record("glossary_categories","id",$cat);
+ }
+ if ( !$category ) {
+ $cat = "";
+ }
+ }
}
- require_login($course->id);
-
- add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id", "$glossary->id");
-
-/// Print the page header
+/// Printing the page header
if ($course->category) {
$navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
}
- $strglossaries = get_string("modulenameplural", "glossary");
- $strglossary = get_string("modulename", "glossary");
- $strselectletter = get_string("selectletter", "glossary");
- $strspecial = get_string("special", "glossary");
- $strallentries = get_string("allentries", "glossary");
- $strnoentries = get_string("noentries", "glossary");
- $straddentry = get_string("addentry", "glossary");
- $streditentry = get_string("editentry", "glossary");
- $strdeleteentry = get_string("deleteentry", "glossary");
+ $strglossaries = get_string("modulenameplural", "glossary");
+ $strglossary = get_string("modulename", "glossary");
+ $strallcategories= get_string("allcategories", "glossary");
+ $straddentry = get_string("addentry", "glossary");
+ $strnoentries = get_string("noentries", "glossary");
print_header("$course->shortname: $glossary->name", "$course->fullname",
"$navigation <A HREF=index.php?id=$course->id>$strglossaries</A> -> $glossary->name",
"", "", true, update_module_button($cm->id, $course->id, $strglossary),
navmenu($course, $cm));
-/// Print the main part of the page
-
-/// Printing the navigation links (letters to look for)
+/// Printing the header of the glossary
echo "<p><center><b>$glossary->name<p>" ;
- if ( !$course->visible ) {
- notice(get_string("activityiscurrentlyhidden"));
- }
-
print_simple_box_start("center", "70%");
- echo "<CENTER>$strselectletter";
-
- ?>
- <form method="POST" action="view.php">
- <? p(get_string("searchconcept","glossary")) ?> <input type="text" name="search" size="20" value=""> <br><? p(get_string("searchindefinition","glossary")) ?> <input type="checkbox" name="includedefinition" value="1">
- <input type="submit" value="Search" name="searchbutton">
- <input type="hidden" name="id" value="<? p($cm->id) ?>">
- </form>
- <?
-
- if ( $glossary->showspecial ) {
- echo "<p><a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$id&l=SPECIAL\">$strspecial</a> | ";
- }
-
- if ( $glossary->showalphabet ) {
- $alphabet = explode("|", get_string("alphabet","glossary"));
- $letters_by_line = 14;
- for ($i = 0; $i < count($alphabet); $i++) {
- echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$id&l=$alphabet[$i]\">$alphabet[$i]</a>";
- if ((int) ($i % $letters_by_line) != 0 or $i == 0) {
- echo " | ";
- } else {
- echo "<br>";
- }
+ echo "<table width=100% border=0><tr><td width=50% align=right>";
+ ?>
+ <form method="POST" action="view.php">
+ <? p(get_string("searchconcept","glossary")) ?> <input type="text" name="search" size="20" value=""> <br><? p(get_string("searchindefinition","glossary")) ?> <input type="checkbox" name="includedefinition" value="1">
+ <input type="submit" value="Search" name="searchbutton">
+ <input type="hidden" name="id" value="<? p($cm->id) ?>">
+ </form>
+ <?
+ echo "</td><td valign=top align=right width=50%>";
+ if (isteacher($course->id) or $glossary->studentcanpost) {
+ $options = array ("id" => "$cm->id");
+ print_single_button("edit.php", $options, $straddentry );
}
- }
-
- if ( $glossary->showall ) {
- echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$id&l=ALL\">$strallentries</a></p>";
- }
-
- if (isteacher($course->id) or $glossary->studentcanpost) {
- $options = array ("id" => "$cm->id");
- echo "<CENTER>";
- print_single_button("edit.php", $options, $straddentry );
- echo "</CENTER>";
- }
-
+ echo "</td></tr></table>";
print_simple_box_end();
echo "<p align=center>";
- if ($l) {
- $CurrentLetter = "";
- if ($l == "ALL" or $l == "SPECIAL") {
- if ( $l == "ALL" ) {
- echo "<h2>$strallentries</h2><p>";
- } elseif ($l == "SPECIAL") {
- echo "<h2>$strspecial</h2><p>";
- }
- }
- } elseif( $search ) {
- echo get_string("search") . ": $search";
- }
-
- $data[0]->link = "view.php?id=$id&l=$l&eid=$eid&search=$search&includedefinition=$includedefinition";
+ $data[0]->link = "view.php?id=$id";
$data[0]->caption = get_string("standardview","glossary");
- $data[1]->link = "view.php?id=$id&l=$l&eid=$eid&search=$search&includedefinition=$includedefinition¤tview=categories&cat=$cat";
+ $data[1]->link = "view.php?id=$id¤tview=categories";
$data[1]->caption = get_string("categoryview","glossary");
-
- $tCFG->TabTableBGColor = $THEME->cellcontent2;
- $tCFG->TabTableWidth = "70%";
- $tCFG->ActiveTabColor = $THEME->cellcontent2;
- $tCFG->InactiveTabColor = $THEME->cellheading2;
- $tCFG->TabsPerRow = 5;
- $tCFG->TabSeparation = 4;
-
- if ( $cat ) {
+
+ if ( $currentview ) {
$CurrentTab = 1;
} else {
$CurrentTab = 0;
}
print_tabbed_table_start($data, $CurrentTab, $tCFG);
echo "<center>";
- if ( $cat ) {
- echo "<b>$category->name</b><hr>";
+ if ( $currentview ) {
+ glossary_print_categories_menu($course, $cm, $glossary, $category);
+ } else {
+ glossary_print_alphabet_menu($cm, $glossary, $l);
+
+ if ($l) {
+ $CurrentLetter = "";
+ } elseif( $search ) {
+ echo "<h3>" . get_string("search") . ": $search</h3>";
+ }
+
+ echo "<hr>";
}
/// Printing the entries
$DumpedDefinitions= 0;
foreach ($allentries as $entry) {
$DumpToScreen = 0;
- $FirstLetter = strtoupper( ltrim( $entry->concept[0] ) );
+ $FirstLetter = strtoupper( substr(ltrim($entry->concept),0,strlen($l) ) );
if ( $l ) {
if ( $l == "ALL" or $FirstLetter == $l) {
- if ( $CurrentLetter != $FirstLetter ) {
- $CurrentLetter = $FirstLetter;
+ if ( $CurrentLetter != $FirstLetter[0] ) {
+ $CurrentLetter = $FirstLetter[0];
if ( $glossary->displayformat == 0 ) {
if ( $DumpedDefinitions > 0) {
}
echo "\n<center><TABLE BORDER=0 CELLSPACING=0 width=95% valign=top cellpadding=10><tr><td align=center BGCOLOR=\"$THEME->cellheading2\">";
}
- echo "<b>$CurrentLetter</b>";
+ if ( $l == "ALL" ) {
+ echo "<b>$CurrentLetter</b>";
+ }
if ( $glossary->displayformat == 0 ) {
echo "\n</center></td></tr></TABLE></center>";
$DumpToScreen = 1;
}
} else {
- $DumpToScreen = 1;
+ if ( $currentview ) {
+ if ( $category ) {
+ if ( record_exists("glossary_entries_categories","entryid",$entry->id, "categoryid",$category->id) ) {
+ $DumpToScreen = 1;
+ }
+ } else {
+ if ( ! record_exists("glossary_entries_categories","entryid",$entry->id) ) {
+ $DumpToScreen = 1;
+ }
+ }
+ } else {
+ $DumpToScreen = 1;
+ }
}
if ( $DumpToScreen ) {
$entry->concept = highlight($search,$concept);
$entry->definition = highlight($search,$definition);
}
- glossary_print_entry($course, $cm, $glossary, $entry);
+ glossary_print_entry($course, $cm, $glossary, $entry,$currentview,$cat);
if ( $glossary->displayformat != 0 ) {
echo "<p>";