Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

remotes/angel/1.11.x
Yannick Warnier 8 years ago
commit 93bab070da
  1. 1
      .codeclimate.yml
  2. 1
      .scrutinizer.yml
  3. 341
      main/inc/lib/internationalization.lib.php
  4. 11
      main/install/configuration.dist.php
  5. 1
      main/template/default/agenda/month.tpl
  6. 2756
      main/wiki/wiki.inc.php

@ -66,6 +66,7 @@ exclude_paths:
- plugin/pens/lib - plugin/pens/lib
- plugin/bbb/lib/bbb_api.php - plugin/bbb/lib/bbb_api.php
- plugin/ims_lti/OAuthSimple.php - plugin/ims_lti/OAuthSimple.php
- plugin/sepe/src/wsse/
- tests/ - tests/
- vendor/ - vendor/
- web/ - web/

@ -169,6 +169,7 @@ filter:
- 'plugin/pens/lib/' - 'plugin/pens/lib/'
- 'plugin/bbb/lib/bbb_api.php' - 'plugin/bbb/lib/bbb_api.php'
- 'plugin/ims_lti/OAuthSimple.php' - 'plugin/ims_lti/OAuthSimple.php'
- 'plugin/sepe/src/wsse/*'
- 'tests/*' - 'tests/*'
- 'vendor/*' - 'vendor/*'
- 'web/*' - 'web/*'

@ -78,14 +78,15 @@ define('PERSON_NAME_DATA_EXPORT', PERSON_NAME_EASTERN_ORDER);
* 3. Translations are created many contributors through using a special tool: Chamilo Translation Application. * 3. Translations are created many contributors through using a special tool: Chamilo Translation Application.
* @link http://translate.chamilo.org/ * @link http://translate.chamilo.org/
*/ */
function get_lang($variable, $reserved = null, $language = null) { function get_lang($variable, $reserved = null, $language = null)
global {
// For serving some old hacks: // For serving some old hacks:
// By manipulating this global variable the translation may be done in different languages too (not the elegant way). // By manipulating this global variable the translation may
$language_interface, // be done in different languages too (not the elegant way).
// Because of possibility for manipulations of the global variable $language_interface, we need its initial value. global $language_interface;
$language_interface_initial_value; // Because of possibility for manipulations of the global
// variable $language_interface, we need its initial value.
global $language_interface_initial_value;
global $used_lang_vars, $_configuration; global $used_lang_vars, $_configuration;
// add language_measure_frequency to your main/inc/conf/configuration.php in order to generate language // add language_measure_frequency to your main/inc/conf/configuration.php in order to generate language
// variables frequency measurements (you can then see them trhough main/cron/lang/langstats.php) // variables frequency measurements (you can then see them trhough main/cron/lang/langstats.php)
@ -213,7 +214,7 @@ function api_get_interface_language(
/** /**
* Returns a purified language id, without possible suffixes that will disturb language identification in certain cases. * Returns a purified language id, without possible suffixes that will disturb language identification in certain cases.
* @param string $language The input language identificator, for example 'french_unicode'. * @param string $language The input language identificator, for example 'french_unicode'.
* @param string The same purified or filtered language identificator, for example 'french'. * @param string The same purified or filtered language id, for example 'french'.
* @return string * @return string
*/ */
function api_purify_language_id($language) function api_purify_language_id($language)
@ -377,7 +378,10 @@ function api_get_timezone()
if ($use_users_timezone === 'true') { if ($use_users_timezone === 'true') {
$userId = api_get_user_id(); $userId = api_get_user_id();
// Get the timezone based on user preference, if it exists // Get the timezone based on user preference, if it exists
$timezone_user = UserManager::get_extra_user_data_by_field($userId, 'timezone'); $timezone_user = UserManager::get_extra_user_data_by_field(
$userId,
'timezone'
);
if (isset($timezone_user['timezone']) && $timezone_user['timezone'] != null) { if (isset($timezone_user['timezone']) && $timezone_user['timezone'] != null) {
$to_timezone = $timezone_user['timezone']; $to_timezone = $timezone_user['timezone'];
} }
@ -400,8 +404,11 @@ function api_get_timezone()
* @author Julio Montoya - Adding the 2nd parameter * @author Julio Montoya - Adding the 2nd parameter
* @author Guillaume Viguier <guillaume.viguier@beeznest.com> * @author Guillaume Viguier <guillaume.viguier@beeznest.com>
*/ */
function api_get_utc_datetime($time = null, $return_null_if_invalid_date = false, $returnObj = false) function api_get_utc_datetime(
{ $time = null,
$return_null_if_invalid_date = false,
$returnObj = false
) {
$from_timezone = api_get_timezone(); $from_timezone = api_get_timezone();
$to_timezone = 'UTC'; $to_timezone = 'UTC';
if (is_null($time) || empty($time) || $time === '0000-00-00 00:00:00') { if (is_null($time) || empty($time) || $time === '0000-00-00 00:00:00') {
@ -524,9 +531,14 @@ function api_strtotime($time, $timezone = null)
* @author Guillaume Viguier <guillaume.viguier@beeznest.com> * @author Guillaume Viguier <guillaume.viguier@beeznest.com>
* *
* @param mixed Timestamp or datetime string * @param mixed Timestamp or datetime string
* @param mixed Date format (string or int; see date formats in the Chamilo system: TIME_NO_SEC_FORMAT, DATE_FORMAT_SHORT, DATE_FORMAT_LONG, DATE_TIME_FORMAT_LONG) * @param string|int Date format (see date formats in the Chamilo system:
* @param string $language (optional) Language identificator. If it is omited, the current interface language is assumed. * TIME_NO_SEC_FORMAT,
* @return string Returns the formatted date. * DATE_FORMAT_SHORT,
* DATE_FORMAT_LONG,
* DATE_TIME_FORMAT_LONG
* @param string $language (optional) Language id
* If it is omitted, the current interface language is assumed.
* @return string Returns the formatted date.
* *
* @link http://php.net/manual/en/function.strftime.php * @link http://php.net/manual/en/function.strftime.php
*/ */
@ -686,7 +698,6 @@ function date_to_str_ago($date, $timeZone = 'UTC')
} }
$getOldTimezone = api_get_timezone(); $getOldTimezone = api_get_timezone();
$isoCode = api_get_language_isocode(); $isoCode = api_get_language_isocode();
if ($isoCode == 'pt') { if ($isoCode == 'pt') {
$isoCode = 'pt-BR'; $isoCode = 'pt-BR';
@ -722,8 +733,8 @@ function api_convert_and_format_date($time = null, $format = null, $from_timezon
/** /**
* Returns an array of translated week days in short names. * Returns an array of translated week days in short names.
* @param string $language (optional) Language id. If it is omitted, 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). * @return string Returns an array of week days (short names).
* Example: api_get_week_days_short('english') means array('Sun', 'Mon', ... 'Sat'). * Example: api_get_week_days_short('english') means array('Sun', 'Mon', ... 'Sat').
* Note: For all languges returned days are in the English order. * Note: For all languges returned days are in the English order.
*/ */
@ -735,8 +746,9 @@ function api_get_week_days_short($language = null)
/** /**
* Returns an array of translated week days. * Returns an array of translated week days.
* @param string $language (optional) Language id. If it is omitted, the current interface language is assumed. * @param string $language (optional) Language id. If it is omitted,
* @return string Returns an array of week days. * 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'). * Example: api_get_week_days_long('english') means array('Sunday, 'Monday', ... 'Saturday').
* Note: For all languges returned days are in the English order. * Note: For all languges returned days are in the English order.
*/ */
@ -748,8 +760,9 @@ function api_get_week_days_long($language = null)
/** /**
* Returns an array of translated months in short names. * Returns an array of translated months in short names.
* @param string $language (optional) Language id. If it is omitted, the current interface language is assumed. * @param string $language (optional) Language id.
* @return string Returns an array of months (short names). * 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'). * Example: api_get_months_short('english') means array('Jan', 'Feb', ... 'Dec').
*/ */
function api_get_months_short($language = null) function api_get_months_short($language = null)
@ -760,7 +773,8 @@ function api_get_months_short($language = null)
/** /**
* Returns an array of translated months. * Returns an array of translated months.
* @param string $language (optional) Language id. If it is omitted, 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. * @return string Returns an array of months.
* Example: api_get_months_long('english') means array('January, 'February' ... 'December'). * Example: api_get_months_long('english') means array('January, 'February' ... 'December').
*/ */
@ -779,15 +793,25 @@ function api_get_months_long($language = null)
* @param string $first_name The first name of the person. * @param string $first_name The first name of the person.
* @param string $last_name The last name of the person. * @param string $last_name The last name of the person.
* @param string $title The title 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 int|string $format (optional) The person name format.
* @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. * It may be a pattern-string (for example '%t %l, %f' or '%T %F %L', ...) or
* @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. * some of the constants
* @return bool The result is sort of full name of the person. * PERSON_NAME_COMMON_CONVENTION (default),
* PERSON_NAME_WESTERN_ORDER,
* PERSON_NAME_EASTERN_ORDER,
* PERSON_NAME_LIBRARY_ORDER.
* @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: * Sample results:
* Peter Ustinoff or Dr. Peter Ustinoff - the Western order * Peter Ustinoff or Dr. Peter Ustinoff - the Western order
* Ustinoff Peter or Dr. Ustinoff Peter - the Eastern order * Ustinoff Peter or Dr. Ustinoff Peter - the Eastern order
* Ustinoff, Peter or - Dr. Ustinoff, Peter - the library order * Ustinoff, Peter or - Dr. Ustinoff, Peter - the library order
* Note: See the file chamilo/main/inc/lib/internationalization_database/name_order_conventions.php where you can revise the convention for your language. * Note: See the file main/inc/lib/internationalization_database/name_order_conventions.php
* where you can check the convention for your language.
* @author Carlos Vargas <carlos.vargas@dokeos.com> - initial implementation. * @author Carlos Vargas <carlos.vargas@dokeos.com> - initial implementation.
* @author Ivan Tcholakov * @author Ivan Tcholakov
*/ */
@ -804,7 +828,8 @@ function api_get_person_name(
if (empty($format)) { if (empty($format)) {
$format = PERSON_NAME_COMMON_CONVENTION; $format = PERSON_NAME_COMMON_CONVENTION;
} }
//We check if the language is supported, otherwise we check the interface language of the parent language of sublanguage // We check if the language is supported, otherwise we check the
// interface language of the parent language of sublanguage
if (empty($language)) { if (empty($language)) {
// Do not set $setParentLanguageName because this function is called before // Do not set $setParentLanguageName because this function is called before
// the main language is loaded in global.inc.php // the main language is loaded in global.inc.php
@ -877,10 +902,19 @@ function api_get_person_name(
/** /**
* Checks whether a given format represents person name in Western order (for which first name is first). * 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 int|string $format (optional) The person name format.
* @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. * It may be a pattern-string (for example '%t. %l, %f') or some of the constants
* @return bool The result TRUE means that the order is first_name last_name, FALSE means last_name first_name. * PERSON_NAME_COMMON_CONVENTION (default),
* Note: You may use this function for determining the order of the fields or columns "First name" and "Last name" in forms, tables and reports. * PERSON_NAME_WESTERN_ORDER,
* PERSON_NAME_EASTERN_ORDER,
* PERSON_NAME_LIBRARY_ORDER.
* @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 determining the order of the fields or
* columns "First name" and "Last name" in forms, tables and reports.
* @author Ivan Tcholakov * @author Ivan Tcholakov
*/ */
function api_is_western_name_order($format = null, $language = null) function api_is_western_name_order($format = null, $language = null)
@ -901,15 +935,19 @@ 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". * Returns a directive for sorting person names depending on a given language
* @param string $language (optional) The input language. If it is omitted, the current interface language is assumed. * and based on the options in the internationalization "database".
* @return bool Returns boolean value. TRUE means ORDER BY first_name, last_name; FALSE means ORDER BY last_name, first_name. * @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: * Note: You may use this function:
* 2. for constructing the ORDER clause of SQL queries, related to first_name and last_name; * 2. for constructing the ORDER clause of SQL queries, related to first_name and last_name;
* 3. for adjusting php-implemented sorting in tables and reports. * 3. for adjusting php-implemented sorting in tables and reports.
* @author Ivan Tcholakov * @author Ivan Tcholakov
*/ */
function api_sort_by_first_name($language = null) { function api_sort_by_first_name($language = null)
{
$userNameSortBy = api_get_setting('user_name_sort_by'); $userNameSortBy = api_get_setting('user_name_sort_by');
if (!empty($userNameSortBy) && in_array($userNameSortBy, array('firstname', 'lastname'))) { if (!empty($userNameSortBy) && in_array($userNameSortBy, array('firstname', 'lastname'))) {
return $userNameSortBy == 'firstname' ? true : false; return $userNameSortBy == 'firstname' ? true : false;
@ -1031,7 +1069,8 @@ function api_htmlentities($string, $quote_style = ENT_COMPAT, $encoding = 'UTF-8
* This function is aimed at replacing the function html_entity_decode() for human-language strings. * This function is aimed at replacing the function html_entity_decode() for human-language strings.
* @link http://php.net/html_entity_decode * @link http://php.net/html_entity_decode
*/ */
function api_html_entity_decode($string, $quote_style = ENT_COMPAT, $encoding = 'UTF-8') { function api_html_entity_decode($string, $quote_style = ENT_COMPAT, $encoding = 'UTF-8')
{
if (empty($encoding)) { if (empty($encoding)) {
$encoding = _api_mb_internal_encoding(); $encoding = _api_mb_internal_encoding();
} }
@ -1080,8 +1119,8 @@ function api_xml_http_response_encode($string, $from_encoding = 'UTF8')
* The output should be: Fyodor Mihaylovich Dostoevkiy * The output should be: Fyodor Mihaylovich Dostoevkiy
* *
* @param string $string The input string. * @param string $string The input string.
* @param string $unknown (optional) Replacement character for unknown characters and illegal UTF-8 sequences. * @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. * @param string $from_encoding (optional) The encoding of the input string.
* If it is omitted, the platform character set is assumed. * If it is omitted, the platform character set is assumed.
* @return string Plain ASCII output. * @return string Plain ASCII output.
* *
@ -1094,7 +1133,8 @@ function api_transliterate($string, $unknown = '?', $from_encoding = null)
/** /**
* Takes the first character in a string and returns its Unicode codepoint. * Takes the first character in a string and returns its Unicode codepoint.
* @param string $character The input string. * @param string $character The input string.
* @param string $encoding (optional) The encoding of the input string. If it is omitted, the platform character set will be used by default. * @param string $encoding (optional) The encoding of the input string.
* If it is omitted, the platform character set will be used by default.
* @return int Returns: the codepoint of the first character; or 0xFFFD (unknown character) when the input string is empty. * @return int Returns: the codepoint of the first character; or 0xFFFD (unknown character) when the input string is empty.
* This is a multibyte aware version of the function ord(). * This is a multibyte aware version of the function ord().
* @link http://php.net/manual/en/function.ord.php * @link http://php.net/manual/en/function.ord.php
@ -1106,17 +1146,21 @@ function api_ord($character, $encoding = 'UTF-8')
} }
/** /**
* This function returns a string or an array with all occurrences of search in subject (ignoring case) replaced with the given replace value. * 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 $search String or array of strings to be found.
* @param mixed $replace String or array of strings used for replacement. * @param mixed $replace String or array of strings used for replacement.
* @param mixed $subject String or array of strings being searched. * @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 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. * @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. * If it is omitted, the platform character set will be used by default.
* @return mixed String or array as a result. * @return mixed String or array as a result.
* Notes: * Notes:
* If $subject is an array, then the search and replace is performed with every entry of subject, the return value is an array. * If $subject is an array, then the search and replace is performed with
* If $search and $replace are arrays, then the function takes a value from each array and uses it to do search and replace on subject. * every entry of subject, the return value is an array.
* If $search and $replace are arrays, then the function takes a value from
* each array and uses it to do search and replace on subject.
* If $replace has fewer values than search, then an empty string is used for the rest of replacement values. * If $replace has fewer values than search, then an empty string is used for the rest of replacement values.
* If $search is an array and $replace is a string, then this replacement string is used for every value of search. * If $search is an array and $replace is a string, then this replacement string is used for every value of search.
* This function is aimed at replacing the function str_ireplace() for human-language strings. * This function is aimed at replacing the function str_ireplace() for human-language strings.
@ -1136,7 +1180,8 @@ function api_str_ireplace($search, $replace, $subject, & $count = null, $encodin
* Converts a string to an array. * Converts a string to an array.
* @param string $string The input string. * @param string $string The input string.
* @param int $split_length Maximum character-length of the chunk, one character by default. * @param int $split_length Maximum character-length of the chunk, one character 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. * @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 The result array of chunks with the spcified length. * @return array The result array of chunks with the spcified length.
* Notes: * Notes:
* If the optional split_length parameter is specified, the returned array will be broken down into chunks * If the optional split_length parameter is specified, the returned array will be broken down into chunks
@ -1155,9 +1200,12 @@ function api_str_split($string, $split_length = 1, $encoding = null)
* Finds position of first occurrence of a string within another, case insensitive. * Finds position of first occurrence of a string within another, case insensitive.
* @param string $haystack The string from which to get the position of the first occurrence. * @param string $haystack The string from which to get the position of the first occurrence.
* @param string $needle The string to be found. * @param string $needle The string to be found.
* @param int $offset The position in $haystack to start searching from. If it is omitted, searching starts from the beginning. * @param int $offset The position in $haystack to start searching from.
* @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. * If it is omitted, searching starts from the beginning.
* @return mixed Returns the numeric position of the first occurrence of $needle in the $haystack, or FALSE if $needle is not 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.
* @return mixed Returns the numeric position of the first occurrence of
* $needle in the $haystack, or FALSE if $needle is not found.
* Note: The first character's position is 0, the second character position is 1, and so on. * Note: The first character's position is 0, the second character position is 1, and so on.
* This function is aimed at replacing the functions stripos() and mb_stripos() for human-language strings. * This function is aimed at replacing the functions stripos() and mb_stripos() for human-language strings.
* @link http://php.net/manual/en/function.stripos * @link http://php.net/manual/en/function.stripos
@ -1172,13 +1220,18 @@ function api_stripos($haystack, $needle, $offset = 0, $encoding = null)
* Finds first occurrence of a string within another, case insensitive. * Finds first occurrence of a string within another, case insensitive.
* @param string $haystack The string from which to get the first occurrence. * @param string $haystack The string from which to get the first occurrence.
* @param mixed $needle The string to be found. * @param mixed $needle The string to be found.
* @param bool $before_needle (optional) Determines which portion of $haystack this function returns. The default value is FALSE. * @param bool $before_needle (optional) Determines which portion of $haystack
* @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. * this function returns. The default value is FALSE.
* @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 Returns the portion of $haystack, or FALSE if $needle is not found. * @return mixed Returns the portion of $haystack, or FALSE if $needle is not found.
* Notes: * Notes:
* If $needle is not a string, it is converted to an integer and applied as the ordinal value (codepoint if the encoding is UTF-8) of a character. * If $needle is not a string, it is converted to an integer and applied as the
* If $before_needle is set to TRUE, the function returns all of $haystack from the beginning to the first occurrence of $needle. * ordinal value (codepoint if the encoding is UTF-8) of a character.
* If $before_needle is set to FALSE, the function returns all of $haystack from the first occurrence of $needle to the end. * If $before_needle is set to TRUE, the function returns all of $haystack
* from the beginning to the first occurrence of $needle.
* If $before_needle is set to FALSE, the function returns all of $haystack f
* rom the first occurrence of $needle to the end.
* This function is aimed at replacing the functions stristr() and mb_stristr() for human-language strings. * This function is aimed at replacing the functions stristr() and mb_stristr() for human-language strings.
* @link http://php.net/manual/en/function.stristr * @link http://php.net/manual/en/function.stristr
* @link http://php.net/manual/en/function.mb-stristr * @link http://php.net/manual/en/function.mb-stristr
@ -1340,12 +1393,13 @@ function api_strtoupper($string, $encoding = null)
} }
/** /**
// Gets part of a string. * // Gets part of a string.
* @param string $string The input string. * @param string $string The input string.
* @param int $start The first position from which the extracted part begins. * @param int $start The first position from which the extracted part begins.
* @param int $length The length in character of the extracted part. * @param int $length The length in character of the extracted part.
* @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
* @return string Returns the part of the string specified by the start and length parameters. * character encoding. If it is omitted, the platform character set will be used by default.
* @return string Returns the part of the string specified by the start and length parameters.
* Note: First character's position is 0. Second character position is 1, and so on. * Note: First character's position is 0. Second character position is 1, and so on.
* This function is aimed at replacing the functions substr() and mb_substr() for human-language strings. * This function is aimed at replacing the functions substr() and mb_substr() for human-language strings.
* @link http://php.net/manual/en/function.substr * @link http://php.net/manual/en/function.substr
@ -1361,11 +1415,11 @@ function api_substr($string, $start, $length = null, $encoding = null)
/** /**
* Counts the number of substring occurrences. * Counts the number of substring occurrences.
* @param string $haystack The string being checked. * @param string $haystack The string being checked.
* @param string $needle The string being found. * @param string $needle The string being found.
* @param string $encoding (optional) The used internally by this function character encoding. * @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. * 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. * @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 * @link http://php.net/manual/en/function.mb-substr-count.php
*/ */
function api_substr_count($haystack, $needle, $encoding = null) function api_substr_count($haystack, $needle, $encoding = null)
@ -1375,21 +1429,21 @@ function api_substr_count($haystack, $needle, $encoding = null)
/** /**
* Replaces text within a portion of a string. * Replaces text within a portion of a string.
* @param string $string The input string. * @param string $string The input string.
* @param string $replacement The replacement string. * @param string $replacement The replacement string.
* @param int $start The position from which replacing will begin. * @param int $start The position from which replacing will begin.
* Notes: * Notes:
* If $start is positive, the replacing will begin at the $start'th offset into the string. * If $start is positive, the replacing will begin at the $start'th offset into the string.
* If $start is negative, the replacing will begin at the $start'th character from the end of the string. * If $start is negative, the replacing will begin at the $start'th character from the end of the string.
* @param int $length (optional) The position where replacing will end. * @param int $length (optional) The position where replacing will end.
* Notes: * Notes:
* If given and is positive, it represents the length of the portion of the string which is to be replaced. * If given and is positive, it represents the length of the portion of the string which is to be replaced.
* If it is negative, it represents the number of characters from the end of string at which to stop replacing. * 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 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. * 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. * @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. * If it is omitted, the platform character set will be used by default.
* @return string The result string is returned. * @return string The result string is returned.
* This function is aimed at replacing the function substr_replace() for human-language strings. * This function is aimed at replacing the function substr_replace() for human-language strings.
* @link http://php.net/manual/function.substr-replace * @link http://php.net/manual/function.substr-replace
*/ */
@ -1404,10 +1458,10 @@ function api_substr_replace($string, $replacement, $start, $length = null, $enco
/** /**
* Makes a string's first character uppercase. * Makes a string's first character uppercase.
* @param string $string The input string. * @param string $string The input string.
* @param string $encoding (optional) The used internally by this function character encoding. * @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. * 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. * @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. * This function is aimed at replacing the function ucfirst() for human-language strings.
* @link http://php.net/manual/en/function.ucfirst * @link http://php.net/manual/en/function.ucfirst
*/ */
@ -1418,10 +1472,10 @@ function api_ucfirst($string, $encoding = null)
/** /**
* Uppercases the first character of each word in a string. * Uppercases the first character of each word in a string.
* @param string $string The input string. * @param string $string The input string.
* @param string $encoding (optional) The used internally by this function character encoding. * @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. * If it is omitted, the platform character set will be used by default.
* @return string Returns the modified string. * @return string Returns the modified string.
* This function is aimed at replacing the function ucwords() for human-language strings. * This function is aimed at replacing the function ucwords() for human-language strings.
* @link http://php.net/manual/en/function.ucwords * @link http://php.net/manual/en/function.ucwords
*/ */
@ -1432,18 +1486,26 @@ function api_ucwords($string, $encoding = null)
/** /**
* Performs a regular expression match, UTF-8 aware when it is applicable. * Performs a regular expression match, UTF-8 aware when it is applicable.
* @param string $pattern The pattern to search for, as a string. * @param string $pattern The pattern to search for, as a string.
* @param string $subject The input string. * @param string $subject The input string.
* @param array &$matches (optional) If matches is provided, then it is filled with the results of search (as an array). * @param array &$matches (optional) If matches is provided,
* $matches[0] will contain the text that matched the full pattern, $matches[1] will have the text that matched the first captured parenthesized subpattern, and so on. * then it is filled with the results of search (as an array).
* @param int $flags (optional) Could be PREG_OFFSET_CAPTURE. If this flag is passed, for every occurring match the appendant string offset will also be returned. * $matches[0] will contain the text that matched the full pattern, $matches[1] will have the text that matched the first captured parenthesized subpattern, and so on.
* Note that this changes the return value in an array where every element is an array consisting of the matched string at index 0 and its string offset into subject at index 1. * @param int $flags (optional) Could be PREG_OFFSET_CAPTURE. If this flag is passed, for every occurring match the appendant string offset will also be returned.
* @param int $offset (optional) Normally, the search starts from the beginning of the subject string. The optional parameter offset can be used to specify the alternate place from which to start the search. * Note that this changes the return value in an array where every element is an array consisting of the matched string at index 0 and its string offset into subject at index 1.
* @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 int $offset (optional) Normally, the search starts from the beginning of the subject string. The optional parameter offset can be used to specify the alternate place from which to start the search.
* @return int|boolean Returns the number of times pattern matches or FALSE if an error occurred. * @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|boolean Returns the number of times pattern matches or FALSE if an error occurred.
* @link http://php.net/preg_match * @link http://php.net/preg_match
*/ */
function api_preg_match($pattern, $subject, &$matches = null, $flags = 0, $offset = 0, $encoding = null) { function api_preg_match(
$pattern,
$subject,
&$matches = null,
$flags = 0,
$offset = 0,
$encoding = null
) {
if (empty($encoding)) { if (empty($encoding)) {
$encoding = _api_mb_internal_encoding(); $encoding = _api_mb_internal_encoding();
} }
@ -1452,10 +1514,10 @@ function api_preg_match($pattern, $subject, &$matches = null, $flags = 0, $offse
/** /**
* Performs a global regular expression match, UTF-8 aware when it is applicable. * Performs a global regular expression match, UTF-8 aware when it is applicable.
* @param string $pattern The pattern to search for, as a string. * @param string $pattern The pattern to search for, as a string.
* @param string $subject The input string. * @param string $subject The input string.
* @param array &$matches (optional) Array of all matches in multi-dimensional array ordered according to $flags. * @param array &$matches (optional) Array of all matches in multi-dimensional array ordered according to $flags.
* @param int $flags (optional) Can be a combination of the following flags (note that it doesn't make sense to use PREG_PATTERN_ORDER together with PREG_SET_ORDER): * @param int $flags (optional) Can be a combination of the following flags (note that it doesn't make sense to use PREG_PATTERN_ORDER together with PREG_SET_ORDER):
* PREG_PATTERN_ORDER - orders results so that $matches[0] is an array of full pattern matches, $matches[1] is an array of strings matched by the first parenthesized subpattern, and so on; * PREG_PATTERN_ORDER - orders results so that $matches[0] is an array of full pattern matches, $matches[1] is an array of strings matched by the first parenthesized subpattern, and so on;
* PREG_SET_ORDER - orders results so that $matches[0] is an array of first set of matches, $matches[1] is an array of second set of matches, and so on; * PREG_SET_ORDER - orders results so that $matches[0] is an array of first set of matches, $matches[1] is an array of second set of matches, and so on;
* PREG_OFFSET_CAPTURE - If this flag is passed, for every occurring match the appendant string offset will also be returned. Note that this changes the value of matches * PREG_OFFSET_CAPTURE - If this flag is passed, for every occurring match the appendant string offset will also be returned. Note that this changes the value of matches
@ -1489,7 +1551,8 @@ function api_preg_match_all($pattern, $subject, &$matches, $flags = PREG_PATTERN
* If matches are found, the new subject will be returned, otherwise subject will be returned unchanged or NULL if an error occurred. * 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 * @link http://php.net/preg_replace
*/ */
function api_preg_replace($pattern, $replacement, $subject, $limit = -1, &$count = 0, $encoding = null) { function api_preg_replace($pattern, $replacement, $subject, $limit = -1, &$count = 0, $encoding = null)
{
if (empty($encoding)) { if (empty($encoding)) {
$encoding = _api_mb_internal_encoding(); $encoding = _api_mb_internal_encoding();
} }
@ -1531,15 +1594,16 @@ function api_preg_split($pattern, $subject, $limit = -1, $flags = 0, $encoding =
/** /**
* Performs string comparison, case insensitive, language sensitive, with extended multibyte support. * Performs string comparison, case insensitive, language sensitive, with extended multibyte support.
* @param string $string1 The first string. * @param string $string1 The first string.
* @param string $string2 The second 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 $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. * @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 strcasecmp() for human-language strings. * This function is aimed at replacing the function strcasecmp() for human-language strings.
* @link http://php.net/manual/en/function.strcasecmp * @link http://php.net/manual/en/function.strcasecmp
*/ */
function api_strcasecmp($string1, $string2, $language = null, $encoding = null) { function api_strcasecmp($string1, $string2, $language = null, $encoding = null)
{
return api_strcmp(api_strtolower($string1, $encoding), api_strtolower($string2, $encoding), $language, $encoding); return api_strcmp(api_strtolower($string1, $encoding), api_strtolower($string2, $encoding), $language, $encoding);
} }
@ -1701,7 +1765,7 @@ function api_get_system_encoding()
/** /**
* Checks whether a specified encoding is supported by this API. * Checks whether a specified encoding is supported by this API.
* @param string $encoding The specified encoding. * @param string $encoding The specified encoding.
* @return bool Returns TRUE when the specified encoding is supported, FALSE othewise. * @return bool Returns TRUE when the specified encoding is supported, FALSE othewise.
*/ */
function api_is_encoding_supported($encoding) function api_is_encoding_supported($encoding)
{ {
@ -1714,9 +1778,9 @@ function api_is_encoding_supported($encoding)
/** /**
* Detects encoding of plain text. * Detects encoding of plain text.
* @param string $string The input text. * @param string $string The input text.
* @param string $language (optional) The language of the input text, provided if it is known. * @param string $language (optional) The language of the input text, provided if it is known.
* @return string Returns the detected encoding. * @return string Returns the detected encoding.
*/ */
function api_detect_encoding($string, $language = null) function api_detect_encoding($string, $language = null)
{ {
@ -1746,7 +1810,8 @@ function api_is_valid_utf8($string)
/** /**
* Checks whether a string contains 7-bit ASCII characters only. * Checks whether a string contains 7-bit ASCII characters only.
* @param string $string The string to be tested/validated. * @param string $string The string to be tested/validated.
* @return bool Returns TRUE when the tested string contains 7-bit ASCII characters only, FALSE othewise. * @return bool Returns TRUE when the tested string contains 7-bit
* ASCII characters only, FALSE othewise.
*/ */
function api_is_valid_ascii(&$string) function api_is_valid_ascii(&$string)
{ {
@ -1780,10 +1845,12 @@ function get_plugin_lang($variable, $pluginName) {
/** /**
* Returns an array of translated week days and months, short and normal names. * Returns an array of translated week days and months, short and normal names.
* @param string $language (optional) Language id. If it is omitted, the current interface language is assumed. * @param string $language (optional Language id. If it is omitted,
* @return array Returns a multidimensional array with translated week days and months. * 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) { function &_api_get_day_month_names($language = null)
{
static $date_parts = array(); static $date_parts = array();
if (empty($language)) { if (empty($language)) {
$language = api_get_interface_language(); $language = api_get_interface_language();
@ -1813,12 +1880,28 @@ function &_api_get_day_month_names($language = null) {
'December', 'December',
); );
for ($i = 0; $i < 7; $i++) { for ($i = 0; $i < 7; $i++) {
$date_parts[$language]['days_short'][] = get_lang($week_day[$i].'Short', '', $language); $date_parts[$language]['days_short'][] = get_lang(
$date_parts[$language]['days_long'][] = get_lang($week_day[$i].'Long', '', $language); $week_day[$i].'Short',
'',
$language
);
$date_parts[$language]['days_long'][] = get_lang(
$week_day[$i].'Long',
'',
$language
);
} }
for ($i = 0; $i < 12; $i++) { for ($i = 0; $i < 12; $i++) {
$date_parts[$language]['months_short'][] = get_lang($month[$i].'Short', '', $language); $date_parts[$language]['months_short'][] = get_lang(
$date_parts[$language]['months_long'][] = get_lang($month[$i].'Long', '', $language); $month[$i].'Short',
'',
$language
);
$date_parts[$language]['months_long'][] = get_lang(
$month[$i].'Long',
'',
$language
);
} }
} }
return $date_parts[$language]; return $date_parts[$language];
@ -1839,7 +1922,7 @@ function _api_get_person_name_convention($language, $type)
if (!isset($conventions)) { if (!isset($conventions)) {
$file = __DIR__.'/internationalization_database/name_order_conventions.php'; $file = __DIR__.'/internationalization_database/name_order_conventions.php';
if (file_exists($file)) { if (file_exists($file)) {
$conventions = include ($file); $conventions = include $file;
} else { } else {
$conventions = array( $conventions = array(
'english' => array( 'english' => array(
@ -1863,7 +1946,19 @@ function _api_get_person_name_convention($language, $type)
$replacement2 = array('%f', '%l', '%t'); $replacement2 = array('%f', '%l', '%t');
foreach (array_keys($conventions) as $key) { foreach (array_keys($conventions) as $key) {
$conventions[$key]['format'] = str_replace($search1, $replacement1, $conventions[$key]['format']); $conventions[$key]['format'] = str_replace($search1, $replacement1, $conventions[$key]['format']);
$conventions[$key]['format'] = _api_validate_person_name_format(_api_clean_person_name(str_replace('%', ' %', str_ireplace($search2, $replacement2, $conventions[$key]['format'])))); $conventions[$key]['format'] = _api_validate_person_name_format(
_api_clean_person_name(
str_replace(
'%',
' %',
str_ireplace(
$search2,
$replacement2,
$conventions[$key]['format']
)
)
)
);
$conventions[$key]['sort_by'] = strtolower($conventions[$key]['sort_by']) != 'last_name' ? true : false; $conventions[$key]['sort_by'] = strtolower($conventions[$key]['sort_by']) != 'last_name' ? true : false;
} }
} }
@ -1878,8 +1973,8 @@ function _api_get_person_name_convention($language, $type)
/** /**
* Replaces non-valid formats for person names with the default (English) format. * Replaces non-valid formats for person names with the default (English) format.
* @param string $format The input format to be verified. * @param string $format The input format to be verified.
* @return bool Returns the same format if is is valid, otherwise returns a valid English format. * @return bool Returns the same format if is is valid, otherwise returns a valid English format.
*/ */
function _api_validate_person_name_format($format) function _api_validate_person_name_format($format)
{ {
@ -1907,10 +2002,10 @@ function _api_clean_person_name($person_name)
/** /**
* This is a php-implementation of a function that is similar to mb_convert_encoding() from mbstring extension. * This is a php-implementation of a function that is similar to mb_convert_encoding() from mbstring extension.
* The function converts a given string from one to another character encoding. * The function converts a given string from one to another character encoding.
* @param string $string The string being converted. * @param string $string The string being converted.
* @param string $to_encoding The encoding that $string is being converted to. * @param string $to_encoding The encoding that $string is being converted to.
* @param string $from_encoding The encoding that $string is being converted from. * @param string $from_encoding The encoding that $string is being converted from.
* @return string Returns the converted string. * @return string Returns the converted string.
*/ */
function _api_convert_encoding(&$string, $to_encoding, $from_encoding) function _api_convert_encoding(&$string, $to_encoding, $from_encoding)
{ {
@ -1920,8 +2015,8 @@ function _api_convert_encoding(&$string, $to_encoding, $from_encoding)
/** /**
* This function determines the name of corresponding to a given encoding conversion table. * This function determines the name of corresponding to a given encoding conversion table.
* It is able to deal with some aliases of the encoding. * It is able to deal with some aliases of the encoding.
* @param string $encoding The given encoding identificator, for example 'WINDOWS-1252'. * @param string $encoding The given encoding identificator, for example 'WINDOWS-1252'.
* @return string Returns the name of the corresponding conversion table, for the same example - 'CP1252'. * @return string Returns the name of the corresponding conversion table, for the same example - 'CP1252'.
*/ */
function _api_get_character_map_name($encoding) function _api_get_character_map_name($encoding)
{ {
@ -1943,9 +2038,9 @@ function _api_get_character_map_name($encoding)
/** /**
* A reverse function from php-core function strnatcmp(), performs string comparison in reverse natural (alpha-numerical) order. * A reverse function from php-core function strnatcmp(), performs string comparison in reverse natural (alpha-numerical) order.
* @param string $string1 The first string. * @param string $string1 The first string.
* @param string $string2 The second string. * @param string $string2 The second string.
* @return int Returns 0 if $string1 = $string2; >0 if $string1 < $string2; <0 if $string1 > $string2. * @return int Returns 0 if $string1 = $string2; >0 if $string1 < $string2; <0 if $string1 > $string2.
*/ */
function _api_strnatrcmp($string1, $string2) function _api_strnatrcmp($string1, $string2)
{ {
@ -1985,7 +2080,7 @@ function _api_mb_supports($encoding)
/** /**
* Checks whether the specified encoding is supported by the PHP iconv extension. * Checks whether the specified encoding is supported by the PHP iconv extension.
* @param string $encoding The specified encoding. * @param string $encoding The specified encoding.
* @return bool Returns TRUE when the specified encoding is supported, FALSE othewise. * @return bool Returns TRUE when the specified encoding is supported, FALSE othewise.
*/ */
function _api_iconv_supports($encoding) function _api_iconv_supports($encoding)
{ {

@ -363,7 +363,7 @@ $_configuration['tracking_columns'] = [
//$_configuration['remove_session_url']= false ; //$_configuration['remove_session_url']= false ;
// //
// //
// AGENDA CONFIGURATION SETTINGS // ------ AGENDA CONFIGURATION SETTINGS
// Shows a legend in the agenda tool // Shows a legend in the agenda tool
/* /*
$_configuration['agenda_legend'] = [ $_configuration['agenda_legend'] = [
@ -382,7 +382,7 @@ $_configuration['agenda_colors'] = [
'student_publication' => '#FF8C00' 'student_publication' => '#FF8C00'
]; ];
*/ */
// // ------
// //
// Save some tool titles with HTML editor // Save some tool titles with HTML editor
// $_configuration['save_titles_as_html'] = false; // $_configuration['save_titles_as_html'] = false;
@ -413,7 +413,8 @@ $_configuration['agenda_colors'] = [
//$_configuration['allow_quiz_question_feedback'] = false; //$_configuration['allow_quiz_question_feedback'] = false;
// Show view accordion lp_category // Show view accordion lp_category
//$_configuration['lp_category_accordion'] = false; //$_configuration['lp_category_accordion'] = false;
// HTTP headers security //
// ------ HTTP headers security
// This section relates to options to increase the security of your Chamilo // This section relates to options to increase the security of your Chamilo
// portal against attacks specifically focused on HTTP headers vulnerabilities // portal against attacks specifically focused on HTTP headers vulnerabilities
// These are all disabled by default, because some of these settings might // These are all disabled by default, because some of these settings might
@ -465,7 +466,8 @@ $_configuration['agenda_colors'] = [
// information the browser includes with navigation away from a document // information the browser includes with navigation away from a document
// and should be set by all sites. // and should be set by all sites.
//$_configuration['security_referrer_policy'] = 'origin-when-cross-origin'; //$_configuration['security_referrer_policy'] = 'origin-when-cross-origin';
// HTTP headers security section ends here // ------ HTTP headers security section ends here
//
// Add answered_at field in table survey_invitation // Add answered_at field in table survey_invitation
// Requires DB change: // Requires DB change:
// ALTER TABLE c_survey_invitation ADD answered_at DATETIME DEFAULT NULL; // ALTER TABLE c_survey_invitation ADD answered_at DATETIME DEFAULT NULL;
@ -485,4 +487,3 @@ $_configuration['send_all_emails_to'] = [
'admin2@example.com', 'admin2@example.com',
] ]
];*/ ];*/

@ -287,7 +287,6 @@ $(document).ready(function() {
} else { } else {
$('#end_date').html(''); $('#end_date').html('');
} }
alert('{{ type_event_color }}');
$('#color_calendar') $('#color_calendar')
.html('{{ type_label | escape('js')}}') .html('{{ type_label | escape('js')}}')

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save