[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/mod/glossary/ -> print.php (source)

   1  <?php   // $Id: print.php,v 1.41.2.1 2007/12/14 21:21:07 skodak Exp $
   2  
   3      global $CFG;
   4  
   5      require_once("../../config.php");
   6      require_once ("lib.php");
   7  
   8      $id            = required_param('id', PARAM_INT);                     // Course Module ID
   9      $sortorder     = optional_param('sortorder', 'asc', PARAM_ALPHA);     // Sorting order
  10      $offset        = optional_param('offset', 0, PARAM_INT);              // number of entries to bypass
  11      $displayformat = optional_param('displayformat',-1, PARAM_INT);
  12  
  13      $mode    = required_param('mode', PARAM_ALPHA);             // mode to show the entries
  14      $hook    = optional_param('hook','ALL', PARAM_ALPHANUM);   // what to show
  15      $sortkey = optional_param('sortkey','UPDATE', PARAM_ALPHA); // Sorting key
  16  
  17      if (! $cm = get_coursemodule_from_id('glossary', $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      if ( !$entriesbypage = $glossary->entbypage ) {
  30          $entriesbypage = $CFG->glossary_entbypage;
  31      }
  32  
  33      print_header();
  34  
  35      require_course_login($course, true, $cm);
  36      $context = get_context_instance(CONTEXT_MODULE, $cm->id);
  37  
  38  /// Loading the textlib singleton instance. We are going to need it.
  39      $textlib = textlib_get_instance();
  40  
  41      if (!has_capability('mod/glossary:manageentries', $context) and !$glossary->allowprintview) {
  42          notice(get_string('printviewnotallowed', 'glossary'));
  43      }
  44  
  45  /// setting the default values for the display mode of the current glossary
  46  /// only if the glossary is viewed by the first time
  47      if ( $dp = get_record('glossary_formats','name', addslashes($glossary->displayformat)) ) {
  48          $printpivot = $dp->showgroup;
  49          if ( $mode == '' and $hook == '' and $show == '') {
  50              $mode      = $dp->defaultmode;
  51              $hook      = $dp->defaulthook;
  52              $sortkey   = $dp->sortkey;
  53              $sortorder = $dp->sortorder;
  54          }
  55      } else {
  56          $printpivot = 1;
  57          if ( $mode == '' and $hook == '' and $show == '') {
  58              $mode = 'letter';
  59              $hook = 'ALL';
  60          }
  61      }
  62  
  63      if ( $displayformat == -1 ) {
  64           $displayformat = $glossary->displayformat;
  65      }
  66  
  67  /// stablishing flag variables
  68      if ( $sortorder = strtolower($sortorder) ) {
  69          if ($sortorder != 'asc' and $sortorder != 'desc') {
  70              $sortorder = '';
  71          }
  72      }
  73      if ( $sortkey = strtoupper($sortkey) ) {
  74          if ($sortkey != 'CREATION' and
  75              $sortkey != 'UPDATE' and
  76              $sortkey != 'FIRSTNAME' and
  77              $sortkey != 'LASTNAME'
  78              ) {
  79              $sortkey = '';
  80          }
  81      }
  82  
  83      switch ( $mode = strtolower($mode) ) {
  84      case 'entry':  /// Looking for a certain entry id
  85          $tab = GLOSSARY_STANDARD_VIEW;
  86      break;
  87  
  88      case 'cat':    /// Looking for a certain cat
  89          $tab = GLOSSARY_CATEGORY_VIEW;
  90          if ( $hook > 0 ) {
  91              $category = get_record("glossary_categories","id",$hook);
  92          }
  93      break;
  94  
  95      case 'approval':    /// Looking for entries waiting for approval
  96          $tab = GLOSSARY_APPROVAL_VIEW;
  97          if ( !$hook and !$sortkey and !$sortorder) {
  98              $hook = 'ALL';
  99          }
 100      break;
 101  
 102      case 'term':   /// Looking for entries that include certain term in its concept, definition or aliases
 103          $tab = GLOSSARY_STANDARD_VIEW;
 104      break;
 105  
 106      case 'date':
 107          $tab = GLOSSARY_DATE_VIEW;
 108          if ( !$sortkey ) {
 109              $sortkey = 'UPDATE';
 110          }
 111          if ( !$sortorder ) {
 112              $sortorder = 'desc';
 113          }
 114      break;
 115  
 116      case 'author':  /// Looking for entries, browsed by author
 117          $tab = GLOSSARY_AUTHOR_VIEW;
 118          if ( !$hook ) {
 119              $hook = 'ALL';
 120          }
 121          if ( !$sortkey ) {
 122              $sortkey = 'FIRSTNAME';
 123          }
 124          if ( !$sortorder ) {
 125              $sortorder = 'asc';
 126          }
 127      break;
 128  
 129      case 'letter':  /// Looking for entries that begin with a certain letter, ALL or SPECIAL characters
 130      default:
 131          $tab = GLOSSARY_STANDARD_VIEW;
 132          if ( !$hook ) {
 133              $hook = 'ALL';
 134          }
 135      break;
 136      }
 137  
 138      include_once ("sql.php");
 139  
 140      $entriesshown = 0;
 141      $currentpivot = '';
 142      if ( $hook == 'SPECIAL' ) {
 143          $alphabet = explode(",", get_string("alphabet"));
 144      }
 145  
 146      $site = get_record("course","id",1);
 147      echo '<p style="text-align:right"><span style="font-size:0.75em">' . userdate(time()) . '</span></p>';
 148      echo get_string("site") . ': <strong>' . format_string($site->fullname) . '</strong><br />';
 149      echo get_string("course") . ': <strong>' . format_string($course->fullname) . ' ('. format_string($course->shortname) . ')</strong><br />';
 150      echo get_string("modulename","glossary") . ': <strong>' . format_string($glossary->name, true) . '</strong>';
 151      if ( $allentries ) {
 152          foreach ($allentries as $entry) {
 153  
 154              // Setting the pivot for the current entry
 155              $pivot = $entry->glossarypivot;
 156              $upperpivot = $textlib->strtoupper($pivot);
 157              // Reduce pivot to 1cc if necessary
 158              if ( !$fullpivot ) {
 159                  $upperpivot = $textlib->substr($upperpivot, 0, 1);
 160              }            
 161              
 162              // If there's  group break
 163              if ( $currentpivot != $upperpivot ) {
 164  
 165                  // print the group break if apply
 166                  if ( $printpivot )  {
 167                      $currentpivot = $upperpivot;
 168  
 169                      $pivottoshow = $currentpivot;
 170                      if ( isset($entry->userispivot) ) {
 171                          // printing the user icon if defined (only when browsing authors)
 172                          $user = get_record("user","id",$entry->userid);
 173                          $pivottoshow = fullname($user);
 174                      }
 175  
 176                      echo "<p align=\"center\"><strong>".clean_text($pivottoshow)."</strong></p>" ;
 177                  }
 178              }
 179  
 180              glossary_print_entry($course, $cm, $glossary, $entry, $mode, $hook,1,$displayformat,false,true);
 181          }
 182      }
 183  
 184      print_footer('empty');
 185  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7