diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc
index 35363b0..ebc3b16 100644
--- a/core/modules/language/language.admin.inc
+++ b/core/modules/language/language.admin.inc
@@ -156,14 +156,15 @@ function language_admin_overview_form_submit($form, &$form_state) {
$language->weight = $form_state['values']['languages'][$langcode]['weight'];
if ($language->default || $old_default->langcode == $langcode) {
- // Automatically enable the default language and the language
- // which was default previously (because we will not get the
- // value from that disabled checkbox).
+ // Automatically enable the default language and the language which was
+ // default previously (because we will not get the value from that
+ // disabled checkbox).
$form_state['values']['languages'][$langcode]['enabled'] = 1;
}
$language->enabled = (int) !empty($form_state['values']['languages'][$langcode]['enabled']);
- // If a language is disabled take sure
+ // If the interface language has been disabled make sure that the form
+ // redirect includes the new default language as a query parameter.
if ($language->enabled == FALSE && $langcode == $GLOBALS['language_interface']->langcode) {
$form_state['redirect'] = array('admin/config/regional/language', array('language' => $languages[$form_state['values']['site_default']]));
}
@@ -284,7 +285,7 @@ function _language_admin_common_controls(&$form, $language = NULL) {
'#required' => TRUE,
'#description' => t('Direction that text in this language is presented.'),
'#default_value' => @$language->direction,
- '#options' => array(LANGUAGE_LTR => t('Left to right'), LANGUAGE_RTL => t('Right to left'))
+ '#options' => array(LANGUAGE_LTR => t('Left to right'), LANGUAGE_RTL => t('Right to left')),
);
return $form;
}
@@ -372,7 +373,7 @@ function language_admin_edit_form_validate($form, &$form_state) {
* Process the language editing form submission.
*/
function language_admin_edit_form_submit($form, &$form_state) {
- // Prepare a language object for saving
+ // Prepare a language object for saving.
$languages = language_list();
$langcode = $form_state['values']['langcode'];
$language = $languages[$langcode];
@@ -393,7 +394,7 @@ function language_admin_delete_form($form, &$form_state, $language) {
drupal_goto('admin/config/regional/language');
}
- // For other languages, warn user that data loss is ahead.
+ // For other languages, warn the user that data loss is ahead.
$languages = language_list();
if (!isset($languages[$langcode])) {
@@ -568,7 +569,6 @@ function theme_language_negotiation_configure_form($variables) {
foreach ($form['#language_types'] as $type) {
$rows = array();
- $info = $form['#language_types_info'][$type];
$title = '';
$description = '
' . $form[$type]['#description'] . '
';
@@ -703,7 +703,7 @@ function language_negotiation_configure_url_form($form, &$form_state) {
'#title' => t('%language (%langcode) path prefix', array('%language' => $language->name, '%langcode' => $language->langcode)),
'#maxlength' => 64,
'#default_value' => isset($prefixes[$langcode]) ? $prefixes[$langcode] : '',
- '#field_prefix' => url('', array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
+ '#field_prefix' => url('', array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
);
$form['domain'][$langcode] = array(
'#type' => 'textfield',
@@ -732,7 +732,6 @@ function language_negotiation_configure_url_form($form, &$form_state) {
function language_negotiation_configure_url_form_validate($form, &$form_state) {
// Get the enabled languages only.
$languages = language_list(TRUE);
- $default = language_default();
// Count repeated values for uniqueness check.
$count = array_count_values($form_state['values']['prefix']);
@@ -741,12 +740,14 @@ function language_negotiation_configure_url_form_validate($form, &$form_state) {
if ($value === '') {
if (!$language->default && $form_state['values']['language_negotiation_url_part'] == LANGUAGE_NEGOTIATION_URL_PREFIX) {
- // Validation error if the prefix is blank for a non-default language, and value is for selected negotiation type.
+ // Throw a form error if the prefix is blank for a non-default language,
+ // although it is required for selected negotiation type.
form_error($form['prefix'][$langcode], t('The prefix may only be left blank for the default language.'));
}
}
- else if (isset($count[$value]) && $count[$value] > 1) {
- // Validation error if there are two languages with the same domain/prefix.
+ elseif (isset($count[$value]) && $count[$value] > 1) {
+ // Throw a form error if there are two languages with the same
+ // domain/prefix.
form_error($form['prefix'][$langcode], t('The prefix for %language, %value, is not unique.', array('%language' => $language->name, '%value' => $value)));
}
}
@@ -758,12 +759,14 @@ function language_negotiation_configure_url_form_validate($form, &$form_state) {
if ($value === '') {
if (!$language->default && $form_state['values']['language_negotiation_url_part'] == LANGUAGE_NEGOTIATION_URL_DOMAIN) {
- // Validation error if the domain is blank for a non-default language, and value is for selected negotiation type.
+ // Throw a form error if the domain is blank for a non-default language,
+ // although it is required for selected negotiation type.
form_error($form['domain'][$langcode], t('The domain may only be left blank for the default language.'));
}
}
- else if (isset($count[$value]) && $count[$value] > 1) {
- // Validation error if there are two languages with the same domain/domain.
+ elseif (isset($count[$value]) && $count[$value] > 1) {
+ // Throw a form error if there are two languages with the same
+ // domain/domain.
form_error($form['domain'][$langcode], t('The domain for %language, %value, is not unique.', array('%language' => $language->name, '%value' => $value)));
}
}
@@ -772,11 +775,10 @@ function language_negotiation_configure_url_form_validate($form, &$form_state) {
foreach ($languages as $langcode => $name) {
$value = $form_state['values']['domain'][$langcode];
if (!empty($value)) {
- // Ensure we have a protocol but only one protocol in the setting for
- // parse_url() checking against the hostname.
+ // Ensure we have exactly one protocol when checking the hostname.
$host = 'http://' . str_replace(array('http://', 'https://'), '', $value);
if (parse_url($host, PHP_URL_HOST) != $value) {
- form_error($form['domain'][$langcode], t('The domain for %language may only contain the domain name, not a protocol and/or port.', array( '%language' => $name)));
+ form_error($form['domain'][$langcode], t('The domain for %language may only contain the domain name, not a protocol and/or port.', array('%language' => $name)));
}
}
}
@@ -786,7 +788,6 @@ function language_negotiation_configure_url_form_validate($form, &$form_state) {
* Saves the URL language negotiation method settings.
*/
function language_negotiation_configure_url_form_submit($form, &$form_state) {
-
// Save selected format (prefix or domain).
variable_set('language_negotiation_url_part', $form_state['values']['language_negotiation_url_part']);
diff --git a/core/modules/language/language.negotiation.inc b/core/modules/language/language.negotiation.inc
index 367d116..f8d73ee 100644
--- a/core/modules/language/language.negotiation.inc
+++ b/core/modules/language/language.negotiation.inc
@@ -74,8 +74,8 @@ function language_from_browser($languages) {
}
// The Accept-Language header contains information about the language
- // preferences configured in the user's browser / operating system.
- // RFC 2616 (section 14.4) defines the Accept-Language header as follows:
+ // preferences configured in the user's browser / operating system. RFC 2616
+ // (section 14.4) defines the Accept-Language header as follows:
// Accept-Language = "Accept-Language" ":"
// 1#( language-range [ ";" "q" "=" qvalue ] )
// language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" )
@@ -107,9 +107,9 @@ function language_from_browser($languages) {
}
}
- // Find the enabled language with the greatest qvalue, following the rules
- // of RFC 2616 (section 14.4). If several languages have the same qvalue,
- // prefer the one with the greatest weight.
+ // Find the enabled language with the greatest qvalue, following the rules of
+ // RFC 2616 (section 14.4). If several languages have the same qvalue, prefer
+ // the one with the greatest weight.
$best_match_langcode = FALSE;
$max_qvalue = 0;
foreach ($languages as $langcode => $language) {
@@ -120,8 +120,8 @@ function language_from_browser($languages) {
// language, if set, or is 0 (which will never match).
$qvalue = isset($browser_langcodes['*']) ? $browser_langcodes['*'] : 0;
- // Find the longest possible prefix of the browser-supplied language
- // ('the language-range') that matches this site language ('the language tag').
+ // Find the longest possible prefix of the browser-supplied language ('the
+ // language-range') that matches this site language ('the language tag').
$prefix = $langcode;
do {
if (isset($browser_langcodes[$prefix])) {
@@ -210,8 +210,8 @@ function language_from_url($languages) {
switch (variable_get('language_negotiation_url_part', LANGUAGE_NEGOTIATION_URL_PREFIX)) {
case LANGUAGE_NEGOTIATION_URL_PREFIX:
- // $_GET['q'] might not be available at this time, because
- // path initialization runs after the language bootstrap phase.
+ // $_GET['q'] might not be available at this time, because path
+ // initialization runs after the language bootstrap phase.
list($language, $_GET['q']) = language_url_split_prefix(isset($_GET['q']) ? $_GET['q'] : NULL, $languages);
if ($language !== FALSE) {
$language_url = $language->langcode;
@@ -221,10 +221,10 @@ function language_from_url($languages) {
case LANGUAGE_NEGOTIATION_URL_DOMAIN:
$domains = language_negotiation_url_domains();
foreach ($languages as $language) {
- // Skip check if the language doesn't have a domain.
+ // Skip the check if the language doesn't have a domain.
if (!empty($domains[$language->langcode])) {
- // Only compare the domains not the protocols or ports.
- // Remove protocol and add http:// so parse_url works
+ // Ensure that there is exactly one protocol in the url when checking
+ // the hostname.
$host = 'http://' . str_replace(array('http://', 'https://'), '', $domains[$language->langcode]);
$host = parse_url($host, PHP_URL_HOST);
if ($_SERVER['HTTP_HOST'] == $host) {
diff --git a/core/modules/language/language.test b/core/modules/language/language.test
index a943bb0..6c64c29 100644
--- a/core/modules/language/language.test
+++ b/core/modules/language/language.test
@@ -41,8 +41,6 @@ class LanguageListTest extends DrupalWebTestCase {
);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
$this->assertText('French', t('Language added successfully.'));
- debug($this->getUrl());
- debug(url('admin/config/regional/language', array('absolute' => TRUE)));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
// Add custom language.
diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install
index bb590f5..c29e0d8 100644
--- a/core/modules/locale/locale.install
+++ b/core/modules/locale/locale.install
@@ -309,10 +309,10 @@ function locale_update_8005() {
$plural_lids = array();
foreach ($results as $row) {
// Need to collect both LID and PLID. The LID for the first (singular)
- // string can only be retrieved from the first plural's PLID given no
- // other indication. The last plural variant is never referenced, so we
- // need to store the LID directly for that. We never know whether we are
- // on the last plural though, so we always remember LID too.
+ // string can only be retrieved from the first plural's PLID given no other
+ // indication. The last plural variant is never referenced, so we need to
+ // store the LID directly for that. We never know whether we are on the last
+ // plural though, so we always remember LID too.
$plural_lids[] = $row->lid;
$plural_lids[] = $row->plid;
}
@@ -320,9 +320,9 @@ function locale_update_8005() {
if (!empty($plural_lids)) {
// Look up all translations for these source strings. Ordering by language
- // will group the strings by language, the 'plid' order will get the
- // strings in singular/plural order and 'plural' will get them in precise
- // sequential order needed.
+ // will group the strings by language, the 'plid' order will get the strings
+ // in singular/plural order and 'plural' will get them in precise sequential
+ // order needed.
$results = db_query("SELECT s.lid, s.source, t.translation, t.plid, t.plural, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid WHERE s.lid IN (:lids) ORDER BY t.language, t.plid, t.plural", array(':lids' => $plural_lids));
// Collect the strings into an array and combine values as we go.
@@ -352,9 +352,9 @@ function locale_update_8005() {
// formulas.
$utmost_parent['translation'][] = str_replace('@count[' . $child->plural .']', '@count', $child->translation);
if (count($utmost_parent['source']) < 2) {
- // Append source to the utmost parent's source string only if it is the
- // plural variant. Further Drupal specific plural variants are not to be
- // retained for source strings.
+ // Append source to the utmost parent's source string only if it is
+ // the plural variant. Further Drupal specific plural variants are not
+ // to be retained for source strings.
$utmost_parent['source'][] = $child->source;
}
@@ -369,10 +369,10 @@ function locale_update_8005() {
foreach ($strings as $langcode => $translations) {
foreach($translations as $lid => $translation) {
if (!in_array($lid, $updated_sources)) {
- // Only update source string if not yet updated. We merged these within
- // the translation lookups because plural information was only avilable
- // with the translation, but we don't need to save it again for every
- // language.
+ // Only update source string if not yet updated. We merged these
+ // within the translation lookups because plural information was only
+ // avilable with the translation, but we don't need to save it again
+ // for every language.
db_update('locales_source')
->fields(array(
'source' => implode(LOCALE_PLURAL_DELIMITER, $translation['source']),
@@ -420,7 +420,11 @@ function locale_update_8005() {
* Convert language_negotiation_* variables to use the new callbacks.
*/
function locale_update_8006() {
- $variable_names = array('language_negotiation_language_interface', 'language_negotiation_language_content', 'language_negotiation_language_url');
+ $variable_names = array(
+ 'language_negotiation_language_interface',
+ 'language_negotiation_language_content',
+ 'language_negotiation_language_url'
+ );
$callback_map = array(
'locale_language_from_url' => 'language_from_url',
'locale_language_switcher_url' => 'language_switcher_url',
@@ -469,11 +473,11 @@ function locale_update_8006() {
* Convert the variable locale_language_negotiation_url_part, locale_language_negotiation_url_domains.
*/
function locale_update_8007() {
- $value = variable_get('locale_language_negotiation_url_part',0);
+ $value = variable_get('locale_language_negotiation_url_part', 0);
variable_set('language_negotiation_url_part', $value);
variable_del('locale_language_negotiation_url_part');
- $value = variable_get('locale_language_negotiation_url_domains',0);
+ $value = variable_get('locale_language_negotiation_url_domains', 0);
variable_set('language_negotiation_url_domains', $value);
variable_del('locale_language_negotiation_url_domains');
}
@@ -485,9 +489,7 @@ function locale_update_8008() {
$block_tables = array('block', 'block_node_type', 'block_role');
foreach ($block_tables as $table) {
db_update($table)
- ->fields(array(
- 'module' => 'language',
- ))
+ ->fields(array('module' => 'language'))
->condition('module', 'locale')
->execute();
}
diff --git a/core/modules/locale/locale.test b/core/modules/locale/locale.test
index 108db1e..893cc35 100644
--- a/core/modules/locale/locale.test
+++ b/core/modules/locale/locale.test
@@ -3008,8 +3008,6 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase {
$this->languageNegotiationUpdate();
$type = LANGUAGE_TYPE_CONTENT;
$language_types = variable_get('language_types', language_types_get_default());
- debug($language_types);
- debug($type);
$this->assertTrue($language_types[$type], t('Content language type is configurable.'));
// Enable some core and custom language negotiation methods. The test