10 defined(
'JPATH_PLATFORM') or die;
31 protected $type =
'Meter';
47 protected $active =
false;
55 protected $animated =
true;
74 public function __get($name)
85 return parent::__get($name);
98 public function __set($name, $value)
104 $this->$name = (string) $value;
108 $value = (string) $value;
109 $this->$name = ($value ===
'true' || $value === $name || $value ===
'1');
113 $value = (string) $value;
114 $this->$name = !($value ===
'false' || $value ===
'off' || $value ===
'0');
118 parent::__set($name, $value);
136 public function setup(SimpleXMLElement $element, $value, $group = null)
138 $return = parent::setup($element, $value, $group);
142 $this->width = isset($this->element[
'width']) ? (string) $this->element[
'width'] :
'';
143 $this->color = isset($this->element[
'color']) ? (string) $this->element[
'color'] :
'';
145 $active = (string) $this->element[
'active'];
146 $this->active = ($active ==
'true' || $active ==
'on' || $active ==
'1');
148 $animated = (string) $this->element[
'animated'];
149 $this->animated = !($animated ==
'false' || $animated ==
'off' || $animated ==
'0');
162 protected function getInput()
165 $width = !empty($this->width) ?
' style="width:' . $this->width .
';"' :
'';
166 $color = !empty($this->color) ?
' background-color:' . $this->color .
';' :
'';
169 $data .=
' data-max="' . $this->max .
'"';
170 $data .=
' data-min="' . $this->min .
'"';
171 $data .=
' data-step="' . $this->step .
'"';
173 $class =
'progress ' . $this->class;
174 $class .= $this->animated ?
' progress-striped' :
'';
175 $class .= $this->active ?
' active' :
'';
176 $class =
' class="' . $class .
'"';
178 $value = (float) $this->value;
179 $value = $value < $this->min ? $this->min : $value;
180 $value = $value > $this->max ? $this->max : $value;
182 $data .=
' data-value="' . $this->value .
'"';
184 $value = ((float) ($value - $this->min) * 100) / ($this->max - $this->min);
186 $html[] =
'<div ' . $class . $width . $data .
' >';
187 $html[] =
' <div class="bar" style="width: ' . strval($value) .
'%;' . $color .
'"></div>';
190 return implode(
'', $html);