Mercurial > hg > rc2
comparison program/lib/Roundcube/rcube_result_set.php @ 0:4681f974d28b
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:52:31 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4681f974d28b |
---|---|
1 <?php | |
2 | |
3 /** | |
4 +-----------------------------------------------------------------------+ | |
5 | This file is part of the Roundcube Webmail client | | |
6 | Copyright (C) 2006-2013, The Roundcube Dev Team | | |
7 | | | |
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. | | |
11 | | | |
12 | PURPOSE: | | |
13 | Class representing an address directory result set | | |
14 +-----------------------------------------------------------------------+ | |
15 | Author: Thomas Bruederli <roundcube@gmail.com> | | |
16 +-----------------------------------------------------------------------+ | |
17 */ | |
18 | |
19 /** | |
20 * Roundcube result set class | |
21 * | |
22 * Representing an address directory result set. | |
23 * Implenets Iterator and thus be used in foreach() loops. | |
24 * | |
25 * @package Framework | |
26 * @subpackage Addressbook | |
27 */ | |
28 class rcube_result_set implements Iterator, ArrayAccess | |
29 { | |
30 public $count = 0; | |
31 public $first = 0; | |
32 public $searchonly = false; | |
33 public $records = array(); | |
34 | |
35 private $current = 0; | |
36 | |
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 } | |
47 | |
48 function iterate() | |
49 { | |
50 return $this->records[$this->current++]; | |
51 } | |
52 | |
53 function first() | |
54 { | |
55 $this->current = 0; | |
56 return $this->records[$this->current]; | |
57 } | |
58 | |
59 function seek($i) | |
60 { | |
61 $this->current = $i; | |
62 } | |
63 | |
64 /*** Implement PHP ArrayAccess interface ***/ | |
65 | |
66 public function offsetSet($offset, $value) | |
67 { | |
68 if (is_null($offset)) { | |
69 $offset = count($this->records); | |
70 $this->records[] = $value; | |
71 } | |
72 else { | |
73 $this->records[$offset] = $value; | |
74 } | |
75 } | |
76 | |
77 public function offsetExists($offset) | |
78 { | |
79 return isset($this->records[$offset]); | |
80 } | |
81 | |
82 public function offsetUnset($offset) | |
83 { | |
84 unset($this->records[$offset]); | |
85 } | |
86 | |
87 public function offsetGet($offset) | |
88 { | |
89 return $this->records[$offset]; | |
90 } | |
91 | |
92 /*** PHP 5 Iterator interface ***/ | |
93 | |
94 function rewind() | |
95 { | |
96 $this->current = 0; | |
97 } | |
98 | |
99 function current() | |
100 { | |
101 return $this->records[$this->current]; | |
102 } | |
103 | |
104 function key() | |
105 { | |
106 return $this->current; | |
107 } | |
108 | |
109 function next() | |
110 { | |
111 return $this->iterate(); | |
112 } | |
113 | |
114 function valid() | |
115 { | |
116 return isset($this->records[$this->current]); | |
117 } | |
118 } |