[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Site 5 * @subpackage Layout 6 * 7 * @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 defined('_JEXEC') or die; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Language\Text; 15 use Joomla\Utilities\ArrayHelper; 16 17 extract($displayData); 18 19 // Get some system objects. 20 $document = Factory::getApplication()->getDocument(); 21 $lang = Factory::getApplication()->getLanguage(); 22 23 /** 24 * Layout variables 25 * ----------------- 26 * @var string $autocomplete Autocomplete attribute for the field. 27 * @var boolean $autofocus Is autofocus enabled? 28 * @var string $class Classes for the input. 29 * @var string $description Description of the field. 30 * @var boolean $disabled Is this field disabled? 31 * @var string $group Group the field belongs to. <fields> section in form XML. 32 * @var boolean $hidden Is this field hidden in the form? 33 * @var string $hint Placeholder for the field. 34 * @var string $id DOM id of the field. 35 * @var string $label Label of the field. 36 * @var string $labelclass Classes to apply to the label. 37 * @var boolean $multiple Does this field support multiple values? 38 * @var string $name Name of the input field. 39 * @var string $onchange Onchange attribute for the field. 40 * @var string $onclick Onclick attribute for the field. 41 * @var string $pattern Pattern (Reg Ex) of value of the form field. 42 * @var boolean $readonly Is this field read only? 43 * @var boolean $repeat Allows extensions to duplicate elements. 44 * @var boolean $required Is this field required? 45 * @var integer $size Size attribute of the input. 46 * @var boolean $spellcheck Spellcheck state for the form field. 47 * @var string $validate Validation rules to apply. 48 * @var string $value Value attribute of the field. 49 * @var array $checkedOptions Options that will be set as checked. 50 * @var boolean $hasValue Has this field a value assigned? 51 * @var array $options Options available for this field. 52 * @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output 53 * @var array $dataAttributes Miscellaneous data attributes for eg, data-*. 54 * 55 * Calendar Specific 56 * @var string $helperPath The relative path for the helper file 57 * @var string $minYear The minimum year, that will be subtracted/added to current year 58 * @var string $maxYear The maximum year, that will be subtracted/added to current year 59 * @var integer $todaybutton The today button 60 * @var integer $weeknumbers The week numbers display 61 * @var integer $showtime The time selector display 62 * @var integer $filltable The previous/next month filling 63 * @var integer $timeformat The time format 64 * @var integer $singleheader Display different header row for month/year 65 * @var string $direction The document direction 66 * @var string $calendar The calendar type 67 * @var array $weekend The weekends days 68 * @var integer $firstday The first day of the week 69 * @var string $format The format of date and time 70 */ 71 72 $inputvalue = ''; 73 74 // Build the attributes array. 75 $attributes = array(); 76 77 empty($size) ? null : $attributes['size'] = $size; 78 empty($maxlength) ? null : $attributes['maxlength'] = $maxLength; 79 empty($class) ? $attributes['class'] = 'form-control' : $attributes['class'] = 'form-control ' . $class; 80 !$readonly ? null : $attributes['readonly'] = 'readonly'; 81 !$disabled ? null : $attributes['disabled'] = 'disabled'; 82 empty($onchange) ? null : $attributes['onchange'] = $onchange; 83 84 if ($required) { 85 $attributes['required'] = ''; 86 } 87 88 // Handle the special case for "now". 89 if (strtoupper($value) === 'NOW') { 90 $value = Factory::getDate()->format('Y-m-d H:i:s'); 91 } 92 93 $readonly = isset($attributes['readonly']) && $attributes['readonly'] === 'readonly'; 94 $disabled = isset($attributes['disabled']) && $attributes['disabled'] === 'disabled'; 95 96 if (is_array($attributes)) { 97 $attributes = ArrayHelper::toString($attributes); 98 } 99 100 $calendarAttrs = [ 101 'data-inputfield' => $id, 102 'data-button' => $id . '_btn', 103 'data-date-format' => $format, 104 'data-firstday' => empty($firstday) ? '' : $firstday, 105 'data-weekend' => empty($weekend) ? '' : implode(',', $weekend), 106 'data-today-btn' => $todaybutton, 107 'data-week-numbers' => $weeknumbers, 108 'data-show-time' => $showtime, 109 'data-show-others' => $filltable, 110 'data-time24' => $timeformat, 111 'data-only-months-nav' => $singleheader, 112 'data-min-year' => $minYear, 113 'data-max-year' => $maxYear, 114 'data-date-type' => strtolower($calendar), 115 ]; 116 117 $calendarAttrsStr = ArrayHelper::toString($calendarAttrs); 118 119 // Add language strings 120 $strings = [ 121 // Days 122 'SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 123 // Short days 124 'SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 125 // Months 126 'JANUARY', 'FEBRUARY', 'MARCH', 'APRIL', 'MAY', 'JUNE', 'JULY', 'AUGUST', 'SEPTEMBER', 'OCTOBER', 'NOVEMBER', 'DECEMBER', 127 // Short months 128 'JANUARY_SHORT', 'FEBRUARY_SHORT', 'MARCH_SHORT', 'APRIL_SHORT', 'MAY_SHORT', 'JUNE_SHORT', 129 'JULY_SHORT', 'AUGUST_SHORT', 'SEPTEMBER_SHORT', 'OCTOBER_SHORT', 'NOVEMBER_SHORT', 'DECEMBER_SHORT', 130 // Buttons 131 'JCLOSE', 'JCLEAR', 'JLIB_HTML_BEHAVIOR_TODAY', 132 // Miscellaneous 133 'JLIB_HTML_BEHAVIOR_WK', 134 ]; 135 136 foreach ($strings as $c) { 137 Text::script($c); 138 } 139 140 // These are new strings. Make sure they exist. Can be generalised at later time: eg in 4.1 version. 141 if ($lang->hasKey('JLIB_HTML_BEHAVIOR_AM')) { 142 Text::script('JLIB_HTML_BEHAVIOR_AM'); 143 } 144 145 if ($lang->hasKey('JLIB_HTML_BEHAVIOR_PM')) { 146 Text::script('JLIB_HTML_BEHAVIOR_PM'); 147 } 148 149 // Redefine locale/helper assets to use correct path, and load calendar assets 150 $document->getWebAssetManager() 151 ->registerAndUseScript('field.calendar.helper', $helperPath, [], ['defer' => true]) 152 ->useStyle('field.calendar' . ($direction === 'rtl' ? '-rtl' : '')) 153 ->useScript('field.calendar'); 154 155 ?> 156 <div class="field-calendar"> 157 <?php if (!$readonly && !$disabled) : ?> 158 <div class="input-group"> 159 <?php endif; ?> 160 <input 161 type="text" 162 id="<?php echo $id; ?>" 163 name="<?php echo $name; ?>" 164 value="<?php echo htmlspecialchars(($value !== '0000-00-00 00:00:00') ? $value : '', ENT_COMPAT, 'UTF-8'); ?>" 165 <?php echo !empty($description) ? ' aria-describedby="' . ($id ?: $name) . '-desc"' : ''; ?> 166 <?php echo $attributes; ?> 167 <?php echo $dataAttribute ?? ''; ?> 168 <?php echo !empty($hint) ? 'placeholder="' . htmlspecialchars($hint, ENT_COMPAT, 'UTF-8') . '"' : ''; ?> 169 data-alt-value="<?php echo htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); ?>" autocomplete="off"> 170 <button type="button" class="<?php echo ($readonly || $disabled) ? 'hidden ' : ''; ?>btn btn-primary" 171 id="<?php echo $id; ?>_btn" 172 title="<?php echo Text::_('JLIB_HTML_BEHAVIOR_OPEN_CALENDAR'); ?>" 173 <?php echo $calendarAttrsStr; ?> 174 ><span class="icon-calendar" aria-hidden="true"></span> 175 <span class="visually-hidden"><?php echo Text::_('JLIB_HTML_BEHAVIOR_OPEN_CALENDAR'); ?></span> 176 </button> 177 <?php if (!$readonly && !$disabled) : ?> 178 </div> 179 <?php endif; ?> 180 </div>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |