CFormatter

Nameformat
ClassCFormatter
Location/home/vhosts/app-manager.eu5.org/framework/utils/CFormatter.php
CFormatter provides a set of commonly used data formatting methods.

The formatting methods provided by CFormatter are all named in the form of formatXyz. The behavior of some of them may be configured via the properties of CFormatter. For example, by configuring {@link dateFormat}, one may control how {@link formatDate} formats the value into a date string. For convenience, CFormatter also implements the mechanism of calling formatting methods with their shortcuts (called types). In particular, if a formatting method is named formatXyz, then its shortcut method is xyz (case-insensitive). For example, calling $formatter->date($value) is equivalent to calling $formatter->formatDate($value). Currently, the following types are recognizable:
  • raw: the attribute value will not be changed at all.
  • text: the attribute value will be HTML-encoded when rendering.
  • ntext: the {@link formatNtext} method will be called to format the attribute value as a HTML-encoded plain text with newlines converted as the HTML <br /> tags.
  • html: the attribute value will be purified and then returned.
  • date: the {@link formatDate} method will be called to format the attribute value as a date.
  • time: the {@link formatTime} method will be called to format the attribute value as a time.
  • datetime: the {@link formatDatetime} method will be called to format the attribute value as a date with time.
  • boolean: the {@link formatBoolean} method will be called to format the attribute value as a boolean display.
  • number: the {@link formatNumber} method will be called to format the attribute value as a number display.
  • email: the {@link formatEmail} method will be called to format the attribute value as a mailto link.
  • image: the {@link formatImage} method will be called to format the attribute value as an image tag where the attribute value is the image URL.
  • url: the {@link formatUrl} method will be called to format the attribute value as a hyperlink where the attribute value is the URL.
By default, {@link CApplication} registers {@link CFormatter} as an application component whose ID is 'format'. Therefore, one may call Yii::app()->format->boolean(1).

Options

Displaying 1-7 of 7 results.
NameValueDescriptionType
dateFormat'Y/m/d'The format string to be used to format a date using PHP date() function. Defaults to 'Y/m/d'.string
timeFormat'h:i:s A'The format string to be used to format a time using PHP date() function. Defaults to 'h:i:s A'.string
datetimeFormat'Y/m/d h:i:s A'The format string to be used to format a date and time using PHP date() function. Defaults to 'Y/m/d h:i:s A'.string
numberFormatarray ( 'decimals' => null, 'decimalSeparator' => null, 'thousandSeparator' => null, )The format used to format a number with PHP number_format() function. Three elements may be specified: "decimals", "decimalSeparator" and "thousandSeparator". They correspond to the number of digits after the decimal point, the character displayed as the decimal point, and the thousands separator character.array
booleanFormatarray ( 'No', 'Yes', )The text to be displayed when formatting a boolean value. The first element corresponds to the text display for false, the second element for true. Defaults to <code>array('No', 'Yes')</code>.array
sizeFormatarray ( 'base' => 1024, 'decimals' => 2, )The format used to format size (bytes). Two elements may be specified: "base" and "decimals". They correspond to the base at which KiloByte is calculated (1000 or 1024) bytes per KiloByte and the number of digits after decimal point.array
behaviorsarray()The behaviors that should be attached to this component. The behaviors will be attached to the component when {@link init} is called. Please refer to {@link CModel::behaviors} on how to specify the value of this property.array
Free Web Hosting