You are here

function theme_guestbook_entry in Guestbook 6

Same name and namespace in other branches
  1. 5.2 guestbook.module \theme_guestbook_entry()
  2. 5 guestbook.module \theme_guestbook_entry()
  3. 6.2 guestbook.module \theme_guestbook_entry()
  4. 7.2 guestbook.module \theme_guestbook_entry()
2 theme calls to theme_guestbook_entry()
guestbook_delete_entry_confirm in ./guestbook.module
theme_guestbook in ./guestbook.module
Guestbook theme functions

File

./guestbook.module, line 696

Code

function theme_guestbook_entry($uid, $entry, $comment_entry = NULL, $zebra, $confirm_delete = false) {
  global $user;
  $output = '';
  $display = (array) variable_get('guestbook_display', array(
    'date',
    'email',
    'website',
    'comments',
  ));
  $output .= "\n<div class=\"comment guestbook-entry {$zebra}\">\n";
  if ($comment_entry == $entry['id']) {
    $output .= '<a name="comment-entry"></a>';
  }

  // author
  if ($entry['author'] == 0) {
    $author = "<b>" . check_plain($entry['anonname']) . "</b>";
  }
  else {
    $author = "<b>" . theme('guestbook_user_picture', $entry['author']) . "</b>";
  }
  $output .= '<div class="author">' . $author . '</div>';

  // date, email, website
  $output .= '<div class="submitted">';
  if (in_array('date', $display)) {
    $output .= format_date($entry['created'], 'medium');
  }
  if (in_array('email', $display) && !empty($entry['anonemail'])) {
    $output .= '&nbsp;|&nbsp;<a href="mailto:' . check_url($entry['anonemail']) . '">' . t('E-mail') . '</a>';
  }
  if (in_array('website', $display) && !empty($entry['anonwebsite'])) {

    // Auto-prepend HTTP protocol if website contains no protocol.
    if (strpos($entry['anonwebsite'], '://') === FALSE) {
      $entry['anonwebsite'] = 'http://' . $entry['anonwebsite'];
    }
    $output .= '&nbsp;|&nbsp;<a href="' . check_url($entry['anonwebsite']) . '">' . t('Website') . '</a>&nbsp;';
  }
  $output .= '</div>';

  // message
  $output .= '<div class="content guestbook-message">' . check_markup($entry['message'], variable_get('guestbook_input_format', 1), FALSE) . '</div>';
  if ($entry['picture']) {
    $output .= '<div style="clear:both;"></div>';
  }

  // comment
  $output .= theme('guestbook_entry_comment', $uid, $entry, $comment_entry);

  // links
  if (_guestbook_access('administer', $uid) && !$confirm_delete) {
    if ($comment_entry != $entry['id']) {
      $pager = !empty($_GET['page']) ? 'page=' . $_GET['page'] : NULL;
      $output .= '<div class="links">&raquo; ';
      $output .= l(t('Delete entry'), guestbook_path($uid) . '/delete/' . $entry['id'], array(
        'query' => $pager,
      )) . '&nbsp;|&nbsp;';
      $output .= l($entry['comment'] == '' ? t('Add comment') : t('Edit comment'), guestbook_path($uid) . '/comment/' . $entry['id'], array(
        'query' => $pager,
        'fragment' => 'comment-entry',
      ));
      $output .= '</div>';
    }
  }
  $output .= "\n</div>";
  return $output;
}