diff --git a/domain_path.module b/domain_path.module index cb9a3a8..3f8fc4e 100644 --- a/domain_path.module +++ b/domain_path.module @@ -147,7 +147,6 @@ function domain_path_paths($key = 'nid', $nid = NULL) { function domain_path_form_node_form_alter(&$form, $form_state) { // Custom setting for vertical tabs for domains. // This is in domain 7.x.3 but not 7.x.2. - if (isset($form['domain'])) { $form['domain']['#group'] = 'additional_settings'; } @@ -178,8 +177,12 @@ function domain_path_form_node_form_alter(&$form, $form_state) { '#title' => t('Delete domain-specific aliases'), '#default_value' => FALSE, ); + if (module_exists('pathauto')) { + $node = $form['#node']; + $aliases = domain_path_get_pathauto_alias(array_keys($domains), 'node', $node, $node->language); + } foreach ($domains as $domain_id => $domain) { - $default = ''; + $default = isset($aliases[$domain_id]) ? $aliases[$domain_id] : ''; // TODO: Only exposed checked domains? $form['domain_path'][$domain_id] = array( '#type' => 'textfield', @@ -341,3 +344,24 @@ function domain_path_field_extra_fields() { } return $extra; } + +function domain_path_get_pathauto_alias($domains, $entity_type, $entity, $langcode) { + list($id, , $bundle) = entity_extract_ids($entity_type, $entity); + $pattern = pathauto_pattern_load_by_entity($entity_type, $bundle, $langcode); + if (!$pattern) { + return; + } + $aliases = array(); + if (!isset($entity->path['pathauto'])) { + if (!empty($id)) { + module_load_include('inc', 'pathauto'); + $uri = entity_uri($entity_type, $entity); + $path = drupal_get_path_alias($uri['path'], $langcode); + foreach ($domains as $domain_id) { + $aliases[$domain_id] = pathauto_create_alias($entity_type, 'return', $uri['path'], array($entity_type => $entity), $bundle, $langcode); + } + } + } + return $aliases; +# dsm($pathauto_alias); +}