Fixing PHP notices.

1.9.x
Julio Montoya 11 years ago
parent d66ae03f9f
commit 67fe0a6363
  1. 15
      main/inc/lib/internationalization.lib.php
  2. 4
      main/inc/lib/internationalization_internal.lib.php

@ -3693,13 +3693,18 @@ function api_detect_encoding($string, $language = null) {
$encodings = api_get_valid_encodings();
foreach ($encodings as & $encoding) {
if (api_is_encoding_supported($encoding) && !api_is_utf8($encoding)) {
$result_array = & _api_compare_n_grams(
_api_generate_n_grams(
api_substr($string, 0, LANGUAGE_DETECT_MAX_LENGTH, $encoding),
$encoding
),
$stringToParse = api_substr($string, 0, LANGUAGE_DETECT_MAX_LENGTH, $encoding);
$strintToParse2 = _api_generate_n_grams(
$stringToParse,
$encoding
);
$result_array = _api_compare_n_grams(
$strintToParse2,
$encoding
);
if (!empty($result_array)) {
list($key, $delta_points) = each($result_array);
if ($delta_points < $delta_points_min) {

@ -54,7 +54,7 @@ function _api_get_latin1_compatible_languages() {
* @param int $n_max (optional) The limit if the number of characters that a n-gram may contain.
* @return array An array that contains cunstructed n-grams, sorted in reverse order by their frequences. Frequences are not stored in the array.
*/
function &_api_generate_n_grams(&$string, $encoding, $n_grams_max = 350, $n_max = 4) {
function _api_generate_n_grams(&$string, $encoding, $n_grams_max = 350, $n_max = 4) {
if (empty($string)) {
return array();
}
@ -91,7 +91,7 @@ function &_api_generate_n_grams(&$string, $encoding, $n_grams_max = 350, $n_max
* If you set the value of $max_delta too low, no language will be recognized.
* $max_delta = 400 * 350 = 140000 is the best detection with lowest speed.
*/
function & _api_compare_n_grams(&$n_grams, $encoding, $max_delta = LANGUAGE_DETECT_MAX_DELTA) {
function _api_compare_n_grams(&$n_grams, $encoding, $max_delta = LANGUAGE_DETECT_MAX_DELTA) {
static $language_profiles;
if (!isset($language_profiles)) {
// Reading the language profile files from the internationalization database.

Loading…
Cancel
Save