Reverted r42528. Links with href="#" make firefox scroll to the top of the page,...
[mediawiki.git] / includes / UserArray.php
bloba2f54b7f2753fb2e155b58b732b0a2059977f143
1 <?php
3 abstract class UserArray implements Iterator {
4 static function newFromResult( $res ) {
5 $userArray = null;
6 if ( !wfRunHooks( 'UserArrayFromResult', array( &$userArray, $res ) ) ) {
7 return null;
9 if ( $userArray === null ) {
10 $userArray = self::newFromResult_internal( $res );
12 return $userArray;
15 protected static function newFromResult_internal( $res ) {
16 $userArray = new UserArrayFromResult( $res );
17 return $userArray;
21 class UserArrayFromResult extends UserArray {
22 var $res;
23 var $key, $current;
25 function __construct( $res ) {
26 $this->res = $res;
27 $this->key = 0;
28 $this->setCurrent( $this->res->current() );
31 protected function setCurrent( $row ) {
32 if ( $row === false ) {
33 $this->current = false;
34 } else {
35 $this->current = User::newFromRow( $row );
39 public function count() {
40 return $this->res->numRows();
43 function current() {
44 return $this->current;
47 function key() {
48 return $this->key;
51 function next() {
52 $row = $this->res->next();
53 $this->setCurrent( $row );
54 $this->key++;
57 function rewind() {
58 $this->res->rewind();
59 $this->key = 0;
60 $this->setCurrent( $this->res->current() );
63 function valid() {
64 return $this->current !== false;