You are here

function theme_quotes_page in Quotes 6

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

Themeable quotes page display function that may be user restricted.

Parameters

$account: The user object for the user whose quotes should be displayed (loaded by menu system).

Return value

An HTML-formatted list of quotes.

2 theme calls to theme_quotes_page()
quotes_myquotes in ./quotes.module
Menu callback that generates a list of quotes created by the current user.
quotes_page in ./quotes.module
Menu callback that calls theme_quotes_page().

File

./quotes.module, line 1242
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 theme_quotes_page($uid = NULL) {
  $limit = variable_get('quotes_per_page', 10);

  //  if ($account) {
  if ($uid) {
    $account = user_load(array(
      'uid' => $uid,
      'status' => 1,
    ));
    $name = isset($account->realname) ? $account->realname : $account->name;
    $menu_info = menu_get_item('quotes');
    $menu_title = $menu_info['title'];
    drupal_set_title(t("!name's !menu", array(
      '!menu' => $menu_title,
      '!name' => $name,
    )));
    $url = url("quotes/{$account->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, $account->uid);
  }
  else {
    $url = url('quotes/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' ORDER BY n.sticky DESC, n.created DESC"), $limit, 0);
  }
  $output = '<div class="quotes">';
  $count = 0;
  while ($nid = db_result($result)) {
    $node = node_load($nid);
    $output .= node_view($node, 1);
    ++$count;
  }
  if ($count) {
    $output .= theme('pager', NULL, $limit);
    drupal_add_feed($url, t('RSS - !title', array(
      '!title' => drupal_get_title(),
    )));
  }
  else {
    $output .= t('No quotes found.');
  }
  return $output . '</div>';
}