Essentially random collection of helper functions, similar to GlobalFunctions.php. More...
Static Public Member Functions | |
static | title (string $message, string $code, int $ns=NS_MEDIAWIKI) |
Does quick normalisation of message name so that in can be looked from the database. | |
static | figureMessage (string $text) |
Splits page name into message key and language code. | |
static | getMessageContent (string $key, string $language, int $namespace=NS_MEDIAWIKI) |
Loads page content without side effects. | |
static | getContents ( $titles, int $namespace) |
Fetches contents for pagenames in given namespace without side effects. | |
static | getContentForTitle (Title $title, bool $addFuzzy=false) |
Returns the content for a given title and adds the fuzzy tag if requested. | |
static | getLanguageName (string $code, ?string $language='en') |
Returns a localised language name. | |
static | getLanguageSelector ( $language, ?string $labelOption=null) |
Standard language selector in Translate extension. | |
static | getLanguageNames (?string $code) |
Get translated language names for the languages generally supported for translation in the current wiki. | |
static | fieldset (string $legend, string $contents, array $attributes=[]) |
Constructs a fieldset with contents. | |
static | convertWhiteSpaceToHTML (string $message) |
Escapes the message, and does some mangling to whitespace, so that it is preserved when outputted as-is to html page. | |
static | cacheFile (string $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, int $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 a URL that points to an editor for this message handle. | |
static | serialize ( $value) |
Serialize the given value. | |
static | deserialize (string $str, array $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. | |
static | isTranslationPage (MessageHandle $handle) |
Essentially random collection of helper functions, similar to GlobalFunctions.php.
Definition at line 31 of file Utilities.php.
|
static |
Checks if the namespace that the title belongs to allows subpages.
Definition at line 387 of file Utilities.php.
|
static |
Gets the path for cache files.
The cache directory must be configured to use this method.
string | $filename |
Definition at line 256 of file Utilities.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 241 of file Utilities.php.
|
static |
|
static |
Constructs a fieldset with contents.
string | $legend | Raw html. |
string | $contents | Raw html. |
array | $attributes | Html attributes for the fieldset. |
Definition at line 224 of file Utilities.php.
|
static |
Splits page name into message key and language code.
string | $text |
Definition at line 62 of file Utilities.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 136 of file Utilities.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 92 of file Utilities.php.
|
static |
Get a URL that points to an editor for this message handle.
MessageHandle | $handle |
Definition at line 341 of file Utilities.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 284 of file Utilities.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 170 of file Utilities.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 204 of file Utilities.php.
|
static |
Standard language selector in Translate extension.
string | $language | Language code of the language the names should be localised to. |
?string | $labelOption |
Definition at line 181 of file Utilities.php.
|
static |
Loads page content without side effects.
string | $key | Message key. |
string | $language | Language code. |
int | $namespace | Namespace number. |
Definition at line 77 of file Utilities.php.
|
static |
Returns a random string that can be used as placeholder in strings.
Definition at line 271 of file Utilities.php.
|
static |
Get a DB handle suitable for read and read-for-write cases.
Definition at line 315 of file Utilities.php.
|
static |
Definition at line 404 of file Utilities.php.
|
static |
Returns all translations of a given message.
MessageHandle | $handle | Language code is ignored. |
Definition at line 422 of file Utilities.php.
|
static |
Definition at line 371 of file Utilities.php.
|
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.
Definition at line 399 of file Utilities.php.
|
static |
Definition at line 448 of file Utilities.php.
|
static |
|
static |
Check whether primary should be used for reads to avoid reading stale data.
Definition at line 323 of file Utilities.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 40 of file Utilities.php.