Thomas
2013-10-14 566747af00ae413c942a7c6702e24c044af36f17
commit | author | age
47124c 1 <?php
T 2
3 /*
4  +-----------------------------------------------------------------------+
e019f2 5  | This file is part of the Roundcube Webmail client                     |
1cf15e 6  | Copyright (C) 2006-2013, The Roundcube Dev Team                       |
7fe381 7  |                                                                       |
T 8  | Licensed under the GNU General Public License version 3 or            |
9  | any later version with exceptions for skins & plugins.                |
10  | See the README file for a full license statement.                     |
47124c 11  |                                                                       |
T 12  | PURPOSE:                                                              |
13  |   Class representing an address directory result set                  |
14  +-----------------------------------------------------------------------+
15  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16  +-----------------------------------------------------------------------+
17 */
18
19 /**
1cf15e 20  * Roundcube result set class
TB 21  *
47124c 22  * Representing an address directory result set.
1cf15e 23  * Implenets Iterator and thus be used in foreach() loops.
47124c 24  *
9ab346 25  * @package    Framework
AM 26  * @subpackage Addressbook
47124c 27  */
1cf15e 28 class rcube_result_set implements Iterator
47124c 29 {
1cf15e 30     public $count = 0;
TB 31     public $first = 0;
32     public $searchonly = false;
33     public $records = array();
2eb794 34
1cf15e 35     private $current = 0;
2eb794 36
A 37     function __construct($c=0, $f=0)
38     {
39         $this->count = (int)$c;
40         $this->first = (int)$f;
41     }
42
43     function add($rec)
44     {
45         $this->records[] = $rec;
46     }
e9a9f2 47
2eb794 48     function iterate()
A 49     {
50         return $this->records[$this->current++];
51     }
e9a9f2 52
2eb794 53     function first()
A 54     {
55         $this->current = 0;
1cf15e 56         return $this->records[$this->current];
2eb794 57     }
e9a9f2 58
2eb794 59     function seek($i)
A 60     {
61         $this->current = $i;
62     }
e9a9f2 63
1cf15e 64     /***  PHP 5 Iterator interface  ***/
TB 65
66     function rewind()
67     {
68         $this->current = 0;
69     }
70
71     function current()
72     {
73         return $this->records[$this->current];
74     }
75
76     function key()
77     {
78         return $this->current;
79     }
80
81     function next()
82     {
83         return $this->iterate();
84     }
85
86     function valid()
87     {
88         return isset($this->records[$this->current]);
89     }
90
2eb794 91 }