Go to the documentation of this file.00001 <?php
00010 class form_range_numeric extends form_range_abstract {
00011
00012 public function setValue($value, $refill=false, $key=null) {
00013 if (is_array($value)) {
00014 $value = array_map(create_function('$v', 'return str_replace(",", ".", $v);'), $value);
00015 } else {
00016 $value = str_replace(',', '.', $value);
00017 }
00018 parent::setValue($value, $refill, $key);
00019 }
00020
00021 public function toHtml() {
00022 $ret = parent::toHtml();
00023
00024 if ($this->cfg->useJs) {
00025 $id = $this->makeid($this->name.'-slider');
00026
00027 $ret = '<div id="'.$id.'" class="range-slider"></div>'.$ret;
00028
00029 $min = $this->cfg->getInarray('allowedRange', 'min');
00030 $max = $this->cfg->getInarray('allowedRange', 'max');
00031
00032 if (!$min) $min = 0;
00033 if (!$max) $max = 100;
00034
00035 $minVal = $this->getValue('min');
00036 $maxVal = $this->getValue('max');
00037 if (!$minVal) $minVal = $min;
00038 if (!$maxVal) $maxVal = $max;
00039
00040 $resp = response::getInstance();
00041 $resp->addJs('jqueryui');
00042 $resp->blockJquery('$("#'.$id.'").slider({
00043 range: true,
00044 min: '.$min.',
00045 max: '.$max.',
00046 values: ['.$minVal.','.$maxVal.'],
00047 slide: function(event, ui) {
00048 $("#'.$this->makeId($this->name.'[0]').'").val(ui.values[0]);
00049 $("#'.$this->makeId($this->name.'[1]').'").val(ui.values[1]);
00050 },
00051 change: function() {
00052 $("#'.$this->makeId($this->name.'[0]').'").change();
00053 $("#'.$this->makeId($this->name.'[1]').'").change();
00054 }
00055 })'.($this->cfg->disabled?'.next(".range").find("input").attr("disabled", "disabled")' : null).';
00056 ;');
00057 }
00058
00059 return $ret;
00060 }
00061
00062 public function toXul() {
00063 return '<textbox type="number" id="'.$this->name.'" value="'.$this->value.'" min="'.$this->min.'" max="'.$this->max.'" increment="'.$this->step.'" '.utils::htmlAttribute($this->more).'/>';
00064 }
00065
00066 }