Commit 7795cfa3 authored by gdd's avatar gdd

Merge remote-tracking branch 'core/8.x' into 8.x

parents 1cbbf747 5fbf8661
......@@ -225,7 +225,7 @@ PHP module
- ?
Poll module
- ?
- Andrei Mateescu 'amateescu' <http://drupal.org/user/729614>
RDF module
- Stéphane Corlosquet 'scor' <http://drupal.org/user/52142>
......
......@@ -2966,6 +2966,18 @@ function drupal_get_css($css = NULL, $skip_alter = FALSE) {
// Sort CSS items, so that they appear in the correct order.
uasort($css, 'drupal_sort_css_js');
// Provide the page with information about the individual CSS files used,
// information not otherwise available when CSS aggregation is enabled. The
// setting is attached later in this function, but is set here, so that CSS
// files removed below are still considered "used" and prevented from being
// added in a later AJAX request.
// Skip if no files were added to the page or jQuery.extend() will overwrite
// the Drupal.settings.ajaxPageState.css object with an empty array.
if (!empty($css)) {
// Cast the array to an object to be on the safe side even if not empty.
$setting['ajaxPageState']['css'] = (object) array_fill_keys(array_keys($css), 1);
}
// Remove the overridden CSS files. Later CSS files override former ones.
$previous_item = array();
foreach ($css as $key => $item) {
......@@ -2985,14 +2997,7 @@ function drupal_get_css($css = NULL, $skip_alter = FALSE) {
'#type' => 'styles',
'#items' => $css,
);
// Provide the page with information about the individual CSS files used,
// information not otherwise available when CSS aggregation is enabled.
// Skip if no files were added to the page or jQuery.extend() will overwrite
// the Drupal.settings.ajaxPageState.css object with an empty array.
// Cast the array to an object to be on the safe side even if not empty.
if (!empty($css)) {
$setting['ajaxPageState']['css'] = (object) array_fill_keys(array_keys($css), 1);
if (!empty($setting)) {
$styles['#attached']['js'][] = array('type' => 'setting', 'data' => $setting);
}
......
......@@ -1035,6 +1035,13 @@ function theme($hook, $variables = array()) {
if (isset($info['base hook'])) {
$base_hook = $info['base hook'];
$base_hook_info = $hooks[$base_hook];
// Include files required by the base hook, since its variable processors
// might reside there.
if (!empty($base_hook_info['includes'])) {
foreach ($base_hook_info['includes'] as $include_file) {
include_once DRUPAL_ROOT . '/' . $include_file;
}
}
if (isset($base_hook_info['preprocess functions']) || isset($base_hook_info['process functions'])) {
$variables['theme_hook_suggestion'] = $hook;
$hook = $base_hook;
......
......@@ -77,9 +77,11 @@ Drupal.behaviors.machineName = {
$source.bind('keyup.machineName change.machineName', function () {
machine = self.transliterate($(this).val(), options);
// Set the machine name to the transliterated value.
if (machine != options.replace && machine != '') {
$target.val(machine);
$preview.text(machine);
if (machine != '') {
if (machine != options.replace) {
$target.val(machine);
$preview.text(machine);
}
$suffix.show();
}
else {
......
......@@ -17,7 +17,8 @@ Drupal.tableSelect = function () {
var table = this, checkboxes, lastChecked;
var strings = { 'selectAll': Drupal.t('Select all rows in this table'), 'selectNone': Drupal.t('Deselect all rows in this table') };
var updateSelectAll = function (state) {
$('th.select-all input:checkbox', table).each(function () {
// Update table's select-all checkbox (and sticky header's if available).
$(table).prev('table.sticky-header').andSelf().find('th.select-all input:checkbox').each(function() {
$(this).attr('title', state ? strings.selectNone : strings.selectAll);
this.checked = state;
});
......
......@@ -691,16 +691,16 @@ function field_info_field_by_ids() {
*/
function field_info_instances($entity_type = NULL, $bundle_name = NULL) {
$info = _field_info_collate_fields();
if (!isset($entity_type)) {
return $info['instances'];
if (isset($entity_type) && isset($bundle_name)) {
return isset($info['instances'][$entity_type][$bundle_name]) ? $info['instances'][$entity_type][$bundle_name] : array();
}
if (!isset($bundle_name)) {
return $info['instances'][$entity_type];
elseif (isset($entity_type)) {
return isset($info['instances'][$entity_type]) ? $info['instances'][$entity_type] : array();
}
if (isset($info['instances'][$entity_type][$bundle_name])) {
return $info['instances'][$entity_type][$bundle_name];
else {
return $info['instances'];
}
return array();
}
/**
......
......@@ -454,8 +454,8 @@ class TextTranslationTestCase extends DrupalWebTestCase {
$langcode = LANGUAGE_NONE;
$body = $this->randomName();
$edit = array(
"title" => $this->randomName(),
"language" => 'en',
'title' => $this->randomName(),
'langcode' => 'en',
"body[$langcode][0][value]" => $body,
);
......@@ -487,7 +487,7 @@ class TextTranslationTestCase extends DrupalWebTestCase {
$title = $this->randomName();
$edit = array(
'title' => $title,
'language' => 'en',
'langcode' => 'en',
);
$this->drupalPost('node/add/article', $edit, t('Save'));
......
......@@ -1079,11 +1079,14 @@ class FieldInfoTestCase extends FieldTestCase {
}
// Verify that no unexpected instances exist.
$core_fields = field_info_fields();
$instances = field_info_instances('test_entity');
$expected = array('test_bundle' => array());
$this->assertIdentical($instances, $expected, "field_info_instances('test_entity') returns " . var_export($expected, TRUE) . '.');
$instances = field_info_instances('test_entity', 'test_bundle');
$this->assertTrue(empty($instances), t('With no instances, info bundles is empty.'));
$this->assertIdentical($instances, array(), "field_info_instances('test_entity', 'test_bundle') returns an empty array.");
// Create a field, verify it shows up.
$core_fields = field_info_fields();
$field = array(
'field_name' => drupal_strtolower($this->randomName()),
'type' => 'test_field',
......@@ -1119,6 +1122,25 @@ class FieldInfoTestCase extends FieldTestCase {
$instances = field_info_instances('test_entity', $instance['bundle']);
$this->assertEqual(count($instances), 1, t('One instance shows up in info when attached to a bundle.'));
$this->assertTrue($instance < $instances[$instance['field_name']], t('Instance appears in info correctly'));
// Test a valid entity type but an invalid bundle.
$instances = field_info_instances('test_entity', 'invalid_bundle');
$this->assertIdentical($instances, array(), "field_info_instances('test_entity', 'invalid_bundle') returns an empty array.");
// Test invalid entity type and bundle.
$instances = field_info_instances('invalid_entity', $instance['bundle']);
$this->assertIdentical($instances, array(), "field_info_instances('invalid_entity', 'test_bundle') returns an empty array.");
// Test invalid entity type, no bundle provided.
$instances = field_info_instances('invalid_entity');
$this->assertIdentical($instances, array(), "field_info_instances('invalid_entity') returns an empty array.");
// Test with an entity type that has no bundles.
$instances = field_info_instances('user');
$expected = array('user' => array());
$this->assertIdentical($instances, $expected, "field_info_instances('user') returns " . var_export($expected, TRUE) . '.');
$instances = field_info_instances('user', 'user');
$this->assertIdentical($instances, array(), "field_info_instances('user', 'user') returns an empty array.");
}
/**
......
......@@ -293,8 +293,8 @@ function theme_field_ui_table($variables) {
* The resulting form allows fields and pseudo-fields to be re-ordered.
*
* @see field_ui_menu()
* @see field_ui_overview_form_validate().
* @see field_ui_overview_form_submit().
* @see field_ui_field_overview_form_validate()
* @see field_ui_field_overview_form_submit()
* @ingroup forms
*/
function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle) {
......@@ -1744,7 +1744,7 @@ function field_ui_widget_type_form_submit($form, &$form_state) {
* hook_entity_info().
*
* @see field_ui_menu()
* @see field_ui_delete_form_submit()
* @see field_ui_field_delete_form_submit()
* @ingroup forms
*/
function field_ui_field_delete_form($form, &$form_state, $instance) {
......
......@@ -292,13 +292,13 @@ function locale_field_node_form_submit($form, &$form_state) {
foreach (field_info_instances('node', $bundle) as $instance) {
$field_name = $instance['field_name'];
$field = field_info_field($field_name);
$previous_language = $form[$field_name]['#language'];
$previous_langcode = $form[$field_name]['#language'];
// Handle a possible language change: new language values are inserted,
// previous ones are deleted.
if ($field['translatable'] && $previous_language != $node->language) {
$form_state['values'][$field_name][$node->language] = $node->{$field_name}[$previous_language];
$form_state['values'][$field_name][$previous_language] = array();
if ($field['translatable'] && $previous_langcode != $node->langcode) {
$form_state['values'][$field_name][$node->langcode] = $node->{$field_name}[$previous_langcode];
$form_state['values'][$field_name][$previous_langcode] = array();
}
}
}
......@@ -1085,15 +1085,15 @@ function locale_form_system_file_system_settings_alter(&$form, $form_state) {
* Implements MODULE_preprocess_HOOK().
*/
function locale_preprocess_node(&$variables) {
if ($variables['language'] != LANGUAGE_NONE) {
if ($variables['langcode'] != LANGUAGE_NONE) {
global $language_interface;
$node_language = language_load($variables['language']);
$node_language = language_load($variables['langcode']);
if ($node_language->langcode != $language_interface->langcode) {
// If the node language was different from the page language, we should
// add markup to identify the language. Otherwise the page language is
// inherited.
$variables['attributes_array']['lang'] = $variables['language'];
$variables['attributes_array']['lang'] = $variables['langcode'];
if ($node_language->direction != $language_interface->direction) {
// If text direction is different form the page's text direction, add
// direction information as well.
......
......@@ -2002,7 +2002,7 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase {
// Verify language selection appears on add "Basic page" form.
$this->drupalGet('node/add/page');
// Verify language select list is present.
$this->assertFieldByName('language', NULL, t('Language select present on add Basic page form.'));
$this->assertFieldByName('langcode', NULL, t('Language select present on add Basic page form.'));
// Ensure enabled language appears.
$this->assertText($name, t('Enabled language present.'));
// Ensure disabled language doesn't appear.
......@@ -2015,7 +2015,7 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase {
'type' => 'page',
'title' => $node_title,
'body' => array($langcode => array(array('value' => $node_body))),
'language' => $langcode,
'langcode' => $langcode,
);
$node = $this->drupalCreateNode($edit);
// Edit the content and ensure correct language is selected.
......@@ -2024,7 +2024,7 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase {
$this->assertRaw('<option value="' . $langcode . '" selected="selected">' . $name . '</option>', t('Correct language selected.'));
// Ensure we can change the node language.
$edit = array(
'language' => 'en',
'langcode' => 'en',
);
$this->drupalPost($path, $edit, t('Save'));
$this->assertRaw(t('%title has been updated.', array('%title' => $node_title)), t('Basic page content updated.'));
......@@ -2107,7 +2107,7 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase {
'type' => 'article',
'title' => $node_title,
'body' => array($langcode => array(array('value' => $node_body))),
'language' => $langcode,
'langcode' => $langcode,
'promote' => 1,
);
return $this->drupalCreateNode($edit);
......@@ -2575,7 +2575,7 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase {
$edit = array();
$edit[$title_key] = $title_value;
$edit[$body_key] = $body_value;
$edit['language'] = 'en';
$edit['langcode'] = 'en';
$this->drupalPost('node/add/page', $edit, t('Save'));
// Check that the node exists in the database.
......@@ -2589,7 +2589,7 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase {
$this->drupalGet("node/$node->nid/edit");
$edit = array(
$title_key => $this->randomName(8),
'language' => 'it'
'langcode' => 'it'
);
$this->drupalPost(NULL, $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($edit[$title_key]);
......@@ -2624,7 +2624,7 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase {
$edit = array();
$edit[$title_key] = $title_value;
$edit[$body_key] = $body_value;
$edit['language'] = 'en';
$edit['langcode'] = 'en';
$this->drupalPost('node/add/page', $edit, t('Save'));
// Check that the node exists in the database.
......@@ -2706,7 +2706,7 @@ class LocaleCommentLanguageFunctionalTest extends DrupalWebTestCase {
$edit = array(
"title" => $title,
"body[$langcode_none][0][value]" => $this->randomName(),
"language" => $node_langcode,
"langcode" => $node_langcode,
);
$this->drupalPost("node/add/article", $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($title);
......
......@@ -435,7 +435,7 @@ function node_admin_nodes() {
// Enable language column if translation module is enabled or if we have any
// node with language.
$multilanguage = (module_exists('translation') || db_query_range("SELECT 1 FROM {node} WHERE language <> :language", 0, 1, array(':language' => LANGUAGE_NONE))->fetchField());
$multilanguage = (module_exists('translation') || db_query_range("SELECT 1 FROM {node} WHERE langcode <> :langcode", 0, 1, array(':langcode' => LANGUAGE_NONE))->fetchField());
// Build the sortable table header.
$header = array(
......@@ -446,7 +446,7 @@ function node_admin_nodes() {
'changed' => array('data' => t('Updated'), 'field' => 'n.changed', 'sort' => 'desc')
);
if ($multilanguage) {
$header['language_name'] = array('data' => t('Language'), 'field' => 'n.language');
$header['language_name'] = array('data' => t('Language'), 'field' => 'n.langcode');
}
$header['operations'] = array('data' => t('Operations'));
......@@ -481,7 +481,7 @@ function node_admin_nodes() {
$destination = drupal_get_destination();
$options = array();
foreach ($nodes as $node) {
$l_options = $node->language != LANGUAGE_NONE && isset($languages[$node->language]) ? array('language' => $languages[$node->language]) : array();
$l_options = $node->langcode != LANGUAGE_NONE && isset($languages[$node->langcode]) ? array('language' => $languages[$node->langcode]) : array();
$options[$node->nid] = array(
'title' => array(
'data' => array(
......@@ -498,7 +498,7 @@ function node_admin_nodes() {
'changed' => format_date($node->changed, 'short'),
);
if ($multilanguage) {
$options[$node->nid]['language_name'] = language_name($node->language);
$options[$node->nid]['language_name'] = language_name($node->langcode);
}
// Build a list of all the accessible operations for the current node.
$operations = array();
......
......@@ -32,7 +32,7 @@ function node_schema() {
'not null' => TRUE,
'default' => '',
),
'language' => array(
'langcode' => array(
'description' => 'The {language}.langcode of this node.',
'type' => 'varchar',
'length' => 12,
......@@ -541,6 +541,20 @@ function node_update_8001() {
}
}
/**
* Rename node.language field to node.langcode.
*/
function node_update_8002() {
$spec = array(
'description' => 'The {language}.langcode of this node.',
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
);
db_change_field('node', 'language', 'langcode', $spec);
}
/**
* @} End of "addtogroup updates-7.x-to-8.x"
* The next series of updates should start at 9000.
......
......@@ -1340,7 +1340,7 @@ function node_view($node, $view_mode = 'full', $langcode = NULL) {
'#theme' => 'node',
'#node' => $node,
'#view_mode' => $view_mode,
'#language' => $langcode,
'#langcode' => $langcode,
);
// Add contextual links for this node, except when the node is already being
......@@ -1724,7 +1724,7 @@ function node_search_execute($keys = NULL, $conditions = NULL) {
// Insert special keywords.
$query->setOption('type', 'n.type');
$query->setOption('language', 'n.language');
$query->setOption('langcode', 'n.langcode');
if ($query->setOption('term', 'ti.tid')) {
$query->join('taxonomy_index', 'ti', 'n.nid = ti.nid');
}
......@@ -1764,7 +1764,7 @@ function node_search_execute($keys = NULL, $conditions = NULL) {
'extra' => $extra,
'score' => $item->calculated_score,
'snippet' => search_excerpt($keys, $node->rendered),
'language' => $node->language,
'langcode' => $node->langcode,
);
}
return $results;
......@@ -2848,10 +2848,8 @@ function node_form_search_form_alter(&$form, $form_state) {
// Languages:
$language_options = array();
foreach (language_list() as $key => $entity) {
if ($entity->enabled) {
$language_options[$key] = $entity->name;
}
foreach (language_list(TRUE) as $langcode => $language) {
$language_options[$langcode] = $language->name;
}
if (count($language_options) > 1) {
$form['advanced']['language'] = array(
......@@ -4204,9 +4202,9 @@ function node_file_download_access($field, $entity_type, $entity) {
* Implements hook_language_delete().
*/
function node_language_delete($language) {
// On nodes with this language, unset the language
// On nodes with this language, unset the language.
db_update('node')
->fields(array('language' => ''))
->condition('language', $language->langcode)
->fields(array('langcode' => ''))
->condition('langcode', $language->langcode)
->execute();
}
......@@ -87,7 +87,7 @@ function node_add($type) {
global $user;
$types = node_type_get_types();
$node = (object) array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => LANGUAGE_NONE);
$node = (object) array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'langcode' => LANGUAGE_NONE);
drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)), PASS_THROUGH);
$output = drupal_get_form($type . '_node_form', $node);
......@@ -153,7 +153,7 @@ function node_form($form, &$form_state, $node) {
// Basic node information.
// These elements are just values so they are not even sent to the client.
foreach (array('nid', 'vid', 'uid', 'created', 'type', 'language') as $key) {
foreach (array('nid', 'vid', 'uid', 'created', 'type') as $key) {
$form[$key] = array(
'#type' => 'value',
'#value' => isset($node->$key) ? $node->$key : NULL,
......@@ -187,20 +187,20 @@ function node_form($form, &$form_state, $node) {
foreach ($languages as $langcode => $language) {
$language_options[$langcode] = $language->name;
}
$form['language'] = array(
$form['langcode'] = array(
'#type' => 'select',
'#title' => t('Language'),
'#default_value' => (isset($node->language) ? $node->language : ''),
'#default_value' => (isset($node->langcode) ? $node->langcode : ''),
'#options' => $language_options,
'#empty_value' => LANGUAGE_NONE,
);
}
else {
$form['language'] = array(
$form['langcode'] = array(
'#type' => 'value',
// New nodes without multilingual support get the default language, old
// nodes keep their language if language.module is not available.
'#value' => !isset($form['#node']->nid) ? language_default()->langcode : $node->language,
'#value' => !isset($form['#node']->nid) ? language_default()->langcode : $node->langcode,
);
}
......@@ -358,7 +358,7 @@ function node_form($form, &$form_state, $node) {
}
$form += array('#submit' => array());
field_attach_form('node', $node, $form, $form_state, $node->language);
field_attach_form('node', $node, $form, $form_state, $node->langcode);
return $form;
}
......
......@@ -510,7 +510,7 @@ class NodeCreationTestCase extends DrupalWebTestCase {
'uid' => $this->loggedInUser->uid,
'name' => $this->loggedInUser->name,
'type' => 'page',
'language' => LANGUAGE_NONE,
'langcode' => LANGUAGE_NONE,
'title' => 'testing_transaction_exception',
);
......@@ -2190,7 +2190,7 @@ class NodeEntityFieldQueryAlter extends DrupalWebTestCase {
// Creating 4 nodes with an entity field so we can test that sort of query
// alter. All field values starts with 'A' so we can identify and fetch them
// in the node_access_test module.
$settings = array('language' => LANGUAGE_NONE);
$settings = array('langcode' => LANGUAGE_NONE);
for ($i = 0; $i < 4; $i++) {
$body = array(
'value' => 'A' . $this->randomName(32),
......@@ -2268,9 +2268,9 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase {
$tests['[node:type]'] = 'article';
$tests['[node:type-name]'] = 'Article';
$tests['[node:title]'] = check_plain($node->title);
$tests['[node:body]'] = _text_sanitize($instance, $node->language, $node->body[$node->language][0], 'value');
$tests['[node:summary]'] = _text_sanitize($instance, $node->language, $node->body[$node->language][0], 'summary');
$tests['[node:language]'] = check_plain($node->language);
$tests['[node:body]'] = _text_sanitize($instance, $node->langcode, $node->body[$node->langcode][0], 'value');
$tests['[node:summary]'] = _text_sanitize($instance, $node->langcode, $node->body[$node->langcode][0], 'summary');
$tests['[node:langcode]'] = check_plain($node->langcode);
$tests['[node:url]'] = url('node/' . $node->nid, $url_options);
$tests['[node:edit-url]'] = url('node/' . $node->nid . '/edit', $url_options);
$tests['[node:author]'] = check_plain(user_format_name($account));
......@@ -2289,9 +2289,9 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase {
// Generate and test unsanitized tokens.
$tests['[node:title]'] = $node->title;
$tests['[node:body]'] = $node->body[$node->language][0]['value'];
$tests['[node:summary]'] = $node->body[$node->language][0]['summary'];
$tests['[node:language]'] = $node->language;
$tests['[node:body]'] = $node->body[$node->langcode][0]['value'];
$tests['[node:summary]'] = $node->body[$node->langcode][0]['summary'];
$tests['[node:langcode]'] = $node->langcode;
$tests['[node:author:name]'] = user_format_name($account);
foreach ($tests as $input => $expected) {
......
......@@ -50,9 +50,9 @@ function node_token_info() {
'name' => t("Summary"),
'description' => t("The summary of the node's main body text."),
);
$node['language'] = array(
'name' => t("Language"),
'description' => t("The language the node is written in."),
$node['langcode'] = array(
'name' => t('Language code'),
'description' => t('The language code of the language the node is written in.'),
);
$node['url'] = array(
'name' => t("URL"),
......@@ -143,8 +143,8 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
}
break;
case 'language':
$replacements[$original] = $sanitize ? check_plain($node->language) : $node->language;
case 'langcode':
$replacements[$original] = $sanitize ? check_plain($node->langcode) : $node->langcode;
break;
case 'url':
......
......@@ -354,7 +354,7 @@ Drupal.overlay.isAdminLink = function (url) {
// Turn the list of administrative paths into a regular expression.
if (!this.adminPathRegExp) {
var regExpPrefix = '^' + Drupal.settings.pathPrefix + '(';
var regExpPrefix = '' + Drupal.settings.pathPrefix + '(';
var adminPaths = regExpPrefix + Drupal.settings.overlay.paths.admin.replace(/\s+/g, ')$|' + regExpPrefix) + ')$';
var nonAdminPaths = regExpPrefix + Drupal.settings.overlay.paths.non_admin.replace(/\s+/g, ')$|'+ regExpPrefix) + ')$';
adminPaths = adminPaths.replace(/\*/g, '.*');
......@@ -554,7 +554,7 @@ Drupal.overlay.eventhandlerOverrideLink = function (event) {
var target = $target[0];
var href = target.href;
// Only handle links that have an href attribute and use the http(s) protocol.
if (href != undefined && href != '' && target.protocol.match(/^https?\:/)) {
if (typeof href !== 'undefined' && href !== '' && (/^https?\:/).test(target.protocol)) {
var anchor = href.replace(target.ownerDocument.location.href, '');
// Skip anchor links.
if (anchor.length == 0 || anchor.charAt(0) == '#') {
......
......@@ -97,8 +97,8 @@ function path_form_node_form_alter(&$form, $form_state) {
$path = array();
if (!empty($form['#node']->nid)) {
$conditions = array('source' => 'node/' . $form['#node']->nid);
if ($form['#node']->language != LANGUAGE_NONE) {
$conditions['langcode'] = $form['#node']->language;
if ($form['#node']->langcode != LANGUAGE_NONE) {
$conditions['langcode'] = $form['#node']->langcode;
}
$path = path_load($conditions);
if ($path === FALSE) {
......@@ -109,7 +109,7 @@ function path_form_node_form_alter(&$form, $form_state) {
'pid' => NULL,
'source' => isset($form['#node']->nid) ? 'node/' . $form['#node']->nid : NULL,
'alias' => '',
'langcode' => isset($form['#node']->language) ? $form['#node']->language : LANGUAGE_NONE,
'langcode' => isset($form['#node']->langcode) ? $form['#node']->langcode : LANGUAGE_NONE,
);
$form['path'] = array(
......@@ -157,8 +157,8 @@ function path_form_element_validate($element, &$form_state, $complete_form) {
// originally assigned URL alias language.
// @todo Remove this after converting Path module to a field, and, after
// stopping Locale module from abusing the content language system.
if (isset($form_state['values']['language'])) {
form_set_value($element['langcode'], $form_state['values']['language'], $form_state);
if (isset($form_state['values']['langcode'])) {
form_set_value($element['langcode'], $form_state['values']['langcode'], $form_state);
}
$path = $form_state['values']['path'];
......@@ -189,7 +189,7 @@ function path_node_insert($node) {
if (!empty($path['alias'])) {
// Ensure fields for programmatic executions.
$path['source'] = 'node/' . $node->nid;
$path['langcode'] = isset($node->language) ? $node->language : LANGUAGE_NONE;
$path['langcode'] = isset($node->langcode) ? $node->langcode : LANGUAGE_NONE;
path_save($path);
}
}
......@@ -210,7 +210,7 @@ function path_node_update($node) {
if (!empty($path['alias'])) {
// Ensure fields for programmatic executions.
$path['source'] = 'node/' . $node->nid;
$path['langcode'] = isset($node->language) ? $node->language : LANGUAGE_NONE;
$path['langcode'] = isset($node->langcode) ? $node->langcode : LANGUAGE_NONE;
path_save($path);
}
}
......
......@@ -267,7 +267,7 @@ class PathLanguageTestCase extends DrupalWebTestCase {
// Edit the node to set language and path.
$edit = array();
$edit['language'] = 'en';
$edit['langcode'] = 'en';
$edit['path[alias]'] = $english_alias;
$this->drupalPost('node/' . $english_node->nid . '/edit', $edit, t('Save'));
......@@ -303,7 +303,7 @@ class PathLanguageTestCase extends DrupalWebTestCase {
drupal_static_reset('locale_url_outbound_alter');
drupal_static_reset('locale_language_url_rewrite_url');
$languages = language_list();
$url = url('node/' . $french_node->nid, array('language' => $languages[$french_node->language]));
$url = url('node/' . $french_node->nid, array('language' => $languages[$french_node->langcode]));
$this->assertTrue(strpos($url, $edit['path[alias]']), t('URL contains the path alias.'));
// Confirm that the alias works even when changing language negotiation
......@@ -353,17 +353,17 @@ class PathLanguageTestCase extends DrupalWebTestCase {
// drupal_lookup_path() has an internal static cache. Check to see that
// it has the appropriate contents at this point.
drupal_lookup_path('wipe');
$french_node_path = drupal_lookup_path('source', $french_alias, $french_node->language);
$french_node_path = drupal_lookup_path('source', $french_alias, $french_node->langcode);
$this->assertEqual($french_node_path, 'node/' . $french_node->nid, t('Normal path works.'));
// Second call should return the same path.
$french_node_path = drupal_lookup_path('source', $french_alias, $french_node->language);
$french_node_path = drupal_lookup_path('source', $french_alias, $french_node->langcode);
$this->assertEqual($french_node_path, 'node/' . $french_node->nid, t('Normal path is the same.'));
// Confirm that the alias works.
$french_node_alias = drupal_lookup_path('alias', 'node/' . $french_node->nid, $french_node->language);
$french_node_alias = drupal_lookup_path('alias', 'node/' . $french_node->nid, $french_node->langcode);
$this->assertEqual($french_node_alias, $french_alias, t('Alias works.'));
// Second call should return the same alias.
$french_node_alias = drupal_lookup_path('alias', 'node/' . $french_node->nid, $french_node->language);
$french_node_alias = drupal_lookup_path('alias', 'node/' . $french_node->nid, $french_node->langcode);
$this->assertEqual($french_node_alias, $french_alias, t('Alias is the same.'));
}
}
......
......@@ -853,7 +853,7 @@ class PollTranslateTestCase extends PollTestCase {
// Set the poll's first choice count to 200.
$edit['choice[chid:1][chvotes]'] = 200;
// Set the language to Dutch.
$edit['language'] = 'nl';
$edit['langcode'] = 'nl';
$this->drupalPost(NULL, $edit, t('Save'));
// Translate the Dutch poll.
......
......@@ -932,7 +932,7 @@ protected function drupalCreateNode($settings = array()) {
'sticky' => 0,
'type' => 'page',
'revisions' => NULL,
'language' => LANGUAGE_NONE,
'langcode' => LANGUAGE_NONE,
);
// Use the original node's created time for existing nodes.
......@@ -957,7 +957,7 @@ protected function drupalCreateNode($settings = array()) {
'value' => $this->randomName(32),
'format' => filter_default_format(),
);
$settings['body'][$settings['language']][0] += $body;
$settings['body'][$settings['langcode']][0] += $body;
$node = (object) $settings;
node_save($node);
......@@ -2083,6 +2083,8 @@ protected function drupalPostAJAX($path, $edit, $triggering_element, $ajax_path
// them.
$dom = new DOMDocument();
@$dom->loadHTML($content);
// XPath allows for finding wrapper nodes better than DOM does.