You are here

function theme_quotes_page in Quotes 5

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

Themeable function that displays a page of quotes that may be restricted to a certain user.

Parameters

$uid: The user ID of the user whose quotes should be displayed.

Return value

An HTML-formatted list of quotes.

1 theme call to theme_quotes_page()
_quotes_page in ./quotes.module
Menu callback that calls theme_quotes_page().

File

./quotes.module, line 1224

Code

function theme_quotes_page($uid) {
  $limit = variable_get('quotes_per_page', 10);
  if (isset($uid)) {
    $user = user_load(array(
      'uid' => $uid,
      'status' => 1,
    ));
    $name = $uid ? module_exists('realname') ? $user->realname : $user->name : variable_get('anonymous', t('Anonymous'));
    drupal_set_title(t("!name's quotes", array(
      '!name' => $name,
    )));
    $url = url("quotes/{$uid}/feed");
    $result = pager_query(db_rewrite_sql("SELECT n.nid FROM {node} n INNER JOIN {node_revisions} nr USING (vid) WHERE n.status=1 AND n.type='quotes' AND n.uid=%d ORDER BY n.sticky DESC, n.created DESC"), $limit, 0, NULL, $uid);
  }
  else {
    drupal_set_title(t('Quotes'));
    $url = url('quotes/feed');
    $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky FROM {node} n INNER JOIN {node_revisions} nr USING (vid) WHERE n.status = 1 AND n.type = 'quotes' ORDER BY n.sticky DESC, n.created DESC"), $limit);
  }
  $output = '<div class="quotes">';
  while ($node = db_fetch_object($result)) {
    $quote = node_load($node->nid);
    $output .= node_view($quote, TRUE);
  }
  $output .= theme('pager', NULL, $limit);
  drupal_add_feed($url, t('RSS - !title', array(
    '!title' => drupal_get_title(),
  )));
  return $output . '</div>';
}