Skip to content
Snippets Groups Projects
Commit 939ad882 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASk] Started work on page browser

parent 6e9fe10e
No related branches found
No related tags found
No related merge requests found
......@@ -67,10 +67,21 @@ class JoblistController extends ActionController {
$this->assignFilterValues($storagePid);
$this->view->assign('recordPageId', $storagePid);
// get all jobs for the next root page
$jobs = $this->jobRepository->findJobs($storagePid);
// pagination logic
$jobLimit = (int) $this->settings['jobLimit'];
$offset = 0;
$currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgjobs_pagebrowser')['currentPage'];
if ($currentPageBrowserPage && $jobLimit) {
$offset = $currentPageBrowserPage * $jobLimit;
}
// get all jobs
$jobs = $this->jobRepository->findJobs($storagePid, [], FALSE, $jobLimit, $offset);
$numberOfPages = ($jobLimit <= 0 ? 0 : ceil(\count($jobs) / $jobLimit));
$this->view->assign('jobs', $jobs);
$this->view->assign('numberOfPages', \count($jobs));
$this->view->assign('numberOfPages', $numberOfPages);
}
/**
......
......@@ -54,11 +54,13 @@ class JobRepository extends Repository {
* @param int $pageUid
* @param array $filters
* @param boolean $raw
* @param int $limit
* @param int $offset
* @return mixed
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
* @throws \InvalidArgumentException
*/
public function findJobs($pageUid, array $filters = [], $raw = FALSE) {
public function findJobs($pageUid, array $filters = [], $raw = FALSE, $limit = 0, $offset = 0) {
$query = $this->createQuery();
$querySettings = $query->getQuerySettings();
$querySettings->setStoragePageIds([$pageUid]);
......@@ -93,6 +95,14 @@ class JobRepository extends Repository {
$constraints[] = $query->logicalOr($searchConstraints);
}
if ($limit > 0) {
$query->setLimit($limit);
}
if ($offset > 0) {
$query->setOffset($offset);
}
if (\count($constraints) > 1) {
$query->matching($query->logicalAnd($constraints));
} elseif (\count($constraints)) {
......
......@@ -27,6 +27,17 @@
</config>
</TCEforms>
</settings.applyPage>
<settings.jobLimit>
<TCEforms>
<label>LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:plugin.overview.flexForm.jobLimit</label>
<config>
<type>input</type>
<size>5</size>
<eval>int</eval>
<default>5</default>
</config>
</TCEforms>
</settings.jobLimit>
</el>
</ROOT>
</sDEF>
......
......@@ -13,6 +13,8 @@
<hr>
</f:for>
</div>
<div id="sgjobs-pagination">
<f:format.raw>
<sg:pageBrowser numberOfPages="{numberOfPages}" />
</f:format.raw>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment