Ejemplo n.º 1
0
 /**
  * Constructor
  *
  * @param mr_preferences $preferences Preferences to store paging information
  * @param moodle_url $url Current URL
  */
 public function __construct(mr_preferences $preferences, moodle_url $url)
 {
     $this->url = $url;
     $this->preferences = $preferences;
     $defultperpage = $this->preferences->get($this->REQUEST_PERPAGE, $this->perpage);
     $this->page = optional_param($this->REQUEST_PAGE, 0, PARAM_INT);
     $this->perpage = optional_param($this->REQUEST_PERPAGE, $defultperpage, PARAM_INT);
     // Save for later
     $this->preferences->set($this->REQUEST_PERPAGE, $this->perpage);
 }
Ejemplo n.º 2
0
 /**
  * Run the report SQL and retrieve rows for rendering or exporting.
  *
  * This method also sends the export to the browser if the
  * user is exporting the report.
  *
  * @return void
  */
 public function run()
 {
     // Initialize the tables and the filters
     $this->table_init();
     $this->filter_init();
     if ($this->filter instanceof mr_html_filter) {
         $this->filter->set_report($this);
     }
     // Determine if we are doing AJAX
     if (!$this->is_exporting() and $this->config->ajax and $this->preferences->get('forceajax', $this->config->ajaxdefault)) {
         if (optional_param('tjson', 0, PARAM_BOOL)) {
             // Filling on AJAX request
             $this->table_fill();
         }
     } else {
         // Normal fill...
         $this->table_fill();
     }
     // If exporting, send it to the browser
     if ($this->is_exporting()) {
         $this->export->send();
     }
 }
Ejemplo n.º 3
0
 /**
  * Setup
  *
  * @param mr_preferences $preferences User preferences
  * @param moodle_url $url Base url
  * @param string $sort Sorting field
  * @param int|string $order Sorting order
  */
 public function __construct($preferences, moodle_url $url, $sort = '', $order = SORT_ASC)
 {
     $this->url = $url;
     $this->preferences = $preferences;
     $this->helper = new mr_helper();
     $this->defaultsort = $sort;
     $this->defaultorder = $order;
     $this->emptymessage = get_string('nothingtodisplay');
     // Get prior sort information
     $this->sort = optional_param($this->REQUEST_SORT, $preferences->get('sort', $sort), PARAM_SAFEDIR);
     $this->order = $preferences->get('order', $order);
     if ($orderp = optional_param($this->REQUEST_ORDER, '', PARAM_SAFEDIR)) {
         if ($orderp == SORT_ASC) {
             $this->order = SORT_ASC;
         } else {
             $this->order = SORT_DESC;
         }
     }
     // Save sort order
     $this->save_sortorder();
 }
Ejemplo n.º 4
0
 /**
  * Get a preference value (default can be returned)
  *
  * @param string $name Preference name
  * @return mixed
  */
 public function preferences_get($name)
 {
     $defaults = $this->preferences_defaults();
     return $this->preferences->get($name, $defaults[$name]);
 }