File indexing completed on 2025-05-04 05:29:14

0001 <?php
0002 /**
0003  *  ocs-webserver
0004  *
0005  *  Copyright 2016 by pling GmbH.
0006  *
0007  *    This file is part of ocs-webserver.
0008  *
0009  *    This program is free software: you can redistribute it and/or modify
0010  *    it under the terms of the GNU Affero General Public License as
0011  *    published by the Free Software Foundation, either version 3 of the
0012  *    License, or (at your option) any later version.
0013  *
0014  *    This program is distributed in the hope that it will be useful,
0015  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  *    GNU Affero General Public License for more details.
0018  *
0019  *    You should have received a copy of the GNU Affero General Public License
0020  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021  **/
0022 class Default_View_Helper_Form_Input_Html5 extends Zend_View_Helper_FormText
0023 {
0024 
0025     protected $_allowedTypes = array('text', 'email', 'url', 'number', 'range', 'date',
0026         'month', 'week', 'time', 'datetime', 'datetime-local', 'search', 'color');
0027 
0028     public function html5($name, $value = null, $attribs = null)
0029     {
0030         $info = $this->_getInfo($name, $value, $attribs);
0031         extract($info); // name, value, attribs, options, listsep, disable
0032 
0033         // build the element
0034         $disabled = '';
0035         if ($disable) {
0036             // disabled
0037             $disabled = ' disabled="disabled"';
0038         }
0039 
0040         // XHTML or HTML end tag?
0041         $endTag = ' />';
0042         if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
0043             $endTag = '>';
0044         }
0045         $type = 'text';
0046         if ($this->view->doctype()->isHtml5() && isset($attribs['type']) && in_array($attribs['type'], $this->_allowedTypes)) {
0047             $type = $attribs['type'];
0048             unset($attribs['type']);
0049         }
0050         $required = '';
0051         if ($this->view->doctype()->isHtml5() && isset($attribs['required'])) {
0052             $required = ' required ';
0053             unset($attribs['required']);
0054         }
0055         $xhtml = '<input type="' . $type . '" '
0056             . ' name="' . $this->view->escape($name) . '"'
0057             . ' id="' . $this->view->escape($id) . '"'
0058             . ' value="' . $this->view->escape($value) . '"'
0059             . $disabled
0060             . $this->_htmlAttribs($attribs)
0061             . $required
0062             . $endTag;
0063 
0064         return $xhtml;
0065     }
0066 
0067 }