From 14d49826e288a2efd3c5f07ff02b16d6baf523af Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Mon, 28 Nov 2011 17:13:39 +0100 Subject: [PATCH] Fixes names captitalization and sorting. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- include/name.func.inc.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/include/name.func.inc.php b/include/name.func.inc.php index 9e66232..1df275b 100644 --- a/include/name.func.inc.php +++ b/include/name.func.inc.php @@ -19,14 +19,17 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -// Some particles should not be capitalized (cf "ORTHOTYPO", by Jean-Pierre -// Lacroux). -// Note that some of them are allowed to use capital letters in some cases, -// for instance "De" in American English. -static $particles = array('d', 'de', 'an', 'auf', 'von', 'von dem', - 'von der', 'zu', 'of', 'del', 'de las', - 'de les', 'de los', 'las', 'los', 'y', 'a', - 'da', 'das', 'do', 'dos', 'af', 'av'); +class Particles +{ + // Some particles should not be capitalized (cf "ORTHOTYPO", by Jean-Pierre + // Lacroux). + // Note that some of them are allowed to use capital letters in some cases, + // for instance "De" in American English. + public static $particles = array('d', 'de', 'an', 'auf', 'von', 'von dem', + 'von der', 'zu', 'of', 'del', 'de las', + 'de les', 'de los', 'las', 'los', 'y', 'a', + 'da', 'das', 'do', 'dos', 'af', 'av'); +} function build_javascript_names($data, $isFemale) @@ -148,10 +151,10 @@ function build_full_name($firstname, $lastname) function build_sort_name($firstname, $lastname) { // Remove uncapitalized particles. - $particles = "/^(d'|(" . implode($particles, '|') . ') )/'; + $particles = "/^(d'|(" . implode(Particles::$particles, '|') . ') )/'; $name = preg_replace($particles, '', $lastname); // Mac must also be uniformized. - $lastname = preg_replace("/^(Mac|Mc)(| )/", 'Mac', $name); + $lastname = preg_replace("/^(Mac|Mc)( |)/", 'Mac', $name); if ($firstname == '') { return $lastname; @@ -266,7 +269,7 @@ function capitalize_name($name) } // Capitalizes the first token. - if (!in_array($token, $particles)) { + if (!in_array($token, Particles::$particles)) { $token = mb_ucfirst($token); } -- 2.1.4