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.
Attr. | Name / Description |
---|---|
public |
Language($context) Create an empty language object. |
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. |
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. |
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 |
Check if this language object can be inserted into the database. |
|
private |
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.
View source: Language.php line 112.
Members
- private \Scrivo\Context $context
-
A Scrivo context.
Inital value: null
View source: Language.php line 105.
- private \Scrivo\String $family
-
The language family (Germanic, Slavic).
Inital value: null
View source: Language.php line 87.
- private int $id
-
The language id (DB key).
Inital value: 0
View source: Language.php line 69.
- private \Scrivo\String $isoCode
-
The language ISO code.
Inital value: null
View source: Language.php line 81.
- private \Scrivo\String $nameEn
-
The language name in English.
Inital value: null
View source: Language.php line 93.
- private \Scrivo\String $nameNl
-
The language name in Dutch.
Inital value: null
View source: Language.php line 99.
- private boolean $shortList
-
Whether a language is on the short list or not.
Inital value: false
View source: Language.php line 75.
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().
View source: Language.php line 133.
- 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.
View source: Language.php line 152.
- 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. View source: Language.php line 356.
- 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.
View source: Language.php line 388.
- 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. View source: Language.php line 250.
- 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.
View source: Language.php line 437.
- private setFamily(\Scrivo\String $family)
-
Set the language family (Germanic, Slavic).
Parameters:
Type Name Def. Description \Scrivo\String $family The language family (Germanic, Slavic).
View source: Language.php line 208.
- 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.
View source: Language.php line 171.
- private setIsoCode(\Scrivo\String $isoCode)
-
Set the language ISO code.
Parameters:
Type Name Def. Description \Scrivo\String $isoCode The language ISO code.
View source: Language.php line 199.
- private setNameEn(\Scrivo\String $nameEn)
-
Set the language name in English.
Parameters:
Type Name Def. Description \Scrivo\String $nameEn The language name in English.
View source: Language.php line 217.
- private setNameNl(\Scrivo\String $nameNl)
-
Set the language name in Dutch.
Parameters:
Type Name Def. Description \Scrivo\String $nameNl The language name in Dutch.
View source: Language.php line 226.
- 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.
View source: Language.php line 188.
- 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. View source: Language.php line 301.
- 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. View source: Language.php line 339.
- 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. View source: Language.php line 236.
- 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. View source: Language.php line 288.
Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013