You are here

function google_appliance_block in Google Search Appliance 5

Same name and namespace in other branches
  1. 6.2 google_appliance.module \google_appliance_block()

Implementation of hook_block().

File

./google_appliance.module, line 39
GSA integration

Code

function google_appliance_block($op = 'list', $delta = 0, $edit = array()) {
  switch ($op) {
    case 'list':
      $blocks['recommended_links']['info'] = t("Recommended Links");
      $blocks['recommended_links']['title'] = t('Recommended Links');
      $blocks['recommended_links']['pages'] = '*search/google_appliance*';
      $blocks['recommended_links']['visibility'] = 1;
      return $blocks;
      break;
    case 'view':
      switch ($delta) {
        case 'recommended_links':
          if ($result =& google_appliance_static_response_cache()) {
            $matches = $result
              ->getKeyMatches();
            if (!$matches) {
              return;
            }
            $links = array();
            foreach ($matches as $link => $title) {
              $links[] = l($title, $link);
            }
            if (count($links)) {
              $block['content'] = theme('item_list', $links);
            }
            else {
              return false;
            }
          }
          break;
      }
      return $block;
      break;
  }
}