oxubase.php

Go to the documentation of this file.
00001 <?php
00002 
00007 // view indexing state for search engines:
00008 define( 'VIEW_INDEXSTATE_INDEX', 0 );           //  index without limitations
00009 define( 'VIEW_INDEXSTATE_NOINDEXNOFOLLOW', 1 ); //  no index / no follow
00010 define( 'VIEW_INDEXSTATE_NOINDEXFOLLOW', 2 );   //  no index / follow
00011 
00017 class oxUBase extends oxView
00018 {
00023     protected $_blFbWidgetsOn = null;
00024 
00029     protected $_sRemoveMetaChars = '.\+*?[^]$(){}=!<>|:&';
00030 
00036     protected $_oaComponents = array();
00037 
00043     protected $_blIsOrderStep = false;
00044 
00050     protected $_sListType = null;
00051 
00057     protected $_aListDisplayTypes = array( 'grid', 'line', 'infogrid' );
00058 
00064     protected $_sListDisplayType = null;
00065 
00071     protected $_sCustomListDisplayType = null;
00072 
00078     protected $_oActCategory = null;
00079 
00085     protected $_oActManufacturer = null;
00086 
00092     protected $_oActVendor = null;
00093 
00098     protected $_oActiveRecommList = null;
00099 
00105     protected $_oActSearch = null;
00106 
00111     protected $_blShowSorting = false;
00112 
00117     protected $_blLoadCurrency = null;
00118 
00123     protected $_blLoadManufacturerTree = null;
00124 
00129     protected $_blDontShowEmptyCats = null;
00130 
00135     protected $_blLoadLanguage = null;
00136 
00141     protected $_iTopCatNavItmCnt = null;
00142 
00147     protected $_aRssLinks = null;
00148 
00153     protected $_sListOrderBy = null;
00154 
00159     protected $_sListOrderDir = null;
00160 
00165     protected $_sMetaDescription = null;
00166 
00171     protected $_sMetaKeywords = null;
00172 
00178     protected $_sMetaDescriptionIdent = null;
00179 
00185     protected $_sMetaKeywordsIdent = null;
00186 
00191     protected $_sAdditionalParams = null;
00192 
00197     protected $_oActCurrency = null;
00198 
00203     protected $_blEnabledPrivateSales = null;
00204 
00211     protected $_blCommonAdded = false;
00212 
00219     protected $_iViewIndexState = VIEW_INDEXSTATE_INDEX;
00220 
00227     protected $_blForceNoIndex = false;
00228 
00233     protected $_iCompItemsCnt = null;
00234 
00240     protected $_sContentId = null;
00241 
00247     protected $_oContent = null;
00248 
00254     protected $_sViewResetID = null;
00255 
00262     protected $_blActiveSorting = null;
00263 
00268     protected $_aMenueList = null;
00269 
00275     protected $_aComponentNames = array(
00276                                     'oxcmp_user'       => 1, // 0 means dont init if cached
00277                                     'oxcmp_lang'       => 0,
00278                                     'oxcmp_cur'        => 1,
00279                                     'oxcmp_shop'       => 1,
00280                                     'oxcmp_categories' => 0,
00281                                     'oxcmp_utils'      => 1,
00282                                     'oxcmp_news'       => 0,
00283                                     'oxcmp_basket'     => 1
00284                                   );
00285 
00291     protected $_aUserComponentNames = array();
00292 
00298     protected $_oProduct = null;
00299 
00304     protected $_iActPage = null;
00305 
00310     protected $_aArticleList = null;
00311 
00316     protected $_oManufacturerTree  = null;
00317 
00322     protected $_oCategoryTree  = null;
00323 
00328     protected $_aTop5ArticleList  = null;
00329 
00334     protected $_aBargainArticleList  = null;
00335 
00340     protected $_blLowOrderPrice = null;
00341 
00346     protected $_sMinOrderPrice  = null;
00347 
00352     protected $_iNewsRealStatus  = null;
00353 
00359     protected $_aBlockRedirectParams = array( 'fnc', 'stoken', 'force_sid', 'force_admin_sid' );
00360 
00365     protected $_oRootVendor = null;
00366 
00371     protected $_sVendorId = null;
00372 
00377     protected $_aManufacturerlist = null;
00378 
00383     protected $_oRootManufacturer = null;
00384 
00389     protected $_sManufacturerId = null;
00390 
00395     protected $_aSearchCatTree = null;
00396 
00401     protected $_blNewsSubscribed = null;
00402 
00407     protected $_oDelAddress = null;
00408 
00413     protected $_sCatTreePath = null;
00414 
00419     protected $_aContents = array();
00420 
00425     protected $_blTop5Action = false;
00426 
00431     protected $_blBargainAction = false;
00432 
00438     protected $_aMustFillFields = null;
00439 
00444     protected $_blShowTagCloud = true;
00445 
00450     protected $_blRootCatChanged = false;
00451 
00456     protected $_aInvoiceAddress = null;
00457 
00462     protected $_aDeliveryAddress = null;
00463 
00468     protected $_sActiveUsername = null;
00469 
00475     protected static $_aCollectedComponentNames = null;
00476 
00483     protected $_blLoadComponents = true;
00484 
00485 
00491     protected $_aSortColumns = null;
00492 
00498     protected function _getComponentNames()
00499     {
00500         if ( self::$_aCollectedComponentNames === null ) {
00501             self::$_aCollectedComponentNames = array_merge( $this->_aComponentNames, $this->_aUserComponentNames );
00502 
00503             // #1721: custom component handling. At the moment it is not possible to override this variable in oxubase,
00504             // so we added this array to config.inc.php file
00505             if ( ( $aUserCmps = $this->getConfig()->getConfigParam( 'aUserComponentNames' ) ) ) {
00506                 self::$_aCollectedComponentNames = array_merge( self::$_aCollectedComponentNames, $aUserCmps );
00507             }
00508 
00509             if ( oxConfig::getParameter( '_force_no_basket_cmp' ) ) {
00510                 unset( self::$_aCollectedComponentNames['oxcmp_basket'] );
00511             }
00512         }
00513 
00514         // resetting array pointer
00515         reset( self::$_aCollectedComponentNames );
00516         return self::$_aCollectedComponentNames;
00517     }
00518 
00527     protected function _processRequest()
00528     {
00529         $myUtils = oxRegistry::getUtils();
00530 
00531         // non admin, request is not empty and was not processed by seo engine
00532         if ( !isSearchEngineUrl() && $myUtils->seoIsActive() && ( $sStdUrl = getRequestUrl( '', true ) ) ) {
00533 
00534             // fetching standard url and looking for it in seo table
00535             if ( $this->_canRedirect() && ( $sRedirectUrl = oxRegistry::get("oxSeoEncoder")->fetchSeoUrl( $sStdUrl ) ) ) {
00536                 $myUtils->redirect( $this->getConfig()->getCurrentShopUrl() . $sRedirectUrl, false );
00537             } elseif (VIEW_INDEXSTATE_INDEX == $this->noIndex()) {
00538                 // forcing to set noindex/follow meta
00539                 $this->_forceNoIndex();
00540 
00541                 if (!$this->getConfig()->isProductiveMode() || $this->getConfig()->getConfigParam('blSeoLogging')) {
00542                     $sShopId = $this->getConfig()->getShopId();
00543                     $sLangId = oxRegistry::getLang()->getBaseLanguage();
00544                     $sIdent  = md5( strtolower( $sStdUrl ) . $sShopId . $sLangId );
00545 
00546                     // logging "not found" url
00547                     $oDb = oxDb::getDb();
00548                     $oDb->execute( "replace oxseologs ( oxstdurl, oxident, oxshopid, oxlang )
00549                                     values ( " . $oDb->quote( $sStdUrl ) . ", '{$sIdent}', '{$sShopId}', '{$sLangId}' ) " );
00550                 }
00551             }
00552         }
00553     }
00554 
00561     public function init()
00562     {
00563         $this->_processRequest();
00564 
00565         // storing current view
00566         $blInit = true;
00567 
00568 
00569         // init all components if there are any
00570         if ( $this->_blLoadComponents ) {
00571             foreach ( $this->_getComponentNames() as $sComponentName => $blNotCacheable ) {
00572                 // do not override initiated components
00573                 if ( !isset( $this->_oaComponents[$sComponentName] ) ) {
00574                     // component objects MUST be created to support user called functions
00575                     $oComponent = oxNew( $sComponentName );
00576                     $oComponent->setParent( $this );
00577                     $oComponent->setThisAction( $sComponentName );
00578                     $this->_oaComponents[$sComponentName] = $oComponent;
00579                 }
00580 
00581                 // do we really need to initiate them ?
00582                 if ( $blInit ) {
00583                     $this->_oaComponents[$sComponentName]->init();
00584 
00585                     // executing only is view does not have action method
00586                     if ( !method_exists( $this, $this->getFncName() ) ) {
00587                         $this->_oaComponents[$sComponentName]->executeFunction( $this->getFncName() );
00588                     }
00589                 }
00590             }
00591         }
00592 
00593         parent::init();
00594     }
00595 
00602     public function getViewId()
00603     {
00604         if ( $this->_sViewId ) {
00605             return $this->_sViewId;
00606         }
00607 
00608         $myConfig = $this->getConfig();
00609         $iLang = oxRegistry::getLang()->getBaseLanguage();
00610         $iCur  = (int) $myConfig->getShopCurrency();
00611 
00612 
00613             $this->_sViewId =  "ox|$iLang|$iCur";
00614 
00615         $this->_sViewId .= "|".( (int) $this->_blForceNoIndex ).'|'.((int)$this->isRootCatChanged());
00616 
00617         // #0004798: SSL should be included in viewId
00618         if ($myConfig->isSsl()) {
00619             $this->_sViewId .= "|ssl";
00620         }
00621 
00622         // #0002866: external global viewID addition
00623         if (function_exists('customGetViewId')) {
00624             $oExtViewId = customGetViewId();
00625 
00626             if ($oExtViewId !== null) {
00627                 $this->_sViewId .= '|'.md5(serialize($oExtViewId));
00628             }
00629         }
00630         return $this->_sViewId;
00631     }
00632 
00633 
00639     public function showSorting()
00640     {
00641         return $this->_blShowSorting && $this->getConfig()->getConfigParam( 'blShowSorting' );
00642     }
00643 
00651     public function setComponents( $aComponents = null )
00652     {
00653         $this->_oaComponents = $aComponents;
00654     }
00655 
00661     public function getComponents()
00662     {
00663         return $this->_oaComponents;
00664     }
00665 
00673     public function getComponent( $sName )
00674     {
00675         if ( $sName != null ) {
00676             return $this->_oaComponents[$sName];
00677         }
00678     }
00686     public function setIsOrderStep( $blIsOrderStep = null )
00687     {
00688         $this->_blIsOrderStep = $blIsOrderStep;
00689     }
00690 
00696     public function getIsOrderStep()
00697     {
00698         return $this->_blIsOrderStep;
00699     }
00700 
00701 
00709     public function setActiveCategory( $oCategory )
00710     {
00711         $this->_oActCategory = $oCategory;
00712     }
00713 
00719     public function getActiveCategory()
00720     {
00721         return $this->_oActCategory;
00722     }
00723 
00729     public function getListType()
00730     {
00731         if ( $this->_sListType == null ) {
00732             if ( $sListType = oxConfig::getParameter( 'listtype' ) ) {
00733                 $this->_sListType = $sListType;
00734             } elseif ( $sListType = $this->getConfig()->getGlobalParameter( 'listtype' ) ) {
00735                 $this->_sListType = $sListType;
00736             }
00737         }
00738         return $this->_sListType;
00739     }
00740 
00746     public function getListDisplayType()
00747     {
00748         if ( $this->_sListDisplayType == null ) {
00749             $this->_sListDisplayType = $this->getCustomListDisplayType();
00750 
00751             if ( !$this->_sListDisplayType ) {
00752                 $this->_sListDisplayType = $this->getConfig()->getConfigParam( 'sDefaultListDisplayType' );
00753             }
00754 
00755             $this->_sListDisplayType = in_array( ( string ) $this->_sListDisplayType, $this->_aListDisplayTypes ) ? $this->_sListDisplayType : 'infogrid';
00756 
00757             // writing to session
00758             if ( oxConfig::getParameter( 'ldtype' ) ) {
00759                 oxSession::setVar( 'ldtype', $this->_sListDisplayType );
00760             }
00761         }
00762         return $this->_sListDisplayType;
00763     }
00764 
00770     public function getCustomListDisplayType()
00771     {
00772         if ( $this->_sCustomListDisplayType == null ) {
00773             $this->_sCustomListDisplayType = oxConfig::getParameter( 'ldtype' );
00774 
00775             if ( !$this->_sCustomListDisplayType ) {
00776                 $this->_sCustomListDisplayType = oxSession::getVar( 'ldtype' );
00777             }
00778         }
00779         return $this->_sCustomListDisplayType;
00780     }
00781 
00789     public function setListType( $sType )
00790     {
00791         $this->_sListType = $sType;
00792         $this->getConfig()->setGlobalParameter( 'listtype', $sType );
00793     }
00794 
00800     public function loadCurrency()
00801     {
00802         if ( $this->_blLoadCurrency == null ) {
00803             $this->_blLoadCurrency = false;
00804             if ( $blLoadCurrency = $this->getConfig()->getConfigParam( 'bl_perfLoadCurrency' ) ) {
00805                 $this->_blLoadCurrency = $blLoadCurrency;
00806             }
00807         }
00808         return $this->_blLoadCurrency;
00809     }
00810 
00816     public function dontShowEmptyCategories()
00817     {
00818         if ( $this->_blDontShowEmptyCats == null ) {
00819             $this->_blDontShowEmptyCats = false;
00820             if ( $blDontShowEmptyCats = $this->getConfig()->getConfigParam( 'blDontShowEmptyCategories' ) ) {
00821                 $this->_blDontShowEmptyCats = $blDontShowEmptyCats;
00822             }
00823         }
00824         return $this->_blDontShowEmptyCats;
00825     }
00826 
00832     public function showCategoryArticlesCount()
00833     {
00834         return $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' );
00835     }
00836 
00842     public function isLanguageLoaded()
00843     {
00844         if ( $this->_blLoadLanguage == null ) {
00845             $this->_blLoadLanguage = false;
00846             if ( $blLoadLanguage = $this->getConfig()->getConfigParam( 'bl_perfLoadLanguages' ) ) {
00847                 $this->_blLoadLanguage = $blLoadLanguage;
00848             }
00849         }
00850         return $this->_blLoadLanguage;
00851     }
00852 
00858     public function getTopNavigationCatCnt()
00859     {
00860         if ( $this->_iTopCatNavItmCnt == null ) {
00861             $iTopCatNavItmCnt = $this->getConfig()->getConfigParam( 'iTopNaviCatCount' );
00862             $this->_iTopCatNavItmCnt = $iTopCatNavItmCnt ? $iTopCatNavItmCnt : 5;
00863         }
00864         return $this->_iTopCatNavItmCnt;
00865     }
00866 
00876     public function addRssFeed($sTitle, $sUrl, $key = null)
00877     {
00878         if (!is_array($this->_aRssLinks)) {
00879             $this->_aRssLinks = array();
00880         }
00881 
00882         $sUrl = oxRegistry::get("oxUtilsUrl")->prepareUrlForNoSession($sUrl);
00883 
00884         if ($key === null) {
00885             $this->_aRssLinks[] = array('title'=>$sTitle, 'link' => $sUrl);
00886         } else {
00887             $this->_aRssLinks[$key] = array('title'=>$sTitle, 'link' => $sUrl);
00888         }
00889     }
00890 
00896     public function getSortOrderByParameterName()
00897     {
00898         return 'listorderby';
00899     }
00900 
00906     public function getSortOrderParameterName()
00907     {
00908         return 'listorder';
00909     }
00910 
00911 
00917     public function getSortIdent()
00918     {
00919         return 'alist';
00920     }
00921 
00927     public function getDefaultSorting()
00928     {
00929         return null;
00930     }
00931 
00937     public function getUserSelectedSorting()
00938     {
00939         $aSorting = null;
00940         $oStr = getStr();
00941         $oConfig = oxRegistry::getConfig();
00942         $aSortDirections = array( 'desc', 'asc' );
00943         $aSortColumns = $this->getSortColumns();
00944 
00945         $sSortBy  = $oConfig->getParameter( $this->getSortOrderByParameterName() );
00946         $sSortDir = $oConfig->getParameter( $this->getSortOrderParameterName() );
00947 
00948         if ( $sSortBy && oxDb::getInstance()->isValidFieldName( $sSortBy ) && /*in_array( $oStr->strtolower($sSortBy), $aSortColumns ) &&*/
00949             $sSortDir && oxRegistry::getUtils()->isValidAlpha( $sSortDir ) && in_array( $oStr->strtolower($sSortDir), $aSortDirections ) ) {
00950             $aSorting = array ( 'sortby' => $sSortBy, 'sortdir' => $sSortDir );
00951         }
00952 
00953         return $aSorting;
00954     }
00955 
00956 
00964     public function getSavedSorting( $sSortIdent )
00965     {
00966         $aSorting = oxSession::getVar( 'aSorting' );
00967         if ( isset( $aSorting[$sSortIdent] ) ) {
00968             return $aSorting[$sSortIdent];
00969         }
00970     }
00971 
00979     public function setListOrderBy( $sColumn )
00980     {
00981         $this->_sListOrderBy = $sColumn;
00982     }
00983 
00991     public function setListOrderDirection( $sDirection )
00992     {
00993         $this->_sListOrderDir = $sDirection;
00994     }
00995 
00996 
00997 
01010     public function prepareSortColumns()
01011     {
01012         $aSortColumns = $this->getConfig()->getConfigParam( 'aSortCols' );
01013         $aSortDir = array( 'desc', 'asc' );
01014         if ( count( $aSortColumns ) > 0 ) {
01015 
01016             $this->_aSortColumns = $aSortColumns;
01017 
01018             $sCnid = oxConfig::getParameter( 'cnid' );
01019 
01020 
01021             $sSortBy  = oxConfig::getParameter( $this->getSortOrderByParameterName() );
01022             $sSortDir = oxConfig::getParameter( $this->getSortOrderParameterName() );
01023 
01024             $oStr = getStr();
01025             if ( (!$sSortBy || !in_array( $oStr->strtolower($sSortBy), $aSortColumns) || !in_array( $oStr->strtolower($sSortDir), $aSortDir) ) && $aSorting = $this->getSorting( $sCnid ) ) {
01026                 $sSortBy  = $aSorting['sortby'];
01027                 $sSortDir = $aSorting['sortdir'];
01028             }
01029 
01030             if ( $sSortBy && oxDb::getInstance()->isValidFieldName( $sSortBy ) &&
01031                  $sSortDir && oxRegistry::getUtils()->isValidAlpha( $sSortDir ) ) {
01032 
01033                 $this->_sListOrderBy  = $sSortBy;
01034                 $this->_sListOrderDir = $sSortDir;
01035 
01036                 // caching sorting config
01037                 $this->setItemSorting( $sCnid, $sSortBy, $sSortDir );
01038             }
01039         }
01040     }
01041 
01047     public function getListOrderBy()
01048     {
01049         //if column is with table name split it
01050         $aColumns = explode('.', $this->_sListOrderBy);
01051 
01052         if ( is_array($aColumns) && count($aColumns) > 1 ) {
01053            return $aColumns[1];
01054         }
01055 
01056         return $this->_sListOrderBy;
01057     }
01058 
01064     public function getListOrderDirection()
01065     {
01066         return $this->_sListOrderDir;
01067     }
01068 
01076     public function setMetaDescription ( $sDescription )
01077     {
01078         return $this->_sMetaDescription = $sDescription;
01079     }
01080 
01088     public function setMetaKeywords( $sKeywords )
01089     {
01090         return $this->_sMetaKeywords = $sKeywords;
01091     }
01092 
01100     protected function _getMetaFromSeo( $sDataType )
01101     {
01102         $sOxid  = $this->_getSeoObjectId();
01103         $iLang  = oxRegistry::getLang()->getBaseLanguage();
01104         $sShop  = $this->getConfig()->getShopId();
01105 
01106         if ( $sOxid && oxRegistry::getUtils()->seoIsActive() &&
01107              ( $sKeywords = oxRegistry::get("oxSeoEncoder")->getMetaData( $sOxid, $sDataType, $sShop, $iLang) ) ) {
01108             return $sKeywords;
01109         }
01110     }
01111 
01119     protected function _getMetaFromContent( $sMetaIdent )
01120     {
01121         if ( $sMetaIdent ) {
01122             $oContent = oxNew( 'oxcontent' );
01123             if ( $oContent->loadByIdent( $sMetaIdent ) &&
01124                  $oContent->oxcontents__oxactive->value ) {
01125                 return getStr()->strip_tags( $oContent->oxcontents__oxcontent->value );
01126             }
01127         }
01128     }
01129 
01135     public function getMetaKeywords()
01136     {
01137         if ( $this->_sMetaKeywords === null ) {
01138             $this->_sMetaKeywords = false;
01139 
01140             // set special meta keywords ?
01141             if ( ( $sKeywords = $this->_getMetaFromSeo( 'oxkeywords' ) ) ) {
01142                 $this->_sMetaKeywords = $sKeywords;
01143             } elseif ( ( $sKeywords = $this->_getMetaFromContent( $this->_sMetaKeywordsIdent ) ) ) {
01144                 $this->_sMetaKeywords = $this->_prepareMetaKeyword( $sKeywords, false );
01145             } else {
01146                 $this->_sMetaKeywords = $this->_prepareMetaKeyword( false, true );
01147             }
01148         }
01149 
01150         return $this->_sMetaKeywords;
01151     }
01152 
01158     public function getMetaDescription()
01159     {
01160         if ( $this->_sMetaDescription === null ) {
01161             $this->_sMetaDescription = false;
01162 
01163             // set special meta description ?
01164             if ( ( $sDescription = $this->_getMetaFromSeo( 'oxdescription' ) ) ) {
01165                 $this->_sMetaDescription = $sDescription;
01166             } elseif ( ( $sDescription = $this->_getMetaFromContent( $this->_sMetaDescriptionIdent ) ) ) {
01167                 $this->_sMetaDescription = $this->_prepareMetaDescription( $sDescription );
01168             } else {
01169                 $this->_sMetaDescription = $this->_prepareMetaDescription( false );
01170             }
01171         }
01172 
01173         return $this->_sMetaDescription;
01174     }
01175 
01181     public function getActCurrency()
01182     {
01183         return $this->_oActCurrency;
01184     }
01185 
01193     public function setActCurrency( $oCur )
01194     {
01195         $this->_oActCurrency = $oCur;
01196     }
01197 
01203     public function getCompareItemCount()
01204     {
01205         if ( $this->_iCompItemsCnt === null ) {
01206             $aItems = oxSession::getVar('aFiltcompproducts');
01207             $this->_iCompItemsCnt = is_array($aItems)?count($aItems):0;
01208         }
01209         return $this->_iCompItemsCnt;
01210     }
01211 
01217     protected function _forceNoIndex()
01218     {
01219         $this->_blForceNoIndex = true;
01220     }
01221 
01228     public function noIndex()
01229     {
01230         if ( $this->_blForceNoIndex ) {
01231             $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
01232         } elseif ( oxConfig::getParameter( 'cur' ) ) {
01233             $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
01234         } else {
01235             switch ( oxConfig::getParameter( 'fnc' ) ) {
01236                 case 'tocomparelist':
01237                 case 'tobasket':
01238                     $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
01239                     break;
01240             }
01241         }
01242         return $this->_iViewIndexState;
01243     }
01244 
01252     public function isSortingActive()
01253     {
01254         return $this->_blActiveSorting;
01255     }
01256 
01262     public function getMenueList()
01263     {
01264         return $this->_aMenueList;
01265     }
01266 
01274     public function setMenueList( $aMenue )
01275     {
01276         $this->_aMenueList = $aMenue;
01277     }
01278 
01279 
01285     protected function _setNrOfArtPerPage()
01286     {
01287         $myConfig  = $this->getConfig();
01288 
01289         //setting default values to avoid possible errors showing article list
01290         $iNrofCatArticles = $myConfig->getConfigParam( 'iNrofCatArticles' );
01291 
01292         $iNrofCatArticles = ( $iNrofCatArticles ) ? $iNrofCatArticles : 10;
01293 
01294         // checking if all needed data is set
01295         switch ( $this->getListDisplayType() ) {
01296             case 'grid':
01297                 $aNrofCatArticles = $myConfig->getConfigParam( 'aNrofCatArticlesInGrid' );
01298                 break;
01299             case 'line':
01300             case 'infogrid':
01301             default:
01302                 $aNrofCatArticles = $myConfig->getConfigParam( 'aNrofCatArticles' );
01303         }
01304 
01305         if ( !is_array( $aNrofCatArticles ) || !isset( $aNrofCatArticles[0] ) ) {
01306             $myConfig->setConfigParam( 'aNrofCatArticles', array( $iNrofCatArticles ) );
01307         } else {
01308             $iNrofCatArticles = $aNrofCatArticles[0];
01309         }
01310 
01311         $oViewConf = $this->getViewConfig();
01312         //value from user input
01313         if ( ( $iNrofArticles = (int) oxConfig::getParameter( '_artperpage' ) ) ) {
01314             // M45 Possibility to push any "Show articles per page" number parameter
01315             $iNrofCatArticles = ( in_array( $iNrofArticles, $aNrofCatArticles ) ) ? $iNrofArticles : $iNrofCatArticles;
01316             $oViewConf->setViewConfigParam( 'iartPerPage', $iNrofCatArticles );
01317             oxSession::setVar( '_artperpage', $iNrofCatArticles );
01318         } elseif ( ( $iSessArtPerPage = oxSession::getVar( '_artperpage' ) )&& is_numeric( $iSessArtPerPage ) ) {
01319             // M45 Possibility to push any "Show articles per page" number parameter
01320             $iNrofCatArticles = ( in_array( $iSessArtPerPage, $aNrofCatArticles ) ) ? $iSessArtPerPage : $iNrofCatArticles;
01321             $oViewConf->setViewConfigParam( 'iartPerPage', $iSessArtPerPage );
01322             $iNrofCatArticles = $iSessArtPerPage;
01323         } else {
01324             $oViewConf->setViewConfigParam( 'iartPerPage', $iNrofCatArticles );
01325         }
01326 
01327         //setting number of articles per page to config value
01328         $myConfig->setConfigParam( 'iNrofCatArticles', $iNrofCatArticles );
01329     }
01330 
01336     protected function _getSeoObjectId()
01337     {
01338     }
01339 
01349     protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blRemoveDuplicatedWords = false )
01350     {
01351         if ( $sMeta ) {
01352 
01353             $oStr = getStr();
01354             if ( $iLength != -1 ) {
01355                 /* *
01356                  * performance - we do not need a huge amount of initial text.
01357                  * assume that effective text may be double longer than $iLength
01358                  * and simple truncate it
01359                  */
01360                 $iELength = ( $iLength * 2 );
01361                 $sMeta = $oStr->substr( $sMeta, 0, $iELength );
01362             }
01363 
01364             // decoding html entities
01365             $sMeta = $oStr->html_entity_decode( $sMeta );
01366             // stripping HTML tags
01367             $sMeta = $oStr->strip_tags( $sMeta );
01368 
01369             // removing some special chars
01370             $sMeta = $oStr->cleanStr( $sMeta );
01371 
01372             // removing duplicate words
01373             if ( $blRemoveDuplicatedWords ) {
01374                 $sMeta = $this->_removeDuplicatedWords( $sMeta, $this->getConfig()->getConfigParam( 'aSkipTags' ) );
01375             }
01376 
01377             // some special cases
01378             $sMeta = str_replace( ' ,', ',', $sMeta );
01379             $aPattern = array( "/,[\s\+\-\*]*,/", "/\s+,/" );
01380             $sMeta = $oStr->preg_replace( $aPattern, ',', $sMeta );
01381             $sMeta = oxRegistry::get("oxUtilsString")->minimizeTruncateString( $sMeta, $iLength );
01382             $sMeta = $oStr->htmlspecialchars( $sMeta );
01383 
01384             return trim( $sMeta );
01385         }
01386     }
01387 
01396     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
01397     {
01398 
01399         $sString = $this->_prepareMetaDescription( $sKeywords, -1, false );
01400 
01401         if ( $blRemoveDuplicatedWords ) {
01402             $sString = $this->_removeDuplicatedWords( $sString, $this->getConfig()->getConfigParam( 'aSkipTags' ) );
01403         }
01404 
01405        return trim( $sString );
01406     }
01407 
01416     protected function _removeDuplicatedWords( $aInput, $aSkipTags = array() )
01417     {
01418         $oStr = getStr();
01419         if ( is_array( $aInput ) ) {
01420             $aInput = implode( " ", $aInput );
01421         }
01422 
01423         // removing some usually met characters..
01424         $aInput = $oStr->preg_replace( "/[".preg_quote( $this->_sRemoveMetaChars, "/" )."]/", " ", $aInput );
01425 
01426         // splitting by word
01427         $aStrings = $oStr->preg_split( "/[\s,]+/", $aInput );
01428 
01429         if ( $sCount = count( $aSkipTags ) ) {
01430             for ( $iNum = 0; $iNum < $sCount; $iNum++ ) {
01431                 $aSkipTags[$iNum] = $oStr->strtolower( $aSkipTags[$iNum] );
01432             }
01433         }
01434         $sCount = count($aStrings);
01435         for ( $iNum = 0; $iNum < $sCount; $iNum++ ) {
01436             $aStrings[$iNum] = $oStr->strtolower( $aStrings[$iNum] );
01437             // removing in admin defined strings
01438             if ( !$aStrings[$iNum] || in_array( $aStrings[$iNum], $aSkipTags ) ) {
01439                 unset( $aStrings[$iNum] );
01440             }
01441         }
01442 
01443         // duplicates
01444         return implode( ', ', array_unique( $aStrings ) );
01445     }
01446 
01454     public function getNavigationParams()
01455     {
01456         $aParams['cnid'] = $this->getCategoryId();
01457         $aParams['mnid'] = oxConfig::getParameter( 'mnid' );
01458 
01459         $aParams['listtype'] = $this->getListType();
01460         $aParams['ldtype'] = $this->getCustomListDisplayType();
01461         $aParams['actcontrol'] = $this->getClassName();
01462 
01463         $aParams['recommid'] = oxConfig::getParameter( 'recommid' );
01464 
01465         $aParams['searchrecomm'] = oxConfig::getParameter( 'searchrecomm', true );
01466         $aParams['searchparam']  = oxConfig::getParameter( 'searchparam', true );
01467         $aParams['searchtag']    = oxConfig::getParameter( 'searchtag', true );
01468 
01469         $aParams['searchvendor'] = oxConfig::getParameter( 'searchvendor' );
01470         $aParams['searchcnid']   = oxConfig::getParameter( 'searchcnid' );
01471         $aParams['searchmanufacturer'] = oxConfig::getParameter( 'searchmanufacturer' );
01472 
01473         return $aParams;
01474     }
01475 
01485     public function setItemSorting( $sSortIdent, $sSortBy, $sSortDir = null )
01486     {
01487         $aSorting = oxSession::getVar( 'aSorting' );
01488         $aSorting[$sSortIdent]['sortby']  = $sSortBy;
01489         $aSorting[$sSortIdent]['sortdir'] = $sSortDir ? $sSortDir : null;
01490 
01491         oxSession::setVar( 'aSorting', $aSorting );
01492     }
01493 
01501     public function getSorting( $sSortIdent )
01502     {
01503         $aSorting = null;
01504 
01505         if ( $aSorting = $this->getUserSelectedSorting() ) {
01506             $this->setItemSorting( $sSortIdent, $aSorting['sortby'], $aSorting['sortdir'] );
01507         } elseif ( !$aSorting = $this->getSavedSorting( $sSortIdent ) ) {
01508             $aSorting = $this->getDefaultSorting();
01509         }
01510 
01511         if ( $aSorting ) {
01512             $this->setListOrderBy( $aSorting['sortby'] );
01513             $this->setListOrderDirection( $aSorting['sortdir'] );
01514         }
01515 
01516         return $aSorting;
01517     }
01518 
01526     public function getSortingSql( $sCnid )
01527     {
01528         $aSorting = $this->getSorting( $sCnid );
01529         if ( is_array( $aSorting ) ) {
01530             return implode( " ", $aSorting );
01531         }
01532     }
01533 
01539     public function getTitleSuffix()
01540     {
01541         return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
01542     }
01543 
01549     public function getTitlePageSuffix()
01550     {
01551     }
01552 
01559     public function getTitlePrefix()
01560     {
01561         return $this->getConfig()->getActiveShop()->oxshops__oxtitleprefix->value;
01562     }
01563 
01564 
01565 
01574     protected function _getSubject( $iLang )
01575     {
01576         return null;
01577     }
01578 
01584     public function getDynUrlParams()
01585     {
01586         $sRet = '';
01587         $sListType = $this->getListType();
01588 
01589         switch ($sListType) {
01590             default:
01591                 break;
01592             case 'search':
01593                 $sRet .= "&amp;listtype={$sListType}";
01594                 if ( $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
01595                     $sRet .= "&amp;searchparam={$sSearchParamForLink}";
01596                 }
01597 
01598                 if ( ( $sVar = oxConfig::getParameter( 'searchcnid', true ) ) ) {
01599                     $sRet .= '&amp;searchcnid='.rawurlencode( rawurldecode( $sVar ) );
01600                 }
01601                 if ( ( $sVar = oxConfig::getParameter( 'searchvendor', true ) ) ) {
01602                     $sRet .= '&amp;searchvendor='.rawurlencode( rawurldecode( $sVar ) );
01603                 }
01604                 if ( ( $sVar = oxConfig::getParameter( 'searchmanufacturer', true ) ) ) {
01605                     $sRet .= '&amp;searchmanufacturer='.rawurlencode( rawurldecode( $sVar ) );
01606                 }
01607                 break;
01608             case 'tag':
01609                 $sRet .= "&amp;listtype={$sListType}";
01610                 if ( $sParam = rawurlencode( oxConfig::getParameter( 'searchtag', true ) ) ) {
01611                     $sRet .= "&amp;searchtag={$sParam}";
01612                 }
01613                 break;
01614         }
01615 
01616         return $sRet;
01617     }
01618 
01626     public function getLink( $iLang = null )
01627     {
01628         if ( !isset( $iLang ) ) {
01629             $iLang = oxRegistry::getLang()->getBaseLanguage();
01630         }
01631 
01632         $oDisplayObj = null;
01633         $blTrySeo = false;
01634         if ( oxRegistry::getUtils()->seoIsActive() ) {
01635             $blTrySeo = true;
01636             $oDisplayObj = $this->_getSubject( $iLang );
01637         }
01638         $iActPageNr = $this->getActPage();
01639 
01640         if ( $oDisplayObj ) {
01641             return $this->_addPageNrParam( $oDisplayObj->getLink( $iLang ), $iActPageNr, $iLang );
01642         }
01643 
01644         $myConfig = $this->getConfig();
01645 
01646         if ( $blTrySeo ) {
01647             $oEncoder = oxRegistry::get("oxSeoEncoder");
01648             if ( ( $sSeoUrl = $oEncoder->getStaticUrl( $myConfig->getShopHomeURL( $iLang ) . $this->_getSeoRequestParams(), $iLang ) ) ) {
01649                 return $this->_addPageNrParam( $sSeoUrl, $iActPageNr, $iLang );
01650             }
01651         }
01652 
01653         $sUrl = oxRegistry::get("oxUtilsUrl")->processUrl( $myConfig->getShopCurrentURL( $iLang ) . $this->_getRequestParams(), true, null, $iLang);
01654 
01655         // fallback to old non seo url
01656         return $this->_addPageNrParam( $sUrl, $iActPageNr, $iLang );
01657     }
01658 
01664     public function getCanonicalUrl()
01665     {
01666     }
01667 
01674     public function getSimilarRecommListIds()
01675     {
01676         return false;
01677     }
01684     public function getSearchParamForHtml()
01685     {
01686     }
01687 
01695     protected function _getRequestParams( $blAddPageNr  = true )
01696     {
01697         $sClass = $this->getClassName();
01698         $sFnc   = $this->getFncName();
01699 
01700         $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher', 'moveleft', 'moveright' );
01701         if ( in_array( $sFnc, $aFnc ) ) {
01702             $sFnc = '';
01703         }
01704 
01705         // #680
01706         $sURL = "cl={$sClass}";
01707         if ( $sFnc ) {
01708             $sURL .= "&amp;fnc={$sFnc}";
01709         }
01710         if ( $sVal = oxConfig::getParameter( 'cnid' ) ) {
01711             $sURL .= "&amp;cnid={$sVal}";
01712         }
01713         if ( $sVal = oxConfig::getParameter( 'mnid' ) ) {
01714             $sURL .= "&amp;mnid={$sVal}";
01715         }
01716         if ( $sVal= oxConfig::getParameter( 'anid' ) ) {
01717             $sURL .= "&amp;anid={$sVal}";
01718         }
01719 
01720         if ( $sVal = basename( oxConfig::getParameter( 'page' ) ) ) {
01721             $sURL .= "&amp;page={$sVal}";
01722         }
01723 
01724         if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
01725             $sURL .= "&amp;tpl={$sVal}";
01726         }
01727 
01728         if ( $sVal = oxConfig::getParameter( 'oxloadid' ) ) {
01729             $sURL .= "&amp;oxloadid={$sVal}";
01730         }
01731 
01732         $iPgNr = (int) oxConfig::getParameter( 'pgNr' );
01733         // don't include page number for navigation
01734         // it will be done in oxubase::generatePageNavigation
01735         if ( $blAddPageNr && $iPgNr > 0 ) {
01736             $sURL .= "&amp;pgNr={$iPgNr}";
01737         }
01738 
01739         // #1184M - specialchar search
01740         if ( $sVal = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
01741             $sURL .= "&amp;searchparam={$sVal}";
01742         }
01743 
01744         if ( $sVal = oxConfig::getParameter( 'searchcnid' ) ) {
01745             $sURL .= "&amp;searchcnid={$sVal}";
01746         }
01747 
01748         if ( $sVal = oxConfig::getParameter( 'searchvendor' ) ) {
01749             $sURL .= "&amp;searchvendor={$sVal}";
01750         }
01751 
01752         if ( $sVal = oxConfig::getParameter( 'searchmanufacturer' ) ) {
01753             $sURL .= "&amp;searchmanufacturer={$sVal}";
01754         }
01755 
01756         if ( $sVal = oxConfig::getParameter( 'searchrecomm' ) ) {
01757             $sURL .= "&amp;searchrecomm={$sVal}";
01758         }
01759 
01760         if ( $sVal = oxConfig::getParameter( 'searchtag' ) ) {
01761             $sURL .= "&amp;searchtag={$sVal}";
01762         }
01763 
01764         if ( $sVal = oxConfig::getParameter( 'recommid' ) ) {
01765             $sURL .= "&amp;recommid={$sVal}";
01766         }
01767 
01768         return $sURL;
01769     }
01770 
01776     protected function _getSeoRequestParams()
01777     {
01778         $sClass = $this->getClassName();
01779         $sFnc   = $this->getFncName();
01780 
01781         // #921 S
01782         $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher' );
01783         if ( in_array( $sFnc, $aFnc ) ) {
01784             $sFnc = '';
01785         }
01786 
01787         // #680
01788         $sURL = "cl={$sClass}";
01789         if ( $sFnc ) {
01790             $sURL .= "&amp;fnc={$sFnc}";
01791         }
01792         if ( $sVal = basename( oxConfig::getParameter( 'page' ) ) ) {
01793             $sURL .= "&amp;page={$sVal}";
01794         }
01795 
01796         if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
01797             $sURL .= "&amp;tpl={$sVal}";
01798         }
01799 
01800         if ( $sVal = oxConfig::getParameter( 'oxloadid' ) ) {
01801             $sURL .= "&amp;oxloadid={$sVal}";
01802         }
01803 
01804         $iPgNr = (int) oxConfig::getParameter( 'pgNr' );
01805         if ( $iPgNr > 0 ) {
01806             $sURL .= "&amp;pgNr={$iPgNr}";
01807         }
01808 
01809         return $sURL;
01810     }
01811 
01817     public function showSearch()
01818     {
01819         $blShow = true;
01820         if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) && $this->getIsOrderStep() ) {
01821             $blShow = false;
01822         }
01823         return (int) $blShow;
01824     }
01825 
01831     public function getRssLinks()
01832     {
01833         return $this->_aRssLinks;
01834     }
01835 
01841     public function getSortColumns()
01842     {
01843         if ( $this->_aSortColumns === null ) {
01844             $this->setSortColumns( $this->getConfig()->getConfigParam( 'aSortCols' ) );
01845         }
01846         return $this->_aSortColumns;
01847     }
01848 
01849 
01857     public function setSortColumns( $aSortColumns )
01858     {
01859         $this->_aSortColumns = $aSortColumns;
01860     }
01861 
01867     public function getEditTags()
01868     {
01869     }
01870 
01876     public function getRecommSearch()
01877     {
01878     }
01879 
01885     public function getPaymentList()
01886     {
01887     }
01888 
01894     public function getActiveRecommList()
01895     {
01896         if ( $this->_oActiveRecommList === null ) {
01897             $this->_oActiveRecommList = false;
01898             if ( $sOxid = oxConfig::getParameter( 'recommid' ) ) {
01899                 $this->_oActiveRecommList = oxNew( 'oxrecommlist' );
01900                 $this->_oActiveRecommList->load( $sOxid );
01901             }
01902         }
01903         return $this->_oActiveRecommList;
01904     }
01905 
01911     public function getAccessoires()
01912     {
01913     }
01914 
01920     public function getCrossSelling()
01921     {
01922     }
01923 
01929     public function getSimilarProducts()
01930     {
01931     }
01932 
01938     public function getAlsoBoughtTheseProducts()
01939     {
01940     }
01941 
01947     public function getArticleId()
01948     {
01949     }
01950 
01956     public function getTitle()
01957     {
01958         $sTranslationName = 'PAGE_TITLE_'.strtoupper($this->getConfig()->getActiveView()->getClassName());
01959         $sTranslated = oxRegistry::getLang()->translateString( $sTranslationName, oxRegistry::getLang()->getBaseLanguage(), false );
01960         return $sTranslationName == $sTranslated? null : $sTranslated;
01961     }
01962 
01968     public function getActiveLangAbbr()
01969     {
01970         // Performance
01971         if ( !$this->getConfig()->getConfigParam( 'bl_perfLoadLanguages' ) ) {
01972             return;
01973         }
01974 
01975         if ( !isset($this->_sActiveLangAbbr ) ) {
01976             $aLanguages = oxRegistry::getLang()->getLanguageArray();
01977             while ( list( $sKey, $oVal ) = each( $aLanguages ) ) {
01978                 if ( $oVal->selected ) {
01979                     $this->_sActiveLangAbbr = $oVal->abbr;
01980                     break;
01981                 }
01982             }
01983         }
01984 
01985         return $this->_sActiveLangAbbr;
01986     }
01987 
01995     public function addGlobalParams( $oShop = null)
01996     {
01997         $oViewConf = parent::addGlobalParams( $oShop );
01998 
01999         $this->_setNrOfArtPerPage();
02000 
02001         return $oViewConf;
02002     }
02003 
02009     public function getAdditionalParams()
02010     {
02011         if ( $this->_sAdditionalParams === null ) {
02012             // #1018A
02013             $this->_sAdditionalParams  = parent::getAdditionalParams();
02014             $this->_sAdditionalParams .= 'cl='.$this->getConfig()->getActiveView()->getClassName();
02015 
02016             // #1834M - specialchar search
02017             $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) );
02018             if ( isset( $sSearchParamForLink ) ) {
02019                 $this->_sAdditionalParams .= "&amp;searchparam={$sSearchParamForLink}";
02020             }
02021             if ( ( $sVar = oxConfig::getParameter( 'searchtag' ) ) ) {
02022                 $this->_sAdditionalParams .= '&amp;searchtag='.rawurlencode( rawurldecode( $sVar ) );
02023             }
02024             if ( ( $sVar = oxConfig::getParameter( 'searchcnid' ) ) ) {
02025                 $this->_sAdditionalParams .= '&amp;searchcnid='.rawurlencode( rawurldecode( $sVar ) );
02026             }
02027             if ( ( $sVar = oxConfig::getParameter( 'searchvendor' ) ) ) {
02028                 $this->_sAdditionalParams .= '&amp;searchvendor='.rawurlencode( rawurldecode( $sVar ) );
02029             }
02030             if ( ( $sVar = oxConfig::getParameter( 'searchmanufacturer' ) ) ) {
02031                 $this->_sAdditionalParams .= '&amp;searchmanufacturer='.rawurlencode( rawurldecode( $sVar ) );
02032             }
02033             if ( ( $sVar = oxConfig::getParameter( 'cnid' ) ) ) {
02034                 $this->_sAdditionalParams .= '&amp;cnid='.rawurlencode( rawurldecode( $sVar ) );
02035             }
02036             if ( ( $sVar = oxConfig::getParameter( 'mnid' ) ) ) {
02037                 $this->_sAdditionalParams .= '&amp;mnid='.rawurlencode( rawurldecode( $sVar ) );
02038             }
02039         }
02040 
02041         return $this->_sAdditionalParams;
02042     }
02043 
02049     public function generatePageNavigationUrl()
02050     {
02051         return $this->getConfig()->getShopHomeURL().$this->_getRequestParams( false );
02052     }
02053 
02063     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null )
02064     {
02065         if ( $iPage ) {
02066             if ( ( strpos( $sUrl, 'pgNr=' ) ) ) {
02067                 $sUrl = preg_replace('/pgNr=[0-9]*/', 'pgNr='.$iPage, $sUrl);
02068             } else {
02069                 $sUrl .= ( ( strpos( $sUrl, '?' ) === false ) ? '?' : '&amp;' ) . 'pgNr='.$iPage;
02070             }
02071         } else {
02072            $sUrl = preg_replace('/pgNr=[0-9]*/', '', $sUrl);
02073            $sUrl = preg_replace('/\&amp\;\&amp\;/', '&amp;', $sUrl);
02074            $sUrl = preg_replace('/\?\&amp\;/', '?', $sUrl);
02075            $sUrl = preg_replace('/\&amp\;$/', '', $sUrl);
02076         }
02077         return $sUrl;
02078     }
02079 
02085     public function getPageNavigation()
02086     {
02087 
02088     }
02089 
02095     public function getPageNavigationLimitedTop()
02096     {
02097 
02098         $this->_oPageNavigation = $this->generatePageNavigation( 7 );
02099 
02100         return $this->_oPageNavigation;
02101     }
02102 
02108     public function getPageNavigationLimitedBottom()
02109     {
02110 
02111         $this->_oPageNavigation = $this->generatePageNavigation( 11 );
02112 
02113         return $this->_oPageNavigation;
02114     }
02115 
02116 
02124     public function generatePageNavigation( $iPositionCount = 0 )
02125     {
02126         startProfile('generatePageNavigation');
02127 
02128         $pageNavigation = new stdClass();
02129 
02130         $pageNavigation->NrOfPages = $this->_iCntPages;
02131         $iActPage = $this->getActPage();
02132         $pageNavigation->actPage   = $iActPage + 1;
02133         $sUrl = $this->generatePageNavigationUrl();
02134 
02135         if ( $iPositionCount == 0 || ($iPositionCount >= $pageNavigation->NrOfPages) ) {
02136              $iStartNo = 2;
02137              $iFinishNo = $pageNavigation->NrOfPages;
02138              $bStart = false;
02139              $bFinish =false;
02140         } else {
02141             $iTmpVal = $iPositionCount - 3;
02142             $iTmpVal2 = floor( ( $iPositionCount - 4 ) / 2 );
02143 
02144             // actual page is at the start
02145             if ( $pageNavigation->actPage <= $iTmpVal ) {
02146                 $iStartNo = 2;
02147                 $iFinishNo = $iTmpVal + 1;
02148                 $bStart = false;
02149                 $bFinish = true;
02150             // actual page is at the end
02151             } elseif ( $pageNavigation->actPage >= $pageNavigation->NrOfPages - $iTmpVal ) {
02152                 $iStartNo = $pageNavigation->NrOfPages - $iTmpVal;
02153                 $iFinishNo = $pageNavigation->NrOfPages - 1;
02154                 $bStart = true;
02155                 $bFinish = false;
02156             // actual page is in the midle
02157             } else {
02158                 $iStartNo = $pageNavigation->actPage - $iTmpVal2;
02159                 $iFinishNo = $pageNavigation->actPage + $iTmpVal2;
02160                 $bStart = true;
02161                 $bFinish = true;
02162             }
02163         }
02164 
02165         if ( $iActPage > 0) {
02166             $pageNavigation->previousPage = $this->_addPageNrParam( $sUrl, $iActPage - 1 );
02167         }
02168 
02169         if ( $iActPage < $pageNavigation->NrOfPages - 1 ) {
02170             $pageNavigation->nextPage = $this->_addPageNrParam( $sUrl, $iActPage + 1 );
02171         }
02172 
02173         if ( $pageNavigation->NrOfPages > 1 ) {
02174 
02175             for ( $i=1; $i < $pageNavigation->NrOfPages + 1; $i++ ) {
02176 
02177                 if ( $i == 1 || $i == $pageNavigation->NrOfPages || ( $i >= $iStartNo && $i <= $iFinishNo ) ) {
02178                     $page = new stdClass();
02179                     $page->url = $this->_addPageNrParam( $sUrl, $i - 1 );
02180                     $page->selected = ( $i == $pageNavigation->actPage ) ? 1 : 0;
02181                     $pageNavigation->changePage[$i] = $page;
02182                 }
02183             }
02184 
02185             // first/last one
02186             $pageNavigation->firstpage = $this->_addPageNrParam( $sUrl, 0 );
02187             $pageNavigation->lastpage  = $this->_addPageNrParam( $sUrl, $pageNavigation->NrOfPages - 1 );
02188         }
02189 
02190         stopProfile('generatePageNavigation');
02191 
02192         return $pageNavigation;
02193     }
02194 
02201     public function render()
02202     {
02203         foreach ( array_keys( $this->_oaComponents ) as $sComponentName ) {
02204             $this->_aViewData[$sComponentName] = $this->_oaComponents[$sComponentName]->render();
02205         }
02206 
02207         parent::render();
02208 
02209         if ( $this->getIsOrderStep() ) {
02210 
02211             // disabling navigation during order ...
02212             if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) ) {
02213                 $this->_iNewsRealStatus = 1;
02214                 $this->setShowNewsletter( 0 );
02215             }
02216         }
02217         return $this->_sThisTemplate;
02218     }
02219 
02225     public function getViewProduct()
02226     {
02227         return $this->getProduct();
02228     }
02229 
02237     public function setViewProduct( $oProduct )
02238     {
02239         $this->_oProduct = $oProduct;
02240     }
02241 
02247     public function getViewProductList()
02248     {
02249         return $this->_aArticleList;
02250     }
02251 
02257     public function getActPage()
02258     {
02259         if ( $this->_iActPage === null ) {
02260             $this->_iActPage = ( int ) oxConfig::getParameter( 'pgNr' );
02261             $this->_iActPage = ( $this->_iActPage < 0 ) ? 0 : $this->_iActPage;
02262         }
02263         return $this->_iActPage;
02264     }
02265 
02273     public function getActTag()
02274     {
02275         if ( $this->_oActTag === null ) {
02276             $this->_oActTag = new stdClass();
02277             $this->_oActTag->sTag = $sTag = oxConfig::getParameter("searchtag", 1);
02278             $oSeoEncoderTag = oxRegistry::get("oxSeoEncoderTag");
02279 
02280             $sLink = false;
02281             if ( oxRegistry::getUtils()->seoIsActive() ) {
02282                 $sLink = $oSeoEncoderTag->getTagUrl( $sTag, oxRegistry::getLang()->getBaseLanguage() );
02283             }
02284 
02285             $this->_oActTag->link = $sLink ? $sLink : $this->getConfig()->getShopHomeURL().$oSeoEncoderTag->getStdTagUri( $sTag, false );
02286         }
02287         return $this->_oActTag;
02288     }
02289 
02297     public function getActVendor()
02298     {
02299         // if active vendor is not set yet - trying to load it from request params
02300         // this may be usefull when category component was unable to load active vendor
02301         // and we still need some object to mount navigation info
02302         if ( $this->_oActVendor === null ) {
02303             $this->_oActVendor = false;
02304             $sVendorId = oxConfig::getParameter( 'cnid' );
02305             $sVendorId = $sVendorId ? str_replace( 'v_', '', $sVendorId ) : $sVendorId;
02306             $oVendor = oxNew( 'oxvendor' );
02307             if ( $oVendor->load( $sVendorId ) ) {
02308                 $this->_oActVendor = $oVendor;
02309             }
02310         }
02311 
02312         return $this->_oActVendor;
02313     }
02314 
02322     public function getActManufacturer()
02323     {
02324         // if active Manufacturer is not set yet - trying to load it from request params
02325         // this may be usefull when category component was unable to load active Manufacturer
02326         // and we still need some object to mount navigation info
02327         if ( $this->_oActManufacturer === null ) {
02328 
02329             $this->_oActManufacturer = false;
02330             $sManufacturerId = oxConfig::getParameter( 'mnid' );
02331             $oManufacturer = oxNew( 'oxmanufacturer' );
02332             if ( $oManufacturer->load( $sManufacturerId ) ) {
02333                 $this->_oActManufacturer = $oManufacturer;
02334             }
02335         }
02336 
02337         return $this->_oActManufacturer;
02338     }
02339 
02347     public function setActVendor( $oVendor )
02348     {
02349         $this->_oActVendor = $oVendor;
02350     }
02351 
02359     public function setActManufacturer( $oManufacturer )
02360     {
02361         $this->_oActManufacturer = $oManufacturer;
02362     }
02363 
02369     public function getActSearch()
02370     {
02371         if ( $this->_oActSearch === null ) {
02372             $this->_oActSearch = new stdClass();
02373             $sUrl = $this->getConfig()->getShopHomeURL();
02374             $this->_oActSearch->link = "{$sUrl}cl=search";
02375         }
02376         return $this->_oActSearch;
02377     }
02378 
02384     public function getCategoryTree()
02385     {
02386         return $this->_oCategoryTree;
02387     }
02388 
02396     public function setCategoryTree( $oCatTree )
02397     {
02398         $this->_oCategoryTree = $oCatTree;
02399     }
02400 
02406     public function getManufacturerTree()
02407     {
02408         return $this->_oManufacturerTree;
02409     }
02410 
02418     public function setManufacturerTree( $oManufacturerTree )
02419     {
02420         $this->_oManufacturerTree = $oManufacturerTree;
02421     }
02422 
02428     public function getAddUrlParams()
02429     {
02430     }
02431 
02440     public function getTop5ArticleList( $iCount = null )
02441     {
02442         if ( $this->_blTop5Action ) {
02443             if ( $this->_aTop5ArticleList === null ) {
02444                 $this->_aTop5ArticleList = false;
02445                 $myConfig = $this->getConfig();
02446                 if ( $myConfig->getConfigParam( 'bl_perfLoadAktion' ) ) {
02447                     // top 5 articles
02448                     $oArtList = oxNew( 'oxarticlelist' );
02449                     $oArtList->loadTop5Articles( $iCount );
02450                     if ( $oArtList->count() ) {
02451                         $this->_aTop5ArticleList = $oArtList;
02452                     }
02453                 }
02454             }
02455         }
02456         return $this->_aTop5ArticleList;
02457     }
02458 
02465     public function getBargainArticleList()
02466     {
02467         if ( $this->_blBargainAction ) {
02468             if ( $this->_aBargainArticleList === null ) {
02469                 $this->_aBargainArticleList = array();
02470                 if ( $this->getConfig()->getConfigParam( 'bl_perfLoadAktion' ) ) {
02471                     $oArtList = oxNew( 'oxarticlelist' );
02472                     $oArtList->loadActionArticles( 'OXBARGAIN' );
02473                     if ( $oArtList->count() ) {
02474                         $this->_aBargainArticleList = $oArtList;
02475                     }
02476                 }
02477             }
02478         }
02479         return $this->_aBargainArticleList;
02480     }
02481 
02488     public function isLowOrderPrice()
02489     {
02490         if ( $this->_blLowOrderPrice === null && ( $oBasket = $this->getSession()->getBasket() ) ) {
02491             $this->_blLowOrderPrice = $oBasket->isBelowMinOrderPrice();
02492         }
02493 
02494         return $this->_blLowOrderPrice;
02495     }
02496 
02502     public function getMinOrderPrice()
02503     {
02504         if ( $this->_sMinOrderPrice === null && $this->isLowOrderPrice() ) {
02505             $dMinOrderPrice = oxPrice::getPriceInActCurrency( $this->getConfig()->getConfigParam( 'iMinOrderPrice' ) );
02506             $this->_sMinOrderPrice = oxRegistry::getLang()->formatCurrency( $dMinOrderPrice );
02507         }
02508         return $this->_sMinOrderPrice;
02509     }
02510 
02516     public function getNewsRealStatus()
02517     {
02518         return $this->_iNewsRealStatus;
02519     }
02520 
02526     protected function _canRedirect()
02527     {
02528         foreach ( $this->_aBlockRedirectParams as $sParam ) {
02529             if ( oxConfig::getParameter( $sParam ) !== null ) {
02530                 return false;
02531             }
02532         }
02533 
02534         return true;
02535     }
02536 
02542     public function getProduct()
02543     {
02544     }
02545 
02551     public function getManufacturerlist()
02552     {
02553         return $this->_aManufacturerlist;
02554     }
02555 
02563     public function setManufacturerlist( $aList )
02564     {
02565         $this->_aManufacturerlist = $aList;
02566     }
02567 
02575     public function setRootVendor( $oVendor )
02576     {
02577         $this->_oRootVendor = $oVendor;
02578     }
02579 
02585     public function getRootVendor()
02586     {
02587         return $this->_oRootVendor;
02588     }
02589 
02597     public function setRootManufacturer( $oManufacturer )
02598     {
02599         $this->_oRootManufacturer = $oManufacturer;
02600     }
02601 
02607     public function getRootManufacturer()
02608     {
02609         return $this->_oRootManufacturer;
02610     }
02611 
02617     public function getVendorId()
02618     {
02619         if ( $this->_sVendorId === null ) {
02620             $this->_sVendorId = false;
02621             if ( ( $oVendor = $this->getActVendor() ) ) {
02622                 $this->_sVendorId = $oVendor->getId();
02623             }
02624         }
02625         return $this->_sVendorId;
02626     }
02627 
02633     public function getManufacturerId()
02634     {
02635         if ( $this->_sManufacturerId === null ) {
02636             $this->_sManufacturerId = false;
02637             if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
02638                 $this->_sManufacturerId = $oManufacturer->getId();
02639             }
02640         }
02641         return $this->_sManufacturerId;
02642     }
02643 
02649     public function getSearchCatTree()
02650     {
02651         return $this->_aSearchCatTree;
02652     }
02653 
02661     public function setSearchCatTree( $aTree )
02662     {
02663         $this->_aSearchCatTree = $aTree;
02664     }
02665 
02671     public function getCatMoreUrl()
02672     {
02673         return $this->getConfig()->getShopHomeURL().'cnid=oxmore';
02674     }
02675 
02681     public function getCatTreePath()
02682     {
02683         return $this->_sCatTreePath;
02684     }
02685 
02693     public function getContentByIdent( $sIdent )
02694     {
02695         if ( !isset( $this->_aContents[$sIdent] ) ) {
02696             $this->_aContents[$sIdent] = oxNew( 'oxcontent' );
02697             $this->_aContents[$sIdent]->loadByIdent( $sIdent );
02698         }
02699         return $this->_aContents[$sIdent];
02700     }
02701 
02707     public function getContentCategory()
02708     {
02709         return false;
02710     }
02711 
02717     public function getMustFillFields()
02718     {
02719         if ( $this->_aMustFillFields === null ) {
02720             $this->_aMustFillFields = false;
02721 
02722             // passing must-be-filled-fields info
02723             $aMustFillFields = $this->getConfig()->getConfigParam( 'aMustFillFields' );
02724             if ( is_array( $aMustFillFields ) ) {
02725                 $this->_aMustFillFields = array_flip( $aMustFillFields );
02726             }
02727         }
02728         return $this->_aMustFillFields;
02729     }
02730 
02738     public function isFieldRequired( $sField )
02739     {
02740         if ( $aMustFillFields = $this->getMustFillFields() ) {
02741             if ( isset( $aMustFillFields[$sField] ) ) {
02742                 return true;
02743             }
02744         }
02745 
02746         return false;
02747     }
02748 
02754     public function getFormId()
02755     {
02756         if ( $this->_sFormId === null ) {
02757             $this->_sFormId = oxUtilsObject::getInstance()->generateUId();
02758             oxSession::setVar( 'sessionuformid', $this->_sFormId );
02759         }
02760 
02761         return $this->_sFormId;
02762     }
02763 
02769     public function canAcceptFormData()
02770     {
02771         if ( $this->_blCanAcceptFormData === null ) {
02772             $this->_blCanAcceptFormData = false;
02773 
02774             $sFormId = oxConfig::getParameter( "uformid" );
02775             $sSessionFormId = oxSession::getVar( "sessionuformid" );
02776 
02777             // testing if form and session ids matches
02778             if ( $sFormId && $sFormId === $sSessionFormId ) {
02779                 $this->_blCanAcceptFormData = true;
02780             }
02781 
02782             // regenerating form data
02783             $this->getFormId();
02784         }
02785         return $this->_blCanAcceptFormData;
02786     }
02787 
02793     public function getPromoFinishedList()
02794     {
02795         if (isset($this->_oPromoFinishedList)) {
02796             return $this->_oPromoFinishedList;
02797         }
02798         $this->_oPromoFinishedList = oxNew( 'oxActionList' );
02799         $this->_oPromoFinishedList->loadFinishedByCount(2);
02800         return $this->_oPromoFinishedList;
02801     }
02802 
02808     public function getPromoCurrentList()
02809     {
02810         if (isset($this->_oPromoCurrentList)) {
02811             return $this->_oPromoCurrentList;
02812         }
02813         $this->_oPromoCurrentList = oxNew( 'oxActionList' );
02814         $this->_oPromoCurrentList->loadCurrent();
02815         return $this->_oPromoCurrentList;
02816     }
02817 
02823     public function getPromoFutureList()
02824     {
02825         if (isset($this->_oPromoFutureList)) {
02826             return $this->_oPromoFutureList;
02827         }
02828         $this->_oPromoFutureList = oxNew( 'oxActionList' );
02829         $this->_oPromoFutureList->loadFutureByCount(2);
02830         return $this->_oPromoFutureList;
02831     }
02832 
02838     public function getShowPromotionList()
02839     {
02840         if (isset($this->_blShowPromotions)) {
02841             return $this->_blShowPromotions;
02842         }
02843         $this->_blShowPromotions = false;
02844         if (oxNew('oxActionList')->areAnyActivePromotions()) {
02845             $this->_blShowPromotions = ( count( $this->getPromoFinishedList() ) + count( $this->getPromoCurrentList() ) + count( $this->getPromoFutureList() ) ) > 0;
02846         }
02847         return $this->_blShowPromotions;
02848     }
02849 
02855     public function isEnabledPrivateSales()
02856     {
02857         if ( $this->_blEnabledPrivateSales === null ) {
02858             $this->_blEnabledPrivateSales = (bool) $this->getConfig()->getConfigParam( 'blPsLoginEnabled' );
02859             if ( $this->_blEnabledPrivateSales && ( $blCanPreview = oxRegistry::getUtils()->canPreview() ) !== null ) {
02860                 $this->_blEnabledPrivateSales = !$blCanPreview;
02861             }
02862         }
02863         return $this->_blEnabledPrivateSales;
02864     }
02865 
02871     public function getFieldValidationErrors()
02872     {
02873         return oxRegistry::get("oxInputValidator")->getFieldValidationErrors();
02874     }
02875 
02881     public function getBreadCrumb()
02882     {
02883         return null;
02884     }
02885 
02893     public function setRootCatChanged( $blRootCatChanged )
02894     {
02895         $this->_blRootCatChanged = $blRootCatChanged;
02896     }
02897 
02903     public function isRootCatChanged()
02904     {
02905         return $this->_blRootCatChanged;
02906     }
02907 
02913     public function getInvoiceAddress()
02914     {
02915         if ( $this->_aInvoiceAddress == null ) {
02916             $aAddress = oxConfig::getParameter( 'invadr');
02917             if ( $aAddress ) {
02918                 $this->_aInvoiceAddress = $aAddress;
02919             }
02920         }
02921         return $this->_aInvoiceAddress;
02922     }
02923 
02929     public function getDeliveryAddress()
02930     {
02931         if ( $this->_aDeliveryAddress == null ) {
02932             $oConfig = $this->getConfig();
02933             //do not show deladr if address was reloaded
02934             if ( !$oConfig->getRequestParameter( 'reloadaddress' ) ) {
02935                 $this->_aDeliveryAddress = $oConfig->getRequestParameter( 'deladr');
02936             }
02937         }
02938         return $this->_aDeliveryAddress;
02939     }
02940 
02948     public function setDeliveryAddress($aDeliveryAddress)
02949     {
02950         $this->_aDeliveryAddress = $aDeliveryAddress;
02951     }
02952 
02960     public function setInvoiceAddress( $aAddress )
02961     {
02962         $this->_aInvoiceAddress = $aAddress;
02963     }
02964 
02970     public function getActiveUsername()
02971     {
02972         if ( $this->_sActiveUsername == null ) {
02973             $this->_sActiveUsername = false;
02974             $sUsername = oxConfig::getParameter( 'lgn_usr' );
02975             if ( $sUsername ) {
02976                 $this->_sActiveUsername = $sUsername;
02977             } elseif ( $oUser = $this->getUser() ) {
02978                 $this->_sActiveUsername = $oUser->oxuser__oxusername->value;
02979             }
02980         }
02981         return $this->_sActiveUsername;
02982     }
02983 
02989     public function getWishlistUserId()
02990     {
02991         return oxConfig::getParameter( 'wishid' );
02992     }
02993 
02999     public function getSearchCatId()
03000     {
03001     }
03002 
03008     public function getSearchVendor()
03009     {
03010     }
03011 
03017     public function getSearchManufacturer()
03018     {
03019     }
03020 
03026     public function getLastProducts()
03027     {
03028 
03029     }
03030 
03036     public function getNewBasketItemMsgType()
03037     {
03038         return (int) $this->getConfig()->getConfigParam( "iNewBasketItemMessage" );
03039     }
03040 
03048     public function isActive( $sName )
03049     {
03050         return $this->getConfig()->getConfigParam( "bl".$sName."Enabled" );
03051     }
03052 
03058     public function isFbWidgetVisible()
03059     {
03060         if ( $this->_blFbWidgetsOn === null ) {
03061             $oUtils = oxRegistry::get("oxUtilsServer");
03062 
03063             // reading ..
03064             $this->_blFbWidgetsOn = (bool) $oUtils->getOxCookie( "fbwidgetson" );
03065         }
03066         return $this->_blFbWidgetsOn;
03067     }
03068 
03074     public function isEnabledDownloadableFiles()
03075     {
03076         return (bool) $this->getConfig()->getConfigParam( "blEnableDownloads" );
03077     }
03078 
03084     public function showRememberMe()
03085     {
03086         return (bool) $this->getConfig()->getConfigParam('blShowRememberMe');
03087     }
03088 
03095     public function isVatIncluded()
03096     {
03097         $blResult = true;
03098         $oUser = $this->getUser();
03099         $oConfig = $this->getConfig();
03100 
03101         if ( $oConfig->getConfigParam( 'blShowNetPrice' ) || $oConfig->getConfigParam( 'bl_perfCalcVatOnlyForBasketOrder' ) ) {
03102             $blResult = false;
03103         } elseif ( $oUser && $oUser->isPriceViewModeNetto() ) {
03104             $blResult = false;
03105         }
03106 
03107         return $blResult;
03108     }
03109 
03115     public function isPriceCalculated()
03116     {
03117         return (bool) $this->getConfig()->getConfigParam( 'bl_perfLoadPrice' );
03118     }
03119 
03125     public function showTags()
03126     {
03127          return (bool) $this->_blShowTagCloud && $this->getConfig()->getConfigParam( "blShowTags" );
03128     }
03129 
03135     public function getWishlistName()
03136     {
03137         if ( $this->getUser() ) {
03138             $sUserId = oxConfig::getParameter( 'wishid') ? oxConfig::getParameter( 'wishid' ): oxSession::getVar( 'wishid');
03139             if ( $sUserId ) {
03140                 $oWishUser = oxNew( 'oxuser' );
03141                 if ( $oWishUser->load( $sUserId ) ) {
03142                     return $oWishUser;
03143                 }
03144             }
03145         }
03146         return false;
03147     }
03148 
03149 }