You are here

function page_manager_page_build_subtask in Chaos Tool Suite (ctools) 7

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

Build a subtask array for a given page.

3 calls to page_manager_page_build_subtask()
page_manager_page_new_page_cache in page_manager/plugins/tasks/page.inc
When adding or cloning a new page, this creates a new page cache and adds our page to it.
page_manager_page_subtask in page_manager/plugins/tasks/page.inc
Callback to return a single subtask.
page_manager_page_subtasks in page_manager/plugins/tasks/page.inc
Task callback to get all subtasks.

File

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

Code

function page_manager_page_build_subtask($task, $page) {
  $operations = array();
  $operations['settings'] = array(
    'type' => 'group',
    'class' => array(
      'operations-settings',
    ),
    'title' => t('Settings'),
    'children' => array(),
  );
  $settings =& $operations['settings']['children'];
  $settings['basic'] = array(
    'title' => t('Basic'),
    'description' => t('Edit name, path and other basic settings for the page.'),
    'form' => 'page_manager_page_form_basic',
  );
  $arguments = page_manager_page_get_named_arguments($page->path);
  if ($arguments) {
    $settings['argument'] = array(
      'title' => t('Arguments'),
      'description' => t('Set up contexts for the arguments on this page.'),
      'form' => 'page_manager_page_form_argument',
    );
  }
  $settings['access'] = array(
    'title' => t('Access'),
    'description' => t('Control what users can access this page.'),
    'admin description' => t('Access rules are used to test if the page is accessible and any menu items associated with it are visible.'),
    'form' => 'page_manager_page_form_access',
  );
  $settings['menu'] = array(
    'title' => t('Menu'),
    'description' => t('Provide this page a visible menu or a menu tab.'),
    'form' => 'page_manager_page_form_menu',
  );
  $operations['actions']['children']['clone'] = array(
    'title' => t('Clone'),
    'description' => t('Make a copy of this page'),
    'form' => 'page_manager_page_form_clone',
  );
  $operations['actions']['children']['export'] = array(
    'title' => t('Export'),
    'description' => t('Export this page as code that can be imported or embedded into a module.'),
    'form' => 'page_manager_page_form_export',
  );
  if ($page->export_type == (EXPORT_IN_CODE | EXPORT_IN_DATABASE)) {
    $operations['actions']['children']['delete'] = array(
      'title' => t('Revert'),
      'description' => t('Remove all changes to this page and revert to the version in code.'),
      'form' => 'page_manager_page_form_delete',
    );
  }
  elseif ($page->export_type != EXPORT_IN_CODE) {
    $operations['actions']['children']['delete'] = array(
      'title' => t('Delete'),
      'description' => t('Remove this page from your system completely.'),
      'form' => 'page_manager_page_form_delete',
    );
  }
  $subtask = array(
    'name' => $page->name,
    'admin title' => check_plain($page->admin_title),
    'admin description' => filter_xss_admin($page->admin_description),
    'admin summary' => 'page_manager_page_admin_summary',
    'admin path' => $page->path,
    'admin type' => t('Custom'),
    'subtask' => $page,
    'operations' => $operations,
    'operations include' => array(
      'file' => 'page.admin.inc',
      'path' => drupal_get_path('module', 'page_manager') . '/plugins/tasks',
    ),
    'single task' => empty($page->multiple),
    'row class' => empty($page->disabled) ? 'page-manager-enabled' : 'page-manager-disabled',
    'storage' => $page->type == t('Default') ? t('In code') : $page->type,
    'disabled' => !empty($page->disabled),
    // This works for both enable AND disable.
    'enable callback' => 'page_manager_page_enable',
  );

  // Default handlers may appear from a default subtask.
  if (isset($page->default_handlers)) {
    $subtask['default handlers'] = $page->default_handlers;
  }
  return $subtask;
}