You are here

function shoutbox_view in Shoutbox 7

Same name and namespace in other branches
  1. 6.2 shoutbox.module \shoutbox_view()
  2. 7.2 shoutbox.module \shoutbox_view()

View the shoutbox.

Parameters

$block: TRUE if the output desired is for a block, otherwise FALSE

4 calls to shoutbox_view()
shoutbox_block_view in ./shoutbox.module
Implements hook_block_view().
shoutbox_domain_block_view_alter in shoutbox_domain/shoutbox_domain.module
Implements hook_block_view_alter().
shoutbox_group_page in shoutbox_group/shoutbox_group.module
Generate dedicated shoutbox page for group
shoutbox_user_page in shoutbox_user/shoutbox_user.module
Page callback for user shoutbox page
1 string reference to 'shoutbox_view'
shoutbox_menu in ./shoutbox.module
Implements hook_menu().

File

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

Code

function shoutbox_view($block = FALSE) {

  // Load externals.
  theme('shoutbox_external_files');
  $build = array();

  // Determine the post count.
  if (!$block) {
    $show_amount = variable_get('shoutbox_showamount_page', '30');
  }
  else {
    $show_amount = variable_get('shoutbox_showamount_block', '10');
  }

  // Output the existing shoutbox posts.
  $shoutbox_posts_data = shoutbox_display_posts($show_amount, !$block);
  $shoutbox_posts_data['#prefix'] = "<div id=\"shoutbox-body\">\n";
  $shoutbox_posts_data['#suffix'] = "</div>\n";
  $build['posts'] = $shoutbox_posts_data;

  // Alterations only needed if there are shouts.
  if (count($shoutbox_posts_data['#rows'])) {
    if ($block) {

      // If block, show link to page.
      $page_path = 'shoutbox';
      $shout = new stdClass();

      // Allow other modules to alter the link path.
      shoutbox_invoke('link', $shout, $page_path);

      // Generate the link.
      $build['all-shouts-link'] = array(
        '#theme' => 'shoutbox_block_page_link',
        '#path' => $page_path,
      );
    }
    else {

      // If page, show pagers.
      $build['pager'] = array(
        '#theme' => 'pager',
        '#quantity' => 5,
        '#weight' => 10,
      );
    }
  }

  // Output the shoutbox form.
  $build['form'] = drupal_get_form('shoutbox_add_form');

  // dprint_r($build);
  // unset($build['content']['count']);
  // JS Settings.
  _shoutbox_js_config();
  return $build;
}