]> git.mjollnir.org Git - moodle.git/commitdiff
- New encapsulated functions in order to make easier to create new display formats
authorwillcast <willcast>
Tue, 28 Oct 2003 16:10:36 +0000 (16:10 +0000)
committerwillcast <willcast>
Tue, 28 Oct 2003 16:10:36 +0000 (16:10 +0000)
- Fixed problem when showing 'ALL' in alphabet frame
- Disabled unnecessary fields when selecting DO NOT AUTOMATICALY LINK THIS ENTRY in the adde entry screen

mod/glossary/deleteentry.html
mod/glossary/edit.html
mod/glossary/edit.php
mod/glossary/formats/2.php
mod/glossary/formats/3.php
mod/glossary/formats/4.php
mod/glossary/formats/5.php
mod/glossary/index.php
mod/glossary/lib.php
mod/glossary/view.php

index e7721b139ac42a670c6cfdb73cc7a9b53fb57e60..0629aa0f4767bf8d6296e58c0e8dc2fcbd00355f 100644 (file)
@@ -1,6 +1,6 @@
 <form name="form" method="post" action="deleteentry.php">
 
-<input type="hidden" name=id              value="<?php p($cm->id) ?>">
+<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 echo $entry ?>">
index 7a22b1cf1508838d687624d2e7a73f3cd5bc1ebe..a2b17d7b4652e6c62fb0c125cab99bcf166320e6 100644 (file)
@@ -1,5 +1,5 @@
 <center>
-<form name="theform" method="post" <?=$onsubmit ?> action="edit.php" enctype="multipart/form-data">
+<form name="form" method="post" <?=$onsubmit ?> action="edit.php" enctype="multipart/form-data">
 <table  class=generalbox cellpadding=5 bgcolor="<?php p($THEME->cellheading)?>">
 <tr valign=top>
     <td align=right><p><b><?php echo get_string("concept","glossary") ?>:</b></p></td>
 <tr valign=top>
     <td align=right><p><b><?php echo get_string("entryusedynalink","glossary") ?>:</b></p></td>
     <td>
-    <select size="1" name="usedynalink">
-     <option value="1" <?php
-      if ( isset($newentry->usedynalink) ) {
-         if ($newentry->usedynalink) {
-             echo "selected";
-         }
-      }
-      ?> 
-      ><?php echo get_string("yes") ?></option>
-     <option value="0" <?php
-      if ( isset($newentry->usedynalink) ) {
-         if (!$newentry->usedynalink) {
-             echo "selected";
-            }
-      }
-      ?>><?php echo get_string("no") ?>
-     </option>
-     </select> <?php helpbutton("usedynalink", get_string("usedynalink", "glossary"), "glossary") ?>
+    <script>
+        var items = ['casesensitive','fullmatch'];
+    </script>
+<?php
+    $selected = "";
+    if ( isset($newentry->usedynalink) ) {
+        if ($newentry->usedynalink) {
+            $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>
                echo "<input type=\"hidden\" name=e value=\"$newentry->id\">";
         }
        ?>
+
+       <input type="hidden" name=husedynalink value="1">
+       <input type="hidden" name=hcasesensitive value="0">
+       <input type="hidden" name=hfullmatch value="1">
+
        <input type="hidden" name=id value="<?=$cm->id ?>">
        <input type="hidden" name=tab value="<?=$tab ?>">
        <input type="hidden" name=cat value="<?=$cat ?>">
 
 <?PHP 
    if ($usehtmleditor) { 
-       print_richedit_javascript("theform", "text", "yes");
+       print_richedit_javascript("form", "text", "yes");
    }
 ?>
 
index 76c8fcb8b3ac8e6a4af144f2495b7356a9ebf649..2a2413ebc4bd8a165f29d3b0c556cbb6e676bff7 100644 (file)
@@ -30,7 +30,9 @@ if (! $glossary = get_record("glossary", "id", $cm->instance)) {
 }
 if ( $confirm ) {
     $form = data_submitted();
-
+    if ( !isset($form->usedynalink) ) {
+        $form->usedynalink = 0;
+    }
     $timenow = time();
     $form->text = clean_text($form->text, $form->format);
 
index 17d8b0fd389bbbda7edae9990f4f794af73c2318..2b495f6184529a6955d1415498340c4e3f38b2a6 100644 (file)
@@ -14,31 +14,27 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $tab=""
     echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostpicture\">";
     if ($entry) {
         print_user_picture($user->id, $course->id, $user->picture);
-    }
-    echo "</td>";
-    echo "<td nowrap valign=\"top\" width=100% bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\">";
-    if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
-        echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&tab=$tab\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
-    }
-    if ($entry->attachment) {
-          $entry->course = $glossary->course;
-          echo "<table border=0 align=right><tr><td>";
-          echo glossary_print_attachments($entry, "html");
-          echo "</td></tr></table>";
-    }
-    if ($entry) {
-        echo "<b>$entry->concept</b><br />";
+
+        echo "</td>";
+        echo "<td nowrap valign=\"top\" width=100% bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\">";
+
+        glossary_print_entry_approval($cm, $entry, $tab);
+        glossary_print_entry_attachment($entry,"html","right");
+
+        echo "<b>";
+        glossary_print_entry_concept($entry);
+               echo "</b><br />";
+
         echo "<font size=\"2\">$strby $user->firstname $user->lastname</font>";
         echo "&nbsp;&nbsp;<font size=1>(".get_string("lastedited").": ".
              userdate($entry->timemodified).")</font>";
-    }
-    echo "</tr>";
+        echo "</tr>";
 
-    echo "\n<tr>";
-    echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostside\">&nbsp;</td>";
-    echo "\n<td width=100% bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">";
-    if ($entry) {
-        echo format_text($entry->definition, $entry->format);
+        echo "\n<tr>";
+        echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostside\">&nbsp;</td>";
+        echo "\n<td width=100% bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">";
+
+        glossary_print_entry_definition($entry);
         glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab,$cat);
 
     } else {
index 0c2155e7982b1d54cd693d935320a12b93be22c6..8c2652a24d0834368a004cbc1ce8c661cecc3843 100644 (file)
@@ -14,24 +14,21 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $tab=""
     echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostpicture\">";
     if ($entry) {
         print_user_picture($user->id, $course->id, $user->picture);
-    }
-    echo "</td>";
-    echo "<td align=\"top\" nowrap width=100% bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\">";
-    if ($entry) {
-        if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
-            echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&tab=$tab\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
-        }
-        echo "<b>$entry->concept</b><br />";
+        echo "</td>";
+        echo "<td align=\"top\" nowrap width=100% bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\">";
+        glossary_print_entry_approval($cm, $entry, $tab);
+        echo "<b>";
+        glossary_print_entry_concept($entry);
+               echo "</b><br />";
         echo "<font size=\"2\">$strby $user->firstname $user->lastname</font>";
         echo "&nbsp;&nbsp;<font size=1>(".get_string("lastedited").": ".
              userdate($entry->timemodified).")</font>";
-    }
-    echo "</tr>";
+        echo "</tr>";
+
+        echo "\n<tr>";
+        echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostside\">&nbsp;</td>";
+        echo "\n<td width=100% align=\"top\" bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">";
 
-    echo "\n<tr>";
-    echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostside\">&nbsp;</td>";
-    echo "\n<td width=100% align=\"top\" bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">";
-    if ($entry) {
         if ($entry->attachment) {
             $entry->course = $course->id;
             if (strlen($entry->definition)%2) {
@@ -39,11 +36,9 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $tab=""
             } else {
                 $align = "left";
             }
-            echo "<table border=0 align=$align><tr><td>";
-            echo glossary_print_attachments($entry);
-            echo "</td></tr></table>";
+            glossary_print_entry_attachment($entry,"",$align);
         }
-        echo format_text($entry->definition, $entry->format);
+        glossary_print_entry_definition($entry);
 
         glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab,$cat);
 
index 58769a12958b56186f308482297f55fbd8e7fc93..246eb536fa445ee245db115337f8ba884236d56b 100644 (file)
@@ -6,31 +6,29 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab="",
     if ( $entry ) {
         $colour = $THEME->cellheading2;
 
-        echo "\n<table border=1 cellspacing=0 width=95% valign=top cellpadding=10>";
+        echo '<table border=1 cellspacing=0 width=95% valign=top cellpadding=10>';
 
-        echo "\n<tr>";
+        echo '<tr>';
         echo "<td width=100% bgcolor=\"$colour\">";
         $entry->course = $course->id;
-        if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
-            echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&tab=$tab\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
-        }
-        if ($entry->attachment) {
-            echo "<table border=0 align=right><tr><td>";
-            echo glossary_print_attachments($entry, "html");
-            echo "</td></tr></table>";
-        }
-        echo "<b>" . get_string("question","glossary") . ":</b> $entry->concept<br>";
-        echo "&nbsp;&nbsp;<font size=1>".get_string("lastedited").": ".userdate($entry->timemodified)."</font></tr>";
-        echo "\n<tr><td width=100% bgcolor=\"$THEME->cellcontent\">";          
-        echo "<b>" . get_string("answer","glossary") . ":</b> " . format_text($entry->definition, $entry->format);
+        glossary_print_entry_approval($cm, $entry, $tab);
+        glossary_print_entry_attachment($entry,"html","right");
+
+        echo '<b>' . get_string("question","glossary") . ':</b> ';
+        echo  glossary_print_entry_concept($entry) . '<br>';
+        echo '&nbsp;&nbsp;<font size=1>' . get_string("lastedited").': '.userdate($entry->timemodified) . '</font></tr>';
+        echo "<tr><td width=100% bgcolor=\"$THEME->cellcontent\">";            
+        echo '<b>' . get_string("answer","glossary") . ':</b> ';
+        echo glossary_print_entry_definition($entry);
+
 
         glossary_print_entry_icons($course, $cm, $glossary, $entry, $tab, $cat);
-        echo "</td></tr></table>\n";
+        echo '</td></tr></table>';
 
     } else {
-        echo "<center>";
+        echo '<center>';
         print_string("noentry", "glossary");
-        echo "</center>";
+        echo '</center>';
     }
 
 }
index 0e798470b59cf0f6d33bb6b1daf4b260a79e051b..e4ec4700280fea904566b0ec7f75d0a206906308 100644 (file)
@@ -9,27 +9,18 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab="",
 
     echo "\n<tr>";
     echo "<td width=100% bgcolor=\"$colour\">";
-    if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
-        echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&tab=$tab\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
-    }
-    if ($entry->attachment) {
-        $entry->course = $course->id;
-        echo "<table border=0 align=right><tr><td>";
-        echo glossary_print_attachments($entry, "html");
-        echo "</td></tr></table>";
-    }
-    echo "<b>$entry->concept</b><br>";
+    glossary_print_entry_approval($cm, $entry, $tab);
     if ($entry) {
+        glossary_print_entry_attachment($entry,"html","right");
+        echo "<b>";
+        glossary_print_entry_concept($entry);
+        echo "</b><br />";
         echo "&nbsp;&nbsp;<font size=1>".get_string("lastedited").": ".userdate($entry->timemodified)."</font>";
-    }
-    echo "</tr>";
-
-    echo "\n<tr><td width=100% bgcolor=\"$THEME->cellcontent\">";
-    if ($entry) {
-        echo format_text($entry->definition, $entry->format);
-
+        echo "</tr>";
+        echo "\n<tr><td width=100% bgcolor=\"$THEME->cellcontent\">";
+               
+        glossary_print_entry_definition($entry);
         glossary_print_entry_icons($course, $cm, $glossary, $entry, $tab, $cat);
-
     } else {
         echo "<center>";
         print_string("noentry", "glossary");
index c85fa8deaf10b564083361a5ba4277c7d4ae3cda..346c85689f0939637e195ae1727a6aaf426aa23e 100644 (file)
@@ -66,7 +66,7 @@
             $link = "<A HREF=\"view.php?id=$glossary->coursemodule\">$glossary->name</A>";
         }
 
-        $count = count_records("glossary_entries", "glossaryid", $glossary->id);
+        $count = count_records_sql("SELECT COUNT(*) FROM {$CFG->prefix}glossary_entries where (glossaryid = $glossary->id or sourceglossaryid = $glossary->id)");
 
         if ($course->format == "weeks" or $course->format == "topics") {
             if (empty($glossary->section)) {
index 76fb8c2f05c429f69b8fdd717f4eb7755b5b962c..55f55cc32ac7f156d97765c2e3146b35d2b6419c 100644 (file)
@@ -249,6 +249,33 @@ function glossary_print_entry($course, $cm, $glossary, $entry, $tab="",$cat="")
         }
     }
 }
+function  glossary_print_entry_concept($entry) {
+        echo $entry->concept;
+}
+
+function glossary_print_entry_definition($entry) {
+    $definition = str_ireplace($entry->concept,"<nolink>$entry->concept</nolink>",$entry->definition);
+    echo format_text($definition, $entry->format);
+}
+
+function glossary_print_entry_attachment($entry,$format,$align) {
+///   valid format values: html  : Return the HTML link for the attachment as an icon
+///                        text  : Return the HTML link for tha attachment as text
+///                        blank : Print the output to the screen
+    if ($entry->attachment) {
+          $glossary = get_record("glossary","id",$entry->glossaryid);            
+          $entry->course = $glossary->course; //used inside print_attachment
+          echo "<table border=0 align=$align><tr><td>";
+          echo glossary_print_attachments($entry,$format,$align);
+          echo "</td></tr></table>";
+    }
+}
+
+function  glossary_print_entry_approval($cm, $entry, $tab) {
+    if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
+        echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&tab=$tab\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
+    }
+}
 
 function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$tab="",$cat="") {
     global $THEME, $USER;
@@ -256,19 +283,14 @@ function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$tab=""
     $colour = $THEME->cellheading2;
 
     echo "\n<TR>";
-    echo "<TD WIDTH=100% valign=\"top\" BGCOLOR=\"#FFFFFF\">";
-    if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
-        echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&tab=$tab\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
-    }
-    if ($entry->attachment) {
-          $entry->course = $course->id;
-          echo "<table border=0 align=right><tr><td>";
-          echo glossary_print_attachments($entry,"html");
-          echo "</td></tr></table>";
-    }
-    echo "<b>$entry->concept</b>: ";
-    echo format_text($entry->definition, $entry->format);
-    glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab,$cat);
+    echo "<TD WIDTH=100% class=\"generalbox\" valign=\"top\" BGCOLOR=\"#FFFFFF\">";
+        glossary_print_entry_approval($cm, $entry, $tab);
+        glossary_print_entry_attachment($entry,"html","right");
+        echo "<b>";
+        glossary_print_entry_concept($entry);
+        echo ":</b> ";
+        glossary_print_entry_definition($entry);
+        glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab,$cat);
     echo "</td>";
     echo "</TR>";
 }
@@ -276,21 +298,15 @@ function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$tab=""
 function glossary_print_entry_continuous($course, $cm, $glossary, $entry,$tab="",$cat="") {
     global $THEME, $USER;
     if ($entry) {
-        if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
-            echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&tab=$tab\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
-        }
-        if ($entry->attachment) {
-            $entry->course = $course->id;
-            echo "<table border=0 align=right><tr><td>";
-            echo glossary_print_attachments($entry, "html");
-            echo "</td></tr></table>";
-        }
-        echo " $entry->concept ";
-        echo format_text($entry->definition, $entry->format);
-
+        glossary_print_entry_approval($cm, $entry, $tab);
+        glossary_print_entry_attachment($entry,"html","right");
+        glossary_print_entry_concept($entry);
+        echo " ";
+        glossary_print_entry_definition($entry);
         glossary_print_entry_icons($course, $cm, $glossary, $entry, $tab, $cat);
     }
 }
+
 function glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab="",$cat="") {
     global $THEME, $USER;
 
@@ -953,11 +969,7 @@ function glossary_sort_entries ( $entry0, $entry1 ) {
 function glossary_print_comment($course, $cm, $glossary, $entry, $comment) {
     global $THEME, $CFG, $USER;
 
-//    if ($entry->timemarked < $entry->modified) {
-        $colour = $THEME->cellheading2;
-//    } else {
-//        $colour = $THEME->cellheading;
-//    }
+    $colour = $THEME->cellheading2;
 
     $user = get_record("user", "id", $comment->userid);
     $strby = get_string("writtenby","glossary");
@@ -972,7 +984,7 @@ function glossary_print_comment($course, $cm, $glossary, $entry, $comment) {
     echo "<br><FONT SIZE=1>(".get_string("lastedited").": ".userdate($comment->timemodified).")</FONT></small><br>";
     echo "</TD>";
 
-    echo "<TD NOWRAP valign=top WIDTH=75% BGCOLOR=\"$THEME->cellcontent\">";
+    echo "<TD valign=top WIDTH=75% BGCOLOR=\"$THEME->cellcontent\">";
     if ($comment) {
         echo format_text($comment->comment, $comment->format);
     } else {
@@ -995,30 +1007,28 @@ function glossary_print_comment($course, $cm, $glossary, $entry, $comment) {
     echo "</td></tr></table>";
 }
 
-    function glossary_print_dynaentry($courseid, $entries) {
-        global $THEME, $USER;
-
-        $colour = $THEME->cellheading2;
-
-        echo "\n<center><table width=95% border=0><tr>";
-        echo "<td width=100%\">";
-        if ( $entries ) {
-            foreach ( $entries as $entry ) {
+function glossary_print_dynaentry($courseid, $entries) {
+    global $THEME, $USER;
 
-                if (! $glossary = get_record("glossary", "id", $entry->glossaryid)) {
-                    error("Glossary ID was incorrect or no longer exists");
-                }
-                if (! $course = get_record("course", "id", $glossary->course)) {
-                    error("Glossary is misconfigured - don't know what course it's from");
-                }
-                if (!$cm = get_coursemodule_from_instance("glossary", $entry->glossaryid, $courseid) ) {
-                    error("Glossary is misconfigured - don't know what course module it is ");
-                }
+    $colour = $THEME->cellheading2;
 
-                glossary_print_entry($course, $cm, $glossary, $entry);
+    echo "\n<center><table width=95% border=0><tr>";
+    echo "<td width=100%\">";
+    if ( $entries ) {
+        foreach ( $entries as $entry ) {
+            if (! $glossary = get_record("glossary", "id", $entry->glossaryid)) {
+                error("Glossary ID was incorrect or no longer exists");
             }
+            if (! $course = get_record("course", "id", $glossary->course)) {
+                error("Glossary is misconfigured - don't know what course it's from");
+            }
+            if (!$cm = get_coursemodule_from_instance("glossary", $entry->glossaryid, $courseid) ) {
+                error("Glossary is misconfigured - don't know what course module it is ");
+            }
+            glossary_print_entry($course, $cm, $glossary, $entry);
         }
-        echo "</td>";
-        echo "</tr></table></center>";
     }
+    echo "</td>";
+    echo "</tr></table></center>";
+}
 ?>
index 183ecf9ef0a6ece0e73f3830c11b7b1d38564fad..14725e28c79e31ead99df2b7aee09e5d063b086e 100644 (file)
     } 
     add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id&tab=$tab", "$glossary->id");
     
+/// stablishing default tab
+    $framebydefault = GLOSSARY_STANDARD_VIEW;
+    if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) {
+        $framebydefault = GLOSSARY_DATE_VIEW;
+    }
 
 /// checking for valid values for sortorder and sortkey
     if ( $sortorder = strtolower($sortorder) ) {
         if ($sortorder != 'asc' and $sortorder != 'desc') {
             $sortorder = '';
         } else {
-            $l = '';
+            $l = ''; /// if we are sorting by date, reset the searching by terms or letters
             $search = '';
         }
     }
             $sortkey = '';
         }
     }
+/// in this point:
+///       $sortkey   = CREATION | UPDATE | ''
+///       $sortorder = asc | desc | ''
+
+    if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
+        $tab = $framebydefault;
 
-    if ( $sortkey or $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) {
-        if ( !$sortkey and $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) {
+        if ( !$sortkey ) {
             $sortkey = 'CREATION';
-            $sortorder = 'asc';
         } 
         if ( !$sortorder ) {
             $sortorder = 'asc';
         }
     } else {
-        $orderby = 'concept ASC';
+        if ( !$sortkey ) {
+            $sortkey = 'concept';
+        } 
+        if ( !$sortorder ) {
+            $sortorder = 'asc';
+        }
     }
 
 // creating matrix of words to search if apply
     $search = trim(strip_tags($search));
-    if ($search and !$eid) {
+    if ($search and !$eid) {   /// searching terms
         $l = '';
         $searchterms = explode(' ', $search); // Search for words independently
         foreach ($searchterms as $key => $searchterm) {
             } 
         } 
         $search = trim(implode(' ', $searchterms));
-        $tab = GLOSSARY_STANDARD_VIEW;
-    } elseif ($eid) {
+        $tab = $framebydefault;
+    } elseif ($eid) {   /// searching a specify entry
         $search = '';
     } 
 
     $alphabet = explode('|', get_string("alphabet","glossary"));
-    if ($l == '' and $search == '' and $sortkey == '' and !$eid) {
+    if ($l == '' and $search == '' and !$eid) {
         // if the user is just entering the glossary...
         if ($tab != GLOSSARY_APPROVAL_VIEW) {
             $l = $alphabet[0];
         } else {
-            $l = 'ALL';
+            $l = 'ALL';  /// show ALL by default in the waiting approval frame
         }
     } elseif ($eid) {
         $l = '';
     $glossary_tCFG->TabsPerRow = 4;
     $glossary_tCFG->TabSeparation = 4;
 
-    $data[GLOSSARY_STANDARD_VIEW]->link = "view.php?id=$id";
     $data[GLOSSARY_STANDARD_VIEW]->caption = get_string("standardview", "glossary");
-    
-    $data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_CATEGORY_VIEW;
     $data[GLOSSARY_CATEGORY_VIEW]->caption = get_string("categoryview", "glossary");
-    
-    $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_DATE_VIEW;
     $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 = "";
             $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 = GLOSSARY_STANDARD_VIEW;
+            $tab = $framebydefault;
         }
     } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) {
-        $tab = GLOSSARY_STANDARD_VIEW;
+        $tab = $framebydefault;
     }
 
 /// printing header of the current tab
     
 /// Printing the entries
 
+    switch ($sortkey) {
+        case 'CREATION':
+            $orderby = "timecreated $sortorder";
+        break;
+        case 'UPDATE':
+            $orderby = "timemodified $sortorder";
+        break;
+               default:
+            $orderby = "$sortkey $sortorder";
+    }
+    
     switch ($tab) {
         case GLOSSARY_CATEGORY_VIEW:
             if ($cat == GLOSSARY_SHOW_ALL_CATEGORIES) { 
             } elseif ($eid) { // looking for an entry
                 $allentries = get_records_select("glossary_entries", "id = $eid");
             } elseif ( $l or $sortkey ) {
-                if ($sortkey == 'CREATION') {
-                    $orderby = "timecreated $sortorder";
-                } else {
-                    $orderby = "timemodified $sortorder";
-                }
                 $where = '';
                 if ($l != 'ALL' and $l != 'SPECIAL') {
                     switch ($CFG->dbtype) {
     } else {
         switch ($glossary->displayformat) {
             case GLOSSARY_FORMAT_CONTINUOUS:
-                echo '</td></tr></table>';
+                echo '</td></tr></table><p>';
             break;
             case GLOSSARY_FORMAT_SIMPLE:
-                echo '</table></center>';
+                echo '</table></center><p>';
             break;
         } 
     }