function views_field_tooltip__inject_tooltip in Views Field Tooltip 7
Inject settings for a tooltip.
2 calls to views_field_tooltip__inject_tooltip()
- views_field_tooltip_views_pre_render in ./
views_field_tooltip.module - Implements hook_views_pre_render().
- views_field_tooltip__inject_field_tooltip in ./
views_field_tooltip.module - Inject settings for a field tooltip.
File
- ./
views_field_tooltip.module, line 512 - Shows tooltips on Views fields and labels.
Code
function views_field_tooltip__inject_tooltip($view, $field_id, $field_css, $row_index, $prefix, $tooltip, &$output, &$class) {
// Return if nothing to do.
if (!empty($tooltip['ajax']) && empty($tooltip['url']) || empty($tooltip['ajax']) && empty($tooltip['text'])) {
return;
}
// The style settings are set to the default ones and overridden with the custom ones, if present.
$default = (array) $view->display_handler
->get_option($prefix);
if (empty($default) && $prefix == 'field') {
$default = (array) $view->display_handler
->get_option('qtip');
}
$qtip = array_replace_recursive($default, (array) @$tooltip['qtip']);
// Expand tokens for this field.
$tokens = views_field_tooltip__get_render_tokens($field_id, $view, $row_index);
if (empty($tooltip['ajax'])) {
$text = t($tooltip['text']);
$qtip['content'] = strtr($text, $tokens);
if (!trim($qtip['content'])) {
return;
}
}
else {
$url = views_field_tooltip__get_tooltip_url($tooltip['url'], $tokens);
if (empty($tooltip['ajax_mode'])) {
$url = check_plain($url);
$qtip['content'] = <<<EOS
<iframe src="{<span class="php-variable">$url</span>}" width="100%" height="100%" seamless="seamless" frameborder="0" />
EOS;
}
else {
$url .= '&true_ajax=1';
$qtip['content']['url'] = $url;
}
}
$icon = @$tooltip['icon'];
$icon = strtr($icon, $tokens);
// Generate output.
$output = array(
'theme' => theme('views_field_tooltip', array(
'view' => $view,
'field' => $field_id,
'icon' => $icon,
'class' => array(
"views-{$prefix}-tooltip-icon",
),
)),
'qtip' => $qtip,
);
// Update target class.
$class = views_field_tooltip__update_class($class, array(
"views-{$prefix}-tooltip",
"views-{$prefix}-tooltip-field-{$field_css}",
// This is a special token added by our module.
is_null($row_index) ? '' : "views-{$prefix}-tooltip-row-[#]",
));
}