|
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
|
|
|
/** |
|
19
|
|
|
* Controller class for the plugin 'Navigation'. |
|
20
|
|
|
* |
|
21
|
|
|
* @author Sebastian Meyer <[email protected]> |
|
22
|
|
|
* @package TYPO3 |
|
23
|
|
|
* @subpackage dlf |
|
24
|
|
|
* @access public |
|
25
|
|
|
*/ |
|
26
|
|
|
class NavigationController extends AbstractController |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* Method to get the page select values and use them with chash |
|
30
|
|
|
* @param \Kitodo\Dlf\Domain\Model\PageSelectForm|NULL $pageSelectForm |
|
31
|
|
|
* @return void |
|
32
|
|
|
*/ |
|
33
|
|
|
public function pageSelectAction(\Kitodo\Dlf\Domain\Model\PageSelectForm $pageSelectForm = NULL) { |
|
34
|
|
|
if ($pageSelectForm) { |
|
35
|
|
|
$uriBuilder = $this->getControllerContext()->getUriBuilder(); |
|
36
|
|
|
$uri = $uriBuilder->reset() |
|
37
|
|
|
->setArguments( |
|
38
|
|
|
[ |
|
39
|
|
|
'tx_dlf' => [ |
|
40
|
|
|
'id' => $pageSelectForm->getId(), |
|
41
|
|
|
'page' => $pageSelectForm->getPage(), |
|
42
|
|
|
'double' => $pageSelectForm->getDouble() |
|
43
|
|
|
] |
|
44
|
|
|
] |
|
45
|
|
|
) |
|
46
|
|
|
->uriFor('main'); |
|
47
|
|
|
$this->redirectToUri($uri); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* The main method of the plugin |
|
53
|
|
|
* |
|
54
|
|
|
* @return void |
|
55
|
|
|
*/ |
|
56
|
|
|
public function mainAction() |
|
57
|
|
|
{ |
|
58
|
|
|
// Load current document. |
|
59
|
|
|
$this->loadDocument($this->requestData); |
|
60
|
|
|
if ( |
|
61
|
|
|
$this->document === null |
|
62
|
|
|
|| $this->document->getDoc() === null |
|
63
|
|
|
) { |
|
64
|
|
|
// Quit without doing anything if required variables are not set. |
|
65
|
|
|
return ''; |
|
|
|
|
|
|
66
|
|
|
} else { |
|
67
|
|
|
// Set default values if not set. |
|
68
|
|
|
if ($this->document->getDoc()->numPages > 0) { |
|
69
|
|
|
if (!empty($this->requestData['logicalPage'])) { |
|
70
|
|
|
$this->requestData['page'] = $this->document->getDoc()->getPhysicalPage($this->requestData['logicalPage']); |
|
71
|
|
|
// The logical page parameter should not appear |
|
72
|
|
|
unset($this->requestData['logicalPage']); |
|
73
|
|
|
} |
|
74
|
|
|
// Set default values if not set. |
|
75
|
|
|
// $this->requestData['page'] may be integer or string (physical structure @ID) |
|
76
|
|
|
if ( |
|
77
|
|
|
(int) $this->requestData['page'] > 0 |
|
78
|
|
|
|| empty($this->requestData['page']) |
|
79
|
|
|
) { |
|
80
|
|
|
$this->requestData['page'] = MathUtility::forceIntegerInRange((int) $this->requestData['page'], 1, $this->document->getDoc()->numPages, 1); |
|
81
|
|
|
} else { |
|
82
|
|
|
$this->requestData['page'] = array_search($this->requestData['page'], $this->document->getDoc()->physicalStructure); |
|
83
|
|
|
} |
|
84
|
|
|
$this->requestData['double'] = MathUtility::forceIntegerInRange($this->requestData['double'], 0, 1, 0); |
|
85
|
|
|
} else { |
|
86
|
|
|
$this->requestData['page'] = 0; |
|
87
|
|
|
$this->requestData['double'] = 0; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
// Steps for X pages backward / forward. Double page view uses double steps. |
|
92
|
|
|
$pageSteps = $this->settings['pageStep'] * ($this->requestData['double'] + 1); |
|
93
|
|
|
|
|
94
|
|
|
$this->view->assign('pageSteps', $pageSteps); |
|
95
|
|
|
$this->view->assign('numPages', $this->document->getDoc()->numPages); |
|
96
|
|
|
$this->view->assign('viewData', $this->viewData); |
|
97
|
|
|
|
|
98
|
|
|
if ($GLOBALS['TSFE']->fe_user->getKey('ses', 'search')) { |
|
99
|
|
|
$lastSearchArguments = []; |
|
100
|
|
|
$searchSessionParameters = $GLOBALS['TSFE']->fe_user->getKey('ses', 'search'); |
|
101
|
|
|
$widgetPage = $GLOBALS['TSFE']->fe_user->getKey('ses', 'widgetPage'); |
|
102
|
|
|
|
|
103
|
|
|
if ($searchSessionParameters) { |
|
104
|
|
|
$lastSearchArguments = [ |
|
105
|
|
|
'tx_dlf_listview' => [ |
|
106
|
|
|
'searchParameter' => $searchSessionParameters |
|
107
|
|
|
] |
|
108
|
|
|
]; |
|
109
|
|
|
} |
|
110
|
|
|
if ($widgetPage) { |
|
111
|
|
|
$lastSearchArguments['tx_dlf_listview']['@widget_0'] = $widgetPage; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
// save last search parameter to generate a link back to the search list |
|
115
|
|
|
$this->view->assign('lastSearchParams', $lastSearchArguments); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
$pageOptions = []; |
|
119
|
|
|
for ($i = 1; $i <= $this->document->getDoc()->numPages; $i++) { |
|
120
|
|
|
$pageOptions[$i] = '[' . $i . ']' . ($this->document->getDoc()->physicalStructureInfo[$this->document->getDoc()->physicalStructure[$i]]['orderlabel'] ? ' - ' . htmlspecialchars($this->document->getDoc()->physicalStructureInfo[$this->document->getDoc()->physicalStructure[$i]]['orderlabel']) : ''); |
|
121
|
|
|
} |
|
122
|
|
|
$this->view->assign('pageOptions', $pageOptions); |
|
123
|
|
|
|
|
124
|
|
|
// prepare feature array for fluid |
|
125
|
|
|
$features = []; |
|
126
|
|
|
foreach (explode(',', $this->settings['features']) as $feature) { |
|
127
|
|
|
$features[$feature] = true; |
|
128
|
|
|
} |
|
129
|
|
|
$this->view->assign('features', $features); |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|