19 require_once(BASE.
"wcmf/lib/presentation/class.Controller.php");
20 require_once(BASE.
"wcmf/lib/util/class.SessionData.php");
91 parent::initialize($request, $response);
95 if ($request->getAction() ==
'prev' || $request->getAction() ==
'next')
99 if ($session->exist($this->OIDS_SESSION_VARNAME) && $session->exist($this->INDEX_SESSION_VARNAME))
103 $lastIndex = $session->get($this->INDEX_SESSION_VARNAME);
109 if ($request->getAction() ==
'next')
112 $this->_startIndex = $lastIndex + $length;
113 if ($this->_startIndex >=
sizeof($allOIDs))
114 $this->_startIndex = $lastIndex;
116 else if ($request->getAction() ==
'prev')
119 $this->_startIndex = $lastIndex - $length;
120 if ($this->_startIndex <= 0)
121 $this->_startIndex = 0;
128 $session->set($this->OIDS_SESSION_VARNAME, $allOIDs);
130 if (in_array($request->getValue(
'oid'), $allOIDs))
134 $this->_curOIDs = array_slice($allOIDs, $index, $length);
135 while (
sizeof($this->_curOIDs) > 0)
140 $this->_curOIDs = array_slice($allOIDs, $index, $length);
142 $this->_startIndex = $index;
145 $this->_startIndex = 0;
149 $session->set($this->INDEX_SESSION_VARNAME, $this->_startIndex);
150 $this->_total =
sizeof($allOIDs);
151 $this->_allOIDs = $allOIDs;
152 $this->_curOIDs = array_slice($allOIDs, $this->_startIndex, $length);
174 foreach($this->_curOIDs as $curOID)
177 if ($rightsManager->authorize($curOID,
'',
ACTION_READ))
181 $nodes[
sizeof($nodes)] = &$node;
186 $this->_response->setValue(
'nodes', $nodes);
187 $this->_response->setValue(
'hasPrev', $this->_hasPrev);
188 $this->_response->setValue(
'hasNext', $this->_hasNext);
190 $this->_response->setValue(
'total', $this->_total);
191 $this->_response->setValue(
'index', $this->_startIndex);
192 $this->_response->setValue(
'size', $this->_size);
195 $packageStartOids = array();
198 while ($index <
sizeof($this->_allOIDs))
200 array_push($packageStartOids, $this->_allOIDs[$index]);
203 $this->_response->setValue(
'packageStartOids', $packageStartOids);
206 $this->_response->setAction(
'ok');
216 WCMFException::throwEx(
"getOIDs() must be implemented by derived class: ".get_class($this), __FILE__, __LINE__);
226 WCMFException::throwEx(
"getDisplayText() must be implemented by derived class: ".get_class($this), __FILE__, __LINE__);
253 if ($startIndex <= 0)
254 $this->_hasPrev =
false;
256 $this->_hasPrev =
true;
259 if ($startIndex >= $total || $startIndex+$length >= $total)
260 $this->_hasNext =
false;
262 $this->_hasNext =
true;
270 $session->remove($this->OIDS_SESSION_VARNAME);
271 $this->
initialize($this->_request, $this->_response);
PagingController is a controller that allows to navigate lists.
throwEx($message, $file='', $line='')
Controller is the base class of all controllers. If a Controller has a view it is expected to reside ...
initialize(&$request, &$response)
updateNavigation($startIndex, $length, $total)