Merge with fca8018557e8b551d7fda0faad42fbc99355ff1d

skala
Ivan Tcholakov 16 years ago
commit 07973b277f
  1. 2
      main/admin/access_url_add_courses_to_url.php
  2. 2
      main/admin/statistics/statistics.lib.php
  3. 2
      main/inc/footer.inc.php
  4. 117
      main/inc/lib/internationalization.lib.php
  5. 113
      main/inc/lib/internationalization_database/name_order_conventions.php
  6. 40
      main/inc/lib/internationalization_internal.lib.php
  7. 9
      main/install/index.php
  8. 9
      main/install/install_functions.inc.php

@ -127,7 +127,7 @@ if(empty($first_letter_user))
$first_letter_course = Database::escape_string($first_letter_course);
$sql = "SELECT code, title FROM $tbl_course
WHERE title LIKE '".$first_letter_course."%' OR title LIKE '".strtolower($first_letter_course)."%'
WHERE title LIKE '".$first_letter_course."%' OR title LIKE '".api_strtolower($first_letter_course)."%'
ORDER BY title, code DESC ";
$result = api_sql_query($sql, __FILE__, __LINE__);

@ -135,7 +135,7 @@ class Statistics
$res = api_sql_query($sql, __FILE__, __LINE__);
$activities = array ();
while ($row = Database::fetch_row($res)) {
$row[4] = api_ucfirst(format_locale_date($dateTimeFormatLong,strtotime($row[4])));
$row[4] = api_format_date(DATE_TIME_FORMAT_LONG, strtotime($row[4]));
$activities[] = $row;
}
return $activities;

@ -60,7 +60,7 @@ api_plugin('footer');
if (api_get_setting('show_administrator_data')=='true') {
// Platform manager
echo '<span id="platformmanager">', get_lang('Manager'), ' : ', Display::encrypted_mailto_link(api_get_setting('emailAdministrator'), api_get_setting('administratorName').' '.api_get_setting('administratorSurname'));
echo '<span id="platformmanager">', get_lang('Manager'), ' : ', Display::encrypted_mailto_link(api_get_setting('emailAdministrator'), api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname')));
}

@ -311,69 +311,102 @@ function api_get_months_long($language = null) {
*/
/**
* Answers in what order names of a person to be shown or sorted, depending on a given language.
* @param string $language (optional) Language indentificator. If it is omited, the current interface language is assumed.
* @return bool The result TRUE means that the order shold be first_name last_name, FALSE means last_name first_name.
* Checks whether a given format represents prson 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 indentificator. If it is omited, 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:
* 1. for determing the order of the fields or columns "First name" and "Last name" in forms and tables;
* 2. for constructing the ORDER clause of SQL queries, related to first name and last name;
* 3. for adjusting php-implemented sorting by names in tables and reports.
* @author Ivan Tcholakov
*/
function api_is_western_name_order($language = null) {
function api_is_western_name_order($format = null, $language = null) {
static $order = array();
if (empty($format)) {
$format = PERSON_NAME_COMMON_CONVENTION;
}
if (empty($language)) {
$language = api_get_interface_language();
}
$language = api_refine_language_id($language);
if (!isset($order[$language])) {
$conventions = &_get_name_conventions();
$convention = $conventions[$language];
if (_api_is_valid_name_convention($convention)) {
$order[$language] = (strpos($convention, '%f') < strpos($convention, '%l'));
} else {
$order[$language] = true;
}
if (!isset($order[$format][$language])) {
$test_name = api_get_person_name('%f', '%l', '%t', $format, $language);
$order[$format][$language] = strpos($test_name, '%f') <= strpos($test_name, '%l');
}
return $order[$language];
return $order[$format][$language];
}
/**
* Builds a person (full) name depending on the convention for a given language.
* @param string $first_name The first name of the preson.
* @param string $last_name The last name of the person.
* @param string $language (optional) Language indentificator. If it is omited, the current interface language is assumed.
* @param int (optional) $option A parameter for overriding the common convention, it should be used in limited number of cases.
* Its values may be: PERSON_NAME_COMMON_CONVENTION (default), PERSON_NAME_WESTERN_ORDER, PERSON_NAME_EASTERN_ORDER, PERSON_NAME_LIBRARY_ORDER.
* @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 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 indentificator. If it is omited, the current interface language is assumed. This parameter has meaning with the format PERSON_NAME_COMMON_CONVENTION only.
* @return bool The result is sort of full name of the person.
* Sample results:
* Peter Ustinoff - the Western order
* Ustinoff Peter - the Eastern order
* Ustinoff, Peter - the library order
* Note: See the file dokeos/main/inc/lib/internationalization_database/name_order_conventions.php
* where you can revise the convention for your language.
* 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 dokeos/main/inc/lib/internationalization_database/name_order_conventions.php where you can revise the convention for your language.
* @author Carlos Vargas <carlos.vargas@dokeos.com> - initial implementation.
* @author Ivan Tcholakov
*/
function api_get_person_name($first_name, $last_name, $language = null, $option = PERSON_NAME_COMMON_CONVENTION) {
switch ($option) {
case PERSON_NAME_WESTERN_ORDER:
return $first_name . ' ' . $last_name;
case PERSON_NAME_EASTERN_ORDER:
return $last_name . ' ' . $first_name;
case PERSON_NAME_LIBRARY_ORDER:
return $last_name . ', ' . $first_name;
case PERSON_NAME_COMMON_CONVENTION:
default:
if (empty($language)) {
$language = api_get_interface_language();
}
$language = api_refine_language_id($language);
$conventions = &_get_name_conventions();
$convention = $conventions[$language];
break;
function api_get_person_name($first_name, $last_name, $title = null, $format = null, $language = null) {
static $conventions;
static $valid = array();
if (empty($format)) {
$format = PERSON_NAME_COMMON_CONVENTION;
}
if (_api_is_valid_name_convention($convention)) {
return str_replace(array('%f', '%l'), array($first_name, $last_name), $convention);
if (empty($language)) {
$language = api_get_interface_language();
}
if (!isset($valid[$format][$language])) {
if (is_int($format)) {
switch ($format) {
case PERSON_NAME_COMMON_CONVENTION:
if (!isset($conventions)) {
$file = dirname(__FILE__) . '/internationalization_database/name_order_conventions.php';
if (file_exists($file)) {
$conventions = include ($file);
} else {
$conventions = array('english' => 'title first_name last_name');
}
$search = array('first_name', 'last_name', 'title');
$replacement = array('%f', '%l', '%t');
foreach ($conventions as $key => &$pattern) {
// Creation of patterns using the configuration options in the internationalization "database".
$pattern = str_ireplace($search, $replacement, $pattern);
// Ensuring separation between the parts of every pattern.
$pattern = str_replace('%', ' %', $pattern);
// Cleaning the patterns.
$pattern = _api_clean_person_name($pattern);
// Validating the patterns.
$pattern = _api_validate_person_name_format($pattern);
}
if (empty($conventions[api_refine_language_id($language)])) {
$conventions[api_refine_language_id($language)] = '%t %f %l';
}
}
$valid[$format][$language] = $conventions[api_refine_language_id($language)];
break;
case PERSON_NAME_WESTERN_ORDER:
$valid[$format][$language] = '%t %f %l';
break;
case PERSON_NAME_EASTERN_ORDER:
$valid[$format][$language] = '%t %l %f';
break;
case PERSON_NAME_LIBRARY_ORDER:
$valid[$format][$language] = '%t %l, %f';
break;
default:
$valid[$format][$language] = '%t %f %l';
}
} else {
$valid[$format][$language] = _api_validate_person_name_format($format);
}
}
return $first_name . ' ' . $last_name;
return _api_clean_person_name(str_replace(array('%f', '%l', '%t'), array($first_name, $last_name, $title), $valid[$format][$language]));
}

@ -3,63 +3,64 @@
/**
* @link http://en.wikipedia.org/wiki/Personal_name#Naming_convention
* You maight need to correct the value for your language. The possible values are:
* first_name last_name - Western order
* last_name first_name - Eastern order
* last_name, first_name - Western libraries order
* title first_name last_name - Western order
* title last_name first_name - Eastern order
* title last_name, first_name - Western libraries order
* Placing the title (Dr, Mr, Miss, etc) depends on the tradition in you country.
* For licensing terms, see dokeos_license.txt.
*/
return array(
'arabic' => 'first_name last_name',
'asturian' => 'first_name last_name',
'bosnian' => 'first_name last_name',
'brazilian' => 'first_name last_name',
'bulgarian' => 'first_name last_name',
'catalan' => 'first_name last_name',
'croatian' => 'first_name last_name',
'czech' => 'first_name last_name',
'danish' => 'first_name last_name',
'dari' => 'first_name last_name',
'dutch' => 'first_name last_name',
'english' => 'first_name last_name',
'euskera' => 'first_name last_name',
'esperanto' => 'first_name last_name',
'finnish' => 'first_name last_name',
'french' => 'first_name last_name',
'friulian' => 'first_name last_name',
'galician' => 'first_name last_name',
'georgian' => 'first_name last_name',
'german' => 'first_name last_name',
'greek' => 'first_name last_name',
'hebrew' => 'first_name last_name',
'hungarian' => 'last_name first_name', // Eastern order
'indonesian' => 'first_name last_name',
'italian' => 'first_name last_name',
'japanese' => 'last_name first_name', // Eastern order
'korean' => 'last_name first_name', // Eastern order
'latvian' => 'first_name last_name',
'lithuanian' => 'first_name last_name',
'macedonian' => 'first_name last_name',
'malay' => 'last_name first_name', // Eastern order
'norwegian' => 'first_name last_name',
'occitan' => 'first_name last_name',
'pashto' => 'first_name last_name',
'persian' => 'first_name last_name',
'polish' => 'first_name last_name',
'portuguese' => 'first_name last_name',
'quechua_cusco' => 'first_name last_name',
'romanian' => 'first_name last_name',
'russian' => 'first_name last_name',
'serbian' => 'first_name last_name',
'simpl_chinese' => 'last_name first_name', // Eastern order
'slovak' => 'first_name last_name',
'slovenian' => 'first_name last_name',
'spanish' => 'first_name last_name',
'swahili' => 'first_name last_name',
'swedish' => 'first_name last_name',
'thai' => 'first_name last_name',
'trad_chinese' => 'last_name first_name', // Eastern order
'turkce' => 'first_name last_name',
'ukrainian' => 'first_name last_name',
'vietnamese' => 'last_name first_name', // Eastern order
'yoruba' => 'first_name last_name'
'arabic' => 'title first_name last_name',
'asturian' => 'title first_name last_name',
'bosnian' => 'title first_name last_name',
'brazilian' => 'title first_name last_name',
'bulgarian' => 'title first_name last_name',
'catalan' => 'title first_name last_name',
'croatian' => 'title first_name last_name',
'czech' => 'title first_name last_name',
'danish' => 'title first_name last_name',
'dari' => 'title first_name last_name',
'dutch' => 'title first_name last_name',
'english' => 'title first_name last_name',
'euskera' => 'title first_name last_name',
'esperanto' => 'title first_name last_name',
'finnish' => 'title first_name last_name',
'french' => 'title first_name last_name',
'friulian' => 'title first_name last_name',
'galician' => 'title first_name last_name',
'georgian' => 'title first_name last_name',
'german' => 'title first_name last_name',
'greek' => 'title first_name last_name',
'hebrew' => 'title first_name last_name',
'hungarian' => 'title last_name first_name', // Eastern order
'indonesian' => 'title first_name last_name',
'italian' => 'title first_name last_name',
'japanese' => 'title last_name first_name', // Eastern order
'korean' => 'title last_name first_name', // Eastern order
'latvian' => 'title first_name last_name',
'lithuanian' => 'title first_name last_name',
'macedonian' => 'title first_name last_name',
'malay' => 'title last_name first_name', // Eastern order
'norwegian' => 'title first_name last_name',
'occitan' => 'title first_name last_name',
'pashto' => 'title first_name last_name',
'persian' => 'title first_name last_name',
'polish' => 'title first_name last_name',
'portuguese' => 'title first_name last_name',
'quechua_cusco' => 'title first_name last_name',
'romanian' => 'title first_name last_name',
'russian' => 'title first_name last_name',
'serbian' => 'title first_name last_name',
'simpl_chinese' => 'title last_name first_name', // Eastern order
'slovak' => 'title first_name last_name',
'slovenian' => 'title first_name last_name',
'spanish' => 'title first_name last_name',
'swahili' => 'title first_name last_name',
'swedish' => 'title first_name last_name',
'thai' => 'title first_name last_name',
'trad_chinese' => 'title last_name first_name', // Eastern order
'turkce' => 'title first_name last_name',
'ukrainian' => 'title first_name last_name',
'vietnamese' => 'title last_name first_name', // Eastern order
'yoruba' => 'title first_name last_name'
);

@ -86,37 +86,23 @@ function &_api_get_day_month_names($language = null) {
*/
/**
* Returns an array of conventions (patterns) of writting personal names for all "known" languages.
* @return array Returns the array in the following form: attay('language1 => 'pattern1', ...).
* @link http://en.wikipedia.org/wiki/Personal_name#Naming_convention
* Replaces non-valid formats for person names with the default (English) format.
* @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.
*/
function &_get_name_conventions() {
static $conventions;
if (!isset($conventions)) {
$file = dirname(__FILE__) . '/internationalization_database/name_order_conventions.php';
if (file_exists($file)) {
$conventions = include ($file);
} else {
$conventions = array('english' => 'first_name last_name');
}
$search = array('first_name', 'last_name');
$replacement = array('%f', '%l');
foreach ($conventions as $key => &$value) {
$value = str_ireplace($search, $replacement, $value);
}
function _api_validate_person_name_format($format) {
if (empty($format) || strpos($format, '%f') === false || strpos($format, '%l') === false) {
return '%t %f %l';
}
return $conventions;
return $format;
}
/**
* Checks whether the input namin convention (a pattern) is valid or not.
* @param string $convention The input convention to be verified.
* @return bool Returns TRUE if the pattern is valid, FALSE othewise.
* Removes leading, trailing and duplicate whitespace and/or commas in a full person name.
* Cleaning is needed for the cases when not all parts of the name are available or when the name is constructed using a "dirty" pattern.
* @param string $person_name The input person name.
* @return string Returns cleaned person name.
*/
function _api_is_valid_name_convention($convention) {
static $cache = array();
if (!isset($cache[$convention])) {
$cache[$convention] = !empty($convention) && strpos($convention, '%f') !== false && strpos($convention, '%l') !== false;
}
return $cache[$convention];
function _api_clean_person_name($person_name) {
return preg_replace(array('/\s+/', '/, ,/', '/,+/', '/^[ ,]/', '/[ ,]$/'), array(' ', ', ', ',', '', ''), $person_name);
}

@ -691,8 +691,13 @@ elseif($_POST['step5'])
?><br /><br/>
<?php echo get_lang('AdminEmail').' : '.$emailForm; ?><br />
<?php echo get_lang('AdminFirstName').' : '.$adminFirstName; ?><br />
<?php echo get_lang('AdminLastName').' : '.$adminLastName; ?><br />
<?php
if (api_is_western_name_order()) {
echo get_lang('AdminFirstName').' : '.$adminFirstName, '<br />', get_lang('AdminLastName').' : '.$adminLastName, '<br />';
} else {
echo get_lang('AdminLastName').' : '.$adminLastName, '<br />', get_lang('AdminFirstName').' : '.$adminFirstName, '<br />';
}
?>
<?php echo get_lang('AdminPhone').' : '.$adminPhoneForm; ?><br />
<?php if($installType == 'new'): ?>

@ -1061,11 +1061,14 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
//Parameter 3: administrator's email
display_configuration_parameter($installType, get_lang("AdminEmail"), "emailForm", $emailForm);
//Parameter 4: administrator's first name
//Parameters 4 and 5: administrator's names
if (api_is_western_name_order()) {
display_configuration_parameter($installType, get_lang("AdminFirstName"), "adminFirstName", $adminFirstName);
//Parameter 5: administrator's last name
display_configuration_parameter($installType, get_lang("AdminLastName"), "adminLastName", $adminLastName);
} else {
display_configuration_parameter($installType, get_lang("AdminLastName"), "adminLastName", $adminLastName);
display_configuration_parameter($installType, get_lang("AdminFirstName"), "adminFirstName", $adminFirstName);
}
//Parameter 6: administrator's telephone
display_configuration_parameter($installType, get_lang("AdminPhone"), "adminPhoneForm", $adminPhoneForm);

Loading…
Cancel
Save