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

Class: Translation2_Decorator

Source Location: /Translation2-2.0.4/Translation2/Decorator.php

Class Overview

Translation2
   |
   --Translation2_Decorator

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: Translation2

Translation2::Translation2()
Constructor
Translation2::factory()
Return a Translation2 instance already initialized
Translation2::get()
Get translated string
Translation2::getDecorator()
Return an instance of a decorator
Translation2::getLang()
get lang info
Translation2::getLangs()
get langs
Translation2::getPage()
Get an entire group of strings
Translation2::getRaw()
Get translated string (as-is)
Translation2::getRawPage()
Get the array of strings in a page
Translation2::getStringID()
Get the stringID for the given string. This method is the reverse of get().
Translation2::replaceEmptyStringsWithKeys()
Replace empty strings with their stringID
Translation2::setCharset()
Set charset used to read/store the translations
Translation2::setContainerOptions()
Set some storage driver options
Translation2::setLang()
Set default lang
Translation2::setPageID()
Set default page
Translation2::setParams()
Set parameters for next string
Translation2::_replaceParams()
Replace parameters in strings
Translation2::__clone()
Clone internal object references

Class Details

[line 53]
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 80]

  • Access: protected

Type:   string
Overrides:   Array


[ Top ]

$lang =

[line 74]

  • Access: protected

Type:   array
Overrides:   Array


[ Top ]

$storage =

[line 68]

  • Access: protected

Type:   object
Overrides:   Array


[ Top ]

$translation2 =

[line 62]

Translation2 object being decorated
  • Access: protected

Type:   object


[ Top ]



Method Detail

Translation2_Decorator (Constructor)   [line 91]

Translation2_Decorator Translation2_Decorator( object &$translation2)

Constructor Constructs the Translation2_Decorator

Parameters:

object   &$translation2   —  Translation2 object to decorate

[ Top ]

get   [line 308]

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

Overrides Translation2::get() (Get translated string)

Parameters:

string   $stringID   —  string ID
string   $pageID   —  page/group ID
string   $langID   —  language ID
string   $defaultText   —  Text to display when the string is empty NB: This parameter is only used in the DefaultText decorator

[ Top ]

getDecorator   [line 169]

object Decorator &getDecorator( string $decorator, object $object)

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

Overrides Translation2::getDecorator() (Return an instance of a decorator)

Parameters:

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

[ Top ]

getLang   [line 236]

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

Get language info
  • Return: [string | array], depending on $format

Overridden in child classes as:

Translation2_Decorator_CacheLiteFunction::getLang()
get lang info

Overrides Translation2::getLang() (get lang info)

Parameters:

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

[ Top ]

getLangs   [line 251]

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

Get languages

Overridden in child classes as:

Translation2_Decorator_CacheLiteFunction::getLangs()
get langs

Overrides Translation2::getLangs() (get langs)

Parameters:

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

[ Top ]

getPage   [line 343]

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

Overrides Translation2::getPage() (Get an entire group of strings)

Parameters:

string   $pageID   —  page/group ID
string   $langID   —  language ID

[ Top ]

getRaw   [line 287]

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)

Overrides Translation2::getRaw() (Get translated string (as-is))

Parameters:

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

[ Top ]

getRawPage   [line 326]

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

Overrides Translation2::getRawPage() (Get the array of strings in a page)

Parameters:

string   $pageID   —  page/group ID
string   $langID   —  language ID

[ Top ]

getStringID   [line 393]

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

Overrides Translation2::getStringID() (Get the stringID for the given string. This method is the reverse of get().)

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   —  page/group ID

[ Top ]

replaceEmptyStringsWithKeys   [line 375]

array replaceEmptyStringsWithKeys( array $strings)

Replace empty strings with their stringID
  • Access: public

Overrides Translation2::replaceEmptyStringsWithKeys() (Replace empty strings with their stringID)

Parameters:

array   $strings   —  array of strings to be replaced if empty

[ Top ]

setCharset   [line 190]

PEAR_Error setCharset( string $charset)

Set charset used to read/store the translations
  • Return: on failure

Overrides Translation2::setCharset() (Set charset used to read/store the translations)

Parameters:

string   $charset   —  character set (encoding)

[ Top ]

setContainerOptions   [line 152]

void setContainerOptions( array $options)

Set some storage driver options
  • Access: protected

Overrides Translation2::setContainerOptions() (Set some storage driver options)

Parameters:

array   $options   —  storage driver options

[ Top ]

setLang   [line 205]

true|PEAR_Error setLang( string $langID)

Set default language

Overridden in child classes as:

Translation2_Decorator_CacheLiteFunction::setLang()
Set default lang

Overrides Translation2::setLang() (Set default lang)

Parameters:

string   $langID   —  language ID

[ Top ]

setOption   [line 131]

self 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 110]

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

set Decorator options

Parameters:

array   $options   —  decorator options

[ Top ]

setPageID   [line 220]

void setPageID( [string $pageID = null])

Set default page

Overrides Translation2::setPageID() (Set default page)

Parameters:

string   $pageID   —  page/group ID

[ Top ]

setParams   [line 266]

void setParams( [array $params = null])

Set parameters for next string

Overrides Translation2::setParams() (Set parameters for next string)

Parameters:

array   $params   —  array of replacement parameters

[ Top ]

_replaceParams   [line 359]

mixed _replaceParams( mixed $strings)

Replace parameters in strings
  • Access: protected

Overrides Translation2::_replaceParams() (Replace parameters in strings)

Parameters:

mixed   $strings   —  strings where the replacements must occur

[ Top ]

__clone   [line 409]

void __clone( )

Clone internal object references

This method is called automatically by PHP5

  • Access: protected

Overrides Translation2::__clone() (Clone internal object references)
[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:41:50 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.