MediaWiki  REL1_24
TitleArrayFromResult.php
Go to the documentation of this file.
00001 <?php
00027 class TitleArrayFromResult extends TitleArray implements Countable {
00029     public $res;
00030 
00031     public $key;
00032 
00033     public $current;
00034 
00035     function __construct( $res ) {
00036         $this->res = $res;
00037         $this->key = 0;
00038         $this->setCurrent( $this->res->current() );
00039     }
00040 
00045     protected function setCurrent( $row ) {
00046         if ( $row === false ) {
00047             $this->current = false;
00048         } else {
00049             $this->current = Title::newFromRow( $row );
00050         }
00051     }
00052 
00056     public function count() {
00057         return $this->res->numRows();
00058     }
00059 
00060     function current() {
00061         return $this->current;
00062     }
00063 
00064     function key() {
00065         return $this->key;
00066     }
00067 
00068     function next() {
00069         $row = $this->res->next();
00070         $this->setCurrent( $row );
00071         $this->key++;
00072     }
00073 
00074     function rewind() {
00075         $this->res->rewind();
00076         $this->key = 0;
00077         $this->setCurrent( $this->res->current() );
00078     }
00079 
00083     function valid() {
00084         return $this->current !== false;
00085     }
00086 }