Stud.IP  5.4
 All Data Structures Namespaces Files Functions Variables Groups
I18NString Class Reference
Inheritance diagram for I18NString:
I18NStringDatafield

Public Member Functions

 __construct ($base, $lang=null, $metadata=[])
 
 __toString ()
 
 jsonSerialize ()
 
 setOriginal ($text)
 
 setTranslations ($lang)
 
 setMetadata ($metadata)
 
 original ()
 
 translation ($lang)
 
 localized ($lang)
 
 setLocalized ($text, $lang)
 
 toArray ()
 
 trim ($symbols=" \t\n\r\0\x0B")
 
 storeTranslations ()
 
 removeTranslations ()
 

Static Public Member Functions

static setContentLanguage ($language)
 
static getContentLanguage ()
 
static setDefaultLanguage ($language=null)
 
static getDefaultLanguage ()
 
static load ($object_id, $table, $field, $base=null)
 
static fetchDataForField ($object_id, $table, $field)
 
static fetchDataForRow ($object_id, $table)
 
static removeAllTranslations ($object_id, $table, $lang=null)
 

Protected Attributes

 $base
 
 $lang
 
 $metadata
 

Static Protected Attributes

static $content_language = null
 
static $default_language = null
 

Detailed Description

I18NString class

Constructor & Destructor Documentation

__construct (   $base,
  $lang = null,
  $metadata = [] 
)

Initialize a new I18NString instance.

Parameters
string$baseText in default content language.
array$langText in additional languages.
array$metadataDatabase info for id, table, field.

Member Function Documentation

__toString ( )

Return the text representation of this i18n field in selected language. The language is selected by self::content_language (with precendence) or by $_SESSION['_language'].

Returns
string
static fetchDataForField (   $object_id,
  $table,
  $field 
)
static

Retrieves all translations of one field.

Parameters
string$object_idThe id of the object with i18n fields.
string$tableThe name of the table with the original values.
string$fieldThe name of the i18n field.
Returns
array An array with language as key and translation as value.
static fetchDataForRow (   $object_id,
  $table 
)
static

Retrieves all translations of all fields for given object (by id) and table.

Parameters
string$object_idThe id of the object with i18n fields.
string$tableThe name of the table with the original values.
Returns
array An array with all translations of all fields grouped by field.
static getContentLanguage ( )
static

Returns the language the contnet is translated into.

Returns
string The language the content is translated into.
static getDefaultLanguage ( )
static

Returns the language all values are translated into by default. The language ist normally defined in $GLOBALS'CONTENT_LANGUAGES'.

Returns
string The default language all values are translated into.
jsonSerialize ( )

Return the JSON representation of this i18n field in selected language.

Returns
string
static load (   $object_id,
  $table,
  $field,
  $base = null 
)
static

Returns an I18NString object by given object_id, table and field.

Parameters
string$object_idThe id of the object with i18n fields.
string$tableThe name of the table with the original values.
string$fieldThe name of the i18n field.
string$baseSets the original value or retrieve it from database if null.
Returns
I18NString The I18NString object.
localized (   $lang)

Returns the string in the specified language (additional languages and default languages).

Parameters
string$langAdditional language or default language.
Returns
string The localized string.
original ( )

Return the string in the default content language.

Returns
string String in default content language.
static removeAllTranslations (   $object_id,
  $table,
  $lang = null 
)
static

Removes all translations by given object id and table name. Accepts the language as third parameter to remove only translations to this language.

Parameters
string$object_idThe id of the sorm object.
string$tableThe table name.
string$langOptional name of language.
Returns
int The number of deleted translations.
removeTranslations ( )

Removes all translations for this I18NString object.

static setContentLanguage (   $language)
static

Sets the language the content is translated into.

Parameters
string$language
static setDefaultLanguage (   $language = null)
static

Sets the default language the content is translated into. The default is normally defined by the first entry in $GLOBALS'CONTENT_LANGUAGES'.

Parameters
string$language
setLocalized (   $text,
  $lang 
)

Sets the translation for the given language. If the given language is the default language, sets the original.

Parameters
type$textThe translated or original value.
type$langThe additional or default language.
Returns
string The translated or original value.
Exceptions
InvalidArgumentException
setMetadata (   $metadata)

Sets the metadata (database info for id, table, field) of this i18n field.

Parameters
array$metadataDatabase info for id, table, field.
setOriginal (   $text)

Sets the original (untranslated) value of this i18n field.

Parameters
string$textThe original value.
Returns
string The original value.
setTranslations (   $lang)

Sets all translations of this i18n field.

Parameters
array$langAn array with languages as keys and translations as values.
Returns
array The array with translations.
storeTranslations ( )

Stores the i18n String manually in the database

toArray ( )

Return an array containing the text in all additional languages.

Returns
array The array with translations.
translation (   $lang)

Return the string in the specified additional language.

Parameters
stringThe additional language.
Returns
string The translated value.
trim (   $symbols = " \t\n\r\0\x0B")

Trim all language strings

Parameters
string$symbolsAll symbols to trim.
Returns
I18NString Returns this.

Field Documentation

$base
protected
$content_language = null
staticprotected
$default_language = null
staticprotected
$lang
protected
$metadata
protected

The documentation for this class was generated from the following file: