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 | languageSelector ( $language, $selectedId) |
Returns a language selector. | |
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 | messageKeyToGroup (int $namespace, string $key) |
Returns the primary group message belongs to. | |
static | messageKeyToGroups (int $namespace, string $key) |
Returns the all the groups message belongs to. | |
static | normaliseKey (int $namespace, string $key) |
Converts page name and namespace to message index format. | |
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. | |
Essentially random collection of helper functions, similar to GlobalFunctions.php.
Definition at line 30 of file Utilities.php.
|
static |
Checks if the namespace that the title belongs to allows subpages.
Definition at line 445 of file Utilities.php.
|
static |
Gets the path for cache files.
string | $filename |
MWException | If cache directory is not configured. |
Definition at line 314 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 298 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 281 of file Utilities.php.
|
static |
Splits page name into message key and language code.
string | $text |
Definition at line 61 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 142 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 91 of file Utilities.php.
|
static |
Get a URL that points to an editor for this message handle.
MessageHandle | $handle |
Definition at line 399 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 342 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 176 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 227 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 204 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 76 of file Utilities.php.
|
static |
Returns a random string that can be used as placeholder in strings.
Definition at line 329 of file Utilities.php.
|
static |
Get a DB handle suitable for read and read-for-write cases.
Definition at line 373 of file Utilities.php.
|
static |
Definition at line 462 of file Utilities.php.
|
static |
Returns all translations of a given message.
MessageHandle | $handle | Language code is ignored. |
Definition at line 480 of file Utilities.php.
|
static |
Definition at line 429 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 457 of file Utilities.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 189 of file Utilities.php.
|
static |
Returns the primary group message belongs to.
int | $namespace | |
string | $key |
Definition at line 246 of file Utilities.php.
|
static |
Returns the all the groups message belongs to.
Definition at line 256 of file Utilities.php.
|
static |
Converts page name and namespace to message index format.
Definition at line 268 of file Utilities.php.
|
static |
|
static |
Check whether primary should be used for reads to avoid reading stale data.
Definition at line 381 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 39 of file Utilities.php.