|
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
|
|
|
/** |
|
13
|
|
|
* Tool 'Fulltext selection' for the plugin 'DLF: Toolbox' of the 'dlf' extension. |
|
14
|
|
|
* |
|
15
|
|
|
* @author Sebastian Meyer <[email protected]> |
|
16
|
|
|
* @author Alexander Bigga <[email protected]> |
|
17
|
|
|
* @package TYPO3 |
|
18
|
|
|
* @subpackage tx_dlf |
|
19
|
|
|
* @access public |
|
20
|
|
|
*/ |
|
21
|
|
|
class tx_dlf_toolsFulltext extends tx_dlf_plugin { |
|
22
|
|
|
|
|
23
|
|
|
public $scriptRelPath = 'plugins/toolbox/tools/fulltext/class.tx_dlf_toolsFulltext.php'; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* The main method of the PlugIn |
|
27
|
|
|
* |
|
28
|
|
|
* @access public |
|
29
|
|
|
* |
|
30
|
|
|
* @param string $content: The PlugIn content |
|
31
|
|
|
* @param array $conf: The PlugIn configuration |
|
32
|
|
|
* |
|
33
|
|
|
* @return string The content that is displayed on the website |
|
34
|
|
|
*/ |
|
35
|
|
|
public function main($content, $conf) { |
|
36
|
|
|
|
|
37
|
|
|
$this->init($conf); |
|
38
|
|
|
|
|
39
|
|
|
// Merge configuration with conf array of toolbox. |
|
40
|
|
|
$this->conf = tx_dlf_helper::array_merge_recursive_overrule($this->cObj->data['conf'], $this->conf); |
|
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
// Load current document. |
|
43
|
|
|
$this->loadDocument(); |
|
44
|
|
|
|
|
45
|
|
View Code Duplication |
if ($this->doc === NULL || $this->doc->numPages < 1 || empty($this->conf['fileGrpFulltext'])) { |
|
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
// Quit without doing anything if required variables are not set. |
|
48
|
|
|
return $content; |
|
49
|
|
|
|
|
50
|
|
|
} else { |
|
51
|
|
|
|
|
52
|
|
|
if (!empty($this->piVars['logicalPage'])) { |
|
53
|
|
|
|
|
54
|
|
|
$this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); |
|
|
|
|
|
|
55
|
|
|
// The logical page parameter should not appear again |
|
56
|
|
|
unset($this->piVars['logicalPage']); |
|
57
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
// Set default values if not set. |
|
61
|
|
|
// $this->piVars['page'] may be integer or string (physical structure @ID) |
|
62
|
|
|
if ( (int)$this->piVars['page'] > 0 || empty($this->piVars['page'])) { |
|
63
|
|
|
|
|
64
|
|
|
$this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1); |
|
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
} else { |
|
67
|
|
|
|
|
68
|
|
|
$this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure); |
|
69
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
$this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0); |
|
73
|
|
|
|
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
// Load template file. |
|
77
|
|
View Code Duplication |
if (!empty($this->conf['toolTemplateFile'])) { |
|
|
|
|
|
|
78
|
|
|
|
|
79
|
|
|
$this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['toolTemplateFile']), '###TEMPLATE###'); |
|
80
|
|
|
|
|
81
|
|
|
} else { |
|
82
|
|
|
|
|
83
|
|
|
$this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dlf/plugins/toolbox/tools/fulltext/template.tmpl'), '###TEMPLATE###'); |
|
84
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
|
|
88
|
|
|
$fullTextFile = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpFulltext']]; |
|
89
|
|
|
|
|
90
|
|
|
if (!empty($fullTextFile)) { |
|
91
|
|
|
$markerArray['###FULLTEXT_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-fulltext" title="" data-dic="fulltext-on:' |
|
|
|
|
|
|
92
|
|
|
.$this->pi_getLL('fulltext-on', '', TRUE).';fulltext-off:' |
|
93
|
|
|
.$this->pi_getLL('fulltext-off', '', TRUE).'"> </a>'; |
|
94
|
|
|
} else { |
|
95
|
|
|
$markerArray['###FULLTEXT_SELECT###'] = '<span class="no-fulltext">' . $this->pi_getLL('fulltext-not-available', '', TRUE) . '</span>'; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
$content .= $this->cObj->substituteMarkerArray($this->template, $markerArray); |
|
99
|
|
|
|
|
100
|
|
|
return $this->pi_wrapInBaseClass($content); |
|
101
|
|
|
|
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
} |
|
105
|
|
|
|