You are here

function glossary_search_results in Glossary 7

Same name and namespace in other branches
  1. 5.2 glossary.module \glossary_search_results()
  2. 5 glossary.module \glossary_search_results()
  3. 6 glossary.module \glossary_search_results()

Present the search results.

1 string reference to 'glossary_search_results'
glossary_menu in ./glossary.module
Implements hook_menu().

File

./glossary.module, line 207
Glossary terms will be automatically marked with links to their descriptions.

Code

function glossary_search_results($keys = NULL) {

  // We onky needs the vids themselves here.
  $vids = array_keys(_glossary_get_filter_vids());
  $output = '<div class="glossary-list">';
  $result = db_select('taxonomy_term_data', 'td');
  $result
    ->addField('td', 'tid');
  $result
    ->condition('td.vid', $vids, 'IN')
    ->condition(db_or()
    ->condition('td.description', "%{$keys}%", 'LIKE')
    ->condition('td.name', "%{$keys}%", 'LIKE'));
  $result = $result
    ->execute();
  $found = NULL;
  foreach ($result as $row) {
    $term = taxonomy_term_load($row->tid);
    $found .= '<dl>' . theme('glossary_overview_item', array(
      'term' => $term,
      'show_desc' => TRUE,
      'dest' => NULL,
    )) . '</dl>';
  }
  if (!$found) {

    // @TODO: This returns a render array now.
    $found = drupal_get_form('glossary_search_form', $keys) . '<p>' . t('Your search yielded no results') . glossary_help('glossary_search#noresults') . '</p>';
    $found = drupal_render($found);
  }
  $output_title = t('Glossary search results');
  $output .= '<div class="box"><h2 class="title">' . $output_title . '</h2><div class="content">' . $found . '</div></div>';
  return $output . "</div>\n";
}