Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   1  <?php
   2  
   3  function glossary_show_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode='', $hook='', $printicons=1, $aliases=true) {
   4      global $CFG, $USER, $DB, $OUTPUT;
   5  
   6  
   7      $user = $DB->get_record('user', array('id'=>$entry->userid));
   8      $strby = get_string('writtenby', 'glossary');
   9  
  10      if ($entry) {
  11  
  12          echo '<table class="glossarypost TEMPLATE">';
  13          echo '<tr>';
  14          echo '<td class="entryheader">';
  15  
  16          //Use this function to show author's image
  17          //Comments: Configuration not supported
  18          echo $OUTPUT->user_picture($user, array('courseid'=>$course->id));
  19  
  20          //Line separator to show this template fine. :-)
  21          echo '<br />';
  22  
  23          //Use this code to show author's name
  24          //Comments: Configuration not supported
  25          $fullname = fullname($user);
  26          $by = new stdClass();
  27          $by->name = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id.'">'.$fullname.'</a>';
  28          $by->date = userdate($entry->timemodified);
  29          echo '<span class="author">'.get_string('bynameondate', 'forum', $by).'</span>' . '<br />';
  30  
  31          //Use this code to show modification date
  32          //Comments: Configuration not supported
  33          echo get_string('lastedited').': '. userdate($entry->timemodified) . '<br /></span>';
  34  
  35          //Use this function to show the approval button. It'll be shown if necessary
  36          //Comments: You can configure this parameters:
  37          //----Define where to show the approval button
  38          $approvalalign = 'right'; //Values: left, center and right (default right)
  39          //----Define if the approval button must be showed into a 100% width table
  40          $approvalinsidetable = true; //Values: true, false (default true)
  41          //Call the function
  42          glossary_print_entry_approval($cm, $entry, $mode, $approvalalign, $approvalinsidetable);
  43  
  44          //Line separator to show this template fine. :-)
  45          echo '<br />';
  46  
  47          echo '</td>';
  48  
  49          echo '<td class="entryattachment">';
  50  
  51          //Line separator to show this template fine. :-)
  52          echo "<br />\n";
  53  
  54          echo '</td></tr>';
  55  
  56          echo '<tr valign="top">';
  57          echo '<td class="entry">';
  58  
  59          //Use this function to print the concept in a heading <h3>
  60          //Comments: Configuration not supported
  61          glossary_print_entry_concept($entry);
  62  
  63          //Line separator not normally needed now.
  64          //echo "<br />\n";
  65  
  66          //Use this function to show the definition
  67          //Comments: Configuration not supported
  68          glossary_print_entry_definition($entry, $glossary, $cm);
  69  
  70          // Use this function to show the attachment. It'll be shown if necessary.
  71          glossary_print_entry_attachment($entry, $cm, 'html');
  72  
  73          //Line separator to show this template fine. :-)
  74          echo "<br />\n";
  75  
  76          //Use this function to show aliases, editing icons and ratings (all know as the 'lower section')
  77          //Comments: You can configure this parameters:
  78          //----Define when to show the aliases popup
  79          //    use it only if you are really sure!
  80          //$aliases = true; //Values: true, false (Default: true)
  81          //----Uncoment this line to avoid editing icons being showed
  82          //    use it only if you are really sure!
  83          //$printicons = false;
  84          glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $aliases);
  85  
  86          echo '</td>';
  87          echo '</tr>';
  88          echo "</table>\n";
  89      } else {
  90          echo '<div style="text-align:center">';
  91          print_string('noentry', 'glossary');
  92          echo '</div>';
  93      }
  94  }
  95  
  96  function glossary_print_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode='', $hook='', $printicons=1) {
  97  
  98      //The print view for this format is exactly the normal view, so we use it
  99      //Anyway, you can modify this to use your own print format!!
 100  
 101      //Take out autolinking in definitions in print view
 102      $entry->definition = '<span class="nolink">'.$entry->definition.'</span>';
 103  
 104      //Call to view function (without icons, ratings and aliases) and return its result
 105      return glossary_show_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode, $hook, false, false, false);
 106  
 107  }
 108  
 109