You are here

function biblio_show_results in Bibliography Module 6.2

Same name and namespace in other branches
  1. 5 biblio.module \biblio_show_results()
  2. 6 biblio.pages.inc \biblio_show_results()

biblio_show_results takes the query results from biblio_db_search and adds some controls to the page then loops through the results applying the selected style to each entry

Parameters

$nodes:

array $query_info:

bool $inline: (optional) A logical flag indicating whether the biblio items should be formatted in a inline manner. The default is FALSE.

Return value

string An HTML string suitable for display in a browser.

1 call to biblio_show_results()
biblio_db_search in includes/biblio.pages.inc
Page callback: Displays a listing of biblio type of content.

File

includes/biblio.pages.inc, line 465
Functions in the biblio module related to filtering and page generation.

Code

function biblio_show_results($nodes, $query_info, $inline = FALSE) {
  global $pager_total_items;
  $content = '';
  $profile = FALSE;
  $attrib = $query_info['sort_attrib'];
  $args = $query_info['args'];
  $base = variable_get('biblio_base', 'biblio');
  $style = biblio_get_style();
  if ($inline === 'profile') {
    $profile = TRUE;
    $inline = FALSE;
  }
  if (module_exists('popups')) {
    popups_add_popups();
  }
  if (!$inline && !$profile) {
    if (variable_get('biblio_rss', 0)) {
      drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="' . variable_get('site_name', 'Drupal') . ' RSS" href="' . url("{$base}/rss.xml") . '" />');
    }

    // Search box. Has same permissions as the filter tab.
    $content = '<div id="biblio-header" class="clear-block">';
    if (variable_get('biblio_search', 0) && user_access('show filter tab')) {
      $content .= drupal_get_form('biblio_search_form');
    }
    if (biblio_access('export')) {
      $content .= '<div class="biblio-export">' . theme('biblio_export_links') . '</div>';
    }
    else {
      $content .= '<div class="biblio-export">' . t('Found @count results', array(
        '@count' => $pager_total_items[0],
      )) . '</div><br />';
    }

    // Add some links to the top of the page to change the sorting/ordering...
    if (user_access('show sort links')) {
      $content .= _biblio_sort_tabs($attrib);
    }
    $content .= '</div>';
    if (user_access('show filter tab')) {
      $content .= $query_info['filter_line'];
    }
  }
  if ($inline === true) {
    print '<div class="biblio-inline">';
  }
  if (isset($_GET['sort'])) {
    $value = '';
    if ($_GET['sort'] == 'title' || $_GET['sort'] == 'author' || $_GET['sort'] == 'keyword') {
      if (strpos($_GET['q'], 'ag') || strpos($_GET['q'], 'tg') || strpos($_GET['q'], 'keyword')) {
        $value = substr($_GET['q'], strrpos($_GET['q'], '/') + 1);
      }
      $content .= theme('biblio_alpha_line', $_GET['sort'], $value);
    }
  }
  $count = 0;

  // Reset separator bar status for repeated calls to biblio_db_search.
  _biblio_category_separator_bar(NULL, NULL, TRUE);
  foreach ($nodes as $node) {
    $count++;
    if (is_array($node)) {
      $node = (object) $node;
    }
    if (variable_get('biblio_hide_bibtex_braces', 0)) {
      $node->title = biblio_remove_brace($node->title);
    }
    if (variable_get('biblio_fix_isi_links', 0)) {
      biblio_fix_isi_links($node);
    }

    // Add a separator bar if needed.
    $content .= _biblio_category_separator_bar($attrib, $node);
    $inline_links = $inline && variable_get('biblio_inlinemode_in_links', 0) ? TRUE : FALSE;
    $content .= theme('biblio_entry', $node, $base, $style, $inline_links);
  }
  if ($count) {
    $content .= '</div><!-- end category-section -->';
  }
  $content .= theme('pager', 0, variable_get('biblio_rowsperpage', 25));
  if ($count == 0) {
    $content .= "<h3>" . t("No items found") . "</h3>";
    if (strstr($content, "Filters:")) {
      $content .= t('!modify_link or !remove_link your filters and try again.', array(
        '!modify_link' => l(t('Modify'), "{$base}/filter"),
        '!remove_link' => l(t('remove'), "{$base}/filter/clear"),
      ));
    }
  }
  if ($profile === TRUE) {
    return $content;
  }
  elseif ($inline === TRUE) {
    return $content . "</div>";
  }
  elseif ($inline === FALSE) {
    drupal_set_title(check_plain(variable_get('biblio_base_title', 'Biblio')));
    return $content;
  }
}