Core message collection class. More...
Public Member Functions | |
__construct ( $code) | |
Constructors. | |
getLanguage () | |
setInFile (array $messages) | |
Set translation from file, as opposed to translation which only exists in the wiki because they are not exported and committed yet. | |
setTags ( $type, array $keys) | |
Set message tags. | |
keys () | |
Returns list of available message keys. | |
getTitles () | |
Returns list of TitleValues of messages that are used in this collection after filtering. | |
getMessageKeys () | |
Returns list of message keys that are used in this collection after filtering. | |
getTags ( $type) | |
Returns stored message tags. | |
getAuthors () | |
Lists all translators that have contributed to the latest revisions of each translation. | |
addCollectionAuthors ( $authors, $mode='append') | |
Add external authors (usually from the file). | |
loadTranslations () | |
Loads all message data. | |
resetForNewLanguage ( $code) | |
Some statistics scripts for example loop the same collection over every language. | |
slice ( $offset, $limit) | |
For paging messages. | |
filter ( $type, $condition=true, $value=null) | |
Filters messages based on some condition. | |
filterUntranslatedOptional () | |
getReverseMap () | |
Creates a two-dimensional map of namespace and pagenames. | |
initMessages () | |
Constructs all TMessages from the data accumulated so far. | |
offsetExists ( $offset) | |
ArrayAccess methods. | |
offsetGet ( $offset) | |
offsetSet ( $offset, $value) | |
offsetUnset ( $offset) | |
__get ( $name) | |
Fail fast if trying to access unknown properties. | |
__set ( $name, $value) | |
Fail fast if trying to access unknown properties. | |
rewind () | |
Iterator method. | |
current () | |
key () | |
next () | |
valid () | |
count () | |
Static Public Member Functions | |
static | newFromDefinitions (MessageDefinitions $definitions, $code) |
Construct a new message collection from definitions. | |
static | getAvailableFilters () |
Public Attributes | |
$code | |
Protected Member Functions | |
applyFilter ( $filter, $condition, $value) | |
Really apply a filter. | |
filterOnCondition (array $keys, array $condKeys, $condition=true) | |
Filters list of keys with other list of keys according to the condition. | |
filterFuzzy (array $keys, $condition) | |
Filters list of keys according to whether the translation is fuzzy. | |
filterHastranslation (array $keys, $condition) | |
Filters list of keys according to whether they have a translation. | |
filterChanged (array $keys, $condition) | |
Filters list of keys according to whether the current translation differs from the commited translation. | |
filterReviewer (array $keys, $condition, $user) | |
Filters list of keys according to whether the user has accepted them. | |
filterLastTranslator (array $keys, $condition, $user) | |
fixKeys () | |
Takes list of keys and converts them into database format. | |
loadInfo (array $keys, ?array $titleConds=null) | |
Loads existence and fuzzy state for given list of keys. | |
loadReviewInfo (array $keys, ?array $titleConds=null) | |
Loads reviewers for given messages. | |
loadData (array $keys, ?array $titleConds=null) | |
Loads translation for given list of keys. | |
getTitleConds ( $db) | |
Of the current set of keys, construct database query conditions. | |
rowToKey ( $row) | |
Given two-dimensional map of namespace and pagenames, this uses database fields page_namespace and page_title as keys and returns the value for those indexes. | |
Protected Attributes | |
$keys = [] | |
$messages = [] | |
$tags = [] | |
Core message collection class.
Message collection is collection of messages of one message group in one language. It handles loading of the messages in one huge batch, and also stores information that can be used to filter the collection in different ways.
Definition at line 25 of file MessageCollection.php.
MessageCollection::__construct | ( | $code | ) |
Constructors.
Use newFromDefinitions() instead.
string | $code | Language code. |
Definition at line 74 of file MessageCollection.php.
MessageCollection::__get | ( | $name | ) |
Fail fast if trying to access unknown properties.
string | $name |
MWException |
Definition at line 944 of file MessageCollection.php.
MessageCollection::__set | ( | $name, | |
$value ) |
Fail fast if trying to access unknown properties.
string | $name | |
mixed | $value |
MWException |
Definition at line 955 of file MessageCollection.php.
MessageCollection::addCollectionAuthors | ( | $authors, | |
$mode = 'append' ) |
Add external authors (usually from the file).
string[] | $authors | List of authors. |
string | $mode | Either append or set authors. |
MWException | If invalid $mode given. |
Definition at line 198 of file MessageCollection.php.
|
protected |
Really apply a filter.
Some filters need multiple conditions.
string | $filter | Filter name. |
bool | $condition | Whether to return messages which do not satisfy |
mixed | $value | Value for properties filtering. the given filter condition (true), or only which do (false). |
MWException |
Definition at line 355 of file MessageCollection.php.
MessageCollection::count | ( | ) |
Definition at line 990 of file MessageCollection.php.
MessageCollection::current | ( | ) |
Definition at line 969 of file MessageCollection.php.
MessageCollection::filter | ( | $type, | |
$condition = true, | |||
$value = null ) |
Filters messages based on some condition.
Some filters cause data to be loaded from the database. PAGEINFO: existence and fuzzy tags. TRANSLATIONS: translations for every message. It is recommended to first filter with messages that do not need those. It is recommended to add translations from file with addInfile, and it is needed for changed filter to work.
string | $type |
|
bool | $condition | Whether to return messages which do not satisfy the given filter condition (true), or only which do (false). |
mixed | null | $value | Value for properties filtering. |
MWException | If given invalid filter name. |
Definition at line 326 of file MessageCollection.php.
|
protected |
Filters list of keys according to whether the current translation differs from the commited translation.
string[] | $keys | List of keys to filter. |
bool | $condition | True to filter changed translations, false to filter unchanged translations. |
Definition at line 503 of file MessageCollection.php.
|
protected |
Filters list of keys according to whether the translation is fuzzy.
string[] | $keys | List of keys to filter. |
bool | $condition | True to filter away fuzzy translations, false to filter non-fuzzy translations. |
Definition at line 442 of file MessageCollection.php.
|
protected |
Filters list of keys according to whether they have a translation.
string[] | $keys | List of keys to filter. |
bool | $condition | True to filter away translated, false to filter untranslated. |
Definition at line 470 of file MessageCollection.php.
|
protected |
string[] | $keys | List of keys to filter. |
bool | $condition | True to remove translatations where last translator is $user false to get only last translations done by others. |
int | $user | Userid |
Definition at line 583 of file MessageCollection.php.
|
protected |
Filters list of keys with other list of keys according to the condition.
In other words, you have a list of keys, and you have determined list of keys that have some feature. Now you can either take messages that are both in the first list and the second list OR are in the first list but are not in the second list (conditition = false and true respectively). What makes this more complex is that second list of keys might not be a subset of the first list of keys.
string[] | $keys | List of keys to filter. |
string[] | $condKeys | Second list of keys for filtering. |
bool | $condition | True (default) to return keys which are on first but not on the second list, false to return keys which are on both. second. |
Definition at line 417 of file MessageCollection.php.
|
protected |
Filters list of keys according to whether the user has accepted them.
string[] | $keys | List of keys to filter. |
bool | $condition | True to remove translatations $user has accepted, false to get only translations accepted by $user. |
int | $user | Userid |
Definition at line 556 of file MessageCollection.php.
MessageCollection::filterUntranslatedOptional | ( | ) |
Definition at line 390 of file MessageCollection.php.
|
protected |
Takes list of keys and converts them into database format.
Definition at line 605 of file MessageCollection.php.
MessageCollection::getAuthors | ( | ) |
Lists all translators that have contributed to the latest revisions of each translation.
Causes translations to be loaded from the database. Is not affected by filters.
Definition at line 158 of file MessageCollection.php.
|
static |
Definition at line 334 of file MessageCollection.php.
MessageCollection::getLanguage | ( | ) |
Definition at line 93 of file MessageCollection.php.
MessageCollection::getMessageKeys | ( | ) |
Returns list of message keys that are used in this collection after filtering.
Definition at line 139 of file MessageCollection.php.
MessageCollection::getReverseMap | ( | ) |
Creates a two-dimensional map of namespace and pagenames.
Definition at line 794 of file MessageCollection.php.
MessageCollection::getTags | ( | $type | ) |
Returns stored message tags.
string | $type | Tag type, usually optional or ignored. |
Definition at line 148 of file MessageCollection.php.
|
protected |
Of the current set of keys, construct database query conditions.
\Wikimedia\Rdbms\IDatabase | $db |
Definition at line 740 of file MessageCollection.php.
MessageCollection::getTitles | ( | ) |
Returns list of TitleValues of messages that are used in this collection after filtering.
Definition at line 130 of file MessageCollection.php.
MessageCollection::initMessages | ( | ) |
Constructs all TMessages from the data accumulated so far.
Usually there is no need to call this method directly.
Definition at line 813 of file MessageCollection.php.
MessageCollection::key | ( | ) |
Definition at line 978 of file MessageCollection.php.
MessageCollection::keys | ( | ) |
Returns list of available message keys.
This is affected by filtering.
Definition at line 121 of file MessageCollection.php.
|
protected |
Loads translation for given list of keys.
string[] | $keys | List of keys in database format. |
string[] | null | $titleConds | Database query condition based on current keys. |
Definition at line 702 of file MessageCollection.php.
|
protected |
Loads existence and fuzzy state for given list of keys.
string[] | $keys | List of keys in database format. |
string[] | null | $titleConds | Database query condition based on current keys. |
Definition at line 624 of file MessageCollection.php.
|
protected |
Loads reviewers for given messages.
string[] | $keys | List of keys in database format. |
string[] | null | $titleConds | Database query condition based on current keys. |
Definition at line 663 of file MessageCollection.php.
MessageCollection::loadTranslations | ( | ) |
Loads all message data.
Must be called before accessing the messages with ArrayAccess or iteration.
Definition at line 218 of file MessageCollection.php.
|
static |
Construct a new message collection from definitions.
MessageDefinitions | $definitions | |
string | $code | Language code. |
Definition at line 84 of file MessageCollection.php.
MessageCollection::next | ( | ) |
Definition at line 982 of file MessageCollection.php.
MessageCollection::offsetExists | ( | $offset | ) |
ArrayAccess methods.
mixed | $offset |
Definition at line 911 of file MessageCollection.php.
MessageCollection::offsetGet | ( | $offset | ) |
MessageCollection::offsetSet | ( | $offset, | |
$value ) |
mixed | $offset | |
mixed | $value |
Definition at line 927 of file MessageCollection.php.
MessageCollection::offsetUnset | ( | $offset | ) |
mixed | $offset |
Definition at line 932 of file MessageCollection.php.
MessageCollection::resetForNewLanguage | ( | $code | ) |
Some statistics scripts for example loop the same collection over every language.
This is a shortcut which keeps tags and definitions.
string | $code |
Definition at line 235 of file MessageCollection.php.
MessageCollection::rewind | ( | ) |
Iterator method.
Definition at line 964 of file MessageCollection.php.
|
protected |
Given two-dimensional map of namespace and pagenames, this uses database fields page_namespace and page_title as keys and returns the value for those indexes.
stdClass | $row |
Definition at line 778 of file MessageCollection.php.
MessageCollection::setInFile | ( | array | $messages | ) |
Set translation from file, as opposed to translation which only exists in the wiki because they are not exported and committed yet.
string[] | $messages | Array of translations indexed by display key. |
Definition at line 104 of file MessageCollection.php.
MessageCollection::setTags | ( | $type, | |
array | $keys ) |
Set message tags.
string | $type | Tag type, usually ignored or optional. |
string[] | $keys | List of display keys. |
Definition at line 113 of file MessageCollection.php.
MessageCollection::slice | ( | $offset, | |
$limit ) |
For paging messages.
One can count messages before and after slice.
string | $offset | |
int | $limit |
Definition at line 256 of file MessageCollection.php.
MessageCollection::valid | ( | ) |
Definition at line 986 of file MessageCollection.php.
MessageCollection::$code |
Definition at line 35 of file MessageCollection.php.
|
protected |
Definition at line 43 of file MessageCollection.php.
|
protected |
Definition at line 45 of file MessageCollection.php.
|
protected |
Definition at line 61 of file MessageCollection.php.