1 path.admin.inc path_bulk_update_form($form, &$form_state)

Form builder; Bulk URL alias update form.

See also

path_bulk_update_form_submit()

Related topics

File

core/modules/path/path.admin.inc, line 652
Admin page callbacks for the Path module.

Code

function path_bulk_update_form($form, &$form_state) {
  // Return a confirm form if submitting aliases to be deleted.
  if (isset($form_state['storage']['delete'])) {
    return path_admin_bulk_delete_confirm($form, $form_state);
  }

  $form['#update_callbacks'] = array();
  $form['#tree'] = TRUE;

  $all_path_info = path_get_info();

  $rows = array();

  foreach ($all_path_info as $type => $path_info) {
    if (!empty($path_info['batch update callback'])) {
      $form['update'][$type]['base'] = array(
        '#type' => 'checkbox',
        '#title' => t('!label URL aliases', array('!label' => $path_info['label'])),
        '#attributes' => array(
          'class' => array('path-base'),
          'data-path-type' => array($type),
          'data-path-name' => array('base'),
        ),
      );
      $form['#update_callbacks'][$type] = $path_info;
      // Check if this entity provides bundle types as pattern items and create
      // a row for each of these bundle types. For the Node entity the pattern
      // items would be keyed by be node types; for taxonomy, these would be
      // vocabularies.
      if (isset($path_info['pattern items'])) {
        foreach ($path_info['pattern items'] as $item => $item_label) {
          $form['update'][$type][$item] = array(
            '#type' => 'checkbox',
            '#title' => t('All !label URL aliases', array('!label' => $item)),
            '#attributes' => array(
              'class' => array('path-type', 'path-' . $type),
              'data-path-type' => array($type),
              'data-path-name' => array($item),
              '#parents' => array('update'),
            ),
          );
        }
      }
    }
  }

  // Build the 'Operations' form.
  $form['operations'] = array(
    '#type' => 'fieldset',
    '#title' => t('Operations'),
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
    '#attributes' => array(
      'class' => array('path-bulk-operations'),
    ),
  );
  $form['operations']['operation'] = array(
    '#type' => 'select',
    '#title' => 'Operations',
    '#title_display' => 'invisible',
    '#options' => array(
      'generate' => t('Generate URL aliases'),
      'update' => t('Update existing URL aliases'),
      'delete' => t('Delete URL aliases'),
    ),
    '#empty_option' => '- ' . t('Choose an action') . ' -',
  );
  $form['operations']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Execute'),
    '#submit' => array('path_bulk_update_form_rebuild_submit'),
    '#validate' => array('path_bulk_update_form_validate'),
  );

  return $form;
}