|
1
|
|
|
<?php |
|
2
|
|
|
namespace Kitodo\Dlf\Plugin\Tools; |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* (c) Kitodo. Key to digital objects e.V. <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* This file is part of the Kitodo and TYPO3 projects. |
|
8
|
|
|
* |
|
9
|
|
|
* @license GNU General Public License version 3 or later. |
|
10
|
|
|
* For the full copyright and license information, please read the |
|
11
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
use Kitodo\Dlf\Common\AbstractPlugin; |
|
15
|
|
|
use Kitodo\Dlf\Common\Helper; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Tool 'Annotation selection' for the plugin 'DLF: Toolbox' of the 'dlf' extension. |
|
19
|
|
|
* Allows the display of IIIF annotations. |
|
20
|
|
|
* |
|
21
|
|
|
* @author Sebastian Meyer <[email protected]> |
|
22
|
|
|
* @author Alexander Bigga <[email protected]> |
|
23
|
|
|
* @author Lutz Helm <[email protected]> |
|
24
|
|
|
* @package TYPO3 |
|
25
|
|
|
* @subpackage dlf |
|
26
|
|
|
* @access public |
|
27
|
|
|
*/ |
|
28
|
|
|
class AnnotationTool extends AbstractPlugin { |
|
29
|
|
|
/** |
|
30
|
|
|
* @access public |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
public $scriptRelPath = 'Classes/Plugin/Tools/AnnotationTool.php'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* The main method of the PlugIn |
|
37
|
|
|
* |
|
38
|
|
|
* @access public |
|
39
|
|
|
* |
|
40
|
|
|
* @param string $content: The PlugIn content |
|
41
|
|
|
* @param array $conf: The PlugIn configuration |
|
42
|
|
|
* |
|
43
|
|
|
* @return string The content that is displayed on the website |
|
44
|
|
|
*/ |
|
45
|
|
|
public function main($content, $conf) { |
|
46
|
|
|
$this->init($conf); |
|
47
|
|
|
// Merge configuration with conf array of toolbox. |
|
48
|
|
|
$this->conf = Helper::mergeRecursiveWithOverrule($this->cObj->data['conf'], $this->conf); |
|
49
|
|
|
// Load current document. |
|
50
|
|
|
$this->loadDocument(); |
|
51
|
|
|
if ($this->doc === NULL || $this->doc->numPages < 1) { |
|
|
|
|
|
|
52
|
|
|
// Quit without doing anything if required variables are not set. |
|
53
|
|
|
return $content; |
|
54
|
|
|
} else { |
|
55
|
|
|
if (!empty($this->piVars['logicalPage'])) { |
|
56
|
|
|
$this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); |
|
57
|
|
|
// The logical page parameter should not appear again |
|
58
|
|
|
unset($this->piVars['logicalPage']); |
|
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
|
|
|
$this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1); |
|
64
|
|
|
} else { |
|
65
|
|
|
$this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure); |
|
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
$this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0); |
|
68
|
|
|
} |
|
69
|
|
|
// Load template file. |
|
70
|
|
|
$this->getTemplate(); |
|
71
|
|
|
$annotationContainers = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['annotationContainers']; |
|
|
|
|
|
|
72
|
|
|
if ($annotationContainers != null && sizeof($annotationContainers)>0) { |
|
73
|
|
|
$markerArray['###ANNOTATION_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-annotations" title="" data-dic="annotations-on:' |
|
|
|
|
|
|
74
|
|
|
.$this->pi_getLL('annotations-on', '', TRUE).';annotations-off:' |
|
75
|
|
|
.$this->pi_getLL('annotations-off', '', TRUE).'"> </a>'; |
|
76
|
|
|
// TODO selector for different motivations |
|
77
|
|
|
} else { |
|
78
|
|
|
$markerArray['###ANNOTATION_SELECT###'] = '<span class="no-annotations">'.$this->pi_getLL('annotations-not-available', '', TRUE).'</span>'; |
|
79
|
|
|
} |
|
80
|
|
|
$content .= $this->cObj->substituteMarkerArray($this->template, $markerArray); |
|
|
|
|
|
|
81
|
|
|
return $this->pi_wrapInBaseClass($content); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|