Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_jobs
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_jobs
Merge requests
!30
[TASK] Remove the pagebrowser controller and let the view helper handle stuff
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
[TASK] Remove the pagebrowser controller and let the view helper handle stuff
task_RemovePagebrowser
into
master
Overview
0
Commits
3
Changes
3
Merged
Kevin Ditscheid
requested to merge
task_RemovePagebrowser
into
master
3 years ago
Overview
0
Commits
3
Changes
3
Expand
0
0
Merge request reports
Viewing commit
d24ac685
Prev
Next
Show latest version
3 files
+
93
−
53
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
d24ac685
[BUGFIX] Code Cleanup, Improve code stability, Fix completely broken pagebrowser integration
· d24ac685
Stefan Galinski
authored
3 years ago
Classes/Controller/PageBrowserController.php deleted
100644 → 0
+
0
−
146
Options
<?php
namespace
SGalinski\SgJobs\Controller
;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use
TYPO3\CMS\Extbase\Mvc\Controller\ActionController
;
/**
* Controller that handles the page browser.
*/
class
PageBrowserController
extends
ActionController
{
/**
* @var string
*/
protected
$pageParameterName
=
''
;
/**
* @var int
*/
protected
$numberOfPages
=
0
;
/**
* @var int
*/
protected
$currentPage
=
0
;
/**
* @var int
*/
protected
$pagesBefore
=
0
;
/**
* @var int
*/
protected
$pagesAfter
=
0
;
/**
* @var bool
*/
protected
$enableMorePages
=
FALSE
;
/**
* @var bool
*/
protected
$enableLessPages
=
FALSE
;
/**
* Renders the index view.
*
* @param int $currentPage
* @return void
*/
public
function
indexAction
(
$currentPage
=
0
):
void
{
$this
->
currentPage
=
(
int
)
$currentPage
;
$this
->
initializeConfiguration
();
$this
->
addDataToView
();
}
/**
* Initializes the configuration.
*
* @return void
*/
protected
function
initializeConfiguration
():
void
{
$this
->
pageParameterName
=
'tx_sgjobs_pagebrowser[currentPage]'
;
$this
->
numberOfPages
=
(
int
)
$this
->
settings
[
'numberOfPages'
];
$this
->
pagesBefore
=
(
int
)
$this
->
settings
[
'pagesBefore'
];
$this
->
pagesAfter
=
(
int
)
$this
->
settings
[
'pagesAfter'
];
$this
->
enableMorePages
=
(
bool
)
$this
->
settings
[
'enableMorePages'
];
$this
->
enableLessPages
=
(
bool
)
$this
->
settings
[
'enableLessPages'
];
}
/**
* Adds the necessary data to the view.
*
* @return void
*/
protected
function
addDataToView
():
void
{
if
(
$this
->
numberOfPages
<=
1
)
{
$this
->
view
=
NULL
;
return
;
}
$pageLinks
=
[];
$start
=
max
(
$this
->
currentPage
-
$this
->
pagesBefore
,
0
);
$end
=
min
(
$this
->
numberOfPages
,
$this
->
currentPage
+
$this
->
pagesAfter
+
1
);
for
(
$i
=
$start
;
$i
<
$end
;
$i
++
)
{
$pageLinks
[]
=
[
'number'
=>
$i
+
1
,
'link'
=>
$this
->
getPageLink
(
$i
),
'isCurrentPage'
=>
$i
===
$this
->
currentPage
,
];
}
$this
->
view
->
assignMultiple
(
[
'enableLessPages'
=>
$this
->
enableLessPages
,
'enableMorePages'
=>
$this
->
enableMorePages
,
'previousLink'
=>
$this
->
getPageLink
(
$this
->
currentPage
-
1
),
'nextLink'
=>
$this
->
getPageLink
(
$this
->
currentPage
+
1
),
'enableLessPagesLink'
=>
$this
->
getPageLink
(
$this
->
currentPage
-
$this
->
pagesBefore
-
1
),
'enableMorePagesLink'
=>
$this
->
getPageLink
(
$this
->
currentPage
+
$this
->
pagesAfter
+
1
),
'pageLinks'
=>
$pageLinks
,
'prevPageExist'
=>
$this
->
currentPage
>
0
,
'showLessPages'
=>
(
$this
->
currentPage
-
$this
->
pagesBefore
)
>
0
,
'showNextPages'
=>
(
$this
->
currentPage
+
$this
->
pagesAfter
+
1
)
<
$this
->
numberOfPages
,
'nextPageExist'
=>
$this
->
currentPage
<
(
$this
->
numberOfPages
-
1
),
]
);
}
/**
* Generates page link. Keeps all current URL parameters except for cHash and tx_pagebrowse_pi1[page].
*
* @param int $page Page number starting from 1
* @return string
*/
protected
function
getPageLink
(
$page
):
string
{
return
$this
->
uriBuilder
->
reset
()
->
setAddQueryString
(
TRUE
)
->
uriFor
(
'index'
,
[
'currentPage'
=>
$page
,]);
}
}
Loading