You are here

function theme_shoutbox_post in Shoutbox 5

Same name and namespace in other branches
  1. 6.2 shoutbox.theme.inc \theme_shoutbox_post()
  2. 6 shoutbox.module \theme_shoutbox_post()
  3. 7.2 shoutbox.theme.inc \theme_shoutbox_post()
  4. 7 shoutbox.theme.inc \theme_shoutbox_post()

Theme function for shoutbox posts.

Parameters

shout: The shout to be themed.

links: Links of possible actions that can be performed on this shout by the current user.

$alter_row_color: Whether or not to alternate the row color for posts. Should be set to FALSE for the page view.

3 theme calls to theme_shoutbox_post()
shoutbox_add_form_submit in ./shoutbox.module
Handles submission of a shout.
shoutbox_callback in ./shoutbox.module
Function to handle shoutbox callbacks that require a shout_id. Does some sanity checking on on the id before forwarding to the actual callback.
_shoutbox_display_posts in ./shoutbox.module
Output existing shoutbox posts as html. Used by shoutbox_block_view.

File

./shoutbox.module, line 315
shoutbox module displays a block for users to create short messages for thw whole site. Uses AHAH to update the database and display content.

Code

function theme_shoutbox_post($shout, $links = array(), $alter_row_color = TRUE) {

  // Get the registered username of the person who posted the shout.
  if ($shout->uid > 0) {
    $user = user_load(array(
      "uid" => $shout->uid,
    ));
    $shout->username = $user->name;
  }
  else {
    $shout->username = 'an anonymous user';
  }

  // BUGBUG strstr returns from http:// till end
  // we should use that instead of full url.
  if (strstr($shout->url, "http://")) {
    $shout->url = '<a href="' . $shout->url . '" target="_blank">' . $shout->nick . '</a>';
  }
  else {
    $shout->url = $shout->nick;
  }
  if ($links) {
    foreach ($links as $link) {
      $linkattributes = $link['attributes'];
      $link_html = $link['title'];
      $link_url = 'shoutbox/' . $shout->shout_id . '/' . $link['action'];
      $action_links = l($link_html, $link_url, $linkattributes, NULL, NULL, FALSE, TRUE) . $action_links;
    }
  }
  $title = 'Posted ' . format_date($shout->created, 'custom', 'm/d/y') . ' at ' . format_date($shout->created, 'custom', 'h:ia') . ' by ' . $shout->username;
  $shout_classes = "shoutbox-msg ";
  if ($alter_row_color) {
    $shout_classes .= $shout->color ? "shoutbox-odd " : "shoutbox-even ";
  }
  if ($shout->moderate == 1) {
    $shout_classes .= "shoutbox-unpublished ";
  }
  return "<div class=\" {$shout_classes} \" title=\"{$title}\"><span class=\"actions\">{$action_links}</span> <span class=\"shout\"><b>{$shout->url}</b>: {$shout->shout}</span></div>\n";
}