* @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 $language (optional) Language identificator. If it is omited, the current interface language is assumed.
* @param string|int Date format (see date formats in the Chamilo system:
* TIME_NO_SEC_FORMAT,
* 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.
@ -686,7 +698,6 @@ function date_to_str_ago($date, $timeZone = 'UTC')
}
$getOldTimezone = api_get_timezone();
$isoCode = api_get_language_isocode();
if ($isoCode == 'pt') {
$isoCode = 'pt-BR';
@ -735,7 +746,8 @@ function api_get_week_days_short($language = null)
/**
* 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,
* 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.
@ -748,7 +760,8 @@ function api_get_week_days_long($language = null)
/**
* 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.
* 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').
*/
@ -760,7 +773,8 @@ function api_get_months_short($language = null)
/**
* 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.
* 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 $last_name The last name of the person.
* @param string $title The title of the person.
* @param int|string $format (optional) The person name format. It may be a pattern-string (for example '%t %l, %f' or '%T %F %L', ...) or some of the constants PERSON_NAME_COMMON_CONVENTION (default), PERSON_NAME_WESTERN_ORDER, PERSON_NAME_EASTERN_ORDER, PERSON_NAME_LIBRARY_ORDER.
* @param string $language (optional) The language 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.
* @param int|string $format (optional) The person name format.
* It may be a pattern-string (for example '%t %l, %f' or '%T %F %L', ...) or
* some of the constants
* PERSON_NAME_COMMON_CONVENTION (default),
* PERSON_NAME_WESTERN_ORDER,
* PERSON_NAME_EASTERN_ORDER,
* PERSON_NAME_LIBRARY_ORDER.
* @param string $language (optional)
* The language 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:
* 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 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 Ivan Tcholakov
*/
@ -804,7 +828,8 @@ function api_get_person_name(
if (empty($format)) {
$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)) {
// Do not set $setParentLanguageName because this function is called before
// 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).
* @param int|string $format (optional) The person name format. It may be a pattern-string (for example '%t. %l, %f') or some of the constants PERSON_NAME_COMMON_CONVENTION (default), PERSON_NAME_WESTERN_ORDER, PERSON_NAME_EASTERN_ORDER, PERSON_NAME_LIBRARY_ORDER.
* @param string $language (optional) The language 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.
* @param int|string $format (optional) The person name format.
* It may be a pattern-string (for example '%t. %l, %f') or some of the constants
* PERSON_NAME_COMMON_CONVENTION (default),
* PERSON_NAME_WESTERN_ORDER,
* PERSON_NAME_EASTERN_ORDER,
* PERSON_NAME_LIBRARY_ORDER.
* @param string $language (optional) The language 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
*/
function api_is_western_name_order($format = null, $language = null)
* @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.
* Notes:
* If the optional split_length parameter is specified, the returned array will be broken down into chunks
* 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 $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 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.
* @param int $offset The position in $haystack to start searching from.
* If it is omitted, searching starts from the beginning.
* @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.
* This function is aimed at replacing the functions stripos() and mb_stripos() for human-language strings.
* Finds first occurrence of a string within another, case insensitive.
* @param string $haystack The string from which to get the first occurrence.
* @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 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 bool $before_needle (optional) Determines which portion of $haystack
* 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.
* 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 $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 from the first occurrence of $needle to the end.
* 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 $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.
@ -1340,11 +1393,12 @@ function api_strtoupper($string, $encoding = null)
}
/**
// Gets part of a string.
* // Gets part of a string.
* @param string $string The input string.
* @param int $start The first position from which the extracted part begins.
* @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
* 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.
* This function is aimed at replacing the functions substr() and mb_substr() for human-language strings.
@ -1434,7 +1488,8 @@ function api_ucwords($string, $encoding = null)
* 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 $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,
* then it is filled with the results of search (as an array).
* $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.
* @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.
* 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.
@ -1443,7 +1498,14 @@ function api_ucwords($string, $encoding = null)
* @return int|boolean Returns the number of times pattern matches or FALSE if an error occurred.