38 require_once realpath(dirname(__FILE__)).
"/../field_renderers.inc";
60 if ($form->data->hasField($field))
62 $form->override($field, $label, $this);
66 $form->add($this, $field);
67 $form->alias($field, $label);
73 $label = isset($this->label) ? $this->label : $this->parent->prettifyFieldName($field);
86 $fn =
"{$this->parent->id}_{$field}_update";
87 $containerId =
"{$this->parent->id}_{$field}_container";
88 $id =
"{$this->parent->id}_{$field}";
90 <script type=
'text/javascript'>
91 function <?echo $fn?>(element, value)
93 var container = document.id(
'<?echo $containerId?>');
94 container.getElements(
"a.selected").each(
function(elt)
96 elt.removeClass(
'selected');
98 document.id(element).addClass(
'selected');
99 var ctrl = document.id(
'<?echo $id?>');
101 ctrl.fireEvent(
'change');
110 if (!count($this->options))
return;
123 $current = $this->parent->data->get($field);
127 if ($this->regular && !$this->tabular)
129 $width = 100 / count($this->options);
130 $widthStyle =
" style='width: {$width}%'";
133 $containerId =
"{$this->parent->id}_{$field}_container";
139 $width = 100 / count($this->options);
140 $tdStyle =
" style='width: {$width}%'";
147 echo
"<table id='{$containerId}' class='push_button_options'><tr><td{$tdStyle}>";
148 $separator =
"</td><td{$tdStyle}>";
149 $close =
"</td></tr></table>";
151 else if ($this->horizontal)
153 echo
"<div id='{$containerId}' class='push_button_options horizontal'>";
158 echo
"<div id='{$containerId}' class='push_button_options vertical'>";
162 $name = $mode ?
"$field:$mode" : $field;
164 echo
"<input type='hidden' id='{$this->parent->id}_{$field}' name='{$name}' value='$current'/>";
168 $max = count($this->options) - 1;
172 foreach($this->options as $value => $name)
174 $selected = ($current == $value) ?
" selected" :
"";
178 if ($count == 0) $position .=
" first";
179 if ($count == $max) $position .=
" last";
182 $out[] =
"<a class='pushbutton{$position}{$selected}'{$widthStyle} href='#' onclick='{$this->parent->id}_{$field}_update(this, \"{$value}\");{$onChange}return false' {$disable}/>{$name}</a>";
187 $buttons = implode($separator, $out);
195 if ($mode !=
"equal")
return;
197 $searchValue = $this->parent->params->get($field, $mode);
211 if (array_key_exists($this->parent->data->get($field), $this->options))
213 echo $this->options[$this->parent->data->get($field)];
217 echo
"Not specified";
FieldRenderer is the abstract base class for all FieldRenderers.
_startField($field, $styles="")
Internal method to generate the starting HTML for the field (including the label)
_endField($field)
Internal method to generate the closing HTML for the field.
FieldRenderer($parent)
Constructor.