public static string
tooltip
(mixed $tooltip, mixed $title = '', mixed $image = 'tooltip.png', mixed $text = '', mixed $href = '', mixed $alt = 'Tooltip', mixed $class = 'hasTooltip')
public static function tooltip($tooltip, $title = '', $image = 'tooltip.png', $text = '', $href = '', $alt = 'Tooltip', $class = 'hasTooltip')
{
if (\is_array($title)) {
foreach (array('image', 'text', 'href', 'alt', 'class') as $param) {
if (isset($title[$param])) {
${$param} = $title[$param];
}
}
if (isset($title['title'])) {
$title = $title['title'];
} else {
$title = '';
}
}
if (!$text) {
$alt = htmlspecialchars($alt, ENT_COMPAT, 'UTF-8');
$text = static::image($image, $alt, null, true);
}
if ($href) {
$tip = '<a href="' . $href . '">' . $text . '</a>';
} else {
$tip = $text;
}
if ($class === 'hasTip') {
$tooltip = htmlspecialchars($tooltip, ENT_COMPAT, 'UTF-8');
if ($title) {
$title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8');
$tooltip = $title . '::' . $tooltip;
}
} else {
$tooltip = self::tooltipText($title, $tooltip, 0);
}
return '<span class="' . $class . '" title="' . $tooltip . '">' . $tip . '</span>';
}