You are here

function quotes_author in Quotes 6

Same name and namespace in other branches
  1. 5 quotes.module \quotes_author()
  2. 7 quotes.module \quotes_author()

Menu callback that selects quotes based on author.

Parameters

$author: The name of the author of the quotes.

Return value

An HTML-formatted list of quotes.

1 call to quotes_author()
quotes_page in ./quotes.module
Menu callback that calls theme_quotes_page().

File

./quotes.module, line 1468
The quotes module allows users to maintain a list of quotes that can be displayed in any number of administrator-defined quote blocks.

Code

function quotes_author($author = NULL) {
  if (!$author) {

    // If no author given, display a selection list.
    return drupal_get_form('quotes_author_form');
  }
  elseif ($author == t('unspecified')) {
    $aid = 0;
    $auth = array(
      'name' => $author,
      'bio' => '',
    );
  }
  else {

    // See whether we have a name or an id.
    if (is_numeric($author)) {
      $aid = $author;
      $auth = db_fetch_array(db_query("SELECT name, bio FROM {quotes_authors} WHERE aid=%d", $aid));
      $author = $auth['name'];
    }
    else {
      $auth = db_fetch_array(db_query("SELECT aid, bio FROM {quotes_authors} WHERE name LIKE('%s%')", $author));
      $aid = $auth['aid'];
    }
    if (!$aid) {
      return t('I couldn\'t locate that author.') . drupal_get_form('quotes_author_form');
    }
  }

  // Unspecified author.
  $limit = variable_get('quotes_per_page', 10);
  $menu_info = menu_get_item('quotes');
  $menu_title = $menu_info['title'];
  drupal_set_title(decode_entities(t('!menu by @name', array(
    '!menu' => $menu_title,
    '@name' => $author,
  ))));
  if ($auth['bio']) {
    $output = '<div class="quotes-header-bio clear-block">' . check_markup($auth['bio']) . '</div>';
  }
  $result = pager_query(db_rewrite_sql("SELECT n.nid FROM {node} n INNER JOIN {node_revisions} nr USING (vid) INNER JOIN {quotes} q USING (vid) WHERE q.aid='%d' AND n.status=1 AND n.type='quotes' ORDER BY n.sticky DESC, n.created DESC"), $limit, 0, NULL, $aid);
  $output .= '<div class="quotes">';
  while ($node = db_fetch_object($result)) {
    $output .= node_view(node_load($node->nid), FALSE);
  }
  $output .= theme('pager', NULL, $limit);
  return $output . '</div>';
}