00001 <?php
00031 abstract class Zend_Mail_Storage_Abstract implements Countable, ArrayAccess, SeekableIterator
00032 {
00037 protected $_has = array('uniqueid' => true,
00038 'delete' => false,
00039 'create' => false,
00040 'top' => false,
00041 'fetchPart' => true,
00042 'flags' => false);
00043
00048 protected $_iterationPos = 0;
00049
00054 protected $_iterationMax = null;
00055
00060 protected $_messageClass = 'Zend_Mail_Message';
00061
00075 public function __get($var)
00076 {
00077 if (strpos($var, 'has') === 0) {
00078 $var = strtolower(substr($var, 3));
00079 return isset($this->_has[$var]) ? $this->_has[$var] : null;
00080 }
00081
00085 require_once 'Zend/Mail/Storage/Exception.php';
00086 throw new Zend_Mail_Storage_Exception($var . ' not found');
00087 }
00088
00089
00095 public function getCapabilities()
00096 {
00097 return $this->_has;
00098 }
00099
00100
00107 abstract public function countMessages();
00108
00109
00116 abstract public function getSize($id = 0);
00117
00118
00125 abstract public function getMessage($id);
00126
00127
00136 abstract public function getRawHeader($id, $part = null, $topLines = 0);
00137
00145 abstract public function getRawContent($id, $part = null);
00146
00153 abstract public function __construct($params);
00154
00155
00159 public function __destruct()
00160 {
00161 $this->close();
00162 }
00163
00164
00171 abstract public function close();
00172
00173
00179 abstract public function noop();
00180
00186 abstract public function removeMessage($id);
00187
00197 abstract public function getUniqueId($id = null);
00198
00209 abstract public function getNumberByUniqueId($id);
00210
00211
00212
00218 public function count()
00219 {
00220 return $this->countMessages();
00221 }
00222
00223
00230 public function offsetExists($id)
00231 {
00232 try {
00233 if ($this->getMessage($id)) {
00234 return true;
00235 }
00236 } catch(Zend_Mail_Storage_Exception $e) {}
00237
00238 return false;
00239 }
00240
00241
00248 public function offsetGet($id)
00249 {
00250 return $this->getMessage($id);
00251 }
00252
00253
00262 public function offsetSet($id, $value)
00263 {
00267 require_once 'Zend/Mail/Storage/Exception.php';
00268 throw new Zend_Mail_Storage_Exception('cannot write mail messages via array access');
00269 }
00270
00271
00278 public function offsetUnset($id)
00279 {
00280 return $this->removeMessage($id);
00281 }
00282
00283
00293 public function rewind()
00294 {
00295 $this->_iterationMax = $this->countMessages();
00296 $this->_iterationPos = 1;
00297 }
00298
00299
00305 public function current()
00306 {
00307 return $this->getMessage($this->_iterationPos);
00308 }
00309
00310
00316 public function key()
00317 {
00318 return $this->_iterationPos;
00319 }
00320
00321
00327 public function next()
00328 {
00329 ++$this->_iterationPos;
00330 }
00331
00332
00338 public function valid()
00339 {
00340 if ($this->_iterationMax === null) {
00341 $this->_iterationMax = $this->countMessages();
00342 }
00343 return $this->_iterationPos && $this->_iterationPos <= $this->_iterationMax;
00344 }
00345
00346
00354 public function seek($pos)
00355 {
00356 if ($this->_iterationMax === null) {
00357 $this->_iterationMax = $this->countMessages();
00358 }
00359
00360 if ($pos > $this->_iterationMax) {
00361 throw new OutOfBoundsException('this position does not exist');
00362 }
00363 $this->_iterationPos = $pos;
00364 }
00365
00366 }