* @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.
* 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)
* @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
* 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.
* 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.
@ -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.
* @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 stringReturns a string with the first character capitalized, if that character is alphabetic.
* @return stringReturns 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 $stringThe input string.
* @param string $stringThe 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 stringReturns the modified string.
* @return stringReturns 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.
* 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 $patternThe pattern to search for, as a string.
* @param string $patternThe pattern to search for, as a string.
* @param string $subjectThe input string.
* @param string $subjectThe 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
* Performs string comparison, case insensitive, language sensitive, with extended multibyte support.
* Performs string comparison, case insensitive, language sensitive, with extended multibyte support.
* @param string $string1The first string.
* @param string $string1The first string.
* @param string $string2The second string.
* @param string $string2The 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 intReturns <0if$string1islessthan$string2;> 0 if $string1 is greater than $string2; and 0 if the strings are equal.
* @return intReturns <0if$string1islessthan$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.