0 ? htmlentities($string, ENT_QUOTES) : ''; } static public function html_string($string) { return isset($string) && strlen($string) > 0 ? nl2br(htmlentities($string, ENT_QUOTES)) : ' '; } static public function js_string($string) { return addslashes($string); } } class Qf_Element { public $label; // Label associated with element public $name; // Name of form element public $value; // Value assigned to element public $filters; public $validators; public $error; // Validation error message protected $attributes; // Other html attributes public function __construct($name, $value, $label, $attributes) { $this->label = $label; $this->name = $name; $this->value = $value; $this->attributes = $attributes; } /** * @return string The html to display this element */ public function view() { return Qf_Utils::html_string($this->value); } public function allowMultiple() { return false; } /** * Override this function if custom javascript is needed to determine if a value was entered */ public function jsEmpty() { return 'isEmpty('.$this->jsElement().')'; } /** * Override this function if custom javascript is needed to be called before processing the element */ public function jsClean() { return null; } public function jsElement() { return "form.elements['".$this->name."']"; } protected function htmlAttributes() { $html = ''; foreach($this->attributes as $name => $value) { $html .= ' '.$name.'="'.Qf_Utils::form_value($value).'"'; } return $html; } protected function choice($type, $label, $value, $checked) { $html = '