2 namespace wcf\system\message\quote
;
6 * Wrapper class for quoted messages.
8 * @author Alexander Ebert
9 * @copyright 2001-2013 WoltLab GmbH
10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
11 * @package com.woltlab.wcf.message
12 * @subpackage system.message.quote
13 * @category Community Framework
15 class QuotedMessage
implements \Countable
, \Iterator
{
17 * list of full quotes for insertation
20 public $fullQuotes = array();
23 * quotable database object
24 * @var wcf\data\IQuotableDatabaseObject
26 public $object = null;
29 * list of quotes (shortend)
32 public $quotes = array();
35 * current iterator index
41 * list of index to object relation
44 protected $indexToObject = null;
47 * Creates a new QuotedMessage object.
49 * @param wcf\data\IMessage $object
51 public function __construct(IMessage
$object) {
52 $this->object = $object;
56 * Adds a quote for this message.
58 * @param string $quoteID
59 * @param string $quote
60 * @param string $fullQuote
62 public function addQuote($quoteID, $quote, $fullQuote) {
63 $this->fullQuotes
[$quoteID] = $fullQuote;
64 $this->quotes
[$quoteID] = $quote;
65 $this->indexToObject
[] = $quoteID;
69 * @see wcf\data\ITitledObject::getTitle()
71 public function __toString() {
72 return $this->object->getTitle();
76 * Forwards calls to the decorated object.
82 public function __call($name, $value) {
83 return $this->object->$name();
87 * Returns the full quote by quote id.
89 * @param string $quoteID
92 public function getFullQuote($quoteID) {
93 if (isset($this->fullQuotes
[$quoteID])) {
94 return $this->fullQuotes
[$quoteID];
101 * @see \Countable::count()
103 public function count() {
104 return count($this->quotes
);
108 * @see \Iterator::current()
110 public function current() {
111 $objectID = $this->indexToObject
[$this->index
];
112 return $this->quotes
[$objectID];
116 * CAUTION: This methods does not return the current iterator index,
117 * rather than the object key which maps to that index.
119 * @see \Iterator::key()
121 public function key() {
122 return $this->indexToObject
[$this->index
];
126 * @see \Iterator::next()
128 public function next() {
133 * @see \Iterator::rewind()
135 public function rewind() {
140 * @see \Iterator::valid()
142 public function valid() {
143 return isset($this->indexToObject
[$this->index
]);