Esempio n. 1
0
 /**
  * First option is default
  */
 public function preferences_defaults()
 {
     foreach ($this->options as $value => $option) {
         return array($this->name => $value);
     }
     return parent::preferences_defaults();
 }
Esempio n. 2
0
 /**
  * Checkbox filter constructor
  *
  * @param string $name Name for the filter instance
  * @param string $label Label to the left of the checkbox
  * @param string $rightlabel Label to the right of the checkbox
  * @param int $default The default state of the checkbox (0, 1)
  * @param array $checkedsql SQL to use when checked
  * @param array $uncheckedsql SQL to use when not checked
  * @param bool $advanced Whether or not the form element should be an advanced option
  * @param string $field The field to be used in the filter
  */
 public function __construct($name, $label, $rightlabel = '', $default = 0, $checkedsql = array(), $uncheckedsql = array(), $advanced = false, $field = NULL)
 {
     parent::__construct($name, $label, $advanced, $field);
     $this->rightlabel = $rightlabel;
     $this->default = $default;
     $this->checkedsql = $checkedsql;
     $this->uncheckedsql = $uncheckedsql;
 }
Esempio n. 3
0
 /**
  * Save as CSV value
  */
 public function preferences_update($data)
 {
     $raw = optional_param_array($this->name, '', PARAM_RAW);
     if (!empty($raw) and !empty($data->{$this->name})) {
         $data->{$this->name} = implode(',', $data->{$this->name});
     } else {
         $data->{$this->name} = '';
     }
     return parent::preferences_update($data);
 }
Esempio n. 4
0
 /**
  * Enforce checkboxes - if not set
  * then set date to 0
  */
 public function preferences_update($data)
 {
     $name = "{$this->name}_sc";
     if (empty($data->{$name})) {
         $name = "{$this->name}_sd";
         $data->{$name} = 0;
     }
     $name = "{$this->name}_ec";
     if (empty($data->{$name})) {
         $name = "{$this->name}_ed";
         $data->{$name} = 0;
     }
     return parent::preferences_update($data);
 }
Esempio n. 5
0
 /**
  * HTML "filter" constructor
  *
  * @param string $name - name for the filter instance
  * @param string $html - html to be added to the form
  */
 public function __construct($name, $html)
 {
     parent::__construct($name, null, false, '');
     $this->html = $html;
 }
Esempio n. 6
0
 /**
  * Adding an options param for the select options
  *
  * Options must be: array(recordID => 'display text')
  */
 public function __construct($name, $label, $options, $advanced = false, $field = NULL)
 {
     parent::__construct($name, $label, $advanced, $field);
     $this->options = $options;
 }
Esempio n. 7
0
 /**
  * Construct
  *
  * @param string $name Filter name
  * @param string $label Filter label
  * @param bool $advanced Filter advanced form setting
  * @param string $field SQL field, defaults to $name
  * @param array $attributes
  */
 public function __construct($name, $label, $advanced = false, $field = NULL, $attributes = array())
 {
     $this->attributes = $attributes;
     parent::__construct($name, $label, $advanced, $field);
 }
Esempio n. 8
0
 /**
  * Add a filter
  *
  * @param mr_html_filter_abstract $filter A filter instance
  * @return mr_html_filter
  */
 public function add(mr_html_filter_abstract $filter)
 {
     $filter->preferences_init($this->preferences);
     $this->filters[$filter->get_name()] = $filter;
     return $this;
 }
Esempio n. 9
0
 /**
  * Header "filter" constructor
  *
  * @param string $name - name for the filter instance
  * @param string $label - label to the left of the checkbox
  */
 public function __construct($name, $label)
 {
     parent::__construct($name, $label, false, '');
 }