http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72419
Revision: 72419
Author: nikerabbit
Date: 2010-09-05 13:07:33 +0000 (Sun, 05 Sep 2010)
Log Message:
-----------
Documentation updates. Moved some methods to the interface that were common or
required by MessageCollection.
Modified Paths:
--------------
trunk/extensions/Translate/Message.php
Modified: trunk/extensions/Translate/Message.php
===================================================================
--- trunk/extensions/Translate/Message.php 2010-09-05 13:05:48 UTC (rev
72418)
+++ trunk/extensions/Translate/Message.php 2010-09-05 13:07:33 UTC (rev
72419)
@@ -1,6 +1,6 @@
<?php
/**
- * Classes for message objects.
+ * Classes for message objects TMessage and ThinMessage.
*
* @file
* @author Niklas Laxström
@@ -9,11 +9,17 @@
*/
/**
- * @todo Needs documentation.
+ * Interface for message objects used by MessageCollection.
*/
abstract class TMessage {
+ /// \string Message display key.
protected $key;
+ /// \string Message definition.
protected $definition;
+ /// \string Committed in-file translation.
+ protected $infile;
+ /// \list{String} Message tags.
+ protected $tags = array();
/**
* Creates new message object.
@@ -26,75 +32,110 @@
$this->definition = $definition;
}
+ /**
+ * Get the message key.
+ * @return \string
+ */
public function key() { return $this->key; }
+
+ /**
+ * Get the message definition.
+ * @return \string
+ */
public function definition() { return $this->definition; }
+
+ /**
+ * Get the message translation.
+ * @return \types{\string,\null}
+ */
abstract public function translation();
+
+ /**
+ * Get the last translator of the message.
+ * @return \types{\string,\null}
+ */
abstract public function author();
-}
-/**
- * @todo Needs documentation.
- */
-class ThinMessage extends TMessage {
- private $infile;
- private $row;
- private $tags = array();
-
+ /**
+ * Set the committed translation.
+ * @param $text \string
+ */
public function setInfile( $text ) {
$this->infile = $text;
}
- public function setRow( $row ) {
- $this->row = $row;
+ /**
+ * Returns the committed translation.
+ * @return \types{\string,\null}
+ */
+ public function infile() {
+ return $this->infile;
}
+ /**
+ * Add a tag for this message.
+ * @param $tag \string
+ * @todo Rename to addTag.
+ */
public function setTag( $tag ) {
$this->tags[] = $tag;
}
- public function key() {
- return $this->key;
+ /**
+ * Check if this message has a given tag.
+ * @param $tag \string
+ * @return \bool
+ */
+ public function hasTag( $tag ) {
+ return in_array( $tag, $this->tags, true );
}
+}
- public function definition() {
- return $this->definition;
+/**
+ * %Message object which is based on database result row. Hence the name thin.
+ * Needs fields rev_user_text and those that are needed for loading revision
+ * text.
+ */
+class ThinMessage extends TMessage {
+ /// \type{Database Result Row}
+ protected $row;
+
+ /**
+ * Set the database row this message is based on.
+ * @param $row \type{Database Result Row}
+ */
+ public function setRow( $row ) {
+ $this->row = $row;
}
public function translation() {
if ( !isset( $this->row ) ) {
return $this->infile();
}
-
return Revision::getRevisionText( $this->row );
}
+
public function author() {
if ( !isset( $this->row ) ) {
return null;
}
-
return $this->row->rev_user_text;
}
- public function infile() {
- if ( !isset( $this->infile ) ) {
- return null;
- }
-
- return $this->infile;
- }
-
- public function hasTag( $tag ) {
- return in_array( $tag, $this->tags, true );
- }
}
/**
- * @todo Needs documentation.
+ * %Message object where you can directly set the translation.
+ * Hence the name fat. Authors are not supported.
*/
class FatMessage extends TMessage {
- protected $translation = null;
- protected $infile = null;
+ /// \string Stored translation.
+ protected $translation;
+ /**
+ * Set the current translation of this message.
+ * @param $text \string
+ */
public function setTranslation( $text ) {
$this->translation = $text;
}
@@ -103,17 +144,9 @@
if ( $this->translation === null ) {
return $this->infile;
}
-
return $this->translation;
}
- public function author() { }
-
- public function setInfile( $text ) {
- $this->infile = $text;
- }
-
- public function infile() {
- return $this->infile;
- }
+ // Not implemented
+ public function author() {}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs