Index: ext_localconf.php =================================================================== --- ext_localconf.php (revision 43562) +++ ext_localconf.php (working copy) @@ -66,6 +66,8 @@ $TYPO3_CONF_VARS['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'][] = 'EXT:dam/class.tx_dam_browse_media.php:&tx_dam_browse_media'; $TYPO3_CONF_VARS['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'][] = 'EXT:dam/class.tx_dam_browse_category.php:&tx_dam_browse_category'; $TYPO3_CONF_VARS['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'][] = 'EXT:dam/class.tx_dam_browse_folder.php:&tx_dam_browse_folder'; + // register secure downloads processor +$TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkDataSubmission'][] = 'EXT:dam/lib/class.tx_dam_tsfe.php:&tx_dam_tsfe'; tx_dam::register_indexingRule ('tx_damindex_rule_recursive', 'EXT:dam/components/class.tx_dam_index_rules.php:&tx_dam_index_rule_recursive'); tx_dam::register_indexingRule ('tx_damindex_rule_folderAsCat', 'EXT:dam/components/class.tx_dam_index_rules.php:&tx_dam_index_rule_folderAsCat'); Index: lib/class.tx_dam_tsfe.php =================================================================== --- lib/class.tx_dam_tsfe.php (revision 43562) +++ lib/class.tx_dam_tsfe.php (working copy) @@ -180,6 +180,60 @@ return $label; } + /** + * This method hooks into the data submission process to try and assemble a jumpurl + * based on a reference to a DAM record passed with the locationData query variable + * + * @param tslib_fe $parentObject Back-reference to the calling tslib_fe object + * @return void + */ + public function checkDataSubmission(tslib_fe $parentObject) { + $locationData = (string)t3lib_div::_GP('locationData'); + if (!empty($locationData)) { + $locationDataParts = explode(':', $locationData); + // Three parts are expected: a page id, a table name and a record id + if (count($locationDataParts) == 3) { + // Consider only references to the DAM + if ($locationDataParts[1] == 'tx_dam') { + $recordId = intval($locationDataParts[2]); + if (!empty($recordId)) { + /** @var $media txdam_media */ + $media = tx_dam::media_getByUid($recordId); + // If the file is indeed available, set its path as the Jump URL + if ($media->isAvailable) { + $metaData = $media->getMetaArray(); + $parentObject->jumpurl = $metaData['file_path'] . $metaData['file_name']; + + // If the file is not available, issue error message + } else { + // If a hook is declared, call the hook for error handling + if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['secureDownloadErrorHandler'])) { + foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['secureDownloadErrorHandler'] as $classReference) { + $errorHandler = t3lib_div::getUserObj($classReference); + $errorHandler->handleDownloadError($locationDataParts, $parentObject); + } + + // In the absence of hooks, just print a standard error message and exit the process + } else { + // Instantiate local language object + /** @var $languageObject language */ + $languageObject = t3lib_div::makeInstance('language'); + // Get language code, if defined + if (!empty($GLOBALS['TSFE']->config['config']['language'])) { + $languageObject->lang = $GLOBALS['TSFE']->config['config']['language']; + if (!empty($GLOBALS['TSFE']->config['config']['language_alt'])) { + $languageObject->lang = $GLOBALS['TSFE']->config['config']['language_alt']; + } + } + $parentObject->printError($languageObject->sL('LLL:EXT:dam/lib/locallang.xml:downloadFailed'), $languageObject->sL('LLL:EXT:dam/lib/locallang.xml:downloadError')); + exit; + } + } + } + } + } + } + } } if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dam/lib/class.tx_dam_tsfe.php']) { Index: lib/locallang.xml =================================================================== --- lib/locallang.xml (revision 43562) +++ lib/locallang.xml (working copy) @@ -167,14 +167,16 @@ - - - - - - - - + + + + + + + + + + Index: binding/mediatag/class.tx_dam_tsfemediatag.php =================================================================== --- binding/mediatag/class.tx_dam_tsfemediatag.php (revision 43562) +++ binding/mediatag/class.tx_dam_tsfemediatag.php (working copy) @@ -175,8 +175,23 @@ // Setting title if blank value to link: if ($linktxt=='') $linktxt = $media->getContent('title'); - if ($GLOBALS['TSFE']->config['config']['jumpurl_enable']) { - $this->cObj->lastTypoLinkUrl = $GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode($media->getPathForSite()).$GLOBALS['TSFE']->getMethodUrlIdToken; + if ($GLOBALS['TSFE']->config['config']['jumpurl_enable'] || $conf['jumpurl']) { + $mediaUrl = $media->getPathForSite(); + $url = $GLOBALS['TSFE']->absRefPrefix . $GLOBALS['TSFE']->config['mainScript'] . $initP . $GLOBALS['TSFE']->getMethodUrlIdToken; + if (!empty($conf['jumpurl.']['secure'])) { + $secureConfiguration = array(); + if (isset($conf['jumpurl.']['secure.']) && is_array($conf['jumpurl.']['secure.'])) { + $secureConfiguration = $conf['jumpurl.']['secure.']; + } + $temporaryCurrentRecordCopy = $this->cObj->currentRecord; + $this->cObj->currentRecord = 'tx_dam:' . $this->cObj->data['txdam_uid']; + $jumpUrlParameters = $this->cObj->locDataJU($mediaUrl, $secureConfiguration); + $this->cObj->currentRecord = $temporaryCurrentRecordCopy; + $url .= $jumpUrlParameters; + } else { + $url .= '&jumpurl=' . rawurlencode($mediaUrl); + } + $this->cObj->lastTypoLinkUrl = $url; } else { $this->cObj->lastTypoLinkUrl = $media->getURL(); }