MessageCollection Class Reference

Core message collection class. More...

Inheritance diagram for MessageCollection:
Inheritance graph
[legend]

List of all members.

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()

Detailed Description

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.


Constructor & Destructor Documentation

MessageCollection::__construct ( code  ) 

Constructors.

Use newFromDefinitions() instead.

Parameters:
string $code Language code.

Reimplemented in MockMessageCollection.

Definition at line 83 of file MessageCollection.php.


Member Function Documentation

MessageCollection::__get ( name  ) 

Fail fast if trying to access unknown properties.

Parameters:
string $name
Exceptions:
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).

Parameters:
string[] $authors List of authors.
string $mode Either append or set authors.
Exceptions:
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.

Parameters:
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).
Exceptions:
MWException 

Definition at line 388 of file MessageCollection.php.

Referenced by filter().

Here is the call graph for this function:

MessageCollection::count (  ) 

Definition at line 955 of file MessageCollection.php.

Referenced by current(), loadData(), loadInfo(), and loadReviewInfo().

Here is the call graph for this function:

MessageCollection::current (  ) 

Definition at line 935 of file MessageCollection.php.

Here is the call graph for this function:

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.

Parameters:
string $type

  • fuzzy: messages with fuzzy tag (PAGEINFO)
  • optional: messages marked for optional.
  • ignored: messages which are not for translation.
  • hastranslation: messages which have translation (be if fuzzy or not) (PAGEINFO, *INFILE).
  • translated: messages which have translation which is not fuzzy (PAGEINFO, *INFILE).
  • changed: translation in database differs from infile. (INFILE, TRANSLATIONS)
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.
Exceptions:
MWException If given invalid filter name.

Reimplemented in MockMessageCollection.

Definition at line 357 of file MessageCollection.php.

Here is the call graph for this function:

MessageCollection::filterChanged ( array $  keys,
condition 
) [protected]

Filters list of keys according to whether the current translation differs from the commited translation.

Parameters:
string[] $keys List of keys to filter.
bool $condition True to filter changed translations, false to filter unchanged translations.
Returns:
string[] Filtered keys.

Definition at line 523 of file MessageCollection.php.

Referenced by applyFilter().

Here is the call graph for this function:

MessageCollection::filterFuzzy ( array $  keys,
condition 
) [protected]

Filters list of keys according to whether the translation is fuzzy.

Parameters:
string[] $keys List of keys to filter.
bool $condition True to filter away fuzzy translations, false to filter non-fuzzy translations.
Returns:
string[] Filtered keys.

Definition at line 462 of file MessageCollection.php.

Referenced by applyFilter().

Here is the call graph for this function:

MessageCollection::filterHastranslation ( array $  keys,
condition 
) [protected]

Filters list of keys according to whether they have a translation.

Parameters:
string[] $keys List of keys to filter.
bool $condition True to filter away translated, false to filter untranslated.
Returns:
string[] Filtered keys.

Definition at line 490 of file MessageCollection.php.

Referenced by applyFilter().

Here is the call graph for this function:

MessageCollection::filterLastTranslator ( array $  keys,
condition,
user 
) [protected]
Parameters:
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
Returns:
string[] Filtered keys.

Definition at line 587 of file MessageCollection.php.

Referenced by applyFilter().

Here is the call graph for this function:

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.

Parameters:
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.
Returns:
string[] Filtered keys.

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.

Parameters:
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
Returns:
string[] Filtered keys.

Definition at line 560 of file MessageCollection.php.

Referenced by applyFilter().

Here is the call graph for this function:

MessageCollection::fixKeys (  )  [protected]

Takes list of keys and converts them into database format.

Returns:
array ( string => string ) Array of keys in database format indexed by display format.

Definition at line 609 of file MessageCollection.php.

Referenced by resetForNewLanguage().

static MessageCollection::getAvailableFilters (  )  [static]
Returns:
array

Definition at line 367 of file MessageCollection.php.

MessageCollection::getLanguage (  ) 
Returns:
string

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.

Returns:
string[]
Since:
2011-12-28

Definition at line 159 of file MessageCollection.php.

Here is the call graph for this function:

MessageCollection::getTags ( type  ) 

Returns stored message tags.

Parameters:
string $type Tag type, usually optional or ignored.
Returns:
string[] List of keys with given tag.

Definition at line 168 of file MessageCollection.php.

MessageCollection::getTitleConds ( db  )  [protected]

Of the current set of keys, construct database query conditions.

Since:
2011-12-28
Parameters:
DatabaseBase $db
Returns:
string

Definition at line 733 of file MessageCollection.php.

Referenced by loadData(), loadInfo(), and loadReviewInfo().

Here is the call graph for this function:

MessageCollection::getTitles (  ) 

Returns list of titles of messages that are used in this collection after filtering.

Returns:
Title[]
Since:
2011-12-28

Definition at line 150 of file MessageCollection.php.

Referenced by getTitleConds().

Here is the call graph for this function:

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().

Here is the call graph for this function:

MessageCollection::key (  ) 

Definition at line 943 of file MessageCollection.php.

Referenced by current(), and valid().

Here is the call graph for this function:

MessageCollection::keys (  ) 

Returns list of available message keys.

This is affected by filtering.

Returns:
array List of database keys indexed by display keys.

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.

Parameters:
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().

Here is the call graph for this function:

MessageCollection::loadInfo ( array $  keys,
dbtype = DB_SLAVE 
) [protected]

Loads existence and fuzzy state for given list of keys.

Parameters:
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().

Here is the call graph for this function:

MessageCollection::loadReviewInfo ( array $  keys,
dbtype = DB_SLAVE 
) [protected]

Loads reviewers for given messages.

Parameters:
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().

Here is the call graph for this function:

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.

Parameters:
int $dbtype One of DB_* constants.

Definition at line 247 of file MessageCollection.php.

Here is the call graph for this function:

static MessageCollection::newEmpty ( code  )  [static]

Constructs a new empty message collection.

Suitable for example for testing.

Parameters:
string $code Language code.
Returns:
MessageCollection

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.

Parameters:
MessageDefinitions $definitions
string $code Language code.
Returns:
MessageCollection

Definition at line 93 of file MessageCollection.php.

Referenced by MessageGroupOld::initCollection(), MessageGroupBase::initCollection(), and AggregateMessageGroup::initCollection().

MessageCollection::next (  ) 

Definition at line 947 of file MessageCollection.php.

Here is the call graph for this function:

MessageCollection::offsetExists ( offset  ) 

ArrayAccess methods.

Parameters:
mixed $offset
Returns:
bool

Definition at line 884 of file MessageCollection.php.

Here is the call graph for this function:

MessageCollection::offsetGet ( offset  ) 
Parameters:
mixed $offset
Returns:
mixed

Definition at line 892 of file MessageCollection.php.

MessageCollection::offsetSet ( offset,
value 
)
Parameters:
mixed $offset
$value 

Definition at line 900 of file MessageCollection.php.

MessageCollection::offsetUnset ( offset  ) 
Parameters:
mixed $offset

Definition at line 907 of file MessageCollection.php.

Here is the call graph for this function:

MessageCollection::resetForNewLanguage ( code  ) 

Some statistics scripts for example loop the same collection over every language.

This is a shortcut which keeps tags and definitions.

Parameters:
string $code

Definition at line 259 of file MessageCollection.php.

Here is the call graph for this function:

MessageCollection::rewind (  ) 

Iterator method.

Definition at line 931 of file MessageCollection.php.

Here is the call graph for this function:

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.

Since:
2011-12-23

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.

Parameters:
array $messages   Array[String => String]   Array of translations indexed by display key.

Definition at line 124 of file MessageCollection.php.

MessageCollection::setReviewMode ( value = true  ) 
Deprecated:
2013-01-18 enabled by default

Definition at line 236 of file MessageCollection.php.

MessageCollection::setTags ( type,
array $  keys 
)

Set message tags.

Parameters:
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.

Parameters:
string $offset
int $limit
Returns:
array Offsets that can be used for paging backwards and forwards
Since:
String offests and return value since 2013-01-10

Definition at line 281 of file MessageCollection.php.

Here is the call graph for this function:

MessageCollection::valid (  ) 

Definition at line 951 of file MessageCollection.php.

Here is the call graph for this function:


Member Data Documentation

MessageCollection::$authors = array() [protected]

Definition at line 77 of file MessageCollection.php.

Referenced by addCollectionAuthors().

MessageCollection::$code
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]
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.


The documentation for this class was generated from the following file:
Generated on Tue Oct 29 00:00:48 2013 for MediaWiki Translate Extension by  doxygen 1.6.3