You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

264 lines
12 KiB

  1. <?php
  2. /**
  3. * (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
  4. *
  5. * This file is part of the Kitodo and TYPO3 projects.
  6. *
  7. * @license GNU General Public License version 3 or later.
  8. * For the full copyright and license information, please read the
  9. * LICENSE.txt file that was distributed with this source code.
  10. */
  11. if (!defined('TYPO3_MODE')) {
  12. die('Access denied.');
  13. }
  14. // Define constants.
  15. if (!defined('DEVLOG_SEVERITY_OK')) {
  16. define('DEVLOG_SEVERITY_OK', -1);
  17. }
  18. if (!defined('DEVLOG_SEVERITY_INFO')) {
  19. define('DEVLOG_SEVERITY_INFO', 0);
  20. }
  21. if (!defined('DEVLOG_SEVERITY_NOTICE')) {
  22. define('DEVLOG_SEVERITY_NOTICE', 1);
  23. }
  24. if (!defined('DEVLOG_SEVERITY_WARNING')) {
  25. define('DEVLOG_SEVERITY_WARNING', 2);
  26. }
  27. if (!defined('DEVLOG_SEVERITY_ERROR')) {
  28. define('DEVLOG_SEVERITY_ERROR', 3);
  29. }
  30. // Register plugins without addPItoST43() as this is not working with TYPO3 9.
  31. \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup(
  32. '
  33. plugin.tx_dlf_audioplayer = USER
  34. plugin.tx_dlf_audioplayer {
  35. userFunc = Kitodo\Dlf\Plugin\AudioPlayer->main
  36. }
  37. tt_content.list.20.dlf_audioplayer < plugin.tx_dlf_audioplayer
  38. plugin.tx_dlf_basket = USER_INT
  39. plugin.tx_dlf_basket {
  40. userFunc = Kitodo\Dlf\Plugin\Basket->main
  41. }
  42. tt_content.list.20.dlf_basket < plugin.tx_dlf_basket
  43. plugin.tx_dlf_calendar = USER
  44. plugin.tx_dlf_calendar {
  45. userFunc = Kitodo\Dlf\Plugin\Calendar->main
  46. }
  47. tt_content.list.20.dlf_calendar < plugin.tx_dlf_calendar
  48. plugin.tx_dlf_collection = USER
  49. plugin.tx_dlf_collection {
  50. userFunc = Kitodo\Dlf\Plugin\Collection->main
  51. }
  52. tt_content.list.20.dlf_collection < plugin.tx_dlf_collection
  53. plugin.tx_dlf_feeds = USER_INT
  54. plugin.tx_dlf_feeds {
  55. userFunc = Kitodo\Dlf\Plugin\Feeds->main
  56. }
  57. tt_content.list.20.dlf_feeds < plugin.tx_dlf_feeds
  58. plugin.tx_dlf_listview = USER_INT
  59. plugin.tx_dlf_listview {
  60. userFunc = Kitodo\Dlf\Plugin\ListView->main
  61. }
  62. tt_content.list.20.dlf_listview < plugin.tx_dlf_listview
  63. plugin.tx_dlf_metadata = USER
  64. plugin.tx_dlf_metadata {
  65. userFunc = Kitodo\Dlf\Plugin\Metadata->main
  66. }
  67. tt_content.list.20.dlf_metadata < plugin.tx_dlf_metadata
  68. plugin.tx_dlf_navigation = USER
  69. plugin.tx_dlf_navigation {
  70. userFunc = Kitodo\Dlf\Plugin\Navigation->main
  71. }
  72. tt_content.list.20.dlf_navigation < plugin.tx_dlf_navigation
  73. plugin.tx_dlf_oaipmh = USER_INT
  74. plugin.tx_dlf_oaipmh {
  75. userFunc = Kitodo\Dlf\Plugin\OaiPmh->main
  76. }
  77. tt_content.list.20.dlf_oaipmh < plugin.tx_dlf_oaipmh
  78. plugin.tx_dlf_pagegrid = USER
  79. plugin.tx_dlf_pagegrid {
  80. userFunc = Kitodo\Dlf\Plugin\PageGrid->main
  81. }
  82. tt_content.list.20.dlf_pagegrid < plugin.tx_dlf_pagegrid
  83. plugin.tx_dlf_pageview = USER
  84. plugin.tx_dlf_pageview {
  85. userFunc = Kitodo\Dlf\Plugin\PageView->main
  86. }
  87. tt_content.list.20.dlf_pageview < plugin.tx_dlf_pageview
  88. plugin.tx_dlf_search = USER
  89. plugin.tx_dlf_search {
  90. userFunc = Kitodo\Dlf\Plugin\Search->main
  91. }
  92. tt_content.list.20.dlf_search < plugin.tx_dlf_search
  93. plugin.tx_dlf_statistics = USER
  94. plugin.tx_dlf_statistics {
  95. userFunc = Kitodo\Dlf\Plugin\Statistics->main
  96. }
  97. tt_content.list.20.dlf_statistics < plugin.tx_dlf_statistics
  98. plugin.tx_dlf_tableofcontents = USER
  99. plugin.tx_dlf_tableofcontents {
  100. userFunc = Kitodo\Dlf\Plugin\TableOfContents->main
  101. }
  102. tt_content.list.20.dlf_tableofcontents < plugin.tx_dlf_tableofcontents
  103. plugin.tx_dlf_toolbox = USER
  104. plugin.tx_dlf_toolbox {
  105. userFunc = Kitodo\Dlf\Plugin\Toolbox->main
  106. }
  107. tt_content.list.20.dlf_toolbox < plugin.tx_dlf_toolbox
  108. plugin.tx_dlf_validator = USER_INT
  109. plugin.tx_dlf_validator {
  110. userFunc = Kitodo\Dlf\Plugin\Validator->main
  111. }
  112. tt_content.list.20.dlf_validator < plugin.tx_dlf_validator
  113. plugin.tx_dlf_fulltexttool = USER
  114. plugin.tx_dlf_fulltexttool {
  115. userFunc = Kitodo\Dlf\Plugin\Tools\FulltextTool->main
  116. }
  117. tt_content.list.20.dlf_fulltexttool < plugin.tx_dlf_fulltexttool
  118. plugin.tx_dlf_annotationtool = USER
  119. plugin.tx_dlf_annotationtool {
  120. userFunc = Kitodo\Dlf\Plugin\Tools\AnnotationTool->main
  121. }
  122. tt_content.list.20.dlf_annotationtool < plugin.tx_dlf_annotationtool
  123. plugin.tx_dlf_fulltextdownloadtool = USER
  124. plugin.tx_dlf_fulltextdownloadtool {
  125. userFunc = Kitodo\Dlf\Plugin\Tools\FulltextDownloadTool->main
  126. }
  127. tt_content.list.20.dlf_fulltextdownloadtool < plugin.tx_dlf_fulltextdownloadtool
  128. plugin.tx_dlf_imagedownloadtool = USER
  129. plugin.tx_dlf_imagedownloadtool {
  130. userFunc = Kitodo\Dlf\Plugin\Tools\ImageDownloadTool->main
  131. }
  132. tt_content.list.20.dlf_imagedownloadtool < plugin.tx_dlf_imagedownloadtool
  133. plugin.tx_dlf_imagemanipulationtool = USER
  134. plugin.tx_dlf_imagemanipulationtool {
  135. userFunc = Kitodo\Dlf\Plugin\Tools\ImageManipulationTool->main
  136. }
  137. tt_content.list.20.dlf_imagemanipulationtool < plugin.tx_dlf_imagemanipulationtool
  138. plugin.tx_dlf_pdfdownloadtool = USER
  139. plugin.tx_dlf_pdfdownloadtool {
  140. userFunc = Kitodo\Dlf\Plugin\Tools\PdfDownloadTool->main
  141. }
  142. tt_content.list.20.dlf_pdfdownloadtool < plugin.tx_dlf_pdfdownloadtool
  143. plugin.tx_dlf_searchindocumenttool = USER
  144. plugin.tx_dlf_searchindocumenttool {
  145. userFunc = Kitodo\Dlf\Plugin\Tools\SearchInDocumentTool->main
  146. }
  147. tt_content.list.20.dlf_searchindocumenttool < plugin.tx_dlf_searchindocumenttool
  148. '
  149. );
  150. // Register plugin icons.
  151. $iconArray = [
  152. 'tx-dlf-audioplayer' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-audioplayer.svg',
  153. 'tx-dlf-basket' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-basket.svg',
  154. 'tx-dlf-calendar' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-calendar.svg',
  155. 'tx-dlf-collection' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-collection.svg',
  156. 'tx-dlf-feeds' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-feeds.svg',
  157. 'tx-dlf-listview' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-listview.svg',
  158. 'tx-dlf-metadata' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-metadata.svg',
  159. 'tx-dlf-navigation' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-navigation.svg',
  160. 'tx-dlf-oaipmh' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-oaipmh.svg',
  161. 'tx-dlf-pagegrid' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-pagegrid.svg',
  162. 'tx-dlf-pageview' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-pageview.svg',
  163. 'tx-dlf-search' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-search.svg',
  164. 'tx-dlf-statistics' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-statistics.svg',
  165. 'tx-dlf-tableofcontents' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-tableofcontents.svg',
  166. 'tx-dlf-toolbox' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-toolbox.svg',
  167. 'tx-dlf-validator' => 'EXT:dlf/Resources/Public/Icons/tx-dlf-validator.svg',
  168. ];
  169. $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
  170. \TYPO3\CMS\Core\Imaging\IconRegistry::class
  171. );
  172. foreach ($iconArray as $key => $value) {
  173. $iconRegistry->registerIcon(
  174. $key,
  175. \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
  176. ['source' => $value]
  177. );
  178. }
  179. // Register plugins as content elements.
  180. \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
  181. '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:dlf/Configuration/TsConfig/ContentElements.tsconfig">'
  182. );
  183. // Register tools for toolbox plugin.
  184. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'] = [];
  185. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_fulltexttool'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.fulltexttool';
  186. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_annotationtool'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.annotationtool';
  187. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_fulltextdownloadtool'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.fulltextdownloadtool';
  188. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_imagedownloadtool'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.imagedownloadtool';
  189. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_imagemanipulationtool'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.imagemanipulationtool';
  190. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_pdfdownloadtool'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.pdfdownloadtool';
  191. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_searchindocumenttool'] = 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_toolbox.searchindocumenttool';
  192. // Register hooks.
  193. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = \Kitodo\Dlf\Hooks\DataHandler::class;
  194. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = \Kitodo\Dlf\Hooks\DataHandler::class;
  195. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Common/MetsDocument.php']['hookClass'][] = \Kitodo\Dlf\Hooks\KitodoProductionHacks::class;
  196. // Register AJAX eID handlers.
  197. $GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['tx_dlf_search_suggest'] = \Kitodo\Dlf\Plugin\Eid\SearchSuggest::class . '::main';
  198. $GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['tx_dlf_search_in_document'] = \Kitodo\Dlf\Plugin\Eid\SearchInDocument::class . '::main';
  199. $GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['tx_dlf_pageview_proxy'] = \Kitodo\Dlf\Plugin\Eid\PageViewProxy::class . '::main';
  200. // Use Caching Framework for Solr queries
  201. if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_dlf_solr'])) {
  202. $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_dlf_solr'] = [];
  203. }
  204. if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_dlf_solr']['backend'])) {
  205. $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_dlf_solr']['backend'] = 'TYPO3\\CMS\\Core\\Cache\\Backend\\SimpleFileBackend';
  206. }
  207. if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_dlf_solr']['options']['defaultLifeTime'])) {
  208. $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['tx_dlf_solr']['options']['defaultLifeTime'] = 87600; // 87600 seconds = 1 day
  209. }
  210. // Register Typoscript user function.
  211. if (\TYPO3_MODE === 'FE') {
  212. /**
  213. * docTypeCheck user function to use in Typoscript
  214. * @example [userFunc = user_dlf_docTypeCheck($type, $pid)]
  215. *
  216. * @access public
  217. *
  218. * @param string $type The document type string to test for
  219. * @param int $pid The PID for the metadata definitions
  220. *
  221. * @return bool true if document type matches, false if not
  222. */
  223. function user_dlf_docTypeCheck(string $type, int $pid): bool
  224. {
  225. $hook = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Kitodo\Dlf\Hooks\UserFunc::class);
  226. return ($hook->getDocumentType($pid) === $type);
  227. }
  228. }
  229. // Add new renderType for TCA fields.
  230. $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][] = [
  231. 'nodeName' => 'editInProductionWarning',
  232. 'priority' => 30,
  233. 'class' => \Kitodo\Dlf\Hooks\Form\FieldInformation\EditInProductionWarning::class
  234. ];
  235. $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][] = [
  236. 'nodeName' => 'solrCoreStatus',
  237. 'priority' => 30,
  238. 'class' => \Kitodo\Dlf\Hooks\Form\FieldInformation\SolrCoreStatus::class
  239. ];