[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/I18N/core/ -> ChoiceFormat.php (sommaire)

ChoiceFormat class file. This program is free software; you can redistribute it and/or modify it under the terms of the BSD License.

Author: Wei Zhuo
Version: $Revision: 1.1 $ $Date: 2005/01/11 07:19:39 $
Poids: 186 lignes (5 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

ChoiceFormat:: (4 méthodes):
  __construct()
  isValid()
  parse()
  format()


Classe: ChoiceFormat  - X-Ref

ChoiceFormat class.

ChoiceFormat converts between ranges of numeric values and string
names for those ranges.

A ChoiceFormat splits the real number line -Inf to +Inf into two or
more contiguous ranges. Each range is mapped to a string.
ChoiceFormat is generally used in a MessageFormat for displaying
grammatically correct plurals such as "There are 2 files."

<code>
$string = '[0] are no files |[1] is one file |(1,Inf] are {number} files';

$formatter = new MessageFormat(...); //init for a source
$translated = $formatter->format($string);

$choice = new ChoiceFormat();
echo $choice->format($translated, 0); //shows "are no files"
</code>

The message/string choices are separated by the pipe "|" followed
by a set notation of the form
# <t>[1,2]</t> -- accepts values between 1 and 2, inclusive.
# <t>(1,2)</t> -- accepts values between 1 and 2, excluding 1 and 2.
# <t>{1,2,3,4}</t> -- only values defined in the set are accepted.
# <t>[-Inf,0)</t> -- accepts value greater or equal to negative infinity
and strictly less than 0
Any non-empty combinations of the delimiters of square and round brackets
are acceptable.

__construct()   X-Ref
Constructor.


isValid($number, $set)   X-Ref
Determine if the given number belongs to a given set

param: float the number to test.
param: string the set, in set notation.
return: boolean true if number is in the set, false otherwise.

parse($string)   X-Ref
Parse a choice string and get a list of sets and a list of strings
corresponding to the sets.

param: string the string containing the choices
return: array array($sets, $strings)

format($string, $number)   X-Ref
For the choice string, and a number, find and return the
string that satisfied the set within the choices.

param: string the choices string.
param: float the number to test.
return: string the choosen string.



Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7