[BUGFIX] indexed_search: use correct TS settings in extbase plugin 65/37965/3
authorTymoteusz Motylewski <t.motylewski@gmail.com>
Thu, 19 Mar 2015 22:33:48 +0000 (23:33 +0100)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Fri, 3 Apr 2015 10:26:51 +0000 (12:26 +0200)
Fixes few places where controller tried to access TS settings
in the wrong way (with dot at the end of the key).

It also fixes calls not extisting cobj property.

Resolves: #66251
Releases: master, 6.2
Change-Id: I1dba9b7f2b93f7a9eb297f82e067ce6e8e36dbb0
Reviewed-on: http://review.typo3.org/37965
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
typo3/sysext/indexed_search/Classes/Controller/SearchController.php
typo3/sysext/indexed_search/Configuration/TypoScript/setup.txt

index 75fd3d4..5dd7388 100644 (file)
@@ -120,6 +120,12 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
        protected $enableMetaphoneSearch = FALSE;
 
        /**
+        * @var \TYPO3\CMS\Extbase\Service\TypoScriptService
+        * @inject
+        */
+       protected $typoScriptService;
+
+       /**
         * sets up all necessary object for searching
         *
         * @param array $searchData The incoming search parameters
@@ -361,7 +367,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
         * @return string HTML code
         */
        protected function compileSingleResultRow($row, $headerOnly = 0) {
-               $specRowConf = $this->getSpecialConfigForResultRow($row);
+               $specRowConf = $this->getSpecialConfigurationForResultRow($row);
                $resultData = $row;
                $resultData['headerOnly'] = $headerOnly;
                $resultData['CSSsuffix'] = $specRowConf['CSSsuffix'] ? '-' . $specRowConf['CSSsuffix'] : '';
@@ -457,15 +463,15 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
         * @param array $row Result row
         * @return array Configuration array
         */
-       protected function getSpecialConfigForResultRow($row) {
+       protected function getSpecialConfigurationForResultRow($row) {
                $pathId = $row['data_page_id'] ?: $row['page_id'];
                $pathMP = $row['data_page_id'] ? $row['data_page_mp'] : '';
                $rl = $GLOBALS['TSFE']->sys_page->getRootLine($pathId, $pathMP);
-               $specConf = $this->settings['specialConfiguration.']['0.'];
+               $specConf = $this->settings['specialConfiguration']['0'];
                if (is_array($rl)) {
                        foreach ($rl as $dat) {
-                               if (is_array($this->conf['specialConfiguration.'][$dat['uid'] . '.'])) {
-                                       $specConf = $this->conf['specialConfiguration.'][$dat['uid'] . '.'];
+                               if (is_array($this->settings['specialConfiguration'][$dat['uid']])) {
+                                       $specConf = $this->settings['specialConfiguration'][$dat['uid']];
                                        $specConf['_pid'] = $dat['uid'];
                                        break;
                                }
@@ -505,10 +511,10 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                                return ceil(log($total) / log($max) * 100) . '%';
                                break;
                        case 'crdate':
-                               return $this->cObj->calcAge($GLOBALS['EXEC_TIME'] - $row['item_crdate'], 0);
+                               return $GLOBALS['TSFE']->cObj->calcAge($GLOBALS['EXEC_TIME'] - $row['item_crdate'], 0);
                                break;
                        case 'mtime':
-                               return $this->cObj->calcAge($GLOBALS['EXEC_TIME'] - $row['item_mtime'], 0);
+                               return $GLOBALS['TSFE']->cObj->calcAge($GLOBALS['EXEC_TIME'] - $row['item_mtime'], 0);
                                break;
                        default:
                                return ' ';
@@ -526,11 +532,12 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                // If search result is a TYPO3 page:
                if ((string)$row['item_type'] === '0') {
                        // If TypoScript is used to render the flag:
-                       if (is_array($this->settings['flagRendering.'])) {
+                       if (is_array($this->settings['flagRendering'])) {
                                /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj */
                                $cObj = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
                                $cObj->setCurrentVal($row['sys_language_uid']);
-                               $output = $cObj->cObjGetSingle($this->settings['flagRendering'], $this->settings['flagRendering.']);
+                               $typoScriptArray = $this->typoScriptService->convertPlainArrayToTypoScriptArray($this->settings['flagRendering']);
+                               $output = $cObj->cObjGetSingle($this->settings['flagRendering']['_typoScriptNodeValue'], $typoScriptArray);
                        }
                }
                return $output;
@@ -546,22 +553,25 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
         */
        public function makeItemTypeIcon($imageType, $alt, $specRowConf) {
                // Build compound key if item type is 0, iconRendering is not used
-               // and specConfs.[pid].pageIcon was set in TS
-               if ($imageType === '0' && $specRowConf['_pid'] && is_array($specRowConf['pageIcon.']) && !is_array($this->settings['iconRendering.'])) {
+               // and specialConfiguration.[pid].pageIcon was set in TS
+               if ($imageType === '0' && $specRowConf['_pid'] && is_array($specRowConf['pageIcon']) && !is_array($this->settings['iconRendering'])) {
                        $imageType .= ':' . $specRowConf['_pid'];
                }
                if (!isset($this->iconFileNameCache[$imageType])) {
                        $this->iconFileNameCache[$imageType] = '';
                        // If TypoScript is used to render the icon:
-                       if (is_array($this->settings['iconRendering.'])) {
-                               $this->cObj->setCurrentVal($imageType);
-                               $this->iconFileNameCache[$imageType] = $this->cObj->cObjGetSingle($this->settings['iconRendering'], $this->settings['iconRendering.']);
+                       if (is_array($this->settings['iconRendering'])) {
+                               /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj */
+                               $cObj = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
+                               $cObj->setCurrentVal($imageType);
+                               $typoScriptArray = $this->typoScriptService->convertPlainArrayToTypoScriptArray($this->settings['iconRendering']);
+                               $this->iconFileNameCache[$imageType] = $cObj->cObjGetSingle($this->settings['iconRendering']['_typoScriptNodeValue'], $typoScriptArray);
                        } else {
                                // Default creation / finding of icon:
                                $icon = '';
                                if ($imageType === '0' || substr($imageType, 0, 2) == '0:') {
-                                       if (is_array($specRowConf['pageIcon.'])) {
-                                               $this->iconFileNameCache[$imageType] = $this->cObj->cObjGetSingle('IMAGE', $specRowConf['pageIcon.']);
+                                       if (is_array($specRowConf['pageIcon'])) {
+                                               $this->iconFileNameCache[$imageType] = $GLOBALS['TSFE']->cObj->cObjGetSingle('IMAGE', $specRowConf['pageIcon']);
                                        } else {
                                                $icon = 'EXT:indexed_search/pi/res/pages.gif';
                                        }
@@ -822,7 +832,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                // Adding search field value
                $this->view->assign('sword', $this->sword);
                // Additonal keyword => "Add to current search words"
-               $showAdditionalKeywordSearch = $this->settings['clearSearchBox'] && $this->settings['clearSearchBox.']['enableSubSearchCheckBox'];
+               $showAdditionalKeywordSearch = $this->settings['clearSearchBox'] && $this->settings['clearSearchBox']['enableSubSearchCheckBox'];
                if ($showAdditionalKeywordSearch) {
                        $this->view->assign('previousSearchWord', $this->settings['clearSearchBox'] ? '' : $this->sword);
                }
@@ -887,7 +897,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                        unset($allOptions[10]);
                }
                // disable single entries by TypoScript
-               $allOptions = $this->removeOptionsFromOptionList($allOptions, $blindSettings['searchType.']);
+               $allOptions = $this->removeOptionsFromOptionList($allOptions, $blindSettings['searchType']);
                return $allOptions;
        }
 
@@ -906,7 +916,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                        );
                }
                // disable single entries by TypoScript
-               $allOptions = $this->removeOptionsFromOptionList($allOptions, $blindSettings['defaultOperand.']);
+               $allOptions = $this->removeOptionsFromOptionList($allOptions, $blindSettings['defaultOperand']);
                return $allOptions;
        }
 
@@ -942,7 +952,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                        }
                }
                // disable single entries by TypoScript
-               $allOptions = $this->removeOptionsFromOptionList($allOptions, $blindSettings['mediaType.']);
+               $allOptions = $this->removeOptionsFromOptionList($allOptions, $blindSettings['mediaType']);
                return $allOptions;
        }
 
@@ -966,7 +976,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                                }
                        }
                        // disable single entries by TypoScript
-                       $allOptions = $this->removeOptionsFromOptionList($allOptions, $blindSettings['languageUid.']);
+                       $allOptions = $this->removeOptionsFromOptionList($allOptions, $blindSettings['languageUid']);
                } else {
                        $allOptions = array();
                }
@@ -1018,7 +1028,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                        $allOptions['rl1_' . implode(',', array_keys($firstLevelMenu))] = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('sections.rootLevel1All', 'indexed_search');
                }
                // disable single entries by TypoScript
-               $allOptions = $this->removeOptionsFromOptionList($allOptions, $blindSettings['sections.']);
+               $allOptions = $this->removeOptionsFromOptionList($allOptions, $blindSettings['sections']);
                return $allOptions;
        }
 
@@ -1046,7 +1056,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                                }
                        }
                        // disable single entries by TypoScript
-                       $allOptions = $this->removeOptionsFromOptionList($allOptions, $blindSettings['indexingConfigurations.']);
+                       $allOptions = $this->removeOptionsFromOptionList($allOptions, $blindSettings['indexingConfigurations']);
                } else {
                        $allOptions = array();
                }
index 39d801b..edb77d2 100644 (file)
@@ -69,6 +69,13 @@ plugin.tx_indexedsearch {
                        default = TEXT
                        default.value = TYPO3 pages
                }
+
+               specialConfiguration {
+                       0.pageIcon = IMAGE
+                       0.pageIcon.file = typo3/sysext/indexed_search/pi/res/pages.gif
+                       1.pageIcon = IMAGE
+                       1.pageIcon.file = typo3/sysext/indexed_search/pi/res/pdf.gif
+               }
 */
                defaultOptions {
                        defaultOperand = 0