|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* (c) Kitodo. Key to digital objects e.V. <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of the Kitodo and TYPO3 projects. |
|
6
|
|
|
* |
|
7
|
|
|
* @license GNU General Public License version 3 or later. |
|
8
|
|
|
* For the full copyright and license information, please read the |
|
9
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Kitodo\Dlf\Controller; |
|
13
|
|
|
|
|
14
|
|
|
use Kitodo\Dlf\Common\Helper; |
|
15
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
16
|
|
|
use TYPO3\CMS\Core\Utility\MathUtility; |
|
17
|
|
|
|
|
18
|
|
|
class NavigationController extends AbstractController |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* The main method of the plugin |
|
22
|
|
|
* |
|
23
|
|
|
* @return void |
|
24
|
|
|
*/ |
|
25
|
|
|
public function mainAction() |
|
26
|
|
|
{ |
|
27
|
|
|
$requestData = GeneralUtility::_GPmerged('tx_dlf'); |
|
28
|
|
|
unset($requestData['__referrer'], $requestData['__trustedProperties']); |
|
29
|
|
|
|
|
30
|
|
|
if (empty($requestData['page'])) { |
|
31
|
|
|
$requestData['page'] = 1; |
|
32
|
|
|
} |
|
33
|
|
|
// Load current document. |
|
34
|
|
|
$this->loadDocument($requestData); |
|
35
|
|
|
if ($this->doc === null) { |
|
36
|
|
|
// Quit without doing anything if required variables are not set. |
|
37
|
|
|
return; |
|
38
|
|
|
} else { |
|
39
|
|
|
// Set default values if not set. |
|
40
|
|
|
if ($this->doc->numPages > 0) { |
|
41
|
|
|
if (!empty($requestData['logicalPage'])) { |
|
42
|
|
|
$requestData['page'] = $this->doc->getPhysicalPage($requestData['logicalPage']); |
|
43
|
|
|
// The logical page parameter should not appear |
|
44
|
|
|
unset($requestData['logicalPage']); |
|
45
|
|
|
} |
|
46
|
|
|
// Set default values if not set. |
|
47
|
|
|
// $requestData['page'] may be integer or string (physical structure @ID) |
|
48
|
|
|
if ( |
|
49
|
|
|
(int) $requestData['page'] > 0 |
|
50
|
|
|
|| empty($requestData['page']) |
|
51
|
|
|
) { |
|
52
|
|
|
$requestData['page'] = MathUtility::forceIntegerInRange((int) $requestData['page'], 1, $this->doc->numPages, 1); |
|
53
|
|
|
} else { |
|
54
|
|
|
$requestData['page'] = array_search($requestData['page'], $this->doc->physicalStructure); |
|
55
|
|
|
} |
|
56
|
|
|
$requestData['double'] = MathUtility::forceIntegerInRange($requestData['double'], 0, 1, 0); |
|
57
|
|
|
} else { |
|
58
|
|
|
$requestData['page'] = 0; |
|
59
|
|
|
$requestData['double'] = 0; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
// Steps for X pages backward / forward. Double page view uses double steps. |
|
64
|
|
|
$pageSteps = $this->settings['pageStep'] * ($requestData['double'] + 1); |
|
65
|
|
|
|
|
66
|
|
|
$this->view->assign('page', $requestData['page']); |
|
67
|
|
|
$this->view->assign('docId', $this->doc->uid); |
|
68
|
|
|
$this->view->assign('pageId', $GLOBALS['TSFE']->id); |
|
69
|
|
|
$this->view->assign('pageSteps', $pageSteps); |
|
70
|
|
|
$this->view->assign('double', $requestData['double']); |
|
71
|
|
|
$this->view->assign('numPages', $this->doc->numPages); |
|
72
|
|
|
|
|
73
|
|
|
// TODO: Check if f:link.action can be used in template Navigation->main |
|
74
|
|
|
$this->view->assign('pageToList', $this->settings['targetPid']); |
|
75
|
|
|
$this->view->assign('forceAbsoluteUrl', !empty($this->conf['settings.forceAbsoluteUrl']) ? 1 : 0); |
|
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
$pageOptions = []; |
|
78
|
|
|
for ($i = 1; $i <= $this->doc->numPages; $i++) { |
|
79
|
|
|
$pageOptions[$i] = ($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$i]]['orderlabel'] ? ' - ' . htmlspecialchars($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$i]]['orderlabel']) : ''); |
|
80
|
|
|
} |
|
81
|
|
|
$this->view->assign('uniqueId', uniqid(Helper::getUnqualifiedClassName(get_class($this)) . '-')); |
|
82
|
|
|
$this->view->assign('pageOptions', $pageOptions); |
|
83
|
|
|
|
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|