skala
Yannick Warnier 16 years ago
commit 64d852daf1
  1. 22
      main/admin/statistics/statistics.lib.php
  2. 38
      main/inc/global.inc.php
  3. 305
      main/inc/lib/internationalization.lib.php
  4. 79
      main/inc/lib/internationalization_internal.lib.php
  5. 214
      main/inc/lib/main_api.lib.php
  6. 6
      main/inc/lib/multibyte_string_functions.lib.php
  7. 6
      main/inc/lib/multibyte_string_functions_internal.lib.php
  8. 6
      main/inc/lib/text.lib.php
  9. 40
      main/install/index.php
  10. 4
      main/install/install_functions.inc.php

@ -249,25 +249,39 @@ class Statistics
switch($type)
{
case 'month':
$months = api_get_months_long();
$period = get_lang('PeriodMonth');
$sql = "SELECT DATE_FORMAT( login_date, '%Y %b' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table." GROUP BY stat_date ORDER BY login_date ";
$sql = "SELECT DATE_FORMAT( login_date, '%Y-%m' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table." GROUP BY stat_date ORDER BY login_date ";
break;
case 'hour':
$period = get_lang('PeriodHour');
$sql = "SELECT DATE_FORMAT( login_date, '%H' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table." GROUP BY stat_date ORDER BY stat_date ";
break;
case 'day':
$week_days = api_get_week_days_long();
$period = get_lang('PeriodDay');
$sql = "SELECT DATE_FORMAT( login_date, '%a' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table." GROUP BY stat_date ORDER BY DATE_FORMAT( login_date, '%w' ) ";
$sql = "SELECT DATE_FORMAT( login_date, '%w' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table." GROUP BY stat_date ORDER BY DATE_FORMAT( login_date, '%w' ) ";
break;
}
$res = api_sql_query($sql,__FILE__,__LINE__);
$result = array();
while($obj = Database::fetch_object($res))
{
$result[$obj->stat_date] = $obj->number_of_logins;
$stat_date = $obj->stat_date;
switch($type)
{
case 'month':
$stat_date = explode('-', $stat_date);
$stat_date[1] = $months[$stat_date[1] - 1];
$stat_date = implode(' ', $stat_date);
break;
case 'day':
$stat_date = $week_days[$stat_date];
break;
}
$result[$stat_date] = $obj->number_of_logins;
}
Statistics::print_stats(get_lang('Logins').' ('.$period.')',$result,true);
Statistics::print_stats(get_lang('Logins').' ('.$period.')', $result, true);
}
/**
* Print the number of recent logins

@ -60,44 +60,6 @@ EOM;
die($error_message_php_version);
}
if (!function_exists('mb_strlen'))
{
$error_message_mbstring = <<<EOM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>PHP extension "mbstring" has not been installed!</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css" media="screen, projection">
/*<![CDATA[*/
@import "main/css/public_admin/default.css";
/*]]>*/
</style>
</head>
<body>
<div id="header">
<div id="header1"><a href="http://www.dokeos.com" target="_blank">Dokeos Homepage</a></div>
<div class="clear"></div>
<div id="header2">&nbsp;</div>
<div id="header3">&nbsp;</div>
</div>
<div style="text-align: center;"><br /><br />
The Dokeos system needs PHP extension <strong>mbstring</strong> to be installed.<br />
See <a href="http://php.net/manual/en/mbstring.installation.php" target="_blank">http://php.net/manual/en/book.mbstring.php</a> for more information<br /><br />
</div>
<div id="footer">
<div class="copyright">Platform <a href="http://www.dokeos.com" target="_blank"> Dokeos </a> &copy; 2009 </div>
&nbsp;
</div>
</body>
</html>
EOM;
header('Content-Type: text/html; charset=UTF-8');
die($error_message_mbstring);
}
// Determine the directory path where this current file lies
// This path will be useful to include the other intialisation files

@ -0,0 +1,305 @@
<?php
/**
* ==============================================================================
* File: internationalization.lib.php
* Main API extension library for Dokeos 1.8.6+ LMS
* A library implementing internationalization related functions.
* License: GNU/GPL version 2 or later (Free Software Foundation)
* @author: Ivan Tcholakov, ivantcholakov@gmail.com
* August 2009 - initial implementation.
* @package dokeos.library
* ==============================================================================
*/
/**
* ----------------------------------------------------------------------------
* Constants
* ----------------------------------------------------------------------------
*/
// Predefined date formats in Dokeos provided by the language sub-system.
// To be used as a parameter for the function api_format_date().
define('TIME_NO_SEC_FORMAT', 0); // 15:23
define('DATE_FORMAT_SHORT', 1); // 25.08.2009
define('DATE_FORMAT_LONG', 2); // Aug 25, 09
define('DATE_TIME_FORMAT_LONG', 3); // August 25, 2009 at 03:28 PM
/**
* ----------------------------------------------------------------------------
* Language support
* ----------------------------------------------------------------------------
*/
/**
* Whenever the server type in the Dokeos Config settings is
* @param string $variable This is the identificator (name) of the translated string to be retrieved.
* @param string $notrans This parameter directs whether a link to DLTT to be shown for untranslated strings
* ($notrans = 'DLTT' means "yes", any other value means "no").
* @param string $language (optional) Language indentificator. If it is omited, the current interface language is assumed.
* @return string Returns the requested string in the correspondent language.
*
* @author Roan Embrechts
* @author Patrick Cool
* @author Ivan Tcholakov, April-August 2009 (caching functionality, additional parameter $language).
*
* Notes:
* 1. If the name of a given language variable has the prefix "lang" it may be omited,
* i.e. get_lang('langYes') == get_lang('Yes').
* 2. Whenever the server type in the Dokeos Config settings is set to
* test/development server you will get an indication that a language variable
* is not translated and a link to a suggestions form of DLTT.
* 3. DLTT means Dokeos Language Translation Tool.
* @link http://www.dokeos.com/DLTT/
*/
function get_lang($variable, $notrans = 'DLTT', $language = null) {
// We introduced the possibility to request specific language
// by the aditional parameter $language to this function.
// By manipulating this global variable the translation
// may be done in different languages too (not the elegant way).
global $language_interface;
// Because of possibility for manipulations of the global variable
// $language_interface, we need its initial value.
global $language_interface_initial_value;
// This is a cache for already translated language variables.
// By using it we will avoid repetitive translations.
static $cache = array();
// Combining both ways for requesting specific language.
if (empty($language)) {
$language = $language_interface;
}
// This is a flag for showing the link to the Dokeos Language Translation Tool
// when the requested variable has no translation within the language files.
$dltt = $notrans == 'DLTT' ? true : false;
// Cache initialization.
if (!is_array($cache[$language])) {
$cache[$language] = array(false => array(), true => array());
}
// Looking up into the cache for existing translation.
if (isset($cache[$language][$dltt][$variable])) {
// There is a previously saved translation, returning it.
return $cache[$language][$dltt][$variable];
}
// There is no saved translation, we have to extract it.
// If the language files have been reloaded, then the language
// variables should be accessed as local ones.
$seek_local_variables = false;
// We reload the language variables when the requested language is different to
// the language of the interface or when the server is in testing mode.
if ($language != $language_interface_initial_value || api_get_setting('server_type') == 'test') {
$seek_local_variables = true;
global $language_files;
$langpath = api_get_path(SYS_CODE_PATH).'lang/';
if (isset ($language_files)) {
if (!is_array($language_files)) {
@include $langpath.$language.'/'.$language_files.'.inc.php';
} else {
foreach ($language_files as $index => $language_file) {
@include $langpath.$language.'/'.$language_file.'.inc.php';
}
}
}
}
$ot = '[='; //opening tag for missing vars
$ct = '=]'; //closing tag for missing vars
if (api_get_setting('hide_dltt_markup') == 'true') {
$ot = '';
$ct = '';
}
// Translation mode for production servers.
if (api_get_setting('server_type') != 'test') {
if (!$seek_local_variables) {
$lvv = isset ($GLOBALS['lang'.$variable]) ? $GLOBALS['lang'.$variable] : (isset ($GLOBALS[$variable]) ? $GLOBALS[$variable] : $ot.$variable.$ct);
} else {
@eval('$lvv = $'.$variable.';');
if (!isset($lvv)) {
@eval('$lvv = $lang'.$variable.';');
if (!isset($lvv)) {
$lvv = $ot.$variable.$ct;
}
}
}
if (!is_string($lvv)) {
$cache[$language][$dltt][$variable] = $lvv;
return $lvv;
}
$lvv = str_replace("\\'", "'", $lvv);
$lvv = _get_lang_purify($lvv, $language);
$cache[$language][$dltt][$variable] = $lvv;
return $lvv;
}
// Translation mode for test/development servers.
if (!is_string($variable)) {
$cache[$language][$dltt][$variable] = $ot.'get_lang(?)'.$ct;
return $cache[$language][$dltt][$variable];
}
@ eval ('$langvar = $'.$variable.';'); // Note (RH): $$var doesn't work with arrays, see PHP doc
if (isset ($langvar) && is_string($langvar) && strlen($langvar) > 0) {
$langvar = str_replace("\\'", "'", $langvar);
$langvar = _get_lang_purify($langvar, $language);
$cache[$language][$dltt][$variable] = $langvar;
return $langvar;
}
@ eval ('$langvar = $lang'.$variable.';');
if (isset ($langvar) && is_string($langvar) && strlen($langvar) > 0) {
$langvar = str_replace("\\'", "'", $langvar);
$langvar = _get_lang_purify($langvar, $language);
$cache[$language][$dltt][$variable] = $langvar;
return $langvar;
}
if (!$dltt) {
$cache[$language][$dltt][$variable] = $ot.$variable.$ct;
return $cache[$language][$dltt][$variable];
}
if (!is_array($language_files)) {
$language_file = $language_files;
} else {
$language_file = implode('.inc.php', $language_files);
}
$cache[$language][$dltt][$variable] =
$ot.$variable.$ct."<a href=\"http://www.dokeos.com/DLTT/suggestion.php?file=".$language_file.".inc.php&amp;variable=$".$variable."&amp;language=".$language_interface."\" target=\"_blank\" style=\"color:#FF0000\"><strong>#</strong></a>";
return $cache[$language][$dltt][$variable];
}
/**
* 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'.
* @return string The current language of the interface.
*/
function api_get_interface_language($purified = false) {
global $language_interface;
if (empty($language_interface)) {
return 'english';
}
if ($purified) {
return api_refine_language_id($language_interface);
}
return $language_interface;
}
/**
* ----------------------------------------------------------------------------
* Date and time formats
* ----------------------------------------------------------------------------
*/
/**
* Returns formated date/time format correspondent to a given language.
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @author Christophe Gesche<gesche@ipm.ucl.ac.be>
* originally inspired from from PhpMyAdmin
* @author Ivan Tcholakov, 2009, code refactoring, adding support for predefined date/time formats.
* @param string/int $date_format The date pattern. See the php-manual about the function strftime().
* Note: For $date_format the following integer constants may be used for using predefined date/time
* formats in the Dokeos system: TIME_NO_SEC_FORMAT, DATE_FORMAT_SHORT, DATE_FORMAT_LONG, DATE_TIME_FORMAT_LONG.
* @param int $time_stamp (optional) Time as an integer value. The default value -1 means now, the function time() is called internally.
* @param string $language (optional) Language indentificator. If it is omited, the current interface language is assumed.
* @return string Returns the formatted date.
* @link http://php.net/manual/en/function.strftime.php
*/
function api_format_date($date_format, $time_stamp = -1, $language = null) {
if ($time_stamp == -1) {
$time_stamp = time();
}
if (is_int($date_format)) {
switch ($date_format) {
case TIME_NO_SEC_FORMAT:
$date_format = get_lang('timeNoSecFormat', '', $language);
break;
case DATE_FORMAT_SHORT:
$date_format = get_lang('dateFormatShort', '', $language);
break;
case DATE_FORMAT_LONG:
$date_format = get_lang('dateFormatShort', '', $language);
break;
case DATE_TIME_FORMAT_LONG:
$date_format = get_lang('dateTimeFormatLong', '', $language);
break;
default:
$date_format = get_lang('dateTimeFormatLong', '', $language);
}
}
// We replace %a %A %b %B masks of date format with translated strings.
$translated = &_api_get_day_month_names($language);
$date_format = str_replace(array('%A', '%a', '%B', '%b'),
array($translated['days_long'][(int)strftime('%w', $time_stamp)],
$translated['days_short'][(int)strftime('%w', $time_stamp)],
$translated['months_long'][(int)strftime('%m', $time_stamp) - 1],
$translated['months_short'][(int)strftime('%m', $time_stamp) - 1]),
$date_format);
return strftime($date_format, $time_stamp);
}
/**
* 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.
* @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.
*/
function api_get_week_days_short($language = null) {
$days = &_api_get_day_month_names($language);
return $days['days_short'];
}
/**
* Returns an array of translated week days.
* @param string $language (optional) Language indentificator. If it is omited, 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.
*/
function api_get_week_days_long($language = null) {
$days = &_api_get_day_month_names($language);
return $days['days_long'];
}
/**
* 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.
* @return string Returns an array of months (short names).
* Example: api_get_months_short('english') means array('Jan', 'Feb', ... 'Dec').
*/
function api_get_months_short($language = null) {
$months = &_api_get_day_month_names($language);
return $months['months_short'];
}
/**
* Returns an array of translated months.
* @param string $language (optional) Language indentificator. If it is omited, the current interface language is assumed.
* @return string Returns an array of months.
* Example: api_get_months_long('english') means array('January, 'February' ... 'December').
*/
function api_get_months_long($language = null) {
$months = &_api_get_day_month_names($language);
return $months['months_long'];
}
/**
* ----------------------------------------------------------------------------
* Functions for internal use behind this API.
* ----------------------------------------------------------------------------
*/
require_once dirname(__FILE__).'/internationalization_internal.lib.php';

@ -0,0 +1,79 @@
<?php
/**
* ==============================================================================
* File: internationalization_internal.lib.php
* Main API extension library for Dokeos 1.8.6+ LMS,
* contains functions for internal use only.
* License: GNU/GPL version 2 or later (Free Software Foundation)
* @author: Ivan Tcholakov, ivantcholakov@gmail.com, 2009
* @package dokeos.library
* ==============================================================================
*
* Note: All functions and data structures here are not to be used directly.
* See the file internationalization.lib.php which contains the "public" API.
*/
/**
* ----------------------------------------------------------------------------
* Appendix to "Language support"
* ----------------------------------------------------------------------------
*/
/**
* Upgrades the function get_lang() with the following logic:
* 1. Checks whether the retrieved human language string is UTF-8 valid or not.
* 2. If the system encoding is UTF-8 and the string is not UTF-8, the function
* performs conversion from supposed non UTF-8 encodeng.
* 3. If the system encoding is non UTF-8 but the string is valid UTF-8, then
* conversion from UTF-8 is performed.
* 4. At the end the string is purified from HTML entities.
* @param string $string This is the retrieved human language string.
* @param string $language A language identiticator.
* @return string Returns the human language string, checked for proper encodeing and purified.
*/
function & _get_lang_purify(& $string, & $language) {
$system_encoding = api_get_system_encoding();
if (api_is_utf8($system_encoding)) {
if (!api_is_valid_utf8($string)) {
$string = api_utf8_encode($string, api_get_non_utf8_encoding($language));
}
} else {
if (api_is_valid_utf8($string)) {
$string = api_utf8_decode($string, $system_encoding);
}
}
return api_html_entity_decode($string, ENT_QUOTES, $system_encoding);
}
/**
* ----------------------------------------------------------------------------
* Appendix to "Date and time formats"
* ----------------------------------------------------------------------------
*/
/**
* Returns an array of translated week days and months, short and normal names.
* @param string $language (optional) Language indentificator. If it is omited, the current interface language is assumed.
* @return string Returns a multidimensional array with translated week days and months.
*/
function &_api_get_day_month_names($language = null) {
static $date_parts = array();
if (empty($language)) {
$language = api_get_interface_language();
}
if (!isset($date_parts[$language])) {
$week_day = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
$month = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
for ($i = 0; $i < 7; $i++) {
$date_parts[$language]['days_short'][] = get_lang($week_day[$i].'Short', '', $language);
$date_parts[$language]['days_long'][] = get_lang($week_day[$i].'Long', '', $language);
}
for ($i = 0; $i < 12; $i++) {
$date_parts[$language]['months_short'][] = get_lang($month[$i].'Short', '', $language);
$date_parts[$language]['months_long'][] = get_lang($month[$i].'Long', '', $language);
}
}
return $date_parts[$language];
}

@ -199,6 +199,7 @@ define('LOG_CONFIGURATION_SETTINGS_VARIABLE', 'settings_variable');
*/
require_once dirname(__FILE__).'/multibyte_string_functions.lib.php';
require_once dirname(__FILE__).'/internationalization.lib.php';
/*
==============================================================================
@ -1062,26 +1063,21 @@ function domesticate($input) {
* @author Noel Dieschburg
* @param the int status code
*/
function get_status_from_code($status_code)
{
switch ($status_code) {
case STUDENT:
return get_lang('Student');
case TEACHER:
return get_lang('Teacher');
case COURSEMANAGER:
return get_lang('Manager');
case SESSIONADMIN:
return get_lang('SessionsAdmin');
case DRH:
return get_lang('Drh');
}
function get_status_from_code($status_code) {
switch ($status_code) {
case STUDENT:
return get_lang('Student');
case TEACHER:
return get_lang('Teacher');
case COURSEMANAGER:
return get_lang('Manager');
case SESSIONADMIN:
return get_lang('SessionsAdmin');
case DRH:
return get_lang('Drh');
}
}
/*
==============================================================================
FAILURE MANAGEMENT
@ -1266,192 +1262,12 @@ function api_get_self() {
return htmlentities($_SERVER['PHP_SELF']);
}
/*
==============================================================================
LANGUAGE SUPPORT
==============================================================================
*/
/**
* Whenever the server type in the Dokeos Config settings is
* set to test/development server you will get an indication that a language variable
* is not translated and a link to a suggestions form of DLTT.
*
* @return language variable '$lang'.$variable or language variable $variable.
*
* @author Roan Embrechts
* @author Patrick Cool
* Reworked by Ivan Tcholakov, APR-2009
*/
function get_lang($variable, $notrans = 'DLTT', $language = null) {
// We introduce the possibility to request specific language
// by the aditional parameter $language to this function.
// By manipulating this global variable the translation
// may be done in different languages too (not the elegant way).
global $language_interface;
// Because of possibility for manipulations of the global variable
// $language_interface, we need its initial value.
global $language_interface_initial_value;
// This is a cache for already translated language variables.
// By using it we will avoid repetitive translations.
static $cache = array();
// Combining both ways for requesting specific language.
if (empty($language))
{
$language = $language_interface;
}
// This is a flag for showing the link to the Dokeos Language Translation Tool
// when the requested variable has no translation within the language files.
$dltt = $notrans == 'DLTT' ? true : false;
// Cache initialization.
if (!is_array($cache[$language]))
{
$cache[$language] = array(false => array(), true => array());
}
// Looking up into the cache for existing translation.
if (isset($cache[$language][$dltt][$variable])) {
// There is a previously saved translation, returning it.
return $cache[$language][$dltt][$variable];
}
// There is no saved translation, we have to extract it.
// If the language files have been reloaded, then the language
// variables should be accessed as local ones.
$seek_local_variables = false;
// We reload the language variables when the requested language is different to
// the language of the interface or when the server is in testing mode.
if ($language != $language_interface_initial_value || api_get_setting('server_type') == 'test') {
$seek_local_variables = true;
global $language_files;
$langpath = api_get_path(SYS_CODE_PATH).'lang/';
if (isset ($language_files)) {
if (!is_array($language_files)) {
@include $langpath.$language.'/'.$language_files.'.inc.php';
} else {
foreach ($language_files as $index => $language_file) {
@include $langpath.$language.'/'.$language_file.'.inc.php';
}
}
}
}
$ot = '[='; //opening tag for missing vars
$ct = '=]'; //closing tag for missing vars
if (api_get_setting('hide_dltt_markup') == 'true') {
$ot = '';
$ct = '';
}
// Translation mode for production servers.
if (api_get_setting('server_type') != 'test') {
if (!$seek_local_variables) {
$lvv = isset ($GLOBALS['lang'.$variable]) ? $GLOBALS['lang'.$variable] : (isset ($GLOBALS[$variable]) ? $GLOBALS[$variable] : $ot.$variable.$ct);
} else {
@eval('$lvv = $'.$variable.';');
if (!isset($lvv)) {
@eval('$lvv = $lang'.$variable.';');
if (!isset($lvv)) {
$lvv = $ot.$variable.$ct;
}
}
}
if (!is_string($lvv)) {
$cache[$language][$dltt][$variable] = $lvv;
return $lvv;
}
$lvv = str_replace("\\'", "'", $lvv);
$lvv = get_lang_to_system_encoding($lvv, $language);
$cache[$language][$dltt][$variable] = $lvv;
return $lvv;
}
// Translation mode for test/development servers.
if (!is_string($variable)) {
$cache[$language][$dltt][$variable] = $ot.'get_lang(?)'.$ct;
return $cache[$language][$dltt][$variable];
}
@ eval ('$langvar = $'.$variable.';'); // Note (RH): $$var doesn't work with arrays, see PHP doc
if (isset ($langvar) && is_string($langvar) && strlen($langvar) > 0) {
$langvar = str_replace("\\'", "'", $langvar);
$langvar = get_lang_to_system_encoding($langvar, $language);
$cache[$language][$dltt][$variable] = $langvar;
return $langvar;
}
@ eval ('$langvar = $lang'.$variable.';');
if (isset ($langvar) && is_string($langvar) && strlen($langvar) > 0) {
$langvar = str_replace("\\'", "'", $langvar);
$langvar = get_lang_to_system_encoding($langvar, $language);
$cache[$language][$dltt][$variable] = $langvar;
return $langvar;
}
if (!$dltt) {
$cache[$language][$dltt][$variable] = $ot.$variable.$ct;
return $cache[$language][$dltt][$variable];
}
if (!is_array($language_files)) {
$language_file = $language_files;
} else {
$language_file = implode('.inc.php',$language_files);
}
$cache[$language][$dltt][$variable] =
$ot.$variable.$ct."<a href=\"http://www.dokeos.com/DLTT/suggestion.php?file=".$language_file.".inc.php&amp;variable=$".$variable."&amp;language=".$language_interface."\" target=\"_blank\" style=\"color:#FF0000\"><strong>#</strong></a>";
return $cache[$language][$dltt][$variable];
}
// Coverting encoding of a translated string to the system's encoding.
// This is needed when the system has been set to use UTF-8 encoding
// with non-UTF-8 language files and vice versa.
// Also htmlentities are converted into normal characters.
// This API function is for internal use. Only get_lang should call it.
function & get_lang_to_system_encoding(& $string, $language) {
$charset = api_get_system_encoding();
if (api_is_utf8($charset)) {
if (!api_is_valid_utf8($string)) {
$string = api_utf8_encode($string, api_get_non_utf8_encoding($language));
}
} else {
if (api_is_valid_utf8($string)) {
$string = api_utf8_decode($string, $charset);
}
}
$string = api_html_entity_decode($string, ENT_QUOTES, $charset);
return $string;
}
/**
* Gets the current interface language
* @param bool $purified 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) {
global $language_interface;
if (empty($language_interface)) {
return 'english';
}
if ($purified) {
return api_refine_language_id($language_interface);
}
return $language_interface;
}
/*
==============================================================================
USER PERMISSIONS
==============================================================================
*/
/**
* Check if current user is a platform administrator
* @return boolean True if the user has platform admin rights,

@ -9,7 +9,7 @@
* October 2008 - initial implementation.
* May 2009 - refactoring and minor corrections have been implemented.
* August 2009 - PCRE-related functions have been added,
* dependancy on mbstring extension has been lowered.
* dependancy on mbstring extension has been removed.
* @package dokeos.library
* ==============================================================================
*/
@ -1149,7 +1149,7 @@ function api_strtolower($string, $encoding = null) {
$matched = true;
} else {
$matched = false;
$properties = _api_utf8_get_letter_case_properties($codepoint, 'upper');
$properties = &_api_utf8_get_letter_case_properties($codepoint, 'upper');
if (!empty($properties)) {
foreach ($properties as $key => $value) {
if ($properties[$key]['upper'] == $codepoint && count($properties[$key]['lower'][0]) === 1) {
@ -1215,7 +1215,7 @@ function api_strtoupper($string, $encoding = null) {
$matched = true;
} else {
$matched = false;
$properties = _api_utf8_get_letter_case_properties($codepoint);
$properties = &_api_utf8_get_letter_case_properties($codepoint);
$property_count = count($properties);
if (!empty($properties)) {
foreach ($properties as $key => $value) {

@ -61,13 +61,13 @@ function _api_convert_encoding($string, $to_encoding, $from_encoding) {
return $string;
}
if (!isset($character_map[$to])) {
$character_map[$to] = _api_parse_character_map($to);
$character_map[$to] = &_api_parse_character_map($to);
}
if ($character_map[$to] === false) {
return $string;
}
if (!isset($character_map[$from])) {
$character_map[$from] = _api_parse_character_map($from);
$character_map[$from] = &_api_parse_character_map($from);
}
if ($character_map[$from] === false) {
return $string;
@ -372,7 +372,7 @@ function _api_html_entity_from_unicode($codepoint) {
* @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') {
function &_api_utf8_get_letter_case_properties($codepoint, $type = 'lower') {
static $config = array();
static $range = array();
if (!isset($range[$codepoint])) {

@ -61,8 +61,9 @@ function make_clickable($string)
* @return the formatted date
*/
function format_locale_date($date_format, $time_stamp = -1)
function format_locale_date($date_format, $time_stamp = -1, $language = null)
{
/*
static $initialized = false;
static $days_short, $days_long, $months_short, $months_long;
@ -91,7 +92,8 @@ function format_locale_date($date_format, $time_stamp = -1)
$date = ereg_replace('%[b]', $months_short[(int)strftime('%m', $time_stamp)-1], $date);
return strftime($date, $time_stamp);
*/
return api_format_date($date_format, $time_stamp, $language);
} // end function format_locale_date

@ -62,46 +62,6 @@ EOM;
die($error_message_php_version);
}
if (!function_exists('mb_strlen')) {
$error_message_mbstring = <<<EOM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>PHP extension "mbstring" has not been installed!</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css" media="screen, projection">
/*<![CDATA[*/
@import "../css/public_admin/default.css";
/*]]>*/
</style>
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="header1"><a href="http://www.dokeos.com" target="_blank">Dokeos Homepage</a></div>
<div class="clear"></div>
<div id="header2">&nbsp;</div>
<div id="header3">&nbsp;</div>
</div>
<div style="text-align: center;"><br /><br />
The Dokeos system needs PHP extension <strong>mbstring</strong> to be installed.<br />
See <a href="http://php.net/manual/en/mbstring.installation.php" target="_blank">http://php.net/manual/en/book.mbstring.php</a> for more information<br /><br />
</div>
<div id="push"></div>
</div>
<div id="footer">
<div class="copyright">Platform <a href="http://www.dokeos.com" target="_blank"> Dokeos </a> &copy; 2009 </div>
&nbsp;
</div>
</body>
</html>
EOM;
header('Content-Type: text/html; charset=UTF-8');
die($error_message_mbstring);
}
/*
==============================================================================
INIT SECTION

@ -426,8 +426,8 @@ function display_requirements($installType, $badUpdatePath, $updatePath='', $upd
<td class="requirements-value">'.check_extension('xml', get_lang('Yes'), get_lang('No')).'</td>
</tr>
<tr>
<td class="requirements-item"><a href="http://php.net/manual/en/book.mbstring.php" target="_blank">Multibyte string</a> '.get_lang('support').'</td>
<td class="requirements-value">'.check_extension('mbstring', get_lang('Yes'), get_lang('ExtensionMBStringNotAvailable')).'</td>
<td class="requirements-item"><a href="http://php.net/manual/en/book.mbstring.php" target="_blank">Multibyte string</a> '.get_lang('support').' ('.get_lang('Optional').')</td>
<td class="requirements-value">'.check_extension('mbstring', get_lang('Yes'), get_lang('ExtensionMBStringNotAvailable'), true).'</td>
</tr>
<tr>
<td class="requirements-item"><a href="http://php.net/manual/en/book.iconv.php" target="_blank">Iconv</a> '.get_lang('support').' ('.get_lang('Optional').')</td>

Loading…
Cancel
Save