You are here

function page_manager_page_admin_summary in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 page_manager/plugins/tasks/page.inc \page_manager_page_admin_summary()

Provide a nice administrative summary of the page so an admin can see at a glance what this page does and how it is configured.

1 string reference to 'page_manager_page_admin_summary'
page_manager_page_build_subtask in page_manager/plugins/tasks/page.inc
Build a subtask array for a given page.

File

page_manager/plugins/tasks/page.inc, line 567
Handle the 'page' task, which creates pages with arbitrary tasks and lets handlers decide how they will be rendered.

Code

function page_manager_page_admin_summary($task, $subtask) {
  $task_name = page_manager_make_task_name($task['name'], $subtask['name']);
  $page = $subtask['subtask'];
  $output = '';
  $rows = array();
  $rows[] = array(
    array(
      'class' => t('page-summary-label'),
      'data' => t('Storage'),
    ),
    array(
      'class' => t('page-summary-data'),
      'data' => $subtask['storage'],
    ),
    array(
      'class' => t('page-summary-operation'),
      'data' => '',
    ),
  );
  if (!empty($page->disabled)) {
    $link = l(t('Enable'), page_manager_edit_url($task_name, array(
      'handlers',
      $page->name,
      'actions',
      'enable',
    )));
    $text = t('Disabled');
  }
  else {
    $link = l(t('Disable'), page_manager_edit_url($task_name, array(
      'handlers',
      $page->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,
    ),
  );
  $path = array();
  foreach (explode('/', $page->path) as $bit) {
    if ($bit[0] != '!') {
      $path[] = $bit;
    }
  }
  $path = implode('/', $path);
  $front = variable_get('site_frontpage', 'node');
  $link = l(t('Edit'), page_manager_edit_url($task_name, array(
    'settings',
    'basic',
  )));
  $message = '';
  if ($path == $front) {
    $message = t('This is your site home page.');
  }
  else {
    if (!empty($page->make_frontpage)) {
      $message = t('This page is set to become your site home page.');
    }
  }
  if ($message) {
    $rows[] = array(
      array(
        'class' => t('page-summary-data'),
        'data' => $message,
        'colspan' => 2,
      ),
      array(
        'class' => t('page-summary-operation'),
        'data' => $link,
      ),
    );
  }
  if (strpos($path, '%') === FALSE) {
    $path = l('/' . $page->path, $path);
  }
  else {
    $path = '/' . $page->path;
  }
  $rows[] = array(
    array(
      'class' => t('page-summary-label'),
      'data' => t('Path'),
    ),
    array(
      'class' => t('page-summary-data'),
      'data' => $path,
    ),
    array(
      'class' => t('page-summary-operation'),
      'data' => $link,
    ),
  );
  if (empty($access['plugins'])) {
    $access['plugins'] = array();
  }
  $contexts = page_manager_page_get_contexts($task, $subtask);
  $access = ctools_access_group_summary($page->access, $contexts);
  if ($access) {
    $access = t('Accessible only if @conditions.', array(
      '@conditions' => $access,
    ));
  }
  else {
    $access = t('This page is publicly accessible.');
  }
  $link = l(t('Edit'), page_manager_edit_url($task_name, array(
    'settings',
    'access',
  )));
  $rows[] = array(
    array(
      'class' => t('page-summary-label'),
      'data' => t('Access'),
    ),
    array(
      'class' => t('page-summary-data'),
      'data' => $access,
    ),
    array(
      'class' => t('page-summary-operation'),
      'data' => $link,
    ),
  );
  $menu_options = array(
    'none' => t('No menu entry.'),
    'normal' => t('Normal menu entry.'),
    'tab' => t('Menu tab.'),
    'default tab' => t('Default menu tab.'),
  );
  if (!empty($page->menu)) {
    $menu = $menu_options[$page->menu['type']];
    if ($page->menu['type'] != 'none') {
      $menu .= ' ' . t('Title: %title.', array(
        '%title' => $page->menu['title'],
      ));
      switch ($page->menu['type']) {
        case 'default tab':
          $menu .= ' ' . t('Parent title: %title.', array(
            '%title' => $page->menu['parent']['title'],
          ));
          break;
        case 'normal':
          if (module_exists('menu')) {
            $menus = menu_get_menus();
            $menu .= ' ' . t('Menu block: %title.', array(
              '%title' => $menus[$page->menu['name']],
            ));
          }
          break;
      }
    }
  }
  else {
    $menu = t('No menu entry');
  }
  $link = l(t('Edit'), page_manager_edit_url($task_name, array(
    'settings',
    'menu',
  )));
  $rows[] = array(
    array(
      'class' => t('page-summary-label'),
      'data' => t('Menu'),
    ),
    array(
      'class' => t('page-summary-data'),
      'data' => $menu,
    ),
    array(
      'class' => t('page-summary-operation'),
      'data' => $link,
    ),
  );
  $output .= theme('table', array(), $rows, array(
    'id' => 'page-manager-page-summary',
  ));
  return $output;
}