renderlabel.php
1.62 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
<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
extract($displayData);
/**
* Layout variables
* ---------------------
* $text : (string) The label text
* $description : (string) An optional description to use in a tooltip
* $for : (string) The id of the input this label is for
* $required : (boolean) True if a required field
* $classes : (array) A list of classes
* $position : (string) The tooltip position. Bottom for alias
*/
$classes = array_filter((array) $classes);
$id = $for . '-lbl';
$title = '';
if (!empty($description))
{
if ($text && $text !== $description)
{
JHtml::_('bootstrap.popover');
$classes[] = 'hasPopover';
$title = ' title="' . htmlspecialchars(trim($text, ':')) . '"'
. ' data-content="'. htmlspecialchars($description) . '"';
if (!$position && JFactory::getLanguage()->isRtl())
{
$position = ' data-placement="left" ';
}
}
else
{
JHtml::_('bootstrap.tooltip');
$classes[] = 'hasTooltip';
$title = ' title="' . JHtml::_('tooltipText', trim($text, ':'), $description, 0) . '"';
}
}
if ($required)
{
$classes[] = 'required';
}
?>
<label id="<?php echo $id; ?>" for="<?php echo $for; ?>"<?php if (!empty($classes)) echo ' class="' . implode(' ', $classes) . '"'; ?><?php echo $title; ?><?php echo $position; ?>>
<?php echo $text; ?><?php if ($required) : ?><span class="star"> *</span><?php endif; ?>
</label>