We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -12,45 +12,45 @@ |
||
| 12 | 12 | $extensionPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('dlf'); |
| 13 | 13 | |
| 14 | 14 | return array ( |
| 15 | - 'tx_dlf_cli' => $extensionPath.'cli/class.tx_dlf_cli.php', |
|
| 16 | - 'tx_dlf_alto' => $extensionPath.'common/class.tx_dlf_alto.php', |
|
| 17 | - 'tx_dlf_document' => $extensionPath.'common/class.tx_dlf_document.php', |
|
| 18 | - 'tx_dlf_format' => $extensionPath.'common/class.tx_dlf_format.php', |
|
| 19 | - 'tx_dlf_fulltext' => $extensionPath.'common/class.tx_dlf_fulltext.php', |
|
| 20 | - 'tx_dlf_helper' => $extensionPath.'common/class.tx_dlf_helper.php', |
|
| 21 | - 'tx_dlf_indexing' => $extensionPath.'common/class.tx_dlf_indexing.php', |
|
| 22 | - 'tx_dlf_list' => $extensionPath.'common/class.tx_dlf_list.php', |
|
| 23 | - 'tx_dlf_mods' => $extensionPath.'common/class.tx_dlf_mods.php', |
|
| 24 | - 'tx_dlf_module' => $extensionPath.'common/class.tx_dlf_module.php', |
|
| 25 | - 'tx_dlf_plugin' => $extensionPath.'common/class.tx_dlf_plugin.php', |
|
| 26 | - 'tx_dlf_solr' => $extensionPath.'common/class.tx_dlf_solr.php', |
|
| 27 | - 'tx_dlf_teihdr' => $extensionPath.'common/class.tx_dlf_teihdr.php', |
|
| 28 | - 'tx_dlf_doctype' => $extensionPath.'hooks/class.tx_dlf_doctype.php', |
|
| 29 | - 'tx_dlf_em' => $extensionPath.'hooks/class.tx_dlf_em.php', |
|
| 30 | - 'tx_dlf_hacks' => $extensionPath.'hooks/class.tx_dlf_hacks.php', |
|
| 31 | - 'tx_dlf_tceforms' => $extensionPath.'hooks/class.tx_dlf_tceforms.php', |
|
| 32 | - 'tx_dlf_tcemain' => $extensionPath.'hooks/class.tx_dlf_tcemain.php', |
|
| 33 | - 'tx_dlf_modIndexing' => $extensionPath.'modules/indexing/index.php', |
|
| 34 | - 'tx_dlf_modNewclient' => $extensionPath.'modules/newclient/index.php', |
|
| 35 | - 'tx_dlf_audioplayer' => $extensionPath.'plugins/audioplayer/class.tx_dlf_audioplayer.php', |
|
| 15 | + 'tx_dlf_cli' => $extensionPath.'cli/class.tx_dlf_cli.php', |
|
| 16 | + 'tx_dlf_alto' => $extensionPath.'common/class.tx_dlf_alto.php', |
|
| 17 | + 'tx_dlf_document' => $extensionPath.'common/class.tx_dlf_document.php', |
|
| 18 | + 'tx_dlf_format' => $extensionPath.'common/class.tx_dlf_format.php', |
|
| 19 | + 'tx_dlf_fulltext' => $extensionPath.'common/class.tx_dlf_fulltext.php', |
|
| 20 | + 'tx_dlf_helper' => $extensionPath.'common/class.tx_dlf_helper.php', |
|
| 21 | + 'tx_dlf_indexing' => $extensionPath.'common/class.tx_dlf_indexing.php', |
|
| 22 | + 'tx_dlf_list' => $extensionPath.'common/class.tx_dlf_list.php', |
|
| 23 | + 'tx_dlf_mods' => $extensionPath.'common/class.tx_dlf_mods.php', |
|
| 24 | + 'tx_dlf_module' => $extensionPath.'common/class.tx_dlf_module.php', |
|
| 25 | + 'tx_dlf_plugin' => $extensionPath.'common/class.tx_dlf_plugin.php', |
|
| 26 | + 'tx_dlf_solr' => $extensionPath.'common/class.tx_dlf_solr.php', |
|
| 27 | + 'tx_dlf_teihdr' => $extensionPath.'common/class.tx_dlf_teihdr.php', |
|
| 28 | + 'tx_dlf_doctype' => $extensionPath.'hooks/class.tx_dlf_doctype.php', |
|
| 29 | + 'tx_dlf_em' => $extensionPath.'hooks/class.tx_dlf_em.php', |
|
| 30 | + 'tx_dlf_hacks' => $extensionPath.'hooks/class.tx_dlf_hacks.php', |
|
| 31 | + 'tx_dlf_tceforms' => $extensionPath.'hooks/class.tx_dlf_tceforms.php', |
|
| 32 | + 'tx_dlf_tcemain' => $extensionPath.'hooks/class.tx_dlf_tcemain.php', |
|
| 33 | + 'tx_dlf_modIndexing' => $extensionPath.'modules/indexing/index.php', |
|
| 34 | + 'tx_dlf_modNewclient' => $extensionPath.'modules/newclient/index.php', |
|
| 35 | + 'tx_dlf_audioplayer' => $extensionPath.'plugins/audioplayer/class.tx_dlf_audioplayer.php', |
|
| 36 | 36 | 'tx_dlf_basket' => $extensionPath.'plugins/basket/class.tx_dlf_basket.php', |
| 37 | 37 | 'tx_dlf_collection' => $extensionPath.'plugins/collection/class.tx_dlf_collection.php', |
| 38 | - 'tx_dlf_feeds' => $extensionPath.'plugins/feeds/class.tx_dlf_feeds.php', |
|
| 39 | - 'tx_dlf_listview' => $extensionPath.'plugins/listview/class.tx_dlf_listview.php', |
|
| 40 | - 'tx_dlf_metadata' => $extensionPath.'plugins/metadata/class.tx_dlf_metadata.php', |
|
| 41 | - 'tx_dlf_navigation' => $extensionPath.'plugins/navigation/class.tx_dlf_navigation.php', |
|
| 42 | - 'tx_dlf_newspaper' => $extensionPath.'plugins/newspaper/class.tx_dlf_newspaper.php', |
|
| 43 | - 'tx_dlf_oai' => $extensionPath.'plugins/oai/class.tx_dlf_oai.php', |
|
| 44 | - 'tx_dlf_pagegrid' => $extensionPath.'plugins/pagegrid/class.tx_dlf_pagegrid.php', |
|
| 45 | - 'tx_dlf_pageview' => $extensionPath.'plugins/pageview/class.tx_dlf_pageview.php', |
|
| 46 | - 'tx_dlf_search' => $extensionPath.'plugins/search/class.tx_dlf_search.php', |
|
| 47 | - 'tx_dlf_search_suggest' => $extensionPath.'plugins/search/class.tx_dlf_search_suggest.php', |
|
| 48 | - 'tx_dlf_statistics' => $extensionPath.'plugins/statistics/class.tx_dlf_statistics.php', |
|
| 49 | - 'tx_dlf_toc' => $extensionPath.'plugins/toc/class.tx_dlf_toc.php', |
|
| 50 | - 'tx_dlf_toolbox' => $extensionPath.'plugins/toolbox/class.tx_dlf_toolbox.php', |
|
| 51 | - 'tx_dlf_toolsPdf' => $extensionPath.'plugins/toolbox/tools/pdf/class.tx_dlf_toolsPdf.php', |
|
| 52 | - 'tx_dlf_toolsFulltext' => $extensionPath.'plugins/toolbox/tools/fulltext/class.tx_dlf_toolsFulltext.php', |
|
| 53 | - 'tx_dlf_toolsImagemanipulation' => $extensionPath.'plugins/toolbox/tools/imagemanipulation/class.tx_dlf_toolsImagemanipulation.php', |
|
| 54 | - 'tx_dlf_toolsImagedownload' => $extensionPath.'plugins/toolbox/tools/imagedownload/class.tx_dlf_toolsImagedownload.php', |
|
| 55 | - 'tx_dlf_validator' => $extensionPath.'plugins/validator/class.tx_dlf_validator.php' |
|
| 38 | + 'tx_dlf_feeds' => $extensionPath.'plugins/feeds/class.tx_dlf_feeds.php', |
|
| 39 | + 'tx_dlf_listview' => $extensionPath.'plugins/listview/class.tx_dlf_listview.php', |
|
| 40 | + 'tx_dlf_metadata' => $extensionPath.'plugins/metadata/class.tx_dlf_metadata.php', |
|
| 41 | + 'tx_dlf_navigation' => $extensionPath.'plugins/navigation/class.tx_dlf_navigation.php', |
|
| 42 | + 'tx_dlf_newspaper' => $extensionPath.'plugins/newspaper/class.tx_dlf_newspaper.php', |
|
| 43 | + 'tx_dlf_oai' => $extensionPath.'plugins/oai/class.tx_dlf_oai.php', |
|
| 44 | + 'tx_dlf_pagegrid' => $extensionPath.'plugins/pagegrid/class.tx_dlf_pagegrid.php', |
|
| 45 | + 'tx_dlf_pageview' => $extensionPath.'plugins/pageview/class.tx_dlf_pageview.php', |
|
| 46 | + 'tx_dlf_search' => $extensionPath.'plugins/search/class.tx_dlf_search.php', |
|
| 47 | + 'tx_dlf_search_suggest' => $extensionPath.'plugins/search/class.tx_dlf_search_suggest.php', |
|
| 48 | + 'tx_dlf_statistics' => $extensionPath.'plugins/statistics/class.tx_dlf_statistics.php', |
|
| 49 | + 'tx_dlf_toc' => $extensionPath.'plugins/toc/class.tx_dlf_toc.php', |
|
| 50 | + 'tx_dlf_toolbox' => $extensionPath.'plugins/toolbox/class.tx_dlf_toolbox.php', |
|
| 51 | + 'tx_dlf_toolsPdf' => $extensionPath.'plugins/toolbox/tools/pdf/class.tx_dlf_toolsPdf.php', |
|
| 52 | + 'tx_dlf_toolsFulltext' => $extensionPath.'plugins/toolbox/tools/fulltext/class.tx_dlf_toolsFulltext.php', |
|
| 53 | + 'tx_dlf_toolsImagemanipulation' => $extensionPath.'plugins/toolbox/tools/imagemanipulation/class.tx_dlf_toolsImagemanipulation.php', |
|
| 54 | + 'tx_dlf_toolsImagedownload' => $extensionPath.'plugins/toolbox/tools/imagedownload/class.tx_dlf_toolsImagedownload.php', |
|
| 55 | + 'tx_dlf_validator' => $extensionPath.'plugins/validator/class.tx_dlf_validator.php' |
|
| 56 | 56 | ); |
@@ -10,32 +10,32 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | $EM_CONF[$_EXTKEY] = array( |
| 13 | - 'title' => 'Kitodo.Presentation', |
|
| 14 | - 'description' => 'Base plugins, modules, services and API of the Digital Library Framework. It is part of the community-based Kitodo Digitization Suite.', |
|
| 15 | - 'category' => 'fe', |
|
| 16 | - 'author' => 'Kitodo. Key to digital objects e.V.', |
|
| 17 | - 'author_email' => '[email protected]', |
|
| 18 | - 'author_company' => '<br /><a href="http://www.kitodo.org/" target="_blank">Kitodo.org</a><br /><a href="https://github.com/kitodo" target="_blank">Kitodo on GitHub</a>', |
|
| 19 | - 'shy' => '', |
|
| 20 | - 'priority' => '', |
|
| 21 | - 'module' => '', |
|
| 22 | - 'state' => 'stable', |
|
| 23 | - 'internal' => '', |
|
| 24 | - 'uploadfolder' => TRUE, |
|
| 25 | - 'createDirs' => '', |
|
| 26 | - 'modify_tables' => '', |
|
| 27 | - 'clearCacheOnLoad' => FALSE, |
|
| 28 | - 'lockType' => '', |
|
| 29 | - 'version' => '2.1.0', |
|
| 30 | - 'constraints' => array( |
|
| 31 | - 'depends' => array( |
|
| 32 | - 'php' => '5.3.7-', |
|
| 33 | - 'typo3' => '6.2.0-7.9.99', |
|
| 34 | - ), |
|
| 35 | - 'conflicts' => array( |
|
| 36 | - ), |
|
| 37 | - 'suggests' => array( |
|
| 38 | - ), |
|
| 39 | - ), |
|
| 40 | - '_md5_values_when_last_written' => '', |
|
| 13 | + 'title' => 'Kitodo.Presentation', |
|
| 14 | + 'description' => 'Base plugins, modules, services and API of the Digital Library Framework. It is part of the community-based Kitodo Digitization Suite.', |
|
| 15 | + 'category' => 'fe', |
|
| 16 | + 'author' => 'Kitodo. Key to digital objects e.V.', |
|
| 17 | + 'author_email' => '[email protected]', |
|
| 18 | + 'author_company' => '<br /><a href="http://www.kitodo.org/" target="_blank">Kitodo.org</a><br /><a href="https://github.com/kitodo" target="_blank">Kitodo on GitHub</a>', |
|
| 19 | + 'shy' => '', |
|
| 20 | + 'priority' => '', |
|
| 21 | + 'module' => '', |
|
| 22 | + 'state' => 'stable', |
|
| 23 | + 'internal' => '', |
|
| 24 | + 'uploadfolder' => TRUE, |
|
| 25 | + 'createDirs' => '', |
|
| 26 | + 'modify_tables' => '', |
|
| 27 | + 'clearCacheOnLoad' => FALSE, |
|
| 28 | + 'lockType' => '', |
|
| 29 | + 'version' => '2.1.0', |
|
| 30 | + 'constraints' => array( |
|
| 31 | + 'depends' => array( |
|
| 32 | + 'php' => '5.3.7-', |
|
| 33 | + 'typo3' => '6.2.0-7.9.99', |
|
| 34 | + ), |
|
| 35 | + 'conflicts' => array( |
|
| 36 | + ), |
|
| 37 | + 'suggests' => array( |
|
| 38 | + ), |
|
| 39 | + ), |
|
| 40 | + '_md5_values_when_last_written' => '', |
|
| 41 | 41 | ); |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * LICENSE.txt file that was distributed with this source code. |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -$EM_CONF[$_EXTKEY] = array( |
|
| 12 | +$EM_CONF[$_EXTKEY] = array ( |
|
| 13 | 13 | 'title' => 'Kitodo.Presentation', |
| 14 | 14 | 'description' => 'Base plugins, modules, services and API of the Digital Library Framework. It is part of the community-based Kitodo Digitization Suite.', |
| 15 | 15 | 'category' => 'fe', |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | 'clearCacheOnLoad' => FALSE, |
| 28 | 28 | 'lockType' => '', |
| 29 | 29 | 'version' => '2.1.0', |
| 30 | - 'constraints' => array( |
|
| 31 | - 'depends' => array( |
|
| 30 | + 'constraints' => array ( |
|
| 31 | + 'depends' => array ( |
|
| 32 | 32 | 'php' => '5.3.7-', |
| 33 | 33 | 'typo3' => '6.2.0-7.9.99', |
| 34 | 34 | ), |
| 35 | - 'conflicts' => array( |
|
| 35 | + 'conflicts' => array ( |
|
| 36 | 36 | ), |
| 37 | - 'suggests' => array( |
|
| 37 | + 'suggests' => array ( |
|
| 38 | 38 | ), |
| 39 | 39 | ), |
| 40 | 40 | '_md5_values_when_last_written' => '', |
@@ -19,24 +19,24 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class tx_dlf_alto implements tx_dlf_fulltext { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * This extracts the fulltext data from ALTO XML |
|
| 24 | - * |
|
| 25 | - * @access public |
|
| 26 | - * |
|
| 27 | - * @param SimpleXMLElement $xml: The XML to extract the metadata from |
|
| 28 | - * |
|
| 29 | - * @return string The raw unformatted fulltext |
|
| 30 | - */ |
|
| 31 | - public static function getRawText(SimpleXMLElement $xml) { |
|
| 22 | + /** |
|
| 23 | + * This extracts the fulltext data from ALTO XML |
|
| 24 | + * |
|
| 25 | + * @access public |
|
| 26 | + * |
|
| 27 | + * @param SimpleXMLElement $xml: The XML to extract the metadata from |
|
| 28 | + * |
|
| 29 | + * @return string The raw unformatted fulltext |
|
| 30 | + */ |
|
| 31 | + public static function getRawText(SimpleXMLElement $xml) { |
|
| 32 | 32 | |
| 33 | - $xml->registerXPathNamespace('alto', 'http://www.loc.gov/standards/alto/ns-v2#'); |
|
| 33 | + $xml->registerXPathNamespace('alto', 'http://www.loc.gov/standards/alto/ns-v2#'); |
|
| 34 | 34 | |
| 35 | - // Get all (presumed) words of the text. |
|
| 36 | - $words = $xml->xpath('./alto:Layout/alto:Page/alto:PrintSpace//alto:TextBlock/alto:TextLine/alto:String/@CONTENT'); |
|
| 35 | + // Get all (presumed) words of the text. |
|
| 36 | + $words = $xml->xpath('./alto:Layout/alto:Page/alto:PrintSpace//alto:TextBlock/alto:TextLine/alto:String/@CONTENT'); |
|
| 37 | 37 | |
| 38 | - return implode(' ', $words); |
|
| 38 | + return implode(' ', $words); |
|
| 39 | 39 | |
| 40 | - } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | } |
@@ -20,1318 +20,1318 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class tx_dlf_helper { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * The extension key |
|
| 25 | - * |
|
| 26 | - * @var string |
|
| 27 | - * @access public |
|
| 28 | - */ |
|
| 29 | - public static $extKey = 'dlf'; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * The locallang array for common use |
|
| 33 | - * |
|
| 34 | - * @var array |
|
| 35 | - * @access protected |
|
| 36 | - */ |
|
| 37 | - protected static $locallang = array (); |
|
| 23 | + /** |
|
| 24 | + * The extension key |
|
| 25 | + * |
|
| 26 | + * @var string |
|
| 27 | + * @access public |
|
| 28 | + */ |
|
| 29 | + public static $extKey = 'dlf'; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * The locallang array for common use |
|
| 33 | + * |
|
| 34 | + * @var array |
|
| 35 | + * @access protected |
|
| 36 | + */ |
|
| 37 | + protected static $locallang = array (); |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Adds a message to the message queue. |
|
| 41 | - * |
|
| 42 | - * @access public |
|
| 43 | - * |
|
| 44 | - * @param \TYPO3\CMS\Core\Messaging\FlashMessage $message: Instance of \TYPO3\CMS\Core\Messaging\FlashMessage |
|
| 45 | - * |
|
| 46 | - * @return void |
|
| 47 | - */ |
|
| 48 | - public static function addMessage($message) { |
|
| 39 | + /** |
|
| 40 | + * Adds a message to the message queue. |
|
| 41 | + * |
|
| 42 | + * @access public |
|
| 43 | + * |
|
| 44 | + * @param \TYPO3\CMS\Core\Messaging\FlashMessage $message: Instance of \TYPO3\CMS\Core\Messaging\FlashMessage |
|
| 45 | + * |
|
| 46 | + * @return void |
|
| 47 | + */ |
|
| 48 | + public static function addMessage($message) { |
|
| 49 | 49 | |
| 50 | - $flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); |
|
| 50 | + $flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); |
|
| 51 | 51 | |
| 52 | - $flashMessageService->getMessageQueueByIdentifier()->enqueue($message); |
|
| 52 | + $flashMessageService->getMessageQueueByIdentifier()->enqueue($message); |
|
| 53 | 53 | |
| 54 | - } |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Implements array_merge_recursive_overrule() in a cross-version way |
|
| 58 | - * This code is a copy from realurl, written by Dmitry Dulepov <[email protected]>. |
|
| 59 | - * |
|
| 60 | - * @access public |
|
| 61 | - * |
|
| 62 | - * @param array $array1: First array |
|
| 63 | - * @param array $array2: Second array |
|
| 64 | - * |
|
| 65 | - * @return array Merged array with second array overruling first one |
|
| 66 | - */ |
|
| 67 | - static public function array_merge_recursive_overrule($array1, $array2) { |
|
| 56 | + /** |
|
| 57 | + * Implements array_merge_recursive_overrule() in a cross-version way |
|
| 58 | + * This code is a copy from realurl, written by Dmitry Dulepov <[email protected]>. |
|
| 59 | + * |
|
| 60 | + * @access public |
|
| 61 | + * |
|
| 62 | + * @param array $array1: First array |
|
| 63 | + * @param array $array2: Second array |
|
| 64 | + * |
|
| 65 | + * @return array Merged array with second array overruling first one |
|
| 66 | + */ |
|
| 67 | + static public function array_merge_recursive_overrule($array1, $array2) { |
|
| 68 | 68 | |
| 69 | - if (class_exists('\\TYPO3\\CMS\\Core\\Utility\\ArrayUtility')) { |
|
| 69 | + if (class_exists('\\TYPO3\\CMS\\Core\\Utility\\ArrayUtility')) { |
|
| 70 | 70 | |
| 71 | - \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($array1, $array2); |
|
| 71 | + \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($array1, $array2); |
|
| 72 | 72 | |
| 73 | - } else { |
|
| 73 | + } else { |
|
| 74 | 74 | |
| 75 | - $array1 = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($array1, $array2); |
|
| 75 | + $array1 = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($array1, $array2); |
|
| 76 | 76 | |
| 77 | - } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - return $array1; |
|
| 79 | + return $array1; |
|
| 80 | 80 | |
| 81 | - } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Searches the array recursively for a given value and returns the corresponding key if successful |
|
| 85 | - * @see http://php.net/array_search |
|
| 86 | - * |
|
| 87 | - * @access public |
|
| 88 | - * |
|
| 89 | - * @param mixed $needle: The searched value |
|
| 90 | - * @param array $haystack: The array to search in |
|
| 91 | - * @param boolean $strict: Check needle's type, too? |
|
| 92 | - * |
|
| 93 | - * @return mixed Returns the needle's key if found and FALSE otherwise |
|
| 94 | - * |
|
| 95 | - * @deprecated because of its inefficiency |
|
| 96 | - */ |
|
| 97 | - public static function array_search_recursive($needle, $haystack, $strict = FALSE) { |
|
| 83 | + /** |
|
| 84 | + * Searches the array recursively for a given value and returns the corresponding key if successful |
|
| 85 | + * @see http://php.net/array_search |
|
| 86 | + * |
|
| 87 | + * @access public |
|
| 88 | + * |
|
| 89 | + * @param mixed $needle: The searched value |
|
| 90 | + * @param array $haystack: The array to search in |
|
| 91 | + * @param boolean $strict: Check needle's type, too? |
|
| 92 | + * |
|
| 93 | + * @return mixed Returns the needle's key if found and FALSE otherwise |
|
| 94 | + * |
|
| 95 | + * @deprecated because of its inefficiency |
|
| 96 | + */ |
|
| 97 | + public static function array_search_recursive($needle, $haystack, $strict = FALSE) { |
|
| 98 | 98 | |
| 99 | - foreach ($haystack as $key => $value) { |
|
| 99 | + foreach ($haystack as $key => $value) { |
|
| 100 | 100 | |
| 101 | - if (($strict && $value === $needle) || (!$strict && $value == $needle) || (is_array($value) && self::array_search_recursive($needle, $value, $strict) !== FALSE)) { |
|
| 101 | + if (($strict && $value === $needle) || (!$strict && $value == $needle) || (is_array($value) && self::array_search_recursive($needle, $value, $strict) !== FALSE)) { |
|
| 102 | 102 | |
| 103 | - return $key; |
|
| 103 | + return $key; |
|
| 104 | 104 | |
| 105 | - } |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - return FALSE; |
|
| 109 | + return FALSE; |
|
| 110 | 110 | |
| 111 | - } |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * Check if given identifier is a valid identifier of the German National Library |
|
| 115 | - * @see http://support.d-nb.de/iltis/onlineRoutinen/Pruefziffernberechnung.htm |
|
| 116 | - * |
|
| 117 | - * @access public |
|
| 118 | - * |
|
| 119 | - * @param string $id: The identifier to check |
|
| 120 | - * @param string $type: What type is the identifier supposed to be? |
|
| 121 | - * Possible values: PPN, IDN, PND, ZDB, SWD, GKD |
|
| 122 | - * |
|
| 123 | - * @return boolean Is $id a valid GNL identifier of the given $type? |
|
| 124 | - */ |
|
| 125 | - public static function checkIdentifier($id, $type) { |
|
| 113 | + /** |
|
| 114 | + * Check if given identifier is a valid identifier of the German National Library |
|
| 115 | + * @see http://support.d-nb.de/iltis/onlineRoutinen/Pruefziffernberechnung.htm |
|
| 116 | + * |
|
| 117 | + * @access public |
|
| 118 | + * |
|
| 119 | + * @param string $id: The identifier to check |
|
| 120 | + * @param string $type: What type is the identifier supposed to be? |
|
| 121 | + * Possible values: PPN, IDN, PND, ZDB, SWD, GKD |
|
| 122 | + * |
|
| 123 | + * @return boolean Is $id a valid GNL identifier of the given $type? |
|
| 124 | + */ |
|
| 125 | + public static function checkIdentifier($id, $type) { |
|
| 126 | 126 | |
| 127 | - $digits = substr($id, 0, 8); |
|
| 127 | + $digits = substr($id, 0, 8); |
|
| 128 | 128 | |
| 129 | - $checksum = 0; |
|
| 129 | + $checksum = 0; |
|
| 130 | 130 | |
| 131 | - for ($i = 0, $j = strlen($digits); $i < $j; $i++) { |
|
| 131 | + for ($i = 0, $j = strlen($digits); $i < $j; $i++) { |
|
| 132 | 132 | |
| 133 | - $checksum += (9 - $i) * intval(substr($digits, $i, 1)); |
|
| 133 | + $checksum += (9 - $i) * intval(substr($digits, $i, 1)); |
|
| 134 | 134 | |
| 135 | - } |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - $checksum = (11 - ($checksum % 11)) % 11; |
|
| 137 | + $checksum = (11 - ($checksum % 11)) % 11; |
|
| 138 | 138 | |
| 139 | - switch (strtoupper($type)) { |
|
| 139 | + switch (strtoupper($type)) { |
|
| 140 | 140 | |
| 141 | - case 'PPN': |
|
| 142 | - case 'IDN': |
|
| 143 | - case 'PND': |
|
| 141 | + case 'PPN': |
|
| 142 | + case 'IDN': |
|
| 143 | + case 'PND': |
|
| 144 | 144 | |
| 145 | - if ($checksum == 10) { |
|
| 145 | + if ($checksum == 10) { |
|
| 146 | 146 | |
| 147 | - $checksum = 'X'; |
|
| 147 | + $checksum = 'X'; |
|
| 148 | 148 | |
| 149 | - } |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - if (!preg_match('/[0-9]{8}[0-9X]{1}/i', $id)) { |
|
| 151 | + if (!preg_match('/[0-9]{8}[0-9X]{1}/i', $id)) { |
|
| 152 | 152 | |
| 153 | - return FALSE; |
|
| 153 | + return FALSE; |
|
| 154 | 154 | |
| 155 | - } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
|
| 155 | + } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
|
| 156 | 156 | |
| 157 | - return FALSE; |
|
| 157 | + return FALSE; |
|
| 158 | 158 | |
| 159 | - } |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - break; |
|
| 161 | + break; |
|
| 162 | 162 | |
| 163 | - case 'ZDB': |
|
| 163 | + case 'ZDB': |
|
| 164 | 164 | |
| 165 | - if ($checksum == 10) { |
|
| 165 | + if ($checksum == 10) { |
|
| 166 | 166 | |
| 167 | - $checksum = 'X'; |
|
| 167 | + $checksum = 'X'; |
|
| 168 | 168 | |
| 169 | - } |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | - if (!preg_match('/[0-9]{8}-[0-9X]{1}/i', $id)) { |
|
| 171 | + if (!preg_match('/[0-9]{8}-[0-9X]{1}/i', $id)) { |
|
| 172 | 172 | |
| 173 | - return FALSE; |
|
| 173 | + return FALSE; |
|
| 174 | 174 | |
| 175 | - } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
|
| 175 | + } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
|
| 176 | 176 | |
| 177 | - return FALSE; |
|
| 177 | + return FALSE; |
|
| 178 | 178 | |
| 179 | - } |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - break; |
|
| 181 | + break; |
|
| 182 | 182 | |
| 183 | - case 'SWD': |
|
| 183 | + case 'SWD': |
|
| 184 | 184 | |
| 185 | - $checksum = 11 - $checksum; |
|
| 185 | + $checksum = 11 - $checksum; |
|
| 186 | 186 | |
| 187 | - if (!preg_match('/[0-9]{8}-[0-9]{1}/i', $id)) { |
|
| 187 | + if (!preg_match('/[0-9]{8}-[0-9]{1}/i', $id)) { |
|
| 188 | 188 | |
| 189 | - return FALSE; |
|
| 189 | + return FALSE; |
|
| 190 | 190 | |
| 191 | - } elseif ($checksum == 10) { |
|
| 191 | + } elseif ($checksum == 10) { |
|
| 192 | 192 | |
| 193 | - return self::checkIdentifier(($digits + 1).substr($id, -2, 2), 'SWD'); |
|
| 193 | + return self::checkIdentifier(($digits + 1).substr($id, -2, 2), 'SWD'); |
|
| 194 | 194 | |
| 195 | - } elseif (substr($id, -1, 1) != $checksum) { |
|
| 195 | + } elseif (substr($id, -1, 1) != $checksum) { |
|
| 196 | 196 | |
| 197 | - return FALSE; |
|
| 197 | + return FALSE; |
|
| 198 | 198 | |
| 199 | - } |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - break; |
|
| 201 | + break; |
|
| 202 | 202 | |
| 203 | - case 'GKD': |
|
| 203 | + case 'GKD': |
|
| 204 | 204 | |
| 205 | - $checksum = 11 - $checksum; |
|
| 205 | + $checksum = 11 - $checksum; |
|
| 206 | 206 | |
| 207 | - if ($checksum == 10) { |
|
| 207 | + if ($checksum == 10) { |
|
| 208 | 208 | |
| 209 | - $checksum = 'X'; |
|
| 209 | + $checksum = 'X'; |
|
| 210 | 210 | |
| 211 | - } |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - if (!preg_match('/[0-9]{8}-[0-9X]{1}/i', $id)) { |
|
| 213 | + if (!preg_match('/[0-9]{8}-[0-9X]{1}/i', $id)) { |
|
| 214 | 214 | |
| 215 | - return FALSE; |
|
| 215 | + return FALSE; |
|
| 216 | 216 | |
| 217 | - } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
|
| 217 | + } elseif (strtoupper(substr($id, -1, 1)) != $checksum) { |
|
| 218 | 218 | |
| 219 | - return FALSE; |
|
| 219 | + return FALSE; |
|
| 220 | 220 | |
| 221 | - } |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - break; |
|
| 223 | + break; |
|
| 224 | 224 | |
| 225 | - } |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | - return TRUE; |
|
| 227 | + return TRUE; |
|
| 228 | 228 | |
| 229 | - } |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - /** |
|
| 232 | - * Decrypt encrypted value with given control hash |
|
| 233 | - * @see http://yavkata.co.uk/weblog/php/securing-html-hidden-input-fields-using-encryption-and-hashing/ |
|
| 234 | - * |
|
| 235 | - * @access public |
|
| 236 | - * |
|
| 237 | - * @param string $encrypted: The encrypted value to decrypt |
|
| 238 | - * @param string $hash: The control hash for decrypting |
|
| 239 | - * |
|
| 240 | - * @return mixed The decrypted value or NULL on error |
|
| 241 | - */ |
|
| 242 | - public static function decrypt($encrypted, $hash) { |
|
| 231 | + /** |
|
| 232 | + * Decrypt encrypted value with given control hash |
|
| 233 | + * @see http://yavkata.co.uk/weblog/php/securing-html-hidden-input-fields-using-encryption-and-hashing/ |
|
| 234 | + * |
|
| 235 | + * @access public |
|
| 236 | + * |
|
| 237 | + * @param string $encrypted: The encrypted value to decrypt |
|
| 238 | + * @param string $hash: The control hash for decrypting |
|
| 239 | + * |
|
| 240 | + * @return mixed The decrypted value or NULL on error |
|
| 241 | + */ |
|
| 242 | + public static function decrypt($encrypted, $hash) { |
|
| 243 | 243 | |
| 244 | - $decrypted = NULL; |
|
| 244 | + $decrypted = NULL; |
|
| 245 | 245 | |
| 246 | - // Check for PHP extension "mcrypt". |
|
| 247 | - if (!extension_loaded('mcrypt')) { |
|
| 246 | + // Check for PHP extension "mcrypt". |
|
| 247 | + if (!extension_loaded('mcrypt')) { |
|
| 248 | 248 | |
| 249 | - if (TYPO3_DLOG) { |
|
| 249 | + if (TYPO3_DLOG) { |
|
| 250 | 250 | |
| 251 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] PHP extension "mcrypt" not available', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 251 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] PHP extension "mcrypt" not available', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 252 | 252 | |
| 253 | - } |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - return; |
|
| 255 | + return; |
|
| 256 | 256 | |
| 257 | - } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - if (empty($encrypted) || empty($hash)) { |
|
| 259 | + if (empty($encrypted) || empty($hash)) { |
|
| 260 | 260 | |
| 261 | - if (TYPO3_DLOG) { |
|
| 261 | + if (TYPO3_DLOG) { |
|
| 262 | 262 | |
| 263 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] Invalid parameters given for decryption', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 263 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] Invalid parameters given for decryption', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 264 | 264 | |
| 265 | - } |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - return; |
|
| 267 | + return; |
|
| 268 | 268 | |
| 269 | - } |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { |
|
| 271 | + if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { |
|
| 272 | 272 | |
| 273 | - if (TYPO3_DLOG) { |
|
| 273 | + if (TYPO3_DLOG) { |
|
| 274 | 274 | |
| 275 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] No encryption key set in TYPO3 configuration', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 275 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] No encryption key set in TYPO3 configuration', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 276 | 276 | |
| 277 | - } |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - return; |
|
| 279 | + return; |
|
| 280 | 280 | |
| 281 | - } |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - $iv = substr(md5($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']), 0, mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CFB)); |
|
| 283 | + $iv = substr(md5($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']), 0, mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CFB)); |
|
| 284 | 284 | |
| 285 | - $decrypted = mcrypt_decrypt(MCRYPT_BLOWFISH, substr($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], 0, 56), base64_decode($encrypted), MCRYPT_MODE_CFB, $iv); |
|
| 285 | + $decrypted = mcrypt_decrypt(MCRYPT_BLOWFISH, substr($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], 0, 56), base64_decode($encrypted), MCRYPT_MODE_CFB, $iv); |
|
| 286 | 286 | |
| 287 | - $salt = substr($hash, 0, 10); |
|
| 287 | + $salt = substr($hash, 0, 10); |
|
| 288 | 288 | |
| 289 | - $hashed = $salt.substr(sha1($salt.$decrypted), -10); |
|
| 289 | + $hashed = $salt.substr(sha1($salt.$decrypted), -10); |
|
| 290 | 290 | |
| 291 | - if ($hashed !== $hash) { |
|
| 291 | + if ($hashed !== $hash) { |
|
| 292 | 292 | |
| 293 | - if (TYPO3_DLOG) { |
|
| 293 | + if (TYPO3_DLOG) { |
|
| 294 | 294 | |
| 295 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] Invalid hash "'.$hash.'" given for decryption', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 295 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->decrypt('.$encrypted.', '.$hash.')] Invalid hash "'.$hash.'" given for decryption', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 296 | 296 | |
| 297 | - } |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | - return; |
|
| 299 | + return; |
|
| 300 | 300 | |
| 301 | - } |
|
| 301 | + } |
|
| 302 | 302 | |
| 303 | - return $decrypted; |
|
| 303 | + return $decrypted; |
|
| 304 | 304 | |
| 305 | - } |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | - /** |
|
| 308 | - * Encrypt the given string |
|
| 309 | - * @see http://yavkata.co.uk/weblog/php/securing-html-hidden-input-fields-using-encryption-and-hashing/ |
|
| 310 | - * |
|
| 311 | - * @access public |
|
| 312 | - * |
|
| 313 | - * @param string $string: The string to encrypt |
|
| 314 | - * |
|
| 315 | - * @return array Array with encrypted string and control hash |
|
| 316 | - */ |
|
| 317 | - public static function encrypt($string) { |
|
| 307 | + /** |
|
| 308 | + * Encrypt the given string |
|
| 309 | + * @see http://yavkata.co.uk/weblog/php/securing-html-hidden-input-fields-using-encryption-and-hashing/ |
|
| 310 | + * |
|
| 311 | + * @access public |
|
| 312 | + * |
|
| 313 | + * @param string $string: The string to encrypt |
|
| 314 | + * |
|
| 315 | + * @return array Array with encrypted string and control hash |
|
| 316 | + */ |
|
| 317 | + public static function encrypt($string) { |
|
| 318 | 318 | |
| 319 | - // Check for PHP extension "mcrypt". |
|
| 320 | - if (!extension_loaded('mcrypt')) { |
|
| 319 | + // Check for PHP extension "mcrypt". |
|
| 320 | + if (!extension_loaded('mcrypt')) { |
|
| 321 | 321 | |
| 322 | - if (TYPO3_DLOG) { |
|
| 322 | + if (TYPO3_DLOG) { |
|
| 323 | 323 | |
| 324 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->encrypt('.$string.')] PHP extension "mcrypt" not available', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 324 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->encrypt('.$string.')] PHP extension "mcrypt" not available', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 325 | 325 | |
| 326 | - } |
|
| 326 | + } |
|
| 327 | 327 | |
| 328 | - return; |
|
| 328 | + return; |
|
| 329 | 329 | |
| 330 | - } |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | - if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { |
|
| 332 | + if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) { |
|
| 333 | 333 | |
| 334 | - if (TYPO3_DLOG) { |
|
| 334 | + if (TYPO3_DLOG) { |
|
| 335 | 335 | |
| 336 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->encrypt('.$string.')] No encryption key set in TYPO3 configuration', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 336 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->encrypt('.$string.')] No encryption key set in TYPO3 configuration', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 337 | 337 | |
| 338 | - } |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - return; |
|
| 340 | + return; |
|
| 341 | 341 | |
| 342 | - } |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - $iv = substr(md5($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']), 0, mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CFB)); |
|
| 344 | + $iv = substr(md5($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']), 0, mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CFB)); |
|
| 345 | 345 | |
| 346 | - $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH, substr($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], 0, 56), $string, MCRYPT_MODE_CFB, $iv)); |
|
| 346 | + $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH, substr($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], 0, 56), $string, MCRYPT_MODE_CFB, $iv)); |
|
| 347 | 347 | |
| 348 | - $salt = substr(md5(uniqid(rand(), TRUE)), 0, 10); |
|
| 348 | + $salt = substr(md5(uniqid(rand(), TRUE)), 0, 10); |
|
| 349 | 349 | |
| 350 | - $hash = $salt.substr(sha1($salt.$string), -10); |
|
| 350 | + $hash = $salt.substr(sha1($salt.$string), -10); |
|
| 351 | 351 | |
| 352 | - return array ('encrypted' => $encrypted, 'hash' => $hash); |
|
| 352 | + return array ('encrypted' => $encrypted, 'hash' => $hash); |
|
| 353 | 353 | |
| 354 | - } |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | - /** |
|
| 357 | - * Get a backend user object (even in frontend mode) |
|
| 358 | - * |
|
| 359 | - * @access public |
|
| 360 | - * |
|
| 361 | - * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication Instance of \TYPO3\CMS\Core\Authentication\BackendUserAuthentication or NULL on failure |
|
| 362 | - */ |
|
| 363 | - public static function getBeUser() { |
|
| 356 | + /** |
|
| 357 | + * Get a backend user object (even in frontend mode) |
|
| 358 | + * |
|
| 359 | + * @access public |
|
| 360 | + * |
|
| 361 | + * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication Instance of \TYPO3\CMS\Core\Authentication\BackendUserAuthentication or NULL on failure |
|
| 362 | + */ |
|
| 363 | + public static function getBeUser() { |
|
| 364 | 364 | |
| 365 | - if (TYPO3_MODE === 'FE' || TYPO3_MODE === 'BE') { |
|
| 365 | + if (TYPO3_MODE === 'FE' || TYPO3_MODE === 'BE') { |
|
| 366 | 366 | |
| 367 | - // Initialize backend session with CLI user's rights. |
|
| 368 | - $userObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication'); |
|
| 367 | + // Initialize backend session with CLI user's rights. |
|
| 368 | + $userObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication'); |
|
| 369 | 369 | |
| 370 | - $userObj->dontSetCookie = TRUE; |
|
| 370 | + $userObj->dontSetCookie = TRUE; |
|
| 371 | 371 | |
| 372 | - $userObj->start(); |
|
| 372 | + $userObj->start(); |
|
| 373 | 373 | |
| 374 | - $userObj->setBeUserByName('_cli_dlf'); |
|
| 374 | + $userObj->setBeUserByName('_cli_dlf'); |
|
| 375 | 375 | |
| 376 | - $userObj->backendCheckLogin(); |
|
| 376 | + $userObj->backendCheckLogin(); |
|
| 377 | 377 | |
| 378 | - return $userObj; |
|
| 378 | + return $userObj; |
|
| 379 | 379 | |
| 380 | - } else { |
|
| 380 | + } else { |
|
| 381 | 381 | |
| 382 | - if (TYPO3_DLOG) { |
|
| 382 | + if (TYPO3_DLOG) { |
|
| 383 | 383 | |
| 384 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getBeUser()] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 384 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getBeUser()] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 385 | 385 | |
| 386 | - } |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | - return; |
|
| 388 | + return; |
|
| 389 | 389 | |
| 390 | - } |
|
| 390 | + } |
|
| 391 | 391 | |
| 392 | - } |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | - /** |
|
| 395 | - * Get the current frontend user object |
|
| 396 | - * |
|
| 397 | - * @access public |
|
| 398 | - * |
|
| 399 | - * @return \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication Instance of \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication or NULL on failure |
|
| 400 | - */ |
|
| 401 | - public static function getFeUser() { |
|
| 394 | + /** |
|
| 395 | + * Get the current frontend user object |
|
| 396 | + * |
|
| 397 | + * @access public |
|
| 398 | + * |
|
| 399 | + * @return \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication Instance of \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication or NULL on failure |
|
| 400 | + */ |
|
| 401 | + public static function getFeUser() { |
|
| 402 | 402 | |
| 403 | - if (TYPO3_MODE === 'FE') { |
|
| 403 | + if (TYPO3_MODE === 'FE') { |
|
| 404 | 404 | |
| 405 | - // Check if a user is currently logged in. |
|
| 406 | - if (!empty($GLOBALS['TSFE']->loginUser)) { |
|
| 405 | + // Check if a user is currently logged in. |
|
| 406 | + if (!empty($GLOBALS['TSFE']->loginUser)) { |
|
| 407 | 407 | |
| 408 | - return $GLOBALS['TSFE']->fe_user; |
|
| 408 | + return $GLOBALS['TSFE']->fe_user; |
|
| 409 | 409 | |
| 410 | - } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('eID') !== NULL) { |
|
| 410 | + } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('eID') !== NULL) { |
|
| 411 | 411 | |
| 412 | - return \TYPO3\CMS\Frontend\Utility\EidUtility::initFeUser(); |
|
| 412 | + return \TYPO3\CMS\Frontend\Utility\EidUtility::initFeUser(); |
|
| 413 | 413 | |
| 414 | - } |
|
| 414 | + } |
|
| 415 | 415 | |
| 416 | - } else { |
|
| 416 | + } else { |
|
| 417 | 417 | |
| 418 | - if (TYPO3_DLOG) { |
|
| 418 | + if (TYPO3_DLOG) { |
|
| 419 | 419 | |
| 420 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getFeUser()] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 420 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getFeUser()] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 421 | 421 | |
| 422 | - } |
|
| 422 | + } |
|
| 423 | 423 | |
| 424 | - } |
|
| 424 | + } |
|
| 425 | 425 | |
| 426 | - return; |
|
| 426 | + return; |
|
| 427 | 427 | |
| 428 | - } |
|
| 428 | + } |
|
| 429 | 429 | |
| 430 | - /** |
|
| 431 | - * Get the registered hook objects for a class |
|
| 432 | - * |
|
| 433 | - * @access public |
|
| 434 | - * |
|
| 435 | - * @param string $scriptRelPath: The path to the class file |
|
| 436 | - * |
|
| 437 | - * @return array Array of hook objects for the class |
|
| 438 | - */ |
|
| 439 | - public static function getHookObjects($scriptRelPath) { |
|
| 430 | + /** |
|
| 431 | + * Get the registered hook objects for a class |
|
| 432 | + * |
|
| 433 | + * @access public |
|
| 434 | + * |
|
| 435 | + * @param string $scriptRelPath: The path to the class file |
|
| 436 | + * |
|
| 437 | + * @return array Array of hook objects for the class |
|
| 438 | + */ |
|
| 439 | + public static function getHookObjects($scriptRelPath) { |
|
| 440 | 440 | |
| 441 | - $hookObjects = array (); |
|
| 441 | + $hookObjects = array (); |
|
| 442 | 442 | |
| 443 | - if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey.'/'.$scriptRelPath]['hookClass'])) { |
|
| 443 | + if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey.'/'.$scriptRelPath]['hookClass'])) { |
|
| 444 | 444 | |
| 445 | - foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey.'/'.$scriptRelPath]['hookClass'] as $classRef) { |
|
| 445 | + foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey.'/'.$scriptRelPath]['hookClass'] as $classRef) { |
|
| 446 | 446 | |
| 447 | - $hookObjects[] = &\TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef); |
|
| 447 | + $hookObjects[] = &\TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef); |
|
| 448 | 448 | |
| 449 | - } |
|
| 449 | + } |
|
| 450 | 450 | |
| 451 | - } |
|
| 451 | + } |
|
| 452 | 452 | |
| 453 | - return $hookObjects; |
|
| 453 | + return $hookObjects; |
|
| 454 | 454 | |
| 455 | - } |
|
| 455 | + } |
|
| 456 | 456 | |
| 457 | - /** |
|
| 458 | - * Get the "index_name" for an UID |
|
| 459 | - * |
|
| 460 | - * @access public |
|
| 461 | - * |
|
| 462 | - * @param integer $uid: The UID of the record |
|
| 463 | - * @param string $table: Get the "index_name" from this table |
|
| 464 | - * @param integer $pid: Get the "index_name" from this page |
|
| 465 | - * |
|
| 466 | - * @return string "index_name" for the given UID |
|
| 467 | - */ |
|
| 468 | - public static function getIndexName($uid, $table, $pid = -1) { |
|
| 457 | + /** |
|
| 458 | + * Get the "index_name" for an UID |
|
| 459 | + * |
|
| 460 | + * @access public |
|
| 461 | + * |
|
| 462 | + * @param integer $uid: The UID of the record |
|
| 463 | + * @param string $table: Get the "index_name" from this table |
|
| 464 | + * @param integer $pid: Get the "index_name" from this page |
|
| 465 | + * |
|
| 466 | + * @return string "index_name" for the given UID |
|
| 467 | + */ |
|
| 468 | + public static function getIndexName($uid, $table, $pid = -1) { |
|
| 469 | 469 | |
| 470 | - // Save parameters for logging purposes. |
|
| 471 | - $_uid = $uid; |
|
| 470 | + // Save parameters for logging purposes. |
|
| 471 | + $_uid = $uid; |
|
| 472 | 472 | |
| 473 | - $_pid = $pid; |
|
| 473 | + $_pid = $pid; |
|
| 474 | 474 | |
| 475 | - // Sanitize input. |
|
| 476 | - $uid = max(intval($uid), 0); |
|
| 475 | + // Sanitize input. |
|
| 476 | + $uid = max(intval($uid), 0); |
|
| 477 | 477 | |
| 478 | - if (!$uid || !in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'))) { |
|
| 478 | + if (!$uid || !in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'))) { |
|
| 479 | 479 | |
| 480 | - if (TYPO3_DLOG) { |
|
| 480 | + if (TYPO3_DLOG) { |
|
| 481 | 481 | |
| 482 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIndexName('.$_uid.', '.$table.', '.$_pid.')] Invalid UID "'.$uid.'" or table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 482 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIndexName('.$_uid.', '.$table.', '.$_pid.')] Invalid UID "'.$uid.'" or table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 483 | 483 | |
| 484 | - } |
|
| 484 | + } |
|
| 485 | 485 | |
| 486 | - return ''; |
|
| 486 | + return ''; |
|
| 487 | 487 | |
| 488 | - } |
|
| 488 | + } |
|
| 489 | 489 | |
| 490 | - $where = ''; |
|
| 490 | + $where = ''; |
|
| 491 | 491 | |
| 492 | - // Should we check for a specific PID, too? |
|
| 493 | - if ($pid !== -1) { |
|
| 492 | + // Should we check for a specific PID, too? |
|
| 493 | + if ($pid !== -1) { |
|
| 494 | 494 | |
| 495 | - $pid = max(intval($pid), 0); |
|
| 495 | + $pid = max(intval($pid), 0); |
|
| 496 | 496 | |
| 497 | - $where = ' AND '.$table.'.pid='.$pid; |
|
| 497 | + $where = ' AND '.$table.'.pid='.$pid; |
|
| 498 | 498 | |
| 499 | - } |
|
| 499 | + } |
|
| 500 | 500 | |
| 501 | - // Get index_name from database. |
|
| 502 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 503 | - $table.'.index_name AS index_name', |
|
| 504 | - $table, |
|
| 505 | - $table.'.uid='.$uid.$where.self::whereClause($table), |
|
| 506 | - '', |
|
| 507 | - '', |
|
| 508 | - '1' |
|
| 509 | - ); |
|
| 501 | + // Get index_name from database. |
|
| 502 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 503 | + $table.'.index_name AS index_name', |
|
| 504 | + $table, |
|
| 505 | + $table.'.uid='.$uid.$where.self::whereClause($table), |
|
| 506 | + '', |
|
| 507 | + '', |
|
| 508 | + '1' |
|
| 509 | + ); |
|
| 510 | 510 | |
| 511 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
| 511 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
| 512 | 512 | |
| 513 | - $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
| 513 | + $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
| 514 | 514 | |
| 515 | - return $resArray['index_name']; |
|
| 515 | + return $resArray['index_name']; |
|
| 516 | 516 | |
| 517 | - } else { |
|
| 517 | + } else { |
|
| 518 | 518 | |
| 519 | - if (TYPO3_DLOG) { |
|
| 519 | + if (TYPO3_DLOG) { |
|
| 520 | 520 | |
| 521 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIndexName('.$_uid.', '.$table.', '.$_pid.')] No "index_name" with UID "'.$uid.'" and PID "'.$pid.'" found in table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 521 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIndexName('.$_uid.', '.$table.', '.$_pid.')] No "index_name" with UID "'.$uid.'" and PID "'.$pid.'" found in table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 522 | 522 | |
| 523 | - } |
|
| 523 | + } |
|
| 524 | 524 | |
| 525 | - return ''; |
|
| 525 | + return ''; |
|
| 526 | 526 | |
| 527 | - } |
|
| 527 | + } |
|
| 528 | 528 | |
| 529 | - } |
|
| 529 | + } |
|
| 530 | 530 | |
| 531 | - /** |
|
| 532 | - * Get the UID for a given "index_name" |
|
| 533 | - * |
|
| 534 | - * @access public |
|
| 535 | - * |
|
| 536 | - * @param integer $index_name: The index_name of the record |
|
| 537 | - * @param string $table: Get the "index_name" from this table |
|
| 538 | - * @param integer $pid: Get the "index_name" from this page |
|
| 539 | - * |
|
| 540 | - * @return string "uid" for the given index_name |
|
| 541 | - */ |
|
| 542 | - public static function getIdFromIndexName($index_name, $table, $pid = -1) { |
|
| 531 | + /** |
|
| 532 | + * Get the UID for a given "index_name" |
|
| 533 | + * |
|
| 534 | + * @access public |
|
| 535 | + * |
|
| 536 | + * @param integer $index_name: The index_name of the record |
|
| 537 | + * @param string $table: Get the "index_name" from this table |
|
| 538 | + * @param integer $pid: Get the "index_name" from this page |
|
| 539 | + * |
|
| 540 | + * @return string "uid" for the given index_name |
|
| 541 | + */ |
|
| 542 | + public static function getIdFromIndexName($index_name, $table, $pid = -1) { |
|
| 543 | 543 | |
| 544 | - // Save parameters for logging purposes. |
|
| 545 | - $_index_name = $index_name; |
|
| 544 | + // Save parameters for logging purposes. |
|
| 545 | + $_index_name = $index_name; |
|
| 546 | 546 | |
| 547 | - $_pid = $pid; |
|
| 547 | + $_pid = $pid; |
|
| 548 | 548 | |
| 549 | - if (!$index_name || !in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'))) { |
|
| 549 | + if (!$index_name || !in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures', 'tx_dlf_solrcores'))) { |
|
| 550 | 550 | |
| 551 | - if (TYPO3_DLOG) { |
|
| 551 | + if (TYPO3_DLOG) { |
|
| 552 | 552 | |
| 553 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIdFromIndexName('.$_index_name.', '.$table.', '.$_pid.')] Invalid UID "'.$index_name.'" or table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 553 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIdFromIndexName('.$_index_name.', '.$table.', '.$_pid.')] Invalid UID "'.$index_name.'" or table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 554 | 554 | |
| 555 | - } |
|
| 555 | + } |
|
| 556 | 556 | |
| 557 | - return ''; |
|
| 557 | + return ''; |
|
| 558 | 558 | |
| 559 | - } |
|
| 559 | + } |
|
| 560 | 560 | |
| 561 | - $where = ''; |
|
| 561 | + $where = ''; |
|
| 562 | 562 | |
| 563 | - // Should we check for a specific PID, too? |
|
| 564 | - if ($pid !== -1) { |
|
| 563 | + // Should we check for a specific PID, too? |
|
| 564 | + if ($pid !== -1) { |
|
| 565 | 565 | |
| 566 | - $pid = max(intval($pid), 0); |
|
| 566 | + $pid = max(intval($pid), 0); |
|
| 567 | 567 | |
| 568 | - $where = ' AND '.$table.'.pid='.$pid; |
|
| 568 | + $where = ' AND '.$table.'.pid='.$pid; |
|
| 569 | 569 | |
| 570 | - } |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | - // Get index_name from database. |
|
| 573 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 574 | - $table.'.uid AS uid', |
|
| 575 | - $table, |
|
| 576 | - $table.'.index_name="'.$index_name.'"'.$where.self::whereClause($table), |
|
| 577 | - '', |
|
| 578 | - '', |
|
| 579 | - '1' |
|
| 580 | - ); |
|
| 572 | + // Get index_name from database. |
|
| 573 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 574 | + $table.'.uid AS uid', |
|
| 575 | + $table, |
|
| 576 | + $table.'.index_name="'.$index_name.'"'.$where.self::whereClause($table), |
|
| 577 | + '', |
|
| 578 | + '', |
|
| 579 | + '1' |
|
| 580 | + ); |
|
| 581 | 581 | |
| 582 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
| 582 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
| 583 | 583 | |
| 584 | - $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
| 584 | + $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
| 585 | 585 | |
| 586 | - return $resArray['uid']; |
|
| 586 | + return $resArray['uid']; |
|
| 587 | 587 | |
| 588 | - } else { |
|
| 588 | + } else { |
|
| 589 | 589 | |
| 590 | - if (TYPO3_DLOG) { |
|
| 590 | + if (TYPO3_DLOG) { |
|
| 591 | 591 | |
| 592 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIdFromIndexName('.$_index_name.', '.$table.', '.$_pid.')] No UID for given "index_name" "'.$index_name.'" and PID "'.$pid.'" found in table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 592 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getIdFromIndexName('.$_index_name.', '.$table.', '.$_pid.')] No UID for given "index_name" "'.$index_name.'" and PID "'.$pid.'" found in table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 593 | 593 | |
| 594 | - } |
|
| 594 | + } |
|
| 595 | 595 | |
| 596 | - return ''; |
|
| 596 | + return ''; |
|
| 597 | 597 | |
| 598 | - } |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | - } |
|
| 600 | + } |
|
| 601 | 601 | |
| 602 | - /** |
|
| 603 | - * Get language name from ISO code |
|
| 604 | - * |
|
| 605 | - * @access public |
|
| 606 | - * |
|
| 607 | - * @param string $code: ISO 639-1 or ISO 639-2/B language code |
|
| 608 | - * |
|
| 609 | - * @return string Localized full name of language or unchanged input |
|
| 610 | - */ |
|
| 611 | - public static function getLanguageName($code) { |
|
| 602 | + /** |
|
| 603 | + * Get language name from ISO code |
|
| 604 | + * |
|
| 605 | + * @access public |
|
| 606 | + * |
|
| 607 | + * @param string $code: ISO 639-1 or ISO 639-2/B language code |
|
| 608 | + * |
|
| 609 | + * @return string Localized full name of language or unchanged input |
|
| 610 | + */ |
|
| 611 | + public static function getLanguageName($code) { |
|
| 612 | 612 | |
| 613 | - // Analyze code and set appropriate ISO table. |
|
| 614 | - $isoCode = strtolower(trim($code)); |
|
| 613 | + // Analyze code and set appropriate ISO table. |
|
| 614 | + $isoCode = strtolower(trim($code)); |
|
| 615 | 615 | |
| 616 | - if (preg_match('/^[a-z]{3}$/', $isoCode)) { |
|
| 616 | + if (preg_match('/^[a-z]{3}$/', $isoCode)) { |
|
| 617 | 617 | |
| 618 | - $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey).'lib/ISO-639/iso-639-2b.xml'; |
|
| 618 | + $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey).'lib/ISO-639/iso-639-2b.xml'; |
|
| 619 | 619 | |
| 620 | - } elseif (preg_match('/^[a-z]{2}$/', $isoCode)) { |
|
| 620 | + } elseif (preg_match('/^[a-z]{2}$/', $isoCode)) { |
|
| 621 | 621 | |
| 622 | - $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey).'lib/ISO-639/iso-639-1.xml'; |
|
| 622 | + $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey).'lib/ISO-639/iso-639-1.xml'; |
|
| 623 | 623 | |
| 624 | - } else { |
|
| 624 | + } else { |
|
| 625 | 625 | |
| 626 | - // No ISO code, return unchanged. |
|
| 627 | - return $code; |
|
| 626 | + // No ISO code, return unchanged. |
|
| 627 | + return $code; |
|
| 628 | 628 | |
| 629 | - } |
|
| 629 | + } |
|
| 630 | 630 | |
| 631 | - // Load ISO table and get localized full name of language. |
|
| 632 | - if (TYPO3_MODE === 'FE') { |
|
| 631 | + // Load ISO table and get localized full name of language. |
|
| 632 | + if (TYPO3_MODE === 'FE') { |
|
| 633 | 633 | |
| 634 | - $iso639 = $GLOBALS['TSFE']->readLLfile($file); |
|
| 634 | + $iso639 = $GLOBALS['TSFE']->readLLfile($file); |
|
| 635 | 635 | |
| 636 | - if (!empty($iso639['default'][$isoCode])) { |
|
| 636 | + if (!empty($iso639['default'][$isoCode])) { |
|
| 637 | 637 | |
| 638 | - $lang = $GLOBALS['TSFE']->getLLL($isoCode, $iso639); |
|
| 638 | + $lang = $GLOBALS['TSFE']->getLLL($isoCode, $iso639); |
|
| 639 | 639 | |
| 640 | - } |
|
| 640 | + } |
|
| 641 | 641 | |
| 642 | - } elseif (TYPO3_MODE === 'BE') { |
|
| 642 | + } elseif (TYPO3_MODE === 'BE') { |
|
| 643 | 643 | |
| 644 | - $iso639 = $GLOBALS['LANG']->includeLLFile($file, FALSE, TRUE); |
|
| 644 | + $iso639 = $GLOBALS['LANG']->includeLLFile($file, FALSE, TRUE); |
|
| 645 | 645 | |
| 646 | - if (!empty($iso639['default'][$isoCode])) { |
|
| 646 | + if (!empty($iso639['default'][$isoCode])) { |
|
| 647 | 647 | |
| 648 | - $lang = $GLOBALS['LANG']->getLLL($isoCode, $iso639, FALSE); |
|
| 648 | + $lang = $GLOBALS['LANG']->getLLL($isoCode, $iso639, FALSE); |
|
| 649 | 649 | |
| 650 | - } |
|
| 650 | + } |
|
| 651 | 651 | |
| 652 | - } else { |
|
| 652 | + } else { |
|
| 653 | 653 | |
| 654 | - if (TYPO3_DLOG) { |
|
| 654 | + if (TYPO3_DLOG) { |
|
| 655 | 655 | |
| 656 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLanguageName('.$code.')] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 656 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLanguageName('.$code.')] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 657 | 657 | |
| 658 | - } |
|
| 658 | + } |
|
| 659 | 659 | |
| 660 | - return $code; |
|
| 660 | + return $code; |
|
| 661 | 661 | |
| 662 | - } |
|
| 662 | + } |
|
| 663 | 663 | |
| 664 | - if (!empty($lang)) { |
|
| 664 | + if (!empty($lang)) { |
|
| 665 | 665 | |
| 666 | - return $lang; |
|
| 666 | + return $lang; |
|
| 667 | 667 | |
| 668 | - } else { |
|
| 668 | + } else { |
|
| 669 | 669 | |
| 670 | - if (TYPO3_DLOG) { |
|
| 670 | + if (TYPO3_DLOG) { |
|
| 671 | 671 | |
| 672 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLanguageName('.$code.')] Language code "'.$code.'" not found in ISO-639 table', self::$extKey, SYSLOG_SEVERITY_NOTICE); |
|
| 672 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLanguageName('.$code.')] Language code "'.$code.'" not found in ISO-639 table', self::$extKey, SYSLOG_SEVERITY_NOTICE); |
|
| 673 | 673 | |
| 674 | - } |
|
| 674 | + } |
|
| 675 | 675 | |
| 676 | - return $code; |
|
| 676 | + return $code; |
|
| 677 | 677 | |
| 678 | - } |
|
| 678 | + } |
|
| 679 | 679 | |
| 680 | - } |
|
| 680 | + } |
|
| 681 | 681 | |
| 682 | - /** |
|
| 683 | - * Wrapper function for getting localizations in frontend and backend |
|
| 684 | - * |
|
| 685 | - * @param string $key: The locallang key to translate |
|
| 686 | - * @param boolean $hsc: Should the result be htmlspecialchar()'ed? |
|
| 687 | - * @param string $default: Default return value if no translation is available |
|
| 688 | - * |
|
| 689 | - * @return string The translated string or the given key on failure |
|
| 690 | - */ |
|
| 691 | - public static function getLL($key, $hsc = FALSE, $default = '') { |
|
| 682 | + /** |
|
| 683 | + * Wrapper function for getting localizations in frontend and backend |
|
| 684 | + * |
|
| 685 | + * @param string $key: The locallang key to translate |
|
| 686 | + * @param boolean $hsc: Should the result be htmlspecialchar()'ed? |
|
| 687 | + * @param string $default: Default return value if no translation is available |
|
| 688 | + * |
|
| 689 | + * @return string The translated string or the given key on failure |
|
| 690 | + */ |
|
| 691 | + public static function getLL($key, $hsc = FALSE, $default = '') { |
|
| 692 | 692 | |
| 693 | - // Set initial output to default value. |
|
| 694 | - $translated = (string) $default; |
|
| 693 | + // Set initial output to default value. |
|
| 694 | + $translated = (string) $default; |
|
| 695 | 695 | |
| 696 | - // Load common locallang file. |
|
| 697 | - if (empty(self::$locallang)) { |
|
| 696 | + // Load common locallang file. |
|
| 697 | + if (empty(self::$locallang)) { |
|
| 698 | 698 | |
| 699 | - $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey, 'common/locallang.xml'); |
|
| 699 | + $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey, 'common/locallang.xml'); |
|
| 700 | 700 | |
| 701 | - if (TYPO3_MODE === 'FE') { |
|
| 701 | + if (TYPO3_MODE === 'FE') { |
|
| 702 | 702 | |
| 703 | - self::$locallang = $GLOBALS['TSFE']->readLLfile($file); |
|
| 703 | + self::$locallang = $GLOBALS['TSFE']->readLLfile($file); |
|
| 704 | 704 | |
| 705 | - } elseif (TYPO3_MODE === 'BE') { |
|
| 705 | + } elseif (TYPO3_MODE === 'BE') { |
|
| 706 | 706 | |
| 707 | - self::$locallang = $GLOBALS['LANG']->includeLLFile($file, FALSE, TRUE); |
|
| 707 | + self::$locallang = $GLOBALS['LANG']->includeLLFile($file, FALSE, TRUE); |
|
| 708 | 708 | |
| 709 | - } elseif (TYPO3_DLOG) { |
|
| 709 | + } elseif (TYPO3_DLOG) { |
|
| 710 | 710 | |
| 711 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLL('.$key.', '.$default.', ['.($hsc ? 'TRUE' : 'FALSE').'])] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 711 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLL('.$key.', '.$default.', ['.($hsc ? 'TRUE' : 'FALSE').'])] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 712 | 712 | |
| 713 | - } |
|
| 713 | + } |
|
| 714 | 714 | |
| 715 | - } |
|
| 715 | + } |
|
| 716 | 716 | |
| 717 | - // Get translation. |
|
| 718 | - if (!empty(self::$locallang['default'][$key])) { |
|
| 717 | + // Get translation. |
|
| 718 | + if (!empty(self::$locallang['default'][$key])) { |
|
| 719 | 719 | |
| 720 | - if (TYPO3_MODE === 'FE') { |
|
| 720 | + if (TYPO3_MODE === 'FE') { |
|
| 721 | 721 | |
| 722 | - $translated = $GLOBALS['TSFE']->getLLL($key, self::$locallang); |
|
| 722 | + $translated = $GLOBALS['TSFE']->getLLL($key, self::$locallang); |
|
| 723 | 723 | |
| 724 | - } elseif (TYPO3_MODE === 'BE') { |
|
| 724 | + } elseif (TYPO3_MODE === 'BE') { |
|
| 725 | 725 | |
| 726 | - $translated = $GLOBALS['LANG']->getLLL($key, self::$locallang, FALSE); |
|
| 726 | + $translated = $GLOBALS['LANG']->getLLL($key, self::$locallang, FALSE); |
|
| 727 | 727 | |
| 728 | - } elseif (TYPO3_DLOG) { |
|
| 728 | + } elseif (TYPO3_DLOG) { |
|
| 729 | 729 | |
| 730 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLL('.$key.', '.$default.', ['.($hsc ? 'TRUE' : 'FALSE').'])] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 730 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLL('.$key.', '.$default.', ['.($hsc ? 'TRUE' : 'FALSE').'])] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 731 | 731 | |
| 732 | - } |
|
| 732 | + } |
|
| 733 | 733 | |
| 734 | - } |
|
| 734 | + } |
|
| 735 | 735 | |
| 736 | - // Escape HTML characters if applicable. |
|
| 737 | - if ($hsc) { |
|
| 736 | + // Escape HTML characters if applicable. |
|
| 737 | + if ($hsc) { |
|
| 738 | 738 | |
| 739 | - $translated = htmlspecialchars($translated); |
|
| 739 | + $translated = htmlspecialchars($translated); |
|
| 740 | 740 | |
| 741 | - } |
|
| 741 | + } |
|
| 742 | 742 | |
| 743 | - return $translated; |
|
| 743 | + return $translated; |
|
| 744 | 744 | |
| 745 | - } |
|
| 745 | + } |
|
| 746 | 746 | |
| 747 | - /** |
|
| 748 | - * Get the URN of an object |
|
| 749 | - * @see http://www.persistent-identifier.de/?link=316 |
|
| 750 | - * |
|
| 751 | - * @access public |
|
| 752 | - * |
|
| 753 | - * @param string $base: The namespace and base URN |
|
| 754 | - * @param string $id: The object's identifier |
|
| 755 | - * |
|
| 756 | - * @return string Uniform Resource Name as string |
|
| 757 | - */ |
|
| 758 | - public static function getURN($base, $id) { |
|
| 747 | + /** |
|
| 748 | + * Get the URN of an object |
|
| 749 | + * @see http://www.persistent-identifier.de/?link=316 |
|
| 750 | + * |
|
| 751 | + * @access public |
|
| 752 | + * |
|
| 753 | + * @param string $base: The namespace and base URN |
|
| 754 | + * @param string $id: The object's identifier |
|
| 755 | + * |
|
| 756 | + * @return string Uniform Resource Name as string |
|
| 757 | + */ |
|
| 758 | + public static function getURN($base, $id) { |
|
| 759 | 759 | |
| 760 | - $concordance = array ( |
|
| 761 | - '0' => 1, |
|
| 762 | - '1' => 2, |
|
| 763 | - '2' => 3, |
|
| 764 | - '3' => 4, |
|
| 765 | - '4' => 5, |
|
| 766 | - '5' => 6, |
|
| 767 | - '6' => 7, |
|
| 768 | - '7' => 8, |
|
| 769 | - '8' => 9, |
|
| 770 | - '9' => 41, |
|
| 771 | - 'a' => 18, |
|
| 772 | - 'b' => 14, |
|
| 773 | - 'c' => 19, |
|
| 774 | - 'd' => 15, |
|
| 775 | - 'e' => 16, |
|
| 776 | - 'f' => 21, |
|
| 777 | - 'g' => 22, |
|
| 778 | - 'h' => 23, |
|
| 779 | - 'i' => 24, |
|
| 780 | - 'j' => 25, |
|
| 781 | - 'k' => 42, |
|
| 782 | - 'l' => 26, |
|
| 783 | - 'm' => 27, |
|
| 784 | - 'n' => 13, |
|
| 785 | - 'o' => 28, |
|
| 786 | - 'p' => 29, |
|
| 787 | - 'q' => 31, |
|
| 788 | - 'r' => 12, |
|
| 789 | - 's' => 32, |
|
| 790 | - 't' => 33, |
|
| 791 | - 'u' => 11, |
|
| 792 | - 'v' => 34, |
|
| 793 | - 'w' => 35, |
|
| 794 | - 'x' => 36, |
|
| 795 | - 'y' => 37, |
|
| 796 | - 'z' => 38, |
|
| 797 | - '-' => 39, |
|
| 798 | - ':' => 17, |
|
| 799 | - ); |
|
| 760 | + $concordance = array ( |
|
| 761 | + '0' => 1, |
|
| 762 | + '1' => 2, |
|
| 763 | + '2' => 3, |
|
| 764 | + '3' => 4, |
|
| 765 | + '4' => 5, |
|
| 766 | + '5' => 6, |
|
| 767 | + '6' => 7, |
|
| 768 | + '7' => 8, |
|
| 769 | + '8' => 9, |
|
| 770 | + '9' => 41, |
|
| 771 | + 'a' => 18, |
|
| 772 | + 'b' => 14, |
|
| 773 | + 'c' => 19, |
|
| 774 | + 'd' => 15, |
|
| 775 | + 'e' => 16, |
|
| 776 | + 'f' => 21, |
|
| 777 | + 'g' => 22, |
|
| 778 | + 'h' => 23, |
|
| 779 | + 'i' => 24, |
|
| 780 | + 'j' => 25, |
|
| 781 | + 'k' => 42, |
|
| 782 | + 'l' => 26, |
|
| 783 | + 'm' => 27, |
|
| 784 | + 'n' => 13, |
|
| 785 | + 'o' => 28, |
|
| 786 | + 'p' => 29, |
|
| 787 | + 'q' => 31, |
|
| 788 | + 'r' => 12, |
|
| 789 | + 's' => 32, |
|
| 790 | + 't' => 33, |
|
| 791 | + 'u' => 11, |
|
| 792 | + 'v' => 34, |
|
| 793 | + 'w' => 35, |
|
| 794 | + 'x' => 36, |
|
| 795 | + 'y' => 37, |
|
| 796 | + 'z' => 38, |
|
| 797 | + '-' => 39, |
|
| 798 | + ':' => 17, |
|
| 799 | + ); |
|
| 800 | 800 | |
| 801 | - $urn = strtolower($base.$id); |
|
| 801 | + $urn = strtolower($base.$id); |
|
| 802 | 802 | |
| 803 | - if (preg_match('/[^a-z0-9:-]/', $urn)) { |
|
| 803 | + if (preg_match('/[^a-z0-9:-]/', $urn)) { |
|
| 804 | 804 | |
| 805 | - if (TYPO3_DLOG) { |
|
| 805 | + if (TYPO3_DLOG) { |
|
| 806 | 806 | |
| 807 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getURN('.$base.', '.$id.')] Invalid chars in given parameters', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 807 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getURN('.$base.', '.$id.')] Invalid chars in given parameters', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 808 | 808 | |
| 809 | - } |
|
| 809 | + } |
|
| 810 | 810 | |
| 811 | - return ''; |
|
| 811 | + return ''; |
|
| 812 | 812 | |
| 813 | - } |
|
| 813 | + } |
|
| 814 | 814 | |
| 815 | - $digits = ''; |
|
| 815 | + $digits = ''; |
|
| 816 | 816 | |
| 817 | - for ($i = 0, $j = strlen($urn); $i < $j; $i++) { |
|
| 817 | + for ($i = 0, $j = strlen($urn); $i < $j; $i++) { |
|
| 818 | 818 | |
| 819 | - $digits .= $concordance[substr($urn, $i, 1)]; |
|
| 819 | + $digits .= $concordance[substr($urn, $i, 1)]; |
|
| 820 | 820 | |
| 821 | - } |
|
| 821 | + } |
|
| 822 | 822 | |
| 823 | - $checksum = 0; |
|
| 823 | + $checksum = 0; |
|
| 824 | 824 | |
| 825 | - for ($i = 0, $j = strlen($digits); $i < $j; $i++) { |
|
| 825 | + for ($i = 0, $j = strlen($digits); $i < $j; $i++) { |
|
| 826 | 826 | |
| 827 | - $checksum += ($i + 1) * intval(substr($digits, $i, 1)); |
|
| 827 | + $checksum += ($i + 1) * intval(substr($digits, $i, 1)); |
|
| 828 | 828 | |
| 829 | - } |
|
| 829 | + } |
|
| 830 | 830 | |
| 831 | - $checksum = substr(intval($checksum / intval(substr($digits, -1, 1))), -1, 1); |
|
| 831 | + $checksum = substr(intval($checksum / intval(substr($digits, -1, 1))), -1, 1); |
|
| 832 | 832 | |
| 833 | - return $base.$id.$checksum; |
|
| 833 | + return $base.$id.$checksum; |
|
| 834 | 834 | |
| 835 | - } |
|
| 835 | + } |
|
| 836 | 836 | |
| 837 | - /** |
|
| 838 | - * Check if given ID is a valid Pica Production Number (PPN) |
|
| 839 | - * |
|
| 840 | - * @access public |
|
| 841 | - * |
|
| 842 | - * @param string $ppn: The identifier to check |
|
| 843 | - * |
|
| 844 | - * @return boolean Is $id a valid PPN? |
|
| 845 | - */ |
|
| 846 | - public static function isPPN($id) { |
|
| 837 | + /** |
|
| 838 | + * Check if given ID is a valid Pica Production Number (PPN) |
|
| 839 | + * |
|
| 840 | + * @access public |
|
| 841 | + * |
|
| 842 | + * @param string $ppn: The identifier to check |
|
| 843 | + * |
|
| 844 | + * @return boolean Is $id a valid PPN? |
|
| 845 | + */ |
|
| 846 | + public static function isPPN($id) { |
|
| 847 | 847 | |
| 848 | - return self::checkIdentifier($id, 'PPN'); |
|
| 848 | + return self::checkIdentifier($id, 'PPN'); |
|
| 849 | 849 | |
| 850 | - } |
|
| 850 | + } |
|
| 851 | 851 | |
| 852 | - /** |
|
| 853 | - * Load value from user's session. |
|
| 854 | - * |
|
| 855 | - * @access public |
|
| 856 | - * |
|
| 857 | - * @param string $key: Session data key for retrieval |
|
| 858 | - * |
|
| 859 | - * @return mixed Session value for given key or NULL on failure |
|
| 860 | - */ |
|
| 861 | - public static function loadFromSession($key) { |
|
| 852 | + /** |
|
| 853 | + * Load value from user's session. |
|
| 854 | + * |
|
| 855 | + * @access public |
|
| 856 | + * |
|
| 857 | + * @param string $key: Session data key for retrieval |
|
| 858 | + * |
|
| 859 | + * @return mixed Session value for given key or NULL on failure |
|
| 860 | + */ |
|
| 861 | + public static function loadFromSession($key) { |
|
| 862 | 862 | |
| 863 | - // Save parameter for logging purposes. |
|
| 864 | - $_key = $key; |
|
| 863 | + // Save parameter for logging purposes. |
|
| 864 | + $_key = $key; |
|
| 865 | 865 | |
| 866 | - // Cast to string for security reasons. |
|
| 867 | - $key = (string) $key; |
|
| 866 | + // Cast to string for security reasons. |
|
| 867 | + $key = (string) $key; |
|
| 868 | 868 | |
| 869 | - if (!$key) { |
|
| 869 | + if (!$key) { |
|
| 870 | 870 | |
| 871 | - if (TYPO3_DLOG) { |
|
| 871 | + if (TYPO3_DLOG) { |
|
| 872 | 872 | |
| 873 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->loadFromSession('.$_key.')] Invalid key "'.$key.'" for session data retrieval', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 873 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->loadFromSession('.$_key.')] Invalid key "'.$key.'" for session data retrieval', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 874 | 874 | |
| 875 | - } |
|
| 875 | + } |
|
| 876 | 876 | |
| 877 | - return; |
|
| 877 | + return; |
|
| 878 | 878 | |
| 879 | - } |
|
| 879 | + } |
|
| 880 | 880 | |
| 881 | - // Get the session data. |
|
| 882 | - if (TYPO3_MODE === 'FE') { |
|
| 881 | + // Get the session data. |
|
| 882 | + if (TYPO3_MODE === 'FE') { |
|
| 883 | 883 | |
| 884 | - return $GLOBALS['TSFE']->fe_user->getKey('ses', $key); |
|
| 884 | + return $GLOBALS['TSFE']->fe_user->getKey('ses', $key); |
|
| 885 | 885 | |
| 886 | - } elseif (TYPO3_MODE === 'BE') { |
|
| 886 | + } elseif (TYPO3_MODE === 'BE') { |
|
| 887 | 887 | |
| 888 | - return $GLOBALS['BE_USER']->getSessionData($key); |
|
| 888 | + return $GLOBALS['BE_USER']->getSessionData($key); |
|
| 889 | 889 | |
| 890 | - } else { |
|
| 890 | + } else { |
|
| 891 | 891 | |
| 892 | - if (TYPO3_DLOG) { |
|
| 892 | + if (TYPO3_DLOG) { |
|
| 893 | 893 | |
| 894 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->loadFromSession('.$_key.')] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 894 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->loadFromSession('.$_key.')] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 895 | 895 | |
| 896 | - } |
|
| 896 | + } |
|
| 897 | 897 | |
| 898 | - return; |
|
| 898 | + return; |
|
| 899 | 899 | |
| 900 | - } |
|
| 900 | + } |
|
| 901 | 901 | |
| 902 | - } |
|
| 902 | + } |
|
| 903 | 903 | |
| 904 | - /** |
|
| 905 | - * Process a data and/or command map with TYPO3 core engine. |
|
| 906 | - * |
|
| 907 | - * @access public |
|
| 908 | - * |
|
| 909 | - * @param array $data: Data map |
|
| 910 | - * @param array $cmd: Command map |
|
| 911 | - * @param boolean $reverseOrder: Should the command map be processed first? |
|
| 912 | - * @param boolean $be_user: Use current backend user's rights for processing? |
|
| 913 | - * |
|
| 914 | - * @return array Array of substituted "NEW..." identifiers and their actual UIDs. |
|
| 915 | - */ |
|
| 916 | - public static function processDB(array $data = array (), array $cmd = array (), $reverseOrder = FALSE, $be_user = FALSE) { |
|
| 904 | + /** |
|
| 905 | + * Process a data and/or command map with TYPO3 core engine. |
|
| 906 | + * |
|
| 907 | + * @access public |
|
| 908 | + * |
|
| 909 | + * @param array $data: Data map |
|
| 910 | + * @param array $cmd: Command map |
|
| 911 | + * @param boolean $reverseOrder: Should the command map be processed first? |
|
| 912 | + * @param boolean $be_user: Use current backend user's rights for processing? |
|
| 913 | + * |
|
| 914 | + * @return array Array of substituted "NEW..." identifiers and their actual UIDs. |
|
| 915 | + */ |
|
| 916 | + public static function processDB(array $data = array (), array $cmd = array (), $reverseOrder = FALSE, $be_user = FALSE) { |
|
| 917 | 917 | |
| 918 | - // Instantiate TYPO3 core engine. |
|
| 919 | - $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler'); |
|
| 918 | + // Instantiate TYPO3 core engine. |
|
| 919 | + $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler'); |
|
| 920 | 920 | |
| 921 | - // Set some configuration variables. |
|
| 922 | - $tce->stripslashes_values = FALSE; |
|
| 921 | + // Set some configuration variables. |
|
| 922 | + $tce->stripslashes_values = FALSE; |
|
| 923 | 923 | |
| 924 | - // Get backend user for processing. |
|
| 925 | - if ($be_user && isset($GLOBALS['BE_USER'])) { |
|
| 924 | + // Get backend user for processing. |
|
| 925 | + if ($be_user && isset($GLOBALS['BE_USER'])) { |
|
| 926 | 926 | |
| 927 | - $user = $GLOBALS['BE_USER']; |
|
| 927 | + $user = $GLOBALS['BE_USER']; |
|
| 928 | 928 | |
| 929 | - } else { |
|
| 929 | + } else { |
|
| 930 | 930 | |
| 931 | - $user = self::getBeUser(); |
|
| 931 | + $user = self::getBeUser(); |
|
| 932 | 932 | |
| 933 | - } |
|
| 933 | + } |
|
| 934 | 934 | |
| 935 | - // Load data and command arrays. |
|
| 936 | - $tce->start($data, $cmd, $user); |
|
| 935 | + // Load data and command arrays. |
|
| 936 | + $tce->start($data, $cmd, $user); |
|
| 937 | 937 | |
| 938 | - // Process command map first if default order is reversed. |
|
| 939 | - if ($cmd && $reverseOrder) { |
|
| 938 | + // Process command map first if default order is reversed. |
|
| 939 | + if ($cmd && $reverseOrder) { |
|
| 940 | 940 | |
| 941 | - $tce->process_cmdmap(); |
|
| 941 | + $tce->process_cmdmap(); |
|
| 942 | 942 | |
| 943 | - } |
|
| 943 | + } |
|
| 944 | 944 | |
| 945 | - // Process data map. |
|
| 946 | - if ($data) { |
|
| 945 | + // Process data map. |
|
| 946 | + if ($data) { |
|
| 947 | 947 | |
| 948 | - $tce->process_datamap(); |
|
| 948 | + $tce->process_datamap(); |
|
| 949 | 949 | |
| 950 | - } |
|
| 950 | + } |
|
| 951 | 951 | |
| 952 | - // Process command map if processing order is not reversed. |
|
| 953 | - if ($cmd && !$reverseOrder) { |
|
| 952 | + // Process command map if processing order is not reversed. |
|
| 953 | + if ($cmd && !$reverseOrder) { |
|
| 954 | 954 | |
| 955 | - $tce->process_cmdmap(); |
|
| 955 | + $tce->process_cmdmap(); |
|
| 956 | 956 | |
| 957 | - } |
|
| 957 | + } |
|
| 958 | 958 | |
| 959 | - return $tce->substNEWwithIDs; |
|
| 959 | + return $tce->substNEWwithIDs; |
|
| 960 | 960 | |
| 961 | - } |
|
| 961 | + } |
|
| 962 | 962 | |
| 963 | - /** |
|
| 964 | - * Process a data and/or command map with TYPO3 core engine as admin. |
|
| 965 | - * |
|
| 966 | - * @access public |
|
| 967 | - * |
|
| 968 | - * @param array $data: Data map |
|
| 969 | - * @param array $cmd: Command map |
|
| 970 | - * @param boolean $reverseOrder: Should the command map be processed first? |
|
| 971 | - * |
|
| 972 | - * @return array Array of substituted "NEW..." identifiers and their actual UIDs. |
|
| 973 | - */ |
|
| 974 | - public static function processDBasAdmin(array $data = array (), array $cmd = array (), $reverseOrder = FALSE) { |
|
| 963 | + /** |
|
| 964 | + * Process a data and/or command map with TYPO3 core engine as admin. |
|
| 965 | + * |
|
| 966 | + * @access public |
|
| 967 | + * |
|
| 968 | + * @param array $data: Data map |
|
| 969 | + * @param array $cmd: Command map |
|
| 970 | + * @param boolean $reverseOrder: Should the command map be processed first? |
|
| 971 | + * |
|
| 972 | + * @return array Array of substituted "NEW..." identifiers and their actual UIDs. |
|
| 973 | + */ |
|
| 974 | + public static function processDBasAdmin(array $data = array (), array $cmd = array (), $reverseOrder = FALSE) { |
|
| 975 | 975 | |
| 976 | - if (TYPO3_MODE === 'BE' && $GLOBALS['BE_USER']->isAdmin()) { |
|
| 976 | + if (TYPO3_MODE === 'BE' && $GLOBALS['BE_USER']->isAdmin()) { |
|
| 977 | 977 | |
| 978 | - return self::processDB($data, $cmd, $reverseOrder, TRUE); |
|
| 978 | + return self::processDB($data, $cmd, $reverseOrder, TRUE); |
|
| 979 | 979 | |
| 980 | - } else { |
|
| 980 | + } else { |
|
| 981 | 981 | |
| 982 | - if (TYPO3_DLOG) { |
|
| 982 | + if (TYPO3_DLOG) { |
|
| 983 | 983 | |
| 984 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->processDBasAdmin([data->data], [data->cmd], ['.($reverseOrder ? 'TRUE' : 'FALSE').'])] Current backend user has no admin privileges', self::$extKey, SYSLOG_SEVERITY_ERROR, array ('data' => $data, 'cmd' => $cmd)); |
|
| 984 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->processDBasAdmin([data->data], [data->cmd], ['.($reverseOrder ? 'TRUE' : 'FALSE').'])] Current backend user has no admin privileges', self::$extKey, SYSLOG_SEVERITY_ERROR, array ('data' => $data, 'cmd' => $cmd)); |
|
| 985 | 985 | |
| 986 | - } |
|
| 986 | + } |
|
| 987 | 987 | |
| 988 | - return array (); |
|
| 988 | + return array (); |
|
| 989 | 989 | |
| 990 | - } |
|
| 990 | + } |
|
| 991 | 991 | |
| 992 | - } |
|
| 992 | + } |
|
| 993 | 993 | |
| 994 | - /** |
|
| 995 | - * Fetches and renders all available flash messages from the queue. |
|
| 996 | - * |
|
| 997 | - * @return string All flash messages in the queue rendered as HTML. |
|
| 998 | - */ |
|
| 999 | - public static function renderFlashMessages() { |
|
| 994 | + /** |
|
| 995 | + * Fetches and renders all available flash messages from the queue. |
|
| 996 | + * |
|
| 997 | + * @return string All flash messages in the queue rendered as HTML. |
|
| 998 | + */ |
|
| 999 | + public static function renderFlashMessages() { |
|
| 1000 | 1000 | |
| 1001 | - $flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); |
|
| 1001 | + $flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); |
|
| 1002 | 1002 | |
| 1003 | - $content = ''; |
|
| 1003 | + $content = ''; |
|
| 1004 | 1004 | |
| 1005 | - if (version_compare(TYPO3_branch, '7.4', '<')) { |
|
| 1005 | + if (version_compare(TYPO3_branch, '7.4', '<')) { |
|
| 1006 | 1006 | |
| 1007 | - // For TYPO3 6.2 - 7.3, we can use the existing method. |
|
| 1008 | - $content .= $flashMessageService->getMessageQueueByIdentifier()->renderFlashMessages(); |
|
| 1007 | + // For TYPO3 6.2 - 7.3, we can use the existing method. |
|
| 1008 | + $content .= $flashMessageService->getMessageQueueByIdentifier()->renderFlashMessages(); |
|
| 1009 | 1009 | |
| 1010 | - } else { |
|
| 1010 | + } else { |
|
| 1011 | 1011 | |
| 1012 | - // Since TYPO3 7.4.0, \TYPO3\CMS\Core\Messaging\FlashMessageQueue::renderFlashMessages |
|
| 1013 | - // uses htmlspecialchars on all texts, but we have message text with HTML tags. |
|
| 1014 | - // Therefore we copy the implementation from 7.4.0, but remove the htmlspecialchars call. |
|
| 1015 | - $flashMessages = $flashMessageService->getMessageQueueByIdentifier()->getAllMessagesAndFlush(); |
|
| 1012 | + // Since TYPO3 7.4.0, \TYPO3\CMS\Core\Messaging\FlashMessageQueue::renderFlashMessages |
|
| 1013 | + // uses htmlspecialchars on all texts, but we have message text with HTML tags. |
|
| 1014 | + // Therefore we copy the implementation from 7.4.0, but remove the htmlspecialchars call. |
|
| 1015 | + $flashMessages = $flashMessageService->getMessageQueueByIdentifier()->getAllMessagesAndFlush(); |
|
| 1016 | 1016 | |
| 1017 | - if (!empty($flashMessages)) { |
|
| 1017 | + if (!empty($flashMessages)) { |
|
| 1018 | 1018 | |
| 1019 | - $content .= '<ul class="typo3-messages">'; |
|
| 1019 | + $content .= '<ul class="typo3-messages">'; |
|
| 1020 | 1020 | |
| 1021 | - foreach ($flashMessages as $flashMessage) { |
|
| 1021 | + foreach ($flashMessages as $flashMessage) { |
|
| 1022 | 1022 | |
| 1023 | - $severityClass = sprintf('alert %s', $flashMessage->getClass()); |
|
| 1023 | + $severityClass = sprintf('alert %s', $flashMessage->getClass()); |
|
| 1024 | 1024 | |
| 1025 | - //~ $messageContent = htmlspecialchars($flashMessage->getMessage()); |
|
| 1025 | + //~ $messageContent = htmlspecialchars($flashMessage->getMessage()); |
|
| 1026 | 1026 | |
| 1027 | - $messageContent = $flashMessage->getMessage(); |
|
| 1027 | + $messageContent = $flashMessage->getMessage(); |
|
| 1028 | 1028 | |
| 1029 | - if ($flashMessage->getTitle() !== '') { |
|
| 1029 | + if ($flashMessage->getTitle() !== '') { |
|
| 1030 | 1030 | |
| 1031 | - $messageContent = sprintf('<h4>%s</h4>', htmlspecialchars($flashMessage->getTitle())) . $messageContent; |
|
| 1031 | + $messageContent = sprintf('<h4>%s</h4>', htmlspecialchars($flashMessage->getTitle())) . $messageContent; |
|
| 1032 | 1032 | |
| 1033 | - } |
|
| 1033 | + } |
|
| 1034 | 1034 | |
| 1035 | - $content .= sprintf('<li class="%s">%s</li>', htmlspecialchars($severityClass), $messageContent); |
|
| 1035 | + $content .= sprintf('<li class="%s">%s</li>', htmlspecialchars($severityClass), $messageContent); |
|
| 1036 | 1036 | |
| 1037 | - } |
|
| 1037 | + } |
|
| 1038 | 1038 | |
| 1039 | - $content .= '</ul>'; |
|
| 1039 | + $content .= '</ul>'; |
|
| 1040 | 1040 | |
| 1041 | - } |
|
| 1041 | + } |
|
| 1042 | 1042 | |
| 1043 | - } |
|
| 1043 | + } |
|
| 1044 | 1044 | |
| 1045 | - return $content; |
|
| 1045 | + return $content; |
|
| 1046 | 1046 | |
| 1047 | - } |
|
| 1047 | + } |
|
| 1048 | 1048 | |
| 1049 | - /** |
|
| 1050 | - * Save given value to user's session. |
|
| 1051 | - * |
|
| 1052 | - * @access public |
|
| 1053 | - * |
|
| 1054 | - * @param mixed $value: Value to save |
|
| 1055 | - * @param string $key: Session data key for saving |
|
| 1056 | - * |
|
| 1057 | - * @return boolean TRUE on success, FALSE on failure |
|
| 1058 | - */ |
|
| 1059 | - public static function saveToSession($value, $key) { |
|
| 1049 | + /** |
|
| 1050 | + * Save given value to user's session. |
|
| 1051 | + * |
|
| 1052 | + * @access public |
|
| 1053 | + * |
|
| 1054 | + * @param mixed $value: Value to save |
|
| 1055 | + * @param string $key: Session data key for saving |
|
| 1056 | + * |
|
| 1057 | + * @return boolean TRUE on success, FALSE on failure |
|
| 1058 | + */ |
|
| 1059 | + public static function saveToSession($value, $key) { |
|
| 1060 | 1060 | |
| 1061 | - // Save parameter for logging purposes. |
|
| 1062 | - $_key = $key; |
|
| 1061 | + // Save parameter for logging purposes. |
|
| 1062 | + $_key = $key; |
|
| 1063 | 1063 | |
| 1064 | - // Cast to string for security reasons. |
|
| 1065 | - $key = (string) $key; |
|
| 1064 | + // Cast to string for security reasons. |
|
| 1065 | + $key = (string) $key; |
|
| 1066 | 1066 | |
| 1067 | - if (!$key) { |
|
| 1067 | + if (!$key) { |
|
| 1068 | 1068 | |
| 1069 | - if (TYPO3_DLOG) { |
|
| 1069 | + if (TYPO3_DLOG) { |
|
| 1070 | 1070 | |
| 1071 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->saveToSession([data], '.$_key.')] Invalid key "'.$key.'" for session data saving', self::$extKey, SYSLOG_SEVERITY_WARNING, $value); |
|
| 1071 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->saveToSession([data], '.$_key.')] Invalid key "'.$key.'" for session data saving', self::$extKey, SYSLOG_SEVERITY_WARNING, $value); |
|
| 1072 | 1072 | |
| 1073 | - } |
|
| 1073 | + } |
|
| 1074 | 1074 | |
| 1075 | - return FALSE; |
|
| 1075 | + return FALSE; |
|
| 1076 | 1076 | |
| 1077 | - } |
|
| 1077 | + } |
|
| 1078 | 1078 | |
| 1079 | - // Save value in session data. |
|
| 1080 | - if (TYPO3_MODE === 'FE') { |
|
| 1079 | + // Save value in session data. |
|
| 1080 | + if (TYPO3_MODE === 'FE') { |
|
| 1081 | 1081 | |
| 1082 | - $GLOBALS['TSFE']->fe_user->setKey('ses', $key, $value); |
|
| 1082 | + $GLOBALS['TSFE']->fe_user->setKey('ses', $key, $value); |
|
| 1083 | 1083 | |
| 1084 | - $GLOBALS['TSFE']->fe_user->storeSessionData(); |
|
| 1084 | + $GLOBALS['TSFE']->fe_user->storeSessionData(); |
|
| 1085 | 1085 | |
| 1086 | - return TRUE; |
|
| 1086 | + return TRUE; |
|
| 1087 | 1087 | |
| 1088 | - } elseif (TYPO3_MODE === 'BE') { |
|
| 1088 | + } elseif (TYPO3_MODE === 'BE') { |
|
| 1089 | 1089 | |
| 1090 | - $GLOBALS['BE_USER']->setAndSaveSessionData($key, $value); |
|
| 1090 | + $GLOBALS['BE_USER']->setAndSaveSessionData($key, $value); |
|
| 1091 | 1091 | |
| 1092 | - return TRUE; |
|
| 1092 | + return TRUE; |
|
| 1093 | 1093 | |
| 1094 | - } else { |
|
| 1094 | + } else { |
|
| 1095 | 1095 | |
| 1096 | - if (TYPO3_DLOG) { |
|
| 1096 | + if (TYPO3_DLOG) { |
|
| 1097 | 1097 | |
| 1098 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->saveToSession([data], '.$_key.')] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR, $data); |
|
| 1098 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->saveToSession([data], '.$_key.')] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR, $data); |
|
| 1099 | 1099 | |
| 1100 | - } |
|
| 1100 | + } |
|
| 1101 | 1101 | |
| 1102 | - return FALSE; |
|
| 1102 | + return FALSE; |
|
| 1103 | 1103 | |
| 1104 | - } |
|
| 1104 | + } |
|
| 1105 | 1105 | |
| 1106 | - } |
|
| 1106 | + } |
|
| 1107 | 1107 | |
| 1108 | - /** |
|
| 1109 | - * This translates an internal "index_name" |
|
| 1110 | - * |
|
| 1111 | - * @access public |
|
| 1112 | - * |
|
| 1113 | - * @param string $index_name: The internal "index_name" to translate |
|
| 1114 | - * @param string $table: Get the translation from this table |
|
| 1115 | - * @param string $pid: Get the translation from this page |
|
| 1116 | - * |
|
| 1117 | - * @return string Localized label for $index_name |
|
| 1118 | - */ |
|
| 1119 | - public static function translate($index_name, $table, $pid) { |
|
| 1108 | + /** |
|
| 1109 | + * This translates an internal "index_name" |
|
| 1110 | + * |
|
| 1111 | + * @access public |
|
| 1112 | + * |
|
| 1113 | + * @param string $index_name: The internal "index_name" to translate |
|
| 1114 | + * @param string $table: Get the translation from this table |
|
| 1115 | + * @param string $pid: Get the translation from this page |
|
| 1116 | + * |
|
| 1117 | + * @return string Localized label for $index_name |
|
| 1118 | + */ |
|
| 1119 | + public static function translate($index_name, $table, $pid) { |
|
| 1120 | 1120 | |
| 1121 | - // Save parameters for logging purposes. |
|
| 1122 | - $_index_name = $index_name; |
|
| 1121 | + // Save parameters for logging purposes. |
|
| 1122 | + $_index_name = $index_name; |
|
| 1123 | 1123 | |
| 1124 | - $_pid = $pid; |
|
| 1124 | + $_pid = $pid; |
|
| 1125 | 1125 | |
| 1126 | - // Load labels into static variable for future use. |
|
| 1127 | - static $labels = array (); |
|
| 1126 | + // Load labels into static variable for future use. |
|
| 1127 | + static $labels = array (); |
|
| 1128 | 1128 | |
| 1129 | - // Sanitize input. |
|
| 1130 | - $pid = max(intval($pid), 0); |
|
| 1129 | + // Sanitize input. |
|
| 1130 | + $pid = max(intval($pid), 0); |
|
| 1131 | 1131 | |
| 1132 | - if (!$pid) { |
|
| 1132 | + if (!$pid) { |
|
| 1133 | 1133 | |
| 1134 | - if (TYPO3_DLOG) { |
|
| 1134 | + if (TYPO3_DLOG) { |
|
| 1135 | 1135 | |
| 1136 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->translate('.$_index_name.', '.$table.', '.$_pid.')] Invalid PID "'.$pid.'" for translation', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 1136 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->translate('.$_index_name.', '.$table.', '.$_pid.')] Invalid PID "'.$pid.'" for translation', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 1137 | 1137 | |
| 1138 | - } |
|
| 1138 | + } |
|
| 1139 | 1139 | |
| 1140 | - return $index_name; |
|
| 1140 | + return $index_name; |
|
| 1141 | 1141 | |
| 1142 | - } |
|
| 1142 | + } |
|
| 1143 | 1143 | |
| 1144 | - // Check if "index_name" is an UID. |
|
| 1145 | - if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($index_name)) { |
|
| 1144 | + // Check if "index_name" is an UID. |
|
| 1145 | + if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($index_name)) { |
|
| 1146 | 1146 | |
| 1147 | - $index_name = self::getIndexName($index_name, $table, $pid); |
|
| 1147 | + $index_name = self::getIndexName($index_name, $table, $pid); |
|
| 1148 | 1148 | |
| 1149 | - } |
|
| 1149 | + } |
|
| 1150 | 1150 | |
| 1151 | - /* $labels already contains the translated content element, but with the index_name of the translated content element itself |
|
| 1151 | + /* $labels already contains the translated content element, but with the index_name of the translated content element itself |
|
| 1152 | 1152 | * and not with the $index_name of the original that we receive here. So we have to determine the index_name of the |
| 1153 | 1153 | * associated translated content element. E.g. $labels['title0'] != $index_name = title. */ |
| 1154 | 1154 | |
| 1155 | - // First fetch the uid of the received index_name |
|
| 1156 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 1157 | - 'uid, l18n_parent', |
|
| 1158 | - $table, |
|
| 1159 | - 'pid='.$pid.' AND index_name="'.$index_name.'"'.self::whereClause($table, TRUE), |
|
| 1160 | - '', |
|
| 1161 | - '', |
|
| 1162 | - '' |
|
| 1163 | - ); |
|
| 1155 | + // First fetch the uid of the received index_name |
|
| 1156 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 1157 | + 'uid, l18n_parent', |
|
| 1158 | + $table, |
|
| 1159 | + 'pid='.$pid.' AND index_name="'.$index_name.'"'.self::whereClause($table, TRUE), |
|
| 1160 | + '', |
|
| 1161 | + '', |
|
| 1162 | + '' |
|
| 1163 | + ); |
|
| 1164 | 1164 | |
| 1165 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
| 1165 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
| 1166 | 1166 | |
| 1167 | - // Now we use the uid of the l18_parent to fetch the index_name of the translated content element. |
|
| 1168 | - $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
| 1167 | + // Now we use the uid of the l18_parent to fetch the index_name of the translated content element. |
|
| 1168 | + $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
| 1169 | 1169 | |
| 1170 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 1171 | - 'index_name', |
|
| 1172 | - $table, |
|
| 1173 | - 'pid='.$pid.' AND uid='.$resArray['l18n_parent'].' AND sys_language_uid='.intval($GLOBALS['TSFE']->sys_language_content).self::whereClause($table, TRUE), |
|
| 1174 | - '', |
|
| 1175 | - '', |
|
| 1176 | - '' |
|
| 1177 | - ); |
|
| 1170 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 1171 | + 'index_name', |
|
| 1172 | + $table, |
|
| 1173 | + 'pid='.$pid.' AND uid='.$resArray['l18n_parent'].' AND sys_language_uid='.intval($GLOBALS['TSFE']->sys_language_content).self::whereClause($table, TRUE), |
|
| 1174 | + '', |
|
| 1175 | + '', |
|
| 1176 | + '' |
|
| 1177 | + ); |
|
| 1178 | 1178 | |
| 1179 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
| 1179 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
| 1180 | 1180 | |
| 1181 | - // If there is an translated content element, overwrite the received $index_name. |
|
| 1182 | - $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
| 1181 | + // If there is an translated content element, overwrite the received $index_name. |
|
| 1182 | + $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
| 1183 | 1183 | |
| 1184 | - $index_name = $resArray['index_name']; |
|
| 1184 | + $index_name = $resArray['index_name']; |
|
| 1185 | 1185 | |
| 1186 | - } |
|
| 1186 | + } |
|
| 1187 | 1187 | |
| 1188 | - } |
|
| 1188 | + } |
|
| 1189 | 1189 | |
| 1190 | - // Check if we already got a translation. |
|
| 1191 | - if (empty($labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name])) { |
|
| 1190 | + // Check if we already got a translation. |
|
| 1191 | + if (empty($labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name])) { |
|
| 1192 | 1192 | |
| 1193 | - // Check if this table is allowed for translation. |
|
| 1194 | - if (in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures'))) { |
|
| 1193 | + // Check if this table is allowed for translation. |
|
| 1194 | + if (in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures'))) { |
|
| 1195 | 1195 | |
| 1196 | - $additionalWhere = ' AND sys_language_uid IN (-1,0)'; |
|
| 1196 | + $additionalWhere = ' AND sys_language_uid IN (-1,0)'; |
|
| 1197 | 1197 | |
| 1198 | - if ($GLOBALS['TSFE']->sys_language_content > 0) { |
|
| 1198 | + if ($GLOBALS['TSFE']->sys_language_content > 0) { |
|
| 1199 | 1199 | |
| 1200 | - $additionalWhere = ' AND (sys_language_uid IN (-1,0) OR (sys_language_uid='.intval($GLOBALS['TSFE']->sys_language_content).' AND l18n_parent=0))'; |
|
| 1200 | + $additionalWhere = ' AND (sys_language_uid IN (-1,0) OR (sys_language_uid='.intval($GLOBALS['TSFE']->sys_language_content).' AND l18n_parent=0))'; |
|
| 1201 | 1201 | |
| 1202 | - } |
|
| 1202 | + } |
|
| 1203 | 1203 | |
| 1204 | - // Get labels from database. |
|
| 1205 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 1206 | - '*', |
|
| 1207 | - $table, |
|
| 1208 | - 'pid='.$pid.$additionalWhere.self::whereClause($table, TRUE), |
|
| 1209 | - '', |
|
| 1210 | - '', |
|
| 1211 | - '' |
|
| 1212 | - ); |
|
| 1204 | + // Get labels from database. |
|
| 1205 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 1206 | + '*', |
|
| 1207 | + $table, |
|
| 1208 | + 'pid='.$pid.$additionalWhere.self::whereClause($table, TRUE), |
|
| 1209 | + '', |
|
| 1210 | + '', |
|
| 1211 | + '' |
|
| 1212 | + ); |
|
| 1213 | 1213 | |
| 1214 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
| 1214 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
| 1215 | 1215 | |
| 1216 | - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
| 1216 | + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
| 1217 | 1217 | |
| 1218 | - // Overlay localized labels if available. |
|
| 1219 | - if ($GLOBALS['TSFE']->sys_language_content > 0) { |
|
| 1218 | + // Overlay localized labels if available. |
|
| 1219 | + if ($GLOBALS['TSFE']->sys_language_content > 0) { |
|
| 1220 | 1220 | |
| 1221 | - $resArray = $GLOBALS['TSFE']->sys_page->getRecordOverlay($table, $resArray,$GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL); |
|
| 1221 | + $resArray = $GLOBALS['TSFE']->sys_page->getRecordOverlay($table, $resArray,$GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL); |
|
| 1222 | 1222 | |
| 1223 | - } |
|
| 1223 | + } |
|
| 1224 | 1224 | |
| 1225 | - if ($resArray) { |
|
| 1225 | + if ($resArray) { |
|
| 1226 | 1226 | |
| 1227 | - $labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$resArray['index_name']] = $resArray['label']; |
|
| 1227 | + $labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$resArray['index_name']] = $resArray['label']; |
|
| 1228 | 1228 | |
| 1229 | - } |
|
| 1229 | + } |
|
| 1230 | 1230 | |
| 1231 | - } |
|
| 1231 | + } |
|
| 1232 | 1232 | |
| 1233 | - } else { |
|
| 1233 | + } else { |
|
| 1234 | 1234 | |
| 1235 | - if (TYPO3_DLOG) { |
|
| 1235 | + if (TYPO3_DLOG) { |
|
| 1236 | 1236 | |
| 1237 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->translate('.$_index_name.', '.$table.', '.$_pid.')] No translation with PID "'.$pid.'" available in table "'.$table.'" or translation not accessible', self::extKey, SYSLOG_SEVERITY_NOTICE); |
|
| 1237 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->translate('.$_index_name.', '.$table.', '.$_pid.')] No translation with PID "'.$pid.'" available in table "'.$table.'" or translation not accessible', self::extKey, SYSLOG_SEVERITY_NOTICE); |
|
| 1238 | 1238 | |
| 1239 | - } |
|
| 1239 | + } |
|
| 1240 | 1240 | |
| 1241 | - } |
|
| 1241 | + } |
|
| 1242 | 1242 | |
| 1243 | - } else { |
|
| 1243 | + } else { |
|
| 1244 | 1244 | |
| 1245 | - if (TYPO3_DLOG) { |
|
| 1245 | + if (TYPO3_DLOG) { |
|
| 1246 | 1246 | |
| 1247 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->translate('.$_index_name.', '.$table.', '.$_pid.')] No translations available for table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 1247 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->translate('.$_index_name.', '.$table.', '.$_pid.')] No translations available for table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 1248 | 1248 | |
| 1249 | - } |
|
| 1249 | + } |
|
| 1250 | 1250 | |
| 1251 | - } |
|
| 1251 | + } |
|
| 1252 | 1252 | |
| 1253 | - } |
|
| 1253 | + } |
|
| 1254 | 1254 | |
| 1255 | - if (!empty($labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name])) { |
|
| 1255 | + if (!empty($labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name])) { |
|
| 1256 | 1256 | |
| 1257 | - return $labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name]; |
|
| 1257 | + return $labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name]; |
|
| 1258 | 1258 | |
| 1259 | - } else { |
|
| 1259 | + } else { |
|
| 1260 | 1260 | |
| 1261 | - return $index_name; |
|
| 1261 | + return $index_name; |
|
| 1262 | 1262 | |
| 1263 | - } |
|
| 1263 | + } |
|
| 1264 | 1264 | |
| 1265 | - } |
|
| 1265 | + } |
|
| 1266 | 1266 | |
| 1267 | - /** |
|
| 1268 | - * This returns the additional WHERE clause of a table based on its TCA configuration |
|
| 1269 | - * |
|
| 1270 | - * @access public |
|
| 1271 | - * |
|
| 1272 | - * @param string $table: Table name as defined in TCA |
|
| 1273 | - * @param boolean $showHidden: Ignore the hidden flag? |
|
| 1274 | - * |
|
| 1275 | - * @return string Additional WHERE clause |
|
| 1276 | - */ |
|
| 1277 | - public static function whereClause($table, $showHidden = FALSE) { |
|
| 1267 | + /** |
|
| 1268 | + * This returns the additional WHERE clause of a table based on its TCA configuration |
|
| 1269 | + * |
|
| 1270 | + * @access public |
|
| 1271 | + * |
|
| 1272 | + * @param string $table: Table name as defined in TCA |
|
| 1273 | + * @param boolean $showHidden: Ignore the hidden flag? |
|
| 1274 | + * |
|
| 1275 | + * @return string Additional WHERE clause |
|
| 1276 | + */ |
|
| 1277 | + public static function whereClause($table, $showHidden = FALSE) { |
|
| 1278 | 1278 | |
| 1279 | - if (TYPO3_MODE === 'FE') { |
|
| 1279 | + if (TYPO3_MODE === 'FE') { |
|
| 1280 | 1280 | |
| 1281 | - // Table "tx_dlf_formats" always has PID 0. |
|
| 1282 | - if ($table == 'tx_dlf_formats') { |
|
| 1281 | + // Table "tx_dlf_formats" always has PID 0. |
|
| 1282 | + if ($table == 'tx_dlf_formats') { |
|
| 1283 | 1283 | |
| 1284 | - return \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table); |
|
| 1284 | + return \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table); |
|
| 1285 | 1285 | |
| 1286 | - } |
|
| 1286 | + } |
|
| 1287 | 1287 | |
| 1288 | - // Should we ignore the record's hidden flag? |
|
| 1289 | - $ignoreHide = -1; |
|
| 1288 | + // Should we ignore the record's hidden flag? |
|
| 1289 | + $ignoreHide = -1; |
|
| 1290 | 1290 | |
| 1291 | - if ($showHidden) { |
|
| 1291 | + if ($showHidden) { |
|
| 1292 | 1292 | |
| 1293 | - $ignoreHide = 1; |
|
| 1293 | + $ignoreHide = 1; |
|
| 1294 | 1294 | |
| 1295 | - } |
|
| 1295 | + } |
|
| 1296 | 1296 | |
| 1297 | - // $GLOBALS['TSFE']->sys_page is not always available in frontend. |
|
| 1298 | - if (is_object($GLOBALS['TSFE']->sys_page)) { |
|
| 1297 | + // $GLOBALS['TSFE']->sys_page is not always available in frontend. |
|
| 1298 | + if (is_object($GLOBALS['TSFE']->sys_page)) { |
|
| 1299 | 1299 | |
| 1300 | - return $GLOBALS['TSFE']->sys_page->enableFields($table, $ignoreHide); |
|
| 1300 | + return $GLOBALS['TSFE']->sys_page->enableFields($table, $ignoreHide); |
|
| 1301 | 1301 | |
| 1302 | - } else { |
|
| 1302 | + } else { |
|
| 1303 | 1303 | |
| 1304 | - $pageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); |
|
| 1304 | + $pageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); |
|
| 1305 | 1305 | |
| 1306 | - $GLOBALS['TSFE']->includeTCA(); |
|
| 1306 | + $GLOBALS['TSFE']->includeTCA(); |
|
| 1307 | 1307 | |
| 1308 | - return $pageRepository->enableFields($table, $ignoreHide); |
|
| 1308 | + return $pageRepository->enableFields($table, $ignoreHide); |
|
| 1309 | 1309 | |
| 1310 | - } |
|
| 1310 | + } |
|
| 1311 | 1311 | |
| 1312 | - } elseif (TYPO3_MODE === 'BE') { |
|
| 1312 | + } elseif (TYPO3_MODE === 'BE') { |
|
| 1313 | 1313 | |
| 1314 | - return \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table); |
|
| 1314 | + return \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table); |
|
| 1315 | 1315 | |
| 1316 | - } else { |
|
| 1316 | + } else { |
|
| 1317 | 1317 | |
| 1318 | - if (TYPO3_DLOG) { |
|
| 1318 | + if (TYPO3_DLOG) { |
|
| 1319 | 1319 | |
| 1320 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->whereClause('.$table.', ['.($showHidden ? 'TRUE' : 'FALSE').'])] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 1320 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->whereClause('.$table.', ['.($showHidden ? 'TRUE' : 'FALSE').'])] Unexpected TYPO3_MODE "'.TYPO3_MODE.'"', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 1321 | 1321 | |
| 1322 | - } |
|
| 1322 | + } |
|
| 1323 | 1323 | |
| 1324 | - return ' AND 1=-1'; |
|
| 1324 | + return ' AND 1=-1'; |
|
| 1325 | 1325 | |
| 1326 | - } |
|
| 1326 | + } |
|
| 1327 | 1327 | |
| 1328 | - } |
|
| 1328 | + } |
|
| 1329 | 1329 | |
| 1330 | - /** |
|
| 1331 | - * This is a static class, thus no instances should be created |
|
| 1332 | - * |
|
| 1333 | - * @access private |
|
| 1334 | - */ |
|
| 1335 | - private function __construct() {} |
|
| 1330 | + /** |
|
| 1331 | + * This is a static class, thus no instances should be created |
|
| 1332 | + * |
|
| 1333 | + * @access private |
|
| 1334 | + */ |
|
| 1335 | + private function __construct() {} |
|
| 1336 | 1336 | |
| 1337 | 1337 | } |
@@ -1028,7 +1028,7 @@ discard block |
||
| 1028 | 1028 | |
| 1029 | 1029 | if ($flashMessage->getTitle() !== '') { |
| 1030 | 1030 | |
| 1031 | - $messageContent = sprintf('<h4>%s</h4>', htmlspecialchars($flashMessage->getTitle())) . $messageContent; |
|
| 1031 | + $messageContent = sprintf('<h4>%s</h4>', htmlspecialchars($flashMessage->getTitle())).$messageContent; |
|
| 1032 | 1032 | |
| 1033 | 1033 | } |
| 1034 | 1034 | |
@@ -1218,7 +1218,7 @@ discard block |
||
| 1218 | 1218 | // Overlay localized labels if available. |
| 1219 | 1219 | if ($GLOBALS['TSFE']->sys_language_content > 0) { |
| 1220 | 1220 | |
| 1221 | - $resArray = $GLOBALS['TSFE']->sys_page->getRecordOverlay($table, $resArray,$GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL); |
|
| 1221 | + $resArray = $GLOBALS['TSFE']->sys_page->getRecordOverlay($table, $resArray, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL); |
|
| 1222 | 1222 | |
| 1223 | 1223 | } |
| 1224 | 1224 | |
@@ -20,15 +20,15 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | interface tx_dlf_fulltext { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * This extracts raw fulltext data from XML |
|
| 25 | - * |
|
| 26 | - * @access public |
|
| 27 | - * |
|
| 28 | - * @param SimpleXMLElement $xml: The XML to extract the metadata from |
|
| 29 | - * |
|
| 30 | - * @return string The raw unformatted fulltext |
|
| 31 | - */ |
|
| 32 | - public static function getRawText(SimpleXMLElement $xml); |
|
| 23 | + /** |
|
| 24 | + * This extracts raw fulltext data from XML |
|
| 25 | + * |
|
| 26 | + * @access public |
|
| 27 | + * |
|
| 28 | + * @param SimpleXMLElement $xml: The XML to extract the metadata from |
|
| 29 | + * |
|
| 30 | + * @return string The raw unformatted fulltext |
|
| 31 | + */ |
|
| 32 | + public static function getRawText(SimpleXMLElement $xml); |
|
| 33 | 33 | |
| 34 | 34 | } |
@@ -19,20 +19,20 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class tx_dlf_teihdr implements tx_dlf_format { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * This extracts the essential TEIHDR metadata from XML |
|
| 24 | - * |
|
| 25 | - * @access public |
|
| 26 | - * |
|
| 27 | - * @param SimpleXMLElement $xml: The XML to extract the metadata from |
|
| 28 | - * @param array &$metadata: The metadata array to fill |
|
| 29 | - * |
|
| 30 | - * @return void |
|
| 31 | - */ |
|
| 32 | - public function extractMetadata(SimpleXMLElement $xml, array &$metadata) { |
|
| 22 | + /** |
|
| 23 | + * This extracts the essential TEIHDR metadata from XML |
|
| 24 | + * |
|
| 25 | + * @access public |
|
| 26 | + * |
|
| 27 | + * @param SimpleXMLElement $xml: The XML to extract the metadata from |
|
| 28 | + * @param array &$metadata: The metadata array to fill |
|
| 29 | + * |
|
| 30 | + * @return void |
|
| 31 | + */ |
|
| 32 | + public function extractMetadata(SimpleXMLElement $xml, array &$metadata) { |
|
| 33 | 33 | |
| 34 | - $xml->registerXPathNamespace('teihdr', 'http://www.tei-c.org/ns/1.0'); |
|
| 34 | + $xml->registerXPathNamespace('teihdr', 'http://www.tei-c.org/ns/1.0'); |
|
| 35 | 35 | |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | } |
@@ -20,115 +20,115 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | abstract class tx_dlf_module extends \TYPO3\CMS\Backend\Module\BaseScriptClass { |
| 22 | 22 | |
| 23 | - public $extKey = 'dlf'; |
|
| 24 | - |
|
| 25 | - public $prefixId = 'tx_dlf'; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * Holds the path to this module relative to 'EXT:dlf/modules/' and with trailing slash |
|
| 29 | - * |
|
| 30 | - * @var string |
|
| 31 | - * @access protected |
|
| 32 | - */ |
|
| 33 | - protected $modPath = ''; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Holds the page record if access granted or FALSE if access denied |
|
| 37 | - * |
|
| 38 | - * @var mixed |
|
| 39 | - * @access protected |
|
| 40 | - */ |
|
| 41 | - protected $pageInfo; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Holds the module's button array |
|
| 45 | - * |
|
| 46 | - * @var array |
|
| 47 | - * @access protected |
|
| 48 | - */ |
|
| 49 | - protected $buttonArray = array (); |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Holds the module's marker array |
|
| 53 | - * |
|
| 54 | - * @var array |
|
| 55 | - * @access protected |
|
| 56 | - */ |
|
| 57 | - protected $markerArray = array (); |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * Holds the module's subpart array |
|
| 61 | - * |
|
| 62 | - * @var array |
|
| 63 | - * @access protected |
|
| 64 | - */ |
|
| 65 | - protected $subpartArray = array (); |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Holds the TYPO3_CONF_VARS array of this extension |
|
| 69 | - * |
|
| 70 | - * @var array |
|
| 71 | - * @access protected |
|
| 72 | - */ |
|
| 73 | - protected $conf = array (); |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Holds the submitted form's data |
|
| 77 | - * |
|
| 78 | - * @var array |
|
| 79 | - * @access protected |
|
| 80 | - */ |
|
| 81 | - protected $data; |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Initializes the backend module by setting internal variables, initializing the menu. |
|
| 85 | - * |
|
| 86 | - * @access public |
|
| 87 | - * |
|
| 88 | - * @return void |
|
| 89 | - */ |
|
| 90 | - public function __construct() { |
|
| 91 | - |
|
| 92 | - $GLOBALS['BE_USER']->modAccess($GLOBALS['MCONF'], 1); |
|
| 93 | - |
|
| 94 | - $GLOBALS['LANG']->includeLLFile('EXT:'.$this->extKey.'/modules/'.$this->modPath.'locallang.xml'); |
|
| 95 | - |
|
| 96 | - $this->setMOD_MENU(); |
|
| 97 | - |
|
| 98 | - parent::init(); |
|
| 99 | - |
|
| 100 | - $this->conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]); |
|
| 101 | - |
|
| 102 | - $this->pageInfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->id, $this->perms_clause); |
|
| 103 | - |
|
| 104 | - $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate'); |
|
| 105 | - |
|
| 106 | - $this->doc->setModuleTemplate('EXT:'.$this->extKey.'/modules/'.$this->modPath.'template.tmpl'); |
|
| 107 | - |
|
| 108 | - $this->doc->getPageRenderer()->addCssFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($this->extKey) . 'res/backend.css'); |
|
| 109 | - |
|
| 110 | - $this->doc->backPath = $GLOBALS['BACK_PATH']; |
|
| 111 | - |
|
| 112 | - $this->doc->bodyTagAdditions = 'class="ext-'.$this->extKey.'-modules"'; |
|
| 113 | - |
|
| 114 | - $this->doc->form = '<form action="" method="post" enctype="multipart/form-data">'; |
|
| 115 | - |
|
| 116 | - $this->data = \TYPO3\CMS\Core\Utility\GeneralUtility::_GPmerged($this->prefixId); |
|
| 117 | - |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Sets the module's MOD_MENU configuration. |
|
| 122 | - * |
|
| 123 | - * @access protected |
|
| 124 | - * |
|
| 125 | - * @return void |
|
| 126 | - */ |
|
| 127 | - protected function setMOD_MENU() { |
|
| 128 | - |
|
| 129 | - // Set $this->MOD_MENU array here or leave empty. |
|
| 130 | - |
|
| 131 | - /* Example code: |
|
| 23 | + public $extKey = 'dlf'; |
|
| 24 | + |
|
| 25 | + public $prefixId = 'tx_dlf'; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Holds the path to this module relative to 'EXT:dlf/modules/' and with trailing slash |
|
| 29 | + * |
|
| 30 | + * @var string |
|
| 31 | + * @access protected |
|
| 32 | + */ |
|
| 33 | + protected $modPath = ''; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Holds the page record if access granted or FALSE if access denied |
|
| 37 | + * |
|
| 38 | + * @var mixed |
|
| 39 | + * @access protected |
|
| 40 | + */ |
|
| 41 | + protected $pageInfo; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Holds the module's button array |
|
| 45 | + * |
|
| 46 | + * @var array |
|
| 47 | + * @access protected |
|
| 48 | + */ |
|
| 49 | + protected $buttonArray = array (); |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Holds the module's marker array |
|
| 53 | + * |
|
| 54 | + * @var array |
|
| 55 | + * @access protected |
|
| 56 | + */ |
|
| 57 | + protected $markerArray = array (); |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * Holds the module's subpart array |
|
| 61 | + * |
|
| 62 | + * @var array |
|
| 63 | + * @access protected |
|
| 64 | + */ |
|
| 65 | + protected $subpartArray = array (); |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Holds the TYPO3_CONF_VARS array of this extension |
|
| 69 | + * |
|
| 70 | + * @var array |
|
| 71 | + * @access protected |
|
| 72 | + */ |
|
| 73 | + protected $conf = array (); |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Holds the submitted form's data |
|
| 77 | + * |
|
| 78 | + * @var array |
|
| 79 | + * @access protected |
|
| 80 | + */ |
|
| 81 | + protected $data; |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Initializes the backend module by setting internal variables, initializing the menu. |
|
| 85 | + * |
|
| 86 | + * @access public |
|
| 87 | + * |
|
| 88 | + * @return void |
|
| 89 | + */ |
|
| 90 | + public function __construct() { |
|
| 91 | + |
|
| 92 | + $GLOBALS['BE_USER']->modAccess($GLOBALS['MCONF'], 1); |
|
| 93 | + |
|
| 94 | + $GLOBALS['LANG']->includeLLFile('EXT:'.$this->extKey.'/modules/'.$this->modPath.'locallang.xml'); |
|
| 95 | + |
|
| 96 | + $this->setMOD_MENU(); |
|
| 97 | + |
|
| 98 | + parent::init(); |
|
| 99 | + |
|
| 100 | + $this->conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]); |
|
| 101 | + |
|
| 102 | + $this->pageInfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->id, $this->perms_clause); |
|
| 103 | + |
|
| 104 | + $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate'); |
|
| 105 | + |
|
| 106 | + $this->doc->setModuleTemplate('EXT:'.$this->extKey.'/modules/'.$this->modPath.'template.tmpl'); |
|
| 107 | + |
|
| 108 | + $this->doc->getPageRenderer()->addCssFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($this->extKey) . 'res/backend.css'); |
|
| 109 | + |
|
| 110 | + $this->doc->backPath = $GLOBALS['BACK_PATH']; |
|
| 111 | + |
|
| 112 | + $this->doc->bodyTagAdditions = 'class="ext-'.$this->extKey.'-modules"'; |
|
| 113 | + |
|
| 114 | + $this->doc->form = '<form action="" method="post" enctype="multipart/form-data">'; |
|
| 115 | + |
|
| 116 | + $this->data = \TYPO3\CMS\Core\Utility\GeneralUtility::_GPmerged($this->prefixId); |
|
| 117 | + |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Sets the module's MOD_MENU configuration. |
|
| 122 | + * |
|
| 123 | + * @access protected |
|
| 124 | + * |
|
| 125 | + * @return void |
|
| 126 | + */ |
|
| 127 | + protected function setMOD_MENU() { |
|
| 128 | + |
|
| 129 | + // Set $this->MOD_MENU array here or leave empty. |
|
| 130 | + |
|
| 131 | + /* Example code: |
|
| 132 | 132 | $this->MOD_MENU = array ( |
| 133 | 133 | 'function' => array ( |
| 134 | 134 | '1' => $GLOBALS['LANG']->getLL('function1'), |
@@ -137,30 +137,30 @@ discard block |
||
| 137 | 137 | ) |
| 138 | 138 | ); */ |
| 139 | 139 | |
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Main function of the module. |
|
| 144 | - * |
|
| 145 | - * @access public |
|
| 146 | - * |
|
| 147 | - * @abstract |
|
| 148 | - * |
|
| 149 | - * @return void |
|
| 150 | - */ |
|
| 151 | - abstract public function main(); |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * Outputs all contents. |
|
| 155 | - * |
|
| 156 | - * @access protected |
|
| 157 | - * |
|
| 158 | - * @return void |
|
| 159 | - */ |
|
| 160 | - protected function printContent() { |
|
| 161 | - |
|
| 162 | - // Add Javascript for function menu. |
|
| 163 | - $this->doc->JScode .= ' |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * Main function of the module. |
|
| 144 | + * |
|
| 145 | + * @access public |
|
| 146 | + * |
|
| 147 | + * @abstract |
|
| 148 | + * |
|
| 149 | + * @return void |
|
| 150 | + */ |
|
| 151 | + abstract public function main(); |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * Outputs all contents. |
|
| 155 | + * |
|
| 156 | + * @access protected |
|
| 157 | + * |
|
| 158 | + * @return void |
|
| 159 | + */ |
|
| 160 | + protected function printContent() { |
|
| 161 | + |
|
| 162 | + // Add Javascript for function menu. |
|
| 163 | + $this->doc->JScode .= ' |
|
| 164 | 164 | <script type="text/javascript"> |
| 165 | 165 | script_ended = 0; |
| 166 | 166 | function jumpToUrl(URL) { |
@@ -168,46 +168,46 @@ discard block |
||
| 168 | 168 | } |
| 169 | 169 | </script>'; |
| 170 | 170 | |
| 171 | - // Add Javascript for convenient module switch. |
|
| 172 | - $this->doc->postCode .= ' |
|
| 171 | + // Add Javascript for convenient module switch. |
|
| 172 | + $this->doc->postCode .= ' |
|
| 173 | 173 | <script type="text/javascript"> |
| 174 | 174 | script_ended = 1; |
| 175 | 175 | </script>'; |
| 176 | 176 | |
| 177 | - // Render output. |
|
| 178 | - $this->content .= $this->doc->startPage($GLOBALS['LANG']->getLL('title')); |
|
| 177 | + // Render output. |
|
| 178 | + $this->content .= $this->doc->startPage($GLOBALS['LANG']->getLL('title')); |
|
| 179 | 179 | |
| 180 | - // Set defaults for buttons and menu. |
|
| 181 | - if (empty($this->buttonArray['RELOAD'])) { |
|
| 180 | + // Set defaults for buttons and menu. |
|
| 181 | + if (empty($this->buttonArray['RELOAD'])) { |
|
| 182 | 182 | |
| 183 | - $this->buttonArray['RELOAD'] = '<a href="'.$GLOBALS['MCONF']['_'].'" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.reload', TRUE).'">'.\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-system-refresh').'</a>'; |
|
| 183 | + $this->buttonArray['RELOAD'] = '<a href="'.$GLOBALS['MCONF']['_'].'" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.reload', TRUE).'">'.\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-system-refresh').'</a>'; |
|
| 184 | 184 | |
| 185 | - } |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - if (empty($this->buttonArray['SHORTCUT'])) { |
|
| 187 | + if (empty($this->buttonArray['SHORTCUT'])) { |
|
| 188 | 188 | |
| 189 | - $this->buttonArray['SHORTCUT'] = $this->doc->makeShortcutIcon('id', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']); |
|
| 189 | + $this->buttonArray['SHORTCUT'] = $this->doc->makeShortcutIcon('id', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']); |
|
| 190 | 190 | |
| 191 | - } |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - if (empty($this->markerArray['CSH'])) { |
|
| 193 | + if (empty($this->markerArray['CSH'])) { |
|
| 194 | 194 | |
| 195 | - $this->markerArray['CSH'] = \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('_MOD_'.$GLOBALS['MCONF']['name'], 'csh', $GLOBALS['BACK_PATH'], '', TRUE); |
|
| 195 | + $this->markerArray['CSH'] = \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('_MOD_'.$GLOBALS['MCONF']['name'], 'csh', $GLOBALS['BACK_PATH'], '', TRUE); |
|
| 196 | 196 | |
| 197 | - } |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - if (empty($this->markerArray['MOD_MENU'])) { |
|
| 199 | + if (empty($this->markerArray['MOD_MENU'])) { |
|
| 200 | 200 | |
| 201 | - $this->markerArray['MOD_MENU'] = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']); |
|
| 201 | + $this->markerArray['MOD_MENU'] = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']); |
|
| 202 | 202 | |
| 203 | - } |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - $this->content .= $this->doc->moduleBody($this->pageInfo, $this->buttonArray, $this->markerArray, $this->subpartArray); |
|
| 205 | + $this->content .= $this->doc->moduleBody($this->pageInfo, $this->buttonArray, $this->markerArray, $this->subpartArray); |
|
| 206 | 206 | |
| 207 | - $this->content .= $this->doc->endPage(); |
|
| 207 | + $this->content .= $this->doc->endPage(); |
|
| 208 | 208 | |
| 209 | - echo $this->content; |
|
| 209 | + echo $this->content; |
|
| 210 | 210 | |
| 211 | - } |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | 213 | } |
@@ -105,7 +105,7 @@ |
||
| 105 | 105 | |
| 106 | 106 | $this->doc->setModuleTemplate('EXT:'.$this->extKey.'/modules/'.$this->modPath.'template.tmpl'); |
| 107 | 107 | |
| 108 | - $this->doc->getPageRenderer()->addCssFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($this->extKey) . 'res/backend.css'); |
|
| 108 | + $this->doc->getPageRenderer()->addCssFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($this->extKey).'res/backend.css'); |
|
| 109 | 109 | |
| 110 | 110 | $this->doc->backPath = $GLOBALS['BACK_PATH']; |
| 111 | 111 | |
@@ -20,16 +20,16 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | interface tx_dlf_format { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * This extracts metadata from XML |
|
| 25 | - * |
|
| 26 | - * @access public |
|
| 27 | - * |
|
| 28 | - * @param SimpleXMLElement $xml: The XML to extract the metadata from |
|
| 29 | - * @param array &$metadata: The metadata array to fill |
|
| 30 | - * |
|
| 31 | - * @return void |
|
| 32 | - */ |
|
| 33 | - public function extractMetadata(SimpleXMLElement $xml, array &$metadata); |
|
| 23 | + /** |
|
| 24 | + * This extracts metadata from XML |
|
| 25 | + * |
|
| 26 | + * @access public |
|
| 27 | + * |
|
| 28 | + * @param SimpleXMLElement $xml: The XML to extract the metadata from |
|
| 29 | + * @param array &$metadata: The metadata array to fill |
|
| 30 | + * |
|
| 31 | + * @return void |
|
| 32 | + */ |
|
| 33 | + public function extractMetadata(SimpleXMLElement $xml, array &$metadata); |
|
| 34 | 34 | |
| 35 | 35 | } |
@@ -20,711 +20,711 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class tx_dlf_solr { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * This holds the core name |
|
| 25 | - * |
|
| 26 | - * @var string |
|
| 27 | - * @access protected |
|
| 28 | - */ |
|
| 29 | - protected $core = ''; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * This holds the PID for the configuration |
|
| 33 | - * |
|
| 34 | - * @var integer |
|
| 35 | - * @access protected |
|
| 36 | - */ |
|
| 37 | - protected $cPid = 0; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * The extension key |
|
| 41 | - * |
|
| 42 | - * @var string |
|
| 43 | - * @access public |
|
| 44 | - */ |
|
| 45 | - public static $extKey = 'dlf'; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * This holds the max results |
|
| 49 | - * |
|
| 50 | - * @var integer |
|
| 51 | - * @access protected |
|
| 52 | - */ |
|
| 53 | - protected $limit = 50000; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * This holds the number of hits for last search |
|
| 57 | - * |
|
| 58 | - * @var integer |
|
| 59 | - * @access protected |
|
| 60 | - */ |
|
| 61 | - protected $numberOfHits = 0; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * This holds the additional query parameters |
|
| 65 | - * |
|
| 66 | - * @var array |
|
| 67 | - * @access protected |
|
| 68 | - */ |
|
| 69 | - protected $params = array (); |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Is the search instantiated successfully? |
|
| 73 | - * |
|
| 74 | - * @var boolean |
|
| 75 | - * @access protected |
|
| 76 | - */ |
|
| 77 | - protected $ready = FALSE; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * This holds the singleton search objects with their core as array key |
|
| 81 | - * |
|
| 82 | - * @var array(tx_dlf_solr) |
|
| 83 | - * @access protected |
|
| 84 | - */ |
|
| 85 | - protected static $registry = array (); |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * This holds the Solr service object |
|
| 89 | - * |
|
| 90 | - * @var Apache_Solr_Service |
|
| 91 | - * @access protected |
|
| 92 | - */ |
|
| 93 | - protected $service; |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Escape all special characters in a query string |
|
| 97 | - * |
|
| 98 | - * @access public |
|
| 99 | - * |
|
| 100 | - * @param string $query: The query string |
|
| 101 | - * |
|
| 102 | - * @return string The escaped query string |
|
| 103 | - */ |
|
| 104 | - public static function escapeQuery($query) { |
|
| 105 | - |
|
| 106 | - // Load class. |
|
| 107 | - if (!class_exists('Apache_Solr_Service')) { |
|
| 108 | - |
|
| 109 | - require_once(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:'.self::$extKey.'/lib/SolrPhpClient/Apache/Solr/Service.php')); |
|
| 110 | - |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - // Escape query phrase or term. |
|
| 114 | - if (preg_match('/^".*"$/', $query)) { |
|
| 115 | - |
|
| 116 | - return '"'.Apache_Solr_Service::escapePhrase(trim($query, '"')).'"'; |
|
| 23 | + /** |
|
| 24 | + * This holds the core name |
|
| 25 | + * |
|
| 26 | + * @var string |
|
| 27 | + * @access protected |
|
| 28 | + */ |
|
| 29 | + protected $core = ''; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * This holds the PID for the configuration |
|
| 33 | + * |
|
| 34 | + * @var integer |
|
| 35 | + * @access protected |
|
| 36 | + */ |
|
| 37 | + protected $cPid = 0; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * The extension key |
|
| 41 | + * |
|
| 42 | + * @var string |
|
| 43 | + * @access public |
|
| 44 | + */ |
|
| 45 | + public static $extKey = 'dlf'; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * This holds the max results |
|
| 49 | + * |
|
| 50 | + * @var integer |
|
| 51 | + * @access protected |
|
| 52 | + */ |
|
| 53 | + protected $limit = 50000; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * This holds the number of hits for last search |
|
| 57 | + * |
|
| 58 | + * @var integer |
|
| 59 | + * @access protected |
|
| 60 | + */ |
|
| 61 | + protected $numberOfHits = 0; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * This holds the additional query parameters |
|
| 65 | + * |
|
| 66 | + * @var array |
|
| 67 | + * @access protected |
|
| 68 | + */ |
|
| 69 | + protected $params = array (); |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Is the search instantiated successfully? |
|
| 73 | + * |
|
| 74 | + * @var boolean |
|
| 75 | + * @access protected |
|
| 76 | + */ |
|
| 77 | + protected $ready = FALSE; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * This holds the singleton search objects with their core as array key |
|
| 81 | + * |
|
| 82 | + * @var array(tx_dlf_solr) |
|
| 83 | + * @access protected |
|
| 84 | + */ |
|
| 85 | + protected static $registry = array (); |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * This holds the Solr service object |
|
| 89 | + * |
|
| 90 | + * @var Apache_Solr_Service |
|
| 91 | + * @access protected |
|
| 92 | + */ |
|
| 93 | + protected $service; |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Escape all special characters in a query string |
|
| 97 | + * |
|
| 98 | + * @access public |
|
| 99 | + * |
|
| 100 | + * @param string $query: The query string |
|
| 101 | + * |
|
| 102 | + * @return string The escaped query string |
|
| 103 | + */ |
|
| 104 | + public static function escapeQuery($query) { |
|
| 105 | + |
|
| 106 | + // Load class. |
|
| 107 | + if (!class_exists('Apache_Solr_Service')) { |
|
| 108 | + |
|
| 109 | + require_once(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:'.self::$extKey.'/lib/SolrPhpClient/Apache/Solr/Service.php')); |
|
| 110 | + |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + // Escape query phrase or term. |
|
| 114 | + if (preg_match('/^".*"$/', $query)) { |
|
| 115 | + |
|
| 116 | + return '"'.Apache_Solr_Service::escapePhrase(trim($query, '"')).'"'; |
|
| 117 | 117 | |
| 118 | - } else { |
|
| 118 | + } else { |
|
| 119 | 119 | |
| 120 | - return Apache_Solr_Service::escape($query); |
|
| 120 | + return Apache_Solr_Service::escape($query); |
|
| 121 | 121 | |
| 122 | - } |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Escape all special characters in a query string while retaining valid field queries |
|
| 128 | - * |
|
| 129 | - * @access public |
|
| 130 | - * |
|
| 131 | - * @param string $query: The query string |
|
| 132 | - * @param integer $pid: The PID for the field configuration |
|
| 133 | - * |
|
| 134 | - * @return string The escaped query string |
|
| 135 | - */ |
|
| 136 | - public static function escapeQueryKeepField($query, $pid) { |
|
| 126 | + /** |
|
| 127 | + * Escape all special characters in a query string while retaining valid field queries |
|
| 128 | + * |
|
| 129 | + * @access public |
|
| 130 | + * |
|
| 131 | + * @param string $query: The query string |
|
| 132 | + * @param integer $pid: The PID for the field configuration |
|
| 133 | + * |
|
| 134 | + * @return string The escaped query string |
|
| 135 | + */ |
|
| 136 | + public static function escapeQueryKeepField($query, $pid) { |
|
| 137 | 137 | |
| 138 | - // Is there a field query? |
|
| 139 | - if (preg_match('/^[[:alnum:]]+_[tu][su]i:\(.*\)$/', $query)) { |
|
| 138 | + // Is there a field query? |
|
| 139 | + if (preg_match('/^[[:alnum:]]+_[tu][su]i:\(.*\)$/', $query)) { |
|
| 140 | 140 | |
| 141 | - // Get all indexed fields. |
|
| 142 | - $fields = array(); |
|
| 141 | + // Get all indexed fields. |
|
| 142 | + $fields = array(); |
|
| 143 | 143 | |
| 144 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 145 | - 'tx_dlf_metadata.index_name,tx_dlf_metadata.index_tokenized,tx_dlf_metadata.index_stored', |
|
| 146 | - 'tx_dlf_metadata', |
|
| 147 | - 'tx_dlf_metadata.index_indexed=1 AND tx_dlf_metadata.pid=' . intval($pid) . ' AND (tx_dlf_metadata.sys_language_uid IN (-1,0) OR tx_dlf_metadata.l18n_parent=0)' . tx_dlf_helper::whereClause('tx_dlf_metadata'), |
|
| 148 | - '', |
|
| 149 | - '', |
|
| 150 | - '' |
|
| 151 | - ); |
|
| 144 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 145 | + 'tx_dlf_metadata.index_name,tx_dlf_metadata.index_tokenized,tx_dlf_metadata.index_stored', |
|
| 146 | + 'tx_dlf_metadata', |
|
| 147 | + 'tx_dlf_metadata.index_indexed=1 AND tx_dlf_metadata.pid=' . intval($pid) . ' AND (tx_dlf_metadata.sys_language_uid IN (-1,0) OR tx_dlf_metadata.l18n_parent=0)' . tx_dlf_helper::whereClause('tx_dlf_metadata'), |
|
| 148 | + '', |
|
| 149 | + '', |
|
| 150 | + '' |
|
| 151 | + ); |
|
| 152 | 152 | |
| 153 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
| 153 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { |
|
| 154 | 154 | |
| 155 | - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) { |
|
| 155 | + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) { |
|
| 156 | 156 | |
| 157 | - $fields[] = $resArray[0].'_'.($resArray[1] ? 't' : 'u').($resArray[2] ? 's' : 'u').'i'; |
|
| 157 | + $fields[] = $resArray[0].'_'.($resArray[1] ? 't' : 'u').($resArray[2] ? 's' : 'u').'i'; |
|
| 158 | 158 | |
| 159 | - } |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - } |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - // Check if queried field is valid. |
|
| 164 | - $splitQuery = explode(':', $query, 2); |
|
| 163 | + // Check if queried field is valid. |
|
| 164 | + $splitQuery = explode(':', $query, 2); |
|
| 165 | 165 | |
| 166 | - if (in_array($splitQuery[0], $fields)) { |
|
| 166 | + if (in_array($splitQuery[0], $fields)) { |
|
| 167 | 167 | |
| 168 | - $query = $splitQuery[0].':('.self::escapeQuery(trim($splitQuery[1], '()')).')'; |
|
| 168 | + $query = $splitQuery[0].':('.self::escapeQuery(trim($splitQuery[1], '()')).')'; |
|
| 169 | 169 | |
| 170 | - } else { |
|
| 170 | + } else { |
|
| 171 | 171 | |
| 172 | - $query = self::escapeQuery($query); |
|
| 172 | + $query = self::escapeQuery($query); |
|
| 173 | 173 | |
| 174 | - } |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - } elseif (!empty($query) && $query !== '*') { |
|
| 176 | + } elseif (!empty($query) && $query !== '*') { |
|
| 177 | 177 | |
| 178 | - // Don't escape plain asterisk search. |
|
| 179 | - $query = self::escapeQuery($query); |
|
| 178 | + // Don't escape plain asterisk search. |
|
| 179 | + $query = self::escapeQuery($query); |
|
| 180 | 180 | |
| 181 | - } |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - return $query; |
|
| 183 | + return $query; |
|
| 184 | 184 | |
| 185 | - } |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - /** |
|
| 188 | - * This is a singleton class, thus instances must be created by this method |
|
| 189 | - * |
|
| 190 | - * @access public |
|
| 191 | - * |
|
| 192 | - * @param mixed $core: Name or UID of the core to load |
|
| 193 | - * |
|
| 194 | - * @return tx_dlf_solr Instance of this class |
|
| 195 | - */ |
|
| 196 | - public static function getInstance($core) { |
|
| 187 | + /** |
|
| 188 | + * This is a singleton class, thus instances must be created by this method |
|
| 189 | + * |
|
| 190 | + * @access public |
|
| 191 | + * |
|
| 192 | + * @param mixed $core: Name or UID of the core to load |
|
| 193 | + * |
|
| 194 | + * @return tx_dlf_solr Instance of this class |
|
| 195 | + */ |
|
| 196 | + public static function getInstance($core) { |
|
| 197 | 197 | |
| 198 | - // Save parameter for logging purposes. |
|
| 199 | - $_core = $core; |
|
| 198 | + // Save parameter for logging purposes. |
|
| 199 | + $_core = $core; |
|
| 200 | 200 | |
| 201 | - // Get core name if UID is given. |
|
| 202 | - if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($core)) { |
|
| 201 | + // Get core name if UID is given. |
|
| 202 | + if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($core)) { |
|
| 203 | 203 | |
| 204 | - $core = tx_dlf_helper::getIndexName($core, 'tx_dlf_solrcores'); |
|
| 204 | + $core = tx_dlf_helper::getIndexName($core, 'tx_dlf_solrcores'); |
|
| 205 | 205 | |
| 206 | - } |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - // Check if core is set. |
|
| 209 | - if (empty($core)) { |
|
| 208 | + // Check if core is set. |
|
| 209 | + if (empty($core)) { |
|
| 210 | 210 | |
| 211 | - if (TYPO3_DLOG) { |
|
| 211 | + if (TYPO3_DLOG) { |
|
| 212 | 212 | |
| 213 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_solr->getInstance('.$_core.')] Invalid core name "'.$core.'" for Apache Solr', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 213 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_solr->getInstance('.$_core.')] Invalid core name "'.$core.'" for Apache Solr', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 214 | 214 | |
| 215 | - } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - return; |
|
| 217 | + return; |
|
| 218 | 218 | |
| 219 | - } |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - // Check if there is an instance in the registry already. |
|
| 222 | - if (is_object(self::$registry[$core]) && self::$registry[$core] instanceof self) { |
|
| 221 | + // Check if there is an instance in the registry already. |
|
| 222 | + if (is_object(self::$registry[$core]) && self::$registry[$core] instanceof self) { |
|
| 223 | 223 | |
| 224 | - // Return singleton instance if available. |
|
| 225 | - return self::$registry[$core]; |
|
| 224 | + // Return singleton instance if available. |
|
| 225 | + return self::$registry[$core]; |
|
| 226 | 226 | |
| 227 | - } |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - // Create new instance... |
|
| 230 | - $instance = new self($core); |
|
| 229 | + // Create new instance... |
|
| 230 | + $instance = new self($core); |
|
| 231 | 231 | |
| 232 | - // ...and save it to registry. |
|
| 233 | - if ($instance->ready) { |
|
| 232 | + // ...and save it to registry. |
|
| 233 | + if ($instance->ready) { |
|
| 234 | 234 | |
| 235 | - self::$registry[$core] = $instance; |
|
| 235 | + self::$registry[$core] = $instance; |
|
| 236 | 236 | |
| 237 | - // Return new instance. |
|
| 238 | - return $instance; |
|
| 237 | + // Return new instance. |
|
| 238 | + return $instance; |
|
| 239 | 239 | |
| 240 | - } else { |
|
| 240 | + } else { |
|
| 241 | 241 | |
| 242 | - if (TYPO3_DLOG) { |
|
| 242 | + if (TYPO3_DLOG) { |
|
| 243 | 243 | |
| 244 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_solr->getInstance('.$_core.')] Could not connect to Apache Solr server', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 244 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_solr->getInstance('.$_core.')] Could not connect to Apache Solr server', self::$extKey, SYSLOG_SEVERITY_ERROR); |
|
| 245 | 245 | |
| 246 | - } |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - return; |
|
| 248 | + return; |
|
| 249 | 249 | |
| 250 | - } |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | - } |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - /** |
|
| 255 | - * Returns the connection information a specific Solr core |
|
| 256 | - * |
|
| 257 | - * @access public |
|
| 258 | - * |
|
| 259 | - * @param string $core: Name of the core to load |
|
| 260 | - * |
|
| 261 | - * @return string The connection parameters for a specific Solr core |
|
| 262 | - */ |
|
| 263 | - public static function getSolrConnectionInfo($core = '') { |
|
| 254 | + /** |
|
| 255 | + * Returns the connection information a specific Solr core |
|
| 256 | + * |
|
| 257 | + * @access public |
|
| 258 | + * |
|
| 259 | + * @param string $core: Name of the core to load |
|
| 260 | + * |
|
| 261 | + * @return string The connection parameters for a specific Solr core |
|
| 262 | + */ |
|
| 263 | + public static function getSolrConnectionInfo($core = '') { |
|
| 264 | 264 | |
| 265 | - $solrInfo = array (); |
|
| 265 | + $solrInfo = array (); |
|
| 266 | 266 | |
| 267 | - // Extract extension configuration. |
|
| 268 | - $conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]); |
|
| 267 | + // Extract extension configuration. |
|
| 268 | + $conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]); |
|
| 269 | 269 | |
| 270 | - // Derive Solr host name. |
|
| 271 | - $solrInfo['host'] = ($conf['solrHost'] ? $conf['solrHost'] : '127.0.0.1'); |
|
| 270 | + // Derive Solr host name. |
|
| 271 | + $solrInfo['host'] = ($conf['solrHost'] ? $conf['solrHost'] : '127.0.0.1'); |
|
| 272 | 272 | |
| 273 | - // Prepend username and password to hostname. |
|
| 274 | - if ($conf['solrUser'] && $conf['solrPass']) { |
|
| 273 | + // Prepend username and password to hostname. |
|
| 274 | + if ($conf['solrUser'] && $conf['solrPass']) { |
|
| 275 | 275 | |
| 276 | - $solrInfo['host'] = $conf['solrUser'].':'.$conf['solrPass'].'@'.$solrInfo['host']; |
|
| 276 | + $solrInfo['host'] = $conf['solrUser'].':'.$conf['solrPass'].'@'.$solrInfo['host']; |
|
| 277 | 277 | |
| 278 | - } |
|
| 278 | + } |
|
| 279 | 279 | |
| 280 | - // Set port if not set. |
|
| 281 | - $solrInfo['port'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($conf['solrPort'], 1, 65535, 8180); |
|
| 280 | + // Set port if not set. |
|
| 281 | + $solrInfo['port'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($conf['solrPort'], 1, 65535, 8180); |
|
| 282 | 282 | |
| 283 | - // Append core name to path. |
|
| 284 | - $solrInfo['path'] = trim($conf['solrPath'], '/').'/'.$core; |
|
| 283 | + // Append core name to path. |
|
| 284 | + $solrInfo['path'] = trim($conf['solrPath'], '/').'/'.$core; |
|
| 285 | 285 | |
| 286 | - return $solrInfo; |
|
| 286 | + return $solrInfo; |
|
| 287 | 287 | |
| 288 | - } |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - /** |
|
| 291 | - * Returns the request URL for a specific Solr core |
|
| 292 | - * |
|
| 293 | - * @access public |
|
| 294 | - * |
|
| 295 | - * @param string $core: Name of the core to load |
|
| 296 | - * |
|
| 297 | - * @return string The request URL for a specific Solr core |
|
| 298 | - */ |
|
| 299 | - public static function getSolrUrl($core = '') { |
|
| 290 | + /** |
|
| 291 | + * Returns the request URL for a specific Solr core |
|
| 292 | + * |
|
| 293 | + * @access public |
|
| 294 | + * |
|
| 295 | + * @param string $core: Name of the core to load |
|
| 296 | + * |
|
| 297 | + * @return string The request URL for a specific Solr core |
|
| 298 | + */ |
|
| 299 | + public static function getSolrUrl($core = '') { |
|
| 300 | 300 | |
| 301 | - // Get Solr connection information. |
|
| 302 | - $solrInfo = self::getSolrConnectionInfo($core); |
|
| 301 | + // Get Solr connection information. |
|
| 302 | + $solrInfo = self::getSolrConnectionInfo($core); |
|
| 303 | 303 | |
| 304 | - // Return entire request URL. |
|
| 305 | - return 'http://'.$solrInfo['host'].':'.$solrInfo['port'].'/'.$solrInfo['path']; |
|
| 304 | + // Return entire request URL. |
|
| 305 | + return 'http://'.$solrInfo['host'].':'.$solrInfo['port'].'/'.$solrInfo['path']; |
|
| 306 | 306 | |
| 307 | - } |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - /** |
|
| 310 | - * Get next unused Solr core number |
|
| 311 | - * |
|
| 312 | - * @access public |
|
| 313 | - * |
|
| 314 | - * @param integer $start: Number to start with |
|
| 315 | - * |
|
| 316 | - * @return integer First unused core number found |
|
| 317 | - */ |
|
| 318 | - public static function solrGetCoreNumber($start = 0) { |
|
| 309 | + /** |
|
| 310 | + * Get next unused Solr core number |
|
| 311 | + * |
|
| 312 | + * @access public |
|
| 313 | + * |
|
| 314 | + * @param integer $start: Number to start with |
|
| 315 | + * |
|
| 316 | + * @return integer First unused core number found |
|
| 317 | + */ |
|
| 318 | + public static function solrGetCoreNumber($start = 0) { |
|
| 319 | 319 | |
| 320 | - $start = max(intval($start), 0); |
|
| 320 | + $start = max(intval($start), 0); |
|
| 321 | 321 | |
| 322 | - // Check if core already exists. |
|
| 323 | - if (self::getInstance('dlfCore'.$start) === NULL) { |
|
| 322 | + // Check if core already exists. |
|
| 323 | + if (self::getInstance('dlfCore'.$start) === NULL) { |
|
| 324 | 324 | |
| 325 | - return $start; |
|
| 325 | + return $start; |
|
| 326 | 326 | |
| 327 | - } else { |
|
| 327 | + } else { |
|
| 328 | 328 | |
| 329 | - return self::solrGetCoreNumber($start + 1); |
|
| 329 | + return self::solrGetCoreNumber($start + 1); |
|
| 330 | 330 | |
| 331 | - } |
|
| 331 | + } |
|
| 332 | 332 | |
| 333 | - } |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | - /** |
|
| 336 | - * Processes a search request. |
|
| 337 | - * |
|
| 338 | - * @access public |
|
| 339 | - * |
|
| 340 | - * @param string $query: The search query |
|
| 341 | - * |
|
| 342 | - * @return tx_dlf_list The result list |
|
| 343 | - */ |
|
| 344 | - public function search($query = '') { |
|
| 335 | + /** |
|
| 336 | + * Processes a search request. |
|
| 337 | + * |
|
| 338 | + * @access public |
|
| 339 | + * |
|
| 340 | + * @param string $query: The search query |
|
| 341 | + * |
|
| 342 | + * @return tx_dlf_list The result list |
|
| 343 | + */ |
|
| 344 | + public function search($query = '') { |
|
| 345 | 345 | |
| 346 | - // Perform search. |
|
| 347 | - $results = $this->service->search((string) $query, 0, $this->limit, $this->params); |
|
| 346 | + // Perform search. |
|
| 347 | + $results = $this->service->search((string) $query, 0, $this->limit, $this->params); |
|
| 348 | 348 | |
| 349 | - $this->numberOfHits = count($results->response->docs); |
|
| 349 | + $this->numberOfHits = count($results->response->docs); |
|
| 350 | 350 | |
| 351 | - $toplevel = array (); |
|
| 351 | + $toplevel = array (); |
|
| 352 | 352 | |
| 353 | - $checks = array (); |
|
| 353 | + $checks = array (); |
|
| 354 | 354 | |
| 355 | - // Get metadata configuration. |
|
| 356 | - if ($this->numberOfHits > 0) { |
|
| 355 | + // Get metadata configuration. |
|
| 356 | + if ($this->numberOfHits > 0) { |
|
| 357 | 357 | |
| 358 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 359 | - 'tx_dlf_metadata.index_name AS index_name', |
|
| 360 | - 'tx_dlf_metadata', |
|
| 361 | - 'tx_dlf_metadata.is_sortable=1 AND tx_dlf_metadata.pid='.intval($this->cPid).tx_dlf_helper::whereClause('tx_dlf_metadata'), |
|
| 362 | - '', |
|
| 363 | - '', |
|
| 364 | - '' |
|
| 365 | - ); |
|
| 358 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 359 | + 'tx_dlf_metadata.index_name AS index_name', |
|
| 360 | + 'tx_dlf_metadata', |
|
| 361 | + 'tx_dlf_metadata.is_sortable=1 AND tx_dlf_metadata.pid='.intval($this->cPid).tx_dlf_helper::whereClause('tx_dlf_metadata'), |
|
| 362 | + '', |
|
| 363 | + '', |
|
| 364 | + '' |
|
| 365 | + ); |
|
| 366 | 366 | |
| 367 | - $sorting = array (); |
|
| 367 | + $sorting = array (); |
|
| 368 | 368 | |
| 369 | - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
| 369 | + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
| 370 | 370 | |
| 371 | - $sorting[$resArray['index_name']] = $resArray['index_name'].'_sorting'; |
|
| 371 | + $sorting[$resArray['index_name']] = $resArray['index_name'].'_sorting'; |
|
| 372 | 372 | |
| 373 | - } |
|
| 373 | + } |
|
| 374 | 374 | |
| 375 | - } |
|
| 375 | + } |
|
| 376 | 376 | |
| 377 | - // Keep track of relevance. |
|
| 378 | - $i = 0; |
|
| 377 | + // Keep track of relevance. |
|
| 378 | + $i = 0; |
|
| 379 | 379 | |
| 380 | - // Process results. |
|
| 381 | - foreach ($results->response->docs as $doc) { |
|
| 380 | + // Process results. |
|
| 381 | + foreach ($results->response->docs as $doc) { |
|
| 382 | 382 | |
| 383 | - // Split toplevel documents from subparts. |
|
| 384 | - if ($doc->toplevel == 1) { |
|
| 383 | + // Split toplevel documents from subparts. |
|
| 384 | + if ($doc->toplevel == 1) { |
|
| 385 | 385 | |
| 386 | - // Prepare document's metadata for sorting. |
|
| 387 | - $docSorting = array (); |
|
| 386 | + // Prepare document's metadata for sorting. |
|
| 387 | + $docSorting = array (); |
|
| 388 | 388 | |
| 389 | - foreach ($sorting as $index_name => $solr_name) { |
|
| 389 | + foreach ($sorting as $index_name => $solr_name) { |
|
| 390 | 390 | |
| 391 | - if (!empty($doc->$solr_name)) { |
|
| 391 | + if (!empty($doc->$solr_name)) { |
|
| 392 | 392 | |
| 393 | - $docSorting[$index_name] = (is_array($doc->$solr_name) ? $doc->$solr_name[0] : $doc->$solr_name); |
|
| 393 | + $docSorting[$index_name] = (is_array($doc->$solr_name) ? $doc->$solr_name[0] : $doc->$solr_name); |
|
| 394 | 394 | |
| 395 | - } |
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | - } |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | - // Preserve relevance ranking. |
|
| 400 | - if (!empty($toplevel[$doc->uid]['s']['relevance'])) { |
|
| 399 | + // Preserve relevance ranking. |
|
| 400 | + if (!empty($toplevel[$doc->uid]['s']['relevance'])) { |
|
| 401 | 401 | |
| 402 | - $docSorting['relevance'] = $toplevel[$doc->uid]['s']['relevance']; |
|
| 402 | + $docSorting['relevance'] = $toplevel[$doc->uid]['s']['relevance']; |
|
| 403 | 403 | |
| 404 | - } |
|
| 404 | + } |
|
| 405 | 405 | |
| 406 | - $toplevel[$doc->uid] = array ( |
|
| 407 | - 'u' => $doc->uid, |
|
| 408 | - 'h' => '', |
|
| 409 | - 's' => $docSorting, |
|
| 410 | - 'p' => (!empty($toplevel[$doc->uid]['p']) ? $toplevel[$doc->uid]['p'] : array ()) |
|
| 411 | - ); |
|
| 406 | + $toplevel[$doc->uid] = array ( |
|
| 407 | + 'u' => $doc->uid, |
|
| 408 | + 'h' => '', |
|
| 409 | + 's' => $docSorting, |
|
| 410 | + 'p' => (!empty($toplevel[$doc->uid]['p']) ? $toplevel[$doc->uid]['p'] : array ()) |
|
| 411 | + ); |
|
| 412 | 412 | |
| 413 | - } else { |
|
| 413 | + } else { |
|
| 414 | 414 | |
| 415 | - $toplevel[$doc->uid]['p'][] = array ( |
|
| 416 | - 'u' => $doc->id, |
|
| 417 | - 'h' => (!empty($results->highlighting->{$doc->id}->fulltext) ? $results->highlighting->{$doc->id}->fulltext[0] : '') |
|
| 418 | - ); |
|
| 415 | + $toplevel[$doc->uid]['p'][] = array ( |
|
| 416 | + 'u' => $doc->id, |
|
| 417 | + 'h' => (!empty($results->highlighting->{$doc->id}->fulltext) ? $results->highlighting->{$doc->id}->fulltext[0] : '') |
|
| 418 | + ); |
|
| 419 | 419 | |
| 420 | - if (!in_array($doc->uid, $checks)) { |
|
| 420 | + if (!in_array($doc->uid, $checks)) { |
|
| 421 | 421 | |
| 422 | - $checks[] = $doc->uid; |
|
| 422 | + $checks[] = $doc->uid; |
|
| 423 | 423 | |
| 424 | - } |
|
| 424 | + } |
|
| 425 | 425 | |
| 426 | - } |
|
| 426 | + } |
|
| 427 | 427 | |
| 428 | - // Add relevance to sorting values. |
|
| 429 | - if (empty($toplevel[$doc->uid]['s']['relevance'])) { |
|
| 428 | + // Add relevance to sorting values. |
|
| 429 | + if (empty($toplevel[$doc->uid]['s']['relevance'])) { |
|
| 430 | 430 | |
| 431 | - $toplevel[$doc->uid]['s']['relevance'] = str_pad($i, 6, '0', STR_PAD_LEFT); |
|
| 431 | + $toplevel[$doc->uid]['s']['relevance'] = str_pad($i, 6, '0', STR_PAD_LEFT); |
|
| 432 | 432 | |
| 433 | - } |
|
| 433 | + } |
|
| 434 | 434 | |
| 435 | - $i++; |
|
| 435 | + $i++; |
|
| 436 | 436 | |
| 437 | - } |
|
| 437 | + } |
|
| 438 | 438 | |
| 439 | - // Check if the toplevel documents have metadata. |
|
| 440 | - foreach ($checks as $check) { |
|
| 439 | + // Check if the toplevel documents have metadata. |
|
| 440 | + foreach ($checks as $check) { |
|
| 441 | 441 | |
| 442 | - if (empty($toplevel[$check]['u'])) { |
|
| 442 | + if (empty($toplevel[$check]['u'])) { |
|
| 443 | 443 | |
| 444 | - // Get information for toplevel document. |
|
| 445 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 446 | - 'tx_dlf_documents.uid AS uid,tx_dlf_documents.metadata_sorting AS metadata_sorting', |
|
| 447 | - 'tx_dlf_documents', |
|
| 448 | - 'tx_dlf_documents.uid='.intval($check).tx_dlf_helper::whereClause('tx_dlf_documents'), |
|
| 449 | - '', |
|
| 450 | - '', |
|
| 451 | - '1' |
|
| 452 | - ); |
|
| 444 | + // Get information for toplevel document. |
|
| 445 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 446 | + 'tx_dlf_documents.uid AS uid,tx_dlf_documents.metadata_sorting AS metadata_sorting', |
|
| 447 | + 'tx_dlf_documents', |
|
| 448 | + 'tx_dlf_documents.uid='.intval($check).tx_dlf_helper::whereClause('tx_dlf_documents'), |
|
| 449 | + '', |
|
| 450 | + '', |
|
| 451 | + '1' |
|
| 452 | + ); |
|
| 453 | 453 | |
| 454 | - // Process results. |
|
| 455 | - if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
|
| 454 | + // Process results. |
|
| 455 | + if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
|
| 456 | 456 | |
| 457 | - $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
| 457 | + $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); |
|
| 458 | 458 | |
| 459 | - // Prepare document's metadata for sorting. |
|
| 460 | - $sorting = unserialize($resArray['metadata_sorting']); |
|
| 459 | + // Prepare document's metadata for sorting. |
|
| 460 | + $sorting = unserialize($resArray['metadata_sorting']); |
|
| 461 | 461 | |
| 462 | - if (!empty($sorting['type']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($sorting['type'])) { |
|
| 462 | + if (!empty($sorting['type']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($sorting['type'])) { |
|
| 463 | 463 | |
| 464 | - $sorting['type'] = tx_dlf_helper::getIndexName($sorting['type'], 'tx_dlf_structures', $this->cPid); |
|
| 464 | + $sorting['type'] = tx_dlf_helper::getIndexName($sorting['type'], 'tx_dlf_structures', $this->cPid); |
|
| 465 | 465 | |
| 466 | - } |
|
| 466 | + } |
|
| 467 | 467 | |
| 468 | - if (!empty($sorting['owner']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($sorting['owner'])) { |
|
| 468 | + if (!empty($sorting['owner']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($sorting['owner'])) { |
|
| 469 | 469 | |
| 470 | - $sorting['owner'] = tx_dlf_helper::getIndexName($sorting['owner'], 'tx_dlf_libraries', $this->cPid); |
|
| 470 | + $sorting['owner'] = tx_dlf_helper::getIndexName($sorting['owner'], 'tx_dlf_libraries', $this->cPid); |
|
| 471 | 471 | |
| 472 | - } |
|
| 472 | + } |
|
| 473 | 473 | |
| 474 | - if (!empty($sorting['collection']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($sorting['collection'])) { |
|
| 474 | + if (!empty($sorting['collection']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($sorting['collection'])) { |
|
| 475 | 475 | |
| 476 | - $sorting['collection'] = tx_dlf_helper::getIndexName($sorting['collection'], 'tx_dlf_collections', $this->cPid); |
|
| 476 | + $sorting['collection'] = tx_dlf_helper::getIndexName($sorting['collection'], 'tx_dlf_collections', $this->cPid); |
|
| 477 | 477 | |
| 478 | - } |
|
| 478 | + } |
|
| 479 | 479 | |
| 480 | - // Preserve relevance ranking. |
|
| 481 | - if (!empty($toplevel[$check]['s']['relevance'])) { |
|
| 480 | + // Preserve relevance ranking. |
|
| 481 | + if (!empty($toplevel[$check]['s']['relevance'])) { |
|
| 482 | 482 | |
| 483 | - $sorting['relevance'] = $toplevel[$check]['s']['relevance']; |
|
| 483 | + $sorting['relevance'] = $toplevel[$check]['s']['relevance']; |
|
| 484 | 484 | |
| 485 | - } |
|
| 485 | + } |
|
| 486 | 486 | |
| 487 | - $toplevel[$check] = array ( |
|
| 488 | - 'u' => $resArray['uid'], |
|
| 489 | - 'h' => '', |
|
| 490 | - 's' => $sorting, |
|
| 491 | - 'p' => $toplevel[$check]['p'] |
|
| 492 | - ); |
|
| 487 | + $toplevel[$check] = array ( |
|
| 488 | + 'u' => $resArray['uid'], |
|
| 489 | + 'h' => '', |
|
| 490 | + 's' => $sorting, |
|
| 491 | + 'p' => $toplevel[$check]['p'] |
|
| 492 | + ); |
|
| 493 | 493 | |
| 494 | - } else { |
|
| 494 | + } else { |
|
| 495 | 495 | |
| 496 | - // Clear entry if there is no (accessible) toplevel document. |
|
| 497 | - unset ($toplevel[$check]); |
|
| 496 | + // Clear entry if there is no (accessible) toplevel document. |
|
| 497 | + unset ($toplevel[$check]); |
|
| 498 | 498 | |
| 499 | - } |
|
| 499 | + } |
|
| 500 | 500 | |
| 501 | - } |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | - } |
|
| 503 | + } |
|
| 504 | 504 | |
| 505 | - // Save list of documents. |
|
| 506 | - $list = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_dlf_list'); |
|
| 505 | + // Save list of documents. |
|
| 506 | + $list = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_dlf_list'); |
|
| 507 | 507 | |
| 508 | - $list->reset(); |
|
| 508 | + $list->reset(); |
|
| 509 | 509 | |
| 510 | - $list->add(array_values($toplevel)); |
|
| 510 | + $list->add(array_values($toplevel)); |
|
| 511 | 511 | |
| 512 | - // Set metadata for search. |
|
| 513 | - $list->metadata = array ( |
|
| 514 | - 'label' => '', |
|
| 515 | - 'description' => '', |
|
| 516 | - 'options' => array ( |
|
| 517 | - 'source' => 'search', |
|
| 518 | - 'engine' => 'solr', |
|
| 519 | - 'select' => $query, |
|
| 520 | - 'userid' => 0, |
|
| 521 | - 'params' => $this->params, |
|
| 522 | - 'core' => $this->core, |
|
| 523 | - 'pid' => $this->cPid, |
|
| 524 | - 'order' => 'relevance', |
|
| 525 | - 'order.asc' => TRUE, |
|
| 526 | - ) |
|
| 527 | - ); |
|
| 512 | + // Set metadata for search. |
|
| 513 | + $list->metadata = array ( |
|
| 514 | + 'label' => '', |
|
| 515 | + 'description' => '', |
|
| 516 | + 'options' => array ( |
|
| 517 | + 'source' => 'search', |
|
| 518 | + 'engine' => 'solr', |
|
| 519 | + 'select' => $query, |
|
| 520 | + 'userid' => 0, |
|
| 521 | + 'params' => $this->params, |
|
| 522 | + 'core' => $this->core, |
|
| 523 | + 'pid' => $this->cPid, |
|
| 524 | + 'order' => 'relevance', |
|
| 525 | + 'order.asc' => TRUE, |
|
| 526 | + ) |
|
| 527 | + ); |
|
| 528 | 528 | |
| 529 | - return $list; |
|
| 529 | + return $list; |
|
| 530 | 530 | |
| 531 | - } |
|
| 531 | + } |
|
| 532 | 532 | |
| 533 | - /** |
|
| 534 | - * This returns $this->limit via __get() |
|
| 535 | - * |
|
| 536 | - * @access protected |
|
| 537 | - * |
|
| 538 | - * @return integer The max number of results |
|
| 539 | - */ |
|
| 540 | - protected function _getLimit() { |
|
| 533 | + /** |
|
| 534 | + * This returns $this->limit via __get() |
|
| 535 | + * |
|
| 536 | + * @access protected |
|
| 537 | + * |
|
| 538 | + * @return integer The max number of results |
|
| 539 | + */ |
|
| 540 | + protected function _getLimit() { |
|
| 541 | 541 | |
| 542 | - return $this->limit; |
|
| 542 | + return $this->limit; |
|
| 543 | 543 | |
| 544 | - } |
|
| 544 | + } |
|
| 545 | 545 | |
| 546 | - /** |
|
| 547 | - * This returns $this->numberOfHits via __get() |
|
| 548 | - * |
|
| 549 | - * @access protected |
|
| 550 | - * |
|
| 551 | - * @return integer Total number of hits for last search |
|
| 552 | - */ |
|
| 553 | - protected function _getNumberOfHits() { |
|
| 546 | + /** |
|
| 547 | + * This returns $this->numberOfHits via __get() |
|
| 548 | + * |
|
| 549 | + * @access protected |
|
| 550 | + * |
|
| 551 | + * @return integer Total number of hits for last search |
|
| 552 | + */ |
|
| 553 | + protected function _getNumberOfHits() { |
|
| 554 | 554 | |
| 555 | - return $this->numberOfHits; |
|
| 555 | + return $this->numberOfHits; |
|
| 556 | 556 | |
| 557 | - } |
|
| 557 | + } |
|
| 558 | 558 | |
| 559 | - /** |
|
| 560 | - * This returns $this->ready via __get() |
|
| 561 | - * |
|
| 562 | - * @access protected |
|
| 563 | - * |
|
| 564 | - * @return boolean Is the search instantiated successfully? |
|
| 565 | - */ |
|
| 566 | - protected function _getReady() { |
|
| 559 | + /** |
|
| 560 | + * This returns $this->ready via __get() |
|
| 561 | + * |
|
| 562 | + * @access protected |
|
| 563 | + * |
|
| 564 | + * @return boolean Is the search instantiated successfully? |
|
| 565 | + */ |
|
| 566 | + protected function _getReady() { |
|
| 567 | 567 | |
| 568 | - return $this->ready; |
|
| 568 | + return $this->ready; |
|
| 569 | 569 | |
| 570 | - } |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | - /** |
|
| 573 | - * This returns $this->service via __get() |
|
| 574 | - * |
|
| 575 | - * @access protected |
|
| 576 | - * |
|
| 577 | - * @return Apache_Solr_Service Apache Solr service object |
|
| 578 | - */ |
|
| 579 | - protected function _getService() { |
|
| 572 | + /** |
|
| 573 | + * This returns $this->service via __get() |
|
| 574 | + * |
|
| 575 | + * @access protected |
|
| 576 | + * |
|
| 577 | + * @return Apache_Solr_Service Apache Solr service object |
|
| 578 | + */ |
|
| 579 | + protected function _getService() { |
|
| 580 | 580 | |
| 581 | - return $this->service; |
|
| 581 | + return $this->service; |
|
| 582 | 582 | |
| 583 | - } |
|
| 583 | + } |
|
| 584 | 584 | |
| 585 | - /** |
|
| 586 | - * This sets $this->cPid via __set() |
|
| 587 | - * |
|
| 588 | - * @access protected |
|
| 589 | - * |
|
| 590 | - * @param integer $value: The new PID for the metadata definitions |
|
| 591 | - * |
|
| 592 | - * @return void |
|
| 593 | - */ |
|
| 594 | - protected function _setCPid($value) { |
|
| 585 | + /** |
|
| 586 | + * This sets $this->cPid via __set() |
|
| 587 | + * |
|
| 588 | + * @access protected |
|
| 589 | + * |
|
| 590 | + * @param integer $value: The new PID for the metadata definitions |
|
| 591 | + * |
|
| 592 | + * @return void |
|
| 593 | + */ |
|
| 594 | + protected function _setCPid($value) { |
|
| 595 | 595 | |
| 596 | - $this->cPid = max(intval($value), 0); |
|
| 596 | + $this->cPid = max(intval($value), 0); |
|
| 597 | 597 | |
| 598 | - } |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | - /** |
|
| 601 | - * This sets $this->limit via __set() |
|
| 602 | - * |
|
| 603 | - * @access protected |
|
| 604 | - * |
|
| 605 | - * @param integer $value: The max number of results |
|
| 606 | - * |
|
| 607 | - * @return void |
|
| 608 | - */ |
|
| 609 | - protected function _setLimit($value) { |
|
| 600 | + /** |
|
| 601 | + * This sets $this->limit via __set() |
|
| 602 | + * |
|
| 603 | + * @access protected |
|
| 604 | + * |
|
| 605 | + * @param integer $value: The max number of results |
|
| 606 | + * |
|
| 607 | + * @return void |
|
| 608 | + */ |
|
| 609 | + protected function _setLimit($value) { |
|
| 610 | 610 | |
| 611 | - $this->limit = max(intval($value), 0); |
|
| 611 | + $this->limit = max(intval($value), 0); |
|
| 612 | 612 | |
| 613 | - } |
|
| 613 | + } |
|
| 614 | 614 | |
| 615 | - /** |
|
| 616 | - * This sets $this->params via __set() |
|
| 617 | - * |
|
| 618 | - * @access protected |
|
| 619 | - * |
|
| 620 | - * @param array $value: The query parameters |
|
| 621 | - * |
|
| 622 | - * @return void |
|
| 623 | - */ |
|
| 624 | - protected function _setParams(array $value) { |
|
| 615 | + /** |
|
| 616 | + * This sets $this->params via __set() |
|
| 617 | + * |
|
| 618 | + * @access protected |
|
| 619 | + * |
|
| 620 | + * @param array $value: The query parameters |
|
| 621 | + * |
|
| 622 | + * @return void |
|
| 623 | + */ |
|
| 624 | + protected function _setParams(array $value) { |
|
| 625 | 625 | |
| 626 | - $this->params = $value; |
|
| 626 | + $this->params = $value; |
|
| 627 | 627 | |
| 628 | - } |
|
| 628 | + } |
|
| 629 | 629 | |
| 630 | - /** |
|
| 631 | - * This magic method is called each time an invisible property is referenced from the object |
|
| 632 | - * |
|
| 633 | - * @access public |
|
| 634 | - * |
|
| 635 | - * @param string $var: Name of variable to get |
|
| 636 | - * |
|
| 637 | - * @return mixed Value of $this->$var |
|
| 638 | - */ |
|
| 639 | - public function __get($var) { |
|
| 630 | + /** |
|
| 631 | + * This magic method is called each time an invisible property is referenced from the object |
|
| 632 | + * |
|
| 633 | + * @access public |
|
| 634 | + * |
|
| 635 | + * @param string $var: Name of variable to get |
|
| 636 | + * |
|
| 637 | + * @return mixed Value of $this->$var |
|
| 638 | + */ |
|
| 639 | + public function __get($var) { |
|
| 640 | 640 | |
| 641 | - $method = '_get'.ucfirst($var); |
|
| 641 | + $method = '_get'.ucfirst($var); |
|
| 642 | 642 | |
| 643 | - if (!property_exists($this, $var) || !method_exists($this, $method)) { |
|
| 643 | + if (!property_exists($this, $var) || !method_exists($this, $method)) { |
|
| 644 | 644 | |
| 645 | - if (TYPO3_DLOG) { |
|
| 645 | + if (TYPO3_DLOG) { |
|
| 646 | 646 | |
| 647 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_solr->__get('.$var.')] There is no getter function for property "'.$var.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 647 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_solr->__get('.$var.')] There is no getter function for property "'.$var.'"', self::$extKey, SYSLOG_SEVERITY_WARNING); |
|
| 648 | 648 | |
| 649 | - } |
|
| 649 | + } |
|
| 650 | 650 | |
| 651 | - return; |
|
| 651 | + return; |
|
| 652 | 652 | |
| 653 | - } else { |
|
| 653 | + } else { |
|
| 654 | 654 | |
| 655 | - return $this->$method(); |
|
| 655 | + return $this->$method(); |
|
| 656 | 656 | |
| 657 | - } |
|
| 657 | + } |
|
| 658 | 658 | |
| 659 | - } |
|
| 659 | + } |
|
| 660 | 660 | |
| 661 | - /** |
|
| 662 | - * This magic method is called each time an invisible property is referenced from the object |
|
| 663 | - * |
|
| 664 | - * @access public |
|
| 665 | - * |
|
| 666 | - * @param string $var: Name of variable to set |
|
| 667 | - * @param mixed $value: New value of variable |
|
| 668 | - * |
|
| 669 | - * @return void |
|
| 670 | - */ |
|
| 671 | - public function __set($var, $value) { |
|
| 661 | + /** |
|
| 662 | + * This magic method is called each time an invisible property is referenced from the object |
|
| 663 | + * |
|
| 664 | + * @access public |
|
| 665 | + * |
|
| 666 | + * @param string $var: Name of variable to set |
|
| 667 | + * @param mixed $value: New value of variable |
|
| 668 | + * |
|
| 669 | + * @return void |
|
| 670 | + */ |
|
| 671 | + public function __set($var, $value) { |
|
| 672 | 672 | |
| 673 | - $method = '_set'.ucfirst($var); |
|
| 673 | + $method = '_set'.ucfirst($var); |
|
| 674 | 674 | |
| 675 | - if (!property_exists($this, $var) || !method_exists($this, $method)) { |
|
| 675 | + if (!property_exists($this, $var) || !method_exists($this, $method)) { |
|
| 676 | 676 | |
| 677 | - if (TYPO3_DLOG) { |
|
| 677 | + if (TYPO3_DLOG) { |
|
| 678 | 678 | |
| 679 | - \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_solr->__set('.$var.', [data])] There is no setter function for property "'.$var.'"', self::$extKey, SYSLOG_SEVERITY_WARNING, $value); |
|
| 679 | + \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_solr->__set('.$var.', [data])] There is no setter function for property "'.$var.'"', self::$extKey, SYSLOG_SEVERITY_WARNING, $value); |
|
| 680 | 680 | |
| 681 | - } |
|
| 681 | + } |
|
| 682 | 682 | |
| 683 | - } else { |
|
| 683 | + } else { |
|
| 684 | 684 | |
| 685 | - $this->$method($value); |
|
| 685 | + $this->$method($value); |
|
| 686 | 686 | |
| 687 | - } |
|
| 687 | + } |
|
| 688 | 688 | |
| 689 | - } |
|
| 689 | + } |
|
| 690 | 690 | |
| 691 | - /** |
|
| 692 | - * This is a singleton class, thus the constructor should be private/protected |
|
| 693 | - * |
|
| 694 | - * @access protected |
|
| 695 | - * |
|
| 696 | - * @param string $core: The name of the core to use |
|
| 697 | - * |
|
| 698 | - * @return void |
|
| 699 | - */ |
|
| 700 | - protected function __construct($core) { |
|
| 691 | + /** |
|
| 692 | + * This is a singleton class, thus the constructor should be private/protected |
|
| 693 | + * |
|
| 694 | + * @access protected |
|
| 695 | + * |
|
| 696 | + * @param string $core: The name of the core to use |
|
| 697 | + * |
|
| 698 | + * @return void |
|
| 699 | + */ |
|
| 700 | + protected function __construct($core) { |
|
| 701 | 701 | |
| 702 | - // Load class. |
|
| 703 | - if (!class_exists('Apache_Solr_Service')) { |
|
| 702 | + // Load class. |
|
| 703 | + if (!class_exists('Apache_Solr_Service')) { |
|
| 704 | 704 | |
| 705 | - require_once(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:'.self::$extKey.'/lib/SolrPhpClient/Apache/Solr/Service.php')); |
|
| 705 | + require_once(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:'.self::$extKey.'/lib/SolrPhpClient/Apache/Solr/Service.php')); |
|
| 706 | 706 | |
| 707 | - } |
|
| 707 | + } |
|
| 708 | 708 | |
| 709 | - $solrInfo = self::getSolrConnectionInfo($core); |
|
| 709 | + $solrInfo = self::getSolrConnectionInfo($core); |
|
| 710 | 710 | |
| 711 | - // Instantiate Apache_Solr_Service class. |
|
| 712 | - $this->service = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Apache_Solr_Service', $solrInfo['host'], $solrInfo['port'], $solrInfo['path']); |
|
| 711 | + // Instantiate Apache_Solr_Service class. |
|
| 712 | + $this->service = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Apache_Solr_Service', $solrInfo['host'], $solrInfo['port'], $solrInfo['path']); |
|
| 713 | 713 | |
| 714 | - // Check if connection is established. |
|
| 715 | - if ($this->service->ping() !== FALSE) { |
|
| 714 | + // Check if connection is established. |
|
| 715 | + if ($this->service->ping() !== FALSE) { |
|
| 716 | 716 | |
| 717 | - // Do not collapse single value arrays. |
|
| 718 | - $this->service->setCollapseSingleValueArrays = FALSE; |
|
| 717 | + // Do not collapse single value arrays. |
|
| 718 | + $this->service->setCollapseSingleValueArrays = FALSE; |
|
| 719 | 719 | |
| 720 | - // Set core name. |
|
| 721 | - $this->core = $core; |
|
| 720 | + // Set core name. |
|
| 721 | + $this->core = $core; |
|
| 722 | 722 | |
| 723 | - // Instantiation successful! |
|
| 724 | - $this->ready = TRUE; |
|
| 723 | + // Instantiation successful! |
|
| 724 | + $this->ready = TRUE; |
|
| 725 | 725 | |
| 726 | - } |
|
| 726 | + } |
|
| 727 | 727 | |
| 728 | - } |
|
| 728 | + } |
|
| 729 | 729 | |
| 730 | 730 | } |
@@ -139,12 +139,12 @@ |
||
| 139 | 139 | if (preg_match('/^[[:alnum:]]+_[tu][su]i:\(.*\)$/', $query)) { |
| 140 | 140 | |
| 141 | 141 | // Get all indexed fields. |
| 142 | - $fields = array(); |
|
| 142 | + $fields = array (); |
|
| 143 | 143 | |
| 144 | 144 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
| 145 | 145 | 'tx_dlf_metadata.index_name,tx_dlf_metadata.index_tokenized,tx_dlf_metadata.index_stored', |
| 146 | 146 | 'tx_dlf_metadata', |
| 147 | - 'tx_dlf_metadata.index_indexed=1 AND tx_dlf_metadata.pid=' . intval($pid) . ' AND (tx_dlf_metadata.sys_language_uid IN (-1,0) OR tx_dlf_metadata.l18n_parent=0)' . tx_dlf_helper::whereClause('tx_dlf_metadata'), |
|
| 147 | + 'tx_dlf_metadata.index_indexed=1 AND tx_dlf_metadata.pid='.intval($pid).' AND (tx_dlf_metadata.sys_language_uid IN (-1,0) OR tx_dlf_metadata.l18n_parent=0)'.tx_dlf_helper::whereClause('tx_dlf_metadata'), |
|
| 148 | 148 | '', |
| 149 | 149 | '', |
| 150 | 150 | '' |