From: Aryeh Gregor Date: Fri, 25 Jul 2008 19:03:53 +0000 (+0000) Subject: Add TitleArray, a straight rip-off of UserArray. I couldn't figure out how to make... X-Git-Tag: 1.31.0-rc.0~46368 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=38473966ead6e85dc444f27b721c89542eb99866;p=lhc%2Fweb%2Fwiklou.git Add TitleArray, a straight rip-off of UserArray. I couldn't figure out how to make them both inherit from ObjectArray or anything, so code duplication works for now. --- diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index f52347f55a..0351017145 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -191,6 +191,7 @@ $wgAutoloadLocalClasses = array( 'ThumbnailImage' => 'includes/MediaTransformOutput.php', 'TitleDependency' => 'includes/CacheDependency.php', 'Title' => 'includes/Title.php', + 'TitleArray' => 'includes/TitleArray.php', 'TitleListDependency' => 'includes/CacheDependency.php', 'TransformParameterError' => 'includes/MediaTransformOutput.php', 'TurckBagOStuff' => 'includes/BagOStuff.php', diff --git a/includes/TitleArray.php b/includes/TitleArray.php new file mode 100644 index 0000000000..b2f3d2f379 --- /dev/null +++ b/includes/TitleArray.php @@ -0,0 +1,77 @@ +res = $res; + $this->key = 0; + $this->setCurrent( $this->res->current() ); + } + + protected function setCurrent( $row ) { + if ( $row === false ) { + $this->current = false; + } else { + $this->current = Title::newFromRow( $row ); + } + } + + function current() { + return $this->current; + } + + function key() { + return $this->key; + } + + function next() { + $row = $this->res->next(); + $this->setCurrent( $row ); + $this->key++; + } + + function rewind() { + $this->res->rewind(); + $this->key = 0; + $this->setCurrent( $this->res->current() ); + } + + function valid() { + return $this->current !== false; + } +}