WikiLambda
MediaWiki WikiLambda extension
|
Public Member Functions | |
__construct ( $strings=[]) | |
Create a ZMultiLingualString instance given an array or a ZTypedList of ZMonoLingualString instances. | |
isValid () | |
@inheritDoc | |
getSerialized ( $form=self::FORM_CANONICAL) | |
@inheritDoc | |
getZValue () | |
Get the list of ZMonoLingualStrings that represent the value of this ZMultiLingualString. | |
getValueAsList () | |
Get the values of this ZMultiLingualString in the shape of an array with language as key and string as value. | |
getStringForLanguageCode (string $languageCode) | |
Fetch the ZMultiLingualString's stored value for a given MediaWiki language code (e.g. | |
isLanguageProvidedValue (string $languageCode) | |
Check if the ZMultiLingualString has a stored value for a given MediaWiki language code (e.g. | |
getStringForLanguage (Language $language) | |
Fetch the ZMultiLingualString's stored value for a given MediaWiki language class. | |
buildStringForLanguage (Language $language) | |
Instantiate a chained builder with which you can ask for a fallback in English, or define a placeholder. | |
setMonoLingualString (ZMonoLingualString $value) | |
setStringForLanguage (Language $language, string $value) | |
removeValue (Language $language) | |
Public Member Functions inherited from MediaWiki\Extension\WikiLambda\ZObjects\ZObject | |
getValueByKey (string $key) | |
Fetch value of given key from the current ZObject. | |
setValueByKey (string $key, ZObject $value) | |
Set a value of given key in the current ZObject. | |
isBuiltin () | |
Returns whether this ZObject is a builtin class. | |
isTypeReference () | |
Returns whether the object type is a ZReference that points to a type. | |
isTypeFunctionCall () | |
Returns whether the object type is a ZFunctionCall that resolves to a type. | |
getZTypeObject () | |
Returns either the ZReference or the ZFunctionCall that contain the type of this ZObject (Z1K1) | |
getZType () | |
Returns a string with the Zid representing the type of this ZObject. | |
getLinkedZObjects () | |
Return all ZObject Zids that are linked to the current ZObject. | |
getHumanReadable ( $language=null) | |
Convert this ZObject into human readable object by translating all keys and references into the preferred language or its fallbacks. | |
__toString () | |
Over-ride the default __toString() method to serialise ZObjects into a JSON representation. | |
Static Public Member Functions | |
static | getDefinition () |
@inheritDoc | |
Additional Inherited Members | |
Public Attributes inherited from MediaWiki\Extension\WikiLambda\ZObjects\ZObject | |
const | FORM_CANONICAL = 1 |
const | FORM_NORMAL = 2 |
Protected Attributes inherited from MediaWiki\Extension\WikiLambda\ZObjects\ZObject | |
$type = null | |
$data = [] | |
$linkedZObjects = [] | |
MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::__construct | ( | $strings = [] | ) |
Create a ZMultiLingualString instance given an array or a ZTypedList of ZMonoLingualString instances.
Internally this class bypasses ZTypedList and stores an array with the language Zid as key.
ZTypedList | array | $strings |
Reimplemented from MediaWiki\Extension\WikiLambda\ZObjects\ZObject.
MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::buildStringForLanguage | ( | Language | $language | ) |
Instantiate a chained builder with which you can ask for a fallback in English, or define a placeholder.
At the end, either call getString()
or getStringAndLanguageCode()
.
Language | $language |
|
static |
@inheritDoc
Reimplemented from MediaWiki\Extension\WikiLambda\ZObjects\ZObject.
MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::getSerialized | ( | $form = self::FORM_CANONICAL | ) |
@inheritDoc
Reimplemented from MediaWiki\Extension\WikiLambda\ZObjects\ZObject.
MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::getStringForLanguage | ( | Language | $language | ) |
Fetch the ZMultiLingualString's stored value for a given MediaWiki language class.
This will walk the language fallback chain, and provide a fallback message if there is no label defined in the given language or any of its fallback languages.
Language | $language | The MediaWiki language class in which the string is wanted. |
MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::getStringForLanguageCode | ( | string | $languageCode | ) |
Fetch the ZMultiLingualString's stored value for a given MediaWiki language code (e.g.
'en' or 'zh-hant'). Note that this is a raw fetch and does not walk the language fallback chain; users are expected to use getStringForLanguage() which does.
string | $languageCode | The MediaWiki language code in which the string is wanted. |
MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::getValueAsList | ( | ) |
Get the values of this ZMultiLingualString in the shape of an array with language as key and string as value.
MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::getZValue | ( | ) |
Get the list of ZMonoLingualStrings that represent the value of this ZMultiLingualString.
Reimplemented from MediaWiki\Extension\WikiLambda\ZObjects\ZObject.
MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::isLanguageProvidedValue | ( | string | $languageCode | ) |
Check if the ZMultiLingualString has a stored value for a given MediaWiki language code (e.g.
'en' or 'zh-hant'). Note that this is a raw check and does not walk the language fallback chain.
string | $languageCode | The MediaWiki language code in which the string is wanted. |
MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::isValid | ( | ) |
@inheritDoc
Reimplemented from MediaWiki\Extension\WikiLambda\ZObjects\ZObject.
MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::removeValue | ( | Language | $language | ) |
Language | $language | The MediaWiki language class in which the string is to be unset. |
MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::setMonoLingualString | ( | ZMonoLingualString | $value | ) |
ZMonoLingualString | $value | The new value to set. |
MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::setStringForLanguage | ( | Language | $language, |
string | $value ) |
Language | $language | The MediaWiki language class in which the string is to be set. |
string | $value | The new string to set. |