[TASK] Use arrays in str_replace() calls
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / ContentObject / SearchResultContentObject.php
index 97480ea..81c9b4e 100644 (file)
@@ -4,7 +4,7 @@ namespace TYPO3\CMS\Frontend\ContentObject;
 /***************************************************************
  *  Copyright notice
  *
- *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
+ *  (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -124,6 +124,19 @@ class SearchResultContentObject extends \TYPO3\CMS\Frontend\ContentObject\Abstra
        public $listOfSearchFields = '';
 
        /**
+        * Override default constructor to make it possible to instantiate this
+        * class for indexed_search
+        *
+        * @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj
+        */
+       public function __construct(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj = NULL) {
+               if (!is_null($cObj)) {
+                       $this->cObj = $cObj;
+                       $this->fileFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
+               }
+       }
+
+       /**
         * Rendering the cObject, SEARCHRESULT
         *
         * @param array $conf Array of TypoScript properties
@@ -225,10 +238,19 @@ class SearchResultContentObject extends \TYPO3\CMS\Frontend\ContentObject\Abstra
                                $targetPart = $LD['target'] ? ' target="' . htmlspecialchars($LD['target']) . '"' : '';
                                $urlParams = $this->cObj->URLqMark($LD['totalURL'], '&sword=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('sword')) . '&scols=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('scols')) . '&stype=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('stype')) . '&scount=' . $total);
                                // substitution:
-                               $result = $this->cObj->cObjGetSingle($conf['layout'], $conf['layout.'], 'layout');
-                               $result = str_replace('###RANGELOW###', $rangeLow, $result);
-                               $result = str_replace('###RANGEHIGH###', $rangeHigh, $result);
-                               $result = str_replace('###TOTAL###', $total, $result);
+                               $result = str_replace(
+                                       array(
+                                               '###RANGELOW###',
+                                               '###RANGEHIGH###',
+                                               '###TOTAL###'
+                                       ),
+                                       array(
+                                               $rangeLow,
+                                               $rangeHigh,
+                                               $total
+                                       ),
+                                       $this->cObj->cObjGetSingle($conf['layout'], $conf['layout.'], 'layout')
+                               );
                                if ($rangeHigh < $total) {
                                        $next = $this->cObj->cObjGetSingle($conf['next'], $conf['next.'], 'next');
                                        $next = '<a href="' . htmlspecialchars(($urlParams . '&spointer=' . ($spointer + $theRange))) . '"' . $targetPart . $GLOBALS['TSFE']->ATagParams . '>' . $next . '</a>';
@@ -270,8 +292,8 @@ class SearchResultContentObject extends \TYPO3\CMS\Frontend\ContentObject\Abstra
                        if (isset($conf['stdWrap.'])) {
                                $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
                        }
-                       // returning
-                       $GLOBALS['TSFE']->set_no_cache();
+                       // Returning, do not cache the result of the search
+                       $GLOBALS['TSFE']->set_no_cache('Search result page');
                        return $content;
                }
                return '';
@@ -442,7 +464,7 @@ class SearchResultContentObject extends \TYPO3\CMS\Frontend\ContentObject\Abstra
         * @param string $endClause Some extra conditions that the search must match.
         * @return boolean Returns TRUE no matter what - sweet isn't it!
         * @access private
-        * @see         tslib_cObj::SEARCHRESULT()
+        * @see \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::SEARCHRESULT()
         * @todo Define visibility
         */
        public function build_search_query($endClause) {
@@ -641,6 +663,3 @@ class SearchResultContentObject extends \TYPO3\CMS\Frontend\ContentObject\Abstra
        }
 
 }
-
-
-?>
\ No newline at end of file