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 page names in given namespace. | |
| 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 | 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, string $action_source='', bool $includeLanguageParam=true) |
| 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 | getTextFromContentOrNull (?Content $content) |
| Best-effort extraction of text from content. | |
| static | getTextFromTextContent (?Content $content) |
| Strict extraction of text from content. | |
| static | getTranslations (MessageHandle $handle) |
| Returns all translations of a given message. | |
| static | getTranslationRevisions (MessageHandle $handle) |
| Returns the latest RevisionRecord for each existing translation of a message. | |
| static | isTranslationPage (MessageHandle $handle) |
| static | isValidRegex (string $pattern, ?string &$error=null) |
| Validate a regular exception. | |
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 383 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 241 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 226 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 207 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 152 of file Utilities.php.
|
static |
Fetches contents for page names in given namespace.
| string | string[] | $titles | Database page names. |
| int | $namespace | The number of the namespace. |
Definition at line 133 of file Utilities.php.
|
static |
Get a URL that points to an editor for this message handle.
| MessageHandle | $handle | |
| string | $action_source | If non-empty, defines where the link originates from, for metrics (event logging) |
| bool | $includeLanguageParam | Whether the language parameter should be included |
Definition at line 329 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 269 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 177 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 189 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 256 of file Utilities.php.
|
static |
Get a DB handle suitable for read and read-for-write cases.
Definition at line 300 of file Utilities.php.
|
static |
Best-effort extraction of text from content.
Returns null when the content is missing, hidden or not text-based.
Definition at line 405 of file Utilities.php.
|
static |
Strict extraction of text from content.
Throws when the content is missing, hidden or not text-based.
Definition at line 414 of file Utilities.php.
|
static |
Returns the latest RevisionRecord for each existing translation of a message.
This is the typed counterpart of {
Results are ordered by page title (ascending), matching the order that {
| MessageHandle | $handle | Language code is ignored. |
Definition at line 458 of file Utilities.php.
|
static |
Returns all translations of a given message.
| MessageHandle | $handle | Language code is ignored. |
Definition at line 432 of file Utilities.php.
|
static |
Definition at line 369 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 395 of file Utilities.php.
|
static |
Definition at line 491 of file Utilities.php.
|
static |
Validate a regular exception.
| string | $pattern | The regular expression to validate. |
| string | null | &$error | Output parameter containing the error message, if any. |
Definition at line 520 of file Utilities.php.
|
static |
|
static |
Check whether primary should be used for reads to avoid reading stale data.
Definition at line 308 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.