Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

- Now the entries could be categorized.

- Any entry could belongs to many categories
- Improved main page and add entry look.
- Added PostgreSQL7 squema (Thanks Janne Mikkonen!)
- Deleting entries also delete its attachments if any.
  • Loading branch information...
commit fb443f1acffe509fd4356b23ab2434fb3823b9ea 1 parent e457648
authored September 21, 2003
15  lang/en/glossary.php
@@ -3,21 +3,31 @@
3 3
 
4 4
 $string['addentry'] = "Add entry";
5 5
 $string['allentries'] = "ALL";
  6
+$string['allcategories'] = "All Categories";
6 7
 $string['allowduplicatedentries'] = "Duplicated entries allowed";
7 8
 $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";
8  
-$string['areyousuredelete'] = "Are you sure you want to delete this entry?";
  9
+$string['areyousuredelete'] = "Are you sure you want to delete it?";
9 10
 $string['attachment'] = "Attachment";
10  
-$string['categoryview'] = "By Category";
  11
+$string['back'] = "Back";
  12
+$string['categories'] = "Categories";
  13
+$string['categoryview'] = "By category";
  14
+$string['category'] = "Category";
  15
+$string['categorydeleted'] = "Category deleted";
11 16
 $string['concept'] = "Concept";
12 17
 $string['concepts'] = "Concepts";
13 18
 $string['definition'] = "Definition";
14 19
 $string['definitions'] = "Definitions";
15 20
 $string['deleteentry'] = "Delete entry";
  21
+$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.";
16 22
 $string['displayformat'] = "Display format";
17 23
 $string['displayformatdefault'] = "Simple, dictionary style";
18 24
 $string['displayformat1'] = "Full without author.";
19 25
 $string['displayformat2']  = "Full with author.";
  26
+$string['entries'] = "Entries";
  27
+$string['entrieswithoutcategory'] = "Entries without category";
  28
+$string['entry'] = "Entry";
20 29
 $string['editentry'] = "Edit entry";
  30
+$string['editcategories'] = "Edit categories";
21 31
 $string['entryalreadyexist'] = "Entry already exist.";
22 32
 $string['entrydeleted'] = "Entry deleted.";
23 33
 $string['entryexported'] = "Entry succesfully exported.";
@@ -27,6 +37,7 @@
27 37
 $string['modulename'] = "Glossary";
28 38
 $string['modulenameplural'] = "Glossaries";
29 39
 $string['newglossaryentries'] = "New glossary entries:";
  40
+$string['nocategorized'] = "No categorized";
30 41
 $string['noentries'] = "No entries found in this section";
31 42
 $string['noentry'] = "No entry found.";
32 43
 $string['searchconcept'] = "Search:";
13  lang/es/glossary.php
@@ -3,21 +3,31 @@
3 3
 
4 4
 $string['addentry'] = "Agregar entrada";
5 5
 $string['allentries'] = "TODAS";
  6
+$string['allcategories'] = "Todas las categorías";
6 7
 $string['allowduplicatedentries'] = "Permitir entradas duplicadas";
7 8
 $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";
8  
-$string['areyousuredelete'] = "¿Está seguro que desea borrar esta entrada?";
  9
+$string['areyousuredelete'] = "¿Está seguro que desea borrarla?";
9 10
 $string['attachment'] = "Adjunto";
  11
+$string['back'] = "Volver";
  12
+$string['categories'] = "Categorías";
10 13
 $string['categoryview'] = "Vista por Categoría";
  14
+$string['category'] = "Categoría";
  15
+$string['categorydeleted'] = "Categoría eliminada";
11 16
 $string['concept'] = "Concepto";
12 17
 $string['concepts'] = "Conceptos";
13 18
 $string['definition'] = "Definición";
14 19
 $string['definitions'] = "Definiciones";
15 20
 $string['deleteentry'] = "Borrar entrada";
  21
+$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.";
16 22
 $string['displayformat'] = "Formato de muestra de entradas";
17 23
 $string['displayformatdefault'] = "Simple, estilo diccionario";
18 24
 $string['displayformat1'] = "Completo sin autor.";
19 25
 $string['displayformat2'] = "Completo con autor.";
20 26
 $string['editentry'] = "Editar entrada";
  27
+$string['editcategories'] = "Editar categorías";
  28
+$string['entries'] = "Entradas";
  29
+$string['entrieswithoutcategory'] = "Entradas sin categoría";
  30
+$string['entry'] = "Entrada";
21 31
 $string['entryalreadyexist'] = "Esta entrada ya existe.";
22 32
 $string['entrydeleted'] = "Entrada borrada.";
23 33
 $string['entryexported'] = "Entrada exportada con éxito.";
@@ -27,6 +37,7 @@
27 37
 $string['modulename'] = "Glosario";
28 38
 $string['modulenameplural'] = "Glosarios";
29 39
 $string['newglossaryentries'] = "Nuevas entradas en el glosario:";
  40
+$string['nocategorized'] = "Sin categoría";
30 41
 $string['noentries'] = "No se encontraro entradas en esta sección";
31 42
 $string['noentry'] = "No se econtró ninguna entrada.";
32 43
 $string['searchconcept'] = "Buscar:";
16  mod/glossary/db/mysql.php
@@ -49,18 +49,10 @@ function glossary_upgrade($oldversion) {
49 49
                     `entryid` INT(10) UNSIGNED NOT NULL default '0',
50 50
                     PRIMARY KEY  (`categoryid`, `entryid`)
51 51
                     ) TYPE=MyISAM COMMENT='categories of each glossary entry'");
52  
-                    
53  
-          // creating a default category for every glossary
54  
-        execute_sql("INSERT INTO `{$CFG->prefix}glossary_categories` (`glossaryid`, `name`)
55  
-                    SELECT `id`, '" . get_string("main","glossary") . "' FROM `{$CFG->prefix}glossary`");
56  
-                    
57  
-
58  
-          // setting the default category for every entry.
59  
-        execute_sql("INSERT INTO `{$CFG->prefix}glossary_entries_categories` (`categoryid`, `entryid`)
60  
-                    SELECT c.id, e.id
61  
-                    FROM `{$CFG->prefix}glossary_entries` e, `{$CFG->prefix}glossary_categories` c
62  
-                    WHERE e.glossaryid = c.glossaryid");
63  
-
  52
+     }
  53
+     
  54
+     if ( $oldversion < 2003092100 ) {
  55
+          execute_sql("ALTER TABLE `{$CFG->prefix}glossary_entries_categories` CHANGE `categoryid` `categoryid` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL ");
64 56
      }
65 57
 
66 58
     return true;
2  mod/glossary/db/mysql.sql
@@ -58,7 +58,7 @@ CREATE TABLE prefix_glossary_categories (
58 58
 #
59 59
 
60 60
 CREATE TABLE prefix_glossary_entries_categories (
61  
-     categoryid int(10) unsigned NOT NULL default '1',
  61
+     categoryid int(10) unsigned NOT NULL default '0',
62 62
      entryid int(10) unsigned NOT NULL default '0',
63 63
      PRIMARY KEY  (categoryid, entryid)
64 64
 ) TYPE=MyISAM COMMENT='categories of each glossary entry';
13  mod/glossary/db/postgres7.php
... ...
@@ -0,0 +1,13 @@
  1
+<?php
  2
+
  3
+function glossary_upgrade($oldversion) {
  4
+/// This function does anything necessary to upgrade 
  5
+/// older versions to match current functionality 
  6
+
  7
+    global $CFG;
  8
+
  9
+
  10
+    return true;
  11
+}
  12
+
  13
+?>
79  mod/glossary/db/postgres7.sql
... ...
@@ -0,0 +1,79 @@
  1
+# This file contains a complete database schema for all the 
  2
+# tables used by this module, written in SQL
  3
+
  4
+# It may also contain INSERT statements for particular data 
  5
+# that may be used, especially new entries in the table log_display
  6
+
  7
+#
  8
+# Table structure for table `glossary`
  9
+#
  10
+
  11
+CREATE TABLE prefix_glossary (
  12
+     id SERIAL,
  13
+     course int4 NOT NULL default '0',
  14
+     name varchar(255) NOT NULL default '',
  15
+     studentcanpost int2 NOT NULL default '0',
  16
+     allowduplicatedentries int2 NOT NULL default '0',
  17
+     displayformat int2 NOT NULL default '0',
  18
+     mainglossary int2 NOT NULL default '0',
  19
+     showspecial int2 NOT NULL default '1',
  20
+     showalphabet int2 NOT NULL default '1',
  21
+     showall int2 NOT NULL default '1',
  22
+     timecreated int4 NOT NULL default '0',
  23
+     timemodified int4 NOT NULL default '0',
  24
+     PRIMARY KEY  (id)
  25
+);
  26
+
  27
+#
  28
+# Table structure for table `glossary_entries`
  29
+#
  30
+
  31
+CREATE TABLE prefix_glossary_entries (
  32
+     id SERIAL,
  33
+     glossaryid int4 NOT NULL default '0',
  34
+     userid int4 NOT NULL default '0',
  35
+     concept varchar(255) NOT NULL default '',
  36
+     definition text NOT NULL,
  37
+     format int2 NOT NULL default '0',
  38
+     attachment VARCHAR(100) NOT NULL default '',
  39
+     timecreated int4 NOT NULL default '0',
  40
+     timemodified int4 NOT NULL default '0',
  41
+     teacherentry int2 NOT NULL default '0',
  42
+     PRIMARY KEY(id)
  43
+);
  44
+
  45
+#
  46
+# Table structure for table `glossary_cageories`
  47
+#
  48
+
  49
+CREATE TABLE prefix_glossary_categories (
  50
+     id SERIAL,
  51
+     glossaryid int4 NOT NULL default '0',
  52
+     name varchar(255) NOT NULL default '',
  53
+     PRIMARY KEY  (id)
  54
+);
  55
+
  56
+#
  57
+# Table structure for table `glossary_entries_category`
  58
+#
  59
+
  60
+CREATE TABLE prefix_glossary_entries_categories (
  61
+     categoryid int4 NOT NULL default '0',
  62
+     entryid int4 NOT NULL default '0',
  63
+     PRIMARY KEY  (categoryid, entryid)
  64
+);
  65
+
  66
+#
  67
+# Dumping data for table `log_display`
  68
+#
  69
+
  70
+INSERT INTO prefix_log_display VALUES ('glossary', 'add', 'glossary', 'name');
  71
+INSERT INTO prefix_log_display VALUES ('glossary', 'update', 'glossary', 'name');
  72
+INSERT INTO prefix_log_display VALUES ('glossary', 'view', 'glossary', 'name');
  73
+INSERT INTO prefix_log_display VALUES ('glossary', 'view all', 'glossary', 'name');
  74
+INSERT INTO prefix_log_display VALUES ('glossary', 'add entry', 'glossary', 'name');
  75
+INSERT INTO prefix_log_display VALUES ('glossary', 'update entry', 'glossary', 'name');
  76
+INSERT INTO prefix_log_display VALUES ('glossary', 'add category', 'glossary', 'name');
  77
+INSERT INTO prefix_log_display VALUES ('glossary', 'update category', 'glossary', 'name');
  78
+INSERT INTO prefix_log_display VALUES ('glossary', 'delete category', 'glossary', 'name');
  79
+
2  mod/glossary/deleteentry.html
@@ -4,6 +4,8 @@
4 4
 <input type="hidden" name=mode         value="delete">
5 5
 <input type="hidden" name=go       value="1">
6 6
 <input type="hidden" name=entry         value="<?php echo $entry ?>">
  7
+<input type="hidden" name=currentview value="<?=$currentview ?>">
  8
+<input type="hidden" name=cat value="<?=$cat ?>">
7 9
 
8 10
 <input type="submit" value=" <?php print_string("yes")?> "> 
9 11
 <input type=button value=" <?php print_string("no")?> " onclick="javascript:history.go(-1);">
28  mod/glossary/deleteentry.php
@@ -50,24 +50,38 @@
50 50
 	if ( isteacher($cm->id) or $glossary->studentcanpost ) {
51 51
 		if ($go) {	// the operation was confirmed.
52 52
 			if ( $mode == "delete") {
  53
+				glossary_delete_old_attachments($entry);
53 54
 				delete_records("glossary_entries","id", $entry);				
54 55
 				print_simple_box_start("center","40%", "#FFBBBB");
55 56
 				echo "<center>$entrydeleted"; //CAMBIAR
56 57
 				echo "</center>";
57 58
 				print_simple_box_end();
58  
-			} elseif ($mode == "edit") {
59 59
 			}
60 60
     			print_footer($course);
61  
-                  add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id", $entry);
62  
-			redirect("view.php?id=$cm->id");
  61
+                  add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id&currentview=$currentview&cat=$cat", $entry);
  62
+			redirect("view.php?id=$cm->id&currentview=$currentview&cat=$cat");
63 63
 		} else {		// the operation has not been confirmed yet so ask the user to do so
64 64
 			if ( $mode == "delete") {				
65 65
 				print_simple_box_start("center","40%", "#FFBBBB");
66  
-				echo "<center><b>$entryfields->concept</b><br>$strareyousuredelete"; //CAMBIAR
67  
-				include("deleteentry.html");
68  
-				echo "</center>";
  66
+				echo "<center><b>$entryfields->concept</b><br>$strareyousuredelete";
  67
+				
  68
+				?>
  69
+                    <form name="form" method="post" action="deleteentry.php">
  70
+
  71
+                    <input type="hidden" name=id 		   value="<?php p($cm->id) ?>">
  72
+                    <input type="hidden" name=mode         value="delete">
  73
+                    <input type="hidden" name=go       value="1">
  74
+                    <input type="hidden" name=entry         value="<?php p($entry) ?>">
  75
+                    <input type="hidden" name=currentview value=<? p($currentview) ?>>
  76
+                    <input type="hidden" name=cat=<? p($cat) ?>>
  77
+
  78
+                    <input type="submit" value=" <?php print_string("yes")?> ">
  79
+                    <input type=button value=" <?php print_string("no")?> " onclick="javascript:history.go(-1);">
  80
+
  81
+                    </form>
  82
+               	</center>
  83
+               	<?
69 84
 				print_simple_box_end();
70  
-			} elseif ($mode == "edit") {
71 85
 			}
72 86
 		} 
73 87
 	} else {
35  mod/glossary/edit.html
@@ -11,6 +11,31 @@
11 11
     </td>
12 12
 </tr>
13 13
 <tr valign=top>
  14
+    <td align=right><p><b><?php echo get_string("categories","glossary") ?>:</b></p></td>
  15
+    <td>	
  16
+	<?
  17
+		$categories = get_records("glossary_categories","glossaryid",$glossary->id);
  18
+		echo "<select size=\"";
  19
+		if ( count($categories) > 7 ) {
  20
+			echo 7;
  21
+		}else {
  22
+			echo count($categories);
  23
+		}
  24
+		echo "\" name=\"categories[]\" multiple=\"yes\">";
  25
+
  26
+		foreach ( $categories as $category ) {
  27
+			echo "  <option ";
  28
+
  29
+			if ( record_exists("glossary_entries_categories","entryid",$entry->id,"categoryid",$category->id) ) {
  30
+				echo "selected " ;
  31
+			}
  32
+			echo "value=\"$category->id\">$category->name</option>\n";
  33
+		}
  34
+	?>
  35
+	</select>
  36
+    </td>
  37
+</tr>
  38
+<tr valign=top>
14 39
     <td align=right><p><b><? echo get_string("definition","glossary") ?>:</b></p>
15 40
     <font size="1">
16 41
      <?php
@@ -37,9 +62,6 @@
37 62
            $form->format = $defaultformat;
38 63
        }
39 64
        choose_from_menu(format_text_menu(), "format", $entry->format, ""); 
40  
-	 if ($entry->id) {
41  
-		echo "<input type=\"hidden\" name=entry value=\"$entry->id\">";
42  
-   	 }
43 65
        echo "</p>";
44 66
     ?>
45 67
     </td>
@@ -58,7 +80,14 @@
58 80
 <tr>
59 81
 <td colspan=2>
60 82
 	<p align=center>
  83
+	<? if ($entry->id) {
  84
+		echo "<input type=\"hidden\" name=entry value=\"$entry->id\">";
  85
+   	 }
  86
+	?>
61 87
 	<input type="hidden" name=id value="<?=$cm->id ?>">
  88
+	<input type="hidden" name=currentview value="<?=$currentview ?>">
  89
+	<input type="hidden" name=cat value="<?=$cat ?>">
  90
+
62 91
 	<input type="submit" value="<? print_string("savechanges") ?>">
63 92
 	<input type="reset" value="<? print_string("revert") ?>">
64 93
 	</P>
16  mod/glossary/edit.php
@@ -7,6 +7,9 @@
7 7
 require_variable($id);    // Course Module ID
8 8
 optional_variable($e);    // EntryID
9 9
 
  10
+optional_variable($currentview);   // categories if by category?
  11
+optional_variable($cat);    // CategoryID
  12
+
10 13
 if (! $cm = get_record("course_modules", "id", $id)) {
11 14
     error("Course Module ID was incorrect");
12 15
 }
@@ -110,14 +113,23 @@
110 113
                               }
111 114
                               set_field("glossary_entries", "attachment", $newfilename, "id", $newentry->id);
112 115
 
113  
-                              add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&eid=$newentry->id", "$newentry->id");
  116
+                              add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&eid=$newentry->id&currentview=$currentview&cat=$cat", "$newentry->id");
114 117
                        }
115 118
                 } else {
116 119
                     error("Could not insert this glossary entry because this concept already exist.");
117 120
                 }
118 121
           }
119 122
 
120  
-          redirect("view.php?id=$cm->id&eid=$newentry->id");
  123
+           delete_records("glossary_entries_categories","entryid",$entry);
  124
+
  125
+           if ( $categories ) {
  126
+                $newcategory->entryid = $newentry->id;
  127
+                foreach ($categories as $category) {
  128
+                    $newcategory->categoryid =$category;
  129
+                    insert_record("glossary_entries_categories",$newcategory);
  130
+                }
  131
+           }
  132
+          redirect("view.php?id=$cm->id&eid=$newentry->id&currentview=$currentview&cat=$cat");
121 133
           die;
122 134
      }
123 135
 }
30  mod/glossary/editcategories.html
... ...
@@ -0,0 +1,30 @@
  1
+<?
  2
+	global $CFG, $THEME;
  3
+    	require_once("../../config.php");
  4
+
  5
+?>
  6
+
  7
+<FORM name="form" method="post" <?=$onsubmit ?> action="editcategories.php">
  8
+<table  class=generalbox cellpadding=5 bgcolor="<? p($THEME->cellheading)?>">
  9
+<tr valign=top>
  10
+    <td align=right><p><b><?php echo get_string("name") ?>:</b></p></td>
  11
+    <td>
  12
+        <INPUT type="text" name="name" size=30 value="<?=$name ?>">
  13
+    </td>
  14
+</tr>
  15
+<td colspan=2>
  16
+	<p align=center>
  17
+	<input type="hidden" name=id value="<?=$cm->id ?>">
  18
+	<input type="hidden" name=action value="<?=$action?>">
  19
+	<input type="hidden" name=confirm value=1>
  20
+	<input type="hidden" name=cat value=<? p($cat) ?>>
  21
+	<input type="submit" value="<? print_string("savechanges") ?>">
  22
+	<input type="reset" value="<? print_string("back","glossary") ?>"  onclick="javascript:history.go(-1);">
  23
+	</P>
  24
+</td>
  25
+</tr>
  26
+</table>
  27
+</p>
  28
+
  29
+
  30
+</form>
233  mod/glossary/editcategories.php
... ...
@@ -0,0 +1,233 @@
  1
+<?PHP  // $Id$
  2
+
  3
+/// This page allows to edit entries categories for a particular instance of glossary
  4
+
  5
+    require_once("../../config.php");
  6
+    require_once("lib.php");
  7
+
  8
+     require_variable($id);    // Course Module ID, or
  9
+     optional_variable($cat);  // category ID
  10
+     optional_variable($action);  // what to do
  11
+     optional_variable($confirm);  // confirm the action
  12
+
  13
+     optional_variable($name);  // confirm the action
  14
+
  15
+     $action = strtolower($action);
  16
+    	
  17
+    if (! $cm = get_record("course_modules", "id", $id)) {
  18
+        error("Course Module ID was incorrect");
  19
+    }
  20
+
  21
+    if (! $course = get_record("course", "id", $cm->course)) {
  22
+        error("Course is misconfigured");
  23
+    }
  24
+
  25
+    if (! $glossary = get_record("glossary", "id", $cm->instance)) {
  26
+        error("Course module is incorrect");
  27
+    }
  28
+
  29
+    require_login($course->id);
  30
+
  31
+     if ( !isteacher($course->id) ) {
  32
+        error("You must be a teacher to use this page.");
  33
+     }
  34
+
  35
+//    add_to_log($course->id, "glossary", "edit categories", "view.php?id=$cm->id", "$glossary->id");
  36
+
  37
+    if ($course->category) {
  38
+        $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
  39
+    }
  40
+
  41
+    $strglossaries   = get_string("modulenameplural", "glossary");
  42
+    $strglossary     = get_string("modulename", "glossary");
  43
+
  44
+    print_header("$course->shortname: $glossary->name", "$course->fullname",
  45
+                 "$navigation <A HREF=index.php?id=$course->id>$strglossaries</A> -> $glossary->name",
  46
+                  "", "", true, update_module_button($cm->id, $course->id, $strglossary),
  47
+                  navmenu($course, $cm));
  48
+
  49
+     if ( $cat ) {
  50
+          $category = get_record("glossary_categories","id",$cat);
  51
+
  52
+          if ( $action == "edit" ) {
  53
+               if ( $confirm ) {
  54
+                    $action = "";
  55
+                    $CategoryObject->id = $cat;
  56
+                    $CategoryObject->name = $name;
  57
+
  58
+                    if ( !update_record("glossary_categories", $CategoryObject) ) {
  59
+     				error("Weird error. The category was not updated.");
  60
+              			
  61
+          			redirect("editcategories.php?id=$cm->id");
  62
+                    }
  63
+                    
  64
+               } else {
  65
+                    echo "<p align=\"center\">" . get_string("edit"). " " . get_string("category","glossary") . "<font size=\"3\">";
  66
+
  67
+                    $name = $category->name;
  68
+                    require "editcategories.html";
  69
+                    print_footer();
  70
+                    die;
  71
+               }
  72
+          } elseif ( $action == "delete" ) {
  73
+               if ( $confirm ) {
  74
+               
  75
+				delete_records("glossary_entries_categories","categoryid", $cat);
  76
+                    delete_records("glossary_categories","id", $cat);
  77
+				
  78
+				print_simple_box_start("center","40%", "#FFBBBB");
  79
+				echo "<center>" . get_string("categorydeleted","glossary") ."</center>";
  80
+				echo "</center>";
  81
+				print_simple_box_end();
  82
+				
  83
+         			print_footer($course);
  84
+
  85
+                    add_to_log($course->id, "glossary", "delete category", "editcategories.php?id=$cm->id", $cat);
  86
+                    
  87
+     			redirect("editcategories.php?id=$cm->id");
  88
+               } else {
  89
+                    echo "<p align=\"center\">" . get_string("delete"). " " . get_string("category","glossary") . "<font size=\"3\">";
  90
+
  91
+     			print_simple_box_start("center","40%", "#FFBBBB");
  92
+     			echo "<center><b>$category->name</b><br>";
  93
+     			
  94
+     			$num_entries = count_records("glossary_entries_categories","categoryid",$category->id);
  95
+                    if ( $num_entries ) {
  96
+                         print_string("deletingnoneemptycategory","glossary");
  97
+                    }
  98
+                    echo "<p>";
  99
+                    print_string("areyousuredelete","glossary");
  100
+                    
  101
+                    ?>
  102
+                    <form name="form" method="post" action="editcategories.php">
  103
+
  104
+                    <input type="hidden" name=id 		   value="<?php p($cm->id) ?>">
  105
+                    <input type="hidden" name=action      value="delete">
  106
+                    <input type="hidden" name=confirm     value="1">
  107
+                    <input type="hidden" name=cat         value="<?php echo $cat ?>">
  108
+                    <table border=0 widTH=100><tr><td align=right width=50%>
  109
+                    <input type="submit" value=" <?php print_string("yes")?> ">
  110
+                    </form>
  111
+                    </td><td align=left width=50%>
  112
+                    <?
  113
+                    unset($options);
  114
+                    $options = array ("id" => $id);
  115
+                    print_single_button("editcategories.php", $options, get_string("no") );
  116
+                    echo "</td></tr></table>";
  117
+     			echo "</center>";
  118
+     			print_simple_box_end();
  119
+               }
  120
+          }
  121
+     } elseif ( $action == "add" ) {
  122
+          if ( $confirm ) {
  123
+               $dupcategory = get_record("glossary_categories","lcase(name)",strtolower($name));
  124
+               if ( $dupcategory ) {
  125
+                    echo "<p align=\"center\">" . get_string("add"). " " . get_string("category","glossary") . "<font size=\"3\">";
  126
+                    
  127
+				print_simple_box_start("center","40%", "#FFBBBB");
  128
+				echo "<center>" . get_string("duplicatedcategory","glossary") ."</center>";
  129
+				echo "</center>";
  130
+				print_simple_box_end();
  131
+				
  132
+         			print_footer($course);
  133
+
  134
+     			redirect("editcategories.php?id=$cm->id&action=add&&name=$name");
  135
+
  136
+               } else {
  137
+                    $action = "";
  138
+                    $CategoryObject->name = $name;
  139
+                    $CategoryObject->glossaryid = $glossary->id;
  140
+
  141
+                    if ( ! $CategoryObject->id = insert_record("glossary_categories", $CategoryObject) ) {
  142
+     				error("Weird error. The category was not inserted.");
  143
+              			
  144
+          			redirect("editcategories.php?id=$cm->id");
  145
+                    } else {
  146
+                         add_to_log($course->id, "glossary", "add category", "editcategories.php?id=$cm->id", $cat);
  147
+                    }
  148
+             }
  149
+          } else {
  150
+               echo "<p align=\"center\">" . get_string("add"). " " . get_string("category","glossary") . "<font size=\"3\">";
  151
+               $name="";
  152
+               require "editcategories.html";
  153
+          }
  154
+     }
  155
+     
  156
+     if ( $action ) {
  157
+
  158
+          print_footer();
  159
+          die;
  160
+     }
  161
+
  162
+?>
  163
+
  164
+
  165
+<p align="center"><? p(get_string("edit")) ?> <? p(get_string("categories","glossary")) ?><font size="3">
  166
+
  167
+<FORM name="theform" method="post" <?=$onsubmit ?> action="editcategories.php">
  168
+<table width="40%" class=generalbox cellpadding=5 bgcolor="<? p($THEME->cellheading)?>">
  169
+        <tr>
  170
+          <td width="90%" align="center"><b>
  171
+          <? p(get_string("categories","glossary")) ?></b></td>
  172
+          <td width="10%" align="center"><b>
  173
+          <? p(get_string("action")) ?></b></td>
  174
+        </tr>
  175
+        <tr><td width=100% colspan=2  bgcolor="<? p($THEME->cellheading2)?>">
  176
+        
  177
+        <table width=100%>
  178
+<?
  179
+     $categories = get_records("glossary_categories","glossaryid",$glossary->id,"name ASC");
  180
+
  181
+     if ( $categories ) {
  182
+          foreach ($categories as $category) {
  183
+               $num_entries = count_records("glossary_entries_categories","categoryid",$category->id);
  184
+             ?>
  185
+             <tr bgcolor="<? p($THEME->cellheading2)?>">
  186
+               <td width="90%" align="left">
  187
+               <?
  188
+                    echo "<b>$category->name</b> <font size=-1>($num_entries " . get_string("entries","glossary") . ")</font>";
  189
+               ?>
  190
+               </td>
  191
+               <td width="10%" align="center"><b>
  192
+               <?
  193
+          		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> ";
  194
+          	  	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>";
  195
+               ?>
  196
+               </b></td>
  197
+             </tr>
  198
+             
  199
+             <?
  200
+          }
  201
+     }
  202
+?>
  203
+        </table>
  204
+        
  205
+        </td>
  206
+        <tr>
  207
+        <td width=100% colspan=2  align=center bgcolor="<? p($THEME->cellheading2)?>">
  208
+            <?
  209
+            
  210
+             $options['id'] = $cm->id;
  211
+             $options['action'] = "add";
  212
+             
  213
+             echo "<table border=0><tr><td align=right>";
  214
+             echo print_single_button("editcategories.php", $options, get_string("add") . " " . get_string("category","glossary"), "get");
  215
+             echo "</td><td align=left>";
  216
+             unset($options['action']);
  217
+             $options['currentview'] = "categories";
  218
+             echo print_single_button("view.php", $options, get_string("back","glossary") );
  219
+             echo "</td></tr>";
  220
+             echo "</tablee>";
  221
+
  222
+            ?>
  223
+        </td>
  224
+        </tr>
  225
+        </table>
  226
+
  227
+</table>
  228
+</p>
  229
+
  230
+
  231
+</form>
  232
+
  233
+<? print_footer() ?>
18  mod/glossary/exportentry.php
@@ -5,6 +5,9 @@
5 5
     	require_variable($id);    // course module ID
6 6
     	require_variable($entry);    // Entry ID
7 7
     	optional_variable($confirm);     // confirmation
  8
+    	optional_variable($currentview);
  9
+    	optional_variable($cat);
  10
+    	
8 11
     	global $THEME, $USER, $CFG;
9 12
 
10 13
 	$PermissionGranted = 1;
@@ -52,8 +55,8 @@
52 55
 			echo "<center>";
53 56
 
54 57
 			notice_yesno ("<center><h2>$entry->concept</h2><p align=center>Seguro que desea agregar esta entrada a<br><b>$mainglossary->name</b>?",
55  
-				"exportentry.php?id=$id&entry=$entry->id&confirm=1",
56  
-				"view.php?id=$cm->id&eid=".$entry->id );
  58
+				"exportentry.php?id=$id&currentview=$currentview&cat=$cat&entry=$entry->id&confirm=1",
  59
+				"view.php?id=$cm->id&currentview=$currentview&cat=$cat&eid=".$entry->id );
57 60
 
58 61
 		} else {
59 62
 			if ( ! $mainglossary->allowduplicatedentries ) {
@@ -86,15 +89,14 @@
86 89
                               }
87 90
                          }
88 91
                          
89  
-                         add_to_log($course->id, "glossary", "add entry",
90  
-                         "view.php?id=$cm->id&eid=".$entry->id, "$newentry->id");
  92
+                         add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&currentview=$currentview&cat=$cat&eid=".$entry->id, "$newentry->id");
91 93
 
92  
-                         print_continue("view.php?id=$cm->id&eid=".$entry->id);
  94
+                         print_continue("view.php?id=$cm->id&currentview=$currentview&cat=$cat&eid=".$entry->id);
93 95
                          print_simple_box_end();
94 96
 
95 97
      					print_footer();
96 98
 
97  
-     	                redirect("view.php?id=$cm->id&eid=".$entry->id);
  99
+     	                redirect("view.php?id=$cm->id&currentview=$currentview&cat=$cat&eid=".$entry->id);
98 100
      	                die;
99 101
 				}
100 102
 			} else {
@@ -102,7 +104,7 @@
102 104
 			    echo "<p align=center><font size=3>$entryalreadyexist</font></p></font>";
103 105
 				echo "<p align=center>";
104 106
 
105  
-				print_continue("view.php?id=$cm->id&eid=".$entry->id);
  107
+				print_continue("view.php?id=$cm->id&currentview=$currentview&cat=$cat&eid=".$entry->id);
106 108
 
107 109
 			    print_simple_box_end();
108 110
 			}
@@ -111,7 +113,7 @@
111 113
 	    	print_simple_box_start("center", "60%", "#FFBBBB");
112 114
 	    	echo "<p align=center><font size=3>A weird error was found while trying to export this entry. Operation cancelled.</font></p></font>";
113 115
 
114  
-			print_continue("view.php?id=$cm->id&eid=".$entry->id);
  116
+			print_continue("view.php?id=$cm->id&currentview=$currentview&cat=$cat&eid=".$entry->id);
115 117
 
116 118
 	    	print_simple_box_end();
117 119
 	}
4  mod/glossary/formats/1.php
... ...
@@ -1,6 +1,6 @@
1 1
 <?PHP  // $Id$
2 2
 
3  
-function glossary_print_entry_by_format($course, $cm, $glossary, $entry) {
  3
+function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$currentview="",$cat="") {
4 4
     global $THEME, $USER;
5 5
 
6 6
 //    if ($entry->timemarked < $entry->modified) {
@@ -30,7 +30,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry) {
30 30
     if ($entry) {
31 31
 	  echo format_text($entry->definition, $entry->format);
32 32
 
33  
-	  glossary_print_entry_icons($course, $cm, $glossary, $entry);
  33
+	  glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview,$cat);
34 34
 
35 35
     } else {
36 36
 	  echo "<center>";
4  mod/glossary/formats/2.php
... ...
@@ -1,7 +1,7 @@
1 1
 <?PHP  // $Id$
2 2
 require_once("lib.php");
3 3
 
4  
-function glossary_print_entry_by_format($course, $cm, $glossary, $entry) {
  4
+function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$currentview="",$cat="") {
5 5
     global $THEME, $CFG, $USER;
6 6
 
7 7
 //    if ($entry->timemarked < $entry->modified) {
@@ -40,7 +40,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry) {
40 40
     if ($entry) {
41 41
 	  echo format_text($entry->definition, $entry->format);
42 42
 
43  
-	  glossary_print_entry_icons($course, $cm, $glossary, $entry);
  43
+	  glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview,$cat);
44 44
 
45 45
     } else {
46 46
 	  echo "<center>";
110  mod/glossary/lib.php
@@ -5,6 +5,13 @@
5 5
 
6 6
 require_once("$CFG->dirroot/files/mimetypes.php");
7 7
 
  8
+$tCFG->TabTableBGColor = $THEME->cellcontent2;
  9
+$tCFG->TabTableWidth = "70%";
  10
+$tCFG->ActiveTabColor = $THEME->cellcontent2;
  11
+$tCFG->InactiveTabColor = $THEME->cellheading2;
  12
+$tCFG->TabsPerRow = 5;
  13
+$tCFG->TabSeparation = 4;
  14
+
8 15
 function glossary_add_instance($glossary) {
9 16
 /// Given an object containing all the necessary data,
10 17
 /// (defined by the form in mod.html) this function
@@ -161,7 +168,7 @@ function glossary_get_entries($glossaryid, $entrylist) {
161 168
                             AND id IN ($entrylist)");
162 169
 }
163 170
 
164  
-function glossary_print_entry($course, $cm, $glossary, $entry) {
  171
+function glossary_print_entry($course, $cm, $glossary, $entry,$currentview="",$cat="") {
165 172
     global $THEME, $USET, $CFG;
166 173
     
167 174
     $PermissionGranted = 0;
@@ -180,14 +187,14 @@ function glossary_print_entry($course, $cm, $glossary, $entry) {
180 187
     }
181 188
     
182 189
     if ( $glossary->displayformat > 0 and $PermissionGranted ) {
183  
-        glossary_print_entry_by_format($course, $cm, $glossary, $entry);
  190
+        glossary_print_entry_by_format($course, $cm, $glossary, $entry,$currentview,$cat);
184 191
     } else {
185  
-        glossary_print_entry_by_default($course, $cm, $glossary, $entry);
  192
+        glossary_print_entry_by_default($course, $cm, $glossary, $entry,$currentview,$cat);
186 193
     }
187 194
 
188 195
 }
189 196
 
190  
-function glossary_print_entry_by_default($course, $cm, $glossary, $entry) {
  197
+function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$currentview="",$cat="") {
191 198
     global $THEME, $USER;
192 199
 
193 200
     $colour = $THEME->cellheading2;
@@ -202,12 +209,12 @@ function glossary_print_entry_by_default($course, $cm, $glossary, $entry) {
202 209
     }
203 210
     echo "<b>$entry->concept</b>: ";
204 211
     echo format_text($entry->definition, $entry->format);
205  
-    glossary_print_entry_icons($course, $cm, $glossary, $entry);
  212
+    glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview,$cat);
206 213
     echo "</td>";
207 214
     echo "</TR>";
208 215
 }
209 216
 
210  
-function glossary_print_entry_icons($course, $cm, $glossary, $entry) {
  217
+function glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview="",$cat="") {
211 218
     global $THEME, $USER;
212 219
 
213 220
 	  if (isteacher($course->id) or $glossary->studentcanpost and $entry->userid == $USER->id) {
@@ -216,12 +223,12 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry) {
216 223
 			$mainglossary = get_record("glossary","mainglossary",1,"course",$course->id);
217 224
 			if ( $mainglossary ) {
218 225
 
219  
-				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> ";
  226
+				echo "<a href=\"exportentry.php?id=$cm->id&entry=$entry->id&currentview=$currentview&cat=$cat\"><img  alt=\"" . get_string("exporttomainglossary","glossary") . "\"src=\"export.gif\" height=11 width=11 border=0></a> ";
220 227
 
221 228
 			}
222 229
 		}
223  
-		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> ";
224  
-	  	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>";
  230
+		echo "<a href=\"deleteentry.php?id=$cm->id&mode=delete&entry=$entry->id&currentview=$currentview&cat=$cat\"><img  alt=\"" . get_string("delete") . "\"src=\"../../pix/t/delete.gif\" height=11 width=11 border=0></a> ";
  231
+	  	echo "<a href=\"edit.php?id=$cm->id&e=$entry->id&currentview=$currentview&cat=$cat\"><img  alt=\"" . get_string("edit") . "\" src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
225 232
 	  }
226 233
 }
227 234
 
@@ -597,4 +604,89 @@ function print_tabbed_table_end() {
597 604
      echo "</center><p></td></tr></table></center>";
598 605
 }
599 606
 
  607
+function glossary_print_alphabet_menu($cm, $glossary, $l) {
  608
+global $CFG, $THEME;
  609
+     $strselectletter = get_string("selectletter", "glossary");
  610
+     $strspecial      = get_string("special", "glossary");
  611
+     $strallentries   = get_string("allentries", "glossary");
  612
+
  613
+     echo "<CENTER>$strselectletter";
  614
+
  615
+      if ( $glossary->showspecial ) {
  616
+          if ( $l == "SPECIAL" ) {
  617
+               echo "<p><b>$strspecial</b> | ";
  618
+          } else {
  619
+               echo "<p><a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=SPECIAL\">$strspecial</a> | ";
  620
+          }
  621
+      }
  622
+
  623
+      if ( $glossary->showalphabet ) {
  624
+           $alphabet = explode("|", get_string("alphabet","glossary"));
  625
+           $letters_by_line = 14;
  626
+           for ($i = 0; $i < count($alphabet); $i++) {
  627
+               if ( $l == $alphabet[$i] ) {
  628
+                    echo "<b>$alphabet[$i]</b>";
  629
+               } else {
  630
+                    echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=$alphabet[$i]\">$alphabet[$i]</a>";
  631
+               }
  632
+               if ((int) ($i % $letters_by_line) != 0 or $i == 0) {
  633
+                    echo " | ";
  634
+               } else {
  635
+                    echo "<br>";
  636
+               }
  637
+           }
  638
+      }
  639
+
  640
+      if ( $glossary->showall ) {
  641
+          if ( $l == "ALL" ) {
  642
+               echo "<b>$strallentries</b></p>";
  643
+          } else {
  644
+               echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=ALL\">$strallentries</a></p>";
  645
+          }
  646
+      }
  647
+}
  648
+function glossary_print_categories_menu($course, $cm, $glossary, $category) {
  649
+global $CFG, $THEME;
  650
+     echo "<table border=0 width=100%>";
  651
+     echo "<tr>";
  652
+
  653
+     echo "<td align=center width=20%>";
  654
+     if ( isteacher($course->id) ) {
  655
+             $options['id'] = $cm->id;
  656
+             $options['cat'] = $cat;
  657
+             echo print_single_button("editcategories.php", $options, get_string("editcategories","glossary"), "get");
  658
+     }
  659
+     echo "</td>";
  660
+
  661
+     echo "<td align=center width=60%>";
  662
+     echo "<b>";
  663
+     if ( $category ) {
  664
+        echo $category->name;
  665
+     } else {
  666
+        echo get_string("entrieswithoutcategory","glossary");
  667
+     }
  668
+     echo "</b></td>";
  669
+     echo "<td align=center width=20%>";
  670
+     $menu[0] = get_string("nocategorized","glossary");
  671
+
  672
+     $categories = get_records("glossary_categories", "glossaryid", $glossary->id, "name ASC");
  673
+     if ( $categories ) {
  674
+          foreach ($categories as $currentcategory) {
  675
+                 $url = $currentcategory->id;
  676
+                 if ($currentcategory->id == $category->id) {
  677
+                     $selected = $url;
  678
+                 }
  679
+                 $menu[$url] = $currentcategory->name;
  680
+          }
  681
+     }
  682
+
  683
+     echo popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&currentview=categories&cat=", $menu, "catmenu", $selected, get_string("jumpto"),
  684
+                      "", "", false);
  685
+
  686
+     echo "</td>";
  687
+     echo "</tr>";
  688
+
  689
+     echo "<tr><td colspan=3><hr></td></tr>";
  690
+     echo "</table>";
  691
+}
600 692
 ?>
2  mod/glossary/version.php
@@ -5,7 +5,7 @@
5 5
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
6 6
 /////////////////////////////////////////////////////////////////////////////////
7 7
 
8  
-$module->version  = 2003091800;  // The current module version (Date: YYYYMMDDXX)
  8
+$module->version  = 2003092100;  // The current module version (Date: YYYYMMDDXX)
9 9
 $module->cron     = 0;           // Period for cron to check this module (secs)
10 10
 
11 11
 $release = "0.3.1 development";   // User-friendly version number
204  mod/glossary/view.php
@@ -15,24 +15,26 @@
15 15
     optional_variable($currentview);  // browsing entries by categories?
16 16
     optional_variable($cat);  // categoryID
17 17
 
18  
-    if ($l == "" and $search == "" and $eid == "") {
19  
-    		$l = "A";
  18
+    if (! $cm = get_record("course_modules", "id", $id)) {
  19
+        error("Course Module ID was incorrect");
20 20
     }
21  
-    
22  
-    if ( $currentview ) {
23  
-          $currentview = strtolower($currentview);
24  
-          if ( !$currentview ) {
25  
-               $currentview = "";
26  
-          } else {
27  
-               if ( !$cat ) {
28  
-                    $cat = 1;
29  
-               }
30  
-               $category = get_record("glossary_categories","id",$cat);
31  
-          }
  21
+
  22
+    if (! $course = get_record("course", "id", $cm->course)) {
  23
+        error("Course is misconfigured");
32 24
     }
33 25
 
34  
-    $search = trim(strip_tags($search));
  26
+    if (! $glossary = get_record("glossary", "id", $cm->instance)) {
  27
+        error("Course module is incorrect");
  28
+    }
  29
+
  30
+    require_login($course->id);
  31
+    if ( !$course->visible ) {
  32
+        notice(get_string("activityiscurrentlyhidden"));
  33
+    }
35 34
 
  35
+    add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id", "$glossary->id");
  36
+
  37
+    $search = trim(strip_tags($search));
36 38
     if ($search and !$entryid ) {
37 39
 	  $l = "";
38 40
         $searchterms = explode(" ", $search);    // Search for words independently
@@ -42,134 +44,92 @@
42 44
             }
43 45
         }
44 46
         $search = trim(implode(" ", $searchterms));
  47
+        $currentview = "";
45 48
     } elseif ( $eid ) {
46  
-	  $search = "";
  49
+         $search = "";
47 50
     }
48  
-
49  
-    if (! $cm = get_record("course_modules", "id", $id)) {
50  
-        error("Course Module ID was incorrect");
51  
-    }
52  
-
53  
-    if (! $course = get_record("course", "id", $cm->course)) {
54  
-        error("Course is misconfigured");
  51
+    if ($l == "" and $search == "" and ($eid == "" or $eid == 0) ) {
  52
+    		$l = "A";
  53
+    } elseif ( $eid ) {
  54
+          $l = "";
55 55
     }
56  
-
57  
-    if (! $glossary = get_record("glossary", "id", $cm->instance)) {
58  
-        error("Course module is incorrect");
  56
+    if ( $currentview ) {
  57
+          $l = "";
  58
+          $currentview = strtolower($currentview);
  59
+          if ( $currentview ) {
  60
+               if ( $cat ) {
  61
+                    $category = get_record("glossary_categories","id",$cat);
  62
+               }
  63
+               if ( !$category ) {
  64
+                    $cat = "";
  65
+               }
  66
+          }
59 67
     }
60 68
 
61  
-    require_login($course->id);
62  
-
63  
-    add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id", "$glossary->id");
64  
-
65  
-/// Print the page header
  69
+/// Printing the page header
66 70
 
67 71
     if ($course->category) {
68 72
         $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
69 73
     }
70 74
 
71  
-    $strglossaries   = get_string("modulenameplural", "glossary");
72  
-    $strglossary     = get_string("modulename", "glossary");
73  
-    $strselectletter = get_string("selectletter", "glossary");
74  
-    $strspecial      = get_string("special", "glossary");
75  
-    $strallentries   = get_string("allentries", "glossary");
76  
-    $strnoentries    = get_string("noentries", "glossary");
77  
-    $straddentry     = get_string("addentry", "glossary");
78  
-    $streditentry    = get_string("editentry", "glossary");
79  
-    $strdeleteentry  = get_string("deleteentry", "glossary");
  75
+     $strglossaries   = get_string("modulenameplural", "glossary");
  76
+     $strglossary     = get_string("modulename", "glossary");
  77
+     $strallcategories= get_string("allcategories", "glossary");
  78
+     $straddentry     = get_string("addentry", "glossary");
  79
+     $strnoentries    = get_string("noentries", "glossary");
80 80
 
81 81
     print_header("$course->shortname: $glossary->name", "$course->fullname",
82 82
                  "$navigation <A HREF=index.php?id=$course->id>$strglossaries</A> -> $glossary->name",
83 83
                   "", "", true, update_module_button($cm->id, $course->id, $strglossary),
84 84
                   navmenu($course, $cm));
85 85
 
86  
-/// Print the main part of the page
87  
-
88  
-/// Printing the navigation links (letters to look for)
  86
+/// Printing the header of the glossary
89 87
 
90 88
     echo "<p><center><b>$glossary->name<p>" ;
91 89
 
92  
-    if ( !$course->visible ) {
93  
-        notice(get_string("activityiscurrentlyhidden"));
94  
-    }
95  
-
96 90
     print_simple_box_start("center", "70%");
97  
-      echo "<CENTER>$strselectletter";
98  
-
99  
-	?>
100  
-	<form method="POST" action="view.php">
101  
-	  <? 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">
102  
-	  <input type="submit" value="Search" name="searchbutton">
103  
-	  <input type="hidden" name="id" value="<? p($cm->id) ?>">
104  
-	</form>
105  
-	<?
106  
-
107  
-      if ( $glossary->showspecial ) {
108  
-          echo "<p><a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$id&l=SPECIAL\">$strspecial</a> | ";
109  
-      }
110  
-
111  
-      if ( $glossary->showalphabet ) {
112  
-           $alphabet = explode("|", get_string("alphabet","glossary"));
113  
-           $letters_by_line = 14;
114  
-           for ($i = 0; $i < count($alphabet); $i++) {
115  
-               echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$id&l=$alphabet[$i]\">$alphabet[$i]</a>";
116  
-               if ((int) ($i % $letters_by_line) != 0 or $i == 0) {
117  
-                    echo " | ";
118  
-               } else {
119  
-                    echo "<br>";
120  
-               }
  91
+          echo "<table width=100% border=0><tr><td width=50% align=right>";
  92
+     	?>
  93
+     	<form method="POST" action="view.php">
  94
+     	  <? 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">
  95
+     	  <input type="submit" value="Search" name="searchbutton">
  96
+     	  <input type="hidden" name="id" value="<? p($cm->id) ?>">
  97
+     	</form>
  98
+     	<?
  99
+          echo "</td><td valign=top align=right width=50%>";
  100
+           if (isteacher($course->id) or $glossary->studentcanpost) {
  101
+              $options = array ("id" => "$cm->id");
  102
+              print_single_button("edit.php", $options, $straddentry );
121 103
            }
122  
-      }
123  
-      
124  
-      if ( $glossary->showall ) {
125  
-          echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$id&l=ALL\">$strallentries</a></p>";
126  
-      }
127  
-      
128  
-      if (isteacher($course->id) or $glossary->studentcanpost) {
129  
-         $options = array ("id" => "$cm->id");
130  
-         echo "<CENTER>";
131  
-         print_single_button("edit.php", $options, $straddentry );
132  
-         echo "</CENTER>";
133  
-      }
134  
-
  104
+           echo "</td></tr></table>";
135 105
     print_simple_box_end();
136 106
 
137 107
     echo "<p align=center>";
138  
-    if ($l) {
139  
-		$CurrentLetter = "";
140  
-		if ($l == "ALL" or $l == "SPECIAL") {
141  
-			if ( $l == "ALL" ) {
142  
-	 			echo "<h2>$strallentries</h2><p>";
143  
-			} elseif ($l == "SPECIAL") {
144  
-	 			echo "<h2>$strspecial</h2><p>";
145  
-			}
146  
-		}
147  
-	} elseif( $search ) {
148  
-		echo get_string("search") . ": $search";
149  
-	}
150  
-
151  
-     $data[0]->link = "view.php?id=$id&l=$l&eid=$eid&search=$search&includedefinition=$includedefinition";
  108
+     $data[0]->link = "view.php?id=$id";
152 109
      $data[0]->caption = get_string("standardview","glossary");
153 110
      
154  
-     $data[1]->link = "view.php?id=$id&l=$l&eid=$eid&search=$search&includedefinition=$includedefinition&currentview=categories&cat=$cat";
  111
+     $data[1]->link = "view.php?id=$id&currentview=categories";
155 112
      $data[1]->caption = get_string("categoryview","glossary");
156  
-     
157  
-     $tCFG->TabTableBGColor = $THEME->cellcontent2;
158  
-     $tCFG->TabTableWidth = "70%";
159  
-     $tCFG->ActiveTabColor = $THEME->cellcontent2;
160  
-     $tCFG->InactiveTabColor = $THEME->cellheading2;
161  
-     $tCFG->TabsPerRow = 5;
162  
-     $tCFG->TabSeparation = 4;
163  
-     
164  
-     if ( $cat ) {
  113
+
  114
+     if ( $currentview ) {
165 115
           $CurrentTab = 1;
166 116
      } else {
167 117
           $CurrentTab = 0;
168 118
      }
169 119
      print_tabbed_table_start($data, $CurrentTab, $tCFG);
170 120
      echo "<center>";
171  
-     if ( $cat ) {
172  
-          echo "<b>$category->name</b><hr>";
  121
+     if ( $currentview ) {
  122
+         glossary_print_categories_menu($course, $cm, $glossary, $category);
  123
+     } else {
  124
+         glossary_print_alphabet_menu($cm, $glossary, $l);
  125
+     
  126
+         if ($l) {
  127
+     		$CurrentLetter = "";
  128
+     	} elseif( $search ) {
  129
+     		echo "<h3>" . get_string("search") . ": $search</h3>";
  130
+     	}
  131
+
  132