Merge branch 'master' into fix-solarium-upgrade

This commit is contained in:
Sebastian Meyer 2020-12-28 11:03:59 +01:00 committed by GitHub
commit 11819891d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 311 additions and 26 deletions

View File

@ -89,6 +89,7 @@ class PageView extends \Kitodo\Dlf\Common\AbstractPlugin
'Resources/Public/Javascript/PageView/AnnotationParser.js',
'Resources/Public/Javascript/PageView/AnnotationControl.js',
'Resources/Public/Javascript/PageView/ImageManipulationControl.js',
'Resources/Public/Javascript/PageView/FulltextDownloadControl.js',
'Resources/Public/Javascript/PageView/FulltextControl.js',
'Resources/Public/Javascript/PageView/FullTextUtility.js',
'Resources/Public/Javascript/PageView/PageView.js'

View File

@ -0,0 +1,86 @@
<?php
/**
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
* This file is part of the Kitodo and TYPO3 projects.
*
* @license GNU General Public License version 3 or later.
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/
namespace Kitodo\Dlf\Plugin\Tools;
use Kitodo\Dlf\Common\Helper;
/**
* Fulltext Download tool for the plugin 'Toolbox' of the 'dlf' extension
*
* @author Beatrycze Volk <beatrycze.volk@slub-dresden.de>
* @package TYPO3
* @subpackage dlf
* @access public
*/
class FulltextDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin
{
public $scriptRelPath = 'Classes/Plugin/Tools/FulltextDownloadTool.php';
/**
* The main method of the PlugIn
*
* @access public
*
* @param string $content: The PlugIn content
* @param array $conf: The PlugIn configuration
*
* @return string The content that is displayed on the website
*/
public function main($content, $conf)
{
$this->init($conf);
// Merge configuration with conf array of toolbox.
if (!empty($this->cObj->data['conf'])) {
$this->conf = Helper::mergeRecursiveWithOverrule($this->cObj->data['conf'], $this->conf);
}
// Load current document.
$this->loadDocument();
if (
$this->doc === null
|| $this->doc->numPages < 1
|| empty($this->conf['fileGrpFulltext'])
) {
// Quit without doing anything if required variables are not set.
return $content;
} else {
if (!empty($this->piVars['logicalPage'])) {
$this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']);
// The logical page parameter should not appear again
unset($this->piVars['logicalPage']);
}
// Set default values if not set.
// $this->piVars['page'] may be integer or string (physical structure @ID)
if (
(int) $this->piVars['page'] > 0
|| empty($this->piVars['page'])
) {
$this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1);
} else {
$this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure);
}
$this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
}
// Load template file.
$this->getTemplate();
// Get text download.
$fullTextFile = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpFulltext']];
if (!empty($fullTextFile)) {
$markerArray['###FULLTEXT_DOWNLOAD###'] = '<a href="#" id="tx-dlf-tools-fulltextdownload" title="' . htmlspecialchars($this->pi_getLL('download-current-page', '')) . '">' . htmlspecialchars($this->pi_getLL('download-current-page', '')) . '</a>';
} else {
$markerArray['###FULLTEXT_DOWNLOAD###'] = '<span class="no-fulltext">' . htmlspecialchars($this->pi_getLL('fulltext-not-available', '')) . '</span>';
}
$content .= $this->templateService->substituteMarkerArray($this->template, $markerArray);
return $this->pi_wrapInBaseClass($content);
}
}

View File

@ -75,7 +75,7 @@ class FulltextTool extends \Kitodo\Dlf\Common\AbstractPlugin
$this->getTemplate();
$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:' . htmlspecialchars($this->pi_getLL('fulltext-on', '')) . ';fulltext-off:' . htmlspecialchars($this->pi_getLL('fulltext-off', '')) . '">&nbsp;</a>';
$markerArray['###FULLTEXT_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-fulltext" title="" data-dic="fulltext:' . htmlspecialchars($this->pi_getLL('fulltext', '')) . ';fulltext-on:' . htmlspecialchars($this->pi_getLL('fulltext-on', '')) . ';fulltext-off:' . htmlspecialchars($this->pi_getLL('fulltext-off', '')) . ';launch-state:' . $this->conf['launchState'] .'">&nbsp;</a>';
} else {
$markerArray['###FULLTEXT_SELECT###'] = '<span class="no-fulltext">' . htmlspecialchars($this->pi_getLL('fulltext-not-available', '')) . '</span>';
}

View File

@ -35,7 +35,7 @@ mod.wizards.newContentElement.wizardItems {
description = LLL:EXT:dlf/Resources/Private/Language/Collection.xml:tt_content.plugin.description
tt_content_defValues {
CType = list
list_type = dlf_calendar
list_type = dlf_collection
}
}
tx_dlf_feeds {
@ -47,6 +47,15 @@ mod.wizards.newContentElement.wizardItems {
list_type = dlf_feeds
}
}
tx_dlf_listview {
iconIdentifier = tx-dlf-listview
title = LLL:EXT:dlf/Resources/Private/Language/ListView.xml:tt_content.plugin.title
description = LLL:EXT:dlf/Resources/Private/Language/ListView.xml:tt_content.plugin.description
tt_content_defValues {
CType = list
list_type = dlf_listview
}
}
tx_dlf_metadata {
iconIdentifier = tx-dlf-metadata
title = LLL:EXT:dlf/Resources/Private/Language/Metadata.xml:tt_content.plugin.title

View File

@ -1,5 +1,7 @@
plugin.tx_dlf_annotationtool.templateFile = EXT:dlf/Resources/Private/Templates/AnnotationTool.tmpl
plugin.tx_dlf_fulltexttool.launchState = off
plugin.tx_dlf_fulltexttool.templateFile = EXT:dlf/Resources/Private/Templates/FulltextTool.tmpl
plugin.tx_dlf_fulltextdownloadtool.templateFile = EXT:dlf/Resources/Private/Templates/FulltextDownloadTool.tmpl
plugin.tx_dlf_imagedownloadtool.templateFile = EXT:dlf/Resources/Private/Templates/ImageDownloadTool.tmpl
plugin.tx_dlf_imagemanipulationtool.templateFile = EXT:dlf/Resources/Private/Templates/ImageManipulationTool.tmpl
plugin.tx_dlf_pdfdownloadtool.templateFile = EXT:dlf/Resources/Private/Templates/PdfDownloadTool.tmpl

View File

@ -1009,6 +1009,7 @@ Toolbox
* tx_dlf_imagedownloadtool
* tx_dlf_imagemanipulationtool
* tx_dlf_pdfdownloadtool
* tx_dlf_fulltextdownloadtool
* tx_dlf_searchindocumenttool
- :Property:

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<!--
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
* This file is part of the Kitodo and TYPO3 projects.
*
* @license GNU General Public License version 3 or later.
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
-->
<T3locallang>
<meta type="array">
<type>module</type>
<description>Language labels for tool FulltextDownload</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="download-current-page">Current page (TXT)</label>
<label index="fulltext-not-available">No Fulltext available</label>
</languageKey>
<languageKey index="de" type="array">
<label index="download-current-page">Aktuelle Seite (TXT)</label>
<label index="fulltext-not-available">Keine Volltexte vorhanden</label>
</languageKey>
</data>
</T3locallang>

View File

@ -15,11 +15,13 @@
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="fulltext">Fulltext</label>
<label index="fulltext-on">Activate Fulltext</label>
<label index="fulltext-off">Deactivate Fulltext</label>
<label index="fulltext-not-available">No Fulltext available</label>
</languageKey>
<languageKey index="de" type="array">
<label index="fulltext">Volltext</label>
<label index="fulltext-on">Volltext an</label>
<label index="fulltext-off">Volltext aus</label>
<label index="fulltext-not-available">Keine Volltexte vorhanden</label>

View File

@ -153,6 +153,7 @@
<label index="tx_dlf_mail.name">Name</label>
<label index="tx_dlf_toolbox.fulltexttool">Fulltext</label>
<label index="tx_dlf_toolbox.annotationtool">IIIF Annotations</label>
<label index="tx_dlf_toolbox.fulltextdownloadtool">Fulltext Download</label>
<label index="tx_dlf_toolbox.imagedownloadtool">Image Download</label>
<label index="tx_dlf_toolbox.imagemanipulationtool">Image Manipulation</label>
<label index="tx_dlf_toolbox.pdfdownloadtool">PDF Download</label>
@ -337,6 +338,7 @@
<label index="tx_dlf_mail.name">Name</label>
<label index="tx_dlf_toolbox.fulltexttool">Volltext</label>
<label index="tx_dlf_toolbox.annotationtool">IIIF-Annotationen</label>
<label index="tx_dlf_toolbox.fulltextdownloadtool">Volltext-Download</label>
<label index="tx_dlf_toolbox.imagedownloadtool">Bild-Download</label>
<label index="tx_dlf_toolbox.imagemanipulationtool">Bildbearbeitung</label>
<label index="tx_dlf_toolbox.pdfdownloadtool">PDF-Download</label>

View File

@ -15,6 +15,8 @@
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="tt_content.plugin.title">List View</label>
<label index="tt_content.plugin.description">List View Plugin for Kitodo.Presentation</label>
<label index="tt_content.pi_flexform.sheet_general">Options</label>
<label index="tt_content.pi_flexform.limit">Documents per page</label>
<label index="tt_content.pi_flexform.targetPid">Target page (with "DLF: Page View" plugin)</label>
@ -39,6 +41,8 @@
<label index="hits">%d hits found in %d documents.</label>
</languageKey>
<languageKey index="de" type="array">
<label index="tt_content.plugin.title">Listenansicht</label>
<label index="tt_content.plugin.description">Listenansicht Plugin für Kitodo.Presentation</label>
<label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
<label index="tt_content.pi_flexform.limit">Dokumente pro Seite</label>
<label index="tt_content.pi_flexform.targetPid">Zielseite (mit Plugin "DLF: Seitenansicht")</label>

View File

@ -0,0 +1,12 @@
<!--
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
* This file is part of the Kitodo and TYPO3 projects.
*
* @license GNU General Public License version 3 or later.
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
-->
<!-- ###TEMPLATE### -->
<span class="tx-dlf-tools-fulltextdownload">###FULLTEXT_DOWNLOAD###</span>
<!-- ###TEMPLATE### -->

View File

@ -57,7 +57,7 @@ var dlfViewerFullTextControl = function(map, image, fulltextUrl) {
*/
this.dic = $('#tx-dlf-tools-fulltext').length > 0 && $('#tx-dlf-tools-fulltext').attr('data-dic') ?
dlfUtils.parseDataDic($('#tx-dlf-tools-fulltext')) :
{'fulltext-on':'Activate Fulltext','fulltext-off':'Deactivate Fulltext'};
{'fulltext':'Fulltext', 'fulltext-on':'Activate Fulltext','fulltext-off':'Deactivate Fulltext', 'launch-state':'on'};
/**
* @type {ol.Feature|undefined}
@ -122,23 +122,7 @@ var dlfViewerFullTextControl = function(map, image, fulltextUrl) {
return;
}
// highlight features
if (this.selectedFeature_) {
// remove old clicks
this.layers_.select.getSource().removeFeature(this.selectedFeature_);
}
if (feature) {
// remove hover for preventing an adding of styles
this.layers_.hoverTextblock.getSource().clear();
// add feature
this.layers_.select.getSource().addFeature(feature);
}
this.handleLayersForClick(feature);
this.selectedFeature_ = feature;
@ -177,7 +161,17 @@ var dlfViewerFullTextControl = function(map, image, fulltextUrl) {
this)
};
// add active / deactive behavior in case of click on control
// add active / deactive behavior in case of click on control depending on launch state
if (this.dic['launch-state'] === 'on') {
this.addActiveBehaviourForSwitchOn();
}
if (this.dic['launch-state'] === 'off') {
this.addActiveBehaviourForSwitchOff();
}
};
dlfViewerFullTextControl.prototype.addActiveBehaviourForSwitchOn = function() {
var anchorEl = $('#tx-dlf-tools-fulltext');
if (anchorEl.length > 0){
var toogleFulltext = $.proxy(function(event) {
@ -191,7 +185,6 @@ var dlfViewerFullTextControl = function(map, image, fulltextUrl) {
this.activate();
}, this);
anchorEl.on('click', toogleFulltext);
anchorEl.on('touchstart', toogleFulltext);
}
@ -206,7 +199,47 @@ var dlfViewerFullTextControl = function(map, image, fulltextUrl) {
// activate the fulltext behavior
this.activate(anchorEl);
}
};
dlfViewerFullTextControl.prototype.addActiveBehaviourForSwitchOff = function() {
var anchorEl = $('#tx-dlf-tools-fulltext');
if (anchorEl.length > 0){
var toogleFulltext = $.proxy(function(event) {
event.preventDefault();
this.activate();
}, this);
anchorEl.on('click', toogleFulltext);
anchorEl.on('touchstart', toogleFulltext);
}
// set initial title of fulltext element
$("#tx-dlf-tools-fulltext")
.text(this.dic['fulltext'])
.attr('title', this.dic['fulltext']);
this.activate(anchorEl);
};
/**
* Handle layers for click
* @param {ol.Feature|undefined} feature
*/
dlfViewerFullTextControl.prototype.handleLayersForClick = function(feature) {
// highlight features
if (this.selectedFeature_) {
// remove old clicks
this.layers_.select.getSource().removeFeature(this.selectedFeature_);
}
if (feature) {
// remove hover for preventing an adding of styles
this.layers_.hoverTextblock.getSource().clear();
// add feature
this.layers_.select.getSource().addFeature(feature);
}
};
/**
@ -392,9 +425,13 @@ dlfViewerFullTextControl.prototype.enableFulltextSelect = function() {
// show fulltext container
var className = 'fulltext-visible';
$("#tx-dlf-tools-fulltext").addClass(className)
.text(this.dic['fulltext-off'])
.attr('title', this.dic['fulltext-off']);
$("#tx-dlf-tools-fulltext").addClass(className);
if(this.dic['launch-state'] === 'on') {
$("#tx-dlf-tools-fulltext")
.text(this.dic['fulltext-off'])
.attr('title', this.dic['fulltext-off']);
}
$('#tx-dlf-fulltextselection').addClass(className);
$('#tx-dlf-fulltextselection').show();

View File

@ -0,0 +1,93 @@
var dlfViewerFullTextDownloadControl = function(map, image, fullTextUrl) {
/**
* @private
* @type {ol.Map}
*/
this.map = map;
/**
* @type {Object}
* @private
*/
this.image = image;
/**
* @type {string}
* @private
*/
this.url = fullTextUrl;
// add active / deactive behavior in case of click on control
var element = $('#tx-dlf-tools-fulltextdownload');
if (element.length > 0){
var downloadFullText = $.proxy(function(event) {
event.preventDefault();
this.downloadFullTextFile();
}, this);
element.on('click', downloadFullText);
element.on('touchstart', downloadFullText);
}
};
/**
* Method fetches the fulltext data from the server
*/
dlfViewerFullTextDownloadControl.prototype.downloadFullTextFile = function() {
var clickedElement = $('#tx-dlf-tools-fulltextdownload');
var element = $('<a/>');
element.attr('id', 'downloadFile');
element.attr('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(this.createFullTextFile()));
element.attr('download', 'fulltext.txt');
element.insertAfter(clickedElement);
$('#downloadFile').get(0).click();
$('#downloadFile').remove();
};
/**
* Activate Fulltext Features
*/
dlfViewerFullTextDownloadControl.prototype.createFullTextFile = function() {
var fullTextData = dlfFullTextUtils.fetchFullTextDataFromServer(this.url, this.image);
var features = fullTextData.getTextblocks();
var fileContent = '';
if (features !== undefined) {
for (feature of features) {
var textLines = feature.get('textlines');
for (textLine of textLines) {
fileContent = fileContent.concat(this.appendTextLine(textLine));
}
fileContent = fileContent.concat('\n\n');
}
}
return fileContent;
};
/**
* Append text line
*
* @param {string} textLine
*/
dlfViewerFullTextDownloadControl.prototype.appendTextLine = function(textLine) {
var fileContent = '';
var content = textLine.get('content');
for (item of content) {
var fullText = item.get('fulltext');
var fullTextLines = fullText.split(/\n/g);
for (const [i, fullTextLine] of fullTextLines.entries()) {
fileContent = fileContent.concat(fullTextLine);
if (i < fullTextLines.length - 1) {
fileContent = fileContent.concat('\n');
}
}
}
return fileContent.concat(fileContent);
};

View File

@ -151,14 +151,16 @@ var dlfViewer = function(settings){
*/
dlfViewer.prototype.addCustomControls = function(controlNames) {
var fulltextControl = undefined,
fulltextDownloadControl = undefined,
annotationControl = undefined,
imageManipulationControl = undefined,
images = this.images;
// Adds fulltext behavior only if there is fulltext available and no double page
// Adds fulltext behavior and download only if there is fulltext available and no double page
// behavior is active
if (this.fulltexts[0] !== undefined && this.fulltexts[0].length !== 0 && this.fulltexts[0].url !== '' && this.images.length === 1) {
fulltextControl = new dlfViewerFullTextControl(this.map, this.images[0], this.fulltexts[0].url);
fulltextDownloadControl = new dlfViewerFullTextDownloadControl(this.map, this.images[0], this.fulltexts[0].url);
} else {
$('#tx-dlf-tools-fulltext').remove();
}

View File

@ -140,6 +140,12 @@ plugin.tx_dlf_annotationtool {
}
tt_content.list.20.dlf_annotationtool < plugin.tx_dlf_annotationtool
plugin.tx_dlf_fulltextdownloadtool = USER
plugin.tx_dlf_fulltextdownloadtool {
userFunc = Kitodo\Dlf\Plugin\Tools\FulltextDownloadTool->main
}
tt_content.list.20.dlf_fulltextdownloadtool < plugin.tx_dlf_fulltextdownloadtool
plugin.tx_dlf_imagedownloadtool = USER
plugin.tx_dlf_imagedownloadtool {
userFunc = Kitodo\Dlf\Plugin\Tools\ImageDownloadTool->main
@ -172,6 +178,7 @@ $iconArray = [
'tx-dlf-calendar' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-calendar.svg',
'tx-dlf-collection' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-collection.svg',
'tx-dlf-feeds' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-feeds.svg',
'tx-dlf-listview' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-listview.svg',
'tx-dlf-metadata' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-metadata.svg',
'tx-dlf-navigation' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-navigation.svg',
'tx-dlf-oaipmh' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-oaipmh.svg',
@ -201,6 +208,7 @@ foreach ($iconArray as $key => $value) {
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'] = [];
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_fulltexttool'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.fulltexttool';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_annotationtool'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.annotationtool';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_fulltextdownloadtool'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.fulltextdownloadtool';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_imagedownloadtool'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.imagedownloadtool';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_imagemanipulationtool'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.imagemanipulationtool';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_pdfdownloadtool'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.pdfdownloadtool';