You are here

function qtip_replacement in qTip (Stylish jQuery Tooltips) 6.2

Same name and namespace in other branches
  1. 6 qtip.module \qtip_replacement()

Private functions

1 call to qtip_replacement()
qtip_filter in ./qtip.module
Implementation of hook_filter()

File

./qtip.module, line 129

Code

function qtip_replacement($text) {
  if (preg_match_all("/\\[qtip:([^\\|\\]]+)\\|?([^\\]]*)?\\]/i", $text, $match)) {

    // Set the default delta value to be used in the foreach statement below for <span> ids
    $delta = 0;
    foreach ($match[2] as $key => $value) {
      $link = $match[1][$key];
      $tip = $match[2][$key];

      // We need to set $header to nothing by default, in case the user didn't specify any header text
      $header = '';

      // If the user also added header text to the filter
      if (strstr($tip, '|')) {
        $tip_splitter = explode('|', $tip);
        $header = '<span class="qtip-header">' . $tip_splitter[0] . '</span>';
        $tip = $tip_splitter[1];
      }
      $search[] = $match[0][$key];
      $replace[] = '<span id="qtip-link-' . $delta . '" class="qtip-link ' . ($delta % 2 ? 'qtip-link-even' : 'qtip-link-odd') . '" title="' . $tip . '">' . $header . $link . '</span>';
      $delta++;
    }
    return str_replace($search, $replace, $text);
  }
  return $text;
}