Adds name_order_conventions configuration option see BT#9287

1.9.x
Julio Montoya 11 years ago
parent 1863e40709
commit f1c9210c4d
  1. 30
      main/inc/lib/internationalization_internal.lib.php
  2. 4
      main/install/configuration.dist.php

@ -196,18 +196,16 @@ function &_api_get_day_month_names($language = null) {
return $date_parts[$language]; return $date_parts[$language];
} }
/**
* Appendix to "Name order conventions"
*/
/** /**
* Returns returns person name convention for a given language. * Returns returns person name convention for a given language.
* @param string $language The input language. * @param string $language The input language.
* @param string $type The type of the requested convention. It may be 'format' for name order convention or 'sort_by' for name sorting convention. * @param string $type The type of the requested convention.
* @return mixed Depending of the requested type, the returned result may be string or boolean; null is returned on error; * It may be 'format' for name order convention or 'sort_by' for name sorting convention.
* @return mixed Depending of the requested type,
* the returned result may be string or boolean; null is returned on error;
*/ */
function _api_get_person_name_convention($language, $type) { function _api_get_person_name_convention($language, $type)
{
static $conventions; static $conventions;
$language = api_purify_language_id($language); $language = api_purify_language_id($language);
if (!isset($conventions)) { if (!isset($conventions)) {
@ -215,8 +213,22 @@ function _api_get_person_name_convention($language, $type) {
if (file_exists($file)) { if (file_exists($file)) {
$conventions = include ($file); $conventions = include ($file);
} else { } else {
$conventions = array('english' => array('format' => 'title first_name last_name', 'sort_by' => 'first_name')); $conventions = array(
'english' => array(
'format' => 'title first_name last_name',
'sort_by' => 'first_name'
)
);
} }
// Overwrite classic conventions
$customConventions = api_get_configuration_value('name_order_conventions');
if (!empty($customConventions)) {
foreach ($customConventions as $key => $data) {
$conventions[$key] = $data;
}
}
$search1 = array('FIRST_NAME', 'LAST_NAME', 'TITLE'); $search1 = array('FIRST_NAME', 'LAST_NAME', 'TITLE');
$replacement1 = array('%F', '%L', '%T'); $replacement1 = array('%F', '%L', '%T');
$search2 = array('first_name', 'last_name', 'title'); $search2 = array('first_name', 'last_name', 'title');

@ -278,3 +278,7 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//$_configuration['exercise_max_fckeditors_in_page'] = 0; //$_configuration['exercise_max_fckeditors_in_page'] = 0;
// Default upload option // Default upload option
//$_configuration['document_if_file_exists_option'] = 'rename'; // overwrite //$_configuration['document_if_file_exists_option'] = 'rename'; // overwrite
// Custom name_order_conventions
//$_configuration['name_order_conventions'] = array(
// 'french' => array('format' => 'title last_name first_name', 'sort_by' => 'last_name')
//);

Loading…
Cancel
Save