[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS\Form\Field; 11 12 use Joomla\CMS\Factory; 13 use Joomla\CMS\Form\FormField; 14 use Joomla\CMS\HTML\HTMLHelper; 15 use Joomla\CMS\Language\Text; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('JPATH_PLATFORM') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * Form Field class for the Joomla Platform. 23 * Provides spacer markup to be used in form layouts. 24 * 25 * @since 1.7.0 26 */ 27 class SpacerField extends FormField 28 { 29 /** 30 * The form field type. 31 * 32 * @var string 33 * @since 1.7.0 34 */ 35 protected $type = 'Spacer'; 36 37 /** 38 * Method to get the field input markup for a spacer. 39 * The spacer does not have accept input. 40 * 41 * @return string The field input markup. 42 * 43 * @since 1.7.0 44 */ 45 protected function getInput() 46 { 47 return ' '; 48 } 49 50 /** 51 * Method to get the field label markup for a spacer. 52 * Use the label text or name from the XML element as the spacer or 53 * Use a hr="true" to automatically generate plain hr markup 54 * 55 * @return string The field label markup. 56 * 57 * @since 1.7.0 58 */ 59 protected function getLabel() 60 { 61 $html = array(); 62 $class = !empty($this->class) ? ' class="' . $this->class . '"' : ''; 63 $html[] = '<span class="spacer">'; 64 $html[] = '<span class="before"></span>'; 65 $html[] = '<span' . $class . '>'; 66 67 if ((string) $this->element['hr'] === 'true') { 68 $html[] = '<hr' . $class . '>'; 69 } else { 70 $label = ''; 71 72 // Get the label text from the XML element, defaulting to the element name. 73 $text = $this->element['label'] ? (string) $this->element['label'] : (string) $this->element['name']; 74 $text = $this->translateLabel ? Text::_($text) : $text; 75 76 // Build the class for the label. 77 $class = !empty($this->description) ? 'hasPopover' : ''; 78 $class = $this->required == true ? $class . ' required' : $class; 79 80 // Add the opening label tag and main attributes attributes. 81 $label .= '<label id="' . $this->id . '-lbl" class="' . $class . '"'; 82 83 // If a description is specified, use it to build a tooltip. 84 if (!empty($this->description)) { 85 HTMLHelper::_('bootstrap.popover', '.hasPopover'); 86 $label .= ' title="' . htmlspecialchars(trim($text, ':'), ENT_COMPAT, 'UTF-8') . '"'; 87 $label .= ' data-bs-content="' . htmlspecialchars( 88 $this->translateDescription ? Text::_($this->description) : $this->description, 89 ENT_COMPAT, 90 'UTF-8' 91 ) . '"'; 92 93 if (Factory::getLanguage()->isRtl()) { 94 $label .= ' data-bs-placement="left"'; 95 } 96 } 97 98 // Add the label text and closing tag. 99 $label .= '>' . $text . '</label>'; 100 $html[] = $label; 101 } 102 103 $html[] = '</span>'; 104 $html[] = '<span class="after"></span>'; 105 $html[] = '</span>'; 106 107 return implode('', $html); 108 } 109 110 /** 111 * Method to get the field title. 112 * 113 * @return string The field title. 114 * 115 * @since 1.7.0 116 */ 117 protected function getTitle() 118 { 119 return $this->getLabel(); 120 } 121 122 /** 123 * Method to get a control group with label and input. 124 * 125 * @param array $options Options to be passed into the rendering of the field 126 * 127 * @return string A string containing the html for the control group 128 * 129 * @since 3.7.3 130 */ 131 public function renderField($options = array()) 132 { 133 $options['class'] = empty($options['class']) ? 'field-spacer' : $options['class'] . ' field-spacer'; 134 135 return parent::renderField($options); 136 } 137 }
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 |