function _shoutbox_display_posts in Shoutbox 5
Same name and namespace in other branches
- 6 shoutbox.module \_shoutbox_display_posts()
Output existing shoutbox posts as html. Used by shoutbox_block_view.
Parameters
$show_amount: The number of posts to show.
$wrap: Whether or not to wrap posts in <div id="shoutbox-posts">
$pager: Whether or not to use pager_query() instead of db_query_range(), defaults to FALSE.
Return value
HTML for show_amount number of posts.
3 calls to _shoutbox_display_posts()
- shoutbox_js_view in ./
shoutbox.module - Javascript callback. Prints out shouts only.
- shoutbox_page_view in ./
shoutbox.module - Show paged view of full list of shouts.
- _shoutbox_block_view in ./
shoutbox.module - Returns the themed HTML to be displayed in the block.
File
- ./
shoutbox.module, line 899 - 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 _shoutbox_display_posts($show_amount, $wrap = TRUE, $pager = FALSE) {
$color = 0;
$count = 0;
$output = '';
$rows = array();
// Figure out if we should display it in ascending or descending order.
$ascending = variable_get('shoutbox_ascending', FALSE);
// Get the shouts from the database.
if (!$pager) {
$result = db_query_range("SELECT * FROM {shoutbox} ORDER BY created DESC", 0, $show_amount);
}
else {
$result = pager_query("SELECT * FROM {shoutbox} ORDER BY created DESC", $show_amount);
}
while ($shout = db_fetch_object($result)) {
if ($shout->moderate == 0 || _shoutbox_user_access('moderate shoutbox') || _shoutbox_is_user_owned($shout)) {
_shoutbox_sanitize_shout($shout);
// Add edit/delete links depending on user's permissions.
$shoutlinks = _shoutbox_get_links($shout);
// Alternate colors for each post (row of the shoutbox).
if ($color == 0) {
$color = 1;
}
else {
$color = 0;
}
$shout->color = $color;
// Theme the shoutbox post.
if ($ascending) {
$output .= theme('shoutbox_post', $shout, $shoutlinks);
}
else {
$output = theme('shoutbox_post', $shout, $shoutlinks) . $output;
}
$rows[] = array(
theme('shoutbox_post', $shout, $shoutlinks, FALSE),
);
++$count;
}
}
if (!$ascending) {
$rows = array_reverse($rows);
}
if (!$count) {
$output .= '<div class="shoutbox-even" title="no shouts">' . t("There are no shouts to view.") . "</div>\n";
}
if ($wrap) {
// Wrap shout box messages.
$output = "<div id=\"shoutbox-posts\">\n" . $output . "</div>\n";
}
$output_data['count'] = $count;
$output_data['output'] = $output;
$output_data['rows'] = $rows;
return $output_data;
}