You are here

function page_manager_page_form_argument in Chaos Tool Suite (ctools) 6

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

Form to handle assigning argument handlers to named arguments.

1 call to page_manager_page_form_argument()
page_manager_page_argument_finish in page_manager/plugins/tasks/page.admin.inc
Callback generated when the add page process is finished.
3 string references to 'page_manager_page_form_argument'
page_manager_page_add_subtask in page_manager/plugins/tasks/page.admin.inc
Page callback to add a subtask.
page_manager_page_argument_finish in page_manager/plugins/tasks/page.admin.inc
Callback generated when the add page process is finished.
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 856
Administrative functions for the page subtasks.

Code

function page_manager_page_form_argument(&$form, &$form_state) {
  $page =& $form_state['page']->subtask['subtask'];
  $path = $page->path;
  $arguments = page_manager_page_get_named_arguments($path);
  $form['table'] = array(
    '#theme' => 'page_manager_page_form_argument_table',
    '#page-manager-path' => $path,
    'argument' => array(),
  );
  $task_name = $form_state['page']->task_name;
  foreach ($arguments as $keyword => $position) {
    $conf = array();
    if (isset($page->temporary_arguments[$keyword]) && !empty($form_state['allow temp'])) {
      $conf = $page->temporary_arguments[$keyword];
    }
    else {
      if (isset($page->arguments[$keyword])) {
        $conf = $page->arguments[$keyword];
      }
    }
    $context = t('No context assigned');
    $plugin = array();
    if ($conf && isset($conf['name'])) {
      ctools_include('context');
      $plugin = ctools_get_argument($conf['name']);
      if (isset($plugin['title'])) {
        $context = $plugin['title'];
      }
    }
    $form['table']['argument'][$keyword]['#keyword'] = $keyword;
    $form['table']['argument'][$keyword]['#position'] = $position;
    $form['table']['argument'][$keyword]['#context'] = $context;

    // The URL for this ajax button
    $form['table']['argument'][$keyword]['change-url'] = array(
      '#attributes' => array(
        'class' => "page-manager-context-{$keyword}-change-url",
      ),
      '#type' => 'hidden',
      '#value' => url("admin/build/pages/argument/change/{$task_name}/{$keyword}", array(
        'absolute' => TRUE,
      )),
    );
    $form['table']['argument'][$keyword]['change'] = array(
      '#type' => 'submit',
      '#value' => t('Change'),
      '#attributes' => array(
        'class' => 'ctools-use-modal',
      ),
      '#id' => "page-manager-context-{$keyword}-change",
    );
    $form['table']['argument'][$keyword]['settings'] = array();

    // Only show the button if this has a settings form available:
    if (!empty($plugin)) {

      // The URL for this ajax button
      $form['table']['argument'][$keyword]['settings-url'] = array(
        '#attributes' => array(
          'class' => "page-manager-context-{$keyword}-settings-url",
        ),
        '#type' => 'hidden',
        '#value' => url("admin/build/pages/argument/settings/{$task_name}/{$keyword}", array(
          'absolute' => TRUE,
        )),
      );
      $form['table']['argument'][$keyword]['settings'] = array(
        '#type' => 'submit',
        '#value' => t('Settings'),
        '#attributes' => array(
          'class' => 'ctools-use-modal',
        ),
        '#id' => "page-manager-context-{$keyword}-settings",
      );
    }
  }
}