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 titles 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. | |
addCollectionAuthors ($authors, $mode= 'append') | |
Add external authors (usually from the file). | |
setReviewMode ($value=true) | |
loadTranslations ($dbtype=DB_SLAVE) | |
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. | |
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) | |
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 | newEmpty ($code) |
Constructs a new empty message collection. | |
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, $dbtype=DB_SLAVE) | |
Loads existence and fuzzy state for given list of keys. | |
loadReviewInfo (array $keys, $dbtype=DB_SLAVE) | |
Loads reviewers for given messages. | |
loadData (array $keys, $dbtype=DB_SLAVE) | |
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 | |
$definitions = null | |
$infile = array() | |
$keys = array() | |
$messages = array() | |
$reverseMap | |
$dbInfo = null | |
Database Result Resource Stored message existence and fuzzy state. | |
$dbData = null | |
Database Result Resource Stored translations in database. | |
$dbReviewData = array() | |
Database Result Resource Stored reviews in database. | |
$tags = array() | |
Tags, copied to thin messages tagtype => keys. | |
$properties = array() | |
Properties, copied to thin messages. | |
$authors = array() |
Core message collection class.
Message group 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 19 of file MessageCollection.php.
MessageCollection::__construct | ( | $ | code | ) |
Constructors.
Use newFromDefinitions() instead.
string | $code Language code. |
Reimplemented in MockMessageCollection.
Definition at line 83 of file MessageCollection.php.
MessageCollection::__get | ( | $ | name | ) |
Fail fast if trying to access unknown properties.
string | $name |
MWException |
Definition at line 918 of file MessageCollection.php.
MessageCollection::__set | ( | $ | name, | |
$ | value | |||
) |
Definition at line 922 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 219 of file MessageCollection.php.
Referenced by SimpleFFS::tryReadSource(), PythonSingleFFS::writeReal(), and MediaWikiExtensionFFS::writeReal().
MessageCollection::applyFilter | ( | $ | filter, | |
$ | condition, | |||
$ | value | |||
) | [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 388 of file MessageCollection.php.
Referenced by filter().
MessageCollection::count | ( | ) |
Definition at line 955 of file MessageCollection.php.
Referenced by current(), loadData(), loadInfo(), and loadReviewInfo().
MessageCollection::current | ( | ) |
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 | $value Value for properties filtering. |
MWException | If given invalid filter name. |
Reimplemented in MockMessageCollection.
Definition at line 357 of file MessageCollection.php.
MessageCollection::filterChanged | ( | array $ | keys, | |
$ | condition | |||
) | [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 523 of file MessageCollection.php.
Referenced by applyFilter().
MessageCollection::filterFuzzy | ( | array $ | keys, | |
$ | condition | |||
) | [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 462 of file MessageCollection.php.
Referenced by applyFilter().
MessageCollection::filterHastranslation | ( | array $ | keys, | |
$ | condition | |||
) | [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 490 of file MessageCollection.php.
Referenced by applyFilter().
MessageCollection::filterLastTranslator | ( | array $ | keys, | |
$ | condition, | |||
$ | user | |||
) | [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 587 of file MessageCollection.php.
Referenced by applyFilter().
MessageCollection::filterOnCondition | ( | array $ | keys, | |
array $ | condKeys, | |||
$ | condition = true | |||
) | [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 = true and false 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 and second list, false to return keys which are on the first but not on second. |
Definition at line 437 of file MessageCollection.php.
Referenced by applyFilter(), and filterChanged().
MessageCollection::filterReviewer | ( | array $ | keys, | |
$ | condition, | |||
$ | user | |||
) | [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 560 of file MessageCollection.php.
Referenced by applyFilter().
MessageCollection::fixKeys | ( | ) | [protected] |
Takes list of keys and converts them into database format.
Definition at line 609 of file MessageCollection.php.
Referenced by resetForNewLanguage().
static MessageCollection::getAvailableFilters | ( | ) | [static] |
Definition at line 367 of file MessageCollection.php.
MessageCollection::getLanguage | ( | ) |
Reimplemented in MockMessageCollectionForExport.
Definition at line 112 of file MessageCollection.php.
Referenced by PythonSingleFFS::writeReal(), and MediaWikiExtensionFFS::writeReal().
MessageCollection::getMessageKeys | ( | ) |
Returns list of message keys that are used in this collection after filtering.
Definition at line 159 of file MessageCollection.php.
MessageCollection::getTags | ( | $ | type | ) |
Returns stored message tags.
string | $type Tag type, usually optional or ignored. |
Definition at line 168 of file MessageCollection.php.
MessageCollection::getTitleConds | ( | $ | db | ) | [protected] |
Of the current set of keys, construct database query conditions.
DatabaseBase | $db |
Definition at line 733 of file MessageCollection.php.
Referenced by loadData(), loadInfo(), and loadReviewInfo().
MessageCollection::getTitles | ( | ) |
Returns list of titles of messages that are used in this collection after filtering.
Definition at line 150 of file MessageCollection.php.
Referenced by getTitleConds().
MessageCollection::initMessages | ( | ) |
Constructs all TMessages from the data accumulated so far.
Usually there is no need to call this method directly.
Definition at line 796 of file MessageCollection.php.
Referenced by loadTranslations().
MessageCollection::key | ( | ) |
Definition at line 943 of file MessageCollection.php.
Referenced by current(), and valid().
MessageCollection::keys | ( | ) |
Returns list of available message keys.
This is affected by filtering.
Definition at line 141 of file MessageCollection.php.
Referenced by MockMessageCollectionForExport::__construct(), MockMessageCollection::__construct(), applyFilter(), count(), current(), getMessageKeys(), getTitles(), initMessages(), key(), loadTranslations(), next(), offsetExists(), offsetUnset(), resetForNewLanguage(), rewind(), slice(), and valid().
MessageCollection::loadData | ( | array $ | keys, | |
$ | dbtype = DB_SLAVE | |||
) | [protected] |
Loads translation for given list of keys.
string[] | $keys List of keys in database format. | |
int | $dbtype One of DB_* constants. |
Definition at line 693 of file MessageCollection.php.
Referenced by filterChanged(), filterLastTranslator(), and loadTranslations().
MessageCollection::loadInfo | ( | array $ | keys, | |
$ | dbtype = DB_SLAVE | |||
) | [protected] |
Loads existence and fuzzy state for given list of keys.
string[] | $keys List of keys in database format. | |
int | $dbtype One of DB_* constants. |
Definition at line 633 of file MessageCollection.php.
Referenced by filterFuzzy(), filterHastranslation(), and loadTranslations().
MessageCollection::loadReviewInfo | ( | array $ | keys, | |
$ | dbtype = DB_SLAVE | |||
) | [protected] |
Loads reviewers for given messages.
string[] | $keys List of keys in database format. | |
int | $dbtype One of DB_* constants. |
Definition at line 663 of file MessageCollection.php.
Referenced by filterReviewer(), and loadTranslations().
MessageCollection::loadTranslations | ( | $ | dbtype = DB_SLAVE |
) |
Loads all message data.
Must be called before accessing the messages with ArrayAccess or iteration. Must be called before filtering for $dbtype to have an effect.
int | $dbtype One of DB_* constants. |
Definition at line 247 of file MessageCollection.php.
static MessageCollection::newEmpty | ( | $ | code | ) | [static] |
Constructs a new empty message collection.
Suitable for example for testing.
string | $code Language code. |
Definition at line 106 of file MessageCollection.php.
Referenced by PageTranslationParserTest::testParsing().
static MessageCollection::newFromDefinitions | ( | MessageDefinitions $ | definitions, | |
$ | code | |||
) | [static] |
Construct a new message collection from definitions.
MessageDefinitions | $definitions | |
string | $code Language code. |
Definition at line 93 of file MessageCollection.php.
Referenced by MessageGroupOld::initCollection(), MessageGroupBase::initCollection(), and AggregateMessageGroup::initCollection().
MessageCollection::next | ( | ) |
MessageCollection::offsetExists | ( | $ | offset | ) |
ArrayAccess methods.
mixed | $offset |
Definition at line 884 of file MessageCollection.php.
MessageCollection::offsetGet | ( | $ | offset | ) |
MessageCollection::offsetSet | ( | $ | offset, | |
$ | value | |||
) |
mixed | $offset | |
$value |
Definition at line 900 of file MessageCollection.php.
MessageCollection::offsetUnset | ( | $ | offset | ) |
mixed | $offset |
Definition at line 907 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 259 of file MessageCollection.php.
MessageCollection::rewind | ( | ) |
Iterator method.
Definition at line 931 of file MessageCollection.php.
MessageCollection::rowToKey | ( | $ | row | ) | [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.
Definition at line 761 of file MessageCollection.php.
Referenced by filterChanged(), filterFuzzy(), filterHastranslation(), filterLastTranslator(), filterReviewer(), and initMessages().
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.
array | $messages Array[String => String] Array of translations indexed by display key. |
Definition at line 124 of file MessageCollection.php.
MessageCollection::setReviewMode | ( | $ | value = true |
) |
Definition at line 236 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 133 of file MessageCollection.php.
Referenced by initMessages(), and MessageGroupBase::setTags().
MessageCollection::slice | ( | $ | offset, | |
$ | limit | |||
) |
For paging messages.
One can count messages before and after slice.
string | $offset | |
int | $limit |
Definition at line 281 of file MessageCollection.php.
MessageCollection::valid | ( | ) |
MessageCollection::$authors = array() [protected] |
Definition at line 77 of file MessageCollection.php.
Referenced by addCollectionAuthors().
MessageCollection::$code |
Definition at line 23 of file MessageCollection.php.
Referenced by __construct(), fixKeys(), newFromDefinitions(), and resetForNewLanguage().
MessageCollection::$dbData = null [protected] |
Database Result Resource Stored translations in database.
Definition at line 58 of file MessageCollection.php.
MessageCollection::$dbInfo = null [protected] |
Database Result Resource Stored message existence and fuzzy state.
Definition at line 55 of file MessageCollection.php.
MessageCollection::$dbReviewData = array() [protected] |
Database Result Resource Stored reviews in database.
Definition at line 61 of file MessageCollection.php.
MessageCollection::$definitions = null [protected] |
Definition at line 28 of file MessageCollection.php.
Referenced by initMessages().
MessageCollection::$infile = array() [protected] |
Definition at line 33 of file MessageCollection.php.
MessageCollection::$keys = array() [protected] |
Definition at line 40 of file MessageCollection.php.
Referenced by MockMessageCollection::__construct(), applyFilter(), and initMessages().
MessageCollection::$messages = array() [protected] |
Definition at line 45 of file MessageCollection.php.
Referenced by MockMessageCollection::__construct(), and initMessages().
MessageCollection::$properties = array() [protected] |
Properties, copied to thin messages.
Definition at line 72 of file MessageCollection.php.
MessageCollection::$reverseMap [protected] |
Definition at line 50 of file MessageCollection.php.
MessageCollection::$tags = array() [protected] |
Tags, copied to thin messages tagtype => keys.
Definition at line 67 of file MessageCollection.php.