You are here

function page_manager_http_response_admin_summary in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 page_manager/plugins/task_handlers/http_response.inc \page_manager_http_response_admin_summary()
1 string reference to 'page_manager_http_response_admin_summary'
http_response.inc in page_manager/plugins/task_handlers/http_response.inc
This is the task handler plugin to handle generating 403, 404 and 301 response codes.

File

page_manager/plugins/task_handlers/http_response.inc, line 114
This is the task handler plugin to handle generating 403, 404 and 301 response codes.

Code

function page_manager_http_response_admin_summary($handler, $task, $subtask, $page, $show_title = TRUE) {
  $task_name = page_manager_make_task_name($task['name'], $subtask['name']);
  $output = '';
  ctools_include('context');
  ctools_include('context-task-handler');

  // Get the operations
  $operations = page_manager_get_operations($page);

  // Get operations for just this handler.
  $operations = $operations['handlers']['children'][$handler->name]['children']['actions']['children'];
  $args = array(
    'handlers',
    $handler->name,
    'actions',
  );
  $rendered_operations = page_manager_render_operations($page, $operations, array(), array(
    'class' => 'actions',
  ), 'actions', $args);
  $plugin = page_manager_get_task_handler($handler->handler);
  $object = ctools_context_handler_get_task_object($task, $subtask, $handler);
  $context = ctools_context_load_contexts($object, TRUE);
  $access = ctools_access_group_summary(!empty($handler->conf['access']) ? $handler->conf['access'] : array(), $context);
  if ($access) {
    $access = t('This task will be selected if @conditions.', array(
      '@conditions' => $access,
    ));
  }
  else {
    $access = t('This task will always be selected.');
  }
  $rows = array();
  $type = $handler->type == t('Default') ? t('In code') : $handler->type;
  $rows[] = array(
    array(
      'class' => t('page-summary-label'),
      'data' => t('Storage'),
    ),
    array(
      'class' => t('page-summary-data'),
      'data' => $type,
    ),
    array(
      'class' => t('page-summary-operation'),
      'data' => '',
    ),
  );
  if (!empty($handler->disabled)) {
    $link = l(t('Enable'), page_manager_edit_url($task_name, array(
      'handlers',
      $handler->name,
      'actions',
      'enable',
    )));
    $text = t('Disabled');
  }
  else {
    $link = l(t('Disable'), page_manager_edit_url($task_name, array(
      'handlers',
      $handler->name,
      'actions',
      'disable',
    )));
    $text = t('Enabled');
  }
  $rows[] = array(
    array(
      'class' => t('page-summary-label'),
      'data' => t('Status'),
    ),
    array(
      'class' => t('page-summary-data'),
      'data' => $text,
    ),
    array(
      'class' => t('page-summary-operation'),
      'data' => $link,
    ),
  );
  $link = l(t('Edit'), page_manager_edit_url($task_name, array(
    'handlers',
    $handler->name,
    'criteria',
  )));
  $rows[] = array(
    array(
      'class' => t('page-summary-label'),
      'data' => t('Selection rule'),
    ),
    array(
      'class' => t('page-summary-data'),
      'data' => $access,
    ),
    array(
      'class' => t('page-summary-operation'),
      'data' => $link,
    ),
  );
  $link = l(t('Edit'), page_manager_edit_url($task_name, array(
    'handlers',
    $handler->name,
    'settings',
  )));
  $codes = page_manager_http_response_codes();
  $rows[] = array(
    array(
      'class' => t('page-summary-label'),
      'data' => t('Response code'),
    ),
    array(
      'class' => t('page-summary-data'),
      'data' => $codes[$handler->conf['code']],
    ),
    array(
      'class' => t('page-summary-operation'),
      'data' => $link,
    ),
  );
  $info = theme('table', array(), $rows, array(
    'class' => 'page-manager-handler-summary',
  ));
  $title = $handler->conf['title'];
  if ($title != t('HTTP Response')) {
    $title = t('HTTP Response: @title', array(
      '@title' => $title,
    ));
  }
  $output .= '<div class="clear-block">';
  if ($show_title) {
    $output .= '<div class="handler-title clear-block">';
    $output .= '<div class="actions handler-actions">' . $rendered_operations['actions'] . '</div>';
    $output .= '<span class="title-label">' . $title . '</span>';
  }
  $output .= '</div>';
  $output .= $info;
  $output .= '</div>';
  return $output;
}