EGOCMS
18.0
EGOTEC Content-Managament-System
Page_Iterator.php
gehe zur Dokumentation dieser Datei
1
<?php
9
require_once(
'base/Page.php'
);
10
21
class
Page_Iterator
implements
Iterator, Countable
22
{
23
private
$_db;
24
private
$_site;
25
private
$_firstRun =
true
;
26
private
$_haltId = 0;
28
public
$page
;
37
public
function
Page_Iterator
($site=
''
, $db=
''
)
38
{
39
$this->_site = $site;
40
$this->_db = $db;
41
}
42
58
public
function
nextPage
()
59
{
60
$this->_firstRun =
false
;
61
if
($this->_db && $this->_db->nextRecord())
62
{
// Wenn noch ein Eintrag existiert, wird ein Page Objekt erzeugt.
63
while
($this->_haltId) {
64
if
($this->_db->Record[
'id'
] == $this->_haltId) {
65
$this->_haltId = 0;
66
}
67
if
(!$this->_db->nextRecord()) {
68
return
false
;
69
}
70
}
71
$class = $this->_site->getPageClass($this->_db->Record[
'type'
]);
72
return
$this->page =
new
$class($this->_site, $this->_db->Record);
73
}
74
unset($this->page);
// Die Funktion valid() testet auf isset($this->page).
75
return
null;
76
}
77
94
public
function
numRecords
()
95
{
96
return
$this->_db?$this->_db->numRecords():0;
97
}
98
104
function
current
()
105
{
106
return
$this->page
;
107
}
108
114
function
next
()
115
{
116
return
$this->
nextPage
();
117
}
118
124
function
key
()
125
{
126
return
$this->_db->key();
127
}
128
132
function
valid
()
133
{
134
return
isset($this->page);
135
}
136
140
function
rewind
()
141
{
142
if
($this->_firstRun) {
143
return
$this->
nextPage
();
144
}
145
$this->_db->rewind();
146
if
($this->_db->Record !== null) {
147
$class = $this->_site->getPageClass($this->_db->Record[
'type'
]);
148
return
$this->page =
new
$class($this->_site, $this->_db->Record);
149
}
150
unset($this->page);
// Die Funktion valid() testet auf isset($this->page).
151
return
null;
152
}
153
159
function
getDb
()
160
{
161
return
$this->_db;
162
}
163
170
public
function
setHaltId
($id) {
171
$this->_haltId = $id;
172
}
173
179
public
function
__toString
()
180
{
181
return
'Page_Iterator('
.$this->page.
')'
;
182
}
183
184
public
function
count
() {
185
return
$this->
numRecords
();
186
}
187
}
Page_Iterator\key
key()
Definition:
Page_Iterator.php:124
Page_Iterator\count
count()
Definition:
Page_Iterator.php:184
Page_Iterator\Page_Iterator
Page_Iterator($site='', $db='')
Definition:
Page_Iterator.php:37
Page_Iterator\__toString
__toString()
Definition:
Page_Iterator.php:179
Page_Iterator\numRecords
numRecords()
Definition:
Page_Iterator.php:94
Page_Iterator\rewind
rewind()
Definition:
Page_Iterator.php:140
Page_Iterator\$page
$page
Definition:
Page_Iterator.php:28
Page_Iterator\nextPage
nextPage()
Definition:
Page_Iterator.php:58
Page_Iterator\getDb
getDb()
Definition:
Page_Iterator.php:159
Page_Iterator\setHaltId
setHaltId($id)
Definition:
Page_Iterator.php:170
Page_Iterator\next
next()
Definition:
Page_Iterator.php:114
Page_Iterator\valid
valid()
Definition:
Page_Iterator.php:132
Page_Iterator\current
current()
Definition:
Page_Iterator.php:104
Page_Iterator
Definition:
Page_Iterator.php:21
lib
base
Page_Iterator.php
Erzeugt am Mon Feb 15 2021 08:11:44 für EGOCMS von
1.8.13