Merge pull request #592 from sebastian-meyer/allow-multiple-filegrps

Allow multiple file groups of any type
This commit is contained in:
Alexander Bigga 2021-03-24 11:39:54 +01:00 committed by GitHub
커밋 4d9a1ffec0
No known key found for this signature in database
GPG 키 ID: 4AEE18F83AFDEB23
15개의 변경된 파일278개의 추가작업 그리고 240개의 파일을 삭제

파일 보기

@ -662,25 +662,31 @@ abstract class Document
$this->_getPhysicalStructure();
// ... and extension configuration.
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
$fileGrpsFulltext = GeneralUtility::trimExplode(',', $extConf['fileGrpFulltext']);
if (!empty($this->physicalStructureInfo[$id])) {
// Get fulltext file.
$file = GeneralUtility::getUrl($this->getFileLocation($this->physicalStructureInfo[$id]['files'][$extConf['fileGrpFulltext']]));
if ($file !== false) {
// Turn off libxml's error logging.
$libxmlErrors = libxml_use_internal_errors(true);
// Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept.
$previousValueOfEntityLoader = libxml_disable_entity_loader(true);
// Load XML from file.
$rawTextXml = simplexml_load_string($file);
// Reset entity loader setting.
libxml_disable_entity_loader($previousValueOfEntityLoader);
// Reset libxml's error logging.
libxml_use_internal_errors($libxmlErrors);
// Get the root element's name as text format.
$textFormat = strtoupper($rawTextXml->getName());
} else {
Helper::devLog('Couln\'t load fulltext file for structure node @ID "' . $id . '"', DEVLOG_SEVERITY_WARNING);
return $rawText;
while ($fileGrpFulltext = array_shift($fileGrpsFulltext)) {
if (!empty($this->physicalStructureInfo[$id]['files'][$fileGrpFulltext])) {
// Get fulltext file.
$file = GeneralUtility::getUrl($this->getFileLocation($this->physicalStructureInfo[$id]['files'][$fileGrpFulltext]));
if ($file !== false) {
// Turn off libxml's error logging.
$libxmlErrors = libxml_use_internal_errors(true);
// Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept.
$previousValueOfEntityLoader = libxml_disable_entity_loader(true);
// Load XML from file.
$rawTextXml = simplexml_load_string($file);
// Reset entity loader setting.
libxml_disable_entity_loader($previousValueOfEntityLoader);
// Reset libxml's error logging.
libxml_use_internal_errors($libxmlErrors);
// Get the root element's name as text format.
$textFormat = strtoupper($rawTextXml->getName());
} else {
Helper::devLog('Couln\'t load fulltext file for structure node @ID "' . $id . '"', DEVLOG_SEVERITY_WARNING);
return $rawText;
}
break;
}
}
} else {
Helper::devLog('Invalid structure node @ID "' . $id . '"', DEVLOG_SEVERITY_WARNING);
@ -696,7 +702,7 @@ abstract class Document
// Get the raw text from class.
if (
class_exists($class)
&& ($obj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($class)) instanceof FulltextInterface
&& ($obj = GeneralUtility::makeInstance($class)) instanceof FulltextInterface
) {
$rawText = $obj->getRawText($rawTextXml);
$this->rawTextArray[$id] = $rawText;

파일 보기

@ -198,12 +198,12 @@ final class IiifManifest extends Document
}
/**
* True if getUseGroups() has been called and $this-useGrps is loaded
* True if getUseGroups() has been called and $this->useGrps is loaded
*
* @var bool
* @access protected
*/
protected $useGrpsLoaded;
protected $useGrpsLoaded = false;
/**
* Holds the configured useGrps as array.
@ -211,7 +211,7 @@ final class IiifManifest extends Document
* @var array
* @access protected
*/
protected $useGrps;
protected $useGrps = [];
/**
* IiifManifest also populates the physical stucture array entries for matching
@ -230,21 +230,22 @@ final class IiifManifest extends Document
if (!$this->useGrpsLoaded) {
// Get configured USE attributes.
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
if (!empty($extConf['fileGrps'])) {
$this->useGrps['fileGrps'] = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $extConf['fileGrps']);
if (!empty($extConf['fileGrpImages'])) {
$this->useGrps['fileGrpImages'] = GeneralUtility::trimExplode(',', $extConf['fileGrpImages']);
}
if (!empty($extConf['fileGrpThumbs'])) {
$this->useGrps['fileGrpThumbs'] = $extConf['fileGrpThumbs'];
$this->useGrps['fileGrpThumbs'] = GeneralUtility::trimExplode(',', $extConf['fileGrpThumbs']);
}
if (!empty($extConf['fileGrpDownload'])) {
$this->useGrps['fileGrpDownload'] = $extConf['fileGrpDownload'];
$this->useGrps['fileGrpDownload'] = GeneralUtility::trimExplode(',', $extConf['fileGrpDownload']);
}
if (!empty($extConf['fileGrpFulltext'])) {
$this->useGrps['fileGrpFulltext'] = $extConf['fileGrpFulltext'];
$this->useGrps['fileGrpFulltext'] = GeneralUtility::trimExplode(',', $extConf['fileGrpFulltext']);
}
if (!empty($extConf['fileGrpAudio'])) {
$this->useGrps['fileGrpAudio'] = $extConf['fileGrpAudio'];
$this->useGrps['fileGrpAudio'] = GeneralUtility::trimExplode(',', $extConf['fileGrpAudio']);
}
$this->useGrpsLoaded = true;
}
return array_key_exists($use, $this->useGrps) ? $this->useGrps[$use] : [];
}
@ -272,22 +273,21 @@ final class IiifManifest extends Document
$fileUseDownload = $this->getUseGroups('fileGrpDownload');
$fileUseFulltext = $this->getUseGroups('fileGrpFulltext');
$fileUseThumbs = $this->getUseGroups('fileGrpThumbs');
$fileUses = $this->getUseGroups('fileGrps');
if (isset($fileUseDownload)) {
$fileUses = $this->getUseGroups('fileGrpImages');
if (!empty($fileUseDownload)) {
$docPdfRendering = $this->iiif->getRenderingUrlsForFormat('application/pdf');
if (!empty($docPdfRendering)) {
$this->physicalStructureInfo[$physSeq[0]]['files'][$fileUseDownload] = $docPdfRendering[0];
$this->physicalStructureInfo[$physSeq[0]]['files'][$fileUseDownload[0]] = $docPdfRendering[0];
}
}
if (isset($fileUseFulltext)) {
$iiifAlto = $this->iiif->getSeeAlsoUrlsForFormat("application/alto+xml");
if (!empty($fileUseFulltext)) {
$iiifAlto = $this->iiif->getSeeAlsoUrlsForFormat('application/alto+xml');
if (empty($iiifAlto)) {
$iiifAlto = $this->iiif->getSeeAlsoUrlsForProfile("http://www.loc.gov/standards/alto/", true);
$iiifAlto = $this->iiif->getSeeAlsoUrlsForProfile('http://www.loc.gov/standards/alto/', true);
}
if (!empty($iiifAlto)) {
// TODO use multiple possible alto files?
$this->mimeTypes[$iiifAlto[0]] = "application/alto+xml";
$this->physicalStructureInfo[$physSeq[0]]['files'][$fileUseFulltext] = $iiifAlto[0];
$this->mimeTypes[$iiifAlto[0]] = 'application/alto+xml';
$this->physicalStructureInfo[$physSeq[0]]['files'][$fileUseFulltext[0]] = $iiifAlto[0];
$this->hasFulltext = true;
$this->hasFulltextSet = true;
}
@ -299,17 +299,11 @@ final class IiifManifest extends Document
$canvasOrder++;
$thumbnailUrl = $canvas->getThumbnailUrl();
// put thumbnails in thumbnail filegroup
if (isset($thumbnailUrl)) {
$this->physicalStructureInfo[$physSeq[0]]['files'][$fileUseThumbs] = $thumbnailUrl;
}
$image = $canvas->getImageAnnotations()[0];
// put images in all non specific filegroups
if (isset($fileUses)) {
foreach ($fileUses as $fileUse) {
if ($image->getBody() != null && $image->getBody() instanceof ContentResourceInterface) {
$this->physicalStructureInfo[$physSeq[0]]['files'][$fileUse] = $image->getBody()->getId();
}
}
if (
!empty($thumbnailUrl)
&& empty($this->physicalStructureInfo[$physSeq[0]]['files'][$fileUseThumbs[0]])
) {
$this->physicalStructureInfo[$physSeq[0]]['files'][$fileUseThumbs[0]] = $thumbnailUrl;
}
// populate structural metadata info
$elements[$canvasOrder] = $canvas->getId();
@ -323,7 +317,6 @@ final class IiifManifest extends Document
$this->physicalStructureInfo[$elements[$canvasOrder]]['annotationContainers'] = null;
if (!empty($canvas->getPossibleTextAnnotationContainers(Motivation::PAINTING))) {
$this->physicalStructureInfo[$elements[$canvasOrder]]['annotationContainers'] = [];
$this->physicalStructureInfo[$physSeq[0]]['annotationContainers'] = [];
foreach ($canvas->getPossibleTextAnnotationContainers(Motivation::PAINTING) as $annotationContainer) {
$this->physicalStructureInfo[$elements[$canvasOrder]]['annotationContainers'][] = $annotationContainer->getId();
if ($extConf['indexAnnotations']) {
@ -332,33 +325,33 @@ final class IiifManifest extends Document
}
}
}
if (isset($fileUseFulltext)) {
$alto = $canvas->getSeeAlsoUrlsForFormat("application/alto+xml");
if (!empty($fileUseFulltext)) {
$alto = $canvas->getSeeAlsoUrlsForFormat('application/alto+xml');
if (empty($alto)) {
$alto = $canvas->getSeeAlsoUrlsForProfile("http://www.loc.gov/standards/alto/", true);
$alto = $canvas->getSeeAlsoUrlsForProfile('http://www.loc.gov/standards/alto/', true);
}
if (!empty($alto)) {
// TODO use all possible alto files?
$this->mimeTypes[$alto[0]] = "application/alto+xml";
$this->physicalStructureInfo[$elements[$canvasOrder]]['files'][$fileUseFulltext] = $alto[0];
$this->mimeTypes[$alto[0]] = 'application/alto+xml';
$this->physicalStructureInfo[$elements[$canvasOrder]]['files'][$fileUseFulltext[0]] = $alto[0];
$this->hasFulltext = true;
$this->hasFulltextSet = true;
}
}
if (isset($fileUses)) {
if (!empty($fileUses)) {
$image = $canvas->getImageAnnotations()[0];
foreach ($fileUses as $fileUse) {
if ($image->getBody() != null && $image->getBody() instanceof ContentResourceInterface) {
if ($image->getBody() !== null && $image->getBody() instanceof ContentResourceInterface) {
$this->physicalStructureInfo[$elements[$canvasOrder]]['files'][$fileUse] = $image->getBody()->getId();
}
}
}
if (isset($thumbnailUrl)) {
if (!empty($thumbnailUrl)) {
$this->physicalStructureInfo[$elements[$canvasOrder]]['files'][$fileUseThumbs] = $thumbnailUrl;
}
if (isset($fileUseDownload)) {
if (!empty($fileUseDownload)) {
$pdfRenderingUrls = $canvas->getRenderingUrlsForFormat('application/pdf');
if (!empty($pdfRenderingUrls)) {
$this->physicalStructureInfo[$elements[$canvasOrder]]['files'][$fileUseDownload] = $pdfRenderingUrls[0];
$this->physicalStructureInfo[$elements[$canvasOrder]]['files'][$fileUseDownload[0]] = $pdfRenderingUrls[0];
}
}
}
@ -514,7 +507,7 @@ final class IiifManifest extends Document
$details['points'] = $startCanvasIndex + 1;
}
}
$useGroups = $this->getUseGroups('fileGrps');
$useGroups = $this->getUseGroups('fileGrpImages');
if (is_string($useGroups)) {
$useGroups = [$useGroups];
}
@ -807,9 +800,13 @@ final class IiifManifest extends Document
$this->_getPhysicalStructure();
// ... and extension configuration.
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
$fileGrpsFulltext = GeneralUtility::trimExplode(',', $extConf['fileGrpFulltext']);
if (!empty($this->physicalStructureInfo[$id])) {
if (!empty($this->physicalStructureInfo[$id]['files'][$extConf['fileGrpFulltext']])) {
$rawText = parent::getRawTextFromXml($id);
while ($fileGrpFulltext = array_shift($fileGrpsFulltext)) {
if (!empty($this->physicalStructureInfo[$id]['files'][$fileGrpFulltext])) {
$rawText = parent::getRawTextFromXml($id);
break;
}
}
if ($extConf['indexAnnotations'] == 1) {
$iiifResource = $this->iiif->getContainedResourceById($id);

파일 보기

@ -13,9 +13,11 @@
namespace Kitodo\Dlf\Common;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use Ubl\Iiif\Tools\IiifHelper;
use TYPO3\CMS\Core\Utility\MathUtility;
use Ubl\Iiif\Presentation\Common\Model\Resources\AnnotationContainerInterface;
use Ubl\Iiif\Tools\IiifHelper;
/**
* Indexer class for the 'dlf' extension
@ -154,7 +156,7 @@ class Indexer
Helper::addMessage(
htmlspecialchars(sprintf(Helper::getMessage('flash.documentIndexed'), $resArray['title'], $doc->uid)),
Helper::getMessage('flash.done', true),
\TYPO3\CMS\Core\Messaging\FlashMessage::OK,
FlashMessage::OK,
true,
'core.template.flashMessages'
);
@ -162,7 +164,7 @@ class Indexer
Helper::addMessage(
htmlspecialchars(sprintf(Helper::getMessage('flash.documentNotIndexed'), $resArray['title'], $doc->uid)),
Helper::getMessage('flash.error', true),
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR,
FlashMessage::ERROR,
true,
'core.template.flashMessages'
);
@ -174,7 +176,7 @@ class Indexer
Helper::addMessage(
Helper::getMessage('flash.solrException', true) . '<br />' . htmlspecialchars($e->getMessage()),
Helper::getMessage('flash.error', true),
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR,
FlashMessage::ERROR,
true,
'core.template.flashMessages'
);
@ -187,7 +189,7 @@ class Indexer
Helper::addMessage(
Helper::getMessage('flash.solrNoConnection', true),
Helper::getMessage('flash.warning', true),
\TYPO3\CMS\Core\Messaging\FlashMessage::WARNING,
FlashMessage::WARNING,
true,
'core.template.flashMessages'
);
@ -325,7 +327,7 @@ class Indexer
$solrDoc->setField('id', $doc->uid . $logicalUnit['id']);
$solrDoc->setField('uid', $doc->uid);
$solrDoc->setField('pid', $doc->pid);
if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($logicalUnit['points'])) {
if (MathUtility::canBeInterpretedAsInteger($logicalUnit['points'])) {
$solrDoc->setField('page', $logicalUnit['points']);
}
if ($logicalUnit['id'] == $doc->toplevelId) {
@ -393,7 +395,7 @@ class Indexer
Helper::addMessage(
Helper::getMessage('flash.solrException', true) . '<br />' . htmlspecialchars($e->getMessage()),
Helper::getMessage('flash.error', true),
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR,
FlashMessage::ERROR,
true,
'core.template.flashMessages'
);
@ -428,59 +430,12 @@ class Indexer
*/
protected static function processPhysical(Document &$doc, $page, array $physicalUnit)
{
$errors = 0;
// Read extension configuration.
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
if (
!empty($physicalUnit['files'][$extConf['fileGrpFulltext']])
|| !empty($annotationContainerIds = $physicalUnit['annotationContainers'])
$doc->hasFulltext
&& $fulltext = $doc->getRawText($physicalUnit['id'])
) {
if (!empty($physicalUnit['files'][$extConf['fileGrpFulltext']])) {
$file = $doc->getFileLocation($physicalUnit['files'][$extConf['fileGrpFulltext']]);
// Load XML file.
if (GeneralUtility::isValidUrl($file)) {
// Set user-agent to identify self when fetching XML data.
if (!empty($extConf['useragent'])) {
@ini_set('user_agent', $extConf['useragent']);
}
$fileResource = GeneralUtility::getUrl($file);
if ($fileResource !== false) {
// Turn off libxml's error logging.
$libxmlErrors = libxml_use_internal_errors(true);
// disable entity loading
$previousValueOfEntityLoader = libxml_disable_entity_loader(true);
// Load XML from file.
$xml = simplexml_load_string($fileResource);
// reset entity loader setting
libxml_disable_entity_loader($previousValueOfEntityLoader);
// Reset libxml's error logging.
libxml_use_internal_errors($libxmlErrors);
if ($xml === false) {
return 1;
}
} else {
return 1;
}
} else {
return 1;
}
}
if (isset($annotationContainerIds) && !empty($annotationContainerIds)) {
foreach ($annotationContainerIds as $annotationContainerId) {
if (!empty($extConf['useragent'])) {
@ini_set('user_agent', $extConf['useragent']);
}
$fileResource = GeneralUtility::getUrl($annotationContainerId);
if ($fileResource !== false) {
$annotationContainer = IiifHelper::loadIiifResource($fileResource);
if (!($annotationContainer instanceof AnnotationContainerInterface)) {
return 1;
}
} else {
return 1;
}
}
}
// Read extension configuration.
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
// Create new Solr document.
$updateQuery = self::$solr->service->createUpdate();
$solrDoc = $updateQuery->createDocument();
@ -489,8 +444,12 @@ class Indexer
$solrDoc->setField('uid', $doc->uid);
$solrDoc->setField('pid', $doc->pid);
$solrDoc->setField('page', $page);
if (!empty($physicalUnit['files'][$extConf['fileGrpThumbs']])) {
$solrDoc->setField('thumbnail', $doc->getFileLocation($physicalUnit['files'][$extConf['fileGrpThumbs']]));
$fileGrpsThumb = GeneralUtility::trimExplode(',', $extConf['fileGrpThumbs']);
while ($fileGrpThumb = array_shift($fileGrpsThumb)) {
if (!empty($physicalUnit['files'][$fileGrpThumb])) {
$solrDoc->setField('thumbnail', $doc->getFileLocation($physicalUnit['files'][$fileGrpThumb]));
break;
}
}
$solrDoc->setField('partof', $doc->parentId);
$solrDoc->setField('root', $doc->rootId);
@ -498,7 +457,7 @@ class Indexer
$solrDoc->setField('toplevel', false);
$solrDoc->setField('type', $physicalUnit['type'], self::$fields['fieldboost']['type']);
$solrDoc->setField('collection', $doc->metadataArray[$doc->toplevelId]['collection']);
$solrDoc->setField('fulltext', htmlspecialchars($doc->getRawText($physicalUnit['id'])));
$solrDoc->setField('fulltext', htmlspecialchars($fulltext));
// Add faceting information to physical sub-elements if applicable.
foreach ($doc->metadataArray[$doc->toplevelId] as $index_name => $data) {
if (
@ -534,7 +493,7 @@ class Indexer
Helper::addMessage(
Helper::getMessage('flash.solrException', true) . '<br />' . htmlspecialchars($e->getMessage()),
Helper::getMessage('flash.error', true),
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR,
FlashMessage::ERROR,
true,
'core.template.flashMessages'
);
@ -542,7 +501,7 @@ class Indexer
return 1;
}
}
return $errors;
return 0;
}
/**

파일 보기

@ -93,7 +93,7 @@ final class MetsDocument extends Document
protected $fileGrps = [];
/**
* Are the file groups loaded?
* Are the image file groups loaded?
* @see $fileGrps
*
* @var bool
@ -312,19 +312,27 @@ final class MetsDocument extends Document
) {
// Link logical structure to the first corresponding physical page/track.
$details['points'] = max(intval(array_search($this->smLinks['l2p'][$details['id']][0], $this->physicalStructure, true)), 1);
if (!empty($this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['files'][$extConf['fileGrpThumbs']])) {
$details['thumbnailId'] = $this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['files'][$extConf['fileGrpThumbs']];
$fileGrpsThumb = GeneralUtility::trimExplode(',', $extConf['fileGrpThumbs']);
while ($fileGrpThumb = array_shift($fileGrpsThumb)) {
if (!empty($this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['files'][$fileGrpThumb])) {
$details['thumbnailId'] = $this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['files'][$fileGrpThumb];
break;
}
}
// Get page/track number of the first page/track related to this structure element.
$details['pagination'] = $this->physicalStructureInfo[$this->smLinks['l2p'][$details['id']][0]]['orderlabel'];
} elseif ($details['id'] == $this->_getToplevelId()) {
// Point to self if this is the toplevel structure.
$details['points'] = 1;
if (
!empty($this->physicalStructure)
&& !empty($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$extConf['fileGrpThumbs']])
) {
$details['thumbnailId'] = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$extConf['fileGrpThumbs']];
$fileGrpsThumb = GeneralUtility::trimExplode(',', $extConf['fileGrpThumbs']);
while ($fileGrpThumb = array_shift($fileGrpsThumb)) {
if (
!empty($this->physicalStructure)
&& !empty($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb])
) {
$details['thumbnailId'] = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb];
break;
}
}
}
// Get the files this structure element is pointing at.
@ -432,7 +440,7 @@ final class MetsDocument extends Document
// Get the metadata from class.
if (
class_exists($class)
&& ($obj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($class)) instanceof MetadataInterface
&& ($obj = GeneralUtility::makeInstance($class)) instanceof MetadataInterface
) {
$obj->extractMetadata($this->dmdSec[$dmdId]['xml'], $metadata);
} else {
@ -839,18 +847,18 @@ final class MetsDocument extends Document
if (!$this->fileGrpsLoaded) {
// Get configured USE attributes.
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
$useGrps = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $extConf['fileGrps']);
$useGrps = GeneralUtility::trimExplode(',', $extConf['fileGrpImages']);
if (!empty($extConf['fileGrpThumbs'])) {
$useGrps[] = $extConf['fileGrpThumbs'];
$useGrps = array_merge($useGrps, GeneralUtility::trimExplode(',', $extConf['fileGrpThumbs']));
}
if (!empty($extConf['fileGrpDownload'])) {
$useGrps[] = $extConf['fileGrpDownload'];
$useGrps = array_merge($useGrps, GeneralUtility::trimExplode(',', $extConf['fileGrpDownload']));
}
if (!empty($extConf['fileGrpFulltext'])) {
$useGrps[] = $extConf['fileGrpFulltext'];
$useGrps = array_merge($useGrps, GeneralUtility::trimExplode(',', $extConf['fileGrpFulltext']));
}
if (!empty($extConf['fileGrpAudio'])) {
$useGrps[] = $extConf['fileGrpAudio'];
$useGrps = array_merge($useGrps, GeneralUtility::trimExplode(',', $extConf['fileGrpAudio']));
}
// Get all file groups.
$fileGrps = $this->mets->xpath('./mets:fileSec/mets:fileGrp');
@ -867,7 +875,7 @@ final class MetsDocument extends Document
// Are there any fulltext files available?
if (
!empty($extConf['fileGrpFulltext'])
&& in_array($extConf['fileGrpFulltext'], $this->fileGrps)
&& array_intersect(GeneralUtility::trimExplode(',', $extConf['fileGrpFulltext']), $this->fileGrps) !== []
) {
$this->hasFulltext = true;
}
@ -1042,13 +1050,19 @@ final class MetsDocument extends Document
// Load smLinks.
$this->_getSmLinks();
// Get thumbnail location.
if (
$this->_getPhysicalStructure()
&& !empty($this->smLinks['l2p'][$strctId])
) {
$this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->smLinks['l2p'][$strctId][0]]['files'][$extConf['fileGrpThumbs']]);
} else {
$this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$extConf['fileGrpThumbs']]);
$fileGrpsThumb = GeneralUtility::trimExplode(',', $extConf['fileGrpThumbs']);
while ($fileGrpThumb = array_shift($fileGrpsThumb)) {
if (
$this->_getPhysicalStructure()
&& !empty($this->smLinks['l2p'][$strctId])
&& !empty($this->physicalStructureInfo[$this->smLinks['l2p'][$strctId][0]]['files'][$fileGrpThumb])
) {
$this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->smLinks['l2p'][$strctId][0]]['files'][$fileGrpThumb]);
break;
} elseif (!empty($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb])) {
$this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb]);
break;
}
}
} else {
Helper::devLog('No structure of type "' . $metadata['type'][0] . '" found in database', DEVLOG_SEVERITY_ERROR);

파일 보기

@ -12,6 +12,12 @@
namespace Kitodo\Dlf\Plugin;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/**
* Plugin AudioPlayer for the 'dlf' extension
*
@ -65,24 +71,24 @@ class AudioPlayer extends \Kitodo\Dlf\Common\AbstractPlugin
url: "' . $this->audio['url'] . '"
},
parentElId: "tx-dlf-audio",
swfPath: "' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extKey)) . 'Resources/Public/Javascript/jPlayer/jquery.jplayer.swf"
swfPath: "' . PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)) . 'Resources/Public/Javascript/jPlayer/jquery.jplayer.swf"
});
});
';
// Add Javascript to page footer if not configured otherwise.
if (empty($this->conf['addJStoBody'])) {
$pageRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
foreach ($cssFiles as $cssFile) {
$pageRenderer->addCssFile(\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extKey)) . $cssFile);
$pageRenderer->addCssFile(PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)) . $cssFile);
}
$pageRenderer->addCssInlineBlock('kitodo-audioplayer-configuration', $inlineCSS);
foreach ($jsFiles as $jsFile) {
$pageRenderer->addJsFooterFile(\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extKey)) . $jsFile);
$pageRenderer->addJsFooterFile(PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)) . $jsFile);
}
$pageRenderer->addJsFooterInlineCode('kitodo-audioplayer-configuration', $audioplayerConfiguration);
} else {
foreach ($jsFiles as $jsFile) {
$markerArray .= '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extKey)) . $jsFile . '"></script>' . "\n";
$markerArray .= '<script type="text/javascript" src="' . PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)) . $jsFile . '"></script>' . "\n";
}
$markerArray .= '
<script type="text/javascript">
@ -123,18 +129,24 @@ class AudioPlayer extends \Kitodo\Dlf\Common\AbstractPlugin
(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);
$this->piVars['page'] = 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);
$this->piVars['double'] = MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
}
// Check if there are any audio files available.
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpAudio']])) {
// Get audio data.
$this->audio['url'] = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpAudio']]);
$this->audio['label'] = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['label'];
$this->audio['mimetype'] = $this->doc->getFileMimeType($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpAudio']]);
$fileGrpsAudio = GeneralUtility::trimExplode(',', $this->conf['fileGrpAudio']);
while ($fileGrpAudio = array_shift($fileGrpsAudio)) {
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$fileGrpAudio])) {
// Get audio data.
$this->audio['url'] = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$fileGrpAudio]);
$this->audio['label'] = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['label'];
$this->audio['mimetype'] = $this->doc->getFileMimeType($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$fileGrpAudio]);
break;
}
}
if (!empty($this->audio)) {
// Add jPlayer javascript.
$markerArray['###JAVASCRIPT###'] = $this->addPlayerJS();
} else {

파일 보기

@ -13,6 +13,10 @@
namespace Kitodo\Dlf\Plugin;
use Kitodo\Dlf\Common\Helper;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/**
* Plugin 'Page Grid' for the 'dlf' extension
@ -50,12 +54,18 @@ class PageGrid extends \Kitodo\Dlf\Common\AbstractPlugin
// Set pagination.
$markerArray['###PAGINATION###'] = htmlspecialchars($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['orderlabel']);
// Get thumbnail or placeholder.
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['files'][$this->conf['fileGrpThumbs']])) {
$thumbnailFile = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['files'][$this->conf['fileGrpThumbs']]);
$fileGrpsThumb = GeneralUtility::trimExplode(',', $this->conf['fileGrpThumbs']);
if (array_intersect($fileGrpsThumb, array_keys($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['files'])) !== [] ) {
while ($fileGrpThumb = array_shift($fileGrpsThumb)) {
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['files'][$fileGrpThumb])) {
$thumbnailFile = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$number]]['files'][$fileGrpThumb]);
break;
}
}
} elseif (!empty($this->conf['placeholder'])) {
$thumbnailFile = $GLOBALS['TSFE']->tmpl->getFileName($this->conf['placeholder']);
} else {
$thumbnailFile = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extKey)) . 'Resources/Public/Images/PageGridPlaceholder.jpg';
$thumbnailFile = PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)) . 'Resources/Public/Images/PageGridPlaceholder.jpg';
}
$thumbnail = '<img alt="' . $markerArray['###PAGINATION###'] . '" src="' . $thumbnailFile . '" />';
// Get new plugin variables for typolink.
@ -69,7 +79,7 @@ class PageGrid extends \Kitodo\Dlf\Common\AbstractPlugin
'parameter' => $this->conf['targetPid'],
'forceAbsoluteUrl' => !empty($this->conf['forceAbsoluteUrl']) ? 1 : 0,
'forceAbsoluteUrl.' => ['scheme' => !empty($this->conf['forceAbsoluteUrl']) && !empty($this->conf['forceAbsoluteUrlHttps']) ? 'https' : 'http'],
'additionalParams' => \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl($this->prefixId, $piVars, '', true, false),
'additionalParams' => GeneralUtility::implodeArrayForUrl($this->prefixId, $piVars, '', true, false),
'title' => $markerArray['###PAGINATION###']
];
$markerArray['###THUMBNAIL###'] = $this->cObj->typoLink($thumbnail, $linkConf);
@ -147,7 +157,7 @@ class PageGrid extends \Kitodo\Dlf\Common\AbstractPlugin
return $content;
} else {
// Set default values for page if not set.
$this->piVars['pointer'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['pointer'], 0, $this->doc->numPages, 0);
$this->piVars['pointer'] = MathUtility::forceIntegerInRange($this->piVars['pointer'], 0, $this->doc->numPages, 0);
}
// Load template file.
$this->getTemplate();
@ -168,7 +178,7 @@ class PageGrid extends \Kitodo\Dlf\Common\AbstractPlugin
(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);
$this->piVars['page'] = MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1);
} else {
$this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure);
}

파일 보기

@ -14,6 +14,11 @@ namespace Kitodo\Dlf\Plugin;
use Kitodo\Dlf\Common\Helper;
use Kitodo\Dlf\Common\IiifManifest;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use Ubl\Iiif\Presentation\Common\Model\Resources\ManifestInterface;
use Ubl\Iiif\Presentation\Common\Vocabulary\Motivation;
@ -111,17 +116,17 @@ class PageView extends \Kitodo\Dlf\Common\AbstractPlugin
';
// Add Javascript to page footer if not configured otherwise.
if (empty($this->conf['addJStoBody'])) {
$pageRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
foreach ($cssFiles as $cssFile) {
$pageRenderer->addCssFile(\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extKey)) . $cssFile);
$pageRenderer->addCssFile(PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)) . $cssFile);
}
foreach ($jsFiles as $jsFile) {
$pageRenderer->addJsFooterFile(\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extKey)) . $jsFile);
$pageRenderer->addJsFooterFile(PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)) . $jsFile);
}
$pageRenderer->addJsFooterInlineCode('kitodo-pageview-configuration', $viewerConfiguration);
} else {
foreach ($jsFiles as $jsFile) {
$markerArray .= '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extKey)) . $jsFile . '"></script>' . "\n";
$markerArray .= '<script type="text/javascript" src="' . PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)) . $jsFile . '"></script>' . "\n";
}
$markerArray .= '
<script type="text/javascript">
@ -185,7 +190,7 @@ class PageView extends \Kitodo\Dlf\Common\AbstractPlugin
'parameter' => $this->conf['targetBasket'],
'forceAbsoluteUrl' => !empty($this->conf['forceAbsoluteUrl']) ? 1 : 0,
'forceAbsoluteUrl.' => ['scheme' => !empty($this->conf['forceAbsoluteUrl']) && !empty($this->conf['forceAbsoluteUrlHttps']) ? 'https' : 'http'],
'additionalParams' => \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl($this->prefixId, $params, '', true, false),
'additionalParams' => GeneralUtility::implodeArrayForUrl($this->prefixId, $params, '', true, false),
'title' => $label
];
$output = '<form id="addToBasketForm" action="' . $this->cObj->typoLink_URL($basketConf) . '" method="post">';
@ -221,11 +226,11 @@ class PageView extends \Kitodo\Dlf\Common\AbstractPlugin
{
$image = [];
// Get @USE value of METS fileGrp.
$fileGrps = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->conf['fileGrps']);
while ($fileGrp = @array_pop($fileGrps)) {
$fileGrpsImages = GeneralUtility::trimExplode(',', $this->conf['fileGrpImages']);
while ($fileGrpImages = array_pop($fileGrpsImages)) {
// Get image link.
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]['files'][$fileGrp])) {
$image['url'] = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]['files'][$fileGrp]);
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]['files'][$fileGrpImages])) {
$image['url'] = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]['files'][$fileGrpImages]);
if ($this->conf['useInternalProxy']) {
// Configure @action URL for form.
$linkConf = [
@ -236,10 +241,10 @@ class PageView extends \Kitodo\Dlf\Common\AbstractPlugin
];
$image['url'] = $this->cObj->typoLink_URL($linkConf);
}
$image['mimetype'] = $this->doc->getFileMimeType($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]['files'][$fileGrp]);
$image['mimetype'] = $this->doc->getFileMimeType($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]['files'][$fileGrpImages]);
break;
} else {
Helper::devLog('File not found in fileGrp "' . $fileGrp . '"', DEVLOG_SEVERITY_WARNING);
Helper::devLog('File not found in fileGrp "' . $fileGrpImages . '"', DEVLOG_SEVERITY_WARNING);
}
}
return $image;
@ -258,20 +263,25 @@ class PageView extends \Kitodo\Dlf\Common\AbstractPlugin
{
$fulltext = [];
// Get fulltext link.
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]['files'][$this->conf['fileGrpFulltext']])) {
$fulltext['url'] = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]['files'][$this->conf['fileGrpFulltext']]);
if ($this->conf['useInternalProxy']) {
// Configure @action URL for form.
$linkConf = [
'parameter' => $GLOBALS['TSFE']->id,
'forceAbsoluteUrl' => !empty($this->conf['forceAbsoluteUrl']) ? 1 : 0,
'forceAbsoluteUrl.' => ['scheme' => !empty($this->conf['forceAbsoluteUrl']) && !empty($this->conf['forceAbsoluteUrlHttps']) ? 'https' : 'http'],
'additionalParams' => '&eID=tx_dlf_pageview_proxy&url=' . urlencode($fulltext['url']),
];
$fulltext['url'] = $this->cObj->typoLink_URL($linkConf);
$fileGrpsFulltext = GeneralUtility::trimExplode(',', $this->conf['fileGrpFulltext']);
while ($fileGrpFulltext = array_shift($fileGrpsFulltext)) {
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]['files'][$fileGrpFulltext])) {
$fulltext['url'] = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]['files'][$fileGrpFulltext]);
if ($this->conf['useInternalProxy']) {
// Configure @action URL for form.
$linkConf = [
'parameter' => $GLOBALS['TSFE']->id,
'forceAbsoluteUrl' => !empty($this->conf['forceAbsoluteUrl']) ? 1 : 0,
'forceAbsoluteUrl.' => ['scheme' => !empty($this->conf['forceAbsoluteUrl']) && !empty($this->conf['forceAbsoluteUrlHttps']) ? 'https' : 'http'],
'additionalParams' => '&eID=tx_dlf_pageview_proxy&url=' . urlencode($fulltext['url']),
];
$fulltext['url'] = $this->cObj->typoLink_URL($linkConf);
}
$fulltext['mimetype'] = $this->doc->getFileMimeType($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]['files'][$fileGrpFulltext]);
break;
}
$fulltext['mimetype'] = $this->doc->getFileMimeType($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]['files'][$this->conf['fileGrpFulltext']]);
} else {
}
if (empty($fulltext)) {
Helper::devLog('File not found in fileGrp "' . $this->conf['fileGrpFulltext'] . '"', DEVLOG_SEVERITY_WARNING);
}
return $fulltext;
@ -364,11 +374,11 @@ class PageView extends \Kitodo\Dlf\Common\AbstractPlugin
// 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);
$this->piVars['page'] = 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);
$this->piVars['double'] = MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
}
// Load template file.
$this->getTemplate();

파일 보기

@ -13,6 +13,8 @@
namespace Kitodo\Dlf\Plugin\Tools;
use Kitodo\Dlf\Common\Helper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
/**
* Fulltext Download tool for the plugin 'Toolbox' of the 'dlf' extension
@ -64,16 +66,22 @@ class FulltextDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin
(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);
$this->piVars['page'] = 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);
$this->piVars['double'] = 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']];
$fileGrpsFulltext = GeneralUtility::trimExplode(',', $this->conf['fileGrpFulltext']);
while ($fileGrpFulltext = array_shift($fileGrpsFulltext)) {
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$fileGrpFulltext])) {
$fullTextFile = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$fileGrpFulltext];
break;
}
}
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 {

파일 보기

@ -12,9 +12,9 @@
namespace Kitodo\Dlf\Plugin\Tools;
use TYPO3\CMS\Core\Utility\MathUtility;
use Kitodo\Dlf\Common\Helper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
/**
* Fulltext tool for the plugin 'Toolbox' of the 'dlf' extension
@ -75,7 +75,13 @@ class FulltextTool extends \Kitodo\Dlf\Common\AbstractPlugin
}
// Load template file.
$this->getTemplate();
$fullTextFile = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpFulltext']];
$fileGrpsFulltext = GeneralUtility::trimExplode(',', $this->conf['fileGrpFulltext']);
while ($fileGrpFulltext = array_shift($fileGrpsFulltext)) {
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$fileGrpFulltext])) {
$fullTextFile = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$fileGrpFulltext];
break;
}
}
if (!empty($fullTextFile)) {
$markerArray['###FULLTEXT_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-fulltext" title="" data-dic="'
. 'fulltext:' . htmlspecialchars($this->pi_getLL('fulltext', ''))

파일 보기

@ -13,6 +13,8 @@
namespace Kitodo\Dlf\Plugin\Tools;
use Kitodo\Dlf\Common\Helper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
/**
* PDF Download tool for the plugin 'Toolbox' of the 'dlf' extension
@ -65,11 +67,11 @@ class PdfDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin
(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);
$this->piVars['page'] = 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);
$this->piVars['double'] = MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
}
// Load template file.
$this->getTemplate();
@ -93,28 +95,27 @@ class PdfDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin
$page1Link = '';
$page2Link = '';
$pageNumber = $this->piVars['page'];
$fileGrpsDownload = GeneralUtility::trimExplode(',', $this->conf['fileGrpDownload']);
// Get image link.
$details = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$pageNumber]];
$file = $details['files'][$this->conf['fileGrpDownload']];
if (!empty($file)) {
$page1Link = $this->doc->getFileLocation($file);
}
// Get second page, too, if double page view is activated.
if (
$this->piVars['double']
&& $pageNumber < $this->doc->numPages
) {
$details = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$pageNumber + 1]];
$file = $details['files'][$this->conf['fileGrpDownload']];
if (!empty($file)) {
$page2Link = $this->doc->getFileLocation($file);
while ($fileGrpDownload = array_shift($fileGrpsDownload)) {
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$pageNumber]]['files'][$fileGrpDownload])) {
$page1Link = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$pageNumber]]['files'][$fileGrpDownload]);
// Get second page, too, if double page view is activated.
if (
$this->piVars['double']
&& $pageNumber < $this->doc->numPages
&& !empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$pageNumber + 1]]['files'][$fileGrpDownload])
) {
$page2Link = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$pageNumber + 1]]['files'][$fileGrpDownload]);
}
break;
}
}
if (
empty($page1Link)
&& empty($page2Link)
) {
Helper::devLog('File not found in fileGrp "' . $this->conf['fileGrpDownload'] . '"', DEVLOG_SEVERITY_WARNING);
Helper::devLog('File not found in fileGrps "' . $this->conf['fileGrpDownload'] . '"', DEVLOG_SEVERITY_WARNING);
}
// Wrap URLs with HTML.
$linkConf = [
@ -149,13 +150,18 @@ class PdfDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin
protected function getWorkLink()
{
$workLink = '';
$fileGrpsDownload = GeneralUtility::trimExplode(',', $this->conf['fileGrpDownload']);
// Get work link.
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[0]]['files'][$this->conf['fileGrpDownload']])) {
$workLink = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[0]]['files'][$this->conf['fileGrpDownload']]);
} else {
$details = $this->doc->getLogicalStructure($this->doc->toplevelId);
if (!empty($details['files'][$this->conf['fileGrpDownload']])) {
$workLink = $this->doc->getFileLocation($details['files'][$this->conf['fileGrpDownload']]);
while ($fileGrpDownload = array_shift($fileGrpsDownload)) {
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[0]]['files'][$fileGrpDownload])) {
$workLink = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[0]]['files'][$fileGrpDownload]);
break;
} else {
$details = $this->doc->getLogicalStructure($this->doc->toplevelId);
if (!empty($details['files'][$fileGrpDownload])) {
$workLink = $this->doc->getFileLocation($details['files'][$fileGrpDownload]);
break;
}
}
}
// Wrap URLs with HTML.

파일 보기

@ -13,7 +13,11 @@
namespace Kitodo\Dlf\Plugin\Tools;
use Kitodo\Dlf\Common\Helper;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/**
* SearchInDocument tool for the plugin 'Toolbox' of the 'dlf' extension
@ -72,14 +76,20 @@ class SearchInDocumentTool extends \Kitodo\Dlf\Common\AbstractPlugin
(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);
$this->piVars['page'] = MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1);
} else {
$this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure);
}
}
// Quit if no fulltext file is present
$fullTextFile = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpFulltext']];
$fileGrpsFulltext = GeneralUtility::trimExplode(',', $this->conf['fileGrpFulltext']);
while ($fileGrpFulltext = array_shift($fileGrpsFulltext)) {
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$fileGrpFulltext])) {
$fullTextFile = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$fileGrpFulltext];
break;
}
}
if (empty($fullTextFile)) {
return $content;
}
@ -124,8 +134,8 @@ class SearchInDocumentTool extends \Kitodo\Dlf\Common\AbstractPlugin
*/
protected function addSearchInDocumentJS()
{
$pageRenderer = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
$pageRenderer->addJsFooterFile(\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extKey)) . 'Resources/Public/Javascript/Search/SearchInDocument.js');
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addJsFooterFile(PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)) . 'Resources/Public/Javascript/Search/SearchInDocument.js');
}
/**

파일 보기

@ -78,7 +78,7 @@
<type>input</type>
<size>30</size>
<max>30</max>
<default>MIN,DEFAULT,MAX</default>
<default>DEFAULT,MAX</default>
</config>
</TCEforms>
</fileGrpsImageDownload>

파일 보기

@ -181,11 +181,11 @@
<label index="config.caching">Cache parsed METS files / IIIF manifests: Caching improves performance a little bit but can result in a very large "fe_session_data" table (default is "FALSE")</label>
<label index="config.publishNewCollections">Publish new collections?: Should new collections automatically be published in the OAI-PMH interface? (default is "TRUE")</label>
<label index="config.unhideOnIndex">Unhide indexed documents?: Should hidden documents be unhidden when re-indexing them? (default is "FALSE")</label>
<label index="config.fileGrps">Page fileGrps: comma-separated list of @USE attribute values ordered by increasing size (default is "MIN,DEFAULT,MAX")</label>
<label index="config.fileGrpThumbs">Thumbnail fileGrp: @USE attribute value (default is "THUMBS")</label>
<label index="config.fileGrpDownload">Download fileGrp: @USE attribute value (default is "DOWNLOAD")</label>
<label index="config.fileGrpFulltext">Fulltext fileGrp: @USE attribute value (default is "FULLTEXT")</label>
<label index="config.fileGrpAudio">Audio fileGrp: @USE attribute value (default is "AUDIO")</label>
<label index="config.fileGrpImages">Page fileGrps: comma-separated list of @USE attribute values ordered by increasing size (default is "DEFAULT,MAX")</label>
<label index="config.fileGrpThumbs">Thumbnail fileGrp: comma-separated list of @USE attribute values ordered by decreasing priority (default is "THUMBS")</label>
<label index="config.fileGrpDownload">Download fileGrp: comma-separated list of @USE attribute values ordered by decreasing priority (default is "DOWNLOAD")</label>
<label index="config.fileGrpFulltext">Fulltext fileGrp: comma-separated list of @USE attribute values ordered by decreasing priority (default is "FULLTEXT")</label>
<label index="config.fileGrpAudio">Audio fileGrp: comma-separated list of @USE attribute values ordered by decreasing priority (default is "AUDIO")</label>
<label index="config.indexAnnotations">Handle IIIF annotations with motivation "painting" as fulltext?: Handling annotations as fulltexts means they are indexed (default is "FALSE")</label>
<label index="config.iiifThumbnailWidth">Maximum thumbnail width for IIIF images: Only for images without a thumbnail declaration (default is "150")</label>
<label index="config.iiifThumbnailHeight">Maximum thumbnail height for IIIF images: Only for images without a thumbnail declaration (default is "150")</label>
@ -366,11 +366,11 @@
<label index="config.caching">Eingelesene METS Dateien / IIIF-Manifeste zwischenspeichern: Dies kann die Geschwindigkeit geringfügig verbessern, führt aber zu einer sehr großen "fe_session_data" Tabelle (Standard ist "FALSE")</label>
<label index="config.publishNewCollections">Neue Kollektionen publizieren?: Sollen neue Kollektionen automatisch in der OAI-PMH-Schnittstelle veröffentlicht werden? (Standard ist "TRUE")</label>
<label index="config.unhideOnIndex">Indexierte Dokumente einblenden?: Sollen ausgeblendete Dokumente bei der erneuten Indexierung wieder eingeblendet werden? (Standard ist "FALSE")</label>
<label index="config.fileGrps">Seiten fileGrps: Komma-getrennte Liste der @USE Attributwerte der Seitenansichten nach aufsteigender Größe sortiert (Standard ist "MIN,DEFAULT,MAX")</label>
<label index="config.fileGrpThumbs">Vorschau fileGrp: @USE Attributwert der Vorschaubilder (Standard ist "THUMBS")</label>
<label index="config.fileGrpDownload">Download fileGrp: @USE Attributwert der Downloads (Standard ist "DOWNLOAD")</label>
<label index="config.fileGrpFulltext">Volltext fileGrp: @USE Attributwert der Volltexte (Standard ist "FULLTEXT")</label>
<label index="config.fileGrpAudio">Audio fileGrp: @USE Attributwert der Audiodateien (Standard ist "AUDIO")</label>
<label index="config.fileGrpImages">Seiten fileGrps: Komma-getrennte Liste der @USE Attributwerte der Seitenansichten nach aufsteigender Größe sortiert (Standard ist "DEFAULT,MAX")</label>
<label index="config.fileGrpThumbs">Vorschau fileGrp: Komma-getrennte Liste der @USE Attributwerte der Vorschaubilder nach absteigender Priorität sortiert (Standard ist "THUMBS")</label>
<label index="config.fileGrpDownload">Download fileGrp: Komma-getrennte Liste der @USE Attributwerte der Downloads nach absteigender Priorität sortiert (Standard ist "DOWNLOAD")</label>
<label index="config.fileGrpFulltext">Volltext fileGrp: Komma-getrennte Liste der @USE Attributwerte der Volltexte nach absteigender Priorität sortiert (Standard ist "FULLTEXT")</label>
<label index="config.fileGrpAudio">Audio fileGrp: Komma-getrennte Liste der @USE Attributwerte der Audiodateien nach absteigender Priorität sortiert (Standard ist "AUDIO")</label>
<label index="config.indexAnnotations">IIIF-Annotationen mit Motivation "painting" als Volltext behandeln?: Als Volltext behandelte Annotationen werden im Suchindex indexiert (Standard ist "FALSE")</label>
<label index="config.iiifThumbnailWidth">Maximale Thumbnail-Breite für IIIF-Images: Gilt nur für Bilder ohne Thumbnail-Angaben (Standard ist "150")</label>
<label index="config.iiifThumbnailHeight">Maximale Thumbnail-Höhe für IIIF-Images: Gilt nur für Bilder ohne Thumbnail-Angaben (Standard ist "150")</label>

파일 보기

@ -20,7 +20,7 @@
<label index="tt_content.pi_flexform.sheet_general">Options</label>
<label index="tt_content.pi_flexform.tools">Tools</label>
<label index="tt_content.pi_flexform.templateFile">Template file</label>
<label index="tt_content.pi_flexform.fileGrps">Page fileGrps used by image download tool: comma-separated list of @USE attribute values ordered by increasing size (default is "MIN,DEFAULT,MAX")</label>
<label index="tt_content.pi_flexform.fileGrps">Page fileGrps used by image download tool: comma-separated list of @USE attribute values ordered by increasing size (default is "DEFAULT,MAX")</label>
</languageKey>
<languageKey index="de" type="array">
<label index="tt_content.plugin.title">Werkzeugkasten</label>
@ -28,7 +28,7 @@
<label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
<label index="tt_content.pi_flexform.tools">Werkzeuge</label>
<label index="tt_content.pi_flexform.templateFile">HTML-Template</label>
<label index="tt_content.pi_flexform.fileGrp">Seiten fileGrps für das Werkzeug Bild-Download: Komma-getrennte Liste der @USE Attributwerte der Seitenansichten nach aufsteigender Größe sortiert (Standard ist "MIN,DEFAULT,MAX")</label>
<label index="tt_content.pi_flexform.fileGrp">Seiten fileGrps für das Werkzeug Bild-Download: Komma-getrennte Liste der @USE Attributwerte der Seitenansichten nach aufsteigender Größe sortiert (Standard ist "DEFAULT,MAX")</label>
</languageKey>
</data>
</T3locallang>

파일 보기

@ -12,8 +12,8 @@ caching = 0
publishNewCollections = 1
# cat=Basic; type=boolean; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.unhideOnIndex
unhideOnIndex = 0
# cat=Files; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.fileGrps
fileGrps = MIN,DEFAULT,MAX
# cat=Files; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.fileGrpImages
fileGrpImages = DEFAULT,MAX
# cat=Files; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.fileGrpThumbs
fileGrpThumbs = THUMBS
# cat=Files; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.fileGrpDownload