|
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 TYPO3\CMS\Core\Configuration\ExtensionConfiguration; |
|
15
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
16
|
|
|
|
|
17
|
|
|
class PageGridController extends AbstractController |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* The main method of the plugin |
|
21
|
|
|
* |
|
22
|
|
|
* @return void |
|
23
|
|
|
*/ |
|
24
|
|
|
public function mainAction() |
|
25
|
|
|
{ |
|
26
|
|
|
$requestData = GeneralUtility::_GPmerged('tx_dlf'); |
|
27
|
|
|
unset($requestData['__referrer'], $requestData['__trustedProperties']); |
|
28
|
|
|
|
|
29
|
|
|
$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('dlf'); |
|
30
|
|
|
|
|
31
|
|
|
$this->loadDocument($requestData); |
|
32
|
|
|
if ( |
|
33
|
|
|
$this->doc === null |
|
34
|
|
|
|| $this->doc->numPages < 1 |
|
35
|
|
|
|| empty($extConf['fileGrpThumbs']) |
|
36
|
|
|
) { |
|
37
|
|
|
// Quit without doing anything if required variables are not set. |
|
38
|
|
|
return; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
$entryArray = []; |
|
42
|
|
|
|
|
43
|
|
|
$numPages = $this->doc->numPages; |
|
44
|
|
|
// Iterate through visible page set and display thumbnails. |
|
45
|
|
|
for ($i = 1; $i < $numPages; $i++) { |
|
46
|
|
|
$foundEntry = $this->getEntry($i, $extConf['fileGrpThumbs']); |
|
47
|
|
|
$foundEntry['state'] = ($i == $requestData['page']) ? 'cur' : 'no'; |
|
48
|
|
|
$entryArray[] = $foundEntry; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
$this->view->assign('pageGridEntries', $entryArray); |
|
52
|
|
|
$this->view->assign('docUid', $requestData['id']); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Renders entry for one page of the current document. |
|
57
|
|
|
* |
|
58
|
|
|
* @access protected |
|
59
|
|
|
* |
|
60
|
|
|
* @param int $number: The page to render |
|
61
|
|
|
* @param string $fileGrpThumbs: the file group(s) of thumbs |
|
62
|
|
|
* |
|
63
|
|
|
* @return array The rendered entry ready for fluid |
|
64
|
|
|
*/ |
|
65
|
|
|
protected function getEntry($number, $fileGrpThumbs) |
|
66
|
|
|
{ |
|
67
|
|
|
// Set pagination. |
|
68
|
|
|
$entry['pagination'] = htmlspecialchars($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['orderlabel']); |
|
69
|
|
|
$entry['page'] = $number; |
|
70
|
|
|
$entry['thumbnail'] = ''; |
|
71
|
|
|
|
|
72
|
|
|
// Get thumbnail or placeholder. |
|
73
|
|
|
$fileGrpsThumb = GeneralUtility::trimExplode(',', $fileGrpThumbs); |
|
74
|
|
|
if (is_array($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['files'])) { |
|
75
|
|
|
if (array_intersect($fileGrpsThumb, array_keys($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['files'])) !== []) { |
|
76
|
|
|
while ($fileGrpThumb = array_shift($fileGrpsThumb)) { |
|
77
|
|
|
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['files'][$fileGrpThumb])) { |
|
78
|
|
|
$entry['thumbnail'] = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['files'][$fileGrpThumb]); |
|
79
|
|
|
break; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
return $entry; |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|