You are here

function path_redirect_form_alter in Path redirect 6

Same name and namespace in other branches
  1. 5 path_redirect.module \path_redirect_form_alter()

Implements hook_form_alter().

Add a summary of redirects pointing to a node on its edit form.

File

./path_redirect.module, line 199

Code

function path_redirect_form_alter(&$form, $form_state, $form_id) {
  if (substr($form_id, -10) == '_node_form' && !empty($form['#node']->nid)) {
    $redirect = array(
      'redirect' => 'node/' . $form['#node']->nid,
      'language' => $form['#node']->language,
    );
    $form['path_redirect'] = array(
      '#type' => 'fieldset',
      '#title' => t('URL redirects'),
      '#description' => t('The following are a list of URL redirects that point to this location.'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#access' => user_access('administer redirects'),
      '#weight' => 30,
      '#group' => 'additional_settings',
      '#attached' => array(
        'js' => array(
          'vertical-tabs' => drupal_get_path('module', 'path_redirect') . '/path_redirect.js',
        ),
      ),
    );
    module_load_include('inc', 'path_redirect', 'path_redirect.admin');
    $form['path_redirect']['table'] = path_redirect_list_redirects(array(), array(
      'redirect' => 'node/' . $form['#node']->nid,
    ));
    $form['path_redirect']['add'] = array(
      '#value' => path_redirect_local_actions($redirect),
    );
  }
}