Update code style

This commit is contained in:
Sebastian Meyer 2019-03-14 20:53:16 +01:00
parent 22051dc584
commit 425aedde5a
11 changed files with 323 additions and 620 deletions

View File

@ -12,16 +12,15 @@ 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 <alexander.bigga@slub-dresden.de>
* @copyright Copyright (c) 2015, Alexander Bigga, SLUB Dresden
* @package TYPO3
* @subpackage tx_dlf
* @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';
/**
@ -34,33 +33,27 @@ class PageViewProxy extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
*
* @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;
}
}

View File

@ -15,7 +15,7 @@ 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 <dev@mentalmotive.com>
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
@ -23,8 +23,8 @@ use Kitodo\Dlf\Common\Solr;
* @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';
/**
@ -37,30 +37,22 @@ class SearchSuggest extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
*
* @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;
}
}

View File

@ -14,7 +14,7 @@ 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 <sebastian.meyer@slub-dresden.de>
* @author Alexander Bigga <alexander.bigga@slub-dresden.de>
@ -22,8 +22,8 @@ use Kitodo\Dlf\Common\Helper;
* @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';
/**
@ -36,64 +36,47 @@ class FulltextTool extends \Kitodo\Dlf\Common\AbstractPlugin {
*
* @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###'] = '<a class="select switchoff" id="tx-dlf-tools-fulltext" title="" data-dic="fulltext-on:'
.$this->pi_getLL('fulltext-on', '', TRUE).';fulltext-off:'
.$this->pi_getLL('fulltext-off', '', TRUE).'">&nbsp;</a>';
if (!empty($fullTextFile))
{
$markerArray['###FULLTEXT_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-fulltext" title="" data-dic="fulltext-on:'.$this->pi_getLL('fulltext-on', '', TRUE).';fulltext-off:'.$this->pi_getLL('fulltext-off', '', TRUE).'">&nbsp;</a>';
} else {
$markerArray['###FULLTEXT_SELECT###'] = '<span class="no-fulltext">'.$this->pi_getLL('fulltext-not-available', '', TRUE).'</span>';
}
$content .= $this->cObj->substituteMarkerArray($this->template, $markerArray);
return $this->pi_wrapInBaseClass($content);
}
}

View File

@ -14,15 +14,15 @@ 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 <alexander.bigga@slub-dresden.de>
* @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';
/**
@ -35,63 +35,47 @@ class ImageDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin {
*
* @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
*
@ -100,55 +84,45 @@ class ImageDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin {
* @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)';
case 'image/tiff':
$mimetypeLabel = '(TIFF)';
break;
default: $mimetypeLabel = '';
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;
}
}

View File

@ -14,15 +14,15 @@ 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 <Jacob.Mendt@slub-dresden.de>
* @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';
/**
@ -35,34 +35,15 @@ class ImageManipulationTool extends \Kitodo\Dlf\Common\AbstractPlugin {
*
* @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###'] = '<span class="tx-dlf-tools-imagetools" id="tx-dlf-tools-imagetools" data-dic="imagemanipulation-on:'
.$this->pi_getLL('imagemanipulation-on', '', TRUE).';imagemanipulation-off:'
.$this->pi_getLL('imagemanipulation-off', '', TRUE).';reset:'
.$this->pi_getLL('reset', '', TRUE).';saturation:'
.$this->pi_getLL('saturation', '', TRUE).';hue:'
.$this->pi_getLL('hue', '', TRUE).';contrast:'
.$this->pi_getLL('contrast', '', TRUE).';brightness:'
.$this->pi_getLL('brightness', '', TRUE).';invert:'
.$this->pi_getLL('invert', '', TRUE).'" title="'
.$this->pi_getLL('no-support', '', TRUE).'"></span>';
$markerArray['###IMAGEMANIPULATION_SELECT###'] = '<span class="tx-dlf-tools-imagetools" id="tx-dlf-tools-imagetools" data-dic="imagemanipulation-on:'.$this->pi_getLL('imagemanipulation-on', '', TRUE).';imagemanipulation-off:'.$this->pi_getLL('imagemanipulation-off', '', TRUE).';reset:'.$this->pi_getLL('reset', '', TRUE).';saturation:'.$this->pi_getLL('saturation', '', TRUE).';hue:'.$this->pi_getLL('hue', '', TRUE).';contrast:'.$this->pi_getLL('contrast', '', TRUE).';brightness:'.$this->pi_getLL('brightness', '', TRUE).';invert:'.$this->pi_getLL('invert', '', TRUE).'" title="'.$this->pi_getLL('no-support', '', TRUE).'"></span>';
$content .= $this->cObj->substituteMarkerArray($this->template, $markerArray);
return $this->pi_wrapInBaseClass($content);
}
}

View File

@ -14,7 +14,7 @@ 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 <sebastian.meyer@slub-dresden.de>
* @author Alexander Bigga <alexander.bigga@slub-dresden.de>
@ -22,8 +22,8 @@ use Kitodo\Dlf\Common\Helper;
* @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';
/**
@ -36,60 +36,45 @@ class PdfDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin {
*
* @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);
}
/**
@ -99,51 +84,49 @@ class PdfDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin {
*
* @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;
}
@ -154,44 +137,30 @@ class PdfDownloadTool extends \Kitodo\Dlf\Common\AbstractPlugin {
*
* @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;
}
}

View File

@ -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/',

View File

@ -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');

View File

@ -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 <sebastian.meyer@slub-dresden.de>
* @package TYPO3
* @subpackage dlf
* @access public
*/
class ext_update {
class ext_update
{
/**
* This holds the output ready to return
*
@ -37,28 +37,22 @@ class ext_update {
*
* @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;
}
/**
@ -68,41 +62,34 @@ class ext_update {
*
* @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;
}
/**
@ -112,30 +99,28 @@ class ext_update {
*
* @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;
}
/**
@ -145,28 +130,24 @@ class ext_update {
*
* @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;
}
/**
@ -174,10 +155,10 @@ class ext_update {
*
* @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',
@ -186,21 +167,17 @@ 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;
}
}
}
/**
@ -210,19 +187,18 @@ class ext_update {
*
* @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),
@ -230,9 +206,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.copyIndexRelatedColumnsNotOkay', TRUE),
@ -240,11 +214,8 @@ class ext_update {
\TYPO3\CMS\Core\Messaging\FlashMessage::WARNING,
FALSE
);
}
$this->content .= $message->render();
}
/**
@ -254,24 +225,19 @@ class ext_update {
*
* @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),
@ -279,9 +245,7 @@ class ext_update {
\TYPO3\CMS\Core\Messaging\FlashMessage::OK,
FALSE
);
$this->content .= $message->render();
}
/**
@ -291,28 +255,25 @@ class ext_update {
*
* @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,15 +308,10 @@ class ext_update {
\TYPO3\CMS\Core\Messaging\FlashMessage::WARNING,
FALSE
);
}
$this->content .= $message->render();
}
}
}
/**
@ -372,33 +321,27 @@ class ext_update {
*
* @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;
}
/**
@ -408,66 +351,53 @@ class ext_update {
*
* @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),
@ -475,15 +405,10 @@ class ext_update {
\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),
@ -491,9 +416,6 @@ class ext_update {
\TYPO3\CMS\Core\Messaging\FlashMessage::OK,
FALSE
);
$this->content .= $message->render();
}
}

View File

@ -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

View File

@ -9,79 +9,55 @@
* 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)]
@ -92,12 +68,9 @@ if (TYPO3_MODE === 'FE') {
*
* @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);
}
}