Browse Source

add $tool (boolean) parameter for getTemplate in abstractPlugin class to recognize every tool plugin.

If a tool plugin is given getTemplate returns the tool template instead of the toolbox template from "this->conf".
pull/392/head
Christopher Timm 2 years ago
parent
commit
2307fe94cc
  1. 11
      Classes/Common/AbstractPlugin.php
  2. 5
      Classes/Plugin/Tools/AnnotationTool.php
  3. 5
      Classes/Plugin/Tools/FulltextTool.php
  4. 5
      Classes/Plugin/Tools/ImageDownloadTool.php
  5. 5
      Classes/Plugin/Tools/ImageManipulationTool.php
  6. 5
      Classes/Plugin/Tools/PdfDownloadTool.php

11
Classes/Common/AbstractPlugin.php

@ -64,12 +64,18 @@ abstract class AbstractPlugin extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
*
* @return void
*/
protected function getTemplate($part = '###TEMPLATE###', $directory = '') {
protected function getTemplate($part = '###TEMPLATE###', $directory = '', $tool = false) {
$this->templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class);
if (!empty($this->conf['templateFile'])) {
// Load template file from configuration.
$this->template = $this->templateService->getSubpart($this->cObj->fileResource($this->conf['templateFile']), $part);
if ($tool) {
$templateLocation = 'EXT:'.$this->extKey.'/Resources/Private/Templates/' . Helper::getUnqualifiedClassName(get_class($this)) . '.tmpl';
$this->template = $this->templateService->getSubpart($this->cObj->fileResource($templateLocation), $part);
} else {
$this->template = $this->templateService->getSubpart($this->cObj->fileResource($this->conf['templateFile']), $part);
}
} else {
if (empty($directory)) {
$templateLocation = 'EXT:'.$this->extKey.'/Resources/Private/Templates/' . Helper::getUnqualifiedClassName(get_class($this)) . '.tmpl';
@ -80,6 +86,7 @@ abstract class AbstractPlugin extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
// Load default template file.
$this->template = $this->templateService->getSubpart($this->cObj->fileResource($templateLocation), $part);
}
}
/**

5
Classes/Plugin/Tools/AnnotationTool.php

@ -69,7 +69,7 @@ class AnnotationTool extends AbstractPlugin {
$this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
}
// Load template file.
$this->getTemplate();
$this->getTemplate('###TEMPLATE###', '', true);
$annotationContainers = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['annotationContainers'];
if ($annotationContainers != null && sizeof($annotationContainers)>0) {
$markerArray['###ANNOTATION_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-annotations" title="" data-dic="annotations-on:'
@ -80,6 +80,7 @@ class AnnotationTool extends AbstractPlugin {
$markerArray['###ANNOTATION_SELECT###'] = '<span class="no-annotations">'.$this->pi_getLL('annotations-not-available', '', TRUE).'</span>';
}
$content .= $this->templateService->substituteMarkerArray($this->template, $markerArray);
return $this->pi_wrapInBaseClass($content);
return $content;
// return $this->pi_wrapInBaseClass($content);
}
}

5
Classes/Plugin/Tools/FulltextTool.php

@ -65,7 +65,7 @@ class FulltextTool extends \Kitodo\Dlf\Common\AbstractPlugin {
$this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
}
// Load template file.
$this->getTemplate();
$this->getTemplate('###TEMPLATE###', '', true);
$fullTextFile = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpFulltext']];
if (!empty($fullTextFile)) {
$markerArray['###FULLTEXT_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-fulltext" title="" data-dic="fulltext-on:'.$this->pi_getLL('fulltext-on', '', TRUE).';fulltext-off:'.$this->pi_getLL('fulltext-off', '', TRUE).'">&nbsp;</a>';
@ -73,6 +73,7 @@ class FulltextTool extends \Kitodo\Dlf\Common\AbstractPlugin {
$markerArray['###FULLTEXT_SELECT###'] = '<span class="no-fulltext">'.$this->pi_getLL('fulltext-not-available', '', TRUE).'</span>';
}
$content .= $this->templateService->substituteMarkerArray($this->template, $markerArray);
return $this->pi_wrapInBaseClass($content);
return $content;
// return $this->pi_wrapInBaseClass($content);
}
}

5
Classes/Plugin/Tools/ImageDownloadTool.php

@ -64,13 +64,14 @@ class ImageDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin {
$this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
}
// Load template file.
$this->getTemplate();
$this->getTemplate('###TEMPLATE###', '', true);
// Get left or single page download.
$markerArray['###IMAGE_LEFT###'] = $this->piVars['double'] == 1 ? $this->getImage($this->piVars['page'], $this->pi_getLL('leftPage', '')) : $this->getImage($this->piVars['page'], $this->pi_getLL('singlePage', ''));
// Get right page download.
$markerArray['###IMAGE_RIGHT###'] = $this->piVars['double'] == 1 ? $this->getImage($this->piVars['page'] + 1, $this->pi_getLL('rightPage', '')) : '';
$content .= $this->templateService->substituteMarkerArray($this->template, $markerArray);
return $this->pi_wrapInBaseClass($content);
return $content;
// return $this->pi_wrapInBaseClass($content);
}
/**

5
Classes/Plugin/Tools/ImageManipulationTool.php

@ -41,9 +41,10 @@ class ImageManipulationTool extends \Kitodo\Dlf\Common\AbstractPlugin {
$this->conf = Helper::mergeRecursiveWithOverrule($this->cObj->data['conf'], $this->conf);
}
// Load template file.
$this->getTemplate();
$this->getTemplate('###TEMPLATE###', '', true);
$markerArray['###IMAGEMANIPULATION_SELECT###'] = '<span class="tx-dlf-tools-imagetools" id="tx-dlf-tools-imagetools" data-dic="imagemanipulation-on:'.$this->pi_getLL('imagemanipulation-on', '', TRUE).';imagemanipulation-off:'.$this->pi_getLL('imagemanipulation-off', '', TRUE).';reset:'.$this->pi_getLL('reset', '', TRUE).';saturation:'.$this->pi_getLL('saturation', '', TRUE).';hue:'.$this->pi_getLL('hue', '', TRUE).';contrast:'.$this->pi_getLL('contrast', '', TRUE).';brightness:'.$this->pi_getLL('brightness', '', TRUE).';invert:'.$this->pi_getLL('invert', '', TRUE).'" title="'.$this->pi_getLL('no-support', '', TRUE).'"></span>';
$content .= $this->templateService->substituteMarkerArray($this->template, $markerArray);
return $this->pi_wrapInBaseClass($content);
return $content;
// return $this->pi_wrapInBaseClass($content);
}
}

5
Classes/Plugin/Tools/PdfDownloadTool.php

@ -65,13 +65,14 @@ class PdfDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin {
$this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
}
// Load template file.
$this->getTemplate();
$this->getTemplate('###TEMPLATE###', '', true);
// Get single page downloads.
$markerArray['###PAGE###'] = $this->getPageLink();
// Get work download.
$markerArray['###WORK###'] = $this->getWorkLink();
$content .= $this->templateService->substituteMarkerArray($this->template, $markerArray);
return $this->pi_wrapInBaseClass($content);
return $content;
// return $this->pi_wrapInBaseClass($content);
}
/**

Loading…
Cancel
Save