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.

= 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
Decorator to cache fetched data in memory (Previous) Decorator to provide a fallback error_text message for empty strings. (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.