* @verbatim
* name = Forum
* description = Enables threaded discussions about general topics.
* dependencies[] = taxonomy
* dependencies[] = comment
* package = Core - optional
* version = VERSION
* @endverbatim
*
*
* @param string $filename
* The file we are parsing. Accepts file with relative or absolute path.
*
* @return
* The info array
*/
function api_parse_info_file($filename)
{
$info = [];
if (!file_exists($filename)) {
return $info;
}
$data = file_get_contents($filename);
if (preg_match_all('
@^\s* # Start at the beginning of a line, ignoring leading whitespace
((?:
[^=;\[\]]| # Key names cannot contain equal signs, semi-colons or square brackets,
\[[^\[\]]*\] # unless they are balanced and not nested
)+?)
\s*=\s* # Key/value pairs are separated by equal signs (ignoring white-space)
(?:
("(?:[^"]|(?<=\\\\)")*")| # Double-quoted string, which may contain slash-escaped quotes/slashes
(\'(?:[^\']|(?<=\\\\)\')*\')| # Single-quoted string, which may contain slash-escaped quotes/slashes
([^\r\n]*?) # Non-quoted string
)\s*$ # Stop at the next end of a line, ignoring trailing whitespace
@msx', $data, $matches, PREG_SET_ORDER)) {
$key = $value1 = $value2 = $value3 = '';
foreach ($matches as $match) {
// Fetch the key and value string.
$i = 0;
foreach (['key', 'value1', 'value2', 'value3'] as $var) {
$$var = isset($match[++$i]) ? $match[$i] : '';
}
$value = stripslashes(substr($value1, 1, -1)).stripslashes(substr($value2, 1, -1)).$value3;
// Parse array syntax.
$keys = preg_split('/\]?\[/', rtrim($key, ']'));
$last = array_pop($keys);
$parent = &$info;
// Create nested arrays.
foreach ($keys as $key) {
if ('' == $key) {
$key = count($parent);
}
if (!isset($parent[$key]) || !is_array($parent[$key])) {
$parent[$key] = [];
}
$parent = &$parent[$key];
}
// Handle PHP constants.
if (defined($value)) {
$value = constant($value);
}
// Insert actual value.
if ('' == $last) {
$last = count($parent);
}
$parent[$last] = $value;
}
}
return $info;
}
/**
* Gets Chamilo version from the configuration files.
*
* @return string A string of type "1.8.4", or an empty string if the version could not be found
*/
function api_get_version()
{
return (string) api_get_configuration_value('system_version');
}
/**
* Gets the software name (the name/brand of the Chamilo-based customized system).
*
* @return string
*/
function api_get_software_name()
{
$name = api_get_configuration_value('software_name');
if (!empty($name)) {
return $name;
} else {
return 'Chamilo';
}
}
function api_get_status_list()
{
$list = [];
// Table of status
$list[COURSEMANAGER] = 'teacher'; // 1
$list[SESSIONADMIN] = 'session_admin'; // 3
$list[DRH] = 'drh'; // 4
$list[STUDENT] = 'user'; // 5
$list[ANONYMOUS] = 'anonymous'; // 6
$list[INVITEE] = 'invited'; // 20
return $list;
}
/**
* Checks whether status given in parameter exists in the platform.
*
* @param mixed the status (can be either int either string)
*
* @return bool if the status exists, else returns false
*/
function api_status_exists($status_asked)
{
$list = api_get_status_list();
return in_array($status_asked, $list) ? true : isset($list[$status_asked]);
}
/**
* Checks whether status given in parameter exists in the platform. The function
* returns the status ID or false if it does not exist, but given the fact there
* is no "0" status, the return value can be checked against
* if(api_status_key()) to know if it exists.
*
* @param mixed The status (can be either int or string)
*
* @return mixed Status ID if exists, false otherwise
*/
function api_status_key($status)
{
$list = api_get_status_list();
return isset($list[$status]) ? $status : array_search($status, $list);
}
/**
* Gets the status langvars list.
*
* @return string[] the list of status with their translations
*/
function api_get_status_langvars()
{
return [
COURSEMANAGER => get_lang('Teacher'),
SESSIONADMIN => get_lang('SessionsAdmin'),
DRH => get_lang('Human Resources Manager'),
STUDENT => get_lang('Learner'),
ANONYMOUS => get_lang('Anonymous'),
STUDENT_BOSS => get_lang('RoleStudentBoss'),
INVITEE => get_lang('Invited'),
];
}
/**
* The function that retrieves all the possible settings for a certain config setting.
*
* @author Patrick Cool Some string
Une chaîne
* @param string $language The language in which we want to get the * * @throws Exception * * @return string The filtered string in the given language, or the full string if no translated string was identified */ function api_get_filtered_multilingual_HTML_string($htmlString, $language = null) { if (api_get_configuration_value('translate_html') != true) { return $htmlString; } $userInfo = api_get_user_info(); $languageId = 0; if (!empty($language)) { $languageId = api_get_language_id($language); } elseif (!empty($userInfo['language'])) { $languageId = api_get_language_id($userInfo['language']); } $languageInfo = api_get_language_info($languageId); $isoCode = 'en'; if (!empty($languageInfo)) { $isoCode = $languageInfo['isocode']; } // Split HTML in the separate language strings // Note: some strings might look like...
but others might be like combine 2 in 1
if (!preg_match('/