/tags/v4.0/client/annuaire/bibliotheque/Words/lang.fr.php |
---|
New file |
0,0 → 1,434 |
<?php |
/* vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +----------------------------------------------------------------------+ |
// | PHP version 4 | |
// +----------------------------------------------------------------------+ |
// | Copyright (c) 1997-2003 The PHP Group | |
// +----------------------------------------------------------------------+ |
// | This source file is subject to version 3.0 of the PHP license, | |
// | that is bundled with this package in the file LICENSE, and is | |
// | available through the world-wide-web at | |
// | http://www.php.net/license/3_0.txt. | |
// | If you did not receive a copy of the PHP license and are unable to | |
// | obtain it through the world-wide-web, please send a note to | |
// | license@php.net so we can mail you a copy immediately. | |
// +----------------------------------------------------------------------+ |
// | Authors: Kouber Saparev <kouber@php.net> | |
// +----------------------------------------------------------------------+ |
// |
// $Id: lang.fr.php,v 1.4 2004/10/22 18:22:52 kouber Exp $ |
/** |
* Class for translating numbers into French. |
* |
* @author Kouber Saparev <kouber@php.net> |
* @package Numbers_Words |
*/ |
class Numbers_Words_fr extends Numbers_Words |
{ |
// {{{ properties |
/** |
* Locale name. |
* @var string |
* @access public |
*/ |
var $locale = 'fr'; |
/** |
* Language name in English. |
* @var string |
* @access public |
*/ |
var $lang = 'French'; |
/** |
* Native language name. |
* @var string |
* @access public |
*/ |
var $lang_native = 'Français'; |
/** |
* The words for some numbers. |
* @var string |
* @access private |
*/ |
var $_misc_numbers = array( |
10=>'dix', // 10 |
'onze', // 11 |
'douze', // 12 |
'treize', // 13 |
'quatorze', // 14 |
'quinze', // 15 |
'seize', // 16 |
20=>'vingt', // 20 |
30=>'trente', // 30 |
40=>'quarante', // 40 |
50=>'cinquante',// 50 |
60=>'soixante', // 60 |
100=>'cent' // 100 |
); |
/** |
* The words for digits (except zero). |
* @var string |
* @access private |
*/ |
var $_digits = array(1=>"un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf"); |
/** |
* The word for zero. |
* @var string |
* @access private |
*/ |
var $_zero = 'zéro'; |
/** |
* The word for infinity. |
* @var string |
* @access private |
*/ |
var $_infinity = 'infini'; |
/** |
* The word for the "and" language construct. |
* @var string |
* @access private |
*/ |
var $_and = 'et'; |
/** |
* The word separator. |
* @var string |
* @access private |
*/ |
var $_sep = ' '; |
/** |
* The dash liaison. |
* @var string |
* @access private |
*/ |
var $_dash = '-'; |
/** |
* The word for the minus sign. |
* @var string |
* @access private |
*/ |
var $_minus = 'moins'; // minus sign |
/** |
* The plural suffix (except for hundred). |
* @var string |
* @access private |
*/ |
var $_plural = 's'; // plural suffix |
/** |
* The suffixes for exponents (singular). |
* @var array |
* @access private |
*/ |
var $_exponent = array( |
0 => '', |
3 => 'mille', |
6 => 'million', |
9 => 'milliard', |
12 => 'trillion', |
15 => 'quadrillion', |
18 => 'quintillion', |
21 => 'sextillion', |
24 => 'septillion', |
27 => 'octillion', |
30 => 'nonillion', |
33 => 'decillion', |
36 => 'undecillion', |
39 => 'duodecillion', |
42 => 'tredecillion', |
45 => 'quattuordecillion', |
48 => 'quindecillion', |
51 => 'sexdecillion', |
54 => 'septendecillion', |
57 => 'octodecillion', |
60 => 'novemdecillion', |
63 => 'vigintillion', |
66 => 'unvigintillion', |
69 => 'duovigintillion', |
72 => 'trevigintillion', |
75 => 'quattuorvigintillion', |
78 => 'quinvigintillion', |
81 => 'sexvigintillion', |
84 => 'septenvigintillion', |
87 => 'octovigintillion', |
90 => 'novemvigintillion', |
93 => 'trigintillion', |
96 => 'untrigintillion', |
99 => 'duotrigintillion', |
102 => 'trestrigintillion', |
105 => 'quattuortrigintillion', |
108 => 'quintrigintillion', |
111 => 'sextrigintillion', |
114 => 'septentrigintillion', |
117 => 'octotrigintillion', |
120 => 'novemtrigintillion', |
123 => 'quadragintillion', |
126 => 'unquadragintillion', |
129 => 'duoquadragintillion', |
132 => 'trequadragintillion', |
135 => 'quattuorquadragintillion', |
138 => 'quinquadragintillion', |
141 => 'sexquadragintillion', |
144 => 'septenquadragintillion', |
147 => 'octoquadragintillion', |
150 => 'novemquadragintillion', |
153 => 'quinquagintillion', |
156 => 'unquinquagintillion', |
159 => 'duoquinquagintillion', |
162 => 'trequinquagintillion', |
165 => 'quattuorquinquagintillion', |
168 => 'quinquinquagintillion', |
171 => 'sexquinquagintillion', |
174 => 'septenquinquagintillion', |
177 => 'octoquinquagintillion', |
180 => 'novemquinquagintillion', |
183 => 'sexagintillion', |
186 => 'unsexagintillion', |
189 => 'duosexagintillion', |
192 => 'tresexagintillion', |
195 => 'quattuorsexagintillion', |
198 => 'quinsexagintillion', |
201 => 'sexsexagintillion', |
204 => 'septensexagintillion', |
207 => 'octosexagintillion', |
210 => 'novemsexagintillion', |
213 => 'septuagintillion', |
216 => 'unseptuagintillion', |
219 => 'duoseptuagintillion', |
222 => 'treseptuagintillion', |
225 => 'quattuorseptuagintillion', |
228 => 'quinseptuagintillion', |
231 => 'sexseptuagintillion', |
234 => 'septenseptuagintillion', |
237 => 'octoseptuagintillion', |
240 => 'novemseptuagintillion', |
243 => 'octogintillion', |
246 => 'unoctogintillion', |
249 => 'duooctogintillion', |
252 => 'treoctogintillion', |
255 => 'quattuoroctogintillion', |
258 => 'quinoctogintillion', |
261 => 'sexoctogintillion', |
264 => 'septoctogintillion', |
267 => 'octooctogintillion', |
270 => 'novemoctogintillion', |
273 => 'nonagintillion', |
276 => 'unnonagintillion', |
279 => 'duononagintillion', |
282 => 'trenonagintillion', |
285 => 'quattuornonagintillion', |
288 => 'quinnonagintillion', |
291 => 'sexnonagintillion', |
294 => 'septennonagintillion', |
297 => 'octononagintillion', |
300 => 'novemnonagintillion', |
303 => 'centillion' |
); |
// }}} |
// {{{ _splitNumber() |
/** |
* Split a number to groups of three-digit numbers. |
* |
* @param mixed $num An integer or its string representation |
* that need to be split |
* |
* @return array Groups of three-digit numbers. |
* |
* @access private |
* @author Kouber Saparev <kouber@php.net> |
* @since PHP 4.2.3 |
*/ |
function _splitNumber($num) |
{ |
if (is_string($num)) { |
$ret = array(); |
$strlen = strlen($num); |
$first = substr($num, 0, $strlen%3); |
preg_match_all('/\d{3}/', substr($num, $strlen%3, $strlen), $m); |
$ret =& $m[0]; |
if ($first) array_unshift($ret, $first); |
return $ret; |
} |
else |
return explode(' ', number_format($num, 0, '', ' ')); // a faster version for integers |
} |
// }}} |
// {{{ _showDigitsGroup() |
/** |
* Converts a three-digit number to its word representation |
* in French language. |
* |
* @param integer $num An integer between 1 and 999 inclusive. |
* |
* @param boolean $last A flag, that determines if it is the last group of digits - |
* this is used to accord the plural suffix of the "hundreds". |
* Example: 200 = "deux cents", but 200000 = "deux cent mille". |
* |
* |
* @return string The words for the given number. |
* |
* @access private |
* @author Kouber Saparev <kouber@php.net> |
*/ |
function _showDigitsGroup($num, $last = false) |
{ |
$ret = ''; |
// extract the value of each digit from the three-digit number |
$e = $num%10; // ones |
$d = ($num-$e)%100/10; // tens |
$s = ($num-$d*10-$e)%1000/100; // hundreds |
// process the "hundreds" digit. |
if ($s) { |
if ($s>1) { |
$ret .= $this->_digits[$s].$this->_sep.$this->_misc_numbers[100]; |
if ($last && !$e && !$d) { |
$ret .= $this->_plural; |
} |
} else { |
$ret .= $this->_misc_numbers[100]; |
} |
$ret .= $this->_sep; |
} |
// process the "tens" digit, and optionally the "ones" digit. |
if ($d) { |
// in the case of 1, the "ones" digit also must be processed |
if ($d==1) { |
if ($e<=6) { |
$ret .= $this->_misc_numbers[10+$e]; |
} else { |
$ret .= $this->_misc_numbers[10].'-'.$this->_digits[$e]; |
} |
$e = 0; |
} elseif ($d>5) { |
if ($d<8) { |
$ret .= $this->_misc_numbers[60]; |
$resto = $d*10+$e-60; |
if ($e==1) { |
$ret .= $this->_sep.$this->_and.$this->_sep; |
} |
elseif ($resto) { |
$ret .= $this->_dash; |
} |
if ($resto) { |
$ret .= $this->_showDigitsGroup($resto); |
} |
$e = 0; |
} else { |
$ret .= $this->_digits[4].$this->_dash.$this->_misc_numbers[20]; |
$resto = $d*10+$e-80; |
if ($resto) { |
$ret .= $this->_dash; |
$ret .= $this->_showDigitsGroup($resto); |
$e = 0; |
} else { |
$ret .= $this->_plural; |
} |
} |
} else { |
$ret .= $this->_misc_numbers[$d*10]; |
} |
} |
// process the "ones" digit |
if ($e) { |
if ($d) { |
if ($e==1) { |
$ret .= $this->_sep.$this->_and.$this->_sep; |
} else { |
$ret .= $this->_dash; |
} |
} |
$ret .= $this->_digits[$e]; |
} |
// strip excessive separators |
$ret = rtrim($ret, $this->_sep); |
return $ret; |
} |
// }}} |
// {{{ toWords() |
/** |
* Converts a number to its word representation |
* in French language. |
* |
* @param integer $num An integer (or its string representation) between 9.99*-10^302 |
* and 9.99*10^302 (999 centillions) that need to be converted to words |
* |
* @return string The corresponding word representation |
* |
* @access public |
* @author Kouber Saparev <kouber@php.net> |
*/ |
function toWords($num = 0) |
{ |
$ret = ''; |
// check if $num is a valid non-zero number |
if (!$num || preg_match('/^-?0+$/', $num) || !preg_match('/^-?\d+$/', $num)) return $this->_zero; |
// add a minus sign |
if (substr($num, 0, 1) == '-') { |
$ret = $this->_minus . $this->_sep; |
$num = substr($num, 1); |
} |
// if the absolute value is greater than 9.99*10^302, return infinity |
if (strlen($num)>306) { |
return $ret . $this->_infinity; |
} |
// strip excessive zero signs |
$num = ltrim($num, '0'); |
// split $num to groups of three-digit numbers |
$num_groups = $this->_splitNumber($num); |
$sizeof_numgroups = count($num_groups); |
foreach ($num_groups as $i=>$number) { |
// what is the corresponding exponent for the current group |
$pow = $sizeof_numgroups-$i; |
// skip processment for empty groups |
if ($number!='000') { |
if ($number!=1 || $pow!=2) { |
$ret .= $this->_showDigitsGroup($number, $i+1==$sizeof_numgroups).$this->_sep; |
} |
$ret .= $this->_exponent[($pow-1)*3]; |
if ($pow>2 && $number>1) { |
$ret .= $this->_plural; |
} |
$ret .= $this->_sep; |
} |
} |
return rtrim($ret, $this->_sep); |
} |
// }}} |
} |
?> |
/tags/v4.0/client/annuaire/bibliotheque/annuaire.fonct.php |
---|
New file |
0,0 → 1,324 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU Lesser General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | Lesser General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU Lesser General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: annuaire.fonct.php,v 1.1 2005/03/24 08:46:07 alex Exp $ |
/** |
* Fonctions du module annuaire |
* |
* Fonctions du module annuaire |
* |
*@package annuaire |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.1 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
// +------------------------------------------------------------------------------------------------------+ |
// | LISTE de FONCTIONS | |
// +------------------------------------------------------------------------------------------------------+ |
function AUTH_formulaire_login() { |
$res = ''; |
$url = preg_replace ('/&/', '&', $GLOBALS['ann_url']->getURL()) ; |
$res .= '<p>'.ANN_IDENTIFICATION_PRESENTATION_XHTML.'</p>'."\n" ; |
$form = new HTML_QuickForm ('inscription', 'post', $url) ; |
$form->addElement ('text', 'username', ANN_EMAIL) ; |
$form->addElement ('password', 'password', ANN_MOT_DE_PASSE) ; |
$form->addElement('submit', 'valider', ANN_VALIDER); |
$res .= $form->toHTML() ; |
return $res; |
} |
/** function parcourrirAnnu () Affiche l'annuaire à partir d'une lettre |
* |
* |
* |
* @return string HTML |
*/ |
function parcourrirAnnu() { |
$res = '<p id="annuaire_alphabet">'; |
// Alphabet pour la rechercher par lettre du nom des inscrits |
for ($i = 65 ; $i <91 ; $i++) { |
$GLOBALS['ann_url']->addQueryString('lettre', chr($i)); |
$url_lettre = $GLOBALS['ann_url']->getURL(); |
$GLOBALS['ann_url']->removeQueryString('lettre'); |
$res .= '<a href="'.$url_lettre.'">'.chr($i).'</a> '."\n"; |
} |
if (ANN_TOUS_BOOL) { |
$GLOBALS['ann_url']->addQueryString('lettre', 'tous'); |
$url_lettre = $GLOBALS['ann_url']->getURL(); |
$GLOBALS['ann_url']->removeQueryString('lettre'); |
$res .= '<a href="'.$url_lettre.'">'.'Tous'.'</a>'."\n"; |
} |
$res .= '</p>'."\n"; |
// Si aucune lettre n'est sélectionnée, attribution de la lettre par défaut |
if (empty($_REQUEST['lettre'])) { |
$_REQUEST['lettre'] = ANN_LETTRE_DEFAUT; |
} |
// Une lettre est disponible... |
$requete = 'SELECT '.ANN_ANNUAIRE.'.*, '.ANN_TABLE_PAYS.'.* '. |
'FROM '.ANN_ANNUAIRE.','.ANN_TABLE_PAYS.' '. |
'WHERE '.ANN_CHAMPS_PAYS.' = '.ANN_GC_ID.' '; |
if ($_REQUEST['lettre'] != 'tous') { |
$requete .= ' AND '.ANN_CHAMPS_NOM.' LIKE "'.$_REQUEST['lettre'].'%" ' ; |
} |
$requete .= 'ORDER BY '.ANN_CHAMPS_NOM; |
$res .= listes_inscrit($requete, $GLOBALS['ann_url']->getURL(), '', $GLOBALS['ann_db'], $niveau = 'pays'). |
carto_texte_cocher(). |
carto_formulaire(); |
return $res; |
} |
/** |
* Renvoie le code HTML de la liste des inscrits |
* en fonction de la requete passé en parametre |
* |
* @return Renvoie le code HTML de la liste des inscrits |
*/ |
function listes_inscrit($requete, $url, $argument, &$db, $niveau = 'pays') { |
$resultat = $GLOBALS['ann_db']->query($requete); |
(DB::isError($resultat)) ? die($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) : ''; |
if ($resultat->numRows() > 0) { |
$res = '<form action="'.$url.'?mailer=1&lettre='.$_REQUEST['lettre'].'" method="post" name="formmail">'."\n"; |
$res .= '<div id="annuaire" class="conteneur_table"> |
<table id="table_inscrit" class="table_cadre"> |
<colgroup> |
<col /> |
<col /> |
<col /> |
<col /> |
<col /> |
<col /> |
<col /> |
</colgroup> |
<thead class="entete_fixe"> |
<tr> |
<th> </th> |
<th>'.ANN_NOM.'</th> |
<th>'.ANN_PRENOM.'</th> |
<th>'.ANN_DATE_INS.'</th> |
<th>'.ANN_CP.'</th> |
<th>'.ANN_VILLE.'</th> |
<th>'.ANN_PAYS.'</th> |
</tr> |
</thead> |
<tbody class="contenu_deroulant">'; |
$indic = 0; |
$i = 1; |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
if ($indic == 0) { |
$res .= '<tr class="ligne_impaire">'."\n"; |
$indic = 1; |
} else { |
$res .= '<tr class="ligne_paire">'."\n"; |
$indic = 0; |
} |
$res.= '<td><input type="checkbox" name="select[]" value="'.$ligne[ANN_CHAMPS_MAIL].'" /></td>'."\n". |
'<td>'.strtoupper($ligne[ANN_CHAMPS_NOM]).' </td>'."\n". |
'<td>'.str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', $ligne[ANN_CHAMPS_PRENOM])))).' </td>'."\n". |
'<td>'.date('d m Y', strtotime($ligne[ANN_CHAMPS_DATE_INS])).' </td>'."\n". |
'<td>'.$ligne[ANN_CHAMPS_CODE_POSTAL].' </td>'."\n". |
'<td>'.strtoupper($ligne[ANN_CHAMPS_VILLE]).' </td>'."\n". |
'<td>'.str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', ($ligne[ANN_GC_NOM]))))).' </td>'."\n"; |
$res .= '</tr>'."\n"; |
} |
$res .= '</tbody></table></div>'."\n"; |
} else { |
$res = '<p class="information">'.'Aucun inscrit n\'a de nom commençant par '.$_REQUEST['lettre'].'</p>'."\n"; |
} |
return $res; |
} |
function carto_formulaire() { |
$res = '<div id="redaction">'."\n"; |
$res .= '<div id="redaction_tete"></div>'."\n"; |
$res .= '<h2 class="chapo">'.ANN_ENVOYER_MAIL.'</h2>'."\n"; |
$res .= '<table>'."\n". |
'<tr><td class="texte">'.ANN_SUJET.' :</td>'."\n". |
'<td><input class="forml" type="text" name="titre_mail" size="60" value="'.$_POST['titre_mail'].'"/></td>'."\n". |
'</tr><tr><td class="texte" valign="top">'.ANN_MESSAGE.' : </td>'."\n". |
'<td><textarea class="forml" name="corps" rows="5" cols="60">'.$_POST['corps'].'</textarea></td>'."\n". |
'</tr><tr><td></td><td align="center">'; |
$res .='<input class="spip_bouton" type="submit" value="'.ANN_ENVOYER.'" />'; |
$res .= '</td>'."\n"; |
$res .= '</tr>'."\n"; |
$res .= '</table>'."\n"; |
$res .= '</form>'."\n"; |
$res .= '<div id="redaction_pied"/></div>'."\n"; |
$res .= '</div>'."\n"; |
$res .= '<p class="attention surveillance">'.ANN_SURVEILLANCE.'</p>' ; |
$res .= '<p class="information message_a_tous">'.sprintf(ANN_MESSAGE_A_TOUS, '<a href="'.ANN_URL_ACTUALITE.'">'.ANN_ACTUALITE.'</a>').'</p>' ; |
return $res ; |
} |
/** function carto_texte_cocher () |
* |
* |
* @return string HTML |
*/ |
function carto_texte_cocher() { |
$res .= '<div class="texte">'.ANN_CHECK_UNCHECK."\n"; |
$res .= ' <input type="checkbox" name="selecttotal" onclick="javascript:setCheckboxes(\'formmail\');"/>'."\n"; |
$res .= '</div>'; |
return $res; |
} |
/** envoie_mail() |
* |
* |
* @return envoie l'email |
*/ |
function envoie_mail($selection, $titre_mail, $corps) { |
$requete = 'SELECT '.ANN_CHAMPS_MAIL.' '. |
'FROM '.ANN_ANNUAIRE.' '. |
'WHERE '.ANN_CHAMPS_ID.' = "'.$GLOBALS['AUTH']->getAuthData(ANN_CHAMPS_ID).'" '; |
$resultat = $GLOBALS['ann_db']->query($requete); |
if (DB::isError($resultat)) { |
die($resultat->getMessage().'<br />'.$resultat->getDebugInfo()); |
} |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC); |
$liste = ''; |
$entete = '' ; |
foreach ($selection as $key => $value) { |
$liste .= $value."," ; |
} |
$precorps = $ligne[ANN_CHAMPS_MAIL]." ".ANN_EXPEDITEUR_ORIGINAL." \n" ; |
$precorps .= ANN_LISTE_DESTINATAIRES." : ".$liste." \n" ; |
$precorps .= ANN_TITRE_MAIL.' : '.$titre_mail." \n" ; |
$precorps .= "\n------".ANN_CONTENU_MESSAGE."------\n"; |
$corps = $precorps.$corps ; |
$corps .= "\n\n".ANN_PIED_MESSAGE."\n"; |
$corps .= "\n----------------------------------------------------------------------------"; |
$corps .= "\n".ANN_MESSAGE_APPLI."\n" ; |
//$corps .= "\n".ANN_MESSAGE_ENVOYE_A." :\n $liste" ; |
// Envoie du message au modérateur |
if(!mail(MAIL_MODERATION,ANN_TITRE_MAIL_MODERATION,$corps, $entete)) |
{ |
trigger_error("Le courriel n'a pas été envoyé à : $courriel", E_USER_WARNING); |
} |
/*foreach ($GLOBALS['mail_admin'] as $courriel) { |
if (!mail($courriel, $titre_mail, $corps, $entete)) { |
trigger_error("Le courriel n'a pas été envoyé à : $courriel", E_USER_WANRNING); |
} |
}*/ |
return '<div class="information">'.ANN_MAIL_ATTENTE_MODERATION.'</div>' ; |
} |
/** translittererVersIso88591() |
* |
* Convertit les caractères CP1252 (= ANSI) non présent dans l'ISO-8859-1 par un équivalant ressemblant. |
* |
* @return envoie l'email |
*/ |
function translittererCp1252VersIso88591($str, $translit = true) { |
$cp1252_entite_map = array( |
'\x80' => '€', /* EURO SIGN */ |
'\x82' => '‚', /* SINGLE LOW-9 QUOTATION MARK */ |
'\x83' => 'ƒ', /* LATIN SMALL LETTER F WITH HOOK */ |
'\x84' => '„', /* DOUBLE LOW-9 QUOTATION MARK */ |
'\x85' => '…', /* HORIZONTAL ELLIPSIS */ |
'\x86' => '†', /* DAGGER */ |
'\x87' => '‡', /* DOUBLE DAGGER */ |
'\x88' => 'ˆ', /* MODIFIER LETTER CIRCUMFLEX ACCENT */ |
'\x89' => '‰', /* PER MILLE SIGN */ |
'\x8a' => 'Š', /* LATIN CAPITAL LETTER S WITH CARON */ |
'\x8b' => '‹', /* SINGLE LEFT-POINTING ANGLE QUOTATION */ |
'\x8c' => 'Œ', /* LATIN CAPITAL LIGATURE OE */ |
'\x8e' => 'Ž', /* LATIN CAPITAL LETTER Z WITH CARON */ |
'\x91' => '‘', /* LEFT SINGLE QUOTATION MARK */ |
'\x92' => '’', /* RIGHT SINGLE QUOTATION MARK */ |
'\x93' => '“', /* LEFT DOUBLE QUOTATION MARK */ |
'\x94' => '”', /* RIGHT DOUBLE QUOTATION MARK */ |
'\x95' => '•', /* BULLET */ |
'\x96' => '–', /* EN DASH */ |
'\x97' => '—', /* EM DASH */ |
'\x98' => '˜', /* SMALL TILDE */ |
'\x99' => '™', /* TRADE MARK SIGN */ |
'\x9a' => 'š', /* LATIN SMALL LETTER S WITH CARON */ |
'\x9b' => '›', /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/ |
'\x9c' => 'œ', /* LATIN SMALL LIGATURE OE */ |
'\x9e' => 'ž', /* LATIN SMALL LETTER Z WITH CARON */ |
'\x9f' => 'Ÿ' /* LATIN CAPITAL LETTER Y WITH DIAERESIS*/ |
); |
$translit_map = array( |
'€' => 'Euro', /* EURO SIGN */ |
'‚' => ',', /* SINGLE LOW-9 QUOTATION MARK */ |
'ƒ' => 'f', /* LATIN SMALL LETTER F WITH HOOK */ |
'„' => ',,', /* DOUBLE LOW-9 QUOTATION MARK */ |
'…' => '...', /* HORIZONTAL ELLIPSIS */ |
'†' => '+', /* DAGGER */ |
'‡' => '++', /* DOUBLE DAGGER */ |
'ˆ' => '^', /* MODIFIER LETTER CIRCUMFLEX ACCENT */ |
'‰' => '0/00', /* PER MILLE SIGN */ |
'Š' => 'S', /* LATIN CAPITAL LETTER S WITH CARON */ |
'‹' => '<', /* SINGLE LEFT-POINTING ANGLE QUOTATION */ |
'Œ' => 'OE', /* LATIN CAPITAL LIGATURE OE */ |
'Ž' => 'Z', /* LATIN CAPITAL LETTER Z WITH CARON */ |
'‘' => "'", /* LEFT SINGLE QUOTATION MARK */ |
'’' => "'", /* RIGHT SINGLE QUOTATION MARK */ |
'“' => '"', /* LEFT DOUBLE QUOTATION MARK */ |
'”' => '"', /* RIGHT DOUBLE QUOTATION MARK */ |
'•' => '*', /* BULLET */ |
'–' => '-', /* EN DASH */ |
'—' => '--', /* EM DASH */ |
'˜' => '~', /* SMALL TILDE */ |
'™' => '(TM)', /* TRADE MARK SIGN */ |
'š' => 's', /* LATIN SMALL LETTER S WITH CARON */ |
'›' => '>', /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/ |
'œ' => 'oe', /* LATIN SMALL LIGATURE OE */ |
'ž' => 'z', /* LATIN SMALL LETTER Z WITH CARON */ |
'Ÿ' => 'Y' /* LATIN CAPITAL LETTER Y WITH DIAERESIS*/ |
); |
$str = strtr($str, $cp1252_entite_map); |
if ($translit) { |
$str = strtr($str, $translit_map); |
} |
return $str; |
} |
?> |
/tags/v4.0/client/annuaire/bibliotheque/Words.php |
---|
New file |
0,0 → 1,188 |
<?php |
/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */ |
// |
// +----------------------------------------------------------------------+ |
// | PHP version 4 | |
// +----------------------------------------------------------------------+ |
// | Copyright (c) 1997-2006 The PHP Group | |
// +----------------------------------------------------------------------+ |
// | This source file is subject to version 3.0 of the PHP license, | |
// | that is bundled with this package in the file LICENSE, and is | |
// | available at through the world-wide-web at | |
// | http://www.php.net/license/3_0.txt. | |
// | If you did not receive a copy of the PHP license and are unable to | |
// | obtain it through the world-wide-web, please send a note to | |
// | license@php.net so we can mail you a copy immediately. | |
// +----------------------------------------------------------------------+ |
// | Authors: Piotr Klaban <makler@man.torun.pl> | |
// +----------------------------------------------------------------------+ |
// |
// $Id: Words.php,v 1.4 2006/06/13 11:29:35 makler Exp $ |
// |
/** |
* The Numbers_Words class provides method to convert arabic numerals to |
* words (also with currency name). |
* |
* @author Piotr Klaban <makler@man.torun.pl> |
* @package Numbers_Words |
*/ |
// {{{ Numbers_Words |
/** |
* The Numbers_Words class provides method to convert arabic numerals to words. |
* |
* @access public |
* @author Piotr Klaban <makler@man.torun.pl> |
* @since PHP 4.2.3 |
* @package Numbers_Words |
*/ |
class Numbers_Words |
{ |
// {{{ toWords() |
/** |
* Converts a number to its word representation |
* |
* @param integer $num An integer between -infinity and infinity inclusive :) |
* that should be converted to a words representation |
* |
* @param string $locale Language name abbreviation. Optional. Defaults to en_US. |
* |
* @return string The corresponding word representation |
* |
* @access public |
* @author Piotr Klaban <makler@man.torun.pl> |
* @since PHP 4.2.3 |
*/ |
function toWords($num, $locale = 'en_US') { |
include_once("Words/lang.${locale}.php"); |
$classname = "Numbers_Words_${locale}"; |
if (!class_exists($classname)) { |
return Numbers_Words::raiseError("Unable to include the Numbers/Words/lang.${locale}.php file"); |
} |
$methods = get_class_methods($classname); |
if (!in_array('toWords', $methods) && !in_array('towords', $methods)) { |
return Numbers_Words::raiseError("Unable to find toWords method in '$classname' class"); |
} |
@$obj =& new $classname; |
return trim($obj->toWords($num)); |
} |
// }}} |
// {{{ toCurrency() |
/** |
* Converts a currency value to word representation (1.02 => one dollar two cents) |
* If the number has not any fraction part, the "cents" number is omitted. |
* |
* @param float $num A float/integer/string number representing currency value |
* |
* @param string $locale Language name abbreviation. Optional. Defaults to en_US. |
* |
* @param string $int_curr International currency symbol |
* as defined by the ISO 4217 standard (three characters). |
* E.g. 'EUR', 'USD', 'PLN'. Optional. |
* Defaults to $def_currency defined in the language class. |
* |
* @return string The corresponding word representation |
* |
* @access public |
* @author Piotr Klaban <makler@man.torun.pl> |
* @since PHP 4.2.3 |
*/ |
function toCurrency($num, $locale = 'en_US', $int_curr = '') { |
$ret = $num; |
@include_once("Numbers/Words/lang.${locale}.php"); |
$classname = "Numbers_Words_${locale}"; |
if (!class_exists($classname)) { |
return Numbers_Words::raiseError("Unable to include the Numbers/Words/lang.${locale}.php file"); |
} |
$methods = get_class_methods($classname); |
if (!in_array('toCurrencyWords', $methods) && !in_array('tocurrencywords', $methods)) { |
return Numbers_Words::raiseError("Unable to find toCurrencyWords method in '$classname' class"); |
} |
@$obj =& new $classname; |
if (strpos($num, '.') === false) |
{ |
$ret = trim($obj->toCurrencyWords($int_curr, $num)); |
} else { |
$currency = explode('.', $num, 2); |
/* add leading zero */ |
if (strlen($currency[1]) == 1) { |
$currency[1] .= '0'; |
} |
$ret = trim($obj->toCurrencyWords($int_curr, $currency[0], $currency[1])); |
} |
return $ret; |
} |
// }}} |
// {{{ getLocales() |
/** |
* Lists available locales for Numbers_Words |
* |
* @param string $int_curr International currency symbol |
* @param mixed string/array of strings $locale |
* Optional searched language name abbreviation. |
* Default: all available locales. |
* |
* @return array The available locales (optionaly only the requested ones) |
* @author Piotr Klaban <makler@man.torun.pl> |
* @author Bertrand Gugger, bertrand at toggg dot com |
* |
* @access public |
* @static |
*/ |
function getLocales($locale = null) { |
$ret = array(); |
if (isset($locale) && is_string($locale)) { |
$locale = array($locale); |
} |
$dname = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Words' . DIRECTORY_SEPARATOR; |
$dh=opendir($dname); |
if ($dh) { |
while ($fname = readdir($dh)) { |
if (preg_match('#^lang\.([a-z_]+)\.php$#i', $fname, $matches)) { |
if (is_file($dname . $fname) && is_readable($dname . $fname) && |
(!isset($locale) || in_array($matches[1], $locale))) { |
$ret[] = $matches[1]; |
} |
} |
} |
closedir($dh); |
sort($ret); |
} |
return $ret; |
} |
// }}} |
// {{{ raiseError() |
/** |
* Trigger a PEAR error |
* |
* To improve performances, the PEAR.php file is included dynamically. |
* |
* @param string error message |
*/ |
function raiseError($msg) |
{ |
include_once('PEAR.php'); |
return PEAR::raiseError($msg); |
} |
// }}} |
} |
// }}} |
?> |