From 0baad49d620d9988837287cb5942eea764d3ed6f Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 2 Dec 2009 19:26:23 +0000 Subject: - Patch #635094 by plach: unify 'language neutral' language codes. --- modules/path/path.admin.inc | 6 +++--- modules/path/path.module | 14 +++++++------- modules/path/path.test | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) (limited to 'modules/path') diff --git a/modules/path/path.admin.inc b/modules/path/path.admin.inc index 74dde0c8b..94fbf5d4c 100644 --- a/modules/path/path.admin.inc +++ b/modules/path/path.admin.inc @@ -16,7 +16,7 @@ function path_admin_overview($keys = NULL) { // Add the filter form above the overview table. $build['path_admin_filter_form'] = drupal_get_form('path_admin_filter_form', $keys); // Enable language column if locale is enabled or if we have any alias with language - $alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE language <> :language', 0, 1, array(':language' => ''))->fetchField(); + $alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE language <> :language', 0, 1, array(':language' => LANGUAGE_NONE))->fetchField(); $multilanguage = (module_exists('locale') || $alias_exists); $header = array( @@ -94,7 +94,7 @@ function path_admin_edit($path = array()) { * @see path_admin_form_validate() * @see path_admin_form_submit() */ -function path_admin_form($form, &$form_state, $path = array('source' => '', 'alias' => '', 'language' => '', 'pid' => NULL)) { +function path_admin_form($form, &$form_state, $path = array('source' => '', 'alias' => '', 'language' => LANGUAGE_NONE, 'pid' => NULL)) { $form['source'] = array( '#type' => 'textfield', '#title' => t('Existing system path'), @@ -151,7 +151,7 @@ function path_admin_form_validate($form, &$form_state) { $alias = $form_state['values']['alias']; $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0; // Language is only set if locale module is enabled, otherwise save for all languages. - $language = isset($form_state['values']['language']) ? $form_state['values']['language'] : ''; + $language = isset($form_state['values']['language']) ? $form_state['values']['language'] : LANGUAGE_NONE; $has_alias = db_query("SELECT COUNT(alias) FROM {url_alias} WHERE pid <> :pid AND alias = :alias AND language = :language", array( ':pid' => $pid, diff --git a/modules/path/path.module b/modules/path/path.module index c27716186..031526564 100644 --- a/modules/path/path.module +++ b/modules/path/path.module @@ -100,7 +100,7 @@ function path_form_alter(&$form, $form_state, $form_id) { $path = array(); if (!empty($form['#node']->nid)) { $conditions = array('source' => 'node/' . $form['#node']->nid); - if (!empty($form['#node']->language)) { + if ($form['#node']->language != LANGUAGE_NONE) { $conditions['language'] = $form['#node']->language; } $path = path_load($conditions); @@ -112,7 +112,7 @@ function path_form_alter(&$form, $form_state, $form_id) { 'pid' => NULL, 'source' => isset($form['#node']->nid) ? 'node/' . $form['#node']->nid : NULL, 'alias' => '', - 'language' => isset($form['#node']->language) ? $form['#node']->language : '', + 'language' => isset($form['#node']->language) ? $form['#node']->language : LANGUAGE_NONE, ); $form['path'] = array( @@ -190,7 +190,7 @@ function path_node_insert($node) { if (!empty($path['alias'])) { // Ensure fields for programmatic executions. $path['source'] = 'node/' . $node->nid; - $path['language'] = isset($node->language) ? $node->language : ''; + $path['language'] = isset($node->language) ? $node->language : LANGUAGE_NONE; path_save($path); } } @@ -211,7 +211,7 @@ function path_node_update($node) { if (!empty($path['alias'])) { // Ensure fields for programmatic executions. $path['source'] = 'node/' . $node->nid; - $path['language'] = isset($node->language) ? $node->language : ''; + $path['language'] = isset($node->language) ? $node->language : LANGUAGE_NONE; path_save($path); } } @@ -239,7 +239,7 @@ function path_form_taxonomy_form_term_alter(&$form, $form_state) { 'pid' => NULL, 'source' => isset($form['#term']['tid']) ? 'taxonomy/term/' . $form['#term']['tid'] : NULL, 'alias' => '', - 'language' => '', + 'language' => LANGUAGE_NONE, ); $form['identification']['path'] = array( '#access' => user_access('create url aliases') || user_access('administer url aliases'), @@ -271,7 +271,7 @@ function path_taxonomy_term_insert($term) { if (!empty($path['alias'])) { // Ensure fields for programmatic executions. $path['source'] = 'taxonomy/term/' . $term->tid; - $path['language'] = ''; + $path['language'] = LANGUAGE_NONE; path_save($path); } } @@ -292,7 +292,7 @@ function path_taxonomy_term_update($term) { if (!empty($path['alias'])) { // Ensure fields for programmatic executions. $path['source'] = 'taxonomy/term/' . $term->tid; - $path['language'] = ''; + $path['language'] = LANGUAGE_NONE; path_save($path); } } diff --git a/modules/path/path.test b/modules/path/path.test index 9ad9d6098..43a9d778a 100644 --- a/modules/path/path.test +++ b/modules/path/path.test @@ -63,7 +63,7 @@ class PathTestCase extends DrupalWebTestCase { // Confirm that the alias works. $this->drupalGet($edit['alias']); - $this->assertText($node1->title[FIELD_LANGUAGE_NONE][0]['value'], 'Alias works.'); + $this->assertText($node1->title[LANGUAGE_NONE][0]['value'], 'Alias works.'); // Change alias. $pid = $this->getPID($edit['alias']); @@ -74,7 +74,7 @@ class PathTestCase extends DrupalWebTestCase { // Confirm that the alias works. $this->drupalGet($edit['alias']); - $this->assertText($node1->title[FIELD_LANGUAGE_NONE][0]['value'], 'Changed alias works.'); + $this->assertText($node1->title[LANGUAGE_NONE][0]['value'], 'Changed alias works.'); drupal_static_reset('drupal_lookup_path'); // Confirm that previous alias no longer works. @@ -115,7 +115,7 @@ class PathTestCase extends DrupalWebTestCase { // Confirm that the alias works. $this->drupalGet($edit['path[alias]']); - $this->assertText($node1->title[FIELD_LANGUAGE_NONE][0]['value'], 'Alias works.'); + $this->assertText($node1->title[LANGUAGE_NONE][0]['value'], 'Alias works.'); // Change alias. $previous = $edit['path[alias]']; @@ -124,11 +124,11 @@ class PathTestCase extends DrupalWebTestCase { // Confirm that the alias works. $this->drupalGet($edit['path[alias]']); - $this->assertText($node1->title[FIELD_LANGUAGE_NONE][0]['value'], 'Changed alias works.'); + $this->assertText($node1->title[LANGUAGE_NONE][0]['value'], 'Changed alias works.'); // Make sure that previous alias no longer works. $this->drupalGet($previous); - $this->assertNoText($node1->title[FIELD_LANGUAGE_NONE][0]['value'], 'Previous alias no longer works.'); + $this->assertNoText($node1->title[LANGUAGE_NONE][0]['value'], 'Previous alias no longer works.'); $this->assertResponse(404); // Create second test node. @@ -264,7 +264,7 @@ class PathLanguageTestCase extends DrupalWebTestCase { // Confirm that the alias works. $this->drupalGet($edit['path[alias]']); - $this->assertText($english_node->title[FIELD_LANGUAGE_NONE][0]['value'], 'Alias works.'); + $this->assertText($english_node->title[LANGUAGE_NONE][0]['value'], 'Alias works.'); // Translate the node into French. $this->drupalGet('node/' . $english_node->nid . '/translate'); @@ -272,7 +272,7 @@ class PathLanguageTestCase extends DrupalWebTestCase { $edit = array(); $langcode = 'fr'; $edit["body[$langcode][0][value]"] = $this->randomName(); - $langcode = FIELD_LANGUAGE_NONE; + $langcode = LANGUAGE_NONE; $edit["title[$langcode][0][value]"] = $this->randomName(); $edit['path[alias]'] = $this->randomName(); $this->drupalPost(NULL, $edit, t('Save')); @@ -286,7 +286,7 @@ class PathLanguageTestCase extends DrupalWebTestCase { // Confirm that the alias works. $this->drupalGet('fr/' . $edit['path[alias]']); - $this->assertText($french_node->title[FIELD_LANGUAGE_NONE][0]['value'], 'Alias for French translation works.'); + $this->assertText($french_node->title[LANGUAGE_NONE][0]['value'], 'Alias for French translation works.'); // Confirm that the alias is returned by url(). drupal_static_reset('language_list'); -- cgit v1.2.3