From b6dbe67d2bca12a1f1d57c4dea91f6fd3eaa5c4b Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 27 Apr 2015 11:27:14 +0200 Subject: [PATCH] Fix PHP warnings. --- main/inc/lib/internationalization.lib.php | 25 +++++++++++++------ main/inc/lib/pear/HTML/QuickForm.php | 3 --- .../lib/pear/HTML/QuickForm/RuleRegistry.php | 10 ++++---- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/main/inc/lib/internationalization.lib.php b/main/inc/lib/internationalization.lib.php index a36cf14aef..5e21a81e60 100755 --- a/main/inc/lib/internationalization.lib.php +++ b/main/inc/lib/internationalization.lib.php @@ -236,10 +236,12 @@ function get_lang($variable, $reserved = null, $language = null) { /** * Gets the current interface language. - * @param bool $purified (optional) When it is true, a purified (refined) language value will be returned, for example 'french' instead of 'french_unicode'. + * @param bool $purified (optional) When it is true, a purified (refined) + * language value will be returned, for example 'french' instead of 'french_unicode'. * @return string The current language of the interface. */ -function api_get_interface_language($purified = false, $check_sub_language = false) { +function api_get_interface_language($purified = false, $check_sub_language = false) +{ global $language_interface; if (empty($language_interface)) { @@ -250,11 +252,15 @@ function api_get_interface_language($purified = false, $check_sub_language = fal static $parent_language_name = null; if (!isset($parent_language_name)) { - //2. The current language is a sub language so we grab the father's + // 2. The current language is a sub language so we grab the father's // setting according to the internalization_database/name_order_convetions.php file $language_id = api_get_language_id($language_interface); $language_info = api_get_language_info($language_id); - if (!empty($language_id) && !empty($language_info)) { + + if (!empty($language_id) && + !empty($language_info) && + !empty($language_info['parent_id'])) { + $language_info = api_get_language_info($language_info['parent_id']); $parent_language_name = $language_info['english_name']; if (!empty($parent_language_name)) { @@ -266,9 +272,10 @@ function api_get_interface_language($purified = false, $check_sub_language = fal return $parent_language_name; } } else { - //2. Normal way + // 2. Normal way $interface_language = $purified ? api_purify_language_id($language_interface) : $language_interface; } + return $interface_language; } @@ -1052,7 +1059,7 @@ function api_convert_encoding($string, $to_encoding, $from_encoding = null) * This function is aimed at replacing the function utf8_encode() for human-language strings. * @link http://php.net/manual/en/function.utf8-encode */ -function api_utf8_encode($string, $from_encoding = null) +function api_utf8_encode($string, $from_encoding = 'UTF-8') { return mb_convert_encoding($string, 'UTF-8', $from_encoding); } @@ -1092,12 +1099,14 @@ function api_to_system_encoding($string, $from_encoding = null, $check_utf8_vali * Converts all applicable characters to HTML entities. * @param string $string The input string. * @param int $quote_style (optional) The quote style - ENT_COMPAT (default), ENT_QUOTES, ENT_NOQUOTES. - * @param string $encoding (optional) The encoding (of the input string) used in conversion. If it is omited, the platform character set is assumed. + * @param string $encoding (optional) The encoding (of the input string) used in conversion. + * If it is omited, the platform character set is assumed. * @return string Returns the converted string. * This function is aimed at replacing the function htmlentities() for human-language strings. * @link http://php.net/manual/en/function.htmlentities */ -function api_htmlentities($string, $quote_style = ENT_COMPAT, $encoding = null) { +function api_htmlentities($string, $quote_style = ENT_COMPAT, $encoding = 'UTF-8') +{ switch($quote_style) { case ENT_COMPAT: $string = str_replace(array('&', '"', '<', '>'), array('&', '"', '<', '>'), $string); diff --git a/main/inc/lib/pear/HTML/QuickForm.php b/main/inc/lib/pear/HTML/QuickForm.php index 55aa61e460..2880f893d4 100755 --- a/main/inc/lib/pear/HTML/QuickForm.php +++ b/main/inc/lib/pear/HTML/QuickForm.php @@ -1539,7 +1539,6 @@ class HTML_QuickForm extends HTML_Common return false; } - include_once('HTML/QuickForm/RuleRegistry.php'); $registry =& HTML_QuickForm_RuleRegistry::singleton(); foreach ($this->_rules as $target => $rules) { @@ -1726,7 +1725,6 @@ class HTML_QuickForm extends HTML_Common */ function &defaultRenderer() { if (!isset($GLOBALS['_HTML_QuickForm_default_renderer'])) { - include_once 'HTML/QuickForm/Renderer/Default.php'; // Modified by Ivan Tcholakov, 16-MAR-2010. Suppressing a deprecation warning on PHP 5.3 //$GLOBALS['_HTML_QuickForm_default_renderer'] =& new HTML_QuickForm_Renderer_Default(); $GLOBALS['_HTML_QuickForm_default_renderer'] = new HTML_QuickForm_Renderer_Default(); @@ -1773,7 +1771,6 @@ class HTML_QuickForm extends HTML_Common return ''; } - include_once('HTML/QuickForm/RuleRegistry.php'); $registry =& HTML_QuickForm_RuleRegistry::singleton(); $test = array(); $js_escape = array( diff --git a/main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php b/main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php index 0a691654c6..ee211d5dce 100755 --- a/main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php +++ b/main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php @@ -91,24 +91,24 @@ class HTML_QuickForm_RuleRegistry // Regular expression $rule =& $this->getRule('regex'); $rule->addData($ruleName, $data1); - $GLOBALS['_HTML_QuickForm_registered_rules'][$ruleName] = $GLOBALS['_HTML_QuickForm_registered_rules']['regex']; + //$GLOBALS['_HTML_QuickForm_registered_rules'][$ruleName] = $GLOBALS['_HTML_QuickForm_registered_rules']['regex']; } elseif ($type == 'function' || $type == 'callback') { // Callback function $rule =& $this->getRule('callback'); $rule->addData($ruleName, $data1, $data2, 'function' == $type); - $GLOBALS['_HTML_QuickForm_registered_rules'][$ruleName] = $GLOBALS['_HTML_QuickForm_registered_rules']['callback']; + //$GLOBALS['_HTML_QuickForm_registered_rules'][$ruleName] = $GLOBALS['_HTML_QuickForm_registered_rules']['callback']; } elseif (is_object($data1)) { // An instance of HTML_QuickForm_Rule $this->_rules[strtolower(get_class($data1))] = $data1; - $GLOBALS['_HTML_QuickForm_registered_rules'][$ruleName] = array(strtolower(get_class($data1)), null); + //$GLOBALS['_HTML_QuickForm_registered_rules'][$ruleName] = array(strtolower(get_class($data1)), null); } else { // Rule class name - $GLOBALS['_HTML_QuickForm_registered_rules'][$ruleName] = array(strtolower($data1), $data2); + //$GLOBALS['_HTML_QuickForm_registered_rules'][$ruleName] = array(strtolower($data1), $data2); } - } // end func registerRule + } /** * Returns a reference to the requested rule object