]> git.mjollnir.org Git - moodle.git/commitdiff
Old-awaiting for 1.4.2 release changes in the glossary.
authorstronk7 <stronk7>
Tue, 9 Nov 2004 23:23:04 +0000 (23:23 +0000)
committerstronk7 <stronk7>
Tue, 9 Nov 2004 23:23:04 +0000 (23:23 +0000)
Now, print view is different for each format (consistent with it).
New, custom formats can, optionally, define their print view. Else
the default one will be used.
With this, 1.4.x glossary developments are finished and we can start
solving some pending things in 1.5...

Merged from MOODLE_14_STABLE

mod/glossary/formats/TEMPLATE/TEMPLATE_format.php
mod/glossary/formats/continuous/continuous_format.php
mod/glossary/formats/dictionary/dictionary_format.php
mod/glossary/formats/encyclopedia/encyclopedia_format.php
mod/glossary/formats/entrylist/entrylist_format.php
mod/glossary/formats/faq/faq_format.php
mod/glossary/formats/fullwithauthor/fullwithauthor_format.php
mod/glossary/formats/fullwithoutauthor/fullwithoutauthor_format.php
mod/glossary/lib.php
mod/glossary/print.php
mod/glossary/version.php

index 12cbaefe6546eecd7e64928e0a52c8fbf0f57d21..1faaf60047df301447b5659be6d4d28d73b09e70 100755 (executable)
@@ -1,6 +1,6 @@
 <?php  // $Id$
 
-function glossary_show_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL) {
+function glossary_show_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL, $aliases=true) {
 
     global $THEME, $CFG, $USER;
 
@@ -69,17 +69,18 @@ function glossary_show_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode="",
         //Line separator to show this template fine. :-)
         echo "<br />\n";
 
-        //Use this function to show aliases, editing icons and ratings
+        //Use this function to show aliases, editing icons and ratings (all know as the 'lower section')
         //Comments: You can configure this parameters:
         //----Define when to show the aliases popup
-        $aliases = true; //Values: true, false (Default: true)
+        //    use it only if you are really sure!
+        //$aliases = true; //Values: true, false (Default: true)
         //----Uncoment this line to avoid ratings being showed
         //    use it only if you are really sure! You can define this in the glossary conf. page.
         //$ratings = NULL;
         //----Uncoment this line to avoid editing icons being showed
         //    use it only if you are really sure!
         //$printicons = false;
-        $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings,$aliases);
+        $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases);
     } else {    
         echo "<center>";
         print_string("noentry", "glossary");
@@ -92,4 +93,17 @@ function glossary_show_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode="",
     return $return;
 }
 
+function glossary_print_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL) {
+
+    //The print view for this format is exactly the normal view, so we use it
+    //Anyway, you can modify this to use your own print format!!
+
+    //Take out autolinking in definitions in print view
+    $entry->definition = '<nolink>'.$entry->definition.'</nolink>';
+
+    //Call to view function (without icons, ratings and aliases) and return its result
+    return glossary_show_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode, $hook, false, false, false);
+
+}
+
 ?>
index f574e56631e090b17653c228b1c3ed6bdc3f39ff..403b3ae4a7adae534f53eba5382fb1c3c6c6c958 100644 (file)
@@ -1,6 +1,6 @@
 <?php  // $Id$
 
-function glossary_show_entry_continuous($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL) {
+function glossary_show_entry_continuous($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL, $aliases=false) {
 
     global $THEME, $USER;
 
@@ -16,7 +16,7 @@ function glossary_show_entry_continuous($course, $cm, $glossary, $entry, $mode="
     echo ":</b> ";
     glossary_print_entry_definition($entry);
     $entry->alias = "";
-    $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings,false);
+    $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases);
     echo "</td>\n";
     echo "</tr>\n";
     echo "</table>\n";
@@ -24,4 +24,16 @@ function glossary_show_entry_continuous($course, $cm, $glossary, $entry, $mode="
     return $return;
 }
 
+function glossary_print_entry_continuous($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL) {
+
+    //The print view for this format is exactly the normal view, so we use it
+
+    //Take out autolinking in definitions un print view
+    $entry->definition = '<nolink>'.$entry->definition.'</nolink>';
+
+    //Call to view function (without icons, ratings and aliases) and return its result
+    return glossary_show_entry_continuous($course, $cm, $glossary, $entry, $mode, $hook, false, false, false);
+    
+}
+
 ?>
index 501e4364b78ad46df5b4da1ef12d322a4fdf7351..1ce0b08035020a0136661943b3b2fe12472406f1 100644 (file)
@@ -1,6 +1,6 @@
 <?php  // $Id$
 
-function glossary_show_entry_dictionary($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL) {
+function glossary_show_entry_dictionary($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL, $aliases=true) {
 
     global $THEME, $CFG, $USER;
 
@@ -15,7 +15,7 @@ function glossary_show_entry_dictionary($course, $cm, $glossary, $entry, $mode="
     glossary_print_entry_concept($entry);
     echo ":</b> ";
     glossary_print_entry_definition($entry);
-    $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings);
+    $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases);
     echo "</td>\n";
     echo "</tr>\n";
     echo "</table>\n";
@@ -23,4 +23,15 @@ function glossary_show_entry_dictionary($course, $cm, $glossary, $entry, $mode="
     return $return;
 }
 
+function glossary_print_entry_dictionary($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL) {
+
+    //The print view for this format is exactly the normal view, so we use it
+
+    //Take out autolinking in definitions in print view
+    $entry->definition = '<nolink>'.$entry->definition.'</nolink>';
+
+    //Call to view function (without icons, ratings and aliases) and return its result
+    return glossary_show_entry_dictionary($course, $cm, $glossary, $entry, $mode, $hook, false, false, false);
+}
+
 ?>
index 58ff4bcd7b36ec5cf47cbddeec8fbc00eb3d0986..96e06eb02cb87fca17fe70de3af900f2c3ac3290 100644 (file)
@@ -1,6 +1,6 @@
 <?php  // $Id$
 
-function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL) {
+function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL, $aliases=true) {
     global $THEME, $CFG, $USER;
 
     $colour = $THEME->cellheading2;
@@ -47,9 +47,14 @@ function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode
             glossary_print_entry_attachment($entry,"",$align,false);
         }
         glossary_print_entry_definition($entry);
-
-        $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings);
-        echo ' ';
+        if ($printicons or $ratings or $aliases) {
+            echo "</td></tr>";
+            echo "\n<td bgcolor=\"$colour\" width=35 valign=top class=\"forumpostside\">&nbsp;</td>";
+            echo "\n<td width=100% colspan=\"2\" bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">";
+    
+            $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings, $aliases);
+            echo ' ';
+        }
     } else {
         echo "<center>";
         print_string("noentry", "glossary");
@@ -62,4 +67,16 @@ function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode
     return $return;
 }
 
+function glossary_print_entry_encyclopedia($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL) {
+
+    //The print view for this format is exactly the normal view, so we use it
+
+    //Take out autolinking in definitions un print view
+    $entry->definition = '<nolink>'.$entry->definition.'</nolink> ';
+
+    //Call to view function (without icons, ratings and aliases) and return its result
+    return glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode, $hook, false, false, false);
+
+}
+
 ?>
index 1c39cc1536d06d898df1756908ecb2ab37f42cb0..fa19fd87e00bdfc70c3e20be0e34244ff72854e4 100644 (file)
@@ -1,6 +1,6 @@
 <?php  // $Id$
 
-function glossary_show_entry_entrylist($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL) {
+function glossary_show_entry_entrylist($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL, $aliases=true) {
     global $THEME, $USER;
 
     $colour = "#FFFFFF";
@@ -31,4 +31,29 @@ function glossary_show_entry_entrylist($course, $cm, $glossary, $entry, $mode=""
     return $return;
 }
 
+function glossary_print_entry_entrylist($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL) {
+
+    //The print view for this format is different from the normal view, so we implement it here completely
+    global $THEME, $CFG, $USER;
+
+    $colour = $THEME->cellheading2;
+
+    //Take out autolinking in definitions un print view
+    $entry->definition = '<nolink>'.$entry->definition.'</nolink>';
+
+    echo "\n<table border=0 width=95% cellspacing=0 valign=top cellpadding=3 class=forumpost align=center>\n";
+    echo "<tr>\n";
+    echo "<td width=\"100%\" valign=\"top\" bgcolor=\"#FFFFFF\">\n";
+    echo "<b>";
+    glossary_print_entry_concept($entry);
+    echo ":</b> ";
+    glossary_print_entry_definition($entry);
+    $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, false, false, false);
+    echo "</td>\n";
+    echo "</tr>\n";
+    echo "</table>\n";
+
+    return $return;
+}
+
 ?>
index 7b69eda6326dec06f2cd09efd96d38e4f592f23d..2f1332cea00cc634f8c92c9cd0ccd3dd71cafb6c 100644 (file)
@@ -1,6 +1,6 @@
 <?php  // $Id$
 
-function glossary_show_entry_faq($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL) {
+function glossary_show_entry_faq($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL, $aliases=true) {
     global $THEME, $USER;
     $return = false;
     if ( $entry ) {
@@ -34,7 +34,7 @@ function glossary_show_entry_faq($course, $cm, $glossary, $entry, $mode="",$hook
         glossary_print_entry_definition($entry);
 
 
-        $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook,$printicons,$ratings);
+        $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases);
         echo '</td></tr></table>';
 
     } else {
@@ -45,4 +45,16 @@ function glossary_show_entry_faq($course, $cm, $glossary, $entry, $mode="",$hook
     return $return;
 }
 
+function glossary_print_entry_faq($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL) {
+
+    //The print view for this format is exactly the normal view, so we use it
+
+    //Take out autolinking in definitions un print view
+    $entry->definition = '<nolink>'.$entry->definition.'</nolink>';
+
+    //Call to view function (without icons, ratings and aliases) and return its result
+    return glossary_show_entry_faq($course, $cm, $glossary, $entry, $mode, $hook, false, false, false);
+
+}
+
 ?>
index e93a276370e63e377a3be33d497d9ed7c5b71650..a1e25ad868f248cdf6293b7569b3d1462be51a12 100644 (file)
@@ -1,6 +1,6 @@
 <?php  // $Id$
 
-function glossary_show_entry_fullwithauthor($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL) {
+function glossary_show_entry_fullwithauthor($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL, $aliases=true) {
     global $THEME, $CFG, $USER;
 
     $colour = $THEME->cellheading2;
@@ -40,7 +40,7 @@ function glossary_show_entry_fullwithauthor($course, $cm, $glossary, $entry, $mo
         echo "\n<td width=\"100%\" colspan=\"2\" bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">";
 
         glossary_print_entry_definition($entry);
-        $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings);
+        $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases);
         echo ' ';
     } else {
         echo "<center>";
@@ -53,4 +53,16 @@ function glossary_show_entry_fullwithauthor($course, $cm, $glossary, $entry, $mo
     return $return;
 }
 
+function glossary_print_entry_fullwithauthor($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL) {
+
+    //The print view for this format is exactly the normal view, so we use it
+
+    //Take out autolinking in definitions un print view
+    $entry->definition = '<nolink>'.$entry->definition.'</nolink>';
+
+    //Call to view function (without icons, ratings and aliases) and return its result
+    return glossary_show_entry_fullwithauthor($course, $cm, $glossary, $entry, $mode, $hook, false, false, false);
+
+}
+
 ?>
index 4a3cf2c1223e0f83d8fb3b621a73cdb70d89621c..c8efaa7a5fa27e1ebf16742dcaa9d7cb273c566c 100644 (file)
@@ -1,6 +1,6 @@
 <?php  // $Id$
 
-function glossary_show_entry_fullwithoutauthor($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1,$ratings=NULL) {
+function glossary_show_entry_fullwithoutauthor($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL, $aliases=true) {
     global $THEME, $CFG, $USER;
 
     $colour = $THEME->cellheading2;
@@ -32,7 +32,7 @@ function glossary_show_entry_fullwithoutauthor($course, $cm, $glossary, $entry,
         echo "\n<td width=\"100%\" colspan=\"2\" bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">";
 
         glossary_print_entry_definition($entry);
-        $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings);
+        $return = glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $ratings, $aliases);
         echo ' ';
     } else {
         echo "<center>";
@@ -45,4 +45,16 @@ function glossary_show_entry_fullwithoutauthor($course, $cm, $glossary, $entry,
     return $return;
 }
 
+function glossary_print_entry_fullwithoutauthor($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL) {
+
+    //The print view for this format is exactly the normal view, so we use it
+
+    //Take out autolinking in definitions un print view
+    $entry->definition = '<nolink>'.$entry->definition.'</nolink>';
+
+    //Call to view function (without icons, ratings and aliases) and return its result
+    return glossary_show_entry_fullwithoutauthor($course, $cm, $glossary, $entry, $mode, $hook, false, false, false);
+
+}
+
 ?>
index 5a7af74149e0e0a666c34f0ebae28a3de15fec4e..4dc39cf522b140d0f9b6732b1fa48c86524bb4e0 100644 (file)
@@ -528,7 +528,7 @@ global $CFG;
                                              (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) $where $orderby");
 }
 
-function glossary_print_entry($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons = 1, $displayformat  = -1, $ratings = NULL) {
+function glossary_print_entry($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons = 1, $displayformat  = -1, $ratings = NULL, $printview = false) {
     global $THEME, $USER, $CFG;
     $return = false;
     if ( $displayformat < 0 ) {
@@ -536,17 +536,32 @@ function glossary_print_entry($course, $cm, $glossary, $entry, $mode="",$hook=""
     }
     if ($entry->approved or ($USER->id == $entry->userid) or ($mode == 'approval' and !$entry->approved) ) {
         $formatfile = $CFG->dirroot.'/mod/glossary/formats/'.$displayformat.'/'.$displayformat.'_format.php';
-        $functionname = 'glossary_show_entry_'.$displayformat;
+        if ($printview) {
+            $functionname = 'glossary_print_entry_'.$displayformat;
+        } else {
+            $functionname = 'glossary_show_entry_'.$displayformat;
+        }
 
         if (file_exists($formatfile)) {
             include_once($formatfile);
             if (function_exists($functionname)) {
                 $return = $functionname($course, $cm, $glossary, $entry,$mode,$hook,$printicons,$ratings);
+            } else if ($printview) {
+                //If the glossary_print_entry_XXXX function doesn't exist, print default (old) print format
+                $return = glossary_print_entry_default($entry);
             }
         }
     }
     return $return;
 }
+ //Default (old) print format used if custom function doesn't exist in format
+function glossary_print_entry_default ($entry) {
+    echo '<b>'. strip_tags($entry->concept) . ': </b>';
+    $options->para = false;
+    $definition = format_text('<nolink>' . strip_tags($entry->definition) . '</nolink>', $entry->format,$options);
+    echo ($definition);
+    echo '<br /><br />';
+}
 
 function  glossary_print_entry_concept($entry) {
     $options->para = false;
@@ -1351,7 +1366,7 @@ global $CFG, $THEME;
                          $selected = $url;
                      }
                  }
-                 $menu[$url] = $currentcategory->name;
+                 $menu[$url] = clean_text($currentcategory->name); //Only clean, not filters
           }
      }
      if ( !$selected ) {
@@ -1359,7 +1374,7 @@ global $CFG, $THEME;
      }
 
      if ( $category ) {
-        echo $category->name;
+        echo format_text($category->name);
      } else {
         if ( $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
 
index 2b01064f5b5d6f0db0e8ac573ba54b93c924a243..413ed2e8745329fc17281f2bc7798d2dc83ce826 100644 (file)
     echo get_string("modulename","glossary") . ': <strong>' . $glossary->name . '</strong><p>';
     if ( $allentries ) {
         foreach ($allentries as $entry) {
-        /// Setting the pivot for the current entry
+
+            // Setting the pivot for the current entry
             $pivot = $entry->pivot;
             if ( !$fullpivot ) {
                 $pivot = $pivot[0];
             }            
             
+            // If there's  group break
             if ( $currentpivot != strtoupper($pivot) ) {  
+
                 // print the group break if apply
                 if ( $printpivot )  {
                     $currentpivot = strtoupper($pivot);
 
                     $pivottoshow = $currentpivot;
                     if ( isset($entry->uid) ) {
+                        // printing the user icon if defined (only when browsing authors)
                         $user = get_record("user","id",$entry->uid);
                         $pivottoshow = fullname($user, isteacher($course->id));
                     }
 
-                    echo "<p align=\"center\"><strong><i>$pivottoshow</i></strong></p>" ;
+                    echo "<p align=\"center\"><strong><i>".clean_text($pivottoshow)."</i></strong></p>" ;
                 }
             }
 
-            echo '<b>'. strip_tags($entry->concept) . ': </b>';
-            $options->para = false;
-            $definition = format_text('<nolink>' . strip_tags($entry->definition) . '</nolink>', $entry->format,$options);
-    
-            echo ($definition);
-        
-            echo '<br /><br />';
+            glossary_print_entry($course, $cm, $glossary, $entry, $mode, $hook,1,$displayformat,false,true);
         }
     }
 
index 29e1f4386da34fe1651fc7d05b45a454a809b6a5..2fcb05005f8016d07e5a649422e1fb79ca71549e 100644 (file)
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2004091700;
+$module->version  = 2004111000;
 $module->requires = 2004091700;  // Requires this Moodle version
 $module->cron     = 0;           // Period for cron to check this module (secs)