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 
00398     protected $_aSearchCatTree = null;
00399 
00404     protected $_blNewsSubscribed = null;
00405 
00410     protected $_oDelAddress = null;
00411 
00416     protected $_sCatTreePath = null;
00417 
00422     protected $_aContents = array();
00423 
00428     protected $_blTop5Action = false;
00429 
00434     protected $_blBargainAction = false;
00435 
00441     protected $_aMustFillFields = null;
00442 
00447     protected $_blShowTagCloud = true;
00448 
00453     protected $_blRootCatChanged = false;
00454 
00459     protected $_aInvoiceAddress = null;
00460 
00465     protected $_aDeliveryAddress = null;
00466 
00471     protected $_sActiveUsername = null;
00472 
00478     protected static $_aCollectedComponentNames = null;
00479 
00486     protected $_blLoadComponents = true;
00487 
00488 
00494     protected $_aSortColumns = null;
00495 
00501     protected function _getComponentNames()
00502     {
00503         if ( self::$_aCollectedComponentNames === null ) {
00504             self::$_aCollectedComponentNames = array_merge( $this->_aComponentNames, $this->_aUserComponentNames );
00505 
00506             // #1721: custom component handling. At the moment it is not possible to override this variable in oxubase,
00507             // so we added this array to config.inc.php file
00508             if ( ( $aUserCmps = $this->getConfig()->getConfigParam( 'aUserComponentNames' ) ) ) {
00509                 self::$_aCollectedComponentNames = array_merge( self::$_aCollectedComponentNames, $aUserCmps );
00510             }
00511 
00512             if ( oxConfig::getParameter( '_force_no_basket_cmp' ) ) {
00513                 unset( self::$_aCollectedComponentNames['oxcmp_basket'] );
00514             }
00515         }
00516 
00517         // resetting array pointer
00518         reset( self::$_aCollectedComponentNames );
00519         return self::$_aCollectedComponentNames;
00520     }
00521 
00530     protected function _processRequest()
00531     {
00532         $myUtils = oxRegistry::getUtils();
00533 
00534         // non admin, request is not empty and was not processed by seo engine
00535         if ( !isSearchEngineUrl() && $myUtils->seoIsActive() && ( $sStdUrl = getRequestUrl( '', true ) ) ) {
00536 
00537             // fetching standard url and looking for it in seo table
00538             if ( $this->_canRedirect() && ( $sRedirectUrl = oxRegistry::get("oxSeoEncoder")->fetchSeoUrl( $sStdUrl ) ) ) {
00539                 $myUtils->redirect( $this->getConfig()->getCurrentShopUrl() . $sRedirectUrl, false );
00540             } elseif (VIEW_INDEXSTATE_INDEX == $this->noIndex()) {
00541                 // forcing to set noindex/follow meta
00542                 $this->_forceNoIndex();
00543 
00544                 if (!$this->getConfig()->isProductiveMode() || $this->getConfig()->getConfigParam('blSeoLogging')) {
00545                     $sShopId = $this->getConfig()->getShopId();
00546                     $sLangId = oxRegistry::getLang()->getBaseLanguage();
00547                     $sIdent  = md5( strtolower( $sStdUrl ) . $sShopId . $sLangId );
00548 
00549                     // logging "not found" url
00550                     $oDb = oxDb::getDb();
00551                     $oDb->execute( "replace oxseologs ( oxstdurl, oxident, oxshopid, oxlang )
00552                                     values ( " . $oDb->quote( $sStdUrl ) . ", '{$sIdent}', '{$sShopId}', '{$sLangId}' ) " );
00553                 }
00554             }
00555         }
00556     }
00557 
00564     public function init()
00565     {
00566         $this->_processRequest();
00567 
00568         // storing current view
00569         $blInit = true;
00570 
00571 
00572         // init all components if there are any
00573         if ( $this->_blLoadComponents ) {
00574             foreach ( $this->_getComponentNames() as $sComponentName => $blNotCacheable ) {
00575                 // do not override initiated components
00576                 if ( !isset( $this->_oaComponents[$sComponentName] ) ) {
00577                     // component objects MUST be created to support user called functions
00578                     $oComponent = oxNew( $sComponentName );
00579                     $oComponent->setParent( $this );
00580                     $oComponent->setThisAction( $sComponentName );
00581                     $this->_oaComponents[$sComponentName] = $oComponent;
00582                 }
00583 
00584                 // do we really need to initiate them ?
00585                 if ( $blInit ) {
00586                     $this->_oaComponents[$sComponentName]->init();
00587 
00588                     // executing only is view does not have action method
00589                     if ( !method_exists( $this, $this->getFncName() ) ) {
00590                         $this->_oaComponents[$sComponentName]->executeFunction( $this->getFncName() );
00591                     }
00592                 }
00593             }
00594         }
00595 
00596         parent::init();
00597     }
00598 
00605     public function getViewId()
00606     {
00607         if ( $this->_sViewId ) {
00608             return $this->_sViewId;
00609         }
00610 
00611         $myConfig = $this->getConfig();
00612         $iLang = oxRegistry::getLang()->getBaseLanguage();
00613         $iCur  = (int) $myConfig->getShopCurrency();
00614 
00615 
00616             $this->_sViewId =  "ox|$iLang|$iCur";
00617 
00618         $this->_sViewId .= "|".( (int) $this->_blForceNoIndex ).'|'.((int)$this->isRootCatChanged());
00619 
00620         // #0004798: SSL should be included in viewId
00621         if ($myConfig->isSsl()) {
00622             $this->_sViewId .= "|ssl";
00623         }
00624 
00625         // #0002866: external global viewID addition
00626         if (function_exists('customGetViewId')) {
00627             $oExtViewId = customGetViewId();
00628 
00629             if ($oExtViewId !== null) {
00630                 $this->_sViewId .= '|'.md5(serialize($oExtViewId));
00631             }
00632         }
00633         return $this->_sViewId;
00634     }
00635 
00636 
00642     public function showSorting()
00643     {
00644         return $this->_blShowSorting && $this->getConfig()->getConfigParam( 'blShowSorting' );
00645     }
00646 
00654     public function setComponents( $aComponents = null )
00655     {
00656         $this->_oaComponents = $aComponents;
00657     }
00658 
00664     public function getComponents()
00665     {
00666         return $this->_oaComponents;
00667     }
00668 
00676     public function getComponent( $sName )
00677     {
00678         if ( $sName != null ) {
00679             return $this->_oaComponents[$sName];
00680         }
00681     }
00689     public function setIsOrderStep( $blIsOrderStep = null )
00690     {
00691         $this->_blIsOrderStep = $blIsOrderStep;
00692     }
00693 
00699     public function getIsOrderStep()
00700     {
00701         return $this->_blIsOrderStep;
00702     }
00703 
00704 
00712     public function setActiveCategory( $oCategory )
00713     {
00714         $this->_oActCategory = $oCategory;
00715     }
00716 
00722     public function getActiveCategory()
00723     {
00724         return $this->_oActCategory;
00725     }
00726 
00732     public function getListType()
00733     {
00734         if ( $this->_sListType == null ) {
00735             if ( $sListType = oxConfig::getParameter( 'listtype' ) ) {
00736                 $this->_sListType = $sListType;
00737             } elseif ( $sListType = $this->getConfig()->getGlobalParameter( 'listtype' ) ) {
00738                 $this->_sListType = $sListType;
00739             }
00740         }
00741         return $this->_sListType;
00742     }
00743 
00749     public function getListDisplayType()
00750     {
00751         if ( $this->_sListDisplayType == null ) {
00752             $this->_sListDisplayType = $this->getCustomListDisplayType();
00753 
00754             if ( !$this->_sListDisplayType ) {
00755                 $this->_sListDisplayType = $this->getConfig()->getConfigParam( 'sDefaultListDisplayType' );
00756             }
00757 
00758             $this->_sListDisplayType = in_array( ( string ) $this->_sListDisplayType, $this->_aListDisplayTypes ) ? $this->_sListDisplayType : 'infogrid';
00759 
00760             // writing to session
00761             if ( oxConfig::getParameter( 'ldtype' ) ) {
00762                 oxSession::setVar( 'ldtype', $this->_sListDisplayType );
00763             }
00764         }
00765         return $this->_sListDisplayType;
00766     }
00767 
00773     public function getCustomListDisplayType()
00774     {
00775         if ( $this->_sCustomListDisplayType == null ) {
00776             $this->_sCustomListDisplayType = oxConfig::getParameter( 'ldtype' );
00777 
00778             if ( !$this->_sCustomListDisplayType ) {
00779                 $this->_sCustomListDisplayType = oxSession::getVar( 'ldtype' );
00780             }
00781         }
00782         return $this->_sCustomListDisplayType;
00783     }
00784 
00792     public function setListType( $sType )
00793     {
00794         $this->_sListType = $sType;
00795         $this->getConfig()->setGlobalParameter( 'listtype', $sType );
00796     }
00797 
00803     public function loadCurrency()
00804     {
00805         if ( $this->_blLoadCurrency == null ) {
00806             $this->_blLoadCurrency = false;
00807             if ( $blLoadCurrency = $this->getConfig()->getConfigParam( 'bl_perfLoadCurrency' ) ) {
00808                 $this->_blLoadCurrency = $blLoadCurrency;
00809             }
00810         }
00811         return $this->_blLoadCurrency;
00812     }
00813 
00819     public function dontShowEmptyCategories()
00820     {
00821         if ( $this->_blDontShowEmptyCats == null ) {
00822             $this->_blDontShowEmptyCats = false;
00823             if ( $blDontShowEmptyCats = $this->getConfig()->getConfigParam( 'blDontShowEmptyCategories' ) ) {
00824                 $this->_blDontShowEmptyCats = $blDontShowEmptyCats;
00825             }
00826         }
00827         return $this->_blDontShowEmptyCats;
00828     }
00829 
00835     public function showCategoryArticlesCount()
00836     {
00837         return $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' );
00838     }
00839 
00845     public function isLanguageLoaded()
00846     {
00847         if ( $this->_blLoadLanguage == null ) {
00848             $this->_blLoadLanguage = false;
00849             if ( $blLoadLanguage = $this->getConfig()->getConfigParam( 'bl_perfLoadLanguages' ) ) {
00850                 $this->_blLoadLanguage = $blLoadLanguage;
00851             }
00852         }
00853         return $this->_blLoadLanguage;
00854     }
00855 
00861     public function getTopNavigationCatCnt()
00862     {
00863         if ( $this->_iTopCatNavItmCnt == null ) {
00864             $iTopCatNavItmCnt = $this->getConfig()->getConfigParam( 'iTopNaviCatCount' );
00865             $this->_iTopCatNavItmCnt = $iTopCatNavItmCnt ? $iTopCatNavItmCnt : 5;
00866         }
00867         return $this->_iTopCatNavItmCnt;
00868     }
00869 
00879     public function addRssFeed($sTitle, $sUrl, $key = null)
00880     {
00881         if (!is_array($this->_aRssLinks)) {
00882             $this->_aRssLinks = array();
00883         }
00884 
00885         $sUrl = oxRegistry::get("oxUtilsUrl")->prepareUrlForNoSession($sUrl);
00886 
00887         if ($key === null) {
00888             $this->_aRssLinks[] = array('title'=>$sTitle, 'link' => $sUrl);
00889         } else {
00890             $this->_aRssLinks[$key] = array('title'=>$sTitle, 'link' => $sUrl);
00891         }
00892     }
00893 
00899     public function getSortOrderByParameterName()
00900     {
00901         return 'listorderby';
00902     }
00903 
00909     public function getSortOrderParameterName()
00910     {
00911         return 'listorder';
00912     }
00913 
00914 
00920     public function getSortIdent()
00921     {
00922         return 'alist';
00923     }
00924 
00930     public function getDefaultSorting()
00931     {
00932         return null;
00933     }
00934 
00940     public function getUserSelectedSorting()
00941     {
00942         $aSorting = null;
00943         $oStr = getStr();
00944         $oConfig = oxRegistry::getConfig();
00945         $aSortDirections = array( 'desc', 'asc' );
00946         $aSortColumns = $this->getSortColumns();
00947 
00948         $sSortBy  = $oConfig->getParameter( $this->getSortOrderByParameterName() );
00949         $sSortDir = $oConfig->getParameter( $this->getSortOrderParameterName() );
00950 
00951         if ( $sSortBy && oxDb::getInstance()->isValidFieldName( $sSortBy ) && /*in_array( $oStr->strtolower($sSortBy), $aSortColumns ) &&*/
00952             $sSortDir && oxRegistry::getUtils()->isValidAlpha( $sSortDir ) && in_array( $oStr->strtolower($sSortDir), $aSortDirections ) ) {
00953             $aSorting = array ( 'sortby' => $sSortBy, 'sortdir' => $sSortDir );
00954         }
00955 
00956         return $aSorting;
00957     }
00958 
00959 
00967     public function getSavedSorting( $sSortIdent )
00968     {
00969         $aSorting = oxSession::getVar( 'aSorting' );
00970         if ( isset( $aSorting[$sSortIdent] ) ) {
00971             return $aSorting[$sSortIdent];
00972         }
00973     }
00974 
00982     public function setListOrderBy( $sColumn )
00983     {
00984         $this->_sListOrderBy = $sColumn;
00985     }
00986 
00994     public function setListOrderDirection( $sDirection )
00995     {
00996         $this->_sListOrderDir = $sDirection;
00997     }
00998 
00999 
01000 
01013     public function prepareSortColumns()
01014     {
01015         $aSortColumns = $this->getConfig()->getConfigParam( 'aSortCols' );
01016         $aSortDir = array( 'desc', 'asc' );
01017         if ( count( $aSortColumns ) > 0 ) {
01018 
01019             $this->_aSortColumns = $aSortColumns;
01020 
01021             $sCnid = oxConfig::getParameter( 'cnid' );
01022 
01023 
01024             $sSortBy  = oxConfig::getParameter( $this->getSortOrderByParameterName() );
01025             $sSortDir = oxConfig::getParameter( $this->getSortOrderParameterName() );
01026 
01027             $oStr = getStr();
01028             if ( (!$sSortBy || !in_array( $oStr->strtolower($sSortBy), $aSortColumns) || !in_array( $oStr->strtolower($sSortDir), $aSortDir) ) && $aSorting = $this->getSorting( $sCnid ) ) {
01029                 $sSortBy  = $aSorting['sortby'];
01030                 $sSortDir = $aSorting['sortdir'];
01031             }
01032 
01033             if ( $sSortBy && oxDb::getInstance()->isValidFieldName( $sSortBy ) &&
01034                  $sSortDir && oxRegistry::getUtils()->isValidAlpha( $sSortDir ) ) {
01035 
01036                 $this->_sListOrderBy  = $sSortBy;
01037                 $this->_sListOrderDir = $sSortDir;
01038 
01039                 // caching sorting config
01040                 $this->setItemSorting( $sCnid, $sSortBy, $sSortDir );
01041             }
01042         }
01043     }
01044 
01050     public function getListOrderBy()
01051     {
01052         //if column is with table name split it
01053         $aColumns = explode('.', $this->_sListOrderBy);
01054 
01055         if ( is_array($aColumns) && count($aColumns) > 1 ) {
01056            return $aColumns[1];
01057         }
01058 
01059         return $this->_sListOrderBy;
01060     }
01061 
01067     public function getListOrderDirection()
01068     {
01069         return $this->_sListOrderDir;
01070     }
01071 
01079     public function setMetaDescription ( $sDescription )
01080     {
01081         return $this->_sMetaDescription = $sDescription;
01082     }
01083 
01091     public function setMetaKeywords( $sKeywords )
01092     {
01093         return $this->_sMetaKeywords = $sKeywords;
01094     }
01095 
01103     protected function _getMetaFromSeo( $sDataType )
01104     {
01105         $sOxid  = $this->_getSeoObjectId();
01106         $iLang  = oxRegistry::getLang()->getBaseLanguage();
01107         $sShop  = $this->getConfig()->getShopId();
01108 
01109         if ( $sOxid && oxRegistry::getUtils()->seoIsActive() &&
01110              ( $sKeywords = oxRegistry::get("oxSeoEncoder")->getMetaData( $sOxid, $sDataType, $sShop, $iLang) ) ) {
01111             return $sKeywords;
01112         }
01113     }
01114 
01122     protected function _getMetaFromContent( $sMetaIdent )
01123     {
01124         if ( $sMetaIdent ) {
01125             $oContent = oxNew( 'oxcontent' );
01126             if ( $oContent->loadByIdent( $sMetaIdent ) &&
01127                  $oContent->oxcontents__oxactive->value ) {
01128                 return getStr()->strip_tags( $oContent->oxcontents__oxcontent->value );
01129             }
01130         }
01131     }
01132 
01138     public function getMetaKeywords()
01139     {
01140         if ( $this->_sMetaKeywords === null ) {
01141             $this->_sMetaKeywords = false;
01142 
01143             // set special meta keywords ?
01144             if ( ( $sKeywords = $this->_getMetaFromSeo( 'oxkeywords' ) ) ) {
01145                 $this->_sMetaKeywords = $sKeywords;
01146             } elseif ( ( $sKeywords = $this->_getMetaFromContent( $this->_sMetaKeywordsIdent ) ) ) {
01147                 $this->_sMetaKeywords = $this->_prepareMetaKeyword( $sKeywords, false );
01148             } else {
01149                 $this->_sMetaKeywords = $this->_prepareMetaKeyword( false, true );
01150             }
01151         }
01152 
01153         return $this->_sMetaKeywords;
01154     }
01155 
01161     public function getMetaDescription()
01162     {
01163         if ( $this->_sMetaDescription === null ) {
01164             $this->_sMetaDescription = false;
01165 
01166             // set special meta description ?
01167             if ( ( $sDescription = $this->_getMetaFromSeo( 'oxdescription' ) ) ) {
01168                 $this->_sMetaDescription = $sDescription;
01169             } elseif ( ( $sDescription = $this->_getMetaFromContent( $this->_sMetaDescriptionIdent ) ) ) {
01170                 $this->_sMetaDescription = $this->_prepareMetaDescription( $sDescription );
01171             } else {
01172                 $this->_sMetaDescription = $this->_prepareMetaDescription( false );
01173             }
01174         }
01175 
01176         return $this->_sMetaDescription;
01177     }
01178 
01184     public function getActCurrency()
01185     {
01186         return $this->_oActCurrency;
01187     }
01188 
01196     public function setActCurrency( $oCur )
01197     {
01198         $this->_oActCurrency = $oCur;
01199     }
01200 
01206     public function getCompareItemCount()
01207     {
01208         if ( $this->_iCompItemsCnt === null ) {
01209             $aItems = oxSession::getVar('aFiltcompproducts');
01210             $this->_iCompItemsCnt = is_array($aItems)?count($aItems):0;
01211         }
01212         return $this->_iCompItemsCnt;
01213     }
01214 
01220     protected function _forceNoIndex()
01221     {
01222         $this->_blForceNoIndex = true;
01223     }
01224 
01231     public function noIndex()
01232     {
01233         if ( $this->_blForceNoIndex ) {
01234             $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
01235         } elseif ( oxConfig::getParameter( 'cur' ) ) {
01236             $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
01237         } else {
01238             switch ( oxConfig::getParameter( 'fnc' ) ) {
01239                 case 'tocomparelist':
01240                 case 'tobasket':
01241                     $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
01242                     break;
01243             }
01244         }
01245         return $this->_iViewIndexState;
01246     }
01247 
01255     public function isSortingActive()
01256     {
01257         return $this->_blActiveSorting;
01258     }
01259 
01265     public function getMenueList()
01266     {
01267         return $this->_aMenueList;
01268     }
01269 
01277     public function setMenueList( $aMenue )
01278     {
01279         $this->_aMenueList = $aMenue;
01280     }
01281 
01282 
01288     protected function _setNrOfArtPerPage()
01289     {
01290         $myConfig  = $this->getConfig();
01291 
01292         //setting default values to avoid possible errors showing article list
01293         $iNrofCatArticles = $myConfig->getConfigParam( 'iNrofCatArticles' );
01294 
01295         $iNrofCatArticles = ( $iNrofCatArticles ) ? $iNrofCatArticles : 10;
01296 
01297         // checking if all needed data is set
01298         switch ( $this->getListDisplayType() ) {
01299             case 'grid':
01300                 $aNrofCatArticles = $myConfig->getConfigParam( 'aNrofCatArticlesInGrid' );
01301                 break;
01302             case 'line':
01303             case 'infogrid':
01304             default:
01305                 $aNrofCatArticles = $myConfig->getConfigParam( 'aNrofCatArticles' );
01306         }
01307 
01308         if ( !is_array( $aNrofCatArticles ) || !isset( $aNrofCatArticles[0] ) ) {
01309             $myConfig->setConfigParam( 'aNrofCatArticles', array( $iNrofCatArticles ) );
01310         } else {
01311             $iNrofCatArticles = $aNrofCatArticles[0];
01312         }
01313 
01314         $oViewConf = $this->getViewConfig();
01315         //value from user input
01316         if ( ( $iNrofArticles = (int) oxConfig::getParameter( '_artperpage' ) ) ) {
01317             // M45 Possibility to push any "Show articles per page" number parameter
01318             $iNrofCatArticles = ( in_array( $iNrofArticles, $aNrofCatArticles ) ) ? $iNrofArticles : $iNrofCatArticles;
01319             $oViewConf->setViewConfigParam( 'iartPerPage', $iNrofCatArticles );
01320             oxSession::setVar( '_artperpage', $iNrofCatArticles );
01321         } elseif ( ( $iSessArtPerPage = oxSession::getVar( '_artperpage' ) )&& is_numeric( $iSessArtPerPage ) ) {
01322             // M45 Possibility to push any "Show articles per page" number parameter
01323             $iNrofCatArticles = ( in_array( $iSessArtPerPage, $aNrofCatArticles ) ) ? $iSessArtPerPage : $iNrofCatArticles;
01324             $oViewConf->setViewConfigParam( 'iartPerPage', $iSessArtPerPage );
01325             $iNrofCatArticles = $iSessArtPerPage;
01326         } else {
01327             $oViewConf->setViewConfigParam( 'iartPerPage', $iNrofCatArticles );
01328         }
01329 
01330         //setting number of articles per page to config value
01331         $myConfig->setConfigParam( 'iNrofCatArticles', $iNrofCatArticles );
01332     }
01333 
01339     protected function _getSeoObjectId()
01340     {
01341     }
01342 
01352     protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blRemoveDuplicatedWords = false )
01353     {
01354         if ( $sMeta ) {
01355 
01356             $oStr = getStr();
01357             if ( $iLength != -1 ) {
01358                 /* *
01359                  * performance - we do not need a huge amount of initial text.
01360                  * assume that effective text may be double longer than $iLength
01361                  * and simple truncate it
01362                  */
01363                 $iELength = ( $iLength * 2 );
01364                 $sMeta = $oStr->substr( $sMeta, 0, $iELength );
01365             }
01366 
01367             // decoding html entities
01368             $sMeta = $oStr->html_entity_decode( $sMeta );
01369             // stripping HTML tags
01370             $sMeta = $oStr->strip_tags( $sMeta );
01371 
01372             // removing some special chars
01373             $sMeta = $oStr->cleanStr( $sMeta );
01374 
01375             // removing duplicate words
01376             if ( $blRemoveDuplicatedWords ) {
01377                 $sMeta = $this->_removeDuplicatedWords( $sMeta, $this->getConfig()->getConfigParam( 'aSkipTags' ) );
01378             }
01379 
01380             // some special cases
01381             $sMeta = str_replace( ' ,', ',', $sMeta );
01382             $aPattern = array( "/,[\s\+\-\*]*,/", "/\s+,/" );
01383             $sMeta = $oStr->preg_replace( $aPattern, ',', $sMeta );
01384             $sMeta = oxRegistry::get("oxUtilsString")->minimizeTruncateString( $sMeta, $iLength );
01385             $sMeta = $oStr->htmlspecialchars( $sMeta );
01386 
01387             return trim( $sMeta );
01388         }
01389     }
01390 
01399     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
01400     {
01401 
01402         $sString = $this->_prepareMetaDescription( $sKeywords, -1, false );
01403 
01404         if ( $blRemoveDuplicatedWords ) {
01405             $sString = $this->_removeDuplicatedWords( $sString, $this->getConfig()->getConfigParam( 'aSkipTags' ) );
01406         }
01407 
01408        return trim( $sString );
01409     }
01410 
01419     protected function _removeDuplicatedWords( $aInput, $aSkipTags = array() )
01420     {
01421         $oStr = getStr();
01422         if ( is_array( $aInput ) ) {
01423             $aInput = implode( " ", $aInput );
01424         }
01425 
01426         // removing some usually met characters..
01427         $aInput = $oStr->preg_replace( "/[".preg_quote( $this->_sRemoveMetaChars, "/" )."]/", " ", $aInput );
01428 
01429         // splitting by word
01430         $aStrings = $oStr->preg_split( "/[\s,]+/", $aInput );
01431 
01432         if ( $sCount = count( $aSkipTags ) ) {
01433             for ( $iNum = 0; $iNum < $sCount; $iNum++ ) {
01434                 $aSkipTags[$iNum] = $oStr->strtolower( $aSkipTags[$iNum] );
01435             }
01436         }
01437         $sCount = count($aStrings);
01438         for ( $iNum = 0; $iNum < $sCount; $iNum++ ) {
01439             $aStrings[$iNum] = $oStr->strtolower( $aStrings[$iNum] );
01440             // removing in admin defined strings
01441             if ( !$aStrings[$iNum] || in_array( $aStrings[$iNum], $aSkipTags ) ) {
01442                 unset( $aStrings[$iNum] );
01443             }
01444         }
01445 
01446         // duplicates
01447         return implode( ', ', array_unique( $aStrings ) );
01448     }
01449 
01457     public function getNavigationParams()
01458     {
01459         $aParams['cnid'] = $this->getCategoryId();
01460         $aParams['mnid'] = oxConfig::getParameter( 'mnid' );
01461 
01462         $aParams['listtype'] = $this->getListType();
01463         $aParams['ldtype'] = $this->getCustomListDisplayType();
01464         $aParams['actcontrol'] = $this->getClassName();
01465 
01466         $aParams['recommid'] = oxConfig::getParameter( 'recommid' );
01467 
01468         $aParams['searchrecomm'] = oxConfig::getParameter( 'searchrecomm', true );
01469         $aParams['searchparam']  = oxConfig::getParameter( 'searchparam', true );
01470         $aParams['searchtag']    = oxConfig::getParameter( 'searchtag', true );
01471 
01472         $aParams['searchvendor'] = oxConfig::getParameter( 'searchvendor' );
01473         $aParams['searchcnid']   = oxConfig::getParameter( 'searchcnid' );
01474         $aParams['searchmanufacturer'] = oxConfig::getParameter( 'searchmanufacturer' );
01475 
01476         return $aParams;
01477     }
01478 
01488     public function setItemSorting( $sSortIdent, $sSortBy, $sSortDir = null )
01489     {
01490         $aSorting = oxSession::getVar( 'aSorting' );
01491         $aSorting[$sSortIdent]['sortby']  = $sSortBy;
01492         $aSorting[$sSortIdent]['sortdir'] = $sSortDir ? $sSortDir : null;
01493 
01494         oxSession::setVar( 'aSorting', $aSorting );
01495     }
01496 
01504     public function getSorting( $sSortIdent )
01505     {
01506         $aSorting = null;
01507 
01508         if ( $aSorting = $this->getUserSelectedSorting() ) {
01509             $this->setItemSorting( $sSortIdent, $aSorting['sortby'], $aSorting['sortdir'] );
01510         } elseif ( !$aSorting = $this->getSavedSorting( $sSortIdent ) ) {
01511             $aSorting = $this->getDefaultSorting();
01512         }
01513 
01514         if ( $aSorting ) {
01515             $this->setListOrderBy( $aSorting['sortby'] );
01516             $this->setListOrderDirection( $aSorting['sortdir'] );
01517         }
01518 
01519         return $aSorting;
01520     }
01521 
01529     public function getSortingSql( $sCnid )
01530     {
01531         $aSorting = $this->getSorting( $sCnid );
01532         if ( is_array( $aSorting ) ) {
01533             return implode( " ", $aSorting );
01534         }
01535     }
01536 
01542     public function getTitleSuffix()
01543     {
01544         return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
01545     }
01546 
01552     public function getTitlePageSuffix()
01553     {
01554     }
01555 
01562     public function getTitlePrefix()
01563     {
01564         return $this->getConfig()->getActiveShop()->oxshops__oxtitleprefix->value;
01565     }
01566 
01567 
01568 
01577     protected function _getSubject( $iLang )
01578     {
01579         return null;
01580     }
01581 
01587     public function getDynUrlParams()
01588     {
01589         $sRet = '';
01590         $sListType = $this->getListType();
01591 
01592         switch ($sListType) {
01593             default:
01594                 break;
01595             case 'search':
01596                 $sRet .= "&amp;listtype={$sListType}";
01597                 if ( $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
01598                     $sRet .= "&amp;searchparam={$sSearchParamForLink}";
01599                 }
01600 
01601                 if ( ( $sVar = oxConfig::getParameter( 'searchcnid', true ) ) ) {
01602                     $sRet .= '&amp;searchcnid='.rawurlencode( rawurldecode( $sVar ) );
01603                 }
01604                 if ( ( $sVar = oxConfig::getParameter( 'searchvendor', true ) ) ) {
01605                     $sRet .= '&amp;searchvendor='.rawurlencode( rawurldecode( $sVar ) );
01606                 }
01607                 if ( ( $sVar = oxConfig::getParameter( 'searchmanufacturer', true ) ) ) {
01608                     $sRet .= '&amp;searchmanufacturer='.rawurlencode( rawurldecode( $sVar ) );
01609                 }
01610                 break;
01611             case 'tag':
01612                 $sRet .= "&amp;listtype={$sListType}";
01613                 if ( $sParam = rawurlencode( oxConfig::getParameter( 'searchtag', true ) ) ) {
01614                     $sRet .= "&amp;searchtag={$sParam}";
01615                 }
01616                 break;
01617         }
01618 
01619         return $sRet;
01620     }
01621 
01629     public function getLink( $iLang = null )
01630     {
01631         if ( !isset( $iLang ) ) {
01632             $iLang = oxRegistry::getLang()->getBaseLanguage();
01633         }
01634 
01635         $oDisplayObj = null;
01636         $blTrySeo = false;
01637         if ( oxRegistry::getUtils()->seoIsActive() ) {
01638             $blTrySeo = true;
01639             $oDisplayObj = $this->_getSubject( $iLang );
01640         }
01641         $iActPageNr = $this->getActPage();
01642 
01643         if ( $oDisplayObj ) {
01644             return $this->_addPageNrParam( $oDisplayObj->getLink( $iLang ), $iActPageNr, $iLang );
01645         }
01646 
01647         $myConfig = $this->getConfig();
01648 
01649         if ( $blTrySeo ) {
01650             $oEncoder = oxRegistry::get("oxSeoEncoder");
01651             if ( ( $sSeoUrl = $oEncoder->getStaticUrl( $myConfig->getShopHomeURL( $iLang ) . $this->_getSeoRequestParams(), $iLang ) ) ) {
01652                 return $this->_addPageNrParam( $sSeoUrl, $iActPageNr, $iLang );
01653             }
01654         }
01655 
01656         $sUrl = oxRegistry::get("oxUtilsUrl")->processUrl( $myConfig->getShopCurrentURL( $iLang ) . $this->_getRequestParams(), true, null, $iLang);
01657 
01658         // fallback to old non seo url
01659         return $this->_addPageNrParam( $sUrl, $iActPageNr, $iLang );
01660     }
01661 
01667     public function getCanonicalUrl()
01668     {
01669     }
01670 
01677     public function getSimilarRecommListIds()
01678     {
01679         return false;
01680     }
01687     public function getSearchParamForHtml()
01688     {
01689     }
01690 
01698     protected function _getRequestParams( $blAddPageNr  = true )
01699     {
01700         $sClass = $this->getClassName();
01701         $sFnc   = $this->getFncName();
01702 
01703         $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher', 'moveleft', 'moveright' );
01704         if ( in_array( $sFnc, $aFnc ) ) {
01705             $sFnc = '';
01706         }
01707 
01708         // #680
01709         $sURL = "cl={$sClass}";
01710         if ( $sFnc ) {
01711             $sURL .= "&amp;fnc={$sFnc}";
01712         }
01713         if ( $sVal = oxConfig::getParameter( 'cnid' ) ) {
01714             $sURL .= "&amp;cnid={$sVal}";
01715         }
01716         if ( $sVal = oxConfig::getParameter( 'mnid' ) ) {
01717             $sURL .= "&amp;mnid={$sVal}";
01718         }
01719         if ( $sVal= oxConfig::getParameter( 'anid' ) ) {
01720             $sURL .= "&amp;anid={$sVal}";
01721         }
01722 
01723         if ( $sVal = basename( oxConfig::getParameter( 'page' ) ) ) {
01724             $sURL .= "&amp;page={$sVal}";
01725         }
01726 
01727         if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
01728             $sURL .= "&amp;tpl={$sVal}";
01729         }
01730 
01731         if ( $sVal = oxConfig::getParameter( 'oxloadid' ) ) {
01732             $sURL .= "&amp;oxloadid={$sVal}";
01733         }
01734 
01735         $iPgNr = (int) oxConfig::getParameter( 'pgNr' );
01736         // don't include page number for navigation
01737         // it will be done in oxubase::generatePageNavigation
01738         if ( $blAddPageNr && $iPgNr > 0 ) {
01739             $sURL .= "&amp;pgNr={$iPgNr}";
01740         }
01741 
01742         // #1184M - specialchar search
01743         if ( $sVal = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
01744             $sURL .= "&amp;searchparam={$sVal}";
01745         }
01746 
01747         if ( $sVal = oxConfig::getParameter( 'searchcnid' ) ) {
01748             $sURL .= "&amp;searchcnid={$sVal}";
01749         }
01750 
01751         if ( $sVal = oxConfig::getParameter( 'searchvendor' ) ) {
01752             $sURL .= "&amp;searchvendor={$sVal}";
01753         }
01754 
01755         if ( $sVal = oxConfig::getParameter( 'searchmanufacturer' ) ) {
01756             $sURL .= "&amp;searchmanufacturer={$sVal}";
01757         }
01758 
01759         if ( $sVal = oxConfig::getParameter( 'searchrecomm' ) ) {
01760             $sURL .= "&amp;searchrecomm={$sVal}";
01761         }
01762 
01763         if ( $sVal = oxConfig::getParameter( 'searchtag' ) ) {
01764             $sURL .= "&amp;searchtag={$sVal}";
01765         }
01766 
01767         if ( $sVal = oxConfig::getParameter( 'recommid' ) ) {
01768             $sURL .= "&amp;recommid={$sVal}";
01769         }
01770 
01771         return $sURL;
01772     }
01773 
01779     protected function _getSeoRequestParams()
01780     {
01781         $sClass = $this->getClassName();
01782         $sFnc   = $this->getFncName();
01783 
01784         // #921 S
01785         $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher' );
01786         if ( in_array( $sFnc, $aFnc ) ) {
01787             $sFnc = '';
01788         }
01789 
01790         // #680
01791         $sURL = "cl={$sClass}";
01792         if ( $sFnc ) {
01793             $sURL .= "&amp;fnc={$sFnc}";
01794         }
01795         if ( $sVal = basename( oxConfig::getParameter( 'page' ) ) ) {
01796             $sURL .= "&amp;page={$sVal}";
01797         }
01798 
01799         if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
01800             $sURL .= "&amp;tpl={$sVal}";
01801         }
01802 
01803         if ( $sVal = oxConfig::getParameter( 'oxloadid' ) ) {
01804             $sURL .= "&amp;oxloadid={$sVal}";
01805         }
01806 
01807         $iPgNr = (int) oxConfig::getParameter( 'pgNr' );
01808         if ( $iPgNr > 0 ) {
01809             $sURL .= "&amp;pgNr={$iPgNr}";
01810         }
01811 
01812         return $sURL;
01813     }
01814 
01820     public function showSearch()
01821     {
01822         $blShow = true;
01823         if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) && $this->getIsOrderStep() ) {
01824             $blShow = false;
01825         }
01826         return (int) $blShow;
01827     }
01828 
01834     public function getRssLinks()
01835     {
01836         return $this->_aRssLinks;
01837     }
01838 
01844     public function getSortColumns()
01845     {
01846         if ( $this->_aSortColumns === null ) {
01847             $this->setSortColumns( $this->getConfig()->getConfigParam( 'aSortCols' ) );
01848         }
01849         return $this->_aSortColumns;
01850     }
01851 
01852 
01860     public function setSortColumns( $aSortColumns )
01861     {
01862         $this->_aSortColumns = $aSortColumns;
01863     }
01864 
01870     public function getEditTags()
01871     {
01872     }
01873 
01879     public function getRecommSearch()
01880     {
01881     }
01882 
01888     public function getPaymentList()
01889     {
01890     }
01891 
01897     public function getActiveRecommList()
01898     {
01899         if ( $this->_oActiveRecommList === null ) {
01900             $this->_oActiveRecommList = false;
01901             if ( $sOxid = oxConfig::getParameter( 'recommid' ) ) {
01902                 $this->_oActiveRecommList = oxNew( 'oxrecommlist' );
01903                 $this->_oActiveRecommList->load( $sOxid );
01904             }
01905         }
01906         return $this->_oActiveRecommList;
01907     }
01908 
01914     public function getAccessoires()
01915     {
01916     }
01917 
01923     public function getCrossSelling()
01924     {
01925     }
01926 
01932     public function getSimilarProducts()
01933     {
01934     }
01935 
01941     public function getAlsoBoughtTheseProducts()
01942     {
01943     }
01944 
01950     public function getArticleId()
01951     {
01952     }
01953 
01959     public function getTitle()
01960     {
01961         $sTranslationName = 'PAGE_TITLE_'.strtoupper($this->getConfig()->getActiveView()->getClassName());
01962         $sTranslated = oxRegistry::getLang()->translateString( $sTranslationName, oxRegistry::getLang()->getBaseLanguage(), false );
01963         return $sTranslationName == $sTranslated? null : $sTranslated;
01964     }
01965 
01971     public function getActiveLangAbbr()
01972     {
01973         // Performance
01974         if ( !$this->getConfig()->getConfigParam( 'bl_perfLoadLanguages' ) ) {
01975             return;
01976         }
01977 
01978         if ( !isset($this->_sActiveLangAbbr ) ) {
01979             $aLanguages = oxRegistry::getLang()->getLanguageArray();
01980             while ( list( $sKey, $oVal ) = each( $aLanguages ) ) {
01981                 if ( $oVal->selected ) {
01982                     $this->_sActiveLangAbbr = $oVal->abbr;
01983                     break;
01984                 }
01985             }
01986         }
01987 
01988         return $this->_sActiveLangAbbr;
01989     }
01990 
01998     public function addGlobalParams( $oShop = null)
01999     {
02000         $oViewConf = parent::addGlobalParams( $oShop );
02001 
02002         $this->_setNrOfArtPerPage();
02003 
02004         return $oViewConf;
02005     }
02006 
02012     public function getAdditionalParams()
02013     {
02014         if ( $this->_sAdditionalParams === null ) {
02015             // #1018A
02016             $this->_sAdditionalParams  = parent::getAdditionalParams();
02017             $this->_sAdditionalParams .= 'cl='.$this->getConfig()->getActiveView()->getClassName();
02018 
02019             // #1834M - specialchar search
02020             $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) );
02021             if ( isset( $sSearchParamForLink ) ) {
02022                 $this->_sAdditionalParams .= "&amp;searchparam={$sSearchParamForLink}";
02023             }
02024             if ( ( $sVar = oxConfig::getParameter( 'searchtag' ) ) ) {
02025                 $this->_sAdditionalParams .= '&amp;searchtag='.rawurlencode( rawurldecode( $sVar ) );
02026             }
02027             if ( ( $sVar = oxConfig::getParameter( 'searchcnid' ) ) ) {
02028                 $this->_sAdditionalParams .= '&amp;searchcnid='.rawurlencode( rawurldecode( $sVar ) );
02029             }
02030             if ( ( $sVar = oxConfig::getParameter( 'searchvendor' ) ) ) {
02031                 $this->_sAdditionalParams .= '&amp;searchvendor='.rawurlencode( rawurldecode( $sVar ) );
02032             }
02033             if ( ( $sVar = oxConfig::getParameter( 'searchmanufacturer' ) ) ) {
02034                 $this->_sAdditionalParams .= '&amp;searchmanufacturer='.rawurlencode( rawurldecode( $sVar ) );
02035             }
02036             if ( ( $sVar = oxConfig::getParameter( 'cnid' ) ) ) {
02037                 $this->_sAdditionalParams .= '&amp;cnid='.rawurlencode( rawurldecode( $sVar ) );
02038             }
02039             if ( ( $sVar = oxConfig::getParameter( 'mnid' ) ) ) {
02040                 $this->_sAdditionalParams .= '&amp;mnid='.rawurlencode( rawurldecode( $sVar ) );
02041             }
02042         }
02043 
02044         return $this->_sAdditionalParams;
02045     }
02046 
02052     public function generatePageNavigationUrl()
02053     {
02054         return $this->getConfig()->getShopHomeURL().$this->_getRequestParams( false );
02055     }
02056 
02066     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null )
02067     {
02068         if ( $iPage ) {
02069             if ( ( strpos( $sUrl, 'pgNr=' ) ) ) {
02070                 $sUrl = preg_replace('/pgNr=[0-9]*/', 'pgNr='.$iPage, $sUrl);
02071             } else {
02072                 $sUrl .= ( ( strpos( $sUrl, '?' ) === false ) ? '?' : '&amp;' ) . 'pgNr='.$iPage;
02073             }
02074         } else {
02075            $sUrl = preg_replace('/pgNr=[0-9]*/', '', $sUrl);
02076            $sUrl = preg_replace('/\&amp\;\&amp\;/', '&amp;', $sUrl);
02077            $sUrl = preg_replace('/\?\&amp\;/', '?', $sUrl);
02078            $sUrl = preg_replace('/\&amp\;$/', '', $sUrl);
02079         }
02080         return $sUrl;
02081     }
02082 
02088     public function getPageNavigation()
02089     {
02090 
02091     }
02092 
02098     public function getPageNavigationLimitedTop()
02099     {
02100 
02101         $this->_oPageNavigation = $this->generatePageNavigation( 7 );
02102 
02103         return $this->_oPageNavigation;
02104     }
02105 
02111     public function getPageNavigationLimitedBottom()
02112     {
02113 
02114         $this->_oPageNavigation = $this->generatePageNavigation( 11 );
02115 
02116         return $this->_oPageNavigation;
02117     }
02118 
02119 
02127     public function generatePageNavigation( $iPositionCount = 0 )
02128     {
02129         startProfile('generatePageNavigation');
02130 
02131         $pageNavigation = new stdClass();
02132 
02133         $pageNavigation->NrOfPages = $this->_iCntPages;
02134         $iActPage = $this->getActPage();
02135         $pageNavigation->actPage   = $iActPage + 1;
02136         $sUrl = $this->generatePageNavigationUrl();
02137 
02138         if ( $iPositionCount == 0 || ($iPositionCount >= $pageNavigation->NrOfPages) ) {
02139              $iStartNo = 2;
02140              $iFinishNo = $pageNavigation->NrOfPages;
02141              $bStart = false;
02142              $bFinish =false;
02143         } else {
02144             $iTmpVal = $iPositionCount - 3;
02145             $iTmpVal2 = floor( ( $iPositionCount - 4 ) / 2 );
02146 
02147             // actual page is at the start
02148             if ( $pageNavigation->actPage <= $iTmpVal ) {
02149                 $iStartNo = 2;
02150                 $iFinishNo = $iTmpVal + 1;
02151                 $bStart = false;
02152                 $bFinish = true;
02153             // actual page is at the end
02154             } elseif ( $pageNavigation->actPage >= $pageNavigation->NrOfPages - $iTmpVal ) {
02155                 $iStartNo = $pageNavigation->NrOfPages - $iTmpVal;
02156                 $iFinishNo = $pageNavigation->NrOfPages - 1;
02157                 $bStart = true;
02158                 $bFinish = false;
02159             // actual page is in the midle
02160             } else {
02161                 $iStartNo = $pageNavigation->actPage - $iTmpVal2;
02162                 $iFinishNo = $pageNavigation->actPage + $iTmpVal2;
02163                 $bStart = true;
02164                 $bFinish = true;
02165             }
02166         }
02167 
02168         if ( $iActPage > 0) {
02169             $pageNavigation->previousPage = $this->_addPageNrParam( $sUrl, $iActPage - 1 );
02170         }
02171 
02172         if ( $iActPage < $pageNavigation->NrOfPages - 1 ) {
02173             $pageNavigation->nextPage = $this->_addPageNrParam( $sUrl, $iActPage + 1 );
02174         }
02175 
02176         if ( $pageNavigation->NrOfPages > 1 ) {
02177 
02178             for ( $i=1; $i < $pageNavigation->NrOfPages + 1; $i++ ) {
02179 
02180                 if ( $i == 1 || $i == $pageNavigation->NrOfPages || ( $i >= $iStartNo && $i <= $iFinishNo ) ) {
02181                     $page = new stdClass();
02182                     $page->url = $this->_addPageNrParam( $sUrl, $i - 1 );
02183                     $page->selected = ( $i == $pageNavigation->actPage ) ? 1 : 0;
02184                     $pageNavigation->changePage[$i] = $page;
02185                 }
02186             }
02187 
02188             // first/last one
02189             $pageNavigation->firstpage = $this->_addPageNrParam( $sUrl, 0 );
02190             $pageNavigation->lastpage  = $this->_addPageNrParam( $sUrl, $pageNavigation->NrOfPages - 1 );
02191         }
02192 
02193         stopProfile('generatePageNavigation');
02194 
02195         return $pageNavigation;
02196     }
02197 
02204     public function render()
02205     {
02206         foreach ( array_keys( $this->_oaComponents ) as $sComponentName ) {
02207             $this->_aViewData[$sComponentName] = $this->_oaComponents[$sComponentName]->render();
02208         }
02209 
02210         parent::render();
02211 
02212         if ( $this->getIsOrderStep() ) {
02213 
02214             // disabling navigation during order ...
02215             if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) ) {
02216                 $this->_iNewsRealStatus = 1;
02217                 $this->setShowNewsletter( 0 );
02218             }
02219         }
02220         return $this->_sThisTemplate;
02221     }
02222 
02228     public function getViewProduct()
02229     {
02230         return $this->getProduct();
02231     }
02232 
02240     public function setViewProduct( $oProduct )
02241     {
02242         $this->_oProduct = $oProduct;
02243     }
02244 
02250     public function getViewProductList()
02251     {
02252         return $this->_aArticleList;
02253     }
02254 
02260     public function getActPage()
02261     {
02262         if ( $this->_iActPage === null ) {
02263             $this->_iActPage = ( int ) oxConfig::getParameter( 'pgNr' );
02264             $this->_iActPage = ( $this->_iActPage < 0 ) ? 0 : $this->_iActPage;
02265         }
02266         return $this->_iActPage;
02267     }
02268 
02276     public function getActTag()
02277     {
02278         if ( $this->_oActTag === null ) {
02279             $this->_oActTag = new stdClass();
02280             $this->_oActTag->sTag = $sTag = oxConfig::getParameter("searchtag", 1);
02281             $oSeoEncoderTag = oxRegistry::get("oxSeoEncoderTag");
02282 
02283             $sLink = false;
02284             if ( oxRegistry::getUtils()->seoIsActive() ) {
02285                 $sLink = $oSeoEncoderTag->getTagUrl( $sTag, oxRegistry::getLang()->getBaseLanguage() );
02286             }
02287 
02288             $this->_oActTag->link = $sLink ? $sLink : $this->getConfig()->getShopHomeURL().$oSeoEncoderTag->getStdTagUri( $sTag, false );
02289         }
02290         return $this->_oActTag;
02291     }
02292 
02300     public function getActVendor()
02301     {
02302         // if active vendor is not set yet - trying to load it from request params
02303         // this may be usefull when category component was unable to load active vendor
02304         // and we still need some object to mount navigation info
02305         if ( $this->_oActVendor === null ) {
02306             $this->_oActVendor = false;
02307             $sVendorId = oxConfig::getParameter( 'cnid' );
02308             $sVendorId = $sVendorId ? str_replace( 'v_', '', $sVendorId ) : $sVendorId;
02309             $oVendor = oxNew( 'oxvendor' );
02310             if ( $oVendor->load( $sVendorId ) ) {
02311                 $this->_oActVendor = $oVendor;
02312             }
02313         }
02314 
02315         return $this->_oActVendor;
02316     }
02317 
02325     public function getActManufacturer()
02326     {
02327         // if active Manufacturer is not set yet - trying to load it from request params
02328         // this may be usefull when category component was unable to load active Manufacturer
02329         // and we still need some object to mount navigation info
02330         if ( $this->_oActManufacturer === null ) {
02331 
02332             $this->_oActManufacturer = false;
02333             $sManufacturerId = oxConfig::getParameter( 'mnid' );
02334             $oManufacturer = oxNew( 'oxmanufacturer' );
02335             if ( $oManufacturer->load( $sManufacturerId ) ) {
02336                 $this->_oActManufacturer = $oManufacturer;
02337             }
02338         }
02339 
02340         return $this->_oActManufacturer;
02341     }
02342 
02350     public function setActVendor( $oVendor )
02351     {
02352         $this->_oActVendor = $oVendor;
02353     }
02354 
02362     public function setActManufacturer( $oManufacturer )
02363     {
02364         $this->_oActManufacturer = $oManufacturer;
02365     }
02366 
02372     public function getActSearch()
02373     {
02374         if ( $this->_oActSearch === null ) {
02375             $this->_oActSearch = new stdClass();
02376             $sUrl = $this->getConfig()->getShopHomeURL();
02377             $this->_oActSearch->link = "{$sUrl}cl=search";
02378         }
02379         return $this->_oActSearch;
02380     }
02381 
02387     public function getCategoryTree()
02388     {
02389         return $this->_oCategoryTree;
02390     }
02391 
02399     public function setCategoryTree( $oCatTree )
02400     {
02401         $this->_oCategoryTree = $oCatTree;
02402     }
02403 
02409     public function getManufacturerTree()
02410     {
02411         return $this->_oManufacturerTree;
02412     }
02413 
02421     public function setManufacturerTree( $oManufacturerTree )
02422     {
02423         $this->_oManufacturerTree = $oManufacturerTree;
02424     }
02425 
02431     public function getAddUrlParams()
02432     {
02433     }
02434 
02443     public function getTop5ArticleList( $iCount = null )
02444     {
02445         if ( $this->_blTop5Action ) {
02446             if ( $this->_aTop5ArticleList === null ) {
02447                 $this->_aTop5ArticleList = false;
02448                 $myConfig = $this->getConfig();
02449                 if ( $myConfig->getConfigParam( 'bl_perfLoadAktion' ) ) {
02450                     // top 5 articles
02451                     $oArtList = oxNew( 'oxarticlelist' );
02452                     $oArtList->loadTop5Articles( $iCount );
02453                     if ( $oArtList->count() ) {
02454                         $this->_aTop5ArticleList = $oArtList;
02455                     }
02456                 }
02457             }
02458         }
02459         return $this->_aTop5ArticleList;
02460     }
02461 
02468     public function getBargainArticleList()
02469     {
02470         if ( $this->_blBargainAction ) {
02471             if ( $this->_aBargainArticleList === null ) {
02472                 $this->_aBargainArticleList = array();
02473                 if ( $this->getConfig()->getConfigParam( 'bl_perfLoadAktion' ) ) {
02474                     $oArtList = oxNew( 'oxarticlelist' );
02475                     $oArtList->loadActionArticles( 'OXBARGAIN' );
02476                     if ( $oArtList->count() ) {
02477                         $this->_aBargainArticleList = $oArtList;
02478                     }
02479                 }
02480             }
02481         }
02482         return $this->_aBargainArticleList;
02483     }
02484 
02491     public function isLowOrderPrice()
02492     {
02493         if ( $this->_blLowOrderPrice === null && ( $oBasket = $this->getSession()->getBasket() ) ) {
02494             $this->_blLowOrderPrice = $oBasket->isBelowMinOrderPrice();
02495         }
02496 
02497         return $this->_blLowOrderPrice;
02498     }
02499 
02505     public function getMinOrderPrice()
02506     {
02507         if ( $this->_sMinOrderPrice === null && $this->isLowOrderPrice() ) {
02508             $dMinOrderPrice = oxPrice::getPriceInActCurrency( $this->getConfig()->getConfigParam( 'iMinOrderPrice' ) );
02509             $this->_sMinOrderPrice = oxRegistry::getLang()->formatCurrency( $dMinOrderPrice );
02510         }
02511         return $this->_sMinOrderPrice;
02512     }
02513 
02519     public function getNewsRealStatus()
02520     {
02521         return $this->_iNewsRealStatus;
02522     }
02523 
02529     protected function _canRedirect()
02530     {
02531         foreach ( $this->_aBlockRedirectParams as $sParam ) {
02532             if ( oxConfig::getParameter( $sParam ) !== null ) {
02533                 return false;
02534             }
02535         }
02536 
02537         return true;
02538     }
02539 
02545     public function getProduct()
02546     {
02547     }
02548 
02554     public function getManufacturerlist()
02555     {
02556         return $this->_aManufacturerlist;
02557     }
02558 
02566     public function setManufacturerlist( $aList )
02567     {
02568         $this->_aManufacturerlist = $aList;
02569     }
02570 
02578     public function setRootVendor( $oVendor )
02579     {
02580         $this->_oRootVendor = $oVendor;
02581     }
02582 
02588     public function getRootVendor()
02589     {
02590         return $this->_oRootVendor;
02591     }
02592 
02600     public function setRootManufacturer( $oManufacturer )
02601     {
02602         $this->_oRootManufacturer = $oManufacturer;
02603     }
02604 
02610     public function getRootManufacturer()
02611     {
02612         return $this->_oRootManufacturer;
02613     }
02614 
02620     public function getVendorId()
02621     {
02622         if ( $this->_sVendorId === null ) {
02623             $this->_sVendorId = false;
02624             if ( ( $oVendor = $this->getActVendor() ) ) {
02625                 $this->_sVendorId = $oVendor->getId();
02626             }
02627         }
02628         return $this->_sVendorId;
02629     }
02630 
02636     public function getManufacturerId()
02637     {
02638         if ( $this->_sManufacturerId === null ) {
02639             $this->_sManufacturerId = false;
02640             if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
02641                 $this->_sManufacturerId = $oManufacturer->getId();
02642             }
02643         }
02644         return $this->_sManufacturerId;
02645     }
02646 
02654     public function getSearchCatTree()
02655     {
02656         return $this->_aSearchCatTree;
02657     }
02658 
02668     public function setSearchCatTree( $aTree )
02669     {
02670         $this->_aSearchCatTree = $aTree;
02671     }
02672 
02678     public function getCatMoreUrl()
02679     {
02680         return $this->getConfig()->getShopHomeURL().'cnid=oxmore';
02681     }
02682 
02688     public function getCatTreePath()
02689     {
02690         return $this->_sCatTreePath;
02691     }
02692 
02700     public function getContentByIdent( $sIdent )
02701     {
02702         if ( !isset( $this->_aContents[$sIdent] ) ) {
02703             $this->_aContents[$sIdent] = oxNew( 'oxcontent' );
02704             $this->_aContents[$sIdent]->loadByIdent( $sIdent );
02705         }
02706         return $this->_aContents[$sIdent];
02707     }
02708 
02714     public function getContentCategory()
02715     {
02716         return false;
02717     }
02718 
02724     public function getMustFillFields()
02725     {
02726         if ( $this->_aMustFillFields === null ) {
02727             $this->_aMustFillFields = false;
02728 
02729             // passing must-be-filled-fields info
02730             $aMustFillFields = $this->getConfig()->getConfigParam( 'aMustFillFields' );
02731             if ( is_array( $aMustFillFields ) ) {
02732                 $this->_aMustFillFields = array_flip( $aMustFillFields );
02733             }
02734         }
02735         return $this->_aMustFillFields;
02736     }
02737 
02745     public function isFieldRequired( $sField )
02746     {
02747         if ( $aMustFillFields = $this->getMustFillFields() ) {
02748             if ( isset( $aMustFillFields[$sField] ) ) {
02749                 return true;
02750             }
02751         }
02752 
02753         return false;
02754     }
02755 
02761     public function getFormId()
02762     {
02763         if ( $this->_sFormId === null ) {
02764             $this->_sFormId = oxUtilsObject::getInstance()->generateUId();
02765             oxSession::setVar( 'sessionuformid', $this->_sFormId );
02766         }
02767 
02768         return $this->_sFormId;
02769     }
02770 
02776     public function canAcceptFormData()
02777     {
02778         if ( $this->_blCanAcceptFormData === null ) {
02779             $this->_blCanAcceptFormData = false;
02780 
02781             $sFormId = oxConfig::getParameter( "uformid" );
02782             $sSessionFormId = oxSession::getVar( "sessionuformid" );
02783 
02784             // testing if form and session ids matches
02785             if ( $sFormId && $sFormId === $sSessionFormId ) {
02786                 $this->_blCanAcceptFormData = true;
02787             }
02788 
02789             // regenerating form data
02790             $this->getFormId();
02791         }
02792         return $this->_blCanAcceptFormData;
02793     }
02794 
02800     public function getPromoFinishedList()
02801     {
02802         if (isset($this->_oPromoFinishedList)) {
02803             return $this->_oPromoFinishedList;
02804         }
02805         $this->_oPromoFinishedList = oxNew( 'oxActionList' );
02806         $this->_oPromoFinishedList->loadFinishedByCount(2);
02807         return $this->_oPromoFinishedList;
02808     }
02809 
02815     public function getPromoCurrentList()
02816     {
02817         if (isset($this->_oPromoCurrentList)) {
02818             return $this->_oPromoCurrentList;
02819         }
02820         $this->_oPromoCurrentList = oxNew( 'oxActionList' );
02821         $this->_oPromoCurrentList->loadCurrent();
02822         return $this->_oPromoCurrentList;
02823     }
02824 
02830     public function getPromoFutureList()
02831     {
02832         if (isset($this->_oPromoFutureList)) {
02833             return $this->_oPromoFutureList;
02834         }
02835         $this->_oPromoFutureList = oxNew( 'oxActionList' );
02836         $this->_oPromoFutureList->loadFutureByCount(2);
02837         return $this->_oPromoFutureList;
02838     }
02839 
02845     public function getShowPromotionList()
02846     {
02847         if (isset($this->_blShowPromotions)) {
02848             return $this->_blShowPromotions;
02849         }
02850         $this->_blShowPromotions = false;
02851         if (oxNew('oxActionList')->areAnyActivePromotions()) {
02852             $this->_blShowPromotions = ( count( $this->getPromoFinishedList() ) + count( $this->getPromoCurrentList() ) + count( $this->getPromoFutureList() ) ) > 0;
02853         }
02854         return $this->_blShowPromotions;
02855     }
02856 
02862     public function isEnabledPrivateSales()
02863     {
02864         if ( $this->_blEnabledPrivateSales === null ) {
02865             $this->_blEnabledPrivateSales = (bool) $this->getConfig()->getConfigParam( 'blPsLoginEnabled' );
02866             if ( $this->_blEnabledPrivateSales && ( $blCanPreview = oxRegistry::getUtils()->canPreview() ) !== null ) {
02867                 $this->_blEnabledPrivateSales = !$blCanPreview;
02868             }
02869         }
02870         return $this->_blEnabledPrivateSales;
02871     }
02872 
02878     public function getFieldValidationErrors()
02879     {
02880         return oxRegistry::get("oxInputValidator")->getFieldValidationErrors();
02881     }
02882 
02888     public function getBreadCrumb()
02889     {
02890         return null;
02891     }
02892 
02900     public function setRootCatChanged( $blRootCatChanged )
02901     {
02902         $this->_blRootCatChanged = $blRootCatChanged;
02903     }
02904 
02910     public function isRootCatChanged()
02911     {
02912         return $this->_blRootCatChanged;
02913     }
02914 
02920     public function getInvoiceAddress()
02921     {
02922         if ( $this->_aInvoiceAddress == null ) {
02923             $aAddress = oxConfig::getParameter( 'invadr');
02924             if ( $aAddress ) {
02925                 $this->_aInvoiceAddress = $aAddress;
02926             }
02927         }
02928         return $this->_aInvoiceAddress;
02929     }
02930 
02936     public function getDeliveryAddress()
02937     {
02938         if ( $this->_aDeliveryAddress == null ) {
02939             $oConfig = $this->getConfig();
02940             //do not show deladr if address was reloaded
02941             if ( !$oConfig->getRequestParameter( 'reloadaddress' ) ) {
02942                 $this->_aDeliveryAddress = $oConfig->getRequestParameter( 'deladr');
02943             }
02944         }
02945         return $this->_aDeliveryAddress;
02946     }
02947 
02955     public function setDeliveryAddress($aDeliveryAddress)
02956     {
02957         $this->_aDeliveryAddress = $aDeliveryAddress;
02958     }
02959 
02967     public function setInvoiceAddress( $aAddress )
02968     {
02969         $this->_aInvoiceAddress = $aAddress;
02970     }
02971 
02977     public function getActiveUsername()
02978     {
02979         if ( $this->_sActiveUsername == null ) {
02980             $this->_sActiveUsername = false;
02981             $sUsername = oxConfig::getParameter( 'lgn_usr' );
02982             if ( $sUsername ) {
02983                 $this->_sActiveUsername = $sUsername;
02984             } elseif ( $oUser = $this->getUser() ) {
02985                 $this->_sActiveUsername = $oUser->oxuser__oxusername->value;
02986             }
02987         }
02988         return $this->_sActiveUsername;
02989     }
02990 
02996     public function getWishlistUserId()
02997     {
02998         return oxConfig::getParameter( 'wishid' );
02999     }
03000 
03006     public function getSearchCatId()
03007     {
03008     }
03009 
03015     public function getSearchVendor()
03016     {
03017     }
03018 
03024     public function getSearchManufacturer()
03025     {
03026     }
03027 
03033     public function getLastProducts()
03034     {
03035 
03036     }
03037 
03043     public function getNewBasketItemMsgType()
03044     {
03045         return (int) $this->getConfig()->getConfigParam( "iNewBasketItemMessage" );
03046     }
03047 
03055     public function isActive( $sName )
03056     {
03057         return $this->getConfig()->getConfigParam( "bl".$sName."Enabled" );
03058     }
03059 
03065     public function isFbWidgetVisible()
03066     {
03067         if ( $this->_blFbWidgetsOn === null ) {
03068             $oUtils = oxRegistry::get("oxUtilsServer");
03069 
03070             // reading ..
03071             $this->_blFbWidgetsOn = (bool) $oUtils->getOxCookie( "fbwidgetson" );
03072         }
03073         return $this->_blFbWidgetsOn;
03074     }
03075 
03081     public function isEnabledDownloadableFiles()
03082     {
03083         return (bool) $this->getConfig()->getConfigParam( "blEnableDownloads" );
03084     }
03085 
03091     public function showRememberMe()
03092     {
03093         return (bool) $this->getConfig()->getConfigParam('blShowRememberMe');
03094     }
03095 
03102     public function isVatIncluded()
03103     {
03104         $blResult = true;
03105         $oUser = $this->getUser();
03106         $oConfig = $this->getConfig();
03107 
03108         if ( $oConfig->getConfigParam( 'blShowNetPrice' ) || $oConfig->getConfigParam( 'bl_perfCalcVatOnlyForBasketOrder' ) ) {
03109             $blResult = false;
03110         } elseif ( $oUser && $oUser->isPriceViewModeNetto() ) {
03111             $blResult = false;
03112         }
03113 
03114         return $blResult;
03115     }
03116 
03122     public function isPriceCalculated()
03123     {
03124         return (bool) $this->getConfig()->getConfigParam( 'bl_perfLoadPrice' );
03125     }
03126 
03132     public function showTags()
03133     {
03134          return (bool) $this->_blShowTagCloud && $this->getConfig()->getConfigParam( "blShowTags" );
03135     }
03136 
03142     public function getWishlistName()
03143     {
03144         if ( $this->getUser() ) {
03145             $sUserId = oxConfig::getParameter( 'wishid') ? oxConfig::getParameter( 'wishid' ): oxSession::getVar( 'wishid');
03146             if ( $sUserId ) {
03147                 $oWishUser = oxNew( 'oxuser' );
03148                 if ( $oWishUser->load( $sUserId ) ) {
03149                     return $oWishUser;
03150                 }
03151             }
03152         }
03153         return false;
03154     }
03155 
03156 }