diff --git a/main/inc/lib/internationalization.lib.php b/main/inc/lib/internationalization.lib.php index 7b7b17341b..0d98e9d74a 100755 --- a/main/inc/lib/internationalization.lib.php +++ b/main/inc/lib/internationalization.lib.php @@ -6,7 +6,6 @@ * Internationalization library for Chamilo 1.8.7 LMS * A library implementing internationalization related functions. * License: GNU General Public License Version 3 (Free Software Foundation)ww - * @todo use Patchwork-UTF8 instead of custom changes. * @author Ivan Tcholakov, , 2009, 2010 * @author More authors, mentioned in the correpsonding fragments of this source. * @package chamilo.library @@ -776,7 +775,7 @@ function api_convert_and_format_date($time = null, $format = null, $from_timezon /** * Returns an array of translated week days in short names. - * @param string $language (optional) Language indentificator. If it is omited, the current interface language is assumed. + * @param string $language (optional) Language id. If it is omitted, the current interface language is assumed. * @return string Returns an array of week days (short names). * Example: api_get_week_days_short('english') means array('Sun', 'Mon', ... 'Sat'). * Note: For all languges returned days are in the English order. @@ -788,7 +787,7 @@ function api_get_week_days_short($language = null) { /** * Returns an array of translated week days. - * @param string $language (optional) Language indentificator. If it is omited, the current interface language is assumed. + * @param string $language (optional) Language id. If it is omitted, the current interface language is assumed. * @return string Returns an array of week days. * Example: api_get_week_days_long('english') means array('Sunday, 'Monday', ... 'Saturday'). * Note: For all languges returned days are in the English order. @@ -800,7 +799,7 @@ function api_get_week_days_long($language = null) { /** * Returns an array of translated months in short names. - * @param string $language (optional) Language indentificator. If it is omited, the current interface language is assumed. + * @param string $language (optional) Language id. If it is omitted, the current interface language is assumed. * @return string Returns an array of months (short names). * Example: api_get_months_short('english') means array('Jan', 'Feb', ... 'Dec'). */ @@ -811,7 +810,7 @@ function api_get_months_short($language = null) { /** * Returns an array of translated months. - * @param string $language (optional) Language indentificator. If it is omited, the current interface language is assumed. + * @param string $language (optional) Language id. If it is omitted, the current interface language is assumed. * @return string Returns an array of months. * Example: api_get_months_long('english') means array('January, 'February' ... 'December'). */ @@ -826,11 +825,11 @@ function api_get_months_long($language = null) { /** * Builds a person (full) name depending on the convention for a given language. - * @param string $first_name The first name of the preson. + * @param string $first_name The first name of the person. * @param string $last_name The last name of the person. * @param string $title The title of the person. * @param int/string $format (optional) The person name format. It may be a pattern-string (for example '%t %l, %f' or '%T %F %L', ...) or some of the constants PERSON_NAME_COMMON_CONVENTION (default), PERSON_NAME_WESTERN_ORDER, PERSON_NAME_EASTERN_ORDER, PERSON_NAME_LIBRARY_ORDER. - * @param string $language (optional) The language indentificator. If it is omited, the current interface language is assumed. This parameter has meaning with the format PERSON_NAME_COMMON_CONVENTION only. + * @param string $language (optional) The language id. If it is omitted, the current interface language is assumed. This parameter has meaning with the format PERSON_NAME_COMMON_CONVENTION only. * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. * @return bool The result is sort of full name of the person. * Sample results: @@ -927,7 +926,7 @@ function api_get_person_name( /** * Checks whether a given format represents person name in Western order (for which first name is first). * @param int/string $format (optional) The person name format. It may be a pattern-string (for example '%t. %l, %f') or some of the constants PERSON_NAME_COMMON_CONVENTION (default), PERSON_NAME_WESTERN_ORDER, PERSON_NAME_EASTERN_ORDER, PERSON_NAME_LIBRARY_ORDER. - * @param string $language (optional) The language identificator. If it is omited, the current interface language is assumed. This parameter has meaning with the format PERSON_NAME_COMMON_CONVENTION only. + * @param string $language (optional) The language id. If it is omitted, the current interface language is assumed. This parameter has meaning with the format PERSON_NAME_COMMON_CONVENTION only. * @return bool The result TRUE means that the order is first_name last_name, FALSE means last_name first_name. * Note: You may use this function for determing the order of the fields or columns "First name" and "Last name" in forms, tables and reports. * @author Ivan Tcholakov @@ -951,7 +950,7 @@ function api_is_western_name_order($format = null, $language = null) /** * Returns a directive for sorting person names depending on a given language and based on the options in the internationalization "database". - * @param string $language (optional) The input language. If it is omited, the current interface language is assumed. + * @param string $language (optional) The input language. If it is omitted, the current interface language is assumed. * @return bool Returns boolean value. TRUE means ORDER BY first_name, last_name; FALSE means ORDER BY last_name, first_name. * Note: You may use this function: * 2. for constructing the ORDER clause of SQL queries, related to first_name and last_name; @@ -984,7 +983,8 @@ function api_sort_by_first_name($language = null) { * Converts character encoding of a given string. * @param string $string The string being converted. * @param string $to_encoding The encoding that $string is being converted to. - * @param string $from_encoding (optional) The encoding that $string is being converted from. If it is omited, the platform character set is assumed. + * @param string $from_encoding (optional) The encoding that $string is being converted from. + * If it is omitted, the platform character set is assumed. * @return string Returns the converted string. * This function is aimed at replacing the function mb_convert_encoding() for human-language strings. * @link http://php.net/manual/en/function.mb-convert-encoding @@ -997,7 +997,8 @@ function api_convert_encoding($string, $to_encoding, $from_encoding = null) /** * Converts a given string into UTF-8 encoded string. * @param string $string The string being converted. - * @param string $from_encoding (optional) The encoding that $string is being converted from. If it is omited, the platform character set is assumed. + * @param string $from_encoding (optional) The encoding that $string is being converted from. + * If it is omitted, the platform character set is assumed. * @return string Returns the converted string. * This function is aimed at replacing the function utf8_encode() for human-language strings. * @link http://php.net/manual/en/function.utf8-encode @@ -1010,7 +1011,8 @@ function api_utf8_encode($string, $from_encoding = 'UTF-8') /** * Converts a given string from UTF-8 encoding to a specified encoding. * @param string $string The string being converted. - * @param string $to_encoding (optional) The encoding that $string is being converted to. If it is omited, the platform character set is assumed. + * @param string $to_encoding (optional) The encoding that $string is being converted to. + * If it is omitted, the platform character set is assumed. * @return string Returns the converted string. * This function is aimed at replacing the function utf8_decode() for human-language strings. * @link http://php.net/manual/en/function.utf8-decode @@ -1028,7 +1030,8 @@ function api_utf8_decode($string, $to_encoding = null) * UTF-8 validity and decides whether to try to convert it or not. * This function is useful for problem detection or making workarounds. * @param string $string The string being converted. - * @param string $from_encoding (optional) The encoding that $string is being converted from. It is guessed when it is omited. + * @param string $from_encoding (optional) The encoding that $string is being converted from. + * It is guessed when it is omitted. * @param bool $check_utf8_validity (optional) A flag for UTF-8 validity check as condition for making conversion. * @return string Returns the converted string. */ @@ -1043,7 +1046,7 @@ function api_to_system_encoding($string, $from_encoding = null, $check_utf8_vali * @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. + * If it is omitted, 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 @@ -1059,14 +1062,18 @@ function api_htmlentities($string, $quote_style = ENT_COMPAT, $encoding = 'UTF-8 break; } - return mb_convert_encoding(api_utf8_encode($string, $encoding), 'HTML-ENTITIES', 'UTF-8'); + return mb_convert_encoding($string, 'HTML-ENTITIES', 'UTF-8'); +/* + return html_entity_decode($string, $quote_style, $encoding); + return mb_convert_encoding($string, 'HTML-ENTITIES', 'UTF-8');*/ } /** * Converts HTML entities into normal characters. * @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 result) used in conversion. If it is omited, the platform character set is assumed. + * @param string $encoding (optional) The encoding (of the result) used in conversion. + * If it is omitted, the platform character set is assumed. * @return string Returns the converted string. * This function is aimed at replacing the function html_entity_decode() for human-language strings. * @link http://php.net/html_entity_decode @@ -1091,7 +1098,8 @@ function api_html_entity_decode($string, $quote_style = ENT_COMPAT, $encoding = /** * This function encodes (conditionally) a given string to UTF-8 if XmlHttp-request has been detected. * @param string $string The string being converted. - * @param string $from_encoding (optional) The encoding that $string is being converted from. If it is omited, the platform character set is assumed. + * @param string $from_encoding (optional) The encoding that $string is being converted from. + * If it is omitted, the platform character set is assumed. * @return string Returns the converted string. */ function api_xml_http_response_encode($string, $from_encoding = 'UTF8') @@ -1120,7 +1128,8 @@ function api_xml_http_response_encode($string, $from_encoding = 'UTF8') * * @param string $string The input string. * @param string $unknown (optional) Replacement character for unknown characters and illegal UTF-8 sequences. - * @param string $from_encoding (optional) The encoding of the input string. If it is omited, the platform character set is assumed. + * @param string $from_encoding (optional) The encoding of the input string. + * If it is omitted, the platform character set is assumed. * @return string Plain ASCII output. * */ @@ -1146,9 +1155,10 @@ function api_ord($character, $encoding) { * This function returns a string or an array with all occurrences of search in subject (ignoring case) replaced with the given replace value. * @param mixed $search String or array of strings to be found. * @param mixed $replace String or array of strings used for replacement. - * @param mixed $subject String or array of strings being searced. + * @param mixed $subject String or array of strings being searched. * @param int $count (optional) The number of matched and replaced needles will be returned in count, which is passed by reference. - * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. + * @param string $encoding (optional) The used internally by this function character encoding. + * If it is omitted, the platform character set will be used by default. * @return mixed String or array as a result. * Notes: * If $subject is an array, then the search and replace is performed with every entry of subject, the return value is an array. @@ -1399,7 +1409,8 @@ function api_substr($string, $start, $length = null, $encoding = null) * Counts the number of substring occurrences. * @param string $haystack The string being checked. * @param string $needle The string being found. - * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. + * @param string $encoding (optional) The used internally by this function character encoding. + * If it is omitted, the platform character set will be used by default. * @return int The number of times the needle substring occurs in the haystack string. * @link http://php.net/manual/en/function.mb-substr-count.php */ @@ -1422,7 +1433,8 @@ function api_substr_count($haystack, $needle, $encoding = null) * If it is negative, it represents the number of characters from the end of string at which to stop replacing. * If it is not given, then it will default to api_strlen($string); i.e. end the replacing at the end of string. * If $length is zero, then this function will have the effect of inserting replacement into the string at the given start offset. - * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. + * @param string $encoding (optional) The used internally by this function character encoding. + * If it is omitted, the platform character set will be used by default. * @return string The result string is returned. * This function is aimed at replacing the function substr_replace() for human-language strings. * @link http://php.net/manual/function.substr-replace @@ -1439,7 +1451,8 @@ function api_substr_replace($string, $replacement, $start, $length = null, $enco /** * Makes a string's first character uppercase. * @param string $string The input string. - * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. + * @param string $encoding (optional) The used internally by this function character encoding. + * If it is omitted, the platform character set will be used by default. * @return string Returns a string with the first character capitalized, if that character is alphabetic. * This function is aimed at replacing the function ucfirst() for human-language strings. * @link http://php.net/manual/en/function.ucfirst @@ -1452,7 +1465,8 @@ function api_ucfirst($string, $encoding = null) /** * Uppercases the first character of each word in a string. * @param string $string The input string. - * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. + * @param string $encoding (optional) The used internally by this function character encoding. + * If it is omitted, the platform character set will be used by default. * @return string Returns the modified string. * This function is aimed at replacing the function ucwords() for human-language strings. * @link http://php.net/manual/en/function.ucwords @@ -1515,7 +1529,8 @@ function api_preg_match_all($pattern, $subject, &$matches, $flags = PREG_PATTERN * @param string|array $subject The string or an array with strings to search and replace. * @param int $limit The maximum possible replacements for each pattern in each subject string. Defaults to -1 (no limit). * @param int &$count If specified, this variable will be filled with the number of replacements done. - * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. + * @param string $encoding (optional) The used internally by this function character encoding. + * If it is omitted, the platform character set will be used by default. * @return array|string|null returns an array if the subject parameter is an array, or a string otherwise. * If matches are found, the new subject will be returned, otherwise subject will be returned unchanged or NULL if an error occurred. * @link http://php.net/preg_replace @@ -1579,7 +1594,8 @@ function api_strcasecmp($string1, $string2, $language = null, $encoding = null) * @param string $string1 The first string. * @param string $string2 The second string. * @param string $language (optional) The language in which comparison is to be made. If language is omitted, interface language is assumed then. - * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. + * @param string $encoding (optional) The used internally by this function character encoding. + * If it is omitted, the platform character set will be used by default. * @return int Returns < 0 if $string1 is less than $string2; > 0 if $string1 is greater than $string2; and 0 if the strings are equal. * This function is aimed at replacing the function strcmp() for human-language strings. * @link http://php.net/manual/en/function.strcmp.php @@ -1595,7 +1611,8 @@ function api_strcmp($string1, $string2, $language = null, $encoding = null) * @param string $string1 The first string. * @param string $string2 The second string. * @param string $language (optional) The language in which comparison is to be made. If language is omitted, interface language is assumed then. - * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. + * @param string $encoding (optional) The used internally by this function character encoding. + * If it is omitted, the platform character set will be used by default. * @return int Returns < 0 if $string1 is less than $string2; > 0 if $string1 is greater than $string2; and 0 if the strings are equal. * This function is aimed at replacing the function strnatcmp() for human-language strings. * @link http://php.net/manual/en/function.strnatcmp.php @@ -1614,7 +1631,8 @@ function api_strnatcmp($string1, $string2, $language = null, $encoding = null) * Sorts an array using natural order algorithm. * @param array $array The input array. * @param string $language (optional) The language in which comparison is to be made. If language is omitted, interface language is assumed then. - * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. + * @param string $encoding (optional) The used internally by this function character encoding. + * If it is omitted, the platform character set will be used by default. * @return bool Returns TRUE on success, FALSE on error. * This function is aimed at replacing the function natsort() for sorting human-language strings. * @link http://php.net/manual/en/function.natsort.php @@ -1628,7 +1646,8 @@ function api_natsort(&$array, $language = null, $encoding = null) * Sorts an array using natural order algorithm in reverse order. * @param array $array The input array. * @param string $language (optional) The language in which comparison is to be made. If language is omitted, interface language is assumed then. - * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. + * @param string $encoding (optional) The used internally by this function character encoding. + * If it is omitted, the platform character set will be used by default. * @return bool Returns TRUE on success, FALSE on error. */ function api_natrsort(&$array, $language = null, $encoding = null) @@ -1656,7 +1675,8 @@ function api_refine_encoding_id($encoding) { * This function checks whether two $encoding are equal (same, equvalent). * @param string/array $encoding1 The first encoding * @param string/array $encoding2 The second encoding - * @param bool $strict When this parameter is TRUE the comparison ignores aliases of encodings. When the parameter is FALSE, aliases are taken into account. + * @param bool $strict When this parameter is TRUE the comparison ignores aliases of encodings. + * When the parameter is FALSE, aliases are taken into account. * @return bool Returns TRUE if the encodings are equal, FALSE otherwise. */ function api_equal_encodings($encoding1, $encoding2, $strict = false) { @@ -1800,7 +1820,7 @@ function get_plugin_lang($variable, $pluginName) { /** * Returns an array of translated week days and months, short and normal names. - * @param string $language (optional) Language id. If it is ommited, the current interface language is assumed. + * @param string $language (optional) Language id. If it is omitted, the current interface language is assumed. * @return array Returns a multidimensional array with translated week days and months. */ function &_api_get_day_month_names($language = null) {