Commit 0baad49d authored by Dries's avatar Dries

- Patch #635094 by plach: unify 'language neutral' language codes.

parent ef451365
......@@ -178,6 +178,13 @@
*/
define('DRUPAL_KILOBYTE', 1024);
/**
* The language code used when no language is explicitly assigned.
*
* Defined by ISO639-2 for "No linguistic content / Not applicable".
*/
define('LANGUAGE_NONE', 'zxx');
/**
* The type of language used to define the content language.
*/
......
......@@ -380,7 +380,7 @@ function language_fallback_get_candidates($type = LANGUAGE_TYPE_CONTENT) {
}
$fallback_candidates = array_keys($fallback_candidates);
$fallback_candidates[] = FIELD_LANGUAGE_NONE;
$fallback_candidates[] = LANGUAGE_NONE;
// Let other modules hook in and add/change candidates.
drupal_alter('language_fallback_candidates', $fallback_candidates);
......
......@@ -43,7 +43,7 @@ function drupal_path_initialize() {
* Either a Drupal system path, an aliased path, or FALSE if no path was
* found.
*/
function drupal_lookup_path($action, $path = '', $path_language = '') {
function drupal_lookup_path($action, $path = '', $path_language = NULL) {
global $language;
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static = array();
......@@ -90,9 +90,10 @@ function drupal_lookup_path($action, $path = '', $path_language = '') {
// Now fetch the aliases corresponding to these system paths.
// We order by ASC and overwrite array keys to ensure the correct
// alias is used when there are multiple aliases per path.
$cache['map'][$path_language] = db_query("SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND language IN (:language, '') ORDER BY language ASC, pid ASC", array(
$cache['map'][$path_language] = db_query("SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND language IN (:language, :language_none) ORDER BY language ASC, pid ASC", array(
':system' => $cache['system_paths'],
':language' => $path_language
':language' => $path_language,
':language_none' => LANGUAGE_NONE,
))->fetchAllKeyed();
// Keep a record of paths with no alias to avoid querying twice.
$cache['no_aliases'][$path_language] = array_flip(array_diff_key($cache['system_paths'], array_keys($cache['map'][$path_language])));
......@@ -111,9 +112,10 @@ function drupal_lookup_path($action, $path = '', $path_language = '') {
// For system paths which were not cached, query aliases individually.
else if (!isset($cache['no_aliases'][$path_language][$path])) {
// Get the most fitting result falling back with alias without language
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND language IN (:language, '') ORDER BY language DESC, pid DESC", array(
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", array(
':source' => $path,
':language' => $path_language
':language' => $path_language,
':language_none' => LANGUAGE_NONE,
))->fetchField();
$cache['map'][$path_language][$path] = $alias;
return $alias;
......@@ -126,9 +128,10 @@ function drupal_lookup_path($action, $path = '', $path_language = '') {
$source = '';
if (!isset($cache['map'][$path_language]) || !($source = array_search($path, $cache['map'][$path_language]))) {
// Get the most fitting result falling back with alias without language
if ($source = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language IN (:language, '') ORDER BY language DESC, pid DESC", array(
if ($source = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", array(
':alias' => $path,
':language' => $path_language))
':language' => $path_language,
':language_none' => LANGUAGE_NONE))
->fetchField()) {
$cache['map'][$path_language][$source] = $path;
}
......@@ -186,7 +189,7 @@ function drupal_cache_system_paths() {
* An aliased path if one was found, or the original path if no alias was
* found.
*/
function drupal_get_path_alias($path = NULL, $path_language = '') {
function drupal_get_path_alias($path = NULL, $path_language = NULL) {
// If no path is specified, use the current page's path.
if ($path == NULL) {
$path = $_GET['q'];
......@@ -210,7 +213,7 @@ function drupal_get_path_alias($path = NULL, $path_language = '') {
* The internal path represented by the alias, or the original alias if no
* internal path was found.
*/
function drupal_get_normal_path($path, $path_language = '') {
function drupal_get_normal_path($path, $path_language = NULL) {
$original_path = $path;
// Lookup the path alias first.
......@@ -445,7 +448,7 @@ function path_load($conditions) {
* - language: (optional) The language of the alias.
*/
function path_save(&$path) {
$path += array('pid' => NULL, 'language' => '');
$path += array('pid' => NULL, 'language' => LANGUAGE_NONE);
// Insert or update the alias.
$status = drupal_write_record('url_alias', $path, (!empty($path['pid']) ? 'pid' : NULL));
......
......@@ -249,7 +249,7 @@ EOF;
}
function createSampleNodes() {
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
// Post 5 articles.
for ($i = 0; $i < 5; $i++) {
$edit = array();
......
......@@ -138,20 +138,20 @@ class BlogTestCase extends DrupalWebTestCase {
// View blog node.
$this->drupalGet('node/' . $node->nid);
$this->assertResponse(200);
$this->assertTitle($node->title[FIELD_LANGUAGE_NONE][0]['value'] . ' | Drupal', t('Blog node was displayed'));
$this->assertTitle($node->title[LANGUAGE_NONE][0]['value'] . ' | Drupal', t('Blog node was displayed'));
$this->assertText(t('Home ' . $crumb . ' Blogs ' . $crumb . ' @name' . $quote . 's blog', array('@name' => format_username($node_user))), t('Breadcrumbs were displayed'));
// View blog edit node.
$this->drupalGet('node/' . $node->nid . '/edit');
$this->assertResponse($response);
if ($response == 200) {
$this->assertTitle('Edit Blog entry ' . $node->title[FIELD_LANGUAGE_NONE][0]['value'] . ' | Drupal', t('Blog edit node was displayed'));
$this->assertTitle('Edit Blog entry ' . $node->title[LANGUAGE_NONE][0]['value'] . ' | Drupal', t('Blog edit node was displayed'));
}
if ($response == 200) {
// Edit blog node.
$edit = array();
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = 'node/' . $node->nid;
$edit["body[$langcode][0][value]"] = $this->randomName(256);
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
......
......@@ -72,7 +72,7 @@ function book_admin_settings_validate($form, &$form_state) {
* @ingroup forms.
*/
function book_admin_edit($form, $form_state, $node) {
drupal_set_title($node->title[FIELD_LANGUAGE_NONE][0]['value']);
drupal_set_title($node->title[LANGUAGE_NONE][0]['value']);
$form['#node'] = $node;
_book_admin_table($node, $form);
$form['save'] = array(
......@@ -125,7 +125,7 @@ function book_admin_edit_submit($form, &$form_state) {
// Update the title if changed.
if ($row['title']['#default_value'] != $values['title']) {
$node = node_load($values['nid'], FALSE);
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
$node->title = array($langcode => array(array('value' => $values['title'])));
$node->book['link_title'] = $values['title'];
$node->revision = 1;
......
......@@ -501,7 +501,7 @@ function _book_add_form_elements(&$form, &$form_state, $node) {
if (isset($node->nid) && ($nid == $node->book['original_bid']) && ($node->book['parent_depth_limit'] == 0)) {
// This is the top level node in a maximum depth book and thus cannot be moved.
$options[$node->nid] = $node->title[FIELD_LANGUAGE_NONE][0]['value'];
$options[$node->nid] = $node->title[LANGUAGE_NONE][0]['value'];
}
else {
foreach (book_get_books() as $book) {
......@@ -550,7 +550,7 @@ function _book_update_outline($node) {
$new = empty($node->book['mlid']);
$node->book['link_path'] = 'node/' . $node->nid;
$node->book['link_title'] = $node->title[FIELD_LANGUAGE_NONE][0]['value'];
$node->book['link_title'] = $node->title[LANGUAGE_NONE][0]['value'];
$node->book['parent_mismatch'] = FALSE; // The normal case.
if ($node->book['bid'] == $node->nid) {
......@@ -906,7 +906,7 @@ function book_form_node_delete_confirm_alter(&$form, $form_state) {
if (isset($node->book) && $node->book['has_children']) {
$form['book_warning'] = array(
'#markup' => '<p>' . t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', array('%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value'])) . '</p>',
'#markup' => '<p>' . t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', array('%title' => $node->title[LANGUAGE_NONE][0]['value'])) . '</p>',
'#weight' => -10,
);
}
......@@ -1129,7 +1129,7 @@ function book_node_export($node, $children = '') {
*/
function template_preprocess_book_node_export_html(&$variables) {
$variables['depth'] = $variables['node']->book['depth'];
$variables['title'] = check_plain($variables['node']->title[FIELD_LANGUAGE_NONE][0]['value']);
$variables['title'] = check_plain($variables['node']->title[LANGUAGE_NONE][0]['value']);
$variables['content'] = $variables['node']->rendered;
}
......
......@@ -79,7 +79,7 @@ function book_export_html($nid) {
$contents = book_export_traverse($tree, 'book_node_export');
}
return theme('book_export_html', array('title' => $node->title[FIELD_LANGUAGE_NONE][0]['value'], 'contents' => $contents, 'depth' => $node->book['depth']));
return theme('book_export_html', array('title' => $node->title[LANGUAGE_NONE][0]['value'], 'contents' => $contents, 'depth' => $node->book['depth']));
}
else {
drupal_access_denied();
......@@ -90,7 +90,7 @@ function book_export_html($nid) {
* Menu callback; show the outline form for a single node.
*/
function book_outline($node) {
drupal_set_title($node->title[FIELD_LANGUAGE_NONE][0]['value']);
drupal_set_title($node->title[LANGUAGE_NONE][0]['value']);
return drupal_get_form('book_outline_form', $node);
}
......@@ -188,7 +188,7 @@ function book_outline_form_submit($form, &$form_state) {
*/
function book_remove_form($form, &$form_state, $node) {
$form['#node'] = $node;
$title = array('%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']);
$title = array('%title' => $node->title[LANGUAGE_NONE][0]['value']);
if ($node->book['has_children']) {
$description = t('%title has associated child pages, which will be relocated automatically to maintain their connection to the book. To recreate the hierarchy (as it was before removing this page), %title may be added again using the Outline tab, and each of its former child pages will need to be relocated manually.', $title);
......
......@@ -110,7 +110,7 @@ class BookTestCase extends DrupalWebTestCase {
// Check previous, up, and next links.
if ($previous) {
$this->assertRaw(l('‹ ' . $previous->title[FIELD_LANGUAGE_NONE][0]['value'], 'node/' . $previous->nid, array('attributes' => array('class' => array('page-previous'), 'title' => t('Go to previous page')))), t('Previous page link found.'));
$this->assertRaw(l('‹ ' . $previous->title[LANGUAGE_NONE][0]['value'], 'node/' . $previous->nid, array('attributes' => array('class' => array('page-previous'), 'title' => t('Go to previous page')))), t('Previous page link found.'));
}
if ($up) {
......@@ -118,7 +118,7 @@ class BookTestCase extends DrupalWebTestCase {
}
if ($next) {
$this->assertRaw(l($next->title[FIELD_LANGUAGE_NONE][0]['value'] . ' ›', 'node/' . $next->nid, array('attributes' => array('class' => array('page-next'), 'title' => t('Go to next page')))), t('Next page link found.'));
$this->assertRaw(l($next->title[LANGUAGE_NONE][0]['value'] . ' ›', 'node/' . $next->nid, array('attributes' => array('class' => array('page-next'), 'title' => t('Go to next page')))), t('Next page link found.'));
}
// Compute the expected breadcrumb.
......@@ -140,8 +140,8 @@ class BookTestCase extends DrupalWebTestCase {
// Check printer friendly version.
$this->drupalGet('book/export/html/' . $node->nid);
$this->assertText($node->title[FIELD_LANGUAGE_NONE][0]['value'], t('Printer friendly title found.'));
$this->assertRaw(check_markup($node->body[FIELD_LANGUAGE_NONE][0]['value'], $node->body[FIELD_LANGUAGE_NONE][0]['format']), t('Printer friendly body found.'));
$this->assertText($node->title[LANGUAGE_NONE][0]['value'], t('Printer friendly title found.'));
$this->assertRaw(check_markup($node->body[LANGUAGE_NONE][0]['value'], $node->body[LANGUAGE_NONE][0]['format']), t('Printer friendly body found.'));
$number++;
}
......@@ -154,7 +154,7 @@ class BookTestCase extends DrupalWebTestCase {
function generateOutlinePattern($nodes) {
$outline = '';
foreach ($nodes as $node) {
$outline .= '(node\/' . $node->nid . ')(.*?)(' . $node->title[FIELD_LANGUAGE_NONE][0]['value'] . ')(.*?)';
$outline .= '(node\/' . $node->nid . ')(.*?)(' . $node->title[LANGUAGE_NONE][0]['value'] . ')(.*?)';
}
return '/<div id="book-navigation-' . $this->book->nid . '"(.*?)<ul(.*?)' . $outline . '<\/ul>/s';
......@@ -172,7 +172,7 @@ class BookTestCase extends DrupalWebTestCase {
static $number = 0; // Used to ensure that when sorted nodes stay in same order.
$edit = array();
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = $number . ' - SimpleTest test node ' . $this->randomName(10);
$edit["body[$langcode][0][value]"] = 'SimpleTest test body ' . $this->randomName(32) . ' ' . $this->randomName(32);
$edit['book[bid]'] = $book_nid;
......
......@@ -1672,7 +1672,7 @@ function comment_form($form, &$form_state, $comment) {
'comment' => '',
'cid' => NULL,
'pid' => NULL,
'language' => '',
'language' => LANGUAGE_NONE,
'uid' => 0,
);
$comment = (object) $comment;
......
......@@ -29,7 +29,7 @@
*/
function comment_reply($node, $pid = NULL) {
// Set the breadcrumb trail.
drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->title[FIELD_LANGUAGE_NONE][0]['value'], 'node/' . $node->nid)));
drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->title[LANGUAGE_NONE][0]['value'], 'node/' . $node->nid)));
$op = isset($_POST['op']) ? $_POST['op'] : '';
$build = array();
......
......@@ -209,7 +209,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
case 'node':
$node = node_load($comment->nid);
$title = $node->title[FIELD_LANGUAGE_NONE][0]['value'];
$title = $node->title[LANGUAGE_NONE][0]['value'];
$replacements[$original] = $sanitize ? filter_xss($title) : $title;
break;
}
......
......@@ -266,7 +266,7 @@ class DBLogTestCase extends DrupalWebTestCase {
// Create node using form to generate add content event (which is not triggered by drupalCreateNode).
$edit = $this->getContent($type);
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
$title = $edit["title[$langcode][0][value]"];
$this->drupalPost('node/add/' . $type, $edit, t('Save'));
$this->assertResponse(200);
......@@ -321,7 +321,7 @@ class DBLogTestCase extends DrupalWebTestCase {
* @return array Content.
*/
private function getContent($type) {
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
switch ($type) {
case 'poll':
$content = array(
......@@ -357,7 +357,7 @@ class DBLogTestCase extends DrupalWebTestCase {
break;
default:
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
$content = array(
"body[$langcode][0][value]" => $this->randomName(32),
);
......
......@@ -1360,7 +1360,7 @@ function hook_field_storage_pre_insert($obj_type, $object, &$skip_fields) {
foreach ($language as $delta) {
$query->values(array(
'nid' => $object->nid,
'title' => $object->title[FIELD_LANGUAGE_NONE][0]['value'],
'title' => $object->title[LANGUAGE_NONE][0]['value'],
'tid' => $delta['value'],
'sticky' => $object->sticky,
'created' => $object->created,
......
......@@ -69,13 +69,6 @@
*/
define('FIELD_CARDINALITY_UNLIMITED', -1);
/**
* The language code assigned to untranslatable fields.
*
* Defined by ISO639-2 for "No linguistic content / Not applicable".
*/
define('FIELD_LANGUAGE_NONE', 'zxx');
/**
* TODO
*/
......
......@@ -18,7 +18,7 @@ function field_multilingual_settings_changed() {
*
* If an entity has a translation handler and the given field is translatable,
* a (not necessarily strict) subset of the current enabled languages will be
* returned, otherwise only FIELD_LANGUAGE_NONE will be returned. Since the
* returned, otherwise only LANGUAGE_NONE will be returned. Since the
* default value for a 'translatable' entity property is FALSE, we ensure that
* only entities that are able to handle translations actually get translatable
* fields.
......@@ -58,7 +58,7 @@ function field_multilingual_available_languages($obj_type, $field, $suggested_la
}
}
else {
$result = $field_languages[$field_name] = array(FIELD_LANGUAGE_NONE);
$result = $field_languages[$field_name] = array(LANGUAGE_NONE);
}
}
else {
......@@ -71,13 +71,13 @@ function field_multilingual_available_languages($obj_type, $field, $suggested_la
/**
* Return available content languages.
*
* The languages that may be associated to fields include FIELD_LANGAUGE_NONE.
* The languages that may be associated to fields include LANGUAGE_NONE.
*
* @return
* An array of language codes.
*/
function field_multilingual_content_languages() {
return array_keys(language_list() + array(FIELD_LANGUAGE_NONE => NULL));
return array_keys(language_list() + array(LANGUAGE_NONE => NULL));
}
/**
......@@ -132,12 +132,6 @@ function field_multilingual_valid_language($langcode, $default = TRUE) {
if (in_array($langcode, $enabled_languages)) {
return $langcode;
}
// @todo Currently, node language neutral code is an empty string. Node passes
// $node->language as language parameter to field_attach_form(). We might
// want to unify the two "language neutral" language codes.
if ($langcode === '') {
return FIELD_LANGUAGE_NONE;
}
global $language;
$langcode = $default ? language_default('language') : $language->language;
if (in_array($langcode, $enabled_languages)) {
......
......@@ -57,7 +57,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
function testFieldAttachLoad() {
$entity_type = 'test_entity';
$eid = 0;
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
$etid = _field_sql_storage_etid($entity_type);
$columns = array('etid', 'entity_id', 'revision_id', 'delta', 'language', $this->field_name . '_value');
......@@ -126,7 +126,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
function testFieldAttachInsertAndUpdate() {
$entity_type = 'test_entity';
$entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']);
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
// Test insert.
$values = array();
......@@ -207,7 +207,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
function testFieldAttachSaveMissingData() {
$entity_type = 'test_entity';
$entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']);
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
// Insert: Field is missing
field_attach_insert($entity_type, $entity);
......@@ -306,7 +306,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
$instance = array('field_name' => 'decimal52', 'object_type' => 'test_entity', 'bundle' => 'test_bundle');
$instance = field_create_instance($instance);
$entity = field_test_create_stub_entity(0, 0, $instance['bundle']);
$entity->decimal52[FIELD_LANGUAGE_NONE][0]['value'] = '1.235';
$entity->decimal52[LANGUAGE_NONE][0]['value'] = '1.235';
field_attach_insert('test_entity', $entity);
// Attempt to update the field in a way that would work without data.
......@@ -344,7 +344,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
// Add data so the table cannot be dropped.
$entity = field_test_create_stub_entity(0, 0, $instance['bundle']);
$entity->{$field_name}[FIELD_LANGUAGE_NONE][0]['value'] = 'field data';
$entity->{$field_name}[LANGUAGE_NONE][0]['value'] = 'field data';
field_attach_insert('test_entity', $entity);
// Add an index
......@@ -367,7 +367,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
// Verify that the tables were not dropped.
$entity = field_test_create_stub_entity(0, 0, $instance['bundle']);
field_attach_load('test_entity', array(0 => $entity));
$this->assertEqual($entity->{$field_name}[FIELD_LANGUAGE_NONE][0]['value'], 'field data', t("Index changes performed without dropping the tables"));
$this->assertEqual($entity->{$field_name}[LANGUAGE_NONE][0]['value'], 'field data', t("Index changes performed without dropping the tables"));
}
}
......
......@@ -42,28 +42,28 @@ class ListFieldTestCase extends DrupalWebTestCase {
// All three options appear.
$entity = field_test_create_stub_entity();
$form = drupal_get_form('field_test_entity_form', $entity);
$this->assertTrue(!empty($form['card_1'][FIELD_LANGUAGE_NONE][1]), t('Option 1 exists'));
$this->assertTrue(!empty($form['card_1'][FIELD_LANGUAGE_NONE][2]), t('Option 2 exists'));
$this->assertTrue(!empty($form['card_1'][FIELD_LANGUAGE_NONE][3]), t('Option 3 exists'));
$this->assertTrue(!empty($form['card_1'][LANGUAGE_NONE][1]), t('Option 1 exists'));
$this->assertTrue(!empty($form['card_1'][LANGUAGE_NONE][2]), t('Option 2 exists'));
$this->assertTrue(!empty($form['card_1'][LANGUAGE_NONE][3]), t('Option 3 exists'));
// Removed options do not appear.
$this->card_1['settings']['allowed_values'] = "2|Two";
field_update_field($this->card_1);
$entity = field_test_create_stub_entity();
$form = drupal_get_form('field_test_entity_form', $entity);
$this->assertTrue(empty($form['card_1'][FIELD_LANGUAGE_NONE][1]), t('Option 1 does not exist'));
$this->assertTrue(!empty($form['card_1'][FIELD_LANGUAGE_NONE][2]), t('Option 2 exists'));
$this->assertTrue(empty($form['card_1'][FIELD_LANGUAGE_NONE][3]), t('Option 3 does not exist'));
$this->assertTrue(empty($form['card_1'][LANGUAGE_NONE][1]), t('Option 1 does not exist'));
$this->assertTrue(!empty($form['card_1'][LANGUAGE_NONE][2]), t('Option 2 exists'));
$this->assertTrue(empty($form['card_1'][LANGUAGE_NONE][3]), t('Option 3 does not exist'));
// Completely new options appear.
$this->card_1['settings']['allowed_values'] = "10|Update\n20|Twenty";
field_update_field($this->card_1);
$form = drupal_get_form('field_test_entity_form', $entity);
$this->assertTrue(empty($form['card_1'][FIELD_LANGUAGE_NONE][1]), t('Option 1 does not exist'));
$this->assertTrue(empty($form['card_1'][FIELD_LANGUAGE_NONE][2]), t('Option 2 does not exist'));
$this->assertTrue(empty($form['card_1'][FIELD_LANGUAGE_NONE][3]), t('Option 3 does not exist'));
$this->assertTrue(!empty($form['card_1'][FIELD_LANGUAGE_NONE][10]), t('Option 10 exists'));
$this->assertTrue(!empty($form['card_1'][FIELD_LANGUAGE_NONE][20]), t('Option 20 exists'));
$this->assertTrue(empty($form['card_1'][LANGUAGE_NONE][1]), t('Option 1 does not exist'));
$this->assertTrue(empty($form['card_1'][LANGUAGE_NONE][2]), t('Option 2 does not exist'));
$this->assertTrue(empty($form['card_1'][LANGUAGE_NONE][3]), t('Option 3 does not exist'));
$this->assertTrue(!empty($form['card_1'][LANGUAGE_NONE][10]), t('Option 10 exists'));
$this->assertTrue(!empty($form['card_1'][LANGUAGE_NONE][20]), t('Option 20 exists'));
// Options are reset when a new field with the same name is created.
field_delete_field($this->card_1['field_name']);
......@@ -81,9 +81,9 @@ class ListFieldTestCase extends DrupalWebTestCase {
$this->instance_1 = field_create_instance($this->instance_1);
$entity = field_test_create_stub_entity();
$form = drupal_get_form('field_test_entity_form', $entity);
$this->assertTrue(!empty($form['card_1'][FIELD_LANGUAGE_NONE][1]), t('Option 1 exists'));
$this->assertTrue(!empty($form['card_1'][FIELD_LANGUAGE_NONE][2]), t('Option 2 exists'));
$this->assertTrue(!empty($form['card_1'][FIELD_LANGUAGE_NONE][3]), t('Option 3 exists'));
$this->assertTrue(!empty($form['card_1'][LANGUAGE_NONE][1]), t('Option 1 exists'));
$this->assertTrue(!empty($form['card_1'][LANGUAGE_NONE][2]), t('Option 2 exists'));
$this->assertTrue(!empty($form['card_1'][LANGUAGE_NONE][3]), t('Option 3 exists'));
}
}
......
......@@ -68,7 +68,7 @@ class OptionsWidgetsTestCase extends DrupalWebTestCase {
),
);
$instance = field_create_instance($instance);
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
// Create an entity.
$entity_init = field_test_create_stub_entity();
......@@ -124,7 +124,7 @@ class OptionsWidgetsTestCase extends DrupalWebTestCase {
),
);
$instance = field_create_instance($instance);
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
// Create an entity.
$entity_init = field_test_create_stub_entity();
......@@ -210,7 +210,7 @@ class OptionsWidgetsTestCase extends DrupalWebTestCase {
),
);
$instance = field_create_instance($instance);
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
// Create an entity.
$entity_init = field_test_create_stub_entity();
......@@ -264,7 +264,7 @@ class OptionsWidgetsTestCase extends DrupalWebTestCase {
),
);
$instance = field_create_instance($instance);
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
// Create an entity.
$entity_init = field_test_create_stub_entity();
......@@ -347,7 +347,7 @@ class OptionsWidgetsTestCase extends DrupalWebTestCase {
),
);
$instance = field_create_instance($instance);
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
// Create an entity.
$entity_init = field_test_create_stub_entity();
......
......@@ -54,7 +54,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
field_create_instance($this->instance);
// Test valid and invalid values with field_attach_validate().
$entity = field_test_create_stub_entity();
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
for ($i = 0; $i <= $max_length + 2; $i++) {
$entity->{$this->field['field_name']}[$langcode][0]['value'] = str_repeat('x', $i);
try {
......@@ -97,7 +97,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
)
);
field_create_instance($this->instance);
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
// Display creation form.
$this->drupalGet('test-entity/add/test-bundle');
......@@ -151,7 +151,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
)
);
field_create_instance($this->instance);
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
// Delete all text formats besides the plain text fallback format.
$this->drupalLogin($this->admin_user);
......
This diff is collapsed.
......@@ -1211,7 +1211,7 @@ function field_ui_default_value_widget($field, $instance, &$form, &$form_state)
$instance['required'] = FALSE;
$instance['description'] = '';
// @todo Allow multiple values (requires more work on 'add more' JS handler).
$element += field_default_form(NULL, NULL, $field, $instance, FIELD_LANGUAGE_NONE, $items, $form, $form_state, 0);
$element += field_default_form(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $form, $form_state, 0);
// Adjust 'form_path' to reflect the actual location of the widget in the
// form structure.
......@@ -1233,16 +1233,16 @@ function field_ui_field_edit_form_validate($form, &$form_state) {
// Extract field values.
$items = array();
$form_state_copy = array('values' => $instance['default_value_widget']);
field_default_extract_form_values(NULL, NULL, $field, $instance, FIELD_LANGUAGE_NONE, $items, $form, $form_state_copy);
field_default_extract_form_values(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $form, $form_state_copy);
// Validate the values and report errors.
$errors = array();
$function = $field['module'] . '_field_validate';
if (function_exists($function)) {
$function(NULL, NULL, $field, $instance, FIELD_LANGUAGE_NONE, $items, $errors);
$function(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $errors);
}
if ($errors) {
field_default_form_errors(NULL, NULL, $field, $instance, FIELD_LANGUAGE_NONE, $items, $form, $errors);
field_default_form_errors(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $form, $errors);
}
}
}
......@@ -1264,10 +1264,10 @@ function field_ui_field_edit_form_submit($form, &$form_state) {
// Extract field values.
$items = array();
$form_state_copy = array('values' => $instance['default_value_widget']);
field_default_extract_form_values(NULL, NULL, $field, $instance, FIELD_LANGUAGE_NONE, $items, $form, $form_state_copy);
field_default_extract_form_values(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $form, $form_state_copy);
// Prepare field values.
field_default_submit(NULL, NULL, $field, $instance, FIELD_LANGUAGE_NONE, $items, $form, $form_state_copy);
field_default_submit(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $form, $form_state_copy);
$instance['default_value'] = $items ? $items : NULL;
unset($instance['default_value_widget']);
......
......@@ -234,7 +234,7 @@ class FieldUITestCase extends DrupalWebTestCase {
);
field_create_instance($instance);
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
$admin_path = 'admin/structure/types/manage/' . $this->hyphen_type . '/fields/' . $field_name;
$element_id = "edit-instance-default-value-widget-$field_name-$langcode-0-value";
$element_name = "instance[default_value_widget][$field_name][$langcode][0][value]";
......
This diff is collapsed.
......@@ -319,7 +319,7 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$text = $body . '<random>' . $extra_text . '</random>';
$edit = array();
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = $this->randomName();
$edit["body[$langcode][0][value]"] = $text;
$edit["body[$langcode][0][value_format]"] = $filtered;
......
......@@ -431,7 +431,7 @@ function forum_field_storage_pre_insert($obj_type, $object, &$skip_fields) {
foreach ($language as $item) {
$query->values(array(
'nid' => $object->nid,
'title' => $object->title[FIELD_LANGUAGE_NONE][0]['value'],
'title' => $object->title[LANGUAGE_NONE][0]['value'],
'tid' => $item['tid'],
'sticky' => $object->sticky,
'created' => $object->created,
......@@ -465,7 +465,7 @@ function forum_field_storage_pre_update($obj_type, $object, &$skip_fields) {
foreach ($language as $item) {
$query->values(array(
'nid' => $object->nid,
'title' => $object->title[FIELD_LANGUAGE_NONE][0]['value'],
'title' => $object->title[LANGUAGE_NONE][0]['value'],
'tid' => $item['tid'],
'sticky' => $object->sticky,
'created' => $object->created,
......
......@@ -263,7 +263,7 @@ class ForumTestCase extends DrupalWebTestCase {
// select items list.
$tid = $forum['tid'];
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
$edit = array(
"title[$langcode][0][value]" => $title,
"body[$langcode][0][value]" => $body,
......@@ -340,20 +340,20 @@ class ForumTestCase extends DrupalWebTestCase {
// View forum node.
$this->drupalGet('node/' . $node->nid);
$this->assertResponse(200);
$this->assertTitle($node->title[FIELD_LANGUAGE_NONE][0]['value'] . ' | Drupal', t('Forum node was displayed'));
$this->assertTitle($node->title[LANGUAGE_NONE][0]['value'] . ' | Drupal', t('Forum node was displayed'));
$this->assertText(t('Home ' . $crumb . ' Forums ' . $crumb . ' @container ' . $crumb . ' @forum', array('@container' => $this->container['name'], '@forum' => $this->forum['name'])), t('Breadcrumbs were displayed'));
// View forum edit node.
$this->drupalGet('node/' . $node->nid . '/edit');
$this->assertResponse($response);
if ($response == 200) {
$this->assertTitle('Edit Forum topic ' . $node->title[FIELD_LANGUAGE_NONE][0]['value'] . ' | Drupal', t('Forum edit node was displayed'));
$this->assertTitle('Edit Forum topic ' . $node->title[LANGUAGE_NONE][0]['value'] . ' | Drupal', t('Forum edit node was displayed'));
}
if ($response == 200) {
// Edit forum node (including moving it to another forum).
$edit = array();
$langcode = FIELD_LANGUAGE_NONE;
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = 'node/' . $node->nid;
$edit["body[$langcode][0][value]"] = $this->randomName(256);
// Assume the topic is initially associated with $forum.
......
......@@ -16,7 +16,7 @@ function locale_field_node_form_update_field_language($form, &$form_state, $rese
$node = (object) $form_state['values'];
$available_languages = field_multilingual_content_languages();
// @todo: Unify language neutral language codes.
$selected_language = empty($node->language) ? FIELD_LANGUAGE_NONE : $node->language;