1 <?php
2 3 4 5 6 7
8
9 defined('FOF_INCLUDED') or die;
10
11 12 13 14 15 16
17 class extends FOFFormHeaderFieldsearchable
18 {
19 20 21 22 23
24 protected function getFilter()
25 {
26 $valide = array('yes', 'true', '1');
27
28
29 $size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
30 $maxLength = $this->element['maxlength'] ? ' maxlength="' . (int) $this->element['maxlength'] . '"' : '';
31 $filterclass = $this->element['filterclass'] ? ' class="' . (string) $this->element['filterclass'] . '"' : '';
32 $placeholder = $this->element['placeholder'] ? $this->element['placeholder'] : $this->getLabel();
33 $name = $this->element['searchfieldname'] ? $this->element['searchfieldname'] : $this->name;
34 $placeholder = ' placeholder="' . JText::_($placeholder) . '"';
35
36 $single = in_array($this->element['single'], $valide) ? true : false;
37 $showMethod = in_array($this->element['showmethod'], $valide) ? true : false;
38 $method = $this->element['method'] ? $this->element['method'] : 'between';
39 $fromName = $this->element['fromname'] ? $this->element['fromname'] : 'from';
40 $toName = $this->element['toname'] ? $this->element['toname'] : 'to';
41
42 $values = $this->form->getModel()->getState($name);
43 $fromValue = $values[$fromName];
44 $toValue = $values[$toName];
45
46
47 if ($this->element['onchange'])
48 {
49 $onchange = ' onchange="' . (string) $this->element['onchange'] . '"';
50 }
51 else
52 {
53 $onchange = ' onchange="document.adminForm.submit();"';
54 }
55
56 if ($showMethod)
57 {
58 $html = '<input type="text" name="' . $name . '[method]" value="'. $method . '" />';
59 } else
60 {
61 $html = '<input type="hidden" name="' . $name . '[method]" value="'. $method . '" />';
62 }
63
64 $html .= '<input type="text" name="' . $name . '[from]" id="' . $this->id . '_' . $fromName . '"' . ' value="'
65 . htmlspecialchars($fromValue, ENT_COMPAT, 'UTF-8') . '"' . $filterclass . $size . $placeholder . $onchange . $maxLength . '/>';
66
67 if (!$single)
68 {
69 $html .= '<input type="text" name="' . $name . '[to]" id="' . $this->id . '_' . $toName . '"' . ' value="'
70 . htmlspecialchars($toValue, ENT_COMPAT, 'UTF-8') . '"' . $filterclass . $size . $placeholder . $onchange . $maxLength . '/>';
71 }
72
73 return $html;
74 }
75 }