[BUGFIX] Use correct extension name for labels in indexed search 34/41834/2
authorMarkus Klein <markus.klein@typo3.org>
Wed, 22 Jul 2015 16:27:35 +0000 (18:27 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Wed, 22 Jul 2015 17:53:39 +0000 (19:53 +0200)
The extbase implementation of the search form must use extensionName
and not extension_key for retrieving translations.
This ensures that translations from the template are taken into account.

Releases: master, 6.2
Resolves: #68430
Change-Id: Ia2265793b4f57c018ffca5ae5af9feb1cbf94803
Reviewed-on: http://review.typo3.org/41834
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/indexed_search/Classes/Controller/SearchController.php
typo3/sysext/indexed_search/Classes/ViewHelpers/PageBrowsingResultsViewHelper.php

index cdb7e95..d8910e4 100644 (file)
@@ -228,7 +228,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                                        $indexCfgRec = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('title', 'index_config', 'uid=' . (int)$freeIndexUid . $GLOBALS['TSFE']->cObj->enableFields('index_config'));
                                        $categoryTitle = $indexCfgRec['title'];
                                } else {
-                                       $categoryTitle = LocalizationUtility::translate('indexingConfigurationHeader.' . $freeIndexUid, 'indexed_search');
+                                       $categoryTitle = LocalizationUtility::translate('indexingConfigurationHeader.' . $freeIndexUid, 'IndexedSearch');
                                }
                                $resultsets[$freeIndexUid]['categoryTitle'] = $categoryTitle;
                        }
@@ -269,13 +269,13 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                                // could we get this in the view?
                                if ($this->searchData['group'] == 'sections' && $freeIndexUid <= 0) {
                                        $resultSectionsCount = count($this->resultSections);
-                                       $result['sectionText'] = sprintf(LocalizationUtility::translate('result.' . ($resultSectionsCount > 1 ? 'inNsections' : 'inNsection'), 'indexed_search'), $resultSectionsCount);
+                                       $result['sectionText'] = sprintf(LocalizationUtility::translate('result.' . ($resultSectionsCount > 1 ? 'inNsections' : 'inNsection'), 'IndexedSearch'), $resultSectionsCount);
                                }
                        }
                }
                // Print a message telling which words in which sections we searched for
                if (substr($this->searchData['sections'], 0, 2) == 'rl') {
-                       $result['searchedInSectionInfo'] = LocalizationUtility::translate('result.inSection', 'indexed_search') . ' "' . substr($this->getPathFromPageId(substr($this->searchData['sections'], 4)), 1) . '"';
+                       $result['searchedInSectionInfo'] = LocalizationUtility::translate('result.inSection', 'IndexedSearch') . ' "' . substr($this->getPathFromPageId(substr($this->searchData['sections'], 4)), 1) . '"';
                }
                return $result;
        }
@@ -337,7 +337,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                                $sectionName = $this->getPathFromPageId($theId);
                                $sectionName = ltrim($sectionName, '/');
                                if (!trim($sectionName)) {
-                                       $sectionTitleLinked = LocalizationUtility::translate('result.unnamedSection', 'indexed_search') . ':';
+                                       $sectionTitleLinked = LocalizationUtility::translate('result.unnamedSection', 'IndexedSearch') . ':';
                                } else {
                                        $onclick = 'document.forms[\'tx_indexedsearch\'][\'tx_indexedsearch_pi2[search][_sections]\'].value=' . GeneralUtility::quoteJSvalue($theRLid) . ';document.forms[\'tx_indexedsearch\'].submit();return false;';
                                        $sectionTitleLinked = '<a href="#" onclick="' . htmlspecialchars($onclick) . '">' . htmlspecialchars($sectionName) . ':</a>';
@@ -381,9 +381,9 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                        $dat = unserialize($row['cHashParams']);
                        $pp = explode('-', $dat['key']);
                        if ($pp[0] != $pp[1]) {
-                               $resultData['titleaddition'] = ', ' . LocalizationUtility::translate('result.page', 'indexed_search') . ' ' . $dat['key'];
+                               $resultData['titleaddition'] = ', ' . LocalizationUtility::translate('result.page', 'IndexedSearch') . ' ' . $dat['key'];
                        } else {
-                               $resultData['titleaddition'] = ', ' . LocalizationUtility::translate('result.pages', 'indexed_search') . ' ' . $pp[0];
+                               $resultData['titleaddition'] = ', ' . LocalizationUtility::translate('result.pages', 'IndexedSearch') . ' ' . $pp[0];
                        }
                }
                $title = $resultData['item_title'] . $resultData['titleaddition'];
@@ -444,7 +444,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                        if (is_array($this->requiredFrontendUsergroups[$pathId]) && !empty($this->requiredFrontendUsergroups[$pathId])) {
                                $resultData['access'] = '<img src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('indexed_search')
                                        . 'pi/res/locked.gif" width="12" height="15" vspace="5" title="'
-                                       . sprintf(LocalizationUtility::translate('result.memberGroups', 'indexed_search'), implode(',', array_unique($this->requiredFrontendUsergroups[$pathId])))
+                                       . sprintf(LocalizationUtility::translate('result.memberGroups', 'IndexedSearch'), implode(',', array_unique($this->requiredFrontendUsergroups[$pathId])))
                                        . '" alt="" />';
                        }
                }
@@ -453,13 +453,13 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                if (is_array($row['_sub'])) {
                        $resultData['subresults'] = array();
                        if ($this->multiplePagesType($row['item_type'])) {
-                               $resultData['subresults']['header'] = LocalizationUtility::translate('result.otherMatching', 'indexed_search');
+                               $resultData['subresults']['header'] = LocalizationUtility::translate('result.otherMatching', 'IndexedSearch');
                                foreach ($row['_sub'] as $subRow) {
                                        $resultData['subresults']['items'][] = $this->compileSingleResultRow($subRow, 1);
                                }
                        } else {
-                               $resultData['subresults']['header'] = LocalizationUtility::translate('result.otherMatching', 'indexed_search');
-                               $resultData['subresults']['info'] = LocalizationUtility::translate('result.otherPageAsWell', 'indexed_search');
+                               $resultData['subresults']['header'] = LocalizationUtility::translate('result.otherMatching', 'IndexedSearch');
+                               $resultData['subresults']['info'] = LocalizationUtility::translate('result.otherPageAsWell', 'IndexedSearch');
                        }
                }
                return $resultData;
@@ -499,7 +499,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
        protected function makeRating($row) {
                switch ((string)$this->searchData['sortOrder']) {
                        case 'rank_count':
-                               return $row['order_val'] . ' ' . LocalizationUtility::translate('result.ratingMatches', 'indexed_search');
+                               return $row['order_val'] . ' ' . LocalizationUtility::translate('result.ratingMatches', 'IndexedSearch');
                                break;
                        case 'rank_first':
                                return ceil(MathUtility::forceIntegerInRange((255 - $row['order_val']), 1, 255) / 255 * 100) . '%';
@@ -628,7 +628,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                        $output = $outputStr ?: $markedSW;
                        $output = $GLOBALS['TSFE']->csConv($output, 'utf-8');
                } else {
-                       $output = '<span class="noResume">' . LocalizationUtility::translate('result.noResume', 'indexed_search') . '</span>';
+                       $output = '<span class="noResume">' . LocalizationUtility::translate('result.noResume', 'IndexedSearch') . '</span>';
                }
                return $output;
        }
@@ -786,9 +786,9 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                                        array('-', 'AND NOT'),
                                        // Add operators for various languages
                                        // Converts the operators to UTF-8 and lowercase
-                                       array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8', $GLOBALS['TSFE']->csConvObj->utf8_encode(LocalizationUtility::translate('localizedOperandAnd', 'indexed_search'), $GLOBALS['TSFE']->renderCharset), 'toLower'), 'AND'),
-                                       array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8', $GLOBALS['TSFE']->csConvObj->utf8_encode(LocalizationUtility::translate('localizedOperandOr', 'indexed_search'), $GLOBALS['TSFE']->renderCharset), 'toLower'), 'OR'),
-                                       array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8', $GLOBALS['TSFE']->csConvObj->utf8_encode(LocalizationUtility::translate('localizedOperandNot', 'indexed_search'), $GLOBALS['TSFE']->renderCharset), 'toLower'), 'AND NOT')
+                                       array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8', $GLOBALS['TSFE']->csConvObj->utf8_encode(LocalizationUtility::translate('localizedOperandAnd', 'IndexedSearch'), $GLOBALS['TSFE']->renderCharset), 'toLower'), 'AND'),
+                                       array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8', $GLOBALS['TSFE']->csConvObj->utf8_encode(LocalizationUtility::translate('localizedOperandOr', 'IndexedSearch'), $GLOBALS['TSFE']->renderCharset), 'toLower'), 'OR'),
+                                       array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8', $GLOBALS['TSFE']->csConvObj->utf8_encode(LocalizationUtility::translate('localizedOperandNot', 'IndexedSearch'), $GLOBALS['TSFE']->renderCharset), 'toLower'), 'AND NOT')
                                );
                                $swordArray = \TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::getExplodedSearchString($searchWords, $defaultOperator == 1 ? 'OR' : 'AND', $operatorTranslateTable);
                                if (is_array($swordArray)) {
@@ -900,7 +900,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                $blindSettings = $this->settings['blind'];
                if (!$blindSettings['searchType']) {
                        foreach ($types as $typeNum) {
-                               $allOptions[$typeNum] = LocalizationUtility::translate('searchTypes.' . $typeNum, 'indexed_search');
+                               $allOptions[$typeNum] = LocalizationUtility::translate('searchTypes.' . $typeNum, 'IndexedSearch');
                        }
                }
                // Remove this option if metaphone search is disabled)
@@ -922,8 +922,8 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                $blindSettings = $this->settings['blind'];
                if (!$blindSettings['defaultOperand']) {
                        $allOptions = array(
-                               0 => LocalizationUtility::translate('defaultOperands.0', 'indexed_search'),
-                               1 => LocalizationUtility::translate('defaultOperands.1', 'indexed_search')
+                               0 => LocalizationUtility::translate('defaultOperands.0', 'IndexedSearch'),
+                               1 => LocalizationUtility::translate('defaultOperands.1', 'IndexedSearch')
                        );
                }
                // disable single entries by TypoScript
@@ -942,7 +942,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                $blindSettings = $this->settings['blind'];
                if (!$blindSettings['mediaType']) {
                        foreach ($mediaTypes as $mediaType) {
-                               $allOptions[$mediaType] = LocalizationUtility::translate('mediaTypes.' . $mediaType, 'indexed_search');
+                               $allOptions[$mediaType] = LocalizationUtility::translate('mediaTypes.' . $mediaType, 'IndexedSearch');
                        }
                        // Add media to search in:
                        $additionalMedia = trim($this->settings['mediaList']);
@@ -957,7 +957,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                                        continue;
                                }
                                if ($name = $obj->searchTypeMediaTitle($extension)) {
-                                       $translatedName = LocalizationUtility::translate('mediaTypes.' . $extension, 'indexed_search');
+                                       $translatedName = LocalizationUtility::translate('mediaTypes.' . $extension, 'IndexedSearch');
                                        $allOptions[$extension] = $translatedName ?: $name;
                                }
                        }
@@ -974,8 +974,8 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
         */
        protected function getAllAvailableLanguageOptions() {
                $allOptions = array(
-                       '-1' => LocalizationUtility::translate('languageUids.-1', 'indexed_search'),
-                       '0' => LocalizationUtility::translate('languageUids.0', 'indexed_search')
+                       '-1' => LocalizationUtility::translate('languageUids.-1', 'IndexedSearch'),
+                       '0' => LocalizationUtility::translate('languageUids.0', 'IndexedSearch')
                );
                $blindSettings = $this->settings['blind'];
                if (!$blindSettings['languageUid']) {
@@ -1009,15 +1009,15 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                $blindSettings = $this->settings['blind'];
                if (!$blindSettings['sections']) {
                        foreach ($sections as $section) {
-                               $allOptions[$section] = LocalizationUtility::translate('sections.' . $section, 'indexed_search');
+                               $allOptions[$section] = LocalizationUtility::translate('sections.' . $section, 'IndexedSearch');
                        }
                }
                // Creating levels for section menu:
                // This selects the first and secondary menus for the "sections" selector - so we can search in sections and sub sections.
                if ($this->settings['displayLevel1Sections']) {
                        $firstLevelMenu = $this->getMenuOfPages($this->searchRootPageIdList);
-                       $labelLevel1 = LocalizationUtility::translate('sections.rootLevel1', 'indexed_search');
-                       $labelLevel2 = LocalizationUtility::translate('sections.rootLevel2', 'indexed_search');
+                       $labelLevel1 = LocalizationUtility::translate('sections.rootLevel1', 'IndexedSearch');
+                       $labelLevel2 = LocalizationUtility::translate('sections.rootLevel2', 'IndexedSearch');
                        foreach ($firstLevelMenu as $firstLevelKey => $menuItem) {
                                if (!$menuItem['nav_hide']) {
                                        $allOptions['rl1_' . $menuItem['uid']] = trim($labelLevel1 . ' ' . $menuItem['title']);
@@ -1030,13 +1030,13 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                                                                unset($secondLevelMenu[$secondLevelKey]);
                                                        }
                                                }
-                                               $allOptions['rl2_' . implode(',', array_keys($secondLevelMenu))] = LocalizationUtility::translate('sections.rootLevel2All', 'indexed_search');
+                                               $allOptions['rl2_' . implode(',', array_keys($secondLevelMenu))] = LocalizationUtility::translate('sections.rootLevel2All', 'IndexedSearch');
                                        }
                                } else {
                                        unset($firstLevelMenu[$firstLevelKey]);
                                }
                        }
-                       $allOptions['rl1_' . implode(',', array_keys($firstLevelMenu))] = LocalizationUtility::translate('sections.rootLevel1All', 'indexed_search');
+                       $allOptions['rl1_' . implode(',', array_keys($firstLevelMenu))] = LocalizationUtility::translate('sections.rootLevel1All', 'IndexedSearch');
                }
                // disable single entries by TypoScript
                $allOptions = $this->removeOptionsFromOptionList($allOptions, $blindSettings['sections']);
@@ -1050,9 +1050,9 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
         */
        protected function getAllAvailableIndexConfigurationsOptions() {
                $allOptions = array(
-                       '-1' => LocalizationUtility::translate('indexingConfigurations.-1', 'indexed_search'),
-                       '-2' => LocalizationUtility::translate('indexingConfigurations.-2', 'indexed_search'),
-                       '0' => LocalizationUtility::translate('indexingConfigurations.0', 'indexed_search')
+                       '-1' => LocalizationUtility::translate('indexingConfigurations.-1', 'IndexedSearch'),
+                       '-2' => LocalizationUtility::translate('indexingConfigurations.-2', 'IndexedSearch'),
+                       '0' => LocalizationUtility::translate('indexingConfigurations.0', 'IndexedSearch')
                );
                $blindSettings = $this->settings['blind'];
                if (!$blindSettings['indexingConfigurations']) {
@@ -1089,7 +1089,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                $blindSettings = $this->settings['blind'];
                if (!$blindSettings['sortOrder']) {
                        foreach ($sortOrders as $order) {
-                               $allOptions[$order] = LocalizationUtility::translate('sortOrders.' . $order, 'indexed_search');
+                               $allOptions[$order] = LocalizationUtility::translate('sortOrders.' . $order, 'IndexedSearch');
                        }
                }
                // disable single entries by TypoScript
@@ -1107,8 +1107,8 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                $blindSettings = $this->settings['blind'];
                if (!$blindSettings['groupBy']) {
                        $allOptions = array(
-                               'sections' => LocalizationUtility::translate('groupBy.sections', 'indexed_search'),
-                               'flat' => LocalizationUtility::translate('groupBy.flat', 'indexed_search')
+                               'sections' => LocalizationUtility::translate('groupBy.sections', 'IndexedSearch'),
+                               'flat' => LocalizationUtility::translate('groupBy.flat', 'IndexedSearch')
                        );
                }
                // disable single entries by TypoScript
@@ -1126,8 +1126,8 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                $blindSettings = $this->settings['blind'];
                if (!$blindSettings['descending']) {
                        $allOptions = array(
-                               0 => LocalizationUtility::translate('sortOrders.descending', 'indexed_search'),
-                               1 => LocalizationUtility::translate('sortOrders.ascending', 'indexed_search')
+                               0 => LocalizationUtility::translate('sortOrders.descending', 'IndexedSearch'),
+                               1 => LocalizationUtility::translate('sortOrders.ascending', 'IndexedSearch')
                        );
                }
                // disable single entries by TypoScript
index 8b8665c..2ddb86a 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\IndexedSearch\ViewHelpers;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
 use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
 use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
 use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
@@ -46,9 +47,8 @@ class PageBrowsingResultsViewHelper extends AbstractViewHelper implements Compil
 
        /**
         * @param array $arguments
-        * @param callable $renderChildrenClosure
+        * @param callable|\Closure $renderChildrenClosure
         * @param RenderingContextInterface $renderingContext
-        *
         * @return string
         */
        static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
@@ -58,7 +58,7 @@ class PageBrowsingResultsViewHelper extends AbstractViewHelper implements Compil
 
                $firstResultOnPage = $currentPage * $resultsPerPage + 1;
                $lastResultOnPage = $currentPage * $resultsPerPage + $resultsPerPage;
-               $label = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('displayResults', 'indexed_search');
+               $label = LocalizationUtility::translate('displayResults', 'IndexedSearch');
                return sprintf($label, $firstResultOnPage, min(array($numberOfResults, $lastResultOnPage)), $numberOfResults);
        }