31 'insertAbove' =>
false,
32 'insertBelow' =>
true,
33 'maximumNumberOfLinks' => 99,
34 'addQueryStringMethod' =>
'',
73 $this->objects = $this->widgetConfiguration[
'objects'];
75 $itemsPerPage = (int)$this->configuration[
'itemsPerPage'];
76 $this->numberOfPages = $itemsPerPage > 0 ? ceil(count($this->objects) / $itemsPerPage) : 0;
77 $this->maximumNumberOfLinks = (int)$this->configuration[
'maximumNumberOfLinks'];
87 if ($this->currentPage < 1) {
88 $this->currentPage = 1;
90 if ($this->currentPage > $this->numberOfPages) {
92 $modifiedObjects =
null;
95 $itemsPerPage = (int)$this->configuration[
'itemsPerPage'];
97 if ($this->objects instanceof QueryResultInterface) {
98 $offset = (int)$this->objects->getQuery()->getOffset();
100 if ($this->currentPage > 1) {
101 $offset = $offset + ((int)($itemsPerPage * ($this->currentPage - 1)));
105 $this->view->assign(
'contentArguments', [
106 $this->widgetConfiguration[
'as'] => $modifiedObjects
108 $this->view->assign(
'configuration', $this->configuration);
123 $this->displayRangeStart = $this->currentPage - $delta;
125 if ($this->displayRangeStart < 1) {
126 $this->displayRangeEnd -= $this->displayRangeStart - 1;
128 if ($this->displayRangeEnd > $this->numberOfPages) {
131 $this->displayRangeStart = (int)max($this->displayRangeStart, 1);
132 $this->displayRangeEnd = (int)min($this->displayRangeEnd, $this->numberOfPages);
154 'hasLessPages' => $this->displayRangeStart > 2,
157 if ($this->currentPage < $this->numberOfPages) {
158 $pagination[
'nextPage'] = $this->currentPage + 1;
160 if ($this->currentPage > 1) {
161 $pagination[
'previousPage'] = $this->currentPage - 1;
176 $currentRange = $offset + $itemsPerPage;
177 $endOfRange = min($currentRange, count($this->objects));
178 $query = $this->objects->getQuery();
179 $query->setLimit($itemsPerPage);
181 $query->setOffset($offset);
182 if ($currentRange > $endOfRange) {
183 $newLimit = $endOfRange - $offset;
184 $query->setLimit($newLimit);
187 $modifiedObjects = $query->execute();
188 return $modifiedObjects;
190 if ($this->objects instanceof ObjectStorage) {
191 $modifiedObjects = [];
192 $objectArray = $this->objects->toArray();
193 $endOfRange = min($offset + $itemsPerPage, count($objectArray));
194 for ($i = $offset; $i < $endOfRange; $i++) {
195 $modifiedObjects[] = $objectArray[$i];
197 return $modifiedObjects;
199 if (is_array($this->objects)) {
200 $modifiedObjects = array_slice($this->objects, $offset, $itemsPerPage);
201 return $modifiedObjects;
203 throw new \InvalidArgumentException(
204 'The ViewHelper "' . static::class
205 .
'" accepts as argument "QueryResultInterface", "\SplObjectStorage", "ObjectStorage" or an array. '
206 .
'given: ' . get_class($this->objects),