Fixed bug #9994: ereg* is deprecated in PHP 5.3 alpha3
[Packages/TYPO3.CMS.git] / typo3 / sysext / indexed_search / pi / class.tx_indexedsearch.php
index fe25513..18a0f4e 100755 (executable)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 2001-2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 2001-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -349,12 +349,14 @@ class tx_indexedsearch extends tslib_pibase {
                if ($this->conf['show.']['L1sections']) {
                        $firstLevelMenu = $this->getMenu($this->wholeSiteIdList);
                        while(list($kk,$mR) = each($firstLevelMenu))    {
-                               if ($mR['doktype']!=5)  {
+                                       // @TODO: RFC #7370: doktype 2&5 are deprecated since TYPO3 4.2-beta1
+                               if ($mR['doktype']!=5 && !$mR['nav_hide']) {
                                        $this->optValues['sections']['rl1_'.$mR['uid']] = trim($this->pi_getLL('opt_RL1').' '.$mR['title']);
                                        if ($this->conf['show.']['L2sections']) {
                                                $secondLevelMenu = $this->getMenu($mR['uid']);
                                                while(list($kk2,$mR2) = each($secondLevelMenu)) {
-                                                       if ($mR['doktype']!=5)  {
+                                                               // @TODO: RFC #7370: doktype 2&5 are deprecated since TYPO3 4.2-beta1
+                                                       if ($mR2['doktype']!=5 && !$mR2['nav_hide']) {
                                                                $this->optValues['sections']['rl2_'.$mR2['uid']] = trim($this->pi_getLL('opt_RL2').' '.$mR2['title']);
                                                        } else unset($secondLevelMenu[$kk2]);
                                                }
@@ -609,7 +611,7 @@ class tx_indexedsearch extends tslib_pibase {
                                                $c++;   // Increase the result pointer
 
                                                        // All rows for display is put into resultRows[]
-                                               if ($c > $pointer * $this->piVars['results'])   {
+                                               if ($c > $pointer * $this->piVars['results'] && $c <= ($pointer * $this->piVars['results'] + $this->piVars['results'])) {
                                                        $row['result_number'] = $c;
                                                        $resultRows[] = $row;
                                                                // This may lead to a problem: If the result check is not stopped here, the search will take longer. However the result counter will not filter out grouped cHashes/pHashes that were not processed yet. You can change this behavior using the "search.exactCount" property (see above).
@@ -1326,7 +1328,7 @@ class tx_indexedsearch extends tslib_pibase {
                        // Multilangual text
                $substituteArray = array('searchFor', 'extResume', 'atATime', 'orderBy', 'fromSection', 'searchIn', 'match', 'style', 'freeIndexUid');
                foreach ($substituteArray as $marker)   {
-                       $markerArray['###FORM_'.strtoupper($marker).'###'] = $this->pi_getLL('form_'.$marker,'',1);
+                       $markerArray['###FORM_'.t3lib_div::strtoupper($marker).'###'] = $this->pi_getLL('form_'.$marker,'',1);
                }
 
                $markerArray['###FORM_SUBMIT###'] = $this->pi_getLL('submit_button_label','',1);
@@ -1594,7 +1596,7 @@ class tx_indexedsearch extends tslib_pibase {
 
                        if (is_array($tmplContent))     {
                                foreach ($tmplContent AS $k => $v)      {
-                                       $markerArray['###'.strtoupper($k).'###'] = $v;
+                                       $markerArray['###'.t3lib_div::strtoupper($k).'###'] = $v;
                                }
                        }
 
@@ -2022,17 +2024,17 @@ class tx_indexedsearch extends tslib_pibase {
                                        // Possibly shorten string:
                                if (!$k)        {       // First entry at all (only cropped on the frontside)
                                        if ($strLen > $postPreLgd)      {
-                                               $output[$k] = $divider.ereg_replace('^[^[:space:]]+[[:space:]]','',$GLOBALS['TSFE']->csConvObj->crop('utf-8',$parts[$k],-($postPreLgd-$postPreLgd_offset)));
+                                               $output[$k] = $divider.preg_replace('/^[^[:space:]]+[[:space:]]/','',$GLOBALS['TSFE']->csConvObj->crop('utf-8',$parts[$k],-($postPreLgd-$postPreLgd_offset)));
                                        }
                                } elseif ($summaryLgd > $summaryMax || !isset($parts[$k+1])) {  // In case summary length is exceed OR if there are no more entries at all:
                                        if ($strLen > $postPreLgd)      {
-                                               $output[$k] = ereg_replace('[[:space:]][^[:space:]]+$','',$GLOBALS['TSFE']->csConvObj->crop('utf-8',$parts[$k],$postPreLgd-$postPreLgd_offset)).$divider;
+                                               $output[$k] = preg_replace('/[[:space:]][^[:space:]]+$/','',$GLOBALS['TSFE']->csConvObj->crop('utf-8',$parts[$k],$postPreLgd-$postPreLgd_offset)).$divider;
                                        }
                                } else {        // In-between search words:
                                        if ($strLen > $postPreLgd*2)    {
-                                               $output[$k] = ereg_replace('[[:space:]][^[:space:]]+$','',$GLOBALS['TSFE']->csConvObj->crop('utf-8',$parts[$k],$postPreLgd-$postPreLgd_offset)).
+                                               $output[$k] = preg_replace('/[[:space:]][^[:space:]]+$/','',$GLOBALS['TSFE']->csConvObj->crop('utf-8',$parts[$k],$postPreLgd-$postPreLgd_offset)).
                                                                                $divider.
-                                                                               ereg_replace('^[^[:space:]]+[[:space:]]','',$GLOBALS['TSFE']->csConvObj->crop('utf-8',$parts[$k],-($postPreLgd-$postPreLgd_offset)));
+                                                                               preg_replace('/^[^[:space:]]+[[:space:]]/','',$GLOBALS['TSFE']->csConvObj->crop('utf-8',$parts[$k],-($postPreLgd-$postPreLgd_offset)));
                                        }
                                }
                                $summaryLgd+= $GLOBALS['TSFE']->csConvObj->strlen('utf-8', $output[$k]);;
@@ -2263,7 +2265,7 @@ class tx_indexedsearch extends tslib_pibase {
        function getFirstSysDomainRecordForPage($id)    {
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('domainName', 'sys_domain', 'pid='.intval($id).$this->cObj->enableFields('sys_domain'), '', 'sorting');
                $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
-               return ereg_replace('\/$','',$row['domainName']);
+               return rtrim($row['domainName'], '/');
        }
 
        /**
@@ -2332,6 +2334,7 @@ class tx_indexedsearch extends tslib_pibase {
                        while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
                                $output[$row['uid']] = $GLOBALS['TSFE']->sys_page->getPageOverlay($row);
                        }
+                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
                        return $output;
                } else {
                        return $GLOBALS['TSFE']->sys_page->getMenu($id);
@@ -2382,4 +2385,5 @@ class tx_indexedsearch extends tslib_pibase {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/indexed_search/pi/class.tx_indexedsearch.php'])       {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/indexed_search/pi/class.tx_indexedsearch.php']);
 }
+
 ?>