public static string
tooltip
(mixed $tooltip, mixed $title = '', mixed $image = 'tooltip.png', mixed $text = '', mixed $href = '', mixed $alt = 'Tooltip', mixed $class = 'hasTooltip')
/**
* Creates a tooltip with an image as button
*
* @param string $tooltip The tip string.
* @param mixed $title The title of the tooltip or an associative array with keys contained in
* {'title','image','text','href','alt'} and values corresponding to parameters of the same name.
* @param string $image The image for the tip, if no text is provided.
* @param string $text The text for the tip.
* @param string $href A URL that will be used to create the link.
* @param string $alt The alt attribute for img tag.
* @param string $class CSS class for the tool tip.
*
* @return string
*
* @since 1.5
*/
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') {
// Still using MooTools tooltips!
$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>';
}