Stud.IP  4.1 Revision
I18NString Class Reference
Inheritance diagram for I18NString:
Inheritance graph
Collaboration diagram for I18NString:
Collaboration graph

Public Member Functions

 __construct ($base, $lang=null, $metadata=[])
 
 __toString ()
 
 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()

__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()

__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
Here is the call graph for this function:

◆ fetchDataForField()

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.

Reimplemented in I18NStringDatafield.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fetchDataForRow()

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.

Reimplemented in I18NStringDatafield.

Here is the call graph for this function:

◆ getContentLanguage()

static getContentLanguage ( )
static

Returns the language the contnet is translated into.

Returns
string The language the content is translated into.
Here is the call graph for this function:

◆ getDefaultLanguage()

static getDefaultLanguage ( )
static

Returns the language all values are translated into by default. The language ist normally defined in $GLOBALS['CONTENT_LANGUAGES'] (see config_defaults.inc.php).

Returns
string The default language all values are translated into.
Here is the caller graph for this function:

◆ load()

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.

Reimplemented in I18NStringDatafield.

Here is the call graph for this function:

◆ localized()

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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ original()

original ( )

Return the string in the default content language.

Returns
string String in default content language.

◆ removeAllTranslations()

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.

Reimplemented in I18NStringDatafield.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeTranslations()

removeTranslations ( )

Removes all translations for this I18NString object.

Here is the call graph for this function:

◆ setContentLanguage()

static setContentLanguage (   $language)
static

Sets the language the content is translated into.

Parameters
string$language
Here is the caller graph for this function:

◆ setDefaultLanguage()

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'] (see config_defaults.inc.php).

Parameters
string$language

◆ setLocalized()

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
Here is the call graph for this function:

◆ setMetadata()

setMetadata (   $metadata)

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

Parameters
array$metadataDatabase info for id, table, field.

◆ setOriginal()

setOriginal (   $text)

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

Parameters
string$textThe original value.
Returns
string The original value.
Here is the caller graph for this function:

◆ setTranslations()

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()

storeTranslations ( )

Stores the i18n String manually in the database

Reimplemented in I18NStringDatafield.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toArray()

toArray ( )

Return an array containing the text in all additional languages.

Returns
array The array with translations.

Reimplemented in I18NStringDatafield.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ translation()

translation (   $lang)

Return the string in the specified additional language.

Parameters
stringThe additional language.
Returns
string The translated value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ trim()

trim (   $symbols = " \t\n\r\0\x0B")

Trim all language strings

Parameters
string$symbolsAll symbols to trim.
Returns
I18NString Returns this.
Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ $base

$base
protected

◆ $content_language

$content_language = null
staticprotected

◆ $default_language

$default_language = null
staticprotected

◆ $lang

$lang
protected

◆ $metadata

$metadata
protected

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