You are here

function group_group_view_page in Group 7

Entry point for our overridden group view.

This function asks its assigned handlers who, if anyone, would like to run with it. If no one does, it passes through to the standard group view, which is group_page().

Parameters

Group $group: The group object.

Return value

array A render array suitable for use by drupal_render().

See also

group_group_view_menu_alter()

1 string reference to 'group_group_view_page'
group_group_view_menu_alter in plugins/page_manager/tasks/group_view.inc
Tries to hi-jack the group/%group path.

File

plugins/page_manager/tasks/group_view.inc, line 68
Take over group/%group with Page Manager.

Code

function group_group_view_page($group) {

  // Keep track of whether we need to set the page title and some <head> links.
  $set_head = TRUE;

  // Load the necessary files for context and task handling.
  ctools_include('context');
  ctools_include('context-task-handler');

  // Load the task plugin
  $task = page_manager_get_task('group_view');

  // Retrieve the Group context given the Group argument.
  $contexts = ctools_context_handler_get_task_contexts($task, '', array(
    $group,
  ));

  // Try to receive output from the task handlers.
  $output = ctools_context_handler_render($task, '', $contexts, array(
    $group->gid,
  ));

  // If no handlers were defined, fall back to either group_page() or another
  // function defined in hook_page_manager_override().
  if ($output === FALSE) {
    $function = 'group_page';
    foreach (module_implements('page_manager_override') as $module) {
      $override_function = module_invoke($module, 'page_manager_override', $function);
      if (function_exists($override_function)) {
        $function = $override_function;
        break;
      }
    }
    if ($function == 'group_page') {
      module_load_include('inc', 'group', 'pages/group');

      // No need to set the head here as group_page() will do the same.
      $set_head = FALSE;
    }
    $output = $function($group);
  }

  // Set the page title and canonical and shortlink head links. Copied verbatim
  // from group_page(). See that function for a more documented version.
  if ($set_head) {
    drupal_set_title($group
      ->label());
    $uri = entity_uri('group', $group);
    drupal_add_html_head_link(array(
      'rel' => 'canonical',
      'href' => url($uri['path'], $uri['options']),
    ), TRUE);
    drupal_add_html_head_link(array(
      'rel' => 'shortlink',
      'href' => url($uri['path'], array_merge($uri['options'], array(
        'alias' => TRUE,
      ))),
    ), TRUE);
  }
  return $output;
}