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. 107
      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); $first_letter_course = Database::escape_string($first_letter_course);
$sql = "SELECT code, title FROM $tbl_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 "; ORDER BY title, code DESC ";
$result = api_sql_query($sql, __FILE__, __LINE__); $result = api_sql_query($sql, __FILE__, __LINE__);

@ -135,7 +135,7 @@ class Statistics
$res = api_sql_query($sql, __FILE__, __LINE__); $res = api_sql_query($sql, __FILE__, __LINE__);
$activities = array (); $activities = array ();
while ($row = Database::fetch_row($res)) { 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; $activities[] = $row;
} }
return $activities; return $activities;

@ -60,7 +60,7 @@ api_plugin('footer');
if (api_get_setting('show_administrator_data')=='true') { if (api_get_setting('show_administrator_data')=='true') {
// Platform manager // 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. * Checks whether a given format represents prson name in Western order (for which first name is first).
* @param string $language (optional) Language indentificator. If it is omited, the current interface language is assumed. * @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.
* @return bool The result TRUE means that the order shold be first_name last_name, FALSE means last_name first_name. * @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: * 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; * 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; * 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. * 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(); static $order = array();
if (empty($format)) {
$format = PERSON_NAME_COMMON_CONVENTION;
}
if (empty($language)) { if (empty($language)) {
$language = api_get_interface_language(); $language = api_get_interface_language();
} }
$language = api_refine_language_id($language); if (!isset($order[$format][$language])) {
if (!isset($order[$language])) { $test_name = api_get_person_name('%f', '%l', '%t', $format, $language);
$conventions = &_get_name_conventions(); $order[$format][$language] = strpos($test_name, '%f') <= strpos($test_name, '%l');
$convention = $conventions[$language];
if (_api_is_valid_name_convention($convention)) {
$order[$language] = (strpos($convention, '%f') < strpos($convention, '%l'));
} else {
$order[$language] = true;
}
} }
return $order[$language]; return $order[$format][$language];
} }
/** /**
* Builds a person (full) name depending on the convention for a given 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 $first_name The first name of the preson.
* @param string $last_name The last name of the person. * @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 string $title The title of the person.
* @param int (optional) $option A parameter for overriding the common convention, it should be used in limited number of cases. * @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.
* Its values may be: 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. * @return bool The result is sort of full name of the person.
* Sample results: * Sample results:
* Peter Ustinoff - the Western order * Peter Ustinoff or Dr. Peter Ustinoff - the Western order
* Ustinoff Peter - the Eastern order * Ustinoff Peter or Dr. Ustinoff Peter - the Eastern order
* Ustinoff, Peter - the library order * Ustinoff, Peter or - Dr. Ustinoff, Peter - the library order
* Note: See the file dokeos/main/inc/lib/internationalization_database/name_order_conventions.php * Note: See the file dokeos/main/inc/lib/internationalization_database/name_order_conventions.php where you can revise the convention for your language.
* 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) { function api_get_person_name($first_name, $last_name, $title = null, $format = null, $language = null) {
switch ($option) { static $conventions;
static $valid = array();
if (empty($format)) {
$format = PERSON_NAME_COMMON_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: case PERSON_NAME_WESTERN_ORDER:
return $first_name . ' ' . $last_name; $valid[$format][$language] = '%t %f %l';
break;
case PERSON_NAME_EASTERN_ORDER: case PERSON_NAME_EASTERN_ORDER:
return $last_name . ' ' . $first_name; $valid[$format][$language] = '%t %l %f';
break;
case PERSON_NAME_LIBRARY_ORDER: case PERSON_NAME_LIBRARY_ORDER:
return $last_name . ', ' . $first_name; $valid[$format][$language] = '%t %l, %f';
case PERSON_NAME_COMMON_CONVENTION: break;
default: default:
if (empty($language)) { $valid[$format][$language] = '%t %f %l';
$language = api_get_interface_language();
} }
$language = api_refine_language_id($language); } else {
$conventions = &_get_name_conventions(); $valid[$format][$language] = _api_validate_person_name_format($format);
$convention = $conventions[$language];
break;
} }
if (_api_is_valid_name_convention($convention)) {
return str_replace(array('%f', '%l'), array($first_name, $last_name), $convention);
} }
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 * @link http://en.wikipedia.org/wiki/Personal_name#Naming_convention
* You maight need to correct the value for your language. The possible values are: * You maight need to correct the value for your language. The possible values are:
* first_name last_name - Western order * title first_name last_name - Western order
* last_name first_name - Eastern order * title last_name first_name - Eastern order
* last_name, first_name - Western libraries 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. * For licensing terms, see dokeos_license.txt.
*/ */
return array( return array(
'arabic' => 'first_name last_name', 'arabic' => 'title first_name last_name',
'asturian' => 'first_name last_name', 'asturian' => 'title first_name last_name',
'bosnian' => 'first_name last_name', 'bosnian' => 'title first_name last_name',
'brazilian' => 'first_name last_name', 'brazilian' => 'title first_name last_name',
'bulgarian' => 'first_name last_name', 'bulgarian' => 'title first_name last_name',
'catalan' => 'first_name last_name', 'catalan' => 'title first_name last_name',
'croatian' => 'first_name last_name', 'croatian' => 'title first_name last_name',
'czech' => 'first_name last_name', 'czech' => 'title first_name last_name',
'danish' => 'first_name last_name', 'danish' => 'title first_name last_name',
'dari' => 'first_name last_name', 'dari' => 'title first_name last_name',
'dutch' => 'first_name last_name', 'dutch' => 'title first_name last_name',
'english' => 'first_name last_name', 'english' => 'title first_name last_name',
'euskera' => 'first_name last_name', 'euskera' => 'title first_name last_name',
'esperanto' => 'first_name last_name', 'esperanto' => 'title first_name last_name',
'finnish' => 'first_name last_name', 'finnish' => 'title first_name last_name',
'french' => 'first_name last_name', 'french' => 'title first_name last_name',
'friulian' => 'first_name last_name', 'friulian' => 'title first_name last_name',
'galician' => 'first_name last_name', 'galician' => 'title first_name last_name',
'georgian' => 'first_name last_name', 'georgian' => 'title first_name last_name',
'german' => 'first_name last_name', 'german' => 'title first_name last_name',
'greek' => 'first_name last_name', 'greek' => 'title first_name last_name',
'hebrew' => 'first_name last_name', 'hebrew' => 'title first_name last_name',
'hungarian' => 'last_name first_name', // Eastern order 'hungarian' => 'title last_name first_name', // Eastern order
'indonesian' => 'first_name last_name', 'indonesian' => 'title first_name last_name',
'italian' => 'first_name last_name', 'italian' => 'title first_name last_name',
'japanese' => 'last_name first_name', // Eastern order 'japanese' => 'title last_name first_name', // Eastern order
'korean' => 'last_name first_name', // Eastern order 'korean' => 'title last_name first_name', // Eastern order
'latvian' => 'first_name last_name', 'latvian' => 'title first_name last_name',
'lithuanian' => 'first_name last_name', 'lithuanian' => 'title first_name last_name',
'macedonian' => 'first_name last_name', 'macedonian' => 'title first_name last_name',
'malay' => 'last_name first_name', // Eastern order 'malay' => 'title last_name first_name', // Eastern order
'norwegian' => 'first_name last_name', 'norwegian' => 'title first_name last_name',
'occitan' => 'first_name last_name', 'occitan' => 'title first_name last_name',
'pashto' => 'first_name last_name', 'pashto' => 'title first_name last_name',
'persian' => 'first_name last_name', 'persian' => 'title first_name last_name',
'polish' => 'first_name last_name', 'polish' => 'title first_name last_name',
'portuguese' => 'first_name last_name', 'portuguese' => 'title first_name last_name',
'quechua_cusco' => 'first_name last_name', 'quechua_cusco' => 'title first_name last_name',
'romanian' => 'first_name last_name', 'romanian' => 'title first_name last_name',
'russian' => 'first_name last_name', 'russian' => 'title first_name last_name',
'serbian' => 'first_name last_name', 'serbian' => 'title first_name last_name',
'simpl_chinese' => 'last_name first_name', // Eastern order 'simpl_chinese' => 'title last_name first_name', // Eastern order
'slovak' => 'first_name last_name', 'slovak' => 'title first_name last_name',
'slovenian' => 'first_name last_name', 'slovenian' => 'title first_name last_name',
'spanish' => 'first_name last_name', 'spanish' => 'title first_name last_name',
'swahili' => 'first_name last_name', 'swahili' => 'title first_name last_name',
'swedish' => 'first_name last_name', 'swedish' => 'title first_name last_name',
'thai' => 'first_name last_name', 'thai' => 'title first_name last_name',
'trad_chinese' => 'last_name first_name', // Eastern order 'trad_chinese' => 'title last_name first_name', // Eastern order
'turkce' => 'first_name last_name', 'turkce' => 'title first_name last_name',
'ukrainian' => 'first_name last_name', 'ukrainian' => 'title first_name last_name',
'vietnamese' => 'last_name first_name', // Eastern order 'vietnamese' => 'title last_name first_name', // Eastern order
'yoruba' => 'first_name last_name' '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. * Replaces non-valid formats for person names with the default (English) format.
* @return array Returns the array in the following form: attay('language1 => 'pattern1', ...). * @param string $format The input format to be verified.
* @link http://en.wikipedia.org/wiki/Personal_name#Naming_convention * @return bool Returns the same format if is is valid, otherwise returns a valid English format.
*/ */
function &_get_name_conventions() { function _api_validate_person_name_format($format) {
static $conventions; if (empty($format) || strpos($format, '%f') === false || strpos($format, '%l') === false) {
if (!isset($conventions)) { return '%t %f %l';
$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);
} }
} return $format;
return $conventions;
} }
/** /**
* Checks whether the input namin convention (a pattern) is valid or not. * Removes leading, trailing and duplicate whitespace and/or commas in a full person name.
* @param string $convention The input convention to be verified. * 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.
* @return bool Returns TRUE if the pattern is valid, FALSE othewise. * @param string $person_name The input person name.
* @return string Returns cleaned person name.
*/ */
function _api_is_valid_name_convention($convention) { function _api_clean_person_name($person_name) {
static $cache = array(); return preg_replace(array('/\s+/', '/, ,/', '/,+/', '/^[ ,]/', '/[ ,]$/'), array(' ', ', ', ',', '', ''), $person_name);
if (!isset($cache[$convention])) {
$cache[$convention] = !empty($convention) && strpos($convention, '%f') !== false && strpos($convention, '%l') !== false;
}
return $cache[$convention];
} }

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

@ -1061,11 +1061,14 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
//Parameter 3: administrator's email //Parameter 3: administrator's email
display_configuration_parameter($installType, get_lang("AdminEmail"), "emailForm", $emailForm); 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); display_configuration_parameter($installType, get_lang("AdminFirstName"), "adminFirstName", $adminFirstName);
//Parameter 5: administrator's last name
display_configuration_parameter($installType, get_lang("AdminLastName"), "adminLastName", $adminLastName); 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 //Parameter 6: administrator's telephone
display_configuration_parameter($installType, get_lang("AdminPhone"), "adminPhoneForm", $adminPhoneForm); display_configuration_parameter($installType, get_lang("AdminPhone"), "adminPhoneForm", $adminPhoneForm);

Loading…
Cancel
Save