Essentially random collection of helper functions, similar to GlobalFunctions.php. More...
Static Public Member Functions | |
static | title ( $message, $code, $ns=NS_MEDIAWIKI) |
Does quick normalisation of message name so that in can be looked from the database. | |
static | figureMessage ( $text) |
Splits page name into message key and language code. | |
static | getMessageContent ( $key, $language, $namespace=NS_MEDIAWIKI) |
Loads page content without side effects. | |
static | getContents ( $titles, $namespace) |
Fetches contents for pagenames in given namespace without side effects. | |
static | getContentForTitle (Title $title, $addFuzzy=false) |
Returns the content for a given title and adds the fuzzy tag if requested. | |
static | translationChanges ( $hours=24, $bots=false, $ns=null, array $extraFields=[]) |
Fetches recent changes for titles in given namespaces. | |
static | getLanguageName ( $code, $language='en') |
Returns a localised language name. | |
static | languageSelector ( $language, $selectedId) |
Returns a language selector. | |
static | getLanguageSelector ( $language, $labelOption=false) |
Standard language selector in Translate extension. | |
static | getLanguageNames ( $code) |
Get translated language names for the languages generally supported for translation in the current wiki. | |
static | messageKeyToGroup ( $namespace, $key) |
Returns the primary group message belongs to. | |
static | messageKeyToGroups ( $namespace, $key) |
Returns the all the groups message belongs to. | |
static | normaliseKey ( $namespace, $key) |
Converts page name and namespace to message index format. | |
static | fieldset ( $legend, $contents, array $attributes=[]) |
Constructs a fieldset with contents. | |
static | convertWhiteSpaceToHTML ( $message) |
Escapes the message, and does some mangling to whitespace, so that it is preserved when outputted as-is to html page. | |
static | assetPath ( $path) |
Construct the web address to given asset. | |
static | cacheFile ( $filename) |
Gets the path for cache files. | |
static | getPlaceholder () |
Returns a random string that can be used as placeholder in strings. | |
static | getIcon (MessageGroup $g, $size) |
Get URLs for icons if available. | |
static | getSafeReadDB () |
Get a DB handle suitable for read and read-for-write cases. | |
static | shouldReadFromPrimary () |
Check whether primary should be used for reads to avoid reading stale data. | |
static | getEditorUrl (MessageHandle $handle) |
Get an URL that points to an editor for this message handle. | |
static | serialize ( $value) |
Serialize the given value. | |
static | deserialize ( $str, $opts=[ 'allowed_classes'=> false]) |
Deserialize the given string. | |
static | getVersion () |
static | allowsSubpages (Title $title) |
Checks if the namespace that the title belongs to allows subpages. | |
static | isSupportedLanguageCode (string $code) |
Checks whether a language code is supported for translation at the wiki level. | |
static | getTextFromTextContent (?Content $content) |
static | getTranslations (MessageHandle $handle) |
Returns all translations of a given message. | |
Essentially random collection of helper functions, similar to GlobalFunctions.php.
Definition at line 18 of file TranslateUtils.php.
|
static |
Checks if the namespace that the title belongs to allows subpages.
Definition at line 527 of file TranslateUtils.php.
|
static |
Construct the web address to given asset.
string | $path | Path to the resource relative to extensions root directory. |
Definition at line 368 of file TranslateUtils.php.
|
static |
Gets the path for cache files.
string | $filename |
MWException | If cache directory is not configured. |
Definition at line 379 of file TranslateUtils.php.
|
static |
Escapes the message, and does some mangling to whitespace, so that it is preserved when outputted as-is to html page.
Line feeds are converted to <br /> and occurrences of leading and trailing and multiple consecutive spaces to non-breaking spaces.
This is also implemented in JavaScript in ext.translate.quickedit.
string | $message | Plain text string. |
Definition at line 353 of file TranslateUtils.php.
|
static |
Deserialize the given string.
string | $str | |
array | null | $opts |
Definition at line 503 of file TranslateUtils.php.
|
static |
Constructs a fieldset with contents.
string | $legend | Raw html. |
string | $contents | Raw html. |
array | $attributes | Html attributes for the fieldset. |
Definition at line 336 of file TranslateUtils.php.
|
static |
Splits page name into message key and language code.
string | $text |
Definition at line 49 of file TranslateUtils.php.
|
static |
Returns the content for a given title and adds the fuzzy tag if requested.
Title | $title | |
bool | $addFuzzy | Add the fuzzy tag if appropriate. |
Definition at line 129 of file TranslateUtils.php.
|
static |
Fetches contents for pagenames in given namespace without side effects.
string | string[] | $titles | Database page names. |
int | $namespace | The number of the namespace. |
Definition at line 79 of file TranslateUtils.php.
|
static |
Get an URL that points to an editor for this message handle.
MessageHandle | $handle |
Definition at line 474 of file TranslateUtils.php.
|
static |
Get URLs for icons if available.
MessageGroup | $g | |
int | $size | Length of the edge of a bounding box to fit the icon. |
Definition at line 412 of file TranslateUtils.php.
|
static |
Returns a localised language name.
string | $code | Language code. |
null | string | $language | Language code of the language that the name should be in. |
Definition at line 226 of file TranslateUtils.php.
|
static |
Get translated language names for the languages generally supported for translation in the current wiki.
Message groups can have further exclusions.
null | string | $code |
Definition at line 275 of file TranslateUtils.php.
|
static |
Standard language selector in Translate extension.
string | $language | Language code of the language the names should be localised to. |
bool | $labelOption |
Definition at line 252 of file TranslateUtils.php.
|
static |
Loads page content without side effects.
string | $key | Message key. |
string | $language | Language code. |
int | $namespace | Namespace number. |
Definition at line 64 of file TranslateUtils.php.
|
static |
Returns a random string that can be used as placeholder in strings.
Definition at line 398 of file TranslateUtils.php.
|
static |
Get a DB handle suitable for read and read-for-write cases.
Definition at line 443 of file TranslateUtils.php.
|
static |
Definition at line 547 of file TranslateUtils.php.
|
static |
Returns all translations of a given message.
MessageHandle | $handle | Language code is ignored. |
Definition at line 566 of file TranslateUtils.php.
|
static |
|
static |
Checks whether a language code is supported for translation at the wiki level.
Note that it is possible that message groups define other language codes which are not supported by the wiki, in which case this function would return false for those.
string | $code |
Definition at line 542 of file TranslateUtils.php.
|
static |
Returns a language selector.
string | $language | Language code of the language the names should be localised to. |
string | $selectedId | The language code that is selected by default. |
Definition at line 237 of file TranslateUtils.php.
|
static |
Returns the primary group message belongs to.
int | $namespace | |
string | $key |
Definition at line 294 of file TranslateUtils.php.
|
static |
Returns the all the groups message belongs to.
int | $namespace | |
string | $key |
Definition at line 306 of file TranslateUtils.php.
|
static |
Converts page name and namespace to message index format.
int | $namespace | |
string | $key |
Definition at line 323 of file TranslateUtils.php.
|
static |
Serialize the given value.
mixed | $value |
Definition at line 493 of file TranslateUtils.php.
|
static |
Check whether primary should be used for reads to avoid reading stale data.
Definition at line 455 of file TranslateUtils.php.
|
static |
Does quick normalisation of message name so that in can be looked from the database.
string | $message | Name of the message |
string | $code | Language code in lower case and with dash as delimiter |
int | $ns | Namespace constant |
Definition at line 27 of file TranslateUtils.php.
|
static |
Fetches recent changes for titles in given namespaces.
int | $hours | Number of hours. |
bool | $bots | Should bot edits be included. |
null | int[] | $ns | List of namespace IDs. |
string[] | $extraFields | List of extra columns to fetch. |
Definition at line 164 of file TranslateUtils.php.