[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/grade/report/history/classes/output/ -> renderer.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Renderer for history grade report.
  19   *
  20   * @package    gradereport_history
  21   * @copyright  2013 NetSpot Pty Ltd (https://www.netspot.com.au)
  22   * @author     Adam Olley <adam.olley@netspot.com.au>
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  namespace gradereport_history\output;
  27  
  28  defined('MOODLE_INTERNAL') || die;
  29  
  30  /**
  31   * Renderer for history grade report.
  32   *
  33   * @since      Moodle 2.8
  34   * @package    gradereport_history
  35   * @copyright  2013 NetSpot Pty Ltd (https://www.netspot.com.au)
  36   * @author     Adam Olley <adam.olley@netspot.com.au>
  37   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  38   */
  39  class renderer extends \plugin_renderer_base {
  40  
  41      /**
  42       * Render for the select user button.
  43       *
  44       * @param user_button $button instance of  gradereport_history_user_button to render
  45       *
  46       * @return string HTML to display
  47       */
  48      protected function render_user_button(user_button $button) {
  49          $attributes = array('type'     => 'button',
  50                              'class'    => 'selectortrigger',
  51                              'value'    => $button->label,
  52                              'disabled' => $button->disabled ? 'disabled' : null,
  53                              'title'    => $button->tooltip);
  54  
  55          if ($button->actions) {
  56              $id = \html_writer::random_id('single_button');
  57              $attributes['id'] = $id;
  58              foreach ($button->actions as $action) {
  59                  $this->add_action_handler($action, $id);
  60              }
  61          }
  62          // First the input element.
  63          $output = \html_writer::empty_tag('input', $attributes);
  64  
  65          // Then hidden fields.
  66          $params = $button->url->params();
  67          if ($button->method === 'post') {
  68              $params['sesskey'] = sesskey();
  69          }
  70          foreach ($params as $var => $val) {
  71              $output .= \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $var, 'value' => $val));
  72          }
  73  
  74          // Then div wrapper for xhtml strictness.
  75          $output = \html_writer::tag('div', $output);
  76  
  77          // Now the form itself around it.
  78          if ($button->method === 'get') {
  79              $url = $button->url->out_omit_querystring(true); // Url without params, the anchor part allowed.
  80          } else {
  81              $url = $button->url->out_omit_querystring();     // Url without params, the anchor part not allowed.
  82          }
  83          if ($url === '') {
  84              $url = '#'; // There has to be always some action.
  85          }
  86          $attributes = array('method' => $button->method,
  87                              'action' => $url,
  88                              'id'     => $button->formid);
  89          $output = \html_writer::tag('div', $output, $attributes);
  90  
  91          // Finally one more wrapper with class.
  92          return \html_writer::tag('div', $output, array('class' => $button->class));
  93      }
  94  
  95      /**
  96       * Get the html for the table.
  97       *
  98       * @param tablelog $tablelog table object.
  99       *
 100       * @return string table html
 101       */
 102      protected function render_tablelog(tablelog $tablelog) {
 103          $o = '';
 104          ob_start();
 105          $tablelog->out($tablelog->pagesize, false);
 106          $o = ob_get_contents();
 107          ob_end_clean();
 108  
 109          return $o;
 110      }
 111  
 112  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1