diff --git a/Classes/Plugins/Eid/PageViewProxy.php b/Classes/Plugins/Eid/PageViewProxy.php index 0ce93b9e..8cbece0a 100644 --- a/Classes/Plugins/Eid/PageViewProxy.php +++ b/Classes/Plugins/Eid/PageViewProxy.php @@ -12,55 +12,48 @@ namespace Kitodo\Dlf\Plugins\Eid; */ /** - * eID image proxy for plugin 'Page View' of the 'dlf' extension. + * eID image proxy for plugin 'Page View' of the 'dlf' extension * - * @author Alexander Bigga - * @copyright Copyright (c) 2015, Alexander Bigga, SLUB Dresden - * @package TYPO3 - * @subpackage tx_dlf - * @access public + * @author Alexander Bigga + * @package TYPO3 + * @subpackage dlf + * @access public */ -class PageViewProxy extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { - +class PageViewProxy extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin +{ public $scriptRelPath = 'Classes/Plugins/Eid/PageViewProxy.php'; /** * The main method of the eID script * - * @access public + * @access public * - * @param string $content: The PlugIn content - * @param array $conf: The PlugIn configuration + * @param string $content: The PlugIn content + * @param array $conf: The PlugIn configuration * - * @return string + * @return string */ - public function main($content = '', $conf = []) { - + public function main($content = '', $conf = []) + { $this->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class); - $header = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('header'); - $url = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('url'); - $fetchedData = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($url, \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($header, 0, 2, 0)); - // Add some header tags header('Last-Modified: '.gmdate("D, d M Y H:i:s").'GMT'); header('Cache-Control: max-age=3600, must-revalidate'); header('Content-Length: '.strlen($fetchedData)); header('Content-Type: '.finfo_buffer(finfo_open(FILEINFO_MIME), $fetchedData)); - // Get last modified date from request header $fetchedHeader = explode("\n", \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($url, 2)); - foreach ($fetchedHeader as $headerline) { - if (stripos($headerline, 'Last-Modified:') !== FALSE) { + foreach ($fetchedHeader as $headerline) + { + if (stripos($headerline, 'Last-Modified:') !== FALSE) + { header($headerline); break; } } - echo $fetchedData; - } - } diff --git a/Classes/Plugins/Eid/SearchSuggest.php b/Classes/Plugins/Eid/SearchSuggest.php index 21663076..abd62cf4 100644 --- a/Classes/Plugins/Eid/SearchSuggest.php +++ b/Classes/Plugins/Eid/SearchSuggest.php @@ -15,52 +15,44 @@ use Kitodo\Dlf\Common\Helper; use Kitodo\Dlf\Common\Solr; /** - * eID search suggestions for plugin 'Search' of the 'dlf' extension. + * eID search suggestions for plugin 'Search' of the 'dlf' extension * - * @author Henrik Lochmann - * @author Sebastian Meyer - * @package TYPO3 - * @subpackage dlf - * @access public + * @author Henrik Lochmann + * @author Sebastian Meyer + * @package TYPO3 + * @subpackage dlf + * @access public */ -class SearchSuggest extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { - +class SearchSuggest extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin +{ public $scriptRelPath = 'Classes/Plugins/Eid/SearchSuggest.php'; /** * The main method of the eID script * - * @access public + * @access public * - * @param string $content: The PlugIn content - * @param array $conf: The PlugIn configuration + * @param string $content: The PlugIn content + * @param array $conf: The PlugIn configuration * - * @return string XML response of search suggestions + * @return string XML response of search suggestions */ - public function main($content = '', $conf = []) { - - if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('encrypted') != '' && \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('hashed') != '') { - + public function main($content = '', $conf = []) + { + if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('encrypted') != '' + && \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('hashed') != '') + { $core = Helper::decrypt(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('encrypted'), \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('hashed')); - } - - if (!empty($core)) { - + if (!empty($core)) + { $url = trim(Solr::getSolrUrl($core), '/').'/suggest/?wt=xml&q='.Solr::escapeQuery(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('q')); - - if ($stream = fopen($url, 'r')) { - + if ($stream = fopen($url, 'r')) + { $content .= stream_get_contents($stream); - fclose($stream); - } - } - echo $content; - } - } diff --git a/Classes/Plugins/Tools/FulltextTool.php b/Classes/Plugins/Tools/FulltextTool.php index 135eeb7a..094f01cc 100644 --- a/Classes/Plugins/Tools/FulltextTool.php +++ b/Classes/Plugins/Tools/FulltextTool.php @@ -14,86 +14,69 @@ namespace Kitodo\Dlf\Plugins\Tools; use Kitodo\Dlf\Common\Helper; /** - * Fulltext tool for the plugin 'Toolbox' of the 'dlf' extension. + * Fulltext tool for the plugin 'Toolbox' of the 'dlf' extension * - * @author Sebastian Meyer - * @author Alexander Bigga - * @package TYPO3 - * @subpackage dlf - * @access public + * @author Sebastian Meyer + * @author Alexander Bigga + * @package TYPO3 + * @subpackage dlf + * @access public */ -class FulltextTool extends \Kitodo\Dlf\Common\AbstractPlugin { - +class FulltextTool extends \Kitodo\Dlf\Common\AbstractPlugin +{ public $scriptRelPath = 'Classes/Plugins/Tools/FulltextTool.php'; /** * The main method of the PlugIn * - * @access public + * @access public * - * @param string $content: The PlugIn content - * @param array $conf: The PlugIn configuration + * @param string $content: The PlugIn content + * @param array $conf: The PlugIn configuration * - * @return string The content that is displayed on the website + * @return string The content that is displayed on the website */ - public function main($content, $conf) { - + public function main($content, $conf) + { $this->init($conf); - // Merge configuration with conf array of toolbox. $this->conf = \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->cObj->data['conf'], $this->conf); - // Load current document. $this->loadDocument(); - - if ($this->doc === NULL || $this->doc->numPages < 1 || empty($this->conf['fileGrpFulltext'])) { - + 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'])) { - + 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'])) { - + 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(); - $fullTextFile = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpFulltext']]; - - if (!empty($fullTextFile)) { - $markerArray['###FULLTEXT_SELECT###'] = ' '; + if (!empty($fullTextFile)) + { + $markerArray['###FULLTEXT_SELECT###'] = ' '; } else { $markerArray['###FULLTEXT_SELECT###'] = ''.$this->pi_getLL('fulltext-not-available', '', TRUE).''; } - $content .= $this->cObj->substituteMarkerArray($this->template, $markerArray); - return $this->pi_wrapInBaseClass($content); - } - } diff --git a/Classes/Plugins/Tools/ImageDownloadTool.php b/Classes/Plugins/Tools/ImageDownloadTool.php index 81d922f0..f351acb9 100644 --- a/Classes/Plugins/Tools/ImageDownloadTool.php +++ b/Classes/Plugins/Tools/ImageDownloadTool.php @@ -14,141 +14,115 @@ namespace Kitodo\Dlf\Plugins\Tools; use Kitodo\Dlf\Common\Helper; /** - * Image Download tool for the plugin 'Toolbox' of the 'dlf' extension. + * Image Download tool for the plugin 'Toolbox' of the 'dlf' extension * - * @author Alexander Bigga - * @package TYPO3 - * @subpackage dlf - * @access public + * @author Alexander Bigga + * @package TYPO3 + * @subpackage dlf + * @access public */ -class ImageDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin { - +class ImageDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin +{ public $scriptRelPath = 'Classes/Plugins/Tools/ImageDownloadTool.php'; /** * The main method of the PlugIn * - * @access public + * @access public * - * @param string $content: The PlugIn content - * @param array $conf: The PlugIn configuration + * @param string $content: The PlugIn content + * @param array $conf: The PlugIn configuration * - * @return string The content that is displayed on the website + * @return string The content that is displayed on the website */ - public function main($content, $conf) { - + public function main($content, $conf) + { $this->init($conf); - // Merge configuration with conf array of toolbox. $this->conf = \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->cObj->data['conf'], $this->conf); - // Load current document. $this->loadDocument(); - - if ($this->doc === NULL || $this->doc->numPages < 1 || empty($this->conf['fileGrpsImageDownload'])) { - + if ($this->doc === NULL + || $this->doc->numPages < 1 + || empty($this->conf['fileGrpsImageDownload'])) + { // Quit without doing anything if required variables are not set. return $content; - } else { - - if (!empty($this->piVars['logicalPage'])) { - + 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'])) { - + 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 left or single page download. $markerArray['###IMAGE_LEFT###'] = $this->piVars['double'] == 1 ? $this->getImage($this->piVars['page'], $this->pi_getLL('leftPage', '')) : $this->getImage($this->piVars['page'], $this->pi_getLL('singlePage', '')); - // Get right page download. $markerArray['###IMAGE_RIGHT###'] = $this->piVars['double'] == 1 ? $this->getImage($this->piVars['page'] + 1, $this->pi_getLL('rightPage', '')) : ''; - $content .= $this->cObj->substituteMarkerArray($this->template, $markerArray); - return $this->pi_wrapInBaseClass($content); - } - /** * Get image's URL and MIME type * - * @access protected + * @access protected * - * @param integer $page: Page number - * @param string $label: Link title and label + * @param integer $page: Page number + * @param string $label: Link title and label * - * @return string linkt to image file with given label + * @return string Link to image file with given label */ - protected function getImage($page, $label) { - + protected function getImage($page, $label) + { $image = []; - // Get @USE value of METS fileGrp. $fileGrps = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->conf['fileGrpsImageDownload']); - - while ($fileGrp = @array_pop($fileGrps)) { - + while ($fileGrp = @array_pop($fileGrps)) + { // Get image link. - if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]['files'][$fileGrp])) { - + 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]); - $image['mimetype'] = $this->doc->getFileMimeType($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]['files'][$fileGrp]); - - switch ($image['mimetype']) { - case 'image/jpeg': $mimetypeLabel = '(JPG)'; + switch ($image['mimetype']) + { + case 'image/jpeg': + $mimetypeLabel = '(JPG)'; break; - case 'image/tiff': $mimetypeLabel = '(TIFF)'; - break; - default: $mimetypeLabel = ''; + case 'image/tiff': + $mimetypeLabel = '(TIFF)'; + break; + default: + $mimetypeLabel = ''; } $linkConf = [ 'parameter' => $image['url'], 'title' => $label.' '.$mimetypeLabel, 'additionalParams' => '', ]; - $imageLink = $this->cObj->typoLink($label.' '.$mimetypeLabel, $linkConf); - break; - } else { - - if (TYPO3_DLOG) { - + if (TYPO3_DLOG) + { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Plugins\Tools\ImageDownloadTool->getImage('.$page.')] File not found in fileGrp "'.$fileGrp.'"', $this->extKey, SYSLOG_SEVERITY_WARNING); - } - } - } - return $imageLink; - } - } diff --git a/Classes/Plugins/Tools/ImageManipulationTool.php b/Classes/Plugins/Tools/ImageManipulationTool.php index c08f06bd..9dadbde6 100644 --- a/Classes/Plugins/Tools/ImageManipulationTool.php +++ b/Classes/Plugins/Tools/ImageManipulationTool.php @@ -14,55 +14,36 @@ namespace Kitodo\Dlf\Plugins\Tools; use Kitodo\Dlf\Common\Helper; /** - * Image Manipulation tool for the plugin 'Toolbox' of the 'dlf' extension. + * Image Manipulation tool for the plugin 'Toolbox' of the 'dlf' extension * - * @author Jacob Mendt - * @package TYPO3 - * @subpackage dlf - * @access public + * @author Jacob Mendt + * @package TYPO3 + * @subpackage dlf + * @access public */ -class ImageManipulationTool extends \Kitodo\Dlf\Common\AbstractPlugin { - +class ImageManipulationTool extends \Kitodo\Dlf\Common\AbstractPlugin +{ public $scriptRelPath = 'Classes/Plugins/Tools/ImageManipulationTool.php'; /** * The main method of the PlugIn * - * @access public + * @access public * - * @param string $content: The PlugIn content - * @param array $conf: The PlugIn configuration + * @param string $content: The PlugIn content + * @param array $conf: The PlugIn configuration * - * @return string The content that is displayed on the website + * @return string The content that is displayed on the website */ - public function main($content, $conf) { - + public function main($content, $conf) + { $this->init($conf); - // Merge configuration with conf array of toolbox. $this->conf = \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->cObj->data['conf'], $this->conf); - - // Load current document. - $this->loadDocument(); - // Load template file. $this->getTemplate(); - - $markerArray['###IMAGEMANIPULATION_SELECT###'] = ''; - + $markerArray['###IMAGEMANIPULATION_SELECT###'] = ''; $content .= $this->cObj->substituteMarkerArray($this->template, $markerArray); - return $this->pi_wrapInBaseClass($content); - } - } diff --git a/Classes/Plugins/Tools/PdfDownloadTool.php b/Classes/Plugins/Tools/PdfDownloadTool.php index 06836da5..3dbc5e96 100644 --- a/Classes/Plugins/Tools/PdfDownloadTool.php +++ b/Classes/Plugins/Tools/PdfDownloadTool.php @@ -14,184 +14,153 @@ namespace Kitodo\Dlf\Plugins\Tools; use Kitodo\Dlf\Common\Helper; /** - * PDF Download tool for the plugin 'Toolbox' of the 'dlf' extension. + * PDF Download tool for the plugin 'Toolbox' of the 'dlf' extension * - * @author Sebastian Meyer - * @author Alexander Bigga - * @package TYPO3 - * @subpackage dlf - * @access public + * @author Sebastian Meyer + * @author Alexander Bigga + * @package TYPO3 + * @subpackage dlf + * @access public */ -class PdfDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin { - +class PdfDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin +{ public $scriptRelPath = 'Classes/Plugins/Tools/PdfDownloadTool.php'; /** * The main method of the PlugIn * - * @access public + * @access public * - * @param string $content: The PlugIn content - * @param array $conf: The PlugIn configuration + * @param string $content: The PlugIn content + * @param array $conf: The PlugIn configuration * - * @return string The content that is displayed on the website + * @return string The content that is displayed on the website */ - public function main($content, $conf) { - + public function main($content, $conf) + { $this->init($conf); - // Merge configuration with conf array of toolbox. $this->conf = \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->cObj->data['conf'], $this->conf); - // Load current document. $this->loadDocument(); - - if ($this->doc === NULL || $this->doc->numPages < 1 || empty($this->conf['fileGrpDownload'])) { - + 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 { - - if (!empty($this->piVars['logicalPage'])) { - + 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'])) { - + 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 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 + * @access protected * - * @return string Link to downloadable page + * @return string Link to downloadable page */ - protected function getPageLink() { - + protected function getPageLink() + { $page1Link = ''; $page2Link = ''; $pageNumber = $this->piVars['page']; - // Get image link. $details = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$pageNumber]]; $file = $details['files'][$this->conf['fileGrpDownload']]; - if (!empty($file)) { + 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) { + 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)) { + if (!empty($file)) + { $page2Link = $this->doc->getFileLocation($file); } } - - if (TYPO3_DLOG && empty($page1Link) && empty($page2Link)) { - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Plugins\Tools\PdfDownloadTool->getPageLink()] '. - 'File not found in fileGrp "'. - $this->conf['fileGrpDownload'].'"', - $this->extKey, - SYSLOG_SEVERITY_WARNING); + if (TYPO3_DLOG + && empty($page1Link) + && empty($page2Link)) + { + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Plugins\Tools\PdfDownloadTool->getPageLink()] File not found in fileGrp "'.$this->conf['fileGrpDownload'].'"', $this->extKey, SYSLOG_SEVERITY_WARNING); } - // Wrap URLs with HTML. - if (!empty($page1Link)) { - if ($this->piVars['double']) { - $page1Link = $this->cObj->typoLink($this->pi_getLL('leftPage', ''), - ['parameter' => $page1Link, 'title' => $this->pi_getLL('leftPage', '')]); + if (!empty($page1Link)) + { + if ($this->piVars['double']) + { + $page1Link = $this->cObj->typoLink($this->pi_getLL('leftPage', ''), ['parameter' => $page1Link, 'title' => $this->pi_getLL('leftPage', '')]); } else { - $page1Link = $this->cObj->typoLink($this->pi_getLL('singlePage', ''), - ['parameter' => $page1Link, 'title' => $this->pi_getLL('singlePage', '')]); + $page1Link = $this->cObj->typoLink($this->pi_getLL('singlePage', ''), ['parameter' => $page1Link, 'title' => $this->pi_getLL('singlePage', '')]); } } - if (!empty($page2Link)) { - $page2Link = $this->cObj->typoLink($this->pi_getLL('rightPage', ''), - ['parameter' => $page2Link, 'title' => $this->pi_getLL('rightPage', '')]); + if (!empty($page2Link)) + { + $page2Link = $this->cObj->typoLink($this->pi_getLL('rightPage', ''), ['parameter' => $page2Link, 'title' => $this->pi_getLL('rightPage', '')]); } - return $page1Link.$page2Link; } /** * Get work's download link * - * @access protected + * @access protected * - * @return string Link to downloadable work + * @return string Link to downloadable work */ - protected function getWorkLink() { - + protected function getWorkLink() + { $workLink = ''; - // Get work link. - if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[0]]['files'][$this->conf['fileGrpDownload']])) { - + 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']])) { - + if (!empty($details['files'][$this->conf['fileGrpDownload']])) + { $workLink = $this->doc->getFileLocation($details['files'][$this->conf['fileGrpDownload']]); - } - } - // Wrap URLs with HTML. - if (!empty($workLink)) { - + if (!empty($workLink)) + { $workLink = $this->cObj->typoLink($this->pi_getLL('work', ''), ['parameter' => $workLink, 'title' => $this->pi_getLL('work', '')]); - } else { - - if (TYPO3_DLOG) { - + if (TYPO3_DLOG) + { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Plugins\Tools\PdfDownloadTool->getWorkLink()] File not found in fileGrp "'.$this->conf['fileGrpDownload'].'"', $this->extKey, SYSLOG_SEVERITY_WARNING); - } - } - return $workLink; - } - } diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php index 73178603..eb164c35 100644 --- a/Configuration/TCA/Overrides/sys_template.php +++ b/Configuration/TCA/Overrides/sys_template.php @@ -9,23 +9,21 @@ * LICENSE.txt file that was distributed with this source code. */ -if (!defined('TYPO3_MODE')) { +if (!defined('TYPO3_MODE')) +{ die('Access denied.'); } - // Register static typoscript. \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile( 'dlf', 'Configuration/TypoScript/', 'Basic Configuration' ); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile( 'dlf', 'Configuration/TypoScript/Search/', 'Search Facets' ); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile( 'dlf', 'Configuration/TypoScript/TableOfContents/', diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 08c1f34d..1d33808a 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -9,150 +9,87 @@ * LICENSE.txt file that was distributed with this source code. */ -if (!defined('TYPO3_MODE')) { +if (!defined('TYPO3_MODE')) +{ die('Access denied.'); } - // Plugin "audioplayer". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_audioplayer'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_audioplayer'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_audioplayer', 'dlf_audioplayer'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_audioplayer', 'FILE:EXT:'.'dlf/Configuration/Flexforms/AudioPlayer.xml'); - // Plugin "basket". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_basket'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_basket'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_basket', 'dlf_basket'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_basket', 'FILE:EXT:'.'dlf/Configuration/Flexforms/Basket.xml'); - // Plugin "calendar". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_calendar'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_calendar'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_calendar', 'dlf_calendar'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_calendar', 'FILE:EXT:'.'dlf/Configuration/Flexforms/Calendar.xml'); - // Plugin "collection". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_collection'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_collection'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_collection', 'dlf_collection'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_collection', 'FILE:EXT:'.'dlf/Configuration/Flexforms/Collection.xml'); - // Plugin "feeds". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_feeds'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_feeds'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_feeds', 'dlf_feeds'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_feeds', 'FILE:EXT:'.'dlf/Configuration/Flexforms/Feeds.xml'); - // Plugin "listview". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_listview'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_listview'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_listview', 'dlf_listview'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_listview', 'FILE:EXT:'.'dlf/Configuration/Flexforms/ListView.xml'); - // Plugin "metadata". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_metadata'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_metadata'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_metadata', 'dlf_metadata'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_metadata', 'FILE:EXT:'.'dlf/Configuration/Flexforms/Metadata.xml'); - // Plugin "navigation". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_navigation'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_navigation'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_navigation', 'dlf_navigation'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_navigation', 'FILE:EXT:'.'dlf/Configuration/Flexforms/Navigation.xml'); - // Plugin "oaipmh". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_oaipmh'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_oaipmh'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_oaipmh', 'dlf_oaipmh'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_oaipmh', 'FILE:EXT:'.'dlf/Configuration/Flexforms/OaiPmh.xml'); - // Plugin "pagegrid". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_pagegrid'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_pagegrid'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_pagegrid', 'dlf_pagegrid'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_pagegrid', 'FILE:EXT:'.'dlf/Configuration/Flexforms/PageGrid.xml'); - // Plugin "pageview". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_pageview'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_pageview'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_pageview', 'dlf_pageview'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_pageview', 'FILE:EXT:'.'dlf/Configuration/Flexforms/PageView.xml'); - // Plugin "search". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_search'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_search'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_search', 'dlf_search'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_search', 'FILE:EXT:'.'dlf/Configuration/Flexforms/Search.xml'); - // Plugin "statistics". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_statistics'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_statistics'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_statistics', 'dlf_statistics'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_statistics', 'FILE:EXT:'.'dlf/Configuration/Flexforms/Statistics.xml'); - // Plugin "tableofcontents". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_tableofcontents'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_tableofcontents'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_tableofcontents', 'dlf_tableofcontents'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_tableofcontents', 'FILE:EXT:'.'dlf/Configuration/Flexforms/TableOfContents.xml'); - // Plugin "toolbox". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_toolbox'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_toolbox'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_toolbox', 'dlf_toolbox'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_toolbox', 'FILE:EXT:'.'dlf/Configuration/Flexforms/Toolbox.xml'); - // Plugin "validator". $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_validator'] = 'layout,select_key,pages,recursive'; - $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_validator'] = 'pi_flexform'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(['LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tt_content.dlf_validator', 'dlf_validator'], 'list_type', 'dlf'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_validator', 'FILE:EXT:'.'dlf/Configuration/Flexforms/Validator.xml'); diff --git a/class.ext_update.php b/class.ext_update.php index fcab6e8a..576fdcd2 100644 --- a/class.ext_update.php +++ b/class.ext_update.php @@ -13,15 +13,15 @@ use Kitodo\Dlf\Common\Helper; use Kitodo\Dlf\Common\Solr; /** - * Update class 'ext_update' for the 'dlf' extension. + * Update class 'ext_update' for the 'dlf' extension * - * @author Sebastian Meyer - * @package TYPO3 - * @subpackage dlf - * @access public + * @author Sebastian Meyer + * @package TYPO3 + * @subpackage dlf + * @access public */ -class ext_update { - +class ext_update +{ /** * This holds the output ready to return * @@ -33,151 +33,132 @@ class ext_update { /** * Triggers the update option in the extension manager * - * @access public + * @access public * - * @return boolean Should the update option be shown? + * @return boolean Should the update option be shown? */ - public function access() { - - if (count($this->getMetadataConfig())) { - + public function access() + { + if (count($this->getMetadataConfig())) + { return TRUE; - - } else if ($this->oldIndexRelatedTableNames()) { - + } elseif ($this->oldIndexRelatedTableNames()) + { return TRUE; - - } else if ($this->solariumSolrUpdateRequired()) { - + } elseif ($this->solariumSolrUpdateRequired()) + { return TRUE; - - } else if (count($this->oldFormatClasses())) { - + } elseif (count($this->oldFormatClasses())) + { return TRUE; - } - return FALSE; - } /** * Get all outdated metadata configuration records * - * @access protected + * @access protected * - * @return array Array of UIDs of outdated records + * @return array Array of UIDs of outdated records */ - protected function getMetadataConfig() { - + protected function getMetadataConfig() + { $uids = []; - // check if tx_dlf_metadata.xpath exists anyhow $fieldsInDatabase = $GLOBALS['TYPO3_DB']->admin_get_fields('tx_dlf_metadata'); - - if (!in_array('xpath', array_keys($fieldsInDatabase))) { - + if (!in_array('xpath', array_keys($fieldsInDatabase))) + { return $uids; - } - // Get all records with outdated configuration. $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 'tx_dlf_metadata.uid AS uid', 'tx_dlf_metadata', - 'tx_dlf_metadata.format=0 AND NOT tx_dlf_metadata.xpath=""'.Helper::whereClause('tx_dlf_metadata'), + 'tx_dlf_metadata.format=0' + .' AND NOT tx_dlf_metadata.xpath=""' + .Helper::whereClause('tx_dlf_metadata'), '', '', '' ); - - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { - - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { - + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) + { + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) + { $uids[] = intval($resArray['uid']); - } - } - return $uids; - } /** * The main method of the class * - * @access public + * @access public * - * @return string The content that is displayed on the website + * @return string The content that is displayed on the website */ - public function main() { - + public function main() + { // Load localization file. $GLOBALS['LANG']->includeLLFile('EXT:dlf/Resources/Private/Language/FlashMessages.xml'); - // Update the metadata configuration. - if (count($this->getMetadataConfig())) { + if (count($this->getMetadataConfig())) + { $this->updateMetadataConfig(); } - - if ($this->oldIndexRelatedTableNames()) { + if ($this->oldIndexRelatedTableNames()) + { $this->renameIndexRelatedColumns(); } - - if ($this->solariumSolrUpdateRequired()) { + if ($this->solariumSolrUpdateRequired()) + { $this->doSolariumSolrUpdate(); } - - if (count($this->oldFormatClasses())) { + if (count($this->oldFormatClasses())) + { $this->updateFormatClasses(); } - return $this->content; - } /** * Check for old format classes * - * @access protected + * @access protected * - * @return boolean true if old format classes exist + * @return boolean true if old format classes exist */ - protected function oldFormatClasses() { - + protected function oldFormatClasses() + { $oldRecords = []; - // Get all records with outdated configuration. $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 'tx_dlf_formats.uid AS uid,tx_dlf_formats.type AS type', 'tx_dlf_formats', - 'tx_dlf_formats.class NOT LIKE "%\\%"'.Helper::whereClause('tx_dlf_formats'), + 'tx_dlf_formats.class NOT LIKE "%\\%"' + .Helper::whereClause('tx_dlf_formats'), '', '', '' ); - - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { - + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) + { $oldRecords[$resArray['uid']] = $resArray['type']; - } - return $oldRecords; - } /** * Check for old index related colums * - * @access protected + * @access protected * - * @return boolean true if old index related columns exist + * @return boolean TRUE if old index related columns exist */ - protected function oldIndexRelatedTableNames() { - + protected function oldIndexRelatedTableNames() + { $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 'column_name', 'INFORMATION_SCHEMA.COLUMNS', @@ -185,134 +166,114 @@ class ext_update { '', '', '' - ); - - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { - + ); + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) + { if ($resArray['column_name'] == 'tokenized' || $resArray['column_name'] == 'stored' || $resArray['column_name'] == 'indexed' || $resArray['column_name'] == 'boost' - || $resArray['column_name'] == 'autocomplete') { - + || $resArray['column_name'] == 'autocomplete') + { return TRUE; - } - } - } /** * Copy the data of the old index related columns to the new columns * - * @access protected + * @access protected * - * @return void + * @return void */ - protected function renameIndexRelatedColumns() { - - $sqlQuery = "UPDATE tx_dlf_metadata SET `index_tokenized` = `tokenized` - , `index_stored` = `stored` - , `index_indexed` = `indexed` - , `index_boost` = `boost` - , `index_autocomplete` = `autocomplete`"; - + protected function renameIndexRelatedColumns() + { + $sqlQuery = 'UPDATE tx_dlf_metadata' + .' SET `index_tokenized` = `tokenized`' + .', `index_stored` = `stored`' + .', `index_indexed` = `indexed`' + .', `index_boost` = `boost`' + .', `index_autocomplete` = `autocomplete`'; // Copy the content of the old tables to the new ones $result = $GLOBALS['TYPO3_DB']->sql_query($sqlQuery); - - if ($result) { - + if ($result) + { $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( \TYPO3\CMS\Core\Messaging\FlashMessage::class, $GLOBALS['LANG']->getLL('update.copyIndexRelatedColumnsOkay', TRUE), $GLOBALS['LANG']->getLL('update.copyIndexRelatedColumns', TRUE), \TYPO3\CMS\Core\Messaging\FlashMessage::OK, FALSE - ); - + ); } else { - $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( \TYPO3\CMS\Core\Messaging\FlashMessage::class, $GLOBALS['LANG']->getLL('update.copyIndexRelatedColumnsNotOkay', TRUE), $GLOBALS['LANG']->getLL('update.copyIndexRelatedColumns', TRUE), \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, FALSE - ); - + ); } - $this->content .= $message->render(); - } /** * Update all outdated format records * - * @access protected + * @access protected * - * @return void + * @return void */ - protected function updateFormatClasses() { - + protected function updateFormatClasses() + { $oldRecords = $this->oldFormatClasses(); - $newValues = [ 'ALTO' => 'Kitodo\\Dlf\\Formats\\Alto', 'MODS' => 'Kitodo\\Dlf\\Formats\\Mods', 'TEIHDR' => 'Kitodo\\Dlf\\Formats\\TeiHeader' ]; - - foreach ($oldRecords as $uid => $type) { - + foreach ($oldRecords as $uid => $type) + { $sqlQuery = 'UPDATE tx_dlf_formats SET class="'.$newValues[$type].'" WHERE uid='.$uid; - $GLOBALS['TYPO3_DB']->sql_query($sqlQuery); - } - $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( \TYPO3\CMS\Core\Messaging\FlashMessage::class, $GLOBALS['LANG']->getLL('update.FormatClassesOkay', TRUE), $GLOBALS['LANG']->getLL('update.FormatClasses', TRUE), \TYPO3\CMS\Core\Messaging\FlashMessage::OK, FALSE - ); - + ); $this->content .= $message->render(); - } /** * Update all outdated metadata configuration records * - * @access protected + * @access protected * - * @return void + * @return void */ - protected function updateMetadataConfig() { - + protected function updateMetadataConfig() + { $metadataUids = $this->getMetadataConfig(); - - if (!empty($metadataUids)) { - + if (!empty($metadataUids)) + { $data = []; - // Get all old metadata configuration records. $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 'tx_dlf_metadata.uid AS uid,tx_dlf_metadata.pid AS pid,tx_dlf_metadata.cruser_id AS cruser_id,tx_dlf_metadata.encoded AS encoded,tx_dlf_metadata.xpath AS xpath,tx_dlf_metadata.xpath_sorting AS xpath_sorting', 'tx_dlf_metadata', - 'tx_dlf_metadata.uid IN ('.implode(',', $metadataUids).')'.Helper::whereClause('tx_dlf_metadata'), + 'tx_dlf_metadata.uid IN ('.implode(',', $metadataUids).')' + .Helper::whereClause('tx_dlf_metadata'), '', '', '' ); - - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { - + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) + { $newId = uniqid('NEW'); - // Copy record to new table. $data['tx_dlf_metadataformat'][$newId] = [ 'pid' => $resArray['pid'], @@ -322,21 +283,16 @@ class ext_update { 'xpath' => $resArray['xpath'], 'xpath_sorting' => $resArray['xpath_sorting'] ]; - // Add reference to old table. $data['tx_dlf_metadata'][$resArray['uid']]['format'] = $newId; - } - - if (!empty($data)) { - + if (!empty($data)) + { // Process datamap. $substUids = Helper::processDBasAdmin($data); - unset ($data); - - if (!empty($substUids)) { - + if (!empty($substUids)) + { $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( \TYPO3\CMS\Core\Messaging\FlashMessage::class, $GLOBALS['LANG']->getLL('update.metadataConfigOkay', TRUE), @@ -344,9 +300,7 @@ class ext_update { \TYPO3\CMS\Core\Messaging\FlashMessage::OK, FALSE ); - } else { - $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( \TYPO3\CMS\Core\Messaging\FlashMessage::class, $GLOBALS['LANG']->getLL('update.metadataConfigNotOkay', TRUE), @@ -354,146 +308,114 @@ class ext_update { \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, FALSE ); - } - $this->content .= $message->render(); - } - } - } /** * Check all configured Solr cores * - * @access protected + * @access protected * - * @return boolean + * @return boolean */ - protected function solariumSolrUpdateRequired() { - + protected function solariumSolrUpdateRequired() + { // Get all Solr cores that were not deleted. $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 'index_name', 'tx_dlf_solrcores', - 'deleted = 0', + 'deleted=0', '', '', '' - ); - - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { - + ); + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) + { // Instantiate search object. $solr = Solr::getInstance($resArray['index_name']); - - if (!$solr->ready) { - + if (!$solr->ready) + { return TRUE; - } - } - return FALSE; - } /** * Create all configured Solr cores * - * @access protected + * @access protected * - * @return void + * @return void */ - protected function doSolariumSolrUpdate() { - + protected function doSolariumSolrUpdate() + { // Get all Solr cores that were not deleted. $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 'index_name', 'tx_dlf_solrcores', - 'deleted = 0', + 'deleted=0', '', '', '' - ); - - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { - + ); + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) + { // Instantiate search object. $solr = Solr::getInstance($resArray['index_name']); - - if (!$solr->ready) { - + if (!$solr->ready) + { $conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dlf']); - $solrInfo = Solr::getSolrConnectionInfo(); - // Prepend username and password to hostname. - if ($solrInfo['username'] && $solrInfo['password']) { - + if ($solrInfo['username'] + && $solrInfo['password']) + { $host = $solrInfo['username'].':'.$solrInfo['password'].'@'.$solrInfo['host']; - } else { - $host = $solrInfo['host']; - } - $context = stream_context_create([ 'http' => [ 'method' => 'GET', 'user_agent' => ($conf['useragent'] ? $conf['useragent'] : ini_get('user_agent')) ] ]); - // Build request for adding new Solr core. // @see http://wiki.apache.org/solr/CoreAdmin $url = $solrInfo['scheme'].'://'.$host.':'.$solrInfo['port'].'/'.$solrInfo['path'].'/admin/cores?wt=xml&action=CREATE&name='.$resArray['index_name'].'&instanceDir=dlfCore'.$resArray['index_name'].'&dataDir=data&configSet=dlf'; - $response = @simplexml_load_string(file_get_contents($url, FALSE, $context)); - // Process response. - if ($response) { - + if ($response) + { $status = $response->xpath('//lst[@name="responseHeader"]/int[@name="status"]'); - - if ($status && $status[0] == 0) { - + if ($status + && $status[0] == 0) + { continue; - } - } - $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( \TYPO3\CMS\Core\Messaging\FlashMessage::class, $GLOBALS['LANG']->getLL('update.solariumSolrUpdateNotOkay', TRUE), sprintf($GLOBALS['LANG']->getLL('update.solariumSolrUpdate', TRUE), $resArray['index_name']), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, FALSE - ); - + ); $this->content .= $message->render(); - return; - } - } - $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( \TYPO3\CMS\Core\Messaging\FlashMessage::class, $GLOBALS['LANG']->getLL('update.solariumSolrUpdateOkay', TRUE), $GLOBALS['LANG']->getLL('update.solariumSolrUpdate', TRUE), \TYPO3\CMS\Core\Messaging\FlashMessage::OK, FALSE - ); - + ); $this->content .= $message->render(); - } - } diff --git a/ext_conf_template.txt b/ext_conf_template.txt index c0d8d788..368c0053 100644 --- a/ext_conf_template.txt +++ b/ext_conf_template.txt @@ -1,59 +1,40 @@ # cat=Basic; type=user[EXT:dlf/Classes/Hooks/ConfigurationForm.php:ConfigurationForm->checkMetadataFormats]; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.metadataFormats metadataFormats = 0 - # cat=Basic; type=user[EXT:dlf/Classes/Hooks/ConfigurationForm.php:ConfigurationForm->checkCliUserGroup]; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.cliUserGroup cliUserGroup = 0 - # cat=Basic; type=boolean; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.makeCliUserGroup makeCliUserGroup = 0 - # cat=Basic; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.useragent useragent = Kitodo.Presentation - # cat=Basic; type=boolean; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.caching caching = 0 - # cat=Basic; type=boolean; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.publishNewCollections 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.fileGrpThumbs fileGrpThumbs = THUMBS - # cat=Files; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.fileGrpDownload fileGrpDownload = DOWNLOAD - # cat=Files; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.fileGrpFulltext fileGrpFulltext = FULLTEXT - # cat=Files; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.fileGrpAudio fileGrpAudio = AUDIO - # cat=Solr; type=user[EXT:dlf/Classes/Hooks/ConfigurationForm.php:ConfigurationForm->checkSolrConnection]; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.solrConnect solrConnect = 0 - # cat=Solr; type=boolean; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.solrHttps solrHttps = 0 - # cat=Solr; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.solrHost solrHost = localhost - # cat=Solr; type=int[0-65535]; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.solrPort solrPort = 8983 - # cat=Solr; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.solrPath solrPath = /solr/ - # cat=Solr; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.solrUser solrUser = - # cat=Solr; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.solrPass solrPass = - # cat=Solr; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.solrTimeout solrTimeout = 10 diff --git a/ext_localconf.php b/ext_localconf.php index fe4dfd66..71c6b0fd 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -9,95 +9,68 @@ * LICENSE.txt file that was distributed with this source code. */ -if (!defined('TYPO3_MODE')) { +if (!defined('TYPO3_MODE')) +{ die ('Access denied.'); } - // Register plugins. \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/AudioPlayer.php', '_audioplayer', 'list_type', TRUE); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/Basket.php', '_basket', 'list_type', FALSE); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/Calendar.php', '_calendar', 'list_type', TRUE); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/Collection.php', '_collection', 'list_type', TRUE); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/Feeds.php', '_feeds', 'list_type', FALSE); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/ListView.php', '_listview', 'list_type', FALSE); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/Metadata.php', '_metadata', 'list_type', TRUE); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/Navigation.php', '_navigation', 'list_type', TRUE); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/OaiPmh.php', '_oaipmh', 'list_type', FALSE); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/PageGrid.php', '_pagegrid', 'list_type', TRUE); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/PageView.php', '_pageview', 'list_type', TRUE); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/Search.php', '_search', 'list_type', TRUE); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/Statistics.php', '_statistics', 'list_type', TRUE); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/TableOfContents.php', '_tableofcontents', 'list_type', TRUE); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/Toolbox.php', '_toolbox', 'list_type', TRUE); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/Validator.php', '_validator', 'list_type', FALSE); - // Register tools for toolbox plugin. \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/Tools/FulltextTool.php', '_toolsFulltext', '', TRUE); $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/plugins/toolbox/tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY).'_toolsFulltext'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.toolsFulltext'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/Tools/ImageDownloadTool.php', '_toolsImageDownload', '', TRUE); $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/plugins/toolbox/tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY).'_toolsImageDownload'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.toolsImageDownload'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/Tools/ImageManipulationTool.php', '_toolsImageManipulation', '', TRUE); $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/plugins/toolbox/tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY).'_toolsImageManipulation'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.toolsImageManipulation'; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'Classes/Plugins/Tools/PdfDownloadTool.php', '_toolsPdfDownload', '', TRUE); $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/plugins/toolbox/tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY).'_toolsPdfDownload'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.toolsPdfDownload'; - // Register hooks. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:'.$_EXTKEY.'/Classes/Hooks/DataHandler.php:DataHandler'; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = 'EXT:'.$_EXTKEY.'/Classes/Hooks/DataHandler.php:DataHandler'; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Common/Document.php']['hookClass'][] = 'EXT:'.$_EXTKEY.'/Classes/Hooks/KitodoProductionHacks.php:KitodoProductionHacks'; - // Register command line scripts. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['cliKeys'][$_EXTKEY] = [ - function () { + function () + { $SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Kitodo\Dlf\Cli\CommandLineIndexer::class); $SOBE->main(); }, '_CLI_dlf' ]; - // Register AJAX eID handlers. $GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['tx_dlf_search_suggest'] = \Kitodo\Dlf\Plugins\Eid\SearchSuggest::class.'::main'; - $GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['tx_dlf_pageview_proxy'] = \Kitodo\Dlf\Plugins\Eid\PageViewProxy::class.'::main'; - -if (TYPO3_MODE === 'FE') { - +// Register Typoscript user function. +if (TYPO3_MODE === 'FE') +{ /** * docTypeCheck user function to use in Typoscript * @example [userFunc = user_dlf_docTypeCheck($type)] * - * @access public + * @access public * - * @param string $type: document type string to test for + * @param string $type: document type string to test for * - * @return boolean TRUE if document type matches, FALSE if not + * @return boolean TRUE if document type matches, FALSE if not */ - function user_dlf_docTypeCheck($type) { - + function user_dlf_docTypeCheck($type) + { $hook = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Kitodo\Dlf\Common\DocumentTypeCheck::class); - return ($hook->getDocType() === $type); - } - }