You are here

function page_manager_page_form_basic in Chaos Tool Suite (ctools) 7

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

Basic settings form for a page manager page.

2 string references to 'page_manager_page_form_basic'
page_manager_page_add_subtask in page_manager/plugins/tasks/page.admin.inc
Page callback to add a subtask.
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.admin.inc, line 385
Administrative functions for the page subtasks.

Code

function page_manager_page_form_basic($form, &$form_state) {
  $page =& $form_state['page']->subtask['subtask'];
  $task = $form_state['task'];
  $form['admin_title'] = array(
    '#type' => 'textfield',
    '#title' => t('Administrative title'),
    '#description' => t('The name of this page. This will appear in the administrative interface to easily identify it.'),
    '#default_value' => $page->admin_title,
  );
  $form['name'] = array(
    '#type' => 'machine_name',
    '#title' => t('Machine name'),
    '#machine_name' => array(
      'exists' => 'page_manager_page_load',
      'source' => array(
        'admin_title',
      ),
    ),
    '#description' => t('The machine readable name of this page. It must be unique, and it must contain only alphanumeric characters and underscores. Once created, you will not be able to change this value!'),
    '#default_value' => $page->name,
  );
  if (isset($page->pid) || empty($form_state['creating'])) {
    $form['name']['#disabled'] = TRUE;
    $form['name']['#value'] = $page->name;
  }
  $form['admin_description'] = array(
    '#type' => 'textarea',
    '#title' => t('Administrative description'),
    '#description' => t('A description of what this page is, does or is for, for administrative use.'),
    '#default_value' => $page->admin_description,
  );

  // Path.
  $form['path'] = array(
    '#type' => 'textfield',
    '#title' => t('Path'),
    '#description' => t('The URL path to get to this page. You may create named placeholders for variable parts of the path by using %name for required elements and !name for optional elements. For example: "node/%node/foo", "forum/%forum" or "dashboard/!input". These named placeholders can be turned into contexts on the arguments form.'),
    '#default_value' => $page->path,
    '#field_prefix' => url(NULL, array(
      'absolute' => TRUE,
    )) . (variable_get('clean_url', 0) ? '' : '?q='),
  );
  $frontpage = variable_get('site_frontpage', 'node');
  $path = array();
  if ($page->path) {
    foreach (explode('/', $page->path) as $bit) {
      if ($bit[0] != '!') {
        $path[] = $bit;
      }
    }
  }
  $path = implode('/', $path);
  if (empty($path) || $path != $frontpage) {
    $form['frontpage'] = array(
      '#type' => 'checkbox',
      '#default_value' => !empty($page->make_frontpage),
      '#title' => t('Make this your site home page.'),
      '#description' => t('To set this panel as your home page you must create a unique path name with no % placeholders in the path. The site home page is currently set to %homepage on the !siteinfo configuration form.', array(
        '!siteinfo' => l(t('Site Information'), 'admin/config/system/site-information'),
        '%homepage' => '/' . $frontpage,
      )),
    );
    $form['admin_paths'] = array(
      '#type' => 'checkbox',
      '#default_value' => !empty($page->conf['admin_paths']),
      '#title' => t('Use this page in an admin overlay.'),
      '#description' => t('Admin overlays are used in many places in Drupal 7 and administrative custom pages should probably utilize this feature.'),
    );
  }
  elseif ($path == $frontpage) {
    $form['frontpage_markup'] = array(
      '#value' => '<b>' . t('This page is currently set to be your site home page. This can be modified on the !siteinfo configuration form.', array(
        '!siteinfo' => l(t('Site Information'), 'admin/settings/site-information'),
      )) . '</b>',
    );
    $form['frontpage'] = array(
      '#type' => 'value',
      '#value' => TRUE,
    );
  }
  if (!isset($page->pid) && !empty($form_state['creating'])) {
    $features['default'] = array(
      'access' => t('Access control'),
      'menu' => t('Visible menu item'),
    );
    module_load_include('inc', 'page_manager', 'page_manager.admin');
    $form = page_manager_handler_add_form($form, $form_state, $features);
  }
  return $form;
}