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 | 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='') |
| 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 29 of file Utilities.php.
|
static |
Checks if the namespace that the title belongs to allows subpages.
Definition at line 364 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 227 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 212 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 195 of file Utilities.php.
|
static |
Splits page name into message key and language code.
| string | $text |
Definition at line 60 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 129 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 90 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) |
Definition at line 314 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 255 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 163 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 175 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 75 of file Utilities.php.
|
static |
Returns a random string that can be used as placeholder in strings.
Definition at line 242 of file Utilities.php.
|
static |
Get a DB handle suitable for read and read-for-write cases.
Definition at line 286 of file Utilities.php.
|
static |
Definition at line 381 of file Utilities.php.
|
static |
Returns all translations of a given message.
| MessageHandle | $handle | Language code is ignored. |
Definition at line 399 of file Utilities.php.
|
static |
Definition at line 350 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 376 of file Utilities.php.
|
static |
Definition at line 423 of file Utilities.php.
|
static |
|
static |
Check whether primary should be used for reads to avoid reading stale data.
Definition at line 294 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 38 of file Utilities.php.