diff --git a/dlf/common/class.tx_dlf_document.php b/dlf/common/class.tx_dlf_document.php
index 7ecd8ca1..4f58c0bb 100644
--- a/dlf/common/class.tx_dlf_document.php
+++ b/dlf/common/class.tx_dlf_document.php
@@ -79,6 +79,24 @@ final class tx_dlf_document {
*/
public $extKey = 'dlf';
+ /**
+ * This holds the file ID -> USE concordance
+ * @see _getFileGrps()
+ *
+ * @var array
+ * @access protected
+ */
+ protected $fileGrps = array ();
+
+ /**
+ * Are the file groups loaded?
+ * @see $fileGrps
+ *
+ * @var boolean
+ * @access protected
+ */
+ protected $fileGrpsLoaded = FALSE;
+
/**
* This holds the configuration for all supported metadata encodings
* @see loadFormats()
@@ -550,6 +568,23 @@ final class tx_dlf_document {
}
+ // Get the files this structure element is pointing at.
+ $details['files'] = array ();
+
+ $fileUse = $this->_getFileGrps();
+
+ // Get the file representations from fileSec node.
+ foreach ($structure->children('http://www.loc.gov/METS/')->fptr as $fptr) {
+
+ // Check if file has valid @USE attribute.
+ if (!empty($fileUse[(string) $fptr->attributes()->FILEID])) {
+
+ $details['files'][$fileUse[(string) $fptr->attributes()->FILEID]] = (string) $fptr->attributes()->FILEID;
+
+ }
+
+ }
+
// Keep for later usage.
$this->logicalUnits[$details['id']] = $details;
@@ -1576,6 +1611,66 @@ final class tx_dlf_document {
}
+ /**
+ * This builds the file ID -> USE concordance
+ *
+ * @access protected
+ *
+ * @return array Array of file use groups with file IDs
+ */
+ protected function _getFileGrps() {
+
+ if (!$this->fileGrpsLoaded) {
+
+ // Get configured USE attributes.
+ $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
+
+ $useGrps = t3lib_div::trimExplode(',', $extConf['fileGrps']);
+
+ if (!empty($extConf['fileGrpThumbs'])) {
+
+ $useGrps[] = $extConf['fileGrpThumbs'];
+
+ }
+
+ if (!empty($extConf['fileGrpDownload'])) {
+
+ $useGrps[] = $extConf['fileGrpDownload'];
+
+ }
+
+ if (!empty($extConf['fileGrpFulltext'])) {
+
+ $useGrps[] = $extConf['fileGrpFulltext'];
+
+ }
+
+ // Get all file groups.
+ $fileGrps = $this->mets->xpath('./mets:fileSec/mets:fileGrp');
+
+ // Build concordance for configured USE attributes.
+ foreach ($fileGrps as $fileGrp) {
+
+ if (in_array((string) $fileGrp['USE'], $useGrps)) {
+
+ foreach ($fileGrp->children('http://www.loc.gov/METS/')->file as $file) {
+
+ $this->fileGrps[(string) $file->attributes()->ID] = (string) $fileGrp['USE'];
+
+ }
+
+ }
+
+ }
+
+ $this->fileGrpsLoaded = TRUE;
+
+ }
+
+ return $this->fileGrps;
+
+ }
+
/**
* This returns $this->location via __get()
*
@@ -1695,40 +1790,8 @@ final class tx_dlf_document {
if ($pageNodes) {
- $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
-
- $useGrps = t3lib_div::trimExplode(',', $extConf['fileGrps']);
-
- if (!empty($extConf['fileGrpThumbs'])) {
-
- $useGrps[] = $extConf['fileGrpThumbs'];
-
- }
-
- if (!empty($extConf['fileGrpFulltext'])) {
-
- $useGrps[] = $extConf['fileGrpFulltext'];
-
- }
-
- // Yes. Get concordance of @FILEID and @USE attributes.
- $fileUse = array ();
-
- $fileGrps = $this->mets->xpath('./mets:fileSec/mets:fileGrp');
-
- foreach ($fileGrps as $fileGrp) {
-
- if (in_array((string) $fileGrp['USE'], $useGrps)) {
-
- foreach ($fileGrp->children('http://www.loc.gov/METS/')->file as $file) {
-
- $fileUse[(string) $file->attributes()->ID] = (string) $fileGrp['USE'];
-
- }
-
- }
-
- }
+ // Get file groups.
+ $fileUse = $this->_getFileGrps();
// Get the physical sequence's metadata.
$physNode = $this->mets->xpath('./mets:structMap[@TYPE="PHYSICAL"]/mets:div[@TYPE="physSequence"]');
diff --git a/dlf/ext_conf_template.txt b/dlf/ext_conf_template.txt
index 13d205c1..1f655df7 100644
--- a/dlf/ext_conf_template.txt
+++ b/dlf/ext_conf_template.txt
@@ -25,6 +25,9 @@ fileGrps = MIN,DEFAULT,MAX
# cat=Files; type=string; label=LLL:EXT:dlf/locallang.xml:config.fileGrpThumbs
fileGrpThumbs = THUMBS
+# cat=Files; type=string; label=LLL:EXT:dlf/locallang.xml:config.fileGrpDownload
+fileGrpDownload = DOWNLOAD
+
# cat=Files; type=string; label=LLL:EXT:dlf/locallang.xml:config.fileGrpFulltext
fileGrpFulltext = FULLTEXT
diff --git a/dlf/ext_localconf.php b/dlf/ext_localconf.php
index ce475645..38b28483 100644
--- a/dlf/ext_localconf.php
+++ b/dlf/ext_localconf.php
@@ -52,10 +52,6 @@ t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/toolbox/class.tx_dlf_toolbox.php',
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/validator/class.tx_dlf_validator.php', '_validator', 'list_type', FALSE);
// Register tools for toolbox plugin.
-t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/toolbox/tools/dfgviewer/class.tx_dlf_toolsDfgviewer.php', '_toolsDfgviewer', '', FALSE);
-
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/plugins/toolbox/tools'][t3lib_extMgm::getCN($_EXTKEY).'_toolsDfgviewer'] = 'LLL:EXT:dlf/locallang.xml:tx_dlf_toolbox.toolsDfgviewer';
-
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/toolbox/tools/pdf/class.tx_dlf_toolsPdf.php', '_toolsPdf', '', FALSE);
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/plugins/toolbox/tools'][t3lib_extMgm::getCN($_EXTKEY).'_toolsPdf'] = 'LLL:EXT:dlf/locallang.xml:tx_dlf_toolbox.toolsPdf';
diff --git a/dlf/ext_tables.php b/dlf/ext_tables.php
index b469f9d8..aa4787d2 100644
--- a/dlf/ext_tables.php
+++ b/dlf/ext_tables.php
@@ -344,12 +344,6 @@ t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang.xml:tt_content.dlf_validato
t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_validator', 'FILE:EXT:'.$_EXTKEY.'/plugins/validator/flexform.xml');
-// Tool "toolsDfgviewer".
-t3lib_extMgm::addStaticFile($_EXTKEY, 'plugins/toolbox/tools/dfgviewer/', 'Tool: DFG Viewer');
-
-// Tool "toolsPdf".
-t3lib_extMgm::addStaticFile($_EXTKEY, 'plugins/toolbox/tools/pdf/', 'Tool: PDF Download');
-
// Register modules.
if (TYPO3_MODE == 'BE') {
diff --git a/dlf/locallang.xml b/dlf/locallang.xml
index eeb7d05f..51ad8318 100644
--- a/dlf/locallang.xml
+++ b/dlf/locallang.xml
@@ -133,7 +133,6 @@
-
@@ -157,6 +156,7 @@
+
@@ -310,7 +310,6 @@
-
@@ -334,6 +333,7 @@
+
diff --git a/dlf/plugins/pageview/class.tx_dlf_pageview.php b/dlf/plugins/pageview/class.tx_dlf_pageview.php
index 642f48e6..2075c362 100644
--- a/dlf/plugins/pageview/class.tx_dlf_pageview.php
+++ b/dlf/plugins/pageview/class.tx_dlf_pageview.php
@@ -242,7 +242,7 @@ class tx_dlf_pageview extends tx_dlf_plugin {
if (TYPO3_DLOG) {
- t3lib_div::devLog('[tx_dlf_pageview->getImage('.$page.')] File not found in fileGrp "'.$fileGrp.'"', $this->extKey, SYSLOG_SEVERITY_WARNING);
+ t3lib_div::devLog('[tx_dlf_pageview->getImageUrl('.$page.')] File not found in fileGrp "'.$fileGrp.'"', $this->extKey, SYSLOG_SEVERITY_WARNING);
}
diff --git a/dlf/plugins/toolbox/tools/dfgviewer/class.tx_dlf_toolsDfgviewer.php b/dlf/plugins/toolbox/tools/dfgviewer/class.tx_dlf_toolsDfgviewer.php
deleted file mode 100644
index eb7c8940..00000000
--- a/dlf/plugins/toolbox/tools/dfgviewer/class.tx_dlf_toolsDfgviewer.php
+++ /dev/null
@@ -1,71 +0,0 @@
-
-* All rights reserved
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * [CLASS/FUNCTION INDEX of SCRIPT]
- */
-
-/**
- * Tool 'Link to DFG Viewer' for the plugin 'DLF: Toolbox' of the 'dlf' extension.
- *
- * @author Sebastian Meyer
- * @package TYPO3
- * @subpackage tx_dlf
- * @access public
- */
-class tx_dlf_toolsDfgviewer extends tx_dlf_plugin {
-
- // Changed to prevent overwriting the main extension's parameters.
- public $prefixId = 'tx_dlf_toolsDfgviewer';
-
- public $scriptRelPath = 'plugins/toolbox/tools/dfgviewer/class.tx_dlf_toolsDfgviewer.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);
-
- // Turn cache off.
- $this->setCache(FALSE);
-
- return '';
-
- }
-
-}
-
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/toolbox/tools/dfgviewer/class.tx_dlf_toolsDfgviewer.php']) {
- include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/toolbox/tools/dfgviewer/class.tx_dlf_toolsDfgviewer.php']);
-}
-
-?>
\ No newline at end of file
diff --git a/dlf/plugins/toolbox/tools/dfgviewer/locallang.xml b/dlf/plugins/toolbox/tools/dfgviewer/locallang.xml
deleted file mode 100644
index 35e61a65..00000000
--- a/dlf/plugins/toolbox/tools/dfgviewer/locallang.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
- module
- Language labels for tool tx_dlf_dfgviewer
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dlf/plugins/toolbox/tools/dfgviewer/setup.txt b/dlf/plugins/toolbox/tools/dfgviewer/setup.txt
deleted file mode 100644
index 1061c0ad..00000000
--- a/dlf/plugins/toolbox/tools/dfgviewer/setup.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-plugin.tx_dlf_toolsDfgviewer {
- recordId.field = record_id
-}
\ No newline at end of file
diff --git a/dlf/plugins/toolbox/tools/dfgviewer/template.tmpl b/dlf/plugins/toolbox/tools/dfgviewer/template.tmpl
deleted file mode 100644
index a330648b..00000000
--- a/dlf/plugins/toolbox/tools/dfgviewer/template.tmpl
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/dlf/plugins/toolbox/tools/pdf/class.tx_dlf_toolsPdf.php b/dlf/plugins/toolbox/tools/pdf/class.tx_dlf_toolsPdf.php
index a5b69d63..2d521f2f 100644
--- a/dlf/plugins/toolbox/tools/pdf/class.tx_dlf_toolsPdf.php
+++ b/dlf/plugins/toolbox/tools/pdf/class.tx_dlf_toolsPdf.php
@@ -2,7 +2,7 @@
/***************************************************************
* Copyright notice
*
-* (c) 2011 Goobi. Digitalisieren im Verein e.V.
+* (c) 2014 Goobi. Digitalisieren im Verein e.V.
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
@@ -59,6 +59,23 @@ class tx_dlf_toolsPdf extends tx_dlf_plugin {
// Turn cache off.
$this->setCache(FALSE);
+ // Load current document.
+ $this->loadDocument();
+
+ if ($this->doc === NULL || $this->doc->numPages < 1 || empty($this->conf['fileGrpDownload'])) {
+
+ // Quit without doing anything if required variables are not set.
+ return $content;
+
+ } else {
+
+ // Set default values if not set.
+ $this->piVars['page'] = t3lib_div::intInRange($this->piVars['page'], 1, $this->doc->numPages, 1);
+
+ $this->piVars['double'] = t3lib_div::intInRange($this->piVars['double'], 0, 1, 0);
+
+ }
+
// Load template file.
if (!empty($this->conf['templateFile'])) {
@@ -70,14 +87,119 @@ class tx_dlf_toolsPdf extends tx_dlf_plugin {
}
- // TODO: Just a quick and dirty hack so far!
- $ppn = preg_replace('/oai\:[\w\-\:]*id-/', '', $this->cObj->data['record_id']);
- $content = $this->cObj->substituteMarkerArray($this->template, array ('###LINK###' => 'PDF Download'));
+ // Get single page downloads.
+ $markerArray['###PAGE###'] = $this->getPageLink();
+
+ // Get work download.
+ $markerArray['###WORK###'] = $this->getWorkLink();
+
+ $content .= $this->cObj->substituteMarkerArray($this->template, $markerArray);
return $this->pi_wrapInBaseClass($content);
}
+ /**
+ * Get page's download link
+ *
+ * @access protected
+ *
+ * @return string Link to downloadable page
+ */
+ protected function getPageLink() {
+
+ $pageLink = array ();
+
+ // Get image link.
+ if (!empty($this->doc->physicalPagesInfo[$this->doc->physicalPages[$this->piVars['page']]]['files'][$this->conf['fileGrpDownload']])) {
+
+ $pageLink[] = $this->doc->getFileLocation($this->doc->physicalPagesInfo[$this->doc->physicalPages[$this->piVars['page']]]['files'][$this->conf['fileGrpDownload']]);
+
+ // Get second page, too, if double page view is activated.
+ if ($this->piVars['double'] && $this->piVars['page'] < $this->doc->numPages) {
+
+ $pageLink[] = $this->doc->getFileLocation($this->doc->physicalPagesInfo[$this->doc->physicalPages[$this->piVars['page'] + 1]]['files'][$this->conf['fileGrpDownload']]);
+
+ }
+
+ } else {
+
+ if (TYPO3_DLOG) {
+
+ t3lib_div::devLog('[tx_dlf_toolsPdf->getPageLink()] File not found in fileGrp "'.$this->conf['fileGrpDownload'].'"', $this->extKey, SYSLOG_SEVERITY_WARNING);
+
+ }
+
+ }
+
+ // Wrap URLs with HTML.
+ if (!empty($pageLink)) {
+
+ if (count($pageLink) > 1) {
+
+ $pageLink[0] = $this->pi_linkToPage($this->pi_getLL('leftPage', ''), $pageLink[0], '_blank', array ('title' => $this->pi_getLL('leftPage', '')));
+
+ $pageLink[1] = $this->pi_linkToPage($this->pi_getLL('rightPage', ''), $pageLink[1], '_blank', array ('title' => $this->pi_getLL('rightPage', '')));
+
+ } else {
+
+ $pageLink[0] = $this->pi_linkToPage($this->pi_getLL('singlePage', ''), $pageLink[0], '_blank', array ('title' => $this->pi_getLL('singlePage', '')));
+
+ }
+
+ }
+
+ return implode('', $pageLink);
+
+ }
+
+ /**
+ * Get work's download link
+ *
+ * @access protected
+ *
+ * @return string Link to downloadable work
+ */
+ protected function getWorkLink() {
+
+ $workLink = '';
+
+ // Get work link.
+ if (!empty($this->doc->physicalPagesInfo[$this->doc->physicalPages[0]]['files'][$this->conf['fileGrpDownload']])) {
+
+ $workLink = $this->doc->getFileLocation($this->doc->physicalPagesInfo[$this->doc->physicalPages[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']]);
+
+ }
+
+ }
+
+ // Wrap URLs with HTML.
+ if (!empty($workLink)) {
+
+ $workLink = $this->pi_linkToPage($this->pi_getLL('work', ''), $workLink, '_blank', array ('title' => $this->pi_getLL('work', '')));
+
+ } else {
+
+ if (TYPO3_DLOG) {
+
+ t3lib_div::devLog('[tx_dlf_toolsPdf->getWorkLink()] File not found in fileGrp "'.$this->conf['fileGrpDownload'].'"', $this->extKey, SYSLOG_SEVERITY_WARNING);
+
+ }
+
+ }
+
+ return $workLink;
+
+ }
+
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/toolbox/tools/pdf/class.tx_dlf_toolsPdf.php']) {
diff --git a/dlf/plugins/toolbox/tools/pdf/locallang.xml b/dlf/plugins/toolbox/tools/pdf/locallang.xml
index 3761fba1..55b87194 100644
--- a/dlf/plugins/toolbox/tools/pdf/locallang.xml
+++ b/dlf/plugins/toolbox/tools/pdf/locallang.xml
@@ -24,14 +24,20 @@
module
- Language labels for tool tx_dlf_pdf
+ Language labels for tool tx_dlf_toolsPdf
-
+
+
+
+
-
+
+
+
+
\ No newline at end of file
diff --git a/dlf/plugins/toolbox/tools/pdf/setup.txt b/dlf/plugins/toolbox/tools/pdf/setup.txt
deleted file mode 100644
index 49e40f59..00000000
--- a/dlf/plugins/toolbox/tools/pdf/setup.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-plugin.tx_dlf_toolsPdf {
- docId.field = uid
-}
\ No newline at end of file
diff --git a/dlf/plugins/toolbox/tools/pdf/template.tmpl b/dlf/plugins/toolbox/tools/pdf/template.tmpl
index ac52885a..6b3fe647 100644
--- a/dlf/plugins/toolbox/tools/pdf/template.tmpl
+++ b/dlf/plugins/toolbox/tools/pdf/template.tmpl
@@ -21,5 +21,6 @@
This copyright notice MUST APPEAR in all copies of the script!
-->
-###LINK###
+###PAGE###
+###WORK###
\ No newline at end of file