You are here

function _fetch_replacement in Glossify 6.3

Same name and namespace in other branches
  1. 6 glossify.module \_fetch_replacement()

Helper function that fetches and returns the styled term depending on the style and term.

2 calls to _fetch_replacement()
_glossify_replace_terms_phpdom in ./glossify.module
Uses PHP's built in DOM extension if available. Adapted from http://stackoverflow.com/questions/3151064/find-and-replace-keywords-by-...
_glossify_replace_terms_simplehtmldom in ./glossify.module

File

./glossify.module, line 693

Code

function _fetch_replacement($style, $term_title, $target_url) {

  // '$1' is the regex placeholder. This allows the original case of the matching text to be retained in a
  // case-insensitive replacement.
  switch ($style) {
    case 'links':
      return $replacement = l('$1', $target_url, array(
        'attributes' => array(
          'title' => $term_title,
          'class' => 'glossify_term',
        ),
      ));
    case 'hovertip':
      return $replacement = '<span class="glossify_term hovertip_target" hovertip="' . $term_title . '">$1</span>';
    case 'reference':
      return $replacement = '<span class="glossify_term">' . $term_title . '</span>';
  }
}