2 namespace TYPO3\CMS\Fluid\ViewHelpers\Widget\Controller;
38 'insertAbove' =>
false,
39 'insertBelow' =>
true,
40 'maximumNumberOfLinks' => 99,
41 'addQueryStringMethod' =>
'',
80 $this->objects = $this->widgetConfiguration[
'objects'];
82 $this->numberOfPages = ceil(count($this->objects) / (
int)$this->configuration[
'itemsPerPage']);
83 $this->maximumNumberOfLinks = (int)$this->configuration[
'maximumNumberOfLinks'];
94 if ($this->currentPage < 1) {
95 $this->currentPage = 1;
97 if ($this->currentPage > $this->numberOfPages) {
99 $modifiedObjects = null;
102 $itemsPerPage = (int)$this->configuration[
'itemsPerPage'];
104 if ($this->currentPage > 1) {
105 $offset = ((int)($itemsPerPage * ($this->currentPage - 1)));
109 $this->view->assign(
'contentArguments', array(
110 $this->widgetConfiguration[
'as'] => $modifiedObjects
112 $this->view->assign(
'configuration', $this->configuration);
129 $this->displayRangeStart = $this->currentPage - $delta;
131 if ($this->displayRangeStart < 1) {
132 $this->displayRangeEnd -= $this->displayRangeStart - 1;
134 if ($this->displayRangeEnd > $this->numberOfPages) {
137 $this->displayRangeStart = (int)max($this->displayRangeStart, 1);
138 $this->displayRangeEnd = (int)min($this->displayRangeEnd, $this->numberOfPages);
152 $pages[] = array(
'number' => $i,
'isCurrent' => $i === $this->currentPage);
156 'current' => $this->currentPage,
157 'numberOfPages' => $this->numberOfPages,
158 'displayRangeStart' => $this->displayRangeStart,
159 'displayRangeEnd' => $this->displayRangeEnd,
160 'hasLessPages' => $this->displayRangeStart > 2,
161 'hasMorePages' => $this->displayRangeEnd + 1 < $this->numberOfPages
163 if ($this->currentPage < $this->numberOfPages) {
164 $pagination[
'nextPage'] = $this->currentPage + 1;
166 if ($this->currentPage > 1) {
167 $pagination[
'previousPage'] = $this->currentPage - 1;
182 $query = $this->objects->getQuery();
183 $query->setLimit($itemsPerPage);
185 $query->setOffset($offset);
187 $modifiedObjects = $query->execute();
188 return $modifiedObjects;
190 $modifiedObjects = array();
191 $endOfRange = $offset + $itemsPerPage;
192 for ($i = $offset; $i < $endOfRange; $i++) {
193 $modifiedObjects[] = $this->objects->toArray()[$i];
195 return $modifiedObjects;
196 }
elseif (is_array($this->objects)) {
197 $modifiedObjects = array_slice($this->objects, $offset, $itemsPerPage);
198 return $modifiedObjects;
200 throw new \InvalidArgumentException(
'The view helper "' . get_class($this)
201 .
'" accepts as argument "QueryResultInterface", "\SplObjectStorage", "ObjectStorage" or an array. '
202 .
'given: ' . get_class($this->objects), 1385547291