Warning, file /webapps/ocs-webserver/application/modules/default/forms/elements/Html5.php was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 <?php 0002 0003 /** 0004 * ocs-webserver 0005 * 0006 * Copyright 2016 by pling GmbH. 0007 * 0008 * This file is part of ocs-webserver. 0009 * 0010 * This program is free software: you can redistribute it and/or modify 0011 * it under the terms of the GNU Affero General Public License as 0012 * published by the Free Software Foundation, either version 3 of the 0013 * License, or (at your option) any later version. 0014 * 0015 * This program is distributed in the hope that it will be useful, 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0018 * GNU Affero General Public License for more details. 0019 * 0020 * You should have received a copy of the GNU Affero General Public License 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0022 **/ 0023 class Default_Form_Element_Html5 extends Zend_Form_Element_Text 0024 { 0025 0026 const DEFAULT_TYPE = 'text'; 0027 const FIELD_EMAIL = 'email'; 0028 const FIELD_EMAIL_ADDRESS = 'emailaddress'; 0029 const FIELD_URL = 'url'; 0030 const FIELD_NUMBER = 'number'; 0031 const FIELD_RANGE = 'range'; 0032 const FIELD_DATE = 'date'; 0033 const FIELD_MONTH = 'month'; 0034 const FIELD_WEEK = 'week'; 0035 const FIELD_TIME = 'time'; 0036 const FIELD_DATE_TIME = 'datetime'; 0037 const FIELD_DATE_TIME_LOCAL = 'datetime-local'; 0038 const FIELD_SEARCH = 'search'; 0039 const FIELD_COLOR = 'color'; 0040 0041 protected static $_mapping = array( 0042 self::FIELD_EMAIL => 'email', 0043 self::FIELD_EMAIL_ADDRESS => 'email', 0044 self::FIELD_URL => 'url', 0045 self::FIELD_NUMBER => 'number', 0046 self::FIELD_RANGE => 'range', 0047 self::FIELD_DATE => 'date', 0048 self::FIELD_MONTH => 'month', 0049 self::FIELD_WEEK => 'week', 0050 self::FIELD_TIME => 'time', 0051 self::FIELD_DATE_TIME => 'datetime', 0052 self::FIELD_DATE_TIME_LOCAL => 'datetime-local', 0053 self::FIELD_SEARCH => 'search', 0054 self::FIELD_COLOR => 'color', 0055 ); 0056 0057 public $helper = 'html5'; 0058 0059 public function __construct($spec, $options = null) 0060 { 0061 if ($this->_isHtml5() && !isset($options['type'])) { 0062 $options['type'] = $this->_getType($spec); 0063 } 0064 parent::__construct($spec, $options); 0065 } 0066 0067 private function _isHtml5() 0068 { 0069 return $this->getView()->getHelper('doctype')->isHtml5(); 0070 } 0071 0072 private function _getType($spec) 0073 { 0074 if (array_key_exists(strtolower($spec), self::$_mapping)) { 0075 return self::$_mapping[$spec]; 0076 } 0077 return self::DEFAULT_TYPE; 0078 } 0079 0080 public function init() 0081 { 0082 $view = $this->getView(); 0083 $view->addHelperPath(APPLICATION_PATH . '/modules/default/views/helpers/forms/input', 'Default_View_Helper_Form_Input'); 0084 parent::init(); 0085 } 0086 0087 public function setRequired($flag = true) 0088 { 0089 if ($flag === true && $this->_isHtml5()) { 0090 $this->setAttrib('required', 'required'); 0091 } 0092 return parent::setRequired($flag); 0093 } 0094 0095 }