You are here

function author_pane_get_block in Author Pane 7.2

Same name and namespace in other branches
  1. 5 author_pane.module \author_pane_get_block()
  2. 6.2 author_pane.module \author_pane_get_block()
  3. 6 author_pane.module \author_pane_get_block()

Creates the contents of the block. Called from author_pane_block().

1 call to author_pane_get_block()
author_pane_block_view in ./author_pane.module
Implements hook_block_view().

File

./author_pane.module, line 327
Gathers information from user related modules into one template.

Code

function author_pane_get_block() {
  $area = arg(0);
  $context = NULL;

  // Check that we're in the right area. The block only works on the user pages,
  // node full view pages, and the blog listing pages. It also does not work on
  // the "edit" subpath.
  if (!($area == 'user' || $area == 'node' || $area == 'blog') || !is_numeric(arg(1)) || arg(2) == 'edit') {
    return;
  }
  if ($area == 'user' || $area == 'blog') {

    // On the user page or the user's blog listing. Get the UID from the URL.
    $uid = arg(1);
  }
  else {

    // We're on a node page so load the node.
    $node = menu_get_object();
    $allowed_types = variable_get('author_pane_block_display_types', array());
    if (!$node || empty($allowed_types[$node->type])) {

      // Not a type we want to show on.
      return;
    }
    $uid = $node->uid;

    // When we're displaying along with a node, we'll want to send the node
    // object into the theme function.
    $context = $node;
  }

  // Load up the user object
  $account = user_load($uid);

  // Theming variables for the author pane.
  $variables = array(
    'account' => $account,
    'caller' => 'author_pane_block',
    'picture_preset' => variable_get('author_pane_block_user_picture_preset', ''),
    'context' => $context,
    'join_date_type' => variable_get('author_pane_block_join_date_type', 'short'),
  );

  // Build and return the author pane.
  return theme('author_pane', $variables);
}