Go to the documentation of this file.00001 <?php
00002
00007 class Search extends oxUBase
00008 {
00013 protected $_iAllArtCnt = 0;
00014
00019 protected $_iCntPages = null;
00020
00025 protected $_sThisTemplate = 'page/search/search.tpl';
00026
00031 protected $_sListType = 'search';
00032
00037 protected $_blShowSorting = true;
00038
00043 protected $_blEmptySearch = null;
00044
00049 protected $_oRecommList = null;
00050
00055 protected $_sSearchParamForHtml = null;
00056
00061 protected $_sSearchParam = null;
00062
00067 protected $_sSearchCatId = null;
00068
00073 protected $_sSearchVendor = null;
00074
00079 protected $_sSearchManufacturer = null;
00080
00085 protected $_blSearchClass = null;
00086
00091 protected $_oPageNavigation = null;
00092
00098 protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
00099
00105 protected $_aSimilarRecommListIds = null;
00106
00107
00116 public function init()
00117 {
00118 parent::init();
00119
00120 $myConfig = $this->getConfig();
00121
00122
00123 $sSearchParamForQuery = oxConfig::getParameter( 'searchparam', true );
00124
00125
00126 $sInitialSearchCat = $this->_sSearchCatId = rawurldecode( oxConfig::getParameter( 'searchcnid' ) );
00127
00128
00129 $sInitialSearchVendor = rawurldecode( oxConfig::getParameter( 'searchvendor' ) );
00130
00131
00132 $sInitialSearchManufacturer = $this->_sSearchManufacturer = rawurldecode( oxConfig::getParameter( 'searchmanufacturer' ) );
00133
00134 $this->_blEmptySearch = false;
00135 if ( !$sSearchParamForQuery && !$sInitialSearchCat && !$sInitialSearchVendor && !$sInitialSearchManufacturer ) {
00136
00137 $this->_aArticleList = null;
00138 $this->_blEmptySearch = true;
00139 return false;
00140 }
00141
00142
00143 if ( !$myConfig->getConfigParam( 'bl_perfLoadManufacturerTree' ) ) {
00144 $sInitialSearchManufacturer = null;
00145 }
00146
00147
00148 $oSearchHandler = oxNew( 'oxsearch' );
00149 $oSearchList = $oSearchHandler->getSearchArticles( $sSearchParamForQuery, $sInitialSearchCat, $sInitialSearchVendor, $sInitialSearchManufacturer, $this->getSortingSql( 'oxsearch' ) );
00150
00151
00152 $this->_aArticleList = $oSearchList;
00153 $this->_iAllArtCnt = 0;
00154
00155
00156 if ( $oSearchList->count() ) {
00157 $this->_iAllArtCnt = $oSearchHandler->getSearchArticleCount( $sSearchParamForQuery, $sInitialSearchCat, $sInitialSearchVendor, $sInitialSearchManufacturer );
00158 }
00159
00160 $iNrofCatArticles = (int) $myConfig->getConfigParam( 'iNrofCatArticles' );
00161 $iNrofCatArticles = $iNrofCatArticles?$iNrofCatArticles:1;
00162 $this->_iCntPages = round( $this->_iAllArtCnt / $iNrofCatArticles + 0.49 );
00163 }
00164
00171 public function render()
00172 {
00173 parent::render();
00174
00175 $myConfig = $this->getConfig();
00176 if ( $myConfig->getConfigParam( 'bl_rssSearch' ) ) {
00177 $oRss = oxNew('oxrssfeed');
00178 $sSearch = oxConfig::getParameter( 'searchparam', true );
00179 $sCnid = oxConfig::getParameter( 'searchcnid', true );
00180 $sVendor = oxConfig::getParameter( 'searchvendor', true );
00181 $sManufacturer = oxConfig::getParameter( 'searchmanufacturer', true );
00182 $this->addRssFeed($oRss->getSearchArticlesTitle($sSearch, $sCnid, $sVendor, $sManufacturer), $oRss->getSearchArticlesUrl($sSearch, $sCnid, $sVendor, $sManufacturer), 'searchArticles');
00183 }
00184
00185
00186 $this->_processListArticles();
00187
00188 return $this->_sThisTemplate;
00189 }
00190
00197 protected function _processListArticles()
00198 {
00199 $sAddDynParams = $this->getAddUrlParams();
00200 if ( $sAddDynParams && ( $aArtList = $this->getArticleList() ) ) {
00201 $blSeo = oxRegistry::getUtils()->seoIsActive();
00202 foreach ( $aArtList as $oArticle ) {
00203
00204 if ( !$blSeo ) {
00205
00206 $oArticle->appendStdLink( $sAddDynParams );
00207 }
00208 $oArticle->appendLink( $sAddDynParams );
00209 }
00210 }
00211 }
00212
00218 public function getAddUrlParams()
00219 {
00220 $sAddParams = parent::getAddUrlParams();
00221 $sAddParams .= ($sAddParams?'&':'') . "listtype={$this->_sListType}";
00222
00223 if ( $sParam = oxConfig::getParameter( 'searchparam', true ) ) {
00224 $sAddParams .= "&searchparam=".rawurlencode($sParam);
00225 }
00226
00227 if ( $sParam = oxConfig::getParameter( 'searchcnid' ) ) {
00228 $sAddParams .= "&searchcnid=$sParam";
00229 }
00230
00231 if ( $sParam = rawurldecode( oxConfig::getParameter( 'searchvendor' ) ) ) {
00232 $sAddParams .= "&searchvendor=$sParam";
00233 }
00234
00235 if ( $sParam = rawurldecode( oxConfig::getParameter( 'searchmanufacturer' ) ) ) {
00236 $sAddParams .= "&searchmanufacturer=$sParam";
00237 }
00238 return $sAddParams;
00239 }
00240
00250 public function setItemSorting( $sCnid, $sSortBy, $sSortOrder = null )
00251 {
00252 parent::setItemSorting( "oxsearch", $sSortBy, $sSortOrder );
00253 }
00254
00262 public function getSorting( $sCnid )
00263 {
00264 return parent::getSorting( "oxsearch" );
00265 }
00266
00272 protected function _isSearchClass()
00273 {
00274 if ( $this->_blSearchClass === null ) {
00275 $this->_blSearchClass = false;
00276 if ( strtolower(oxConfig::getParameter( 'cl' )) == 'search' ) {
00277 $this->_blSearchClass = true;
00278 }
00279 }
00280 return $this->_blSearchClass;
00281 }
00287 public function isEmptySearch()
00288 {
00289 return $this->_blEmptySearch;
00290 }
00291
00297 public function getArticleList()
00298 {
00299 return $this->_aArticleList;
00300 }
00301
00307 public function getSimilarRecommListIds()
00308 {
00309 if ( $this->_aSimilarRecommListIds === null ) {
00310 $this->_aSimilarRecommListIds = false;
00311
00312 $aList = $this->getArticleList();
00313 if ( $aList && $aList->count() > 0 ) {
00314 $this->_aSimilarRecommListIds = $aList->arrayKeys();
00315 }
00316 }
00317
00318 return $this->_aSimilarRecommListIds;
00319 }
00320
00326 public function getSearchParamForHtml()
00327 {
00328 if ( $this->_sSearchParamForHtml === null ) {
00329 $this->_sSearchParamForHtml = false;
00330 if ( $this->_isSearchClass() ) {
00331 $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' );
00332 }
00333 }
00334 return $this->_sSearchParamForHtml;
00335 }
00336
00342 public function getSearchParam()
00343 {
00344 if ( $this->_sSearchParam === null ) {
00345 $this->_sSearchParam = false;
00346 if ( $this->_isSearchClass() ) {
00347 $this->_sSearchParam = rawurlencode( oxConfig::getParameter( 'searchparam', true ) );
00348 }
00349 }
00350 return $this->_sSearchParam;
00351 }
00352
00358 public function getSearchCatId()
00359 {
00360 if ( $this->_sSearchCatId === null ) {
00361 $this->_sSearchCatId = false;
00362 if ( $this->_isSearchClass() ) {
00363 $this->_sSearchCatId = rawurldecode( oxConfig::getParameter( 'searchcnid' ) );
00364 }
00365 }
00366 return $this->_sSearchCatId;
00367 }
00368
00374 public function getSearchVendor()
00375 {
00376 if ( $this->_sSearchVendor === null ) {
00377 $this->_sSearchVendor = false;
00378 if ( $this->_isSearchClass() ) {
00379
00380 $this->_sSearchVendor = rawurldecode( oxConfig::getParameter( 'searchvendor' ) );
00381 }
00382 }
00383 return $this->_sSearchVendor;
00384 }
00385
00391 public function getSearchManufacturer()
00392 {
00393 if ( $this->_sSearchManufacturer === null ) {
00394 $this->_sSearchManufacturer = false;
00395 if ( $this->_isSearchClass() ) {
00396
00397 $this->_sSearchManufacturer = rawurldecode( oxConfig::getParameter( 'searchmanufacturer' ) );
00398 }
00399 }
00400 return $this->_sSearchManufacturer;
00401 }
00402
00408 public function getPageNavigation()
00409 {
00410 if ( $this->_oPageNavigation === null ) {
00411 $this->_oPageNavigation = false;
00412 $this->_oPageNavigation = $this->generatePageNavigation();
00413 }
00414 return $this->_oPageNavigation;
00415 }
00416
00417
00423 public function getActiveCategory()
00424 {
00425 return $this->getActSearch();
00426 }
00427
00433 public function getBreadCrumb()
00434 {
00435 $aPaths = array();
00436 $aPath = array();
00437
00438 $aPath['title'] = oxRegistry::getLang()->translateString( 'SEARCH_TITLE', oxRegistry::getLang()->getBaseLanguage(), false );
00439 $aPath['link'] = $this->getLink();
00440 $aPaths[] = $aPath;
00441
00442 return $aPaths;
00443 }
00444
00450 public function canSelectDisplayType()
00451 {
00452 return $this->getConfig()->getConfigParam( 'blShowListDisplayType' );
00453 }
00454
00460 protected function _canRedirect()
00461 {
00462 return false;
00463 }
00464
00470 public function getArticleCount()
00471 {
00472 return $this->_iAllArtCnt;
00473 }
00474
00475 }