You are here

function theme_quotes_quote in Quotes 7

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

Themeable function that displays a single quote and optional author.

File

./quotes.module, line 1630
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_quote($variables) {
  if (!isset($variables['teaser'])) {
    $variables['teaser'] == FALSE;
  }
  if (!isset($variables['show_bio'])) {
    $variables['show_bio'] == variable_get('quotes_author_bio', FALSE);
  }
  if (!isset($variables['max_length'])) {
    $variables['max_length'] == 0;
  }
  $node = $variables['node'];
  $teaser = $variables['teaser'];
  $show_bio = $variables['show_bio'];
  $max_length = $variables['max_length'];
  global $user;
  $body = render(field_view_value('node', $node, 'body', 0, $teaser ? 'teaser' : 'full'));
  if ($max_length) {

    // We want to limit the text.
    $text = text_summary($body, $node->format, $size = $max_length);
    if (drupal_strlen($text) < drupal_strlen($body)) {
      $text .= '&hellip;' . l(t('(more)'), drupal_get_path_alias('node/' . $node->nid));
    }
  }
  else {
    $text = $body;
  }
  $leader = variable_get('quotes_leader', '&mdash;') . ' ';

  // Get the format for author and citation.
  $format = variable_get('quotes_format', filter_default_format());
  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, $format, $node->language, FALSE) : '';
  }
  switch ($show_bio) {
    case 1:
      $bio = $node->quotes_bio ? '<div class="quotes-bio">' . check_markup($node->quotes_bio, $format, $node->language, FALSE) . '</div>' : '';
      break;
    case 2:
      $menu_info = menu_get_item('quotes');
      $menu_title = drupal_strtolower($menu_info['title']);
      $bio = $node->quotes_author ? '<div class = "quotes-bio-link">' . l(t('See biography and !menu', array(
        '!menu' => $menu_title,
      )), '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>", $format, $node->language, FALSE) : '';
}