You are here

function freelinking_google_callback in Freelinking 7.3

Same name and namespace in other branches
  1. 6.3 plugins/freelinking_search.inc \freelinking_google_callback()

Replacement callback for Google plugin

1 string reference to 'freelinking_google_callback'
freelinking_search.inc in plugins/freelinking_search.inc

File

plugins/freelinking_search.inc, line 72

Code

function freelinking_google_callback($target, $plugin) {
  global $language;
  if (!$language) {
    $lang = 'en';
  }
  else {
    $lang = $language->language;
  }
  if ($target['text']) {
    $title = $target['text'];
  }
  else {
    $title = 'Google Search “' . $target['dest'] . '”';
  }
  $link = array(
    check_plain($title),
    'http://www.google.com/search',
    array(
      'query' => array(
        'q' => check_url($target['dest']),
        'hl' => $lang,
      ),
      'external' => TRUE,
      'attributes' => array(
        'title' => t('Search Google for content like “%dest”', array(
          '%dest' => $target['dest'],
        )),
      ),
    ),
  );
  if (isset($target['other']['site'])) {
    $link[2]['query']['as_sitesearch'] = urlencode($target['other']['site']);
  }
  return $link;
}