[BUGFIX] indexed_search: Correct js for section titles 19/38119/5
authorTymoteusz Motylewski <t.motylewski@gmail.com>
Tue, 24 Mar 2015 16:45:34 +0000 (17:45 +0100)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Fri, 3 Apr 2015 11:53:22 +0000 (13:53 +0200)
Fixes js error when clicking on the section title
(both pibased and Extbase plugin)
Fix navigation of section menu in Extbase plugin.
Move "Displaying results" text to correct place
(above section menu) in Extbase plugin.

Resolves: #65980
Releases: master, 6.2
Change-Id: I46418ad8ca78f92f332c9ddcbb30d4c3afbd02b9
Reviewed-on: http://review.typo3.org/38119
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/Classes/Controller/SearchFormController.php
typo3/sysext/indexed_search/Resources/Private/Templates/Search/Search.html

index 5dd7388..1adb003 100644 (file)
@@ -334,7 +334,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                                if (!trim($sectionName)) {
                                        $sectionTitleLinked = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('result.unnamedSection', 'indexed_search') . ':';
                                } else {
-                                       $onclick = 'document.' . $this->prefixId . '[\'' . $this->prefixId . '[_sections]\'].value=\'' . $theRLid . '\';document.' . $this->prefixId . '.submit();return false;';
+                                       $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>';
                                }
                                $this->resultSections[$id] = array($sectionName, count($resultRows));
@@ -342,7 +342,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                                $finalResultRows[] = array(
                                        'isSectionHeader' => TRUE,
                                        'numResultRows' => count($resultRows),
-                                       'anchorName' => 'anchor_' . md5($id),
+                                       'sectionId' => $id,
                                        'sectionTitle' => $sectionTitleLinked
                                );
                                // Render result rows
index cf6c44e..6f0a47c 100644 (file)
@@ -747,7 +747,8 @@ class SearchFormController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
                                                if (!trim($sectionName)) {
                                                        $sectionTitleLinked = $this->pi_getLL('unnamedSection', '', TRUE) . ':';
                                                } elseif ($this->conf['linkSectionTitles']) {
-                                                       $onclick = 'document.' . $this->prefixId . '[\'' . $this->prefixId . '[_sections]\'].value=\'' . $theRLid . '\';document.' . $this->prefixId . '.submit();return false;';
+                                                       $quotedPrefix = GeneralUtility::quoteJSvalue($this->prefixId);
+                                                       $onclick = 'document.forms[' . $quotedPrefix . '][' . GeneralUtility::quoteJSvalue($this->prefixId . '[_sections]') . '].value=' . GeneralUtility::quoteJSvalue($theRLid) . ';document.forms[' . $quotedPrefix . '].submit();return false;';
                                                        $sectionTitleLinked = '<a href="#" onclick="' . htmlspecialchars($onclick) . '">' . htmlspecialchars($sectionName) . ':</a>';
                                                } else {
                                                        $sectionTitleLinked = htmlspecialchars($sectionName);
index c23e73e..9a3e3d3 100644 (file)
        <f:if condition="{result.count} > 0">
                <f:then>
                        <div class="tx-indexedsearch-browsebox">
+                               <p>
+                                       <is:pageBrowsingResults numberOfResults="{result.count}" currentPage="{searchParams.pointer}" resultsPerPage="{searchParams.results}" />
+                                       {result.sectionText}
+                               </p>
                                <!-- render the anchor-links to the sections inside the displayed result rows -->
                                <f:if condition="{result.affectedSections}">
                                        <div class="tx-indexedsearch-sectionlinks">
                                                </table>
                                        </div>
                                </f:if>
-                               <p>
-                                       <is:pageBrowsingResults numberOfResults="{result.count}" currentPage="{searchParams.pointer}" resultsPerPage="{searchParams.results}" />
-                                       {result.sectionText}
-                               </p>
                                <is:pageBrowsing maximumNumberOfResultPages="{settings.search.page_links}" numberOfResults="{result.count}" currentPage="{searchParams.pointer}" resultsPerPage="{searchParams.results}" />
                        </div>
                        <f:for each="{result.rows}" as="row">
                                <f:if condition="{row.isSectionHeader}">
                                        <f:then>
-                                       <div id="{row.anchorId}" class="tx-indexedsearch-sectionhead">
-                                               <h2 class="tx-indexedsearch-title">{row.sectionTitle} <span class="tx-indexedsearch-result-count">{row.numResultRows} <f:translate key="{f:if(condition: '{row.numResultRows} > 1', then: 'result.pages', else: 'result.page')}" /></span></h2>
+                                       <div id="anchor_{row.sectionId}" class="tx-indexedsearch-sectionhead">
+                                               <h2 class="tx-indexedsearch-title"><f:format.html>{row.sectionTitle}</f:format.html> <span class="tx-indexedsearch-result-count">{row.numResultRows} <f:translate key="{f:if(condition: '{row.numResultRows} > 1', then: 'result.pages', else: 'result.page')}" /></span></h2>
                                        </div>
                                        </f:then>
                                        <f:else>