Skip to content
Snippets Groups Projects

[TASK] Change the PageBrowser to not use a Controller and TypoScript

Closed Kevin Ditscheid requested to merge task_RemovePagebrowser into master
2 files
+ 9
10
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -26,6 +26,7 @@ namespace SGalinski\SgNews\ViewHelpers;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
@@ -62,12 +63,13 @@ class PageBrowserViewHelper extends AbstractViewHelper {
* @throws \UnexpectedValueException
*/
public function render(): string {
$configuration = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_sgnews.'];
$typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);
$configuration = $typoScriptService->convertTypoScriptArrayToPlainArray($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_sgnews.']);
$view = GeneralUtility::makeInstance(StandaloneView::class);
$view->setRenderingContext($this->renderingContext);
$view->setTemplateRootPaths($configuration['view.']['templateRootPaths.']);
$view->setPartialRootPaths($configuration['view.']['partialRootPaths.']);
$view->setLayoutRootPaths($configuration['view.']['layoutRootPaths.']);
$view->setTemplateRootPaths($configuration['view']['templateRootPaths']);
$view->setPartialRootPaths($configuration['view']['partialRootPaths']);
$view->setLayoutRootPaths($configuration['view']['layoutRootPaths']);
$view->setTemplate('PageBrowser/Index');
$pageBrowserVars = GeneralUtility::_GP('tx_sgnews_pagebrowser');
if (isset($pageBrowserVars['currentPage']) && (int) $pageBrowserVars['currentPage'] > 0) {
@@ -77,8 +79,8 @@ class PageBrowserViewHelper extends AbstractViewHelper {
}
$pageLinks = [];
$start = 1;
$end = $this->arguments['numberOfPages'];
$start = \max($currentPage - 1, 1);
$end = \min($this->arguments['numberOfPages'], $currentPage + 2);
for ($i = $start; $i < $end; $i++) {
$pageLinks[] = [
'number' => $i,
@@ -94,7 +96,7 @@ class PageBrowserViewHelper extends AbstractViewHelper {
'currentPage' => $currentPage,
'prevPageExist' => $currentPage > 1,
'showLessPages' => ($currentPage - 1) > 1,
'showNextPages' => ($currentPage + 1) < $this->arguments['numberOfPages'],
'showNextPages' => ($currentPage + 2) < $this->arguments['numberOfPages'],
'nextPageExist' => $currentPage < $this->arguments['numberOfPages'] - 1,
'numberOfPages' => $this->arguments['numberOfPages']
]
Loading