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

Class: Translation2_Decorator

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

Class Overview


Translation2_Decorator. Base Decorator class for Translation2


Author(s):

Copyright:

  • 2004-2005 Lorenzo Alberton

Variables

Methods


Child classes:

Translation2_Decorator_Iconv
Translation2 Iconv Decorator
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_ErrorText
Decorator to provide a fallback text 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 the Cache_Lite_Function class.
Translation2_Admin_Decorator
Decorates a Translation2_Admin class.

Inherited Variables

Inherited Methods


Class Details

[line 39]
Translation2_Decorator. Base Decorator class for Translation2

Extend this class to provide custom decorators. Some decorators are already bundled with the package.



[ Top ]


Class Variables

$currentPageID =

[line 66]

  • Access: protected

Type:   string


[ Top ]

$lang =

[line 60]

  • Access: protected

Type:   array


[ Top ]

$storage =

[line 54]

  • Access: protected

Type:   object


[ Top ]

$translation2 =

[line 48]

Translation2 object being decorated
  • Access: protected

Type:   object


[ Top ]



Method Detail

Translation2_Decorator (Constructor)   [line 77]

Translation2_Decorator Translation2_Decorator( object Translation2 &$translation2)

Constructor

Constructs the Translation2_Decorator


Parameters:

object Translation2   &$translation2   —  object to decorate

[ Top ]

get   [line 256]

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_ErrorText::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 string is empty NB: This parameter is only used in the DefaultText decorator

[ Top ]

getDecorator   [line 147]

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 191]

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 204]

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

get langs

Parameters:

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

[ Top ]

getPage   [line 289]

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

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_ErrorText::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   — 

[ Top ]

getRaw   [line 236]

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

Get translated string

No filter is applied.


Overridden in child classes as:

Translation2_Decorator_CacheMemory::getRaw()
Get translated string (as-is)
Translation2_Decorator_CacheLiteFunction::getRaw()
Get translated string (as-is)

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 ]

getRawPage   [line 273]

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 349]

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 315]

void replaceEmptyStringsWithKeys( $strings, mixed $params)

Replace empty strings with their stringID
  • Access: public

Parameters:

mixed   $params   — 
   $strings   — 

[ Top ]

setContainerOptions   [line 131]

void setContainerOptions( array $options)

Set some storage driver options
  • Access: protected

Parameters:

array   $options   — 

[ Top ]

setLang   [line 165]

void setLang( string $langID)

Set default lang

Parameters:

string   $langID   — 

[ Top ]

setOption   [line 112]

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 94]

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

set Decorator options

Parameters:

array   $options   —  options

[ Top ]

setPageID   [line 177]

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

Set default page

Parameters:

string   $langID   — 
   $pageID   — 

[ Top ]

setParams   [line 216]

void setParams( [array $params = null])

Set parameters for next string

Parameters:

array   $params   — 

[ Top ]

translate   [line 332]

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 302]

void _replaceParams( $strings, mixed $params)

Replace parameters in strings
  • Access: protected

Parameters:

mixed   $params   — 
   $strings   — 

[ Top ]

__clone   [line 364]

void __clone( )

Clone internal object references

This method is called automatically by PHP5

  • Access: protected

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:18:26 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.