subtitle.php
2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* @package AllediaFreeDefaultFiles
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright Copyright (C) Open Sources Training, LLC, All rights reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('_JEXEC') or die('Restricted access');
if (!class_exists('JFormFieldSpacer')) {
require_once JPATH_ROOT . "/libraries/joomla/form/fields/spacer.php";
}
/**
* Form field to show a subtitle for setting fields
*/
class JFormFieldSubtitle extends JFormFieldSpacer
{
protected function getLabel()
{
$html = array();
$class = !empty($this->class) ? ' class="' . $this->class . '"' : '';
$tag = isset($this->element['tag']) ? (string)$this->element['tag'] : 'h4';
$html[] = '<span class="spacer">';
$html[] = '<span class="before"></span>';
$html[] = '<span' . $class . '>';
if ((string) $this->element['hr'] == 'true') {
$html[] = '<hr' . $class . ' />';
} else {
$label = '';
// Get the label text from the XML element, defaulting to the element name.
$text = $this->element['label'] ? (string) $this->element['label'] : (string) $this->element['name'];
$text = $this->translateLabel ? JText::_($text) : $text;
// Build the class for the label.
$class = !empty($this->description) ? 'hasTooltip' : '';
$class = $this->required == true ? $class . ' required' : $class;
// Add the opening label tag and main attributes attributes.
$label .= '<' . $tag . ' id="' . $this->id . '-lbl" class="' . $class . '"';
// If a description is specified, use it to build a tooltip.
if (!empty($this->description)) {
JHtml::_('bootstrap.tooltip');
$label .= ' title="' . JHtml::tooltipText(trim($text, ':'), JText::_($this->description), 0) . '"';
}
// Add the label text and closing tag.
$label .= '>' . $text . '</' . $tag . '>';
$html[] = $label;
}
$html[] = '</span>';
$html[] = '<span class="after"></span>';
$html[] = '</span>';
return implode('', $html);
}
}