* @package tao */ class tao_helpers_form_elements_xhtml_Checkbox extends tao_helpers_form_elements_Checkbox { use XhtmlRenderingTrait; /** * Short description of method feed * * @access public * @author Joel Bout, */ public function feed() { $expression = "/^" . preg_quote($this->name, "/") . "(.)*[0-9]+$/"; $this->setValues([]); foreach ($_POST as $key => $value) { if (preg_match($expression, $key)) { $this->addValue(tao_helpers_Uri::decode($value)); } } } /** * Short description of method render * * @access public * @author Joel Bout, * @return string */ public function render() { $returnValue = $this->renderLabel(); $checkAll = false; if (isset($this->attributes['checkAll'])) { $checkAll = (bool) $this->attributes['checkAll']; unset($this->attributes['checkAll']); } $i = 0; $checked = 0; $returnValue .= '
'; $readOnlyOptions = $this->getReadOnly(); foreach ($this->options as $optionId => $optionLabel) { $readOnly = isset($readOnlyOptions[$optionId]); if ($readOnly) { $returnValue .= '
'; } else { $returnValue .= '
'; } $returnValue .= '
'; $returnValue .= "renderAttributes(); if ($readOnly) { $returnValue .= "disabled='disabled' readonly='readonly' "; } if (in_array($optionId, $this->values)) { $returnValue .= " checked='checked' "; $checked++; } $returnValue .= ' />'; $returnValue .= '
'; $returnValue .= ""; $returnValue .= '
'; if ($readOnly) { $readOnlyReason = $readOnlyOptions[$optionId]; if (!empty($readOnlyReason)) { $returnValue .= '
' . _dh($readOnlyReason) . '
'; } } $returnValue .= '
'; $i++; } $returnValue .= "
"; // add a small link if ($checkAll) { if ($checked == (count($this->options) - count($readOnlyOptions))) { $returnValue .= "" . __('Uncheck All') . ""; } else { $returnValue .= "" . __('Check All') . ""; } } return (string) $returnValue; } /** * Short description of method setValue * * @access public * @author Joel Bout, * @param string $value * @return mixed */ public function setValue($value) { $this->addValue($value); } /** * Short description of method getEvaluatedValue * * @access public * @author Joel Bout, * @return array */ public function getEvaluatedValue() { return array_map("tao_helpers_Uri::decode", $this->getValues()); // return array_map("tao_helpers_Uri::decode", $this->getRawValue()); } }