From 38473966ead6e85dc444f27b721c89542eb99866 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Fri, 25 Jul 2008 19:03:53 +0000 Subject: [PATCH] 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. --- includes/AutoLoader.php | 1 + includes/TitleArray.php | 77 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 includes/TitleArray.php 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; + } +} -- 2.20.1