]> git.mjollnir.org Git - moodle.git/commitdiff
- Cosmetic changes... Changing the Add Entry button for a new tab
authorwillcast <willcast>
Mon, 3 Nov 2003 02:26:44 +0000 (02:26 +0000)
committerwillcast <willcast>
Mon, 3 Nov 2003 02:26:44 +0000 (02:26 +0000)
- Creating two new tabs for the future export/import features.
- Improving a little the Printer-Friendly version (now it shows what you were watching in the previous frame)

lang/en/glossary.php
mod/glossary/dynalink.php
mod/glossary/edit.html
mod/glossary/edit.php
mod/glossary/export.php
mod/glossary/lib.php
mod/glossary/print.php
mod/glossary/tabs.html [new file with mode: 0644]
mod/glossary/view.php

index 715214b047c8988275a248d3c7878566943b3588..f72ed0ad109c5e12adaf132d7a59382e2f4c34e7 100644 (file)
@@ -15,7 +15,7 @@ $string['areyousuredeletecomment'] = "Are you sure you want to delete this comme
 $string['ascending'] = "(ascending)";
 $string['attachment'] = "Attachment";
 $string['back'] = "Back";
-$string['casesensitive'] = "This entry is<br>case sensitive";
+$string['casesensitive'] = "This entry is case sensitive";
 $string['categories'] = "Categories";
 $string['categoryview'] = "Browse by category";
 $string['category'] = "Category";
@@ -51,6 +51,7 @@ $string['displayformat3']  = "Encyclopedia";
 $string['displayformat4']  = "FAQ";
 $string['displayformat5'] = "Full without author";
 $string['editcategories'] = "Edit categories";
+$string['editalias'] = "Edit alias";
 $string['editentry'] = "Edit entry";
 $string['editingcomment'] = "Editing comment";
 $string['entries'] = "Entries";
@@ -60,11 +61,12 @@ $string['entryalreadyexist'] = "Entry already exists";
 $string['entryapproved'] = "This entry has been approved";
 $string['entrydeleted'] = "Entry deleted";
 $string['entryishidden'] = "(this entry is currently hidden)";
-$string['entryusedynalink'] = "This entry should be<br>automatically linked";
+$string['entryusedynalink'] = "This entry should be automatically linked";
 $string['entryexported'] = "Entry succesfully exported";
 $string['explainspecial'] = "Shows entries that do not begin with a letter";
 $string['explainalphabet'] = "Browse the glossary using this index";
 $string['explainall'] = "Shows ALL entries on one page";
+$string['explainaddentry'] = "Add a new entry to the current glossary.<br>Concept and definition are mandatory fields.";
 $string['exportedentry'] = "Exported entry";
 $string['exportglossary'] = "Export glossary";
 $string['exporttomainglossary'] = "Export to main glossary";
index 7762b41ee097edb939d1d312738bffea1dbf0b85..b48d07e6b3200be7833dd424f790cd393d4c81ca 100644 (file)
                              "onClick=\"return openpopup('/mod/glossary/showentry.php?courseid=$courseid\&concept=$concept->concept', 'entry', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">";
                     }
 
-                    $currentconcept = trim(strip_tags($concept->concept));
+                    $currentconcept = trim(strip_tags(str_replace("|", "\|", $concept->concept)));
+                    if ( !$concept->category ) {
+                        if ( $aliases = get_records("glossary_alias","entryid",$concept->id) ) {
+                            foreach ($aliases as $alias) {
+                                $currentconcept .= "|" . trim(strip_tags(str_replace("|", "\|", $alias->alias)));
+                            }
+                        }
+                    }
                     $text = glossary_link_concepts($text,$currentconcept,$href_tag_begin, "</a>",$concept->casesensitive,$concept->fullmatch);
                 }
             }
index faa4a8e4e6fe756db82d8d14e207cf9b42249486..d05cddd8109505e667252a26bdf99c4a925e43d1 100644 (file)
@@ -22,7 +22,10 @@ if (isset($errors)) {
 </tr>
 <tr valign=top>
     <td align=right><p><b><?php echo get_string("categories","glossary") ?>:</b></p></td>
-    <td>       
+    <td>
+    <table border=0>
+    <tr>
+    <td>
     <?php
         $categories = get_records("glossary_categories","glossaryid",$glossary->id);
         echo "<select size=\"6\" name=\"categories[]\" multiple=\"yes\">";
@@ -41,11 +44,10 @@ if (isset($errors)) {
         }
     ?>
     </select>
-    </td>
-</tr>
-<tr valign=top>
-    <td align=right><p><b><?php echo get_string("entryusedynalink","glossary") ?>:</b></p></td>
     <td>
+    <td width=100%>
+    <table border=0 width=100%>
+        <tr><td align=right width=80%><small><?php echo get_string("entryusedynalink","glossary") ?>:</small></td><td width=20%>
     <script>
         var items = ['casesensitive','fullmatch'];
     </script>
@@ -59,61 +61,38 @@ if (isset($errors)) {
         $selected = "checked";
     }
 ?> 
-    <input type="checkbox" name="usedynalink" value=1 <?php p($selected) ?> onclick="return lockoptions('form','usedynalink', items)"> <?php helpbutton("usedynalink", get_string("usedynalink", "glossary"), "glossary") ?>
-    </td>
-</tr>
-<tr valign=top>
-    <td align=right><p><b><?php echo get_string("casesensitive","glossary") ?>:</b></p></td>
-    <td>
-    <select size="1" name="casesensitive">
-     <option value=1 <?php
-      if ( isset($newentry->casesensitive) ) {
-          if ( $newentry->casesensitive ) {
-             echo "selected";
-          }
-      } elseif ( $CFG->cnfcasesensitive ) {
-          echo "selected";
-      }
-      ?> 
-      ><?php echo get_string("yes") ?></option>
-     <option value=0 <?php
-      if ( isset($newentry->casesensitive) ) {
-          if ( !$newentry->casesensitive ) {
-             echo "selected";
-          }
-      } elseif ( !$CFG->cnfcasesensitive ) {
-          echo "selected";
-      }
-      ?>><?php echo get_string("no") ?>
-     </option>
-     </select> <?php helpbutton("casesensitive", get_string("casesensitive", "glossary"), "glossary") ?>
+    <input type="checkbox" name="usedynalink" value=1 <?php p($selected) ?> onclick="return lockoptions('form','usedynalink', items)"> <?php helpbutton("usedynalink", strip_tags(get_string("usedynalink"), "glossary"), "glossary") ?>
+        </td></tr>
+        <tr><td align=right width=80%><small><?php echo get_string("casesensitive","glossary") ?>:</small></td><td width=20%>
+<?php
+    $selected = "";
+    if ( isset($newentry->casesensitive) ) {
+        if ($newentry->casesensitive) {
+            $selected = "checked";
+        }
+    } elseif ( $CFG->cnfcasesensitive ) {
+        $selected = "checked";
+    }
+?> 
+    <input type="checkbox" name="casesensitive" value=1 <?php p($selected) ?>> <?php helpbutton("casesensitive", strip_tags(get_string("casesensitive", "glossary")), "glossary") ?>
+        </td></tr>
+        <tr><td align=right width=80%><small><?php echo get_string("fullmatch","glossary") ?>:</small></td><td width=20%>
+<?php
+    $selected = "";
+    if ( isset($newentry->fullmatch) ) {
+        if ($newentry->fullmatch) {
+            $selected = "checked";
+        }
+    } elseif ( $CFG->cnffullmatch ) {
+        $selected = "checked";
+    }
+?> 
+    <input type="checkbox" name="fullmatch" value=1 <?php p($selected) ?>> <?php helpbutton("fullmatch", strip_tags(get_string("fullmatch", "glossary")), "glossary") ?>
+        </td></tr>
+    </table>
     </td>
-</tr>
-<tr valign=top>
-    <td align=right><p><b><?php echo get_string("fullmatch","glossary") ?>:</b></p></td>
-    <td>
-    <select size="1" name="fullmatch">
-     <option value=1 <?php
-      if ( isset($newentry->fullmatch) ) {
-          if ( $newentry->fullmatch ) {
-             echo "selected";
-          }
-      } elseif ( $CFG->cnffullmatch ) {
-          echo "selected";
-      }
-      ?> 
-      ><?php echo get_string("yes") ?></option>
-     <option value=0 <?php
-      if ( isset($newentry->fullmatch) ) {
-          if ( !$newentry->fullmatch ) {
-             echo "selected";
-          }
-      } elseif ( !$CFG->cnffullmatch ) {
-          echo "selected";
-      }
-      ?>><?php echo get_string("no") ?>
-     </option>
-     </select> <?php helpbutton("fullmatch", get_string("fullmatch", "glossary"), "glossary") ?>
+    </tr>
+    </table>
     </td>
 </tr>
 <tr valign=top>
@@ -160,9 +139,9 @@ if (isset($errors)) {
 </tr>
 <tr>
 <td colspan=2>
-       <p align=center>
-       <?php if (isset($newentry->id)) {
-               echo "<input type=\"hidden\" name=e value=\"$newentry->id\">";
+    <p align=center>
+    <?php if (isset($newentry->id)) {
+        echo "<input type=\"hidden\" name=e value=\"$newentry->id\">";
         }
        ?>
 
index e3c1cb61dabc91025cd4e5ae6f228f2b147daa98..b56c02eeca9c6d280cef74760059242d04018aad 100644 (file)
@@ -188,11 +188,26 @@ print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullna
               <A HREF=\"view.php?id=$cm->id\">$glossary->name</A> -> $stredit", "form.text",
               "", true, "", navmenu($course, $cm));
 
-print_heading($glossary->name);
+    echo '<p align="center"><font size="3"><b>' . stripslashes_safe($glossary->name);
+    echo '</b></font></p>';
 
+/// Info box
+
+    if ( $glossary->intro ) {
+        print_simple_box_start('center','70%');
+        echo format_text($glossary->intro);
+        print_simple_box_end();
+    }
+
+/// Tabbed browsing sections
+$tab = GLOSSARY_ADDENTRY_VIEW;
+include("tabs.html");
 
 include("edit.html");
 
+echo '</center>';
+glossary_print_tabbed_table_end();
+
 print_footer($course);
 
 ?>
index d079f31bec9a25f2455ec8f47886a5a4093ba41b..84d8ae953307b341badaebef5703bd83ee979ba7 100644 (file)
@@ -5,7 +5,7 @@
     
     require_variable($id);           // Course Module ID
 
-    optional_variable($tab,GLOSSARY_APPROVAL_VIEW);
+    optional_variable($tab,GLOSSARY_STANDARD_VIEW);
     optional_variable($l,"ALL");
 
     if (! $cm = get_record("course_modules", "id", $id)) {
index 86a233046bab2d97a3cc07dd62c9294035315d6b..f807b501eeff72e4b99418489e57e6b97feef947 100644 (file)
@@ -11,7 +11,10 @@ define("GLOSSARY_SHOW_NOT_CATEGORISED", -1);
 define("GLOSSARY_STANDARD_VIEW", 0);
 define("GLOSSARY_CATEGORY_VIEW", 1);
 define("GLOSSARY_DATE_VIEW", 2);
-define("GLOSSARY_APPROVAL_VIEW", 3);
+define("GLOSSARY_ADDENTRY_VIEW", 3);
+define("GLOSSARY_IMPORT_VIEW", 4);
+define("GLOSSARY_EXPORT_VIEW", 5);
+define("GLOSSARY_APPROVAL_VIEW", 6);
 
 define("GLOSSARY_FORMAT_SIMPLE", 0);
 define("GLOSSARY_FORMAT_CONTINUOUS", 1);
@@ -93,6 +96,7 @@ function glossary_delete_instance($id) {
             $ents = substr($ents,0,-1);
             if ($ents) {
                 delete_records_select("glossary_comments", "entryid in ($ents)");
+                delete_records_select("glossary_alias", "entryid in ($ents)");
             }
         }
         delete_records("glossary_entries", "glossaryid", "$glossary->id");
@@ -214,15 +218,18 @@ function glossary_log_info($log) {
                               AND u.id = '$log->userid'");
 }
 
-function glossary_get_entries($glossaryid, $entrylist) {
+function glossary_get_entries($glossaryid, $entrylist, $pivot = "") {
     global $CFG;
+    if ($pivot) {
+       $pivot .= ",";
+    }
 
-    return get_records_sql("SELECT id,userid,concept,definition,format
+    return get_records_sql("SELECT $pivot id,userid,concept,definition,format
                             FROM {$CFG->prefix}glossary_entries
                             WHERE glossaryid = '$glossaryid'
                             AND id IN ($entrylist)");
 }
-function glossary_get_entries_sorted($glossary, $where="", $orderby="") {
+function glossary_get_entries_sorted($glossary, $where="", $orderby="", $pivot = "") {
 global $CFG;
     if ($where) {
        $where = " and $where";
@@ -230,12 +237,15 @@ global $CFG;
     if ($orderby) {
        $orderby = " ORDER BY $orderby";
     }
-    return      get_records_sql("SELECT *
+    if ($pivot) {
+       $pivot .= ",";
+    }
+    return      get_records_sql("SELECT $pivot *
                                  FROM {$CFG->prefix}glossary_entries 
                                  WHERE (glossaryid = $glossary->id or sourceglossaryid = $glossary->id) $where $orderby");
 }
 
-function glossary_get_entries_by_category($glossary, $cat, $where="", $orderby="") {
+function glossary_get_entries_by_category($glossary, $cat, $where="", $orderby="", $pivot = "") {
 global $CFG;
     if ($where) {
        $where = " and $where";
@@ -243,7 +253,10 @@ global $CFG;
     if ($orderby) {
        $orderby = " ORDER BY $orderby";
     }
-    return      get_records_sql("SELECT ge.*
+    if ($pivot) {
+       $pivot .= ",";
+    }
+    return      get_records_sql("SELECT $pivot ge.*
                                  FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories c
                                  WHERE (ge.id = c.entryid and c.categoryid = $cat) and
                                              (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) $where $orderby");
@@ -284,9 +297,20 @@ function glossary_print_entry($course, $cm, $glossary, $entry, $tab="",$cat="")
         }
     }
 }
-function  glossary_print_entry_concept($entry) {
-        echo $entry->concept;
-}
+function  glossary_print_entry_concept($entry, $alias = true) {
+static $glossary; // to avoid unnecessary calls when dealing with the same glossary
+static $cm;
+    echo $entry->concept;
+/*
+    if ($alias) {
+        if ($glossary->id != $entry->glossaryid) {
+            $glossary = get_record("glossary","id",$entry->glossaryid);
+            $cm = get_coursemodule_from_instance("glossary", $glossary->id, $glossary->course);
+        }
+        echo " <a title=\"" . get_string("editalias","glossary") . "\" href=\"alias.php?id=$cm->id&eid=$entry->id\"><img border=0 src=alias.gif></a>";
+    }
+*/
+ }
 
 function glossary_print_entry_definition($entry) {
     $definition = str_ireplace($entry->concept,"<nolink>$entry->concept</nolink>",$entry->definition);
@@ -397,6 +421,7 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab="",$cat
             echo " <font size=-1>" . get_string("exportedentry","glossary") . "</font>";
         }
     }
+    echo "&nbsp;&nbsp;"; // just to make up a little the output in Mozilla ;)
 }
 
 function glossary_search_entries($searchterms, $glossary, $includedefinition) {
@@ -808,6 +833,10 @@ function glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder =
     glossary_print_sorting_links($cm, $sortkey,$sortorder, $tab);
 }
 
+function glossary_print_addentry_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) {
+    echo '<center>' . get_string("explainaddentry","glossary") . '<p>';
+}
+
 function glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) {
     if ( $tab != GLOSSARY_DATE_VIEW ) {
         if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
index 96894a8cef9edbf86ca0a27baaa74c969f7241f8..1d66474275c72cd8d2032e94ae58d8b2c5f6a0e2 100644 (file)
@@ -8,6 +8,10 @@
     require_variable($tab,GLOSSARY_STANDARD_VIEW); // format to show the entries
     optional_variable($sortkey,"UPDATE");          // Sorting key if TAB = GLOSSARY_DATE_VIEW
     optional_variable($sortorder,"asc");           // Sorting order if TAB = GLOSSARY_DATE_VIEW
+    optional_variable($l,"ALL");          
+    optional_variable($eid);          
+    optional_variable($search);
+    optional_variable($cat,GLOSSARY_SHOW_ALL_CATEGORIES);          
 
     if (! $cm = get_record("course_modules", "id", $id)) {
         error("Course Module ID was incorrect");
         error("You must be logged to use this page.");
     } 
 
+    if ( $eid ) {
+        $l = '';
+        $tab = GLOSSARY_STANDARD_VIEW;
+    }
 /// Generating the SQL based on the format to show
     switch ($tab) {
     case GLOSSARY_CATEGORY_VIEW:
+        $where = '';
+        if ($cat) {
+            if ( $cat != GLOSSARY_SHOW_ALL_CATEGORIES and $cat != GLOSSARY_SHOW_NOT_CATEGORISED ) {
+                    $where = 'and c.id = ' . $cat;
+            }
+        }
         $entries = get_records_sql("SELECT c.name pivot, e.*
                                     FROM {$CFG->prefix}glossary_entries e,
                                          {$CFG->prefix}glossary_entries_categories ec,
                                          {$CFG->prefix}glossary_categories as c
                                     WHERE e.id = ec.entryid AND ec.categoryid = c.id AND
                                           (e.glossaryid = $glossary->id or e.sourceglossaryid = $glossary->id)
-                                          AND e.approved != 0
+                                          AND e.approved != 0 $where
                                     ORDER BY c.name, e.concept");
 
     break;
         break;
         }
 
+        if ( $l ) {
+            if ($l != 'ALL' and $l != 'SPECIAL') {
+                switch ($CFG->dbtype) {
+                case 'postgres7':
+                    $where = 'and substr(ucase(concept),1,' .  strlen($l) . ') = \'' . strtoupper($l) . '\'';
+                break;
+                case 'mysql':
+                    $where = 'and left(ucase(concept),' .  strlen($l) . ") = '$l'";
+                break;
+                default:
+                    $where = '';
+                }
+            }
+        } elseif ($eid) {
+            $where = " and e.id = $eid";
+        }
+
         $entries = get_records_sql("SELECT $pivot pivot, e.*
                                     FROM {$CFG->prefix}glossary_entries e
                                     WHERE (e.glossaryid = $glossary->id or e.sourceglossaryid = $glossary->id)
-                                          AND e.approved != 0
+                                          AND e.approved != 0 $where
                                     ORDER BY e.concept $sortorder");
     break;
     } 
 
-
     echo '<p><STRONG>' . get_string("course") . ': <i>' . $course->fullname . '</i><br />';
     echo get_string("modulename","glossary") . ': <i>' . $glossary->name . '</i></STRONG></p>';
 
diff --git a/mod/glossary/tabs.html b/mod/glossary/tabs.html
new file mode 100644 (file)
index 0000000..4c06736
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+
+    echo '<p align="center">';
+    $glossary_tCFG->TabTableBGColor = $THEME->cellheading;
+    $glossary_tCFG->ActiveTabColor = $THEME->cellheading;
+    $glossary_tCFG->InactiveTabColor = $THEME->cellcontent2;
+    $glossary_tCFG->InactiveFontColor= $THEME->hidden;
+    $glossary_tCFG->TabTableWidth = "70%";
+    $glossary_tCFG->TabsPerRow = 4;
+    $glossary_tCFG->TabSeparation = 4;
+
+    $data[GLOSSARY_STANDARD_VIEW]->caption = get_string("standardview", "glossary");
+    $data[GLOSSARY_CATEGORY_VIEW]->caption = get_string("categoryview", "glossary");
+    $data[GLOSSARY_DATE_VIEW]->caption = get_string("dateview", "glossary");
+    if (!isguest()) {
+        if ( isteacher($course->id) or $glossary->studentcanpost  ) {
+            $data[GLOSSARY_ADDENTRY_VIEW]->caption = get_string("addentry", "glossary");
+            $data[GLOSSARY_ADDENTRY_VIEW]->link = "edit.php?id=$cm->id";
+        }
+    }
+
+    if ( isteacher($course->id) ) {
+        $data[GLOSSARY_IMPORT_VIEW]->caption = "Import Entries";
+        $data[GLOSSARY_EXPORT_VIEW]->caption = "Export Entries";
+
+//        $data[GLOSSARY_IMPORT_VIEW]->link = "import.php?id=$cm->id&tab=$tab";
+//        $data[GLOSSARY_EXPORT_VIEW]->link = "export.php?id=$cm->id&tab=$tab";
+    }
+
+    $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_DATE_VIEW;
+    if ( $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS ) {
+        $data[GLOSSARY_STANDARD_VIEW]->link = "view.php?id=$id";
+        $data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_CATEGORY_VIEW;
+    }
+
+
+
+    if (isteacher($course->id)) {
+        $data[GLOSSARY_APPROVAL_VIEW]->caption = get_string("waitingapproval", "glossary");
+        $data[GLOSSARY_APPROVAL_VIEW]->link = "";
+
+        $hiddenentries = get_records_select("glossary_entries","glossaryid  = $glossary->id and approved = 0");
+        if ($hiddenentries) {
+            $data[GLOSSARY_APPROVAL_VIEW]->caption .= "<br><font size=1>(" . count($hiddenentries) . " " . get_string("entries","glossary") . ")</font>";
+            $data[GLOSSARY_APPROVAL_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_APPROVAL_VIEW;
+        } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) {
+            $tab = $framebydefault;
+        }
+    } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) {
+        $tab = $framebydefault;
+    }
+
+/// printing header of the current tab
+    echo '<center>';
+    glossary_print_tabbed_table_start($data, $tab, $glossary_tCFG);
+    switch ($tab) {
+        case GLOSSARY_CATEGORY_VIEW:
+            glossary_print_categories_menu($course, $cm, $glossary, $cat, $category);
+        break;
+        case GLOSSARY_APPROVAL_VIEW:
+            glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+        break;
+        case GLOSSARY_ADDENTRY_VIEW:
+            $search = "";
+            $l = "";
+            glossary_print_addentry_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+        break;
+        case GLOSSARY_DATE_VIEW:
+            if (!$sortkey) {
+                $sortkey = 'UPDATE';
+            }
+            if (!$sortorder) {
+                $sortorder = 'desc';
+            }
+        case GLOSSARY_STANDARD_VIEW:
+        default:
+            glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+            if ($search) {
+                echo "<h3>$strsearch: $search</h3>";
+            } 
+        break;
+    } 
+    echo '<hr>';
+?>
\ No newline at end of file
index 003db7615a9df638d73e0fb236c3036b1e6454be..664b088907393ec738848eb2b0baa50cb871100c 100644 (file)
         error("Course Module ID was incorrect");
     } 
     
+    if ($tab == GLOSSARY_ADDENTRY_VIEW and !$eid) {
+        redirect("edit.php?id=$cm->id&tab=$tab");
+    }
+
     if (! $course = get_record("course", "id", $cm->course)) {
         error("Course is misconfigured");
     } 
@@ -89,6 +93,7 @@
         $search = trim(implode(' ', $searchterms));
         $tab = $framebydefault;
     } elseif ($eid) {   /// searching a specify entry
+        $tab = GLOSSARY_STANDARD_VIEW;
         $search = '';
     } 
 
         navmenu($course, $cm));
     
     echo '<p align="center"><font size="3"><b>' . stripslashes_safe($glossary->name);
-    echo ' <a title ="' . get_string("printerfriendly","glossary") . '" target="_blank" href="print.php?id=' . $cm->id . '&tab=' . $tab . '&sortkey=' . $sortkey . '&sortorder=' . $sortorder . '">';
-    echo '<img border=0 src="print.gif"/></a>';
+    if ($tab == GLOSSARY_CATEGORY_VIEW | $tab == GLOSSARY_STANDARD_VIEW |
+        $tab == GLOSSARY_DATE_VIEW) {
+    /// the "Print" icon
+        echo " <a title =\"". get_string("printerfriendly","glossary") . "\" target=\"_blank\" href=\"print.php?id=$cm->id&tab=$tab&cat=$cat&l=$l&eid=$eid&sortkey=$sortkey&sortorder=$sortorder\">";
+        echo '<img border=0 src="print.gif"/></a>';
+    }
     echo '</b></font></p>';
 
 /// Info box
         print_simple_box_end();
     }
 
-/// Add buttons
-
-    if (!isguest()) {
-        if ( isteacher($course->id) or $glossary->studentcanpost  ) {
-            unset($options);
-            $options = array ("id" => "$cm->id");
-            echo '<center><p>';
-            print_single_button("edit.php", $options, $straddentry);
-            echo '</p></center>';
-        }
-    } 
-
-/*
-    unset($options);
-    $options = array ("id" => "$cm->id");
-    echo '<center><p>';
-    print_single_button("export.php", $options, get_string("exportglossary","glossary"));
-    echo '</p></center>';
-*/
-
 /// Search box
 
+    echo '<p>';
     print_simple_box_start("center", "", $THEME->cellheading);
     echo '<p>';
     echo '<form method="POST" action="view.php">';
 
 
 /// Tabbed browsing sections
-    echo '<p align="center">';
-    $glossary_tCFG->TabTableBGColor = $THEME->cellheading;
-    $glossary_tCFG->ActiveTabColor = $THEME->cellheading;
-    $glossary_tCFG->InactiveTabColor = $THEME->cellcontent2;
-    $glossary_tCFG->InactiveFontColor= $THEME->hidden;
-    $glossary_tCFG->TabTableWidth = "70%";
-    $glossary_tCFG->TabsPerRow = 4;
-    $glossary_tCFG->TabSeparation = 4;
-
-    $data[GLOSSARY_STANDARD_VIEW]->caption = get_string("standardview", "glossary");
-    $data[GLOSSARY_CATEGORY_VIEW]->caption = get_string("categoryview", "glossary");
-    $data[GLOSSARY_DATE_VIEW]->caption = get_string("dateview", "glossary");
-
-    $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_DATE_VIEW;
-    if ( $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS ) {
-        $data[GLOSSARY_STANDARD_VIEW]->link = "view.php?id=$id";
-        $data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_CATEGORY_VIEW;
-    }
-
-    if (isteacher($course->id)) {
-        $data[GLOSSARY_APPROVAL_VIEW]->caption = get_string("waitingapproval", "glossary");
-        $data[GLOSSARY_APPROVAL_VIEW]->link = "";
-
-        $hiddenentries = get_records_select("glossary_entries","glossaryid  = $glossary->id and approved = 0");
-        if ($hiddenentries) {
-            $data[GLOSSARY_APPROVAL_VIEW]->caption .= "<br><font size=1>(" . count($hiddenentries) . " " . get_string("entries","glossary") . ")</font>";
-            $data[GLOSSARY_APPROVAL_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_APPROVAL_VIEW;
-        } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) {
-            $tab = $framebydefault;
-        }
-    } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) {
-        $tab = $framebydefault;
-    }
-
-/// printing header of the current tab
-    echo '<center>';
-    glossary_print_tabbed_table_start($data, $tab, $glossary_tCFG);
-    switch ($tab) {
-        case GLOSSARY_CATEGORY_VIEW:
-            glossary_print_categories_menu($course, $cm, $glossary, $cat, $category);
-        break;
-        case GLOSSARY_APPROVAL_VIEW:
-            glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
-        break;
-        case GLOSSARY_DATE_VIEW:
-            if (!$sortkey) {
-                $sortkey = 'UPDATE';
-            }
-            if (!$sortorder) {
-                $sortorder = 'desc';
-            }
-        case GLOSSARY_STANDARD_VIEW:
-        default:
-            glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
-            if ($search) {
-                echo "<h3>$strsearch: $search</h3>";
-            } 
-        break;
-    } 
-    echo '<hr>';
+    include("tabs.html");
     
 /// Printing the entries
 
                                 echo "\n<center><table border=0 cellspacing=0 width=95% valign=top cellpadding=5><tr><td align=center bgcolor=\"$THEME->cellheading2\">";
                             }
                             if ($l == 'ALL' and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
-                                echo "<b>$currentletter</b>";
+                                if ($tab != GLOSSARY_DATE_VIEW) {
+                                    echo "<b>$currentletter</b>";
+                                } 
                             } 
     
                             if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {