Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
spacer.php
Aller à la documentation de ce fichier.
1 <?php
2 /**
3  * @package Joomla.Platform
4  * @subpackage Form
5  *
6  * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
7  * @license GNU General Public License version 2 or later; see LICENSE
8  */
9 
10 defined('JPATH_PLATFORM') or die;
11 
12 /**
13  * Form Field class for the Joomla Platform.
14  * Provides spacer markup to be used in form layouts.
15  *
16  * @package Joomla.Platform
17  * @subpackage Form
18  * @since 11.1
19  */
21 {
22  /**
23  * The form field type.
24  *
25  * @var string
26  * @since 11.1
27  */
28  protected $type = 'Spacer';
29 
30  /**
31  * Method to get the field input markup for a spacer.
32  * The spacer does not have accept input.
33  *
34  * @return string The field input markup.
35  *
36  * @since 11.1
37  */
38  protected function getInput()
39  {
40  return ' ';
41  }
42 
43  /**
44  * Method to get the field label markup for a spacer.
45  * Use the label text or name from the XML element as the spacer or
46  * Use a hr="true" to automatically generate plain hr markup
47  *
48  * @return string The field label markup.
49  *
50  * @since 11.1
51  */
52  protected function getLabel()
53  {
54  $html = array();
55  $class = !empty($this->class) ? ' class="' . $this->class . '"' : '';
56  $html[] = '<span class="spacer">';
57  $html[] = '<span class="before"></span>';
58  $html[] = '<span' . $class . '>';
59 
60  if ((string) $this->element['hr'] == 'true')
61  {
62  $html[] = '<hr' . $class . ' />';
63  }
64  else
65  {
66  $label = '';
67 
68  // Get the label text from the XML element, defaulting to the element name.
69  $text = $this->element['label'] ? (string) $this->element['label'] : (string) $this->element['name'];
70  $text = $this->translateLabel ? JText::_($text) : $text;
71 
72  // Build the class for the label.
73  $class = !empty($this->description) ? 'hasTooltip' : '';
74  $class = $this->required == true ? $class . ' required' : $class;
75 
76  // Add the opening label tag and main attributes attributes.
77  $label .= '<label id="' . $this->id . '-lbl" class="' . $class . '"';
78 
79  // If a description is specified, use it to build a tooltip.
80  if (!empty($this->description))
81  {
82  JHtml::_('bootstrap.tooltip');
83  $label .= ' title="' . JHtml::tooltipText(trim($text, ':'), JText::_($this->description), 0) . '"';
84  }
85 
86  // Add the label text and closing tag.
87  $label .= '>' . $text . '</label>';
88  $html[] = $label;
89  }
90 
91  $html[] = '</span>';
92  $html[] = '<span class="after"></span>';
93  $html[] = '</span>';
94 
95  return implode('', $html);
96  }
97 
98  /**
99  * Method to get the field title.
100  *
101  * @return string The field title.
102  *
103  * @since 11.1
104  */
105  protected function getTitle()
106  {
107  return $this->getLabel();
108  }
109 }