Class Summary Translation2_Decorator_CacheMemory (Previous) (Next) Class Summary Translation2_Decorator_ErrorText

View this page in Last updated: Sun, 11 May 2008
English | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Plain HTML

Class Summary Translation2_Decorator_DefaultText

Class Summary Translation2_Decorator_DefaultText  -- Decorator to provide a fallback text for empty strings.

DefaultText Decorator Example

When the fetched string is empty, it replaces it with the 4th parameter of the get() method, i.e. $defaultText. If the defaultText parameter is empty too, then return "$emptyPostfix.$outputString.$emptyPrefix", the three variables being class properties you can set to a custom string.

When getPage() is called, all the empty strings in the page are replaced by their stringID value.


<?php
$tr = new Translation2($driver$dbinfo$params);
$tr =& $tr->getDecorator('DefaultText');

// %stringID% will be replaced with the stringID
// %pageID_url% will be replaced with the pageID
// %stringID_url% will replaced with a urlencoded stringID
// %url% will be replaced with the targeted url
$tr->outputString '%stringID%<a href="%url%">(T)</a>'//default: '%stringID%'
$tr->url '#';           //same as default
$tr->emptyPrefix  '[';  //default: empty string
$tr->emptyPostfix ']';  //default: empty string
?>

Class Summary Translation2_Decorator_CacheMemory (Previous) (Next) Class Summary Translation2_Decorator_ErrorText

Download Documentation Last updated: Sun, 11 May 2008
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.