function domain_path_form_alter in Domain Path 6
Same name and namespace in other branches
- 8 domain_path.module \domain_path_form_alter()
Implements hook_form_alter().
File
- ./
domain_path.module, line 141 - Path alias handling for multiple domains.
Code
function domain_path_form_alter(&$form, $form_state, $form_id) {
// Apply to all node editing forms, but make sure we are not on the CCK field configuration form.
if ($form['#id'] != 'node-form' || isset($form['#node']->cck_dummy_node_form)) {
return;
}
cache_clear_all('domain_path', 'cache');
// This lets CCK adjust the weight of our element using domain_content_extra_fields().
$weight = module_exists('content') ? content_extra_field_weight($form['type']['#value'], 'domain_path') : 31;
$form['domain_path'] = array(
'#tree' => TRUE,
'#title' => t('Domain-specific paths'),
'#type' => 'fieldset',
'#weight' => $weight,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#access' => user_access('edit domain paths'),
);
$paths = array();
$domains = domain_domains();
$default_domain = domain_default();
$current = t('<none>');
if (!empty($form['#node']->nid)) {
$current = drupal_get_path_alias('node/' . $form['#node']->nid);
$paths = domain_path_paths('nid', $form['#node']->nid);
}
$form['domain_path']['current'] = array(
'#type' => 'item',
'#title' => t('Current alias'),
'#markup' => check_plain($current),
);
$form['domain_path']['domain_path_ignore'] = array(
'#type' => 'checkbox',
'#title' => t('Delete domain-specific aliases'),
'#default_value' => FALSE,
);
foreach ($domains as $domain_id => $domain) {
$default = '';
// TODO: Only exposed checked domains?
$form['domain_path'][$domain_id] = array(
'#type' => 'textfield',
'#title' => check_plain($domain['path']),
'#default_value' => isset($paths[$domain_id]) ? $paths[$domain_id] : $default,
'#access' => user_access('edit domain paths'),
);
}
}