3 * Note: this entire file is a byte-for-byte copy of UserArray.php with
4 * s/User/Title/. If anyone can figure out how to do this nicely with inheri-
5 * tance or something, please do so.
9 * The TitleArray class only exists to provide the newFromResult method at pre-
12 abstract class TitleArray
implements Iterator
{
14 * @param $res result A MySQL result including at least page_namespace and
15 * page_title -- also can have page_id, page_len, page_is_redirect,
16 * page_latest (if those will be used). See Title::newFromRow.
19 static function newFromResult( $res ) {
21 if ( !wfRunHooks( 'TitleArrayFromResult', array( &$array, $res ) ) ) {
24 if ( $array === null ) {
25 $array = self
::newFromResult_internal( $res );
30 protected static function newFromResult_internal( $res ) {
31 $array = new TitleArrayFromResult( $res );
36 class TitleArrayFromResult
extends TitleArray
{
40 function __construct( $res ) {
43 $this->setCurrent( $this->res
->current() );
46 protected function setCurrent( $row ) {
47 if ( $row === false ) {
48 $this->current
= false;
50 $this->current
= Title
::newFromRow( $row );
54 public function count() {
55 return $this->res
->numRows();
59 return $this->current
;
67 $row = $this->res
->next();
68 $this->setCurrent( $row );
75 $this->setCurrent( $this->res
->current() );
79 return $this->current
!== false;