You are here

function page_manager_page_form_argument 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_argument()

Form to handle assigning argument handlers to named arguments.

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_build_subtask in page_manager/plugins/tasks/page.inc
Build a subtask array for a given page.
page_manager_page_subtask_argument_ajax in page_manager/plugins/tasks/page.admin.inc
Ajax entry point to edit an item.

File

page_manager/plugins/tasks/page.admin.inc, line 860
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];
    }
    elseif (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' => array(
          "page-manager-context-{$keyword}-change-url",
        ),
      ),
      '#type' => 'hidden',
      '#value' => url("admin/structure/pages/argument/change/{$task_name}/{$keyword}", array(
        'absolute' => TRUE,
      )),
    );
    $form['table']['argument'][$keyword]['change'] = array(
      '#type' => 'submit',
      '#value' => t('Change'),
      '#attributes' => array(
        'class' => array(
          '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' => array(
            "page-manager-context-{$keyword}-settings-url",
          ),
        ),
        '#type' => 'hidden',
        '#value' => url("admin/structure/pages/argument/settings/{$task_name}/{$keyword}", array(
          'absolute' => TRUE,
        )),
      );
      $form['table']['argument'][$keyword]['settings'] = array(
        '#type' => 'submit',
        '#value' => t('Settings'),
        '#attributes' => array(
          'class' => array(
            'ctools-use-modal',
          ),
        ),
        '#id' => "page-manager-context-{$keyword}-settings",
      );
    }
  }
  return $form;
}