You are here

function theme_quotes_quote in Quotes 5

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

Themeable function that displays a single quote and optional author.

Parameters

$node: The node object containing the quote body and author.

$teaser: Boolean to indicate whether to use the teaser or the body.

$bio: Boolean to indicate whether to use the author's biography.

Return value

An HTML-formatted quote.

1 theme call to theme_quotes_quote()
quotes_view in ./quotes.module
Implementation of hook_view().

File

./quotes.module, line 1164

Code

function theme_quotes_quote($node, $teaser = FALSE, $bio = TRUE, $max_length = 0) {
  global $user;
  if ($max_length) {

    // We want to limit the text.
    $text = _quotes_trim($node->body, $max_length);
    if (drupal_strlen($text) < drupal_strlen($node->body)) {
      $text .= l(t('(more)'), drupal_get_path_alias('node/' . $node->nid));
    }
  }
  else {
    $text = $teaser ? $node->teaser : $node->body;
  }
  $body = check_markup($text, $node->format, $user->uid == $node->uid);
  $leader = variable_get('quotes_leader', '&mdash;') . ' ';
  if (arg(1) == 'author') {
    $show_bio = FALSE;
  }
  else {
    $show_bio = variable_get('quotes_author_bio', FALSE);
  }
  if (variable_get('quotes_author_link', FALSE)) {
    $author = $node->quotes_author ? $leader . l($node->quotes_author, 'quotes/author/' . $node->quotes_author, array(
      'title' => t('View all quotes by this author'),
    )) : '';
    $author = decode_entities($author);
  }
  else {
    $author = $node->quotes_author ? check_markup($leader . $node->quotes_author, $node->format, $user->uid == $node->uid) : '';
  }
  switch ($show_bio) {
    case 1:
      $bio = $node->quotes_bio ? '<div class="quotes-bio">' . check_markup($node->quotes_bio, $node->format, $user->uid == $node->uid) . '</div>' : '';
      break;
    case 2:
      $bio = $node->quotes_author ? '<div class="quotes-bio-link">' . l(t('See biography and quotes'), 'quotes/author/' . $node->quotes_author, array(
        'title' => t('View all quotes by this author'),
      )) . '</div>' : '';
      break;
    default:
      $bio = NULL;
  }
  $citation = $node->quotes_citation ? check_markup("<cite>" . $node->quotes_citation . "</cite>", $node->format, $user->uid == $node->uid) : '';
  return '<div class="quotes-quote">' . $body . '</div>' . ($author ? '<div class="quotes-author">' . $author . '</div>' : '') . $bio . ($citation ? '<div class="quotes-citation">' . $citation . '</div>' : '') . '<div class="clear-block"></div>';
}