Remove unused code. Cleaning up i18n library.

Set UTF-8 by default.
1.10.x
Julio Montoya 10 years ago
parent 5448995441
commit fe5db3a50e
  1. 2
      app/config/mail.conf.dist.php
  2. 23
      main/admin/add_courses_to_usergroup.php
  3. 5
      main/admin/add_sessions_to_promotion.php
  4. 21
      main/admin/add_sessions_to_usergroup.php
  5. 5
      main/admin/add_users_to_group.php
  6. 3
      main/admin/add_users_to_session.php
  7. 2
      main/admin/course_import.php
  8. 2
      main/admin/dashboard_add_courses_to_user.php
  9. 3
      main/admin/dashboard_add_sessions_to_user.php
  10. 3
      main/admin/dashboard_add_users_to_user.php
  11. 6
      main/admin/ldap_import_students.php
  12. 9
      main/admin/ldap_import_students_to_session.php
  13. 4
      main/admin/ldap_synchro.php
  14. 6
      main/admin/session_add.php
  15. 2
      main/admin/session_export.php
  16. 4
      main/admin/session_import.php
  17. 25
      main/admin/settings.lib.php
  18. 2
      main/admin/sub_language_ajax.inc.php
  19. 2
      main/admin/user_import.php
  20. 8
      main/auth/external_login/ldap.inc.php
  21. 4
      main/chat/chat.php
  22. 4
      main/chat/header_frame.inc.php
  23. 1
      main/coursecopy/classes/Course.class.php
  24. 3
      main/exercice/admin.php
  25. 1309
      main/exercice/answer_admin.inc.php
  26. 6
      main/inc/global.inc.php
  27. 2
      main/inc/lib/groupmanager.lib.php
  28. 804
      main/inc/lib/internationalization.lib.php
  29. 61
      main/inc/lib/internationalization_database/language_detection/update_language_profiles.php
  30. 446
      main/inc/lib/internationalization_internal.lib.php
  31. 19
      main/install/database.sql
  32. 2
      main/social/profile.php
  33. 2
      main/wiki/wiki.inc.php
  34. 2
      src/Chamilo/CoreBundle/Migrations/Schema/V110/Version110.php
  35. 103
      tests/main/inc/lib/internationalization.lib.test.php

@ -15,5 +15,5 @@ $platform_email['SMTP_MAILER'] = IS_WINDOWS_OS ? 'smtp' : 'mail'; // mail, sendm
$platform_email['SMTP_AUTH'] = 0;
$platform_email['SMTP_USER'] = '';
$platform_email['SMTP_PASS'] = '';
$platform_email['SMTP_CHARSET'] = api_get_system_encoding();
$platform_email['SMTP_CHARSET'] = 'UTF-8';
$platform_email['SMTP_UNIQUE_SENDER'] = 0; // to send all mails from the same user

@ -147,34 +147,11 @@ function search($needle,$type)
$xajax_response = new xajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
if ($type == 'single') {
// search users where username or firstname or lastname begins likes $needle
/* $sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
WHERE (username LIKE "'.$needle.'%"
OR firstname LIKE "'.$needle.'%"
OR lastname LIKE "'.$needle.'%") AND user.user_id<>"'.$user_anonymous.'" AND user.status<>'.DRH.''.
$order_clause.
' LIMIT 11';*/
} else {
$list = CourseManager::get_courses_list(0, 0, 2, 'ASC', -1, $needle);
}
if ($type=='single') {
/*
while ($user = Database :: fetch_array($rs)) {
$i++;
if ($i<=10) {
$person_name = api_get_person_name($user['firstname'], $user['lastname']);
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
} else {
$return .= '...<br />';
}
}
$xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));*/
} else {
$return .= '<select id="elements_not_in" name="elements_not_in_name[]" multiple="multiple" size="15" style="width:360px;">';

@ -112,11 +112,6 @@ function search_sessions($needle, $type)
$xajax_response = new xajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$session_list = SessionManager::get_sessions_list(
array('s.name' => array('operator' => 'LIKE', 'value' => "$needle%"))
);

@ -120,15 +120,10 @@ $ajax_search = $add_type == 'unique' ? true : false;
//checking for extra field with filter on
function search_sessions($needle,$type) {
global $tbl_user,$elements_in;
global $elements_in;
$xajax_response = new xajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
if ($type == 'single') {
// search users where username or firstname or lastname begins likes $needle
/* $sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
@ -148,17 +143,6 @@ function search_sessions($needle,$type) {
}
$i=0;
if ($type=='single') {
/*
while ($user = Database :: fetch_array($rs)) {
$i++;
if ($i<=10) {
$person_name = api_get_person_name($user['firstname'], $user['lastname']);
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
} else {
$return .= '...<br />';
}
}
$xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));*/
} else {
$return .= '<select id="elements_not_in" name="elements_not_in_name[]" multiple="multiple" size="15" style="width:360px;">';
@ -171,9 +155,10 @@ function search_sessions($needle,$type) {
$xajax_response -> addAssign('ajax_list_multiple','innerHTML',api_utf8_encode($return));
}
}
return $xajax_response;
}
$xajax -> processRequests();
$xajax->processRequests();
Display::display_header($tool_name);

@ -98,10 +98,6 @@ function search_users($needle, $type, $relation_type)
}
if (!empty($needle) && !empty($type)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$user_anonymous = api_get_anonymous_id();
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
if ($type == 'single') {
@ -167,6 +163,7 @@ function search_users($needle, $type, $relation_type)
}
}
}
return $xajax_response;
}

@ -76,9 +76,6 @@ function search_users($needle, $type)
$needle = '';
}
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$needle = Database::escape_string($needle);
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
$showOfficialCode = false;

@ -97,7 +97,7 @@ function save_data($courses)
{
$msg = '';
foreach ($courses as $course) {
$course_language = api_get_valid_language($course['Language']);
$course_language = $course['Language'];
$teachers = getTeacherListInArray($course['Teacher']);
$teacherList = array();
$creatorId = api_get_user_id();

@ -60,8 +60,6 @@ function search_courses($needle, $type)
$return = '';
if (!empty($needle) && !empty($type)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$needle = Database::escape_string($needle);
$assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($user_id);

@ -61,9 +61,6 @@ function search_sessions($needle, $type)
$xajax_response = new xajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$needle = Database::escape_string($needle);
$assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id);
$assigned_sessions_id = array_keys($assigned_sessions_to_hrm);

@ -67,9 +67,6 @@ function search_users($needle,$type)
$xajax_response = new xajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$assigned_users_to_hrm = array();
switch ($userStatus) {

@ -208,7 +208,7 @@ elseif(!empty($annee) && empty($course))
$courses = CourseManager::get_courses_list();
foreach($courses as $row)
{
echo '<option value="'.$row['code'].'">'.api_htmlentities($row['title'], ENT_COMPAT, api_get_system_encoding()).'</option>';
echo '<option value="'.$row['code'].'">'.api_htmlentities($row['title']).'</option>';
}
echo '</select>';
echo '<input type="submit" value="'.get_lang('Submit').'">';
@ -240,8 +240,8 @@ elseif (!empty($annee) && !empty($course) && empty($_POST['confirmed']))
$info = ldap_get_entries($ds, $sr);
for ($key = 0; $key < $info["count"]; $key ++) {
$nom_form[] = $info[$key]["sn"][0];//api_utf8_decode($info[$key]["sn"][0], api_get_system_encoding());
$prenom_form[] = $info[$key]["givenname"][0];//api_utf8_decode($info[$key]["givenname"][0], api_get_system_encoding());
$nom_form[] = $info[$key]["sn"][0];
$prenom_form[] = $info[$key]["givenname"][0];
$email_form[] = $info[$key]["mail"][0];
// Get uid from dn
//$dn_array=ldap_explode_dn($info[$key]["dn"],1);

@ -80,9 +80,8 @@ elseif(!empty($annee) && empty($id_session))
$sessions=Database::store_result($result);
$nbr_results=count($sessions);
foreach($sessions as $row)
{
echo '<option value="'.$row['id'].'">'.api_htmlentities($row['name'], ENT_COMPAT, api_get_system_encoding()).' ('.$row['date_start'].' - '.$row['date_end'].')</option>';
foreach($sessions as $row) {
echo '<option value="'.$row['id'].'">'.api_htmlentities($row['name']).' ('.$row['date_start'].' - '.$row['date_end'].')</option>';
}
echo '</select>';
echo '<input type="submit" value="'.get_lang('Submit').'">';
@ -114,8 +113,8 @@ elseif (!empty($annee) && !empty($id_session) && empty($_POST['confirmed']))
$info = ldap_get_entries($ds, $sr);
for ($key = 0; $key < $info["count"]; $key ++) {
$nom_form[] = $info[$key]["sn"][0];//api_utf8_decode($info[$key]["sn"][0], api_get_system_encoding());
$prenom_form[] = $info[$key]["givenname"][0];//api_utf8_decode($info[$key]["givenname"][0], api_get_system_encoding());
$nom_form[] = $info[$key]["sn"][0];
$prenom_form[] = $info[$key]["givenname"][0];
$email_form[] = $info[$key]["mail"][0];
// Get uid from dn
//$dn_array=ldap_explode_dn($info[$key]["dn"],1);

@ -86,8 +86,8 @@ foreach($Sessions as $session){
echo "<pre>";
print_r($info[$key]);
echo "</pre>";
$lastname = api_utf8_decode($info[$key]["sn"][0], api_get_system_encoding());
$firstname = api_utf8_decode($info[$key]["givenname"][0], api_get_system_encoding());
$lastname = api_utf8_decode($info[$key]["sn"][0]);
$firstname = api_utf8_decode($info[$key]["givenname"][0]);
$email = $info[$key]["mail"][0];
// Get uid from dn
$dn_array=ldap_explode_dn($info[$key]["dn"],1);

@ -36,11 +36,7 @@ function search_coachs($needle) {
$xajax_response = new xajaxResponse();
$return = '';
if(!empty($needle)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
if (!empty($needle)) {
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
// search users where username or firstname or lastname begins likes $needle

@ -105,7 +105,7 @@ if (isset($_POST['formSent'])) {
fputs($fp,"SessionName;Coach;DateStart;DateEnd;Visibility;SessionCategory;Users;Courses;\n");
} else {
$cvs = false;
fputs($fp, "<?xml version=\"1.0\" encoding=\"".api_get_system_encoding()."\"?>\n<Sessions>\n");
fputs($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Sessions>\n");
}
while($row=Database::fetch_array($result)) {

@ -149,7 +149,7 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
$params['wanted_code'] = api_utf8_decode($courseNode->CourseCode);
$params['tutor_name'] = null;
$params['course_category'] = null;
$params['course_language'] = api_get_valid_language(api_utf8_decode($courseNode->CourseLanguage));
$params['course_language'] = api_utf8_decode($courseNode->CourseLanguage);
$params['user_id'] = api_get_user_id();
// Looking up for the teacher.
@ -559,7 +559,7 @@ $form->display();
<p><?php echo get_lang('XMLMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
<blockquote>
<pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;<?php echo api_refine_encoding_id(api_get_system_encoding()); ?>&quot;?&gt;
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;Sessions&gt;
&lt;Users&gt;
&lt;User&gt;

@ -1212,30 +1212,7 @@ function generate_settings_form($settings, $settings_by_access_list) {
// For platform character set selection: Conversion of the textfield to a select box with valid values.
} elseif ($row['variable'] == 'platform_charset') {
$current_system_encoding = api_refine_encoding_id(trim($row['selected_value']));
$valid_encodings = array_flip(api_get_valid_encodings());
if (!isset($valid_encodings[$current_system_encoding])) {
$is_alias_encoding = false;
foreach ($valid_encodings as $encoding) {
if (api_equal_encodings($encoding, $current_system_encoding)) {
$is_alias_encoding = true;
$current_system_encoding = $encoding;
break;
}
}
if (!$is_alias_encoding) {
$valid_encodings[$current_system_encoding] = $current_system_encoding;
}
}
foreach ($valid_encodings as $key => &$encoding) {
if (api_is_encoding_supported($key)) {
$encoding = $key;
} else {
unset($valid_encodings[$key]);
}
}
$form->addElement('select', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), $valid_encodings);
$default_values[$row['variable']] = $current_system_encoding;
continue;
} else {
$hideme['class'] = 'span4';
$form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), $hideme);

@ -30,7 +30,7 @@ if (isset($new_language) && isset($language_variable) && isset($file_id)) {
$new_language = str_replace('"', '\"',$new_language);
// Replace new line signs to avoid parse errors - see #6773
$new_language = str_replace("\n","\\n",$new_language);
$all_file_of_directory[$language_variable]="\"".api_convert_encoding($new_language, api_get_system_encoding(),'UTF-8')."\";";
$all_file_of_directory[$language_variable]="\"".$new_language."\";";
$result_array = array();
foreach ($all_file_of_directory as $key_value=>$value_info) {

@ -528,7 +528,7 @@ if ($count_fields > 0) {
<p><?php echo get_lang('XMLMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
<blockquote>
<pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;<?php echo api_refine_encoding_id(api_get_system_encoding()); ?>&quot;?&gt;
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;Contacts&gt;
&lt;Contact&gt;
<b>&lt;LastName&gt;xxx&lt;/LastName&gt;</b>

@ -306,14 +306,6 @@ function extldap_add_user_by_array($data, $update_if_exists = true)
$passwordKey = isset($extldap_user_correspondance['password']) ? $extldap_user_correspondance['password'] : 'userPassword';
$password = $data[$passwordKey][0];
// Structure
/* $structure = $data['edupersonprimaryorgunitdn'][0];
$array_structure = explode(",", $structure);
$array_val = explode("=", $array_structure[0]);
$etape = $array_val[1];
$array_val = explode("=", $array_structure[1]);
$annee = $array_val[1];
*/
// To ease management, we add the step-year (etape-annee) code
//$official_code = $etape."-".$annee;
$official_code = api_convert_encoding($data[$extldap_user_correspondance['official_code']][0], api_get_system_encoding(), 'UTF-8');

@ -27,7 +27,7 @@ api_protect_course_group(GroupManager::GROUP_TOOL_CHAT, false);
/* TRACKING */
Event::event_access_tool(TOOL_CHAT);
header('Content-Type: text/html; charset='.api_get_system_encoding());
header('Content-Type: text/html; charset=UTF-8');
/*
* Choose CSS style (platform's, user's, or course's)
@ -45,7 +45,7 @@ $courseCode = Security::remove_XSS($_GET['cidReq']);
<!DOCTYPE html>
<html>
<head>
<meta charset="<?php echo api_get_system_encoding(); ?>" />
<meta charset="UTF-8" />
<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CSS_PATH); ?>chat.css">
<?php
echo'<title>'.get_lang('Chat').' - '.$mycourseid.' - '.api_get_setting('siteName').'</title>';

@ -116,12 +116,12 @@ foreach ($icons as $key => $icon) {
$icons = json_encode($iconList);
$ajax = api_get_path(WEB_AJAX_PATH).'chat.ajax.php?action=preview&'.api_get_cidreq();
header('Content-Type: text/html; charset='.api_get_system_encoding());
header('Content-Type: text/html; charset=UTF-8');
?><!DOCTYPE html>
<html>
<head>
<meta charset="<?php echo api_get_system_encoding(); ?>" />
<meta charset="UTF-8" />
<title>Chat</title>
<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_PATH); ?>web/assets/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_LIBRARY_PATH); ?>javascript/jquery-emojiarea/jquery.emojiarea.css">

@ -261,7 +261,6 @@ class Course
$resource->description = api_to_system_encoding($resource->description, $this->encoding);
$resource->content_maker = api_to_system_encoding($resource->content_maker, $this->encoding);
$resource->content_license = api_to_system_encoding($resource->content_license, $this->encoding);
//$resource->author = api_to_system_encoding($resource->author, $this->encoding); // Needs implamantation.
break;
case RESOURCE_LINK:
$resource->title = api_to_system_encoding($resource->title, $this->encoding);

@ -13,7 +13,6 @@
* - exercise_admin.inc.php : management of the exercise
* - question_admin.inc.php : management of a question (statement & answers)
* - statement_admin.inc.php : management of a statement
* - answer_admin.inc.php : management of answers
* - question_list_admin.inc.php : management of the question list
*
* Main variables used in this script :
@ -45,7 +44,7 @@
* Modified by Hubert Borderiou 21-10-2011 Question by category
*/
use \ChamiloSession as Session;
use ChamiloSession as Session;
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_QUIZ;

File diff suppressed because it is too large Load Diff

@ -186,12 +186,6 @@ $charset = 'UTF-8';
// Enables the portablity layer and configures PHP for UTF-8
\Patchwork\Utf8\Bootup::initAll();
// Initialization of the internationalization library.
//api_initialize_internationalization();
// Initialization of the default encoding that will be used by the multibyte string routines in the internationalization library.
//api_set_internationalization_default_encoding($charset);
// Start session after the internationalization library has been initialized.
Chamilo::session()->start($already_installed);

@ -1885,7 +1885,7 @@ class GroupManager
* Check if a user has access to a certain group tool
* @param int $user_id The user id
* @param int $group_id The group id
* @param constant $tool The tool to check the access rights. This should be
* @param string $tool The tool to check the access rights. This should be
* one of constants: GROUP_TOOL_DOCUMENTS
* @return bool True if the given user has access to the given tool in the
* given course.

File diff suppressed because it is too large Load Diff

@ -1,61 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.include.internationalization
*/
/**
* Code
*/
$_current_dir = str_replace('\\', '/', realpath(dirname(__FILE__))).'/';
$_sys_code_path = str_replace('\\', '/', realpath($_current_dir.'../../../../')).'/';
$_sys_include_path = $_sys_code_path.'inc/';
$_sys_library_path = $_sys_code_path.'inc/lib/';
require_once $_sys_include_path.'global.inc.php';
header('Content-Type: text/html; charset=UTF-8');
$_SESSION['_user']['user_id'] = 1;
function read_file($file_name) {
$handle = fopen($file_name, 'rb');
$string = fread($handle, filesize($file_name));
fclose($handle);
return $string;
}
function write_file($file_name, $text) {
$handle = fopen($file_name, "w");
fwrite($handle, $text);
fclose($handle);
}
function get_directory_content($path) {
$exceptions = array('.', '..', 'CVS', '.htaccess', '.svn', '_svn', 'index.html');
$result = array();
$path = realpath($path);
if (!is_dir($path)) return $result;
if (!$handle = opendir($path)) return $result;
while (($dir_entry = readdir($handle)) !== false) {
if (api_in_array_nocase($dir_entry, $exceptions)) continue;
$dir_entry_full_path = $path .'/'. $dir_entry;
if (filetype($dir_entry_full_path) != 'dir') {
$result[] = str_replace("\\", '/', $dir_entry_full_path);
}
}
closedir($handle);
asort($result);
return $result;
}
$files = get_directory_content($_current_dir.'sample_texts/');
echo 'Updating language profiles...<br />';
echo '<br />';
foreach ($files as $file) {
$language = basename($file, '.txt');
echo $language.'<br />';
write_file($_current_dir.'language_profiles/'.$language.'.txt', join("\n", _api_generate_n_grams(read_file($file), 'UTF-8', 400, 4)));
}
echo '<br />';
echo 'Done.<br />';

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* File: internationalization_internal.lib.php
* Main API extension library for Chamilo 1.8.7 LMS,
@ -17,26 +18,6 @@
*/
$_api_encoding = null;
$_api_collator = null;
/**
* This function returns an array of those languages that can use Latin 1 encoding.
* Appendix to "Language support"
* @return array The array of languages that can use Latin 1 encoding (ISO-8859-15, ISO-8859-1, WINDOWS-1252, ...).
* Note: The returned language identificators are purified, without suffixes.
*/
function _api_get_latin1_compatible_languages() {
static $latin1_languages;
if (!isset($latin1_languages)) {
$latin1_languages = array();
$encodings = & _api_non_utf8_encodings();
foreach ($encodings as $key => $value) {
if (api_is_latin1($value[0])) {
$latin1_languages[] = $key;
}
}
}
return $latin1_languages;
}
/**
* Appendix to "Language recognition"
@ -164,76 +145,6 @@ function _api_clean_person_name($person_name) {
function _api_convert_encoding(&$string, $to_encoding, $from_encoding)
{
return mb_convert_encoding($string, $to_encoding, $from_encoding);
/*
$str = (string)$string;
static $character_map = array();
static $utf8_compatible = array('UTF-8', 'US-ASCII');
if (empty($str)) {
return $str;
}
$to_encoding = api_refine_encoding_id($to_encoding);
$from_encoding = api_refine_encoding_id($from_encoding);
if (api_equal_encodings($to_encoding, $from_encoding)) {
return $str;
}
if ($to_encoding == 'HTML-ENTITIES') {
return api_htmlentities($str, ENT_QUOTES, $from_encoding);
}
if ($from_encoding == 'HTML-ENTITIES') {
return api_html_entity_decode($str, ENT_QUOTES, $to_encoding);
}
$to = _api_get_character_map_name($to_encoding);
$from = _api_get_character_map_name($from_encoding);
if (empty($to) || empty($from) || $to == $from || (in_array($to, $utf8_compatible) && in_array($from, $utf8_compatible))) {
return $str;
}
if (!isset($character_map[$to])) {
$character_map[$to] = &_api_parse_character_map($to);
}
if ($character_map[$to] === false) {
return $str;
}
if (!isset($character_map[$from])) {
$character_map[$from] = &_api_parse_character_map($from);
}
if ($character_map[$from] === false) {
return $str;
}
if ($from != 'UTF-8') {
$len = api_byte_count($str);
$codepoints = array();
for ($i = 0; $i < $len; $i++) {
$ord = ord($str[$i]);
if ($ord > 127) {
if (isset($character_map[$from]['local'][$ord])) {
$codepoints[] = $character_map[$from]['local'][$ord];
} else {
$codepoints[] = 0xFFFD; // U+FFFD REPLACEMENT CHARACTER is the general substitute character in the Unicode Standard.
}
} else {
$codepoints[] = $ord;
}
}
} else {
$codepoints = _api_utf8_to_unicode($str);
}
if ($to != 'UTF-8') {
foreach ($codepoints as $i => &$codepoint) {
if ($codepoint > 127) {
if (isset($character_map[$to]['unicode'][$codepoint])) {
$codepoint = chr($character_map[$to]['unicode'][$codepoint]);
} else {
$codepoint = '?'; // Unknown character.
}
} else {
$codepoint = chr($codepoint);
}
}
$str = implode($codepoints);
} else {
$str = _api_utf8_from_unicode($codepoints);
}
return $str;*/
}
/**
@ -422,232 +333,11 @@ function _api_utf8_chr($codepoint) {
return $result;
}
/**
* Takes the first UTF-8 character in a string and returns its Unicode codepoint.
* @param string $utf8_character The UTF-8 encoded character.
* @return int Returns: the codepoint; or 0xFFFD (unknown character) when the input string is empty.
* This is a UTF-8 aware version of the function ord().
* @link http://php.net/manual/en/function.ord.php
* Note about a difference with the original funtion ord(): ord('') returns 0.
*/
function _api_utf8_ord($utf8_character) {
if ($utf8_character == '') {
return 0xFFFD;
}
$codepoints = _api_utf8_to_unicode($utf8_character);
return $codepoints[0];
}
/**
* Makes a html-entity from Unicode codepoint.
* @param int $codepoint The Unicode codepoint.
* @return string Returns the corresponding html-entity; or ASCII character if $codepoint < 128.
*/
function _api_html_entity_from_unicode($codepoint) {
if ($codepoint < 128) {
return chr($codepoint);
}
return '&#'.$codepoint.';';
}
/**
* Appendix to "Common multibyte string functions"
*/
/**
* The following function reads case folding properties about a given character from a file-based "database".
* @param int $codepoint The Unicode codepoint that represents a caharacter.
* @param string $type (optional) The type of initial case to be altered: 'lower' (default) or 'upper'.
* @return array Returns an array with properties used to change case of the character.
*/
function &_api_utf8_get_letter_case_properties($codepoint, $type = 'lower') {
static $config = array();
static $range = array();
if (!isset($range[$codepoint])) {
if ($codepoint > 128 && $codepoint < 256) {
$range[$codepoint] = '0080_00ff'; // Latin-1 Supplement
} elseif ($codepoint < 384) {
$range[$codepoint] = '0100_017f'; // Latin Extended-A
} elseif ($codepoint < 592) {
$range[$codepoint] = '0180_024F'; // Latin Extended-B
} elseif ($codepoint < 688) {
$range[$codepoint] = '0250_02af'; // IPA Extensions
} elseif ($codepoint >= 880 && $codepoint < 1024) {
$range[$codepoint] = '0370_03ff'; // Greek and Coptic
} elseif ($codepoint < 1280) {
$range[$codepoint] = '0400_04ff'; // Cyrillic
} elseif ($codepoint < 1328) {
$range[$codepoint] = '0500_052f'; // Cyrillic Supplement
} elseif ($codepoint < 1424) {
$range[$codepoint] = '0530_058f'; // Armenian
} elseif ($codepoint >= 7680 && $codepoint < 7936) {
$range[$codepoint] = '1e00_1eff'; // Latin Extended Additional
} elseif ($codepoint < 8192) {
$range[$codepoint] = '1f00_1fff'; // Greek Extended
} elseif ($codepoint >= 8448 && $codepoint < 8528) {
$range[$codepoint] = '2100_214f'; // Letterlike Symbols
} elseif ($codepoint < 8592) {
$range[$codepoint] = '2150_218f'; // Number Forms
} elseif ($codepoint >= 9312 && $codepoint < 9472) {
$range[$codepoint] = '2460_24ff'; // Enclosed Alphanumerics
} elseif ($codepoint >= 11264 && $codepoint < 11360) {
$range[$codepoint] = '2c00_2c5f'; // Glagolitic
} elseif ($codepoint < 11392) {
$range[$codepoint] = '2c60_2c7f'; // Latin Extended-C
} elseif ($codepoint < 11520) {
$range[$codepoint] = '2c80_2cff'; // Coptic
} elseif ($codepoint >= 65280 && $codepoint < 65520) {
$range[$codepoint] = 'ff00_ffef'; // Halfwidth and Fullwidth Forms
} else {
$range[$codepoint] = false;
}
if ($range[$codepoint] === false) {
return null;
}
if (!isset($config[$range[$codepoint]])) {
$file = dirname(__FILE__).'/internationalization_database/casefolding/' . $range[$codepoint] . '.php';
if (file_exists($file)) {
include $file;
}
}
}
if ($range[$codepoint] === false || !isset($config[$range[$codepoint]])) {
return null;
}
$result = array();
$count = count($config[$range[$codepoint]]);
for ($i = 0; $i < $count; $i++) {
if ($type === 'lower' && $config[$range[$codepoint]][$i][$type][0] === $codepoint) {
$result[] = $config[$range[$codepoint]][$i];
} elseif ($type === 'upper' && $config[$range[$codepoint]][$i][$type] === $codepoint) {
$result[] = $config[$range[$codepoint]][$i];
}
}
return $result;
}
/**
* A callback for serving the function api_ucwords().
* @param array $matches Input array of matches corresponding to a single word
* @return string Returns a with first char of the word in uppercase
*/
function _api_utf8_ucwords_callback($matches) {
return $matches[2] . api_ucfirst(ltrim($matches[0]), 'UTF-8');
}
/**
* Appendix to "Common sting operations with arrays"
*/
/**
* This callback function converts from UTF-8 to other encoding. It works with strings or arrays of strings.
* @param mixed $variable The variable to be converted, a string or an array.
* @return mixed Returns the converted form UTF-8 $variable with the same type, string or array.
*/
function _api_array_utf8_decode($variable) {
global $_api_encoding;
if (is_array($variable)) {
return array_map('_api_array_utf8_decode', $variable);
}
if (is_string($variable)) {
return api_utf8_decode($variable, $_api_encoding);
}
return $variable;
}
/**
* Appendix to "String comparison"
*/
/**
* Returns an instance of Collator class (ICU) created for a specified language.
* @param string $language (optional) Language indentificator: 'english', 'french' ... If it is omited, the current interface language is assumed.
* @return object Returns a instance of Collator class that is suitable for common string comparisons.
*/
function _api_get_collator($language = null) {
static $collator = array();
if (empty($language)) {
$language = api_get_interface_language();
}
if (!isset($collator[$language])) {
$locale = _api_get_locale_from_language($language);
$collator[$language] = collator_create($locale);
if (is_object($collator[$language])) {
collator_set_attribute($collator[$language], Collator::CASE_FIRST, Collator::UPPER_FIRST);
}
}
return $collator[$language];
}
/**
* Returns an instance of Collator class (ICU) created for a specified language. This collator treats substrings of digits as numbers.
* @param string $language (optional) Language indentificator. If it is omited, the current interface language is assumed.
* @return object Returns a instance of Collator class that is suitable for alpha-numerical comparisons.
*/
function _api_get_alpha_numerical_collator($language = null) {
static $collator = array();
if (empty($language)) {
$language = api_get_interface_language();
}
if (!isset($collator[$language])) {
$locale = _api_get_locale_from_language($language);
$collator[$language] = collator_create($locale);
if (is_object($collator[$language])) {
collator_set_attribute($collator[$language], Collator::CASE_FIRST, Collator::UPPER_FIRST);
collator_set_attribute($collator[$language], Collator::NUMERIC_COLLATION, Collator::ON);
}
}
return $collator[$language];
}
/**
* A string comparison callback function for sorting.
* @param string $string1 The first string.
* @param string $string2 The second string.
* @return int Returns 0 if $string1 = $string2 or if there is an error; 1 if $string1 > $string2; -1 if $string1 < $string2.
*/
function _api_cmp($string1, $string2) {
global $_api_collator, $_api_encoding;
$result = collator_compare($_api_collator, api_utf8_encode($string1, $_api_encoding), api_utf8_encode($string2, $_api_encoding));
return $result === false ? 0 : $result;
}
/**
* A reverse string comparison callback function for sorting.
* @param string $string1 The first string.
* @param string $string2 The second string.
* @return int Returns 0 if $string1 = $string2 or if there is an error; 1 if $string1 < $string2; -1 if $string1 > $string2.
*/
function _api_rcmp($string1, $string2) {
global $_api_collator, $_api_encoding;
$result = collator_compare($_api_collator, api_utf8_encode($string2, $_api_encoding), api_utf8_encode($string1, $_api_encoding));
return $result === false ? 0 : $result;
}
/**
* A case-insensitive string comparison callback function for sorting.
* @param string $string1 The first string.
* @param string $string2 The second string.
* @return int Returns 0 if $string1 = $string2 or if there is an error; 1 if $string1 > $string2; -1 if $string1 < $string2.
*/
function _api_casecmp($string1, $string2) {
global $_api_collator, $_api_encoding;
$result = collator_compare($_api_collator, api_strtolower(api_utf8_encode($string1, $_api_encoding), 'UTF-8'), api_strtolower(api_utf8_encode($string2, $_api_encoding), 'UTF-8'));
return $result === false ? 0 : $result;
}
/**
* A reverse case-insensitive string comparison callback function for sorting.
* @param string $string1 The first string.
* @param string $string2 The second string.
* @return int Returns 0 if $string1 = $string2 or if there is an error; 1 if $string1 < $string2; -1 if $string1 > $string2.
*/
function _api_casercmp($string1, $string2) {
global $_api_collator, $_api_encoding;
$result = collator_compare($_api_collator, api_strtolower(api_utf8_encode($string2, $_api_encoding), 'UTF-8'), api_strtolower(api_utf8_encode($string1, $_api_encoding), 'UTF-8'));
return $result === false ? 0 : $result;
}
/**
* A reverse function from php-core function strnatcmp(), performs string comparison in reverse natural (alpha-numerical) order.
* @param string $string1 The first string.
@ -658,105 +348,14 @@ function _api_strnatrcmp($string1, $string2) {
return strnatcmp($string2, $string1);
}
/**
* A reverse function from php-core function strnatcasecmp(), performs string comparison in reverse case-insensitive natural (alpha-numerical) order.
* @param string $string1 The first string.
* @param string $string2 The second string.
* @return int Returns 0 if $string1 = $string2; >0 if $string1 < $string2; <0 if $string1 > $string2.
*/
function _api_strnatcasercmp($string1, $string2) {
return strnatcasecmp($string2, $string1);
}
/**
* A function that translates sorting flag constants from php core to correspondent constants from intl extension.
* @param int $sort_flag (optional) Sorting modifier flag as it is defined for php core. The default value is SORT_REGULAR.
* @return int Retturns the corresponding sorting modifier flag as it is defined in intl php-extension.
*/
function _api_get_collator_sort_flag($sort_flag = SORT_REGULAR) {
switch ($sort_flag) {
case SORT_STRING:
case SORT_LOCALE_STRING:
return Collator::SORT_STRING;
case SORT_NUMERIC:
return Collator::SORT_NUMERIC;
}
return Collator::SORT_REGULAR;
}
/**
* ICU locales (accessible through intl extension).
*/
/**
* Returns isocode (see api_get_language_isocode()) which is purified accordingly to
* be used by the php intl extension (ICU library).
* @param string $language (optional) This is the name of the folder containing translations for the corresponding language.
* If $language is omitted, interface language is assumed then.
* @return string The found language locale id or null on error. Examples: bg, en, pt_BR, ...
*/
function _api_get_locale_from_language($language = null) {
static $locale = array();
if (empty($language)) {
$language = api_get_interface_language();
}
if (!isset($locale[$language])) {
$locale[$language] = str_replace('-', '_', api_get_language_isocode($language));
}
return $locale[$language];
}
/**
* Sets/gets the default internal value of the locale id (for the intl extension, ICU).
* @param string $locale (optional) The locale id to be set. When it is omitted, the function returns (gets, reads) the default internal value.
* @return mixed When the function sets the default value, it returns TRUE on success or FALSE on error. Otherwise the function returns as string the current default value.
*/
function _api_set_default_locale($locale = null) {
static $default_locale = 'en';
if (!empty($locale)) {
$default_locale = $locale;
if (INTL_INSTALLED) {
return @locale_set_default($locale);
}
return true;
} else {
if (INTL_INSTALLED) {
$default_locale = @locale_get_default();
}
}
return $default_locale;
}
/**
* Gets the default internal value of the locale id (for the intl extension, ICU).
* @return string Returns as string the current default value.
*/
function api_get_default_locale() {
return _api_set_default_locale();
}
/**
* Appendix to "Encoding management functions"
*/
/**
* Returns a table with non-UTF-8 encodings for all system languages.
* @return array Returns an array in the form array('language1' => array('encoding1', encoding2', ...), ...)
* Note: The function api_get_non_utf8_encoding() returns the first encoding from this array that is correspondent to the given language.
*/
function & _api_non_utf8_encodings() {
static $encodings;
if (!isset($encodings)) {
$file = dirname(__FILE__).'/internationalization_database/non_utf8_encodings.php';
if (file_exists($file)) {
$encodings = include ($file);
} else {
$encodings = array('english' => array('ISO-8859-15'));
}
}
return $encodings;
}
/**
* Sets/Gets internal character encoding of the common string functions within the PHP mbstring extension.
* @param string $encoding (optional) When this parameter is given, the function sets the internal encoding.
@ -766,48 +365,7 @@ function & _api_non_utf8_encodings() {
*/
function _api_mb_internal_encoding($encoding = null)
{
static $mb_internal_encoding = null;
if (empty($encoding)) {
if (is_null($mb_internal_encoding)) {
if (MBSTRING_INSTALLED) {
$mb_internal_encoding = @mb_internal_encoding();
} else {
$mb_internal_encoding = 'UTF-8';
}
}
return $mb_internal_encoding;
}
$mb_internal_encoding = $encoding;
if (_api_mb_supports($encoding)) {
return @mb_internal_encoding($encoding);
}
return false;
}
/**
* Sets/Gets internal character encoding of the regular expression functions (ereg-like) within the PHP mbstring extension.
* @param string $encoding (optional) When this parameter is given, the function sets the internal encoding.
* @return string When $encoding parameter is not given, the function returns the internal encoding.
* Note: This function is used in the global initialization script for setting the internal encoding to the platform's character set.
* @link http://php.net/manual/en/function.mb-regex-encoding
*/
function _api_mb_regex_encoding($encoding = null) {
static $mb_regex_encoding = null;
if (empty($encoding)) {
if (is_null($mb_regex_encoding)) {
if (MBSTRING_INSTALLED) {
$mb_regex_encoding = @mb_regex_encoding();
} else {
$mb_regex_encoding = 'UTF-8';
}
}
return $mb_regex_encoding;
}
$mb_regex_encoding = $encoding;
if (_api_mb_supports($encoding)) {
return @mb_regex_encoding($encoding);
}
return false;
return mb_internal_encoding($encoding);
}
/**

@ -1,18 +1,7 @@
-- MySQL dump 10.9
--
-- Host: localhost Database: chamilo_main
-- ------------------------------------------------------
-- Server version 4.1.14
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-- Don't modify this file. Edit the entities located in
-- src/Chamilo/CoreBundle/Entity
-- src/Chamilo/CourseBundle/Entity
-- src/Chamilo/UserBundle/Entity
--
-- Table structure for table user

@ -119,7 +119,7 @@ $ajax_url = api_get_path(WEB_AJAX_PATH).'message.ajax.php';
$socialAjaxUrl = api_get_path(WEB_AJAX_PATH).'social.ajax.php';
$javascriptDir = api_get_path(LIBRARY_PATH) . 'javascript/';
api_block_anonymous_users();
$locale = _api_get_locale_from_language();
$locale = api_get_language_isocode();
// Add Jquery scroll pagination plugin
$htmlHeadXtra[] = api_get_js('jscroll/jquery.jscroll.js');
// Add Jquery Time ago plugin

@ -586,7 +586,7 @@ class Wiki
$course_id = api_get_course_int_id();
// Filter no _uass
if (api_eregi('_uass', $values['title']) ||
if (api_strpos('_uass', $values['title']) === false ||
(api_strtoupper(trim($values['title'])) == 'INDEX' ||
api_strtoupper(trim(api_htmlentities($values['title'], ENT_QUOTES, $charset))) == api_strtoupper(api_htmlentities(get_lang('DefaultTitle'), ENT_QUOTES, $charset)))
) {

@ -451,6 +451,8 @@ class Version110 extends AbstractMigrationChamilo
$this->addSql("UPDATE c_student_publication_assignment SET expires_on = NULL WHERE expires_on = '0000-00-00 00:00:00'");
$this->addSql("UPDATE c_student_publication_assignment SET ends_on = NULL WHERE ends_on = '0000-00-00 00:00:00'");
$this->addSql("UPDATE settings_current SET selected_value = 'UTF-8' WHERE variable = 'platform_charset'");
}
/**

@ -619,15 +619,6 @@ class TestInternationalization extends UnitTestCase {
//var_dump($res);
}
public function test_api_is_latin1() {
$encoding = 'ISO-8859-15';
$strict = false;
$res = api_is_latin1($encoding, false);
$this->assertTrue(is_bool($res));
$this->assertTrue($res);
//var_dump($res);
}
public function test_api_get_system_encoding() {
$res = api_get_system_encoding();
$this->assertTrue(is_string($res));
@ -655,19 +646,6 @@ class TestInternationalization extends UnitTestCase {
//var_dump($res);
}
public function test_api_get_valid_encodings() {
$res = api_get_valid_encodings();
$ok = is_array($res) && !empty($res);
$this->assertTrue($ok);
if ($ok) {
foreach ($res as $value) {
$ok = $ok && is_string($value);
}
$this->assertTrue($ok);
}
//var_dump($res);
}
public function test_api_detect_encoding_html() {
$meta = '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />'."\n";
$head1 = '<head>'."\n".'<title>Sample Document</title>'."\n".'</head>'."\n";
@ -845,54 +823,6 @@ class TestInternationalization extends UnitTestCase {
//var_dump($res);
}
/**
* ----------------------------------------------------------------------------
* Language management functions
* ----------------------------------------------------------------------------
*/
public function test_api_is_language_supported() {
$language1 = 'english';
$language2 = 'english_org';
$language3 = 'EnGlIsh';
$language4 = 'EnGlIsh_oRg';
$language5 = 'french';
$language6 = 'french_corporate';
$language7 = 'frEncH';
$language8 = 'freNch_corPorAte';
$language9 = 'xxxxxxxxxxxxxx';
$res1 = api_is_language_supported($language1);
$res2 = api_is_language_supported($language2);
$res3 = api_is_language_supported($language3);
$res4 = api_is_language_supported($language4);
$res5 = api_is_language_supported($language5);
$res6 = api_is_language_supported($language6);
$res7 = api_is_language_supported($language7);
$res8 = api_is_language_supported($language8);
$res9 = api_is_language_supported($language9);
$this->assertTrue(
$res1 === true
&& $res2 === true
&& $res3 === true
&& $res4 === true
&& $res5 === true
&& $res6 === true
&& $res7 === true
&& $res8 === true
&& $res9 === false
);
//var_dump($res1);
//var_dump($res2);
//var_dump($res3);
//var_dump($res4);
//var_dump($res5);
//var_dump($res6);
//var_dump($res7);
//var_dump($res8);
//var_dump($res9);
}
public function test_api_get_valid_language() {
$enabled_languages_info = api_get_languages();
$enabled_languages = $enabled_languages_info['folder'];
@ -1027,41 +957,8 @@ class TestInternationalization extends UnitTestCase {
$res[] = api_get_text_direction($language);
}
$this->assertTrue($res === $expected_results);
//var_dump($res);
}
/*
// This test works. It has been disabled, because it is time-consuming.
public function test_api_detect_encoding() {
$strings = $this->language_strings;
$is_test_ok = true;
foreach ($strings as $language => $string) {
if (api_is_language_supported($language)) {
$is_ok = api_is_utf8(api_detect_encoding($string)); // Checking whether the input string is UTF-8.
$is_test_ok = $is_test_ok && $is_ok;
$non_utf8_encoding = api_get_non_utf8_encoding($language);
if (!empty($non_utf8_encoding) && api_is_encoding_supported($non_utf8_encoding)) {
$res = api_detect_encoding(api_utf8_decode($string, $non_utf8_encoding));
$test_string = api_utf8_encode(api_utf8_decode($string, $non_utf8_encoding), $res);
$is_ok = api_equal_encodings($non_utf8_encoding, $res) || $string == $test_string;
echo $language.'<br />';
echo $string.'<br />';
echo $test_string.'<br />';
echo ($is_ok ? '<span style="color: green; font-weight: bold;">Ok</span>' : '<span style="color: red; font-weight: bold;">Failed</span>').' '.$non_utf8_encoding.' => <strong>'.$res.'</strong><br />';
echo '<br />';
} else {
$is_ok = true;
}
$is_test_ok = $is_test_ok && $is_ok;
}
}
$this->assertTrue($is_test_ok);
}
*/
// The second function for testing api_detect_encoding().
public function test_api_detect_encoding_2() {
$string_utf8 = 'Това е тест на български език'; // Bulgarian language, UTF-8

Loading…
Cancel
Save