]> dev.renevier.net Git - syj.git/blob - application/views/helpers/SyjFormCheckbox.php
update copyright headers
[syj.git] / application / views / helpers / SyjFormCheckbox.php
1 <?php
2 /*  This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
3     and is published under the AGPL license. */
4
5 require_once 'Zend/View/Helper/FormCheckbox.php';
6
7 class Syj_View_Helper_SyjFormCheckbox extends Zend_View_Helper_FormCheckbox
8 {
9     public function SyjFormCheckbox($name, $value = null, $attribs = null, array $checkedOptions = null)
10     {
11         $info = $this->_getInfo($name, $value, $attribs);
12         extract($info); // name, id, value, attribs, options, listsep, disable
13
14         $checked = false;
15         if (isset($attribs['checked']) && $attribs['checked']) {
16             $checked = true;
17             unset($attribs['checked']);
18         } elseif (isset($attribs['checked'])) {
19             $checked = false;
20             unset($attribs['checked']);
21         }
22
23         $checkedOptions = self::determineCheckboxInfo($value, $checked, $checkedOptions);
24
25         // is the element disabled?
26         $disabled = '';
27         if ($disable) {
28             $disabled = ' disabled="disabled"';
29         }
30
31         // XHTML or HTML end tag?
32         $endTag = ' />';
33         if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
34             $endTag= '>';
35         }
36
37         // build the element
38         $xhtml = '';
39         if (!$disable && !strstr($name, '[]')) {
40             //XXX: we have just copied Zend_View_Helper_FormCheckbox, and
41             // commented this line.
42 //            $xhtml = $this->_hidden($name, $checkedOptions['uncheckedValue']);
43         }
44         $xhtml .= '<input type="checkbox"'
45                 . ' name="' . $this->view->escape($name) . '"'
46                 . ' id="' . $this->view->escape($id) . '"'
47                 . ' value="' . $this->view->escape($checkedOptions['checkedValue']) . '"'
48                 . $checkedOptions['checkedString']
49                 . $disabled
50                 . $this->_htmlAttribs($attribs)
51                 . $endTag;
52
53         return $xhtml;
54
55     }
56 }