Translation2
[ class tree: Translation2 ] [ index: Translation2 ] [ all elements ]

Class: Translation2_Decorator

Source Location: /Translation2-2.0.0beta4/Decorator.php

Class Overview


Decorates a Translation2 class.


Author(s):

Variables

Methods


Child classes:

Translation2_Decorator_Iconv
Decorator to change the encoding of the stored translation to the one given in the 'encoding' option.
Translation2_Decorator_DefaultText
Decorator to provide a fallback text for empty strings.
Translation2_Decorator_CacheMemory
Decorator to cache fetched data in memory
Translation2_Decorator_Lang
Decorator to provide a fallback language for empty strings.
Translation2_Decorator_UTF8
Decorator to convert UTF-8 strings to ISO-8859-1
Translation2_Decorator_SpecialChars
Decorator to replace special chars with the matching html entities.
Translation2_Decorator_CacheLiteFunction
Decorator to cache fetched data using Cache_Lite_Function class
Translation2_Admin_Decorator
Decorates a Translation2_Admin class.

Inherited Variables

Inherited Methods


Class Details

[line 31]
Decorates a Translation2 class.

Create a subclass of this class for your own "decoration".

  • Abstract:


[ Top ]


Class Variables

$currentPageID =

[line 59]

  • Access: protected

Type:   string


[ Top ]

$lang =

[line 53]

  • Access: protected

Type:   array


[ Top ]

$storage =

[line 47]

Used for debug only.
  • Access: protected

Type:   object


[ Top ]

$translation2 =

[line 40]

Translation2 object being decorated
  • Access: protected

Type:   object


[ Top ]



Method Detail

Translation2_Decorator (Constructor)   [line 70]

Translation2_Decorator Translation2_Decorator( object Translation2 &$translation2)

Constructor

Constructs the Translation2_Decorator


Parameters:

object Translation2   &$translation2   —  object to decorate

[ Top ]

get   [line 213]

string get( string $stringID, [string $pageID = TRANSLATION2_DEFAULT_PAGEID], [string $langID = null], [string $defaultText = ''])

Get translated string

All the filters are applied.


Overridden in child classes as:

Translation2_Decorator_Iconv::get()
Get the translated string, in the new encoding
Translation2_Decorator_DefaultText::get()
Get translated string
Translation2_Decorator_CacheMemory::get()
Get translated string
Translation2_Decorator_Lang::get()
Get translated string
Translation2_Decorator_UTF8::get()
Get translated string
Translation2_Decorator_SpecialChars::get()
Get translated string
Translation2_Decorator_CacheLiteFunction::get()
Get translated string
Translation2_Admin_Decorator_Autoadd::get()
Get a translated string

Parameters:

string   $stringID   — 
string   $pageID   — 
string   $langID   — 
string   $defaultText   —  Text to display when the strings in both the default and the fallback lang are empty

[ Top ]

getDecorator   [line 125]

object Decorator &getDecorator( string $decorator, object [optional] 1)

Return an instance of a decorator
  • Return: object reference
  • Access: public

Parameters:

string   $decorator   —  Name of the decorator
object [optional]   1   — 

[ Top ]

getLang   [line 168]

mixed getLang( [string $langID = null], [string $format = 'name'])

get lang info
  • Return: [string | array], depending on $format

Parameters:

string   $langID   — 
string   $format   —  ['name', 'meta', 'error_text', 'array']

[ Top ]

getLangs   [line 181]

array getLangs( [string $format = 'name'])

get langs

Parameters:

string   $format   —  ['ids', 'names', 'array']

[ Top ]

getPage   [line 246]

array getPage( [string $pageID = TRANSLATION2_DEFAULT_PAGEID], [string $langID = null], [ $defaultText = ''])

Same as getRawPage, but resort to fallback language and replace parameters when needed

Overridden in child classes as:

Translation2_Decorator_Iconv::getPage()
Same as getRawPage, but apply transformations when needed
Translation2_Decorator_DefaultText::getPage()
Replace empty strings with their $stringID
Translation2_Decorator_CacheMemory::getPage()
Same as getRawPage, but resort to fallback language and replace parameters when needed
Translation2_Decorator_Lang::getPage()
Same as getRawPage, but resort to fallback language and replace parameters when needed
Translation2_Decorator_UTF8::getPage()
Same as getRawPage, but resort to fallback language and replace parameters when needed
Translation2_Decorator_SpecialChars::getPage()
Same as getRawPage, but apply transformations when needed
Translation2_Decorator_CacheLiteFunction::getPage()
Same as getRawPage, but resort to fallback language and replace parameters when needed

Parameters:

string   $pageID   — 
string   $langID   — 
   $defaultText   — 

[ Top ]

getRawPage   [line 230]

array getRawPage( [string $pageID = TRANSLATION2_DEFAULT_PAGEID], [string $langID = null])

Get the array of strings in a page

Fetch the strings from the container, without any replacing


Overridden in child classes as:

Translation2_Decorator_CacheMemory::getRawPage()
Get the array of strings in a page
Translation2_Decorator_CacheLiteFunction::getRawPage()
Get the array of strings in a page

Parameters:

string   $pageID   — 
string   $langID   — 

[ Top ]

getStringID   [line 306]

string getStringID( string $string, [string $pageID = TRANSLATION2_DEFAULT_PAGEID])

Get the stringID for the given string. This method is the reverse of get().

Overridden in child classes as:

Translation2_Decorator_DefaultText::getStringID()
Get the stringID for the given string. This method is the reverse of get().
Translation2_Decorator_CacheLiteFunction::getStringID()
Get translated string

Parameters:

string   $string   —  This is NOT the stringID, this is a real string. The method will search for its matching stringID, and then it will return the associate string in the selected language.
string   $pageID   — 

[ Top ]

replaceEmptyStringsWithKeys   [line 272]

void replaceEmptyStringsWithKeys( $strings, mixed $params)

Replace empty strings with their stringID
  • Access: public

Parameters:

mixed   $params   — 
   $strings   — 

[ Top ]

setLang   [line 142]

void setLang( string $langID)

Set default lang

Parameters:

string   $langID   — 

[ Top ]

setOption   [line 105]

void setOption( string $option, [mixed $value = null])

set Decorator option

Overridden in child classes as:

Translation2_Decorator_Lang::setOption()
set Decorator option (intercept 'fallbackLang' option).

Parameters:

string   $option   —  option name
mixed   $value   —  option value

[ Top ]

setOptions   [line 87]

void setOptions( [array $options = array()])

set Decorator options

Parameters:

array   $options   —  options

[ Top ]

setPageID   [line 154]

void setPageID( [ $pageID = null], string $langID)

Set default page

Parameters:

string   $langID   — 
   $pageID   — 

[ Top ]

setParams   [line 193]

void setParams( [array $params = null])

Set parameters for next string

Parameters:

array   $params   — 

[ Top ]

translate   [line 289]

string translate( string $string, string $langID, [ $pageID = TRANSLATION2_DEFAULT_PAGEID])

Get translated string

Parameters:

string   $string   —  This is NOT the stringID, this is a real string. The method will search for its matching stringID, and then it will return the associate string in the selected language.
string   $langID   — 
   $pageID   — 

[ Top ]

_replaceParams   [line 259]

void _replaceParams( $strings, mixed $params)

Replace parameters in strings
  • Access: protected

Parameters:

mixed   $params   — 
   $strings   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 13:58:51 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.