Class \Scrivo\Language

Class that represents a language.

Pages (and possible HTML elements) can have a language attribute. For that reason Scrivo maintains a table of (primary) language codes.

To facilitate language selection a short list of languages can be compiled. In the user interface language selection will be limited to those that are on the short list.

Since the primary purpose of the language class is to fill language selection dialogs the full display name of the languages is stored in both Dutch and English.

TODO: This should be refactored. There is no need for a seperate class: ISO language codes will do fully here. An other undesirable feature is the storage of i18n data (the full language names) in the database.

Defined in: Language.php.


Constructor summary

Attr. Name / Description
public

Language($context)

Create an empty language object.

Properties

Attr. Type Name Description
\..\String $family The language family (Germanic, Slavic).
read-only int $id The language id (DB key).
\..\String $isoCode The language ISO code.
\..\String $nameEn The language name in English.
\..\String $nameNl The language name in Dutch.
boolean $shortList Whether a language is on the short list or not.

Member summary

Attr. Type Name Description
private \..\Context $context A Scrivo context.
private \..\String $family The language family (Germanic, Slavic).
private int $id The language id (DB key).
private \..\String $isoCode The language ISO code.
private \..\String $nameEn The language name in English.
private \..\String $nameNl The language name in Dutch.
private boolean $shortList Whether a language is on the short list or not.

Method summary

Attr. Type Name / Description
public mixed

__get($name)

Implementation of the readable properties using the PHP magic method __get().

public

__set($name, $value)

Implementation of the writable properties using the PHP magic method __set().

public static

delete($context, $id)

Delete existing language data from the database.

public static \..\Language

fetch($context, $id)

Fetch a language object by from the database using the object id.

public

insert()

Insert new language object data into the database.

public static \..\Language[]

select($context, $shortList)

Select languages from the database.

private

setFamily($family)

Set the language family (Germanic, Slavic).

private

setFields($context, $rd)

Convenience method to set the fields of a language object from an array (result set row).

private

setIsoCode($isoCode)

Set the language ISO code.

private

setNameEn($nameEn)

Set the language name in English.

private

setNameNl($nameNl)

Set the language name in Dutch.

private

setShortList($shortList)

Set the value to indicate if a language is on the short list or not.

public

update()

Update an existing language object data in the database.

private static

validateDelete($context, $id)

Check if deletion of language object data does not violate any business rules.

private

validateInsert()

Check if this language object can be inserted into the database.

private

validateUpdate()

Check if this language object can be updated in the database.

 


Constructor

public Language(\Scrivo\Context $context=null)

Create an empty language object.

Parameters:

Type Name Def. Description
\Scrivo\Context $context null

A Scrivo context.


Members


				
private \Scrivo\Context $context

A Scrivo context.

Inital value: null


				
private \Scrivo\String $family

The language family (Germanic, Slavic).

Inital value: null


				
private int $id

The language id (DB key).

Inital value: 0


				
private \Scrivo\String $isoCode

The language ISO code.

Inital value: null


				
private \Scrivo\String $nameEn

The language name in English.

Inital value: null


				
private \Scrivo\String $nameNl

The language name in Dutch.

Inital value: null


				
private boolean $shortList

Whether a language is on the short list or not.

Inital value: false


Methods

public mixed __get(string $name)

Implementation of the readable properties using the PHP magic method __get().

Parameters:

Type Name Def. Description
string $name

The name of the property to get.

Returns:

mixed Implementation of the readable properties using the PHP magic method __get().

public __set(string $name, mixed $value)

Implementation of the writable properties using the PHP magic method __set().

Parameters:

Type Name Def. Description
string $name

The name of the property to set.

mixed $value

The value of the property to set.

public static delete(\Scrivo\Context $context, int $id)

Delete existing language data from the database.

First it is is checked if it's possible to delete language data, then the language data including its dependecies is deleted from the database.

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

int $id

The object id of the language to select.

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or if it is not possible to delete the language data.
public static \Scrivo\Language fetch(\Scrivo\Context $context, int $id)

Fetch a language object by from the database using the object id.

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

int $id

The object id of the language to select.

Returns:

\Scrivo\Language Fetch a language object by from the database using the object id.

public insert()

Insert new language object data into the database.

First it is checked if the data of this language object can be inserted into the database, then the data is inserted into the database. If no id was set a new object id is generated.

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data.
public static \Scrivo\Language[id] select(\Scrivo\Context $context, boolean $shortList=null)

Select languages from the database.

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

boolean $shortList null

A Scrivo context.

Returns:

\Scrivo\Language[id] Select languages from the database.

private setFamily(\Scrivo\String $family)

Set the language family (Germanic, Slavic).

Parameters:

Type Name Def. Description
\Scrivo\String $family

The language family (Germanic, Slavic).

private setFields(\Scrivo\Context $context, array $rd)

Convenience method to set the fields of a language object from an array (result set row).

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

array $rd

An array containing the field data using the database field names as keys.

private setIsoCode(\Scrivo\String $isoCode)

Set the language ISO code.

Parameters:

Type Name Def. Description
\Scrivo\String $isoCode

The language ISO code.

private setNameEn(\Scrivo\String $nameEn)

Set the language name in English.

Parameters:

Type Name Def. Description
\Scrivo\String $nameEn

The language name in English.

private setNameNl(\Scrivo\String $nameNl)

Set the language name in Dutch.

Parameters:

Type Name Def. Description
\Scrivo\String $nameNl

The language name in Dutch.

private setShortList(boolean $shortList)

Set the value to indicate if a language is on the short list or not.

Parameters:

Type Name Def. Description
boolean $shortList

Whether a language is on the short list or not.

public update()

Update an existing language object data in the database.

First it is checked if the data of this language object can be updated in the database, then the data is updated in the database.

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data.
private static validateDelete(\Scrivo\Context $context, int $id)

Check if deletion of language object data does not violate any business rules.

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

int $id

The object id of the language to select.

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or if it is not possible to delete the language data.
private validateInsert()

Check if this language object can be inserted into the database.

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data.
private validateUpdate()

Check if this language object can be updated in the database.

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data.

Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013