Beispiel #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);
 }
Beispiel #2
0
 /**
  * Update user preferences to current filter settings
  *
  * @param object $data Form data
  * @return mr_html_filter_abstract
  */
 public function preferences_update($data)
 {
     foreach ($this->preferences_defaults() as $name => $default) {
         if (!isset($data->{$name}) or $data->{$name} == $default) {
             $this->preferences_delete($name);
         } else {
             $this->preferences->set($name, stripslashes($data->{$name}));
         }
     }
     return $this;
 }
Beispiel #3
0
 /**
  * Run init routines
  *
  * @return void
  */
 protected function _init()
 {
     $this->init();
     // Determine if we can turn ajax on.
     if (($forceajax = optional_param('forceajax', -1, PARAM_INT)) != -1) {
         $this->preferences->set('forceajax', $forceajax);
     }
     // Setup Paging.
     $this->paging = new mr_html_paging($this->preferences, $this->url);
     if ($this->config->perpage) {
         $this->paging->set_perpageopts($this->config->perpageopts);
     }
     // Setup Export.
     if ($this->config->export) {
         $this->export = new mr_file_export($this->config->export, false, $this->url, $this->name());
     }
 }
Beispiel #4
0
 /**
  * Store sort and weight based on current settings
  *
  * @return void
  */
 protected function save_sortorder()
 {
     // Store sorting information if necessary
     if ($this->sort != $this->defaultsort) {
         // Sort not the same as default, save
         $this->preferences->set('sort', $this->sort);
     } else {
         // Sort same as default, remove
         $this->preferences->delete('sort');
     }
     if ($this->order != $this->defaultorder) {
         // Order not the same as default, save
         $this->preferences->set('order', $this->order);
     } else {
         // Order same as default, remove
         $this->preferences->delete('order');
     }
 }