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             $aNrofCatArticles = array( $iNrofCatArticles );
01310             $myConfig->setConfigParam( 'aNrofCatArticles', $aNrofCatArticles );
01311         } else {
01312             $iNrofCatArticles = $aNrofCatArticles[0];
01313         }
01314 
01315         $oViewConf = $this->getViewConfig();
01316         //value from user input
01317         if ( ( $iNrofArticles = (int) oxConfig::getParameter( '_artperpage' ) ) ) {
01318             // M45 Possibility to push any "Show articles per page" number parameter
01319             $iNrofCatArticles = ( in_array( $iNrofArticles, $aNrofCatArticles ) ) ? $iNrofArticles : $iNrofCatArticles;
01320             $oViewConf->setViewConfigParam( 'iartPerPage', $iNrofCatArticles );
01321             oxSession::setVar( '_artperpage', $iNrofCatArticles );
01322         } elseif ( ( $iSessArtPerPage = oxSession::getVar( '_artperpage' ) )&& is_numeric( $iSessArtPerPage ) ) {
01323             // M45 Possibility to push any "Show articles per page" number parameter
01324             $iNrofCatArticles = ( in_array( $iSessArtPerPage, $aNrofCatArticles ) ) ? $iSessArtPerPage : $iNrofCatArticles;
01325             $oViewConf->setViewConfigParam( 'iartPerPage', $iSessArtPerPage );
01326             $iNrofCatArticles = $iSessArtPerPage;
01327         } else {
01328             $oViewConf->setViewConfigParam( 'iartPerPage', $iNrofCatArticles );
01329         }
01330 
01331         //setting number of articles per page to config value
01332         $myConfig->setConfigParam( 'iNrofCatArticles', $iNrofCatArticles );
01333     }
01334 
01340     protected function _getSeoObjectId()
01341     {
01342     }
01343 
01353     protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blRemoveDuplicatedWords = false )
01354     {
01355         if ( $sMeta ) {
01356 
01357             $oStr = getStr();
01358             if ( $iLength != -1 ) {
01359                 /* *
01360                  * performance - we do not need a huge amount of initial text.
01361                  * assume that effective text may be double longer than $iLength
01362                  * and simple truncate it
01363                  */
01364                 $iELength = ( $iLength * 2 );
01365                 $sMeta = $oStr->substr( $sMeta, 0, $iELength );
01366             }
01367 
01368             // decoding html entities
01369             $sMeta = $oStr->html_entity_decode( $sMeta );
01370             // stripping HTML tags
01371             $sMeta = $oStr->strip_tags( $sMeta );
01372 
01373             // removing some special chars
01374             $sMeta = $oStr->cleanStr( $sMeta );
01375 
01376             // removing duplicate words
01377             if ( $blRemoveDuplicatedWords ) {
01378                 $sMeta = $this->_removeDuplicatedWords( $sMeta, $this->getConfig()->getConfigParam( 'aSkipTags' ) );
01379             }
01380 
01381             // some special cases
01382             $sMeta = str_replace( ' ,', ',', $sMeta );
01383             $aPattern = array( "/,[\s\+\-\*]*,/", "/\s+,/" );
01384             $sMeta = $oStr->preg_replace( $aPattern, ',', $sMeta );
01385             $sMeta = oxRegistry::get("oxUtilsString")->minimizeTruncateString( $sMeta, $iLength );
01386             $sMeta = $oStr->htmlspecialchars( $sMeta );
01387 
01388             return trim( $sMeta );
01389         }
01390     }
01391 
01400     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
01401     {
01402 
01403         $sString = $this->_prepareMetaDescription( $sKeywords, -1, false );
01404 
01405         if ( $blRemoveDuplicatedWords ) {
01406             $sString = $this->_removeDuplicatedWords( $sString, $this->getConfig()->getConfigParam( 'aSkipTags' ) );
01407         }
01408 
01409        return trim( $sString );
01410     }
01411 
01420     protected function _removeDuplicatedWords( $aInput, $aSkipTags = array() )
01421     {
01422         $oStr = getStr();
01423         if ( is_array( $aInput ) ) {
01424             $aInput = implode( " ", $aInput );
01425         }
01426 
01427         // removing some usually met characters..
01428         $aInput = $oStr->preg_replace( "/[".preg_quote( $this->_sRemoveMetaChars, "/" )."]/", " ", $aInput );
01429 
01430         // splitting by word
01431         $aStrings = $oStr->preg_split( "/[\s,]+/", $aInput );
01432 
01433         if ( $sCount = count( $aSkipTags ) ) {
01434             for ( $iNum = 0; $iNum < $sCount; $iNum++ ) {
01435                 $aSkipTags[$iNum] = $oStr->strtolower( $aSkipTags[$iNum] );
01436             }
01437         }
01438         $sCount = count($aStrings);
01439         for ( $iNum = 0; $iNum < $sCount; $iNum++ ) {
01440             $aStrings[$iNum] = $oStr->strtolower( $aStrings[$iNum] );
01441             // removing in admin defined strings
01442             if ( !$aStrings[$iNum] || in_array( $aStrings[$iNum], $aSkipTags ) ) {
01443                 unset( $aStrings[$iNum] );
01444             }
01445         }
01446 
01447         // duplicates
01448         return implode( ', ', array_unique( $aStrings ) );
01449     }
01450 
01458     public function getNavigationParams()
01459     {
01460         $aParams['cnid'] = $this->getCategoryId();
01461         $aParams['mnid'] = oxConfig::getParameter( 'mnid' );
01462 
01463         $aParams['listtype'] = $this->getListType();
01464         $aParams['ldtype'] = $this->getCustomListDisplayType();
01465         $aParams['actcontrol'] = $this->getClassName();
01466 
01467         $aParams['recommid'] = oxConfig::getParameter( 'recommid' );
01468 
01469         $aParams['searchrecomm'] = oxConfig::getParameter( 'searchrecomm', true );
01470         $aParams['searchparam']  = oxConfig::getParameter( 'searchparam', true );
01471         $aParams['searchtag']    = oxConfig::getParameter( 'searchtag', true );
01472 
01473         $aParams['searchvendor'] = oxConfig::getParameter( 'searchvendor' );
01474         $aParams['searchcnid']   = oxConfig::getParameter( 'searchcnid' );
01475         $aParams['searchmanufacturer'] = oxConfig::getParameter( 'searchmanufacturer' );
01476 
01477         return $aParams;
01478     }
01479 
01489     public function setItemSorting( $sSortIdent, $sSortBy, $sSortDir = null )
01490     {
01491         $aSorting = oxSession::getVar( 'aSorting' );
01492         $aSorting[$sSortIdent]['sortby']  = $sSortBy;
01493         $aSorting[$sSortIdent]['sortdir'] = $sSortDir ? $sSortDir : null;
01494 
01495         oxSession::setVar( 'aSorting', $aSorting );
01496     }
01497 
01505     public function getSorting( $sSortIdent  )
01506     {
01507         $aSorting = null;
01508 
01509         if ( $aSorting = $this->getUserSelectedSorting() ) {
01510             $this->setItemSorting( $sSortIdent, $aSorting['sortby'], $aSorting['sortdir'] );
01511         } elseif ( !$aSorting = $this->getSavedSorting( $sSortIdent ) ) {
01512             $aSorting = $this->getDefaultSorting();
01513         }
01514 
01515         if ( $aSorting ) {
01516             $this->setListOrderBy( $aSorting['sortby'] );
01517             $this->setListOrderDirection( $aSorting['sortdir'] );
01518         }
01519 
01520         return $aSorting;
01521     }
01522 
01530     public function getSortingSql( $sIdent )
01531     {
01532         $aSorting = $this->getSorting( $sIdent );
01533         if ( is_array( $aSorting ) ) {
01534             return implode( " ", $aSorting );
01535         }
01536     }
01537 
01543     public function getTitleSuffix()
01544     {
01545         return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
01546     }
01547 
01553     public function getTitlePageSuffix()
01554     {
01555     }
01556 
01563     public function getTitlePrefix()
01564     {
01565         return $this->getConfig()->getActiveShop()->oxshops__oxtitleprefix->value;
01566     }
01567 
01568 
01569 
01578     protected function _getSubject( $iLang )
01579     {
01580         return null;
01581     }
01582 
01588     public function getDynUrlParams()
01589     {
01590         $sRet = '';
01591         $sListType = $this->getListType();
01592 
01593         switch ($sListType) {
01594             default:
01595                 break;
01596             case 'search':
01597                 $sRet .= "&amp;listtype={$sListType}";
01598                 if ( $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
01599                     $sRet .= "&amp;searchparam={$sSearchParamForLink}";
01600                 }
01601 
01602                 if ( ( $sVar = oxConfig::getParameter( 'searchcnid', true ) ) ) {
01603                     $sRet .= '&amp;searchcnid='.rawurlencode( rawurldecode( $sVar ) );
01604                 }
01605                 if ( ( $sVar = oxConfig::getParameter( 'searchvendor', true ) ) ) {
01606                     $sRet .= '&amp;searchvendor='.rawurlencode( rawurldecode( $sVar ) );
01607                 }
01608                 if ( ( $sVar = oxConfig::getParameter( 'searchmanufacturer', true ) ) ) {
01609                     $sRet .= '&amp;searchmanufacturer='.rawurlencode( rawurldecode( $sVar ) );
01610                 }
01611                 break;
01612             case 'tag':
01613                 $sRet .= "&amp;listtype={$sListType}";
01614                 if ( $sParam = rawurlencode( oxConfig::getParameter( 'searchtag', true ) ) ) {
01615                     $sRet .= "&amp;searchtag={$sParam}";
01616                 }
01617                 break;
01618         }
01619 
01620         return $sRet;
01621     }
01622 
01630     public function getLink( $iLang = null )
01631     {
01632         if ( !isset( $iLang ) ) {
01633             $iLang = oxRegistry::getLang()->getBaseLanguage();
01634         }
01635 
01636         $oDisplayObj = null;
01637         $blTrySeo = false;
01638         if ( oxRegistry::getUtils()->seoIsActive() ) {
01639             $blTrySeo = true;
01640             $oDisplayObj = $this->_getSubject( $iLang );
01641         }
01642         $iActPageNr = $this->getActPage();
01643 
01644         if ( $oDisplayObj ) {
01645             return $this->_addPageNrParam( $oDisplayObj->getLink( $iLang ), $iActPageNr, $iLang );
01646         }
01647 
01648         $myConfig = $this->getConfig();
01649 
01650         if ( $blTrySeo ) {
01651             $oEncoder = oxRegistry::get("oxSeoEncoder");
01652             if ( ( $sSeoUrl = $oEncoder->getStaticUrl( $myConfig->getShopHomeURL( $iLang ) . $this->_getSeoRequestParams(), $iLang ) ) ) {
01653                 return $this->_addPageNrParam( $sSeoUrl, $iActPageNr, $iLang );
01654             }
01655         }
01656 
01657         $sUrl = oxRegistry::get("oxUtilsUrl")->processUrl( $myConfig->getShopCurrentURL( $iLang ) . $this->_getRequestParams(), true, null, $iLang);
01658 
01659         // fallback to old non seo url
01660         return $this->_addPageNrParam( $sUrl, $iActPageNr, $iLang );
01661     }
01662 
01668     public function getCanonicalUrl()
01669     {
01670     }
01671 
01678     public function getSimilarRecommListIds()
01679     {
01680         return false;
01681     }
01688     public function getSearchParamForHtml()
01689     {
01690     }
01691 
01699     protected function _getRequestParams( $blAddPageNr  = true )
01700     {
01701         $sClass = $this->getClassName();
01702         $sFnc   = $this->getFncName();
01703 
01704         $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher', 'moveleft', 'moveright' );
01705         if ( in_array( $sFnc, $aFnc ) ) {
01706             $sFnc = '';
01707         }
01708 
01709         // #680
01710         $sURL = "cl={$sClass}";
01711         if ( $sFnc ) {
01712             $sURL .= "&amp;fnc={$sFnc}";
01713         }
01714         if ( $sVal = oxConfig::getParameter( 'cnid' ) ) {
01715             $sURL .= "&amp;cnid={$sVal}";
01716         }
01717         if ( $sVal = oxConfig::getParameter( 'mnid' ) ) {
01718             $sURL .= "&amp;mnid={$sVal}";
01719         }
01720         if ( $sVal= oxConfig::getParameter( 'anid' ) ) {
01721             $sURL .= "&amp;anid={$sVal}";
01722         }
01723 
01724         if ( $sVal = basename( oxConfig::getParameter( 'page' ) ) ) {
01725             $sURL .= "&amp;page={$sVal}";
01726         }
01727 
01728         if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
01729             $sURL .= "&amp;tpl={$sVal}";
01730         }
01731 
01732         if ( $sVal = oxConfig::getParameter( 'oxloadid' ) ) {
01733             $sURL .= "&amp;oxloadid={$sVal}";
01734         }
01735 
01736         $iPgNr = (int) oxConfig::getParameter( 'pgNr' );
01737         // don't include page number for navigation
01738         // it will be done in oxubase::generatePageNavigation
01739         if ( $blAddPageNr && $iPgNr > 0 ) {
01740             $sURL .= "&amp;pgNr={$iPgNr}";
01741         }
01742 
01743         // #1184M - specialchar search
01744         if ( $sVal = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
01745             $sURL .= "&amp;searchparam={$sVal}";
01746         }
01747 
01748         if ( $sVal = oxConfig::getParameter( 'searchcnid' ) ) {
01749             $sURL .= "&amp;searchcnid={$sVal}";
01750         }
01751 
01752         if ( $sVal = oxConfig::getParameter( 'searchvendor' ) ) {
01753             $sURL .= "&amp;searchvendor={$sVal}";
01754         }
01755 
01756         if ( $sVal = oxConfig::getParameter( 'searchmanufacturer' ) ) {
01757             $sURL .= "&amp;searchmanufacturer={$sVal}";
01758         }
01759 
01760         if ( $sVal = oxConfig::getParameter( 'searchrecomm' ) ) {
01761             $sURL .= "&amp;searchrecomm={$sVal}";
01762         }
01763 
01764         if ( $sVal = oxConfig::getParameter( 'searchtag' ) ) {
01765             $sURL .= "&amp;searchtag={$sVal}";
01766         }
01767 
01768         if ( $sVal = oxConfig::getParameter( 'recommid' ) ) {
01769             $sURL .= "&amp;recommid={$sVal}";
01770         }
01771 
01772         return $sURL;
01773     }
01774 
01780     protected function _getSeoRequestParams()
01781     {
01782         $sClass = $this->getClassName();
01783         $sFnc   = $this->getFncName();
01784 
01785         // #921 S
01786         $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher' );
01787         if ( in_array( $sFnc, $aFnc ) ) {
01788             $sFnc = '';
01789         }
01790 
01791         // #680
01792         $sURL = "cl={$sClass}";
01793         if ( $sFnc ) {
01794             $sURL .= "&amp;fnc={$sFnc}";
01795         }
01796         if ( $sVal = basename( oxConfig::getParameter( 'page' ) ) ) {
01797             $sURL .= "&amp;page={$sVal}";
01798         }
01799 
01800         if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
01801             $sURL .= "&amp;tpl={$sVal}";
01802         }
01803 
01804         if ( $sVal = oxConfig::getParameter( 'oxloadid' ) ) {
01805             $sURL .= "&amp;oxloadid={$sVal}";
01806         }
01807 
01808         $iPgNr = (int) oxConfig::getParameter( 'pgNr' );
01809         if ( $iPgNr > 0 ) {
01810             $sURL .= "&amp;pgNr={$iPgNr}";
01811         }
01812 
01813         return $sURL;
01814     }
01815 
01821     public function showSearch()
01822     {
01823         $blShow = true;
01824         if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) && $this->getIsOrderStep() ) {
01825             $blShow = false;
01826         }
01827         return (int) $blShow;
01828     }
01829 
01835     public function getRssLinks()
01836     {
01837         return $this->_aRssLinks;
01838     }
01839 
01845     public function getSortColumns()
01846     {
01847         if ( $this->_aSortColumns === null ) {
01848             $this->setSortColumns( $this->getConfig()->getConfigParam( 'aSortCols' ) );
01849         }
01850         return $this->_aSortColumns;
01851     }
01852 
01853 
01861     public function setSortColumns( $aSortColumns )
01862     {
01863         $this->_aSortColumns = $aSortColumns;
01864     }
01865 
01871     public function getEditTags()
01872     {
01873     }
01874 
01880     public function getRecommSearch()
01881     {
01882     }
01883 
01889     public function getPaymentList()
01890     {
01891     }
01892 
01898     public function getActiveRecommList()
01899     {
01900         if ( $this->_oActiveRecommList === null ) {
01901             $this->_oActiveRecommList = false;
01902             if ( $sOxid = oxConfig::getParameter( 'recommid' ) ) {
01903                 $this->_oActiveRecommList = oxNew( 'oxrecommlist' );
01904                 $this->_oActiveRecommList->load( $sOxid );
01905             }
01906         }
01907         return $this->_oActiveRecommList;
01908     }
01909 
01915     public function getAccessoires()
01916     {
01917     }
01918 
01924     public function getCrossSelling()
01925     {
01926     }
01927 
01933     public function getSimilarProducts()
01934     {
01935     }
01936 
01942     public function getAlsoBoughtTheseProducts()
01943     {
01944     }
01945 
01951     public function getArticleId()
01952     {
01953     }
01954 
01960     public function getTitle()
01961     {
01962         $sTranslationName = 'PAGE_TITLE_'.strtoupper($this->getConfig()->getActiveView()->getClassName());
01963         $sTranslated = oxRegistry::getLang()->translateString( $sTranslationName, oxRegistry::getLang()->getBaseLanguage(), false );
01964         return $sTranslationName == $sTranslated? null : $sTranslated;
01965     }
01966 
01972     public function getActiveLangAbbr()
01973     {
01974         // Performance
01975         if ( !$this->getConfig()->getConfigParam( 'bl_perfLoadLanguages' ) ) {
01976             return;
01977         }
01978 
01979         if ( !isset($this->_sActiveLangAbbr ) ) {
01980             $aLanguages = oxRegistry::getLang()->getLanguageArray();
01981             while ( list( $sKey, $oVal ) = each( $aLanguages ) ) {
01982                 if ( $oVal->selected ) {
01983                     $this->_sActiveLangAbbr = $oVal->abbr;
01984                     break;
01985                 }
01986             }
01987         }
01988 
01989         return $this->_sActiveLangAbbr;
01990     }
01991 
01999     public function addGlobalParams( $oShop = null)
02000     {
02001         $oViewConf = parent::addGlobalParams( $oShop );
02002 
02003         $this->_setNrOfArtPerPage();
02004 
02005         return $oViewConf;
02006     }
02007 
02013     public function getAdditionalParams()
02014     {
02015         if ( $this->_sAdditionalParams === null ) {
02016             // #1018A
02017             $this->_sAdditionalParams  = parent::getAdditionalParams();
02018             $this->_sAdditionalParams .= 'cl='.$this->getConfig()->getActiveView()->getClassName();
02019 
02020             // #1834M - specialchar search
02021             $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) );
02022             if ( isset( $sSearchParamForLink ) ) {
02023                 $this->_sAdditionalParams .= "&amp;searchparam={$sSearchParamForLink}";
02024             }
02025             if ( ( $sVar = oxConfig::getParameter( 'searchtag' ) ) ) {
02026                 $this->_sAdditionalParams .= '&amp;searchtag='.rawurlencode( rawurldecode( $sVar ) );
02027             }
02028             if ( ( $sVar = oxConfig::getParameter( 'searchcnid' ) ) ) {
02029                 $this->_sAdditionalParams .= '&amp;searchcnid='.rawurlencode( rawurldecode( $sVar ) );
02030             }
02031             if ( ( $sVar = oxConfig::getParameter( 'searchvendor' ) ) ) {
02032                 $this->_sAdditionalParams .= '&amp;searchvendor='.rawurlencode( rawurldecode( $sVar ) );
02033             }
02034             if ( ( $sVar = oxConfig::getParameter( 'searchmanufacturer' ) ) ) {
02035                 $this->_sAdditionalParams .= '&amp;searchmanufacturer='.rawurlencode( rawurldecode( $sVar ) );
02036             }
02037             if ( ( $sVar = oxConfig::getParameter( 'cnid' ) ) ) {
02038                 $this->_sAdditionalParams .= '&amp;cnid='.rawurlencode( rawurldecode( $sVar ) );
02039             }
02040             if ( ( $sVar = oxConfig::getParameter( 'mnid' ) ) ) {
02041                 $this->_sAdditionalParams .= '&amp;mnid='.rawurlencode( rawurldecode( $sVar ) );
02042             }
02043         }
02044 
02045         return $this->_sAdditionalParams;
02046     }
02047 
02053     public function generatePageNavigationUrl()
02054     {
02055         return $this->getConfig()->getShopHomeURL().$this->_getRequestParams( false );
02056     }
02057 
02067     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null )
02068     {
02069         if ( $iPage ) {
02070             if ( ( strpos( $sUrl, 'pgNr=' ) ) ) {
02071                 $sUrl = preg_replace('/pgNr=[0-9]*/', 'pgNr='.$iPage, $sUrl);
02072             } else {
02073                 $sUrl .= ( ( strpos( $sUrl, '?' ) === false ) ? '?' : '&amp;' ) . 'pgNr='.$iPage;
02074             }
02075         } else {
02076            $sUrl = preg_replace('/pgNr=[0-9]*/', '', $sUrl);
02077            $sUrl = preg_replace('/\&amp\;\&amp\;/', '&amp;', $sUrl);
02078            $sUrl = preg_replace('/\?\&amp\;/', '?', $sUrl);
02079            $sUrl = preg_replace('/\&amp\;$/', '', $sUrl);
02080         }
02081         return $sUrl;
02082     }
02083 
02089     public function getPageNavigation()
02090     {
02091 
02092     }
02093 
02101     public function getPageNavigationLimitedTop( $iPositionCount = 7 )
02102     {
02103         $this->_oPageNavigation = $this->generatePageNavigation( $iPositionCount );
02104         return $this->_oPageNavigation;
02105     }
02106 
02114     public function getPageNavigationLimitedBottom( $iPositionCount = 11 )
02115     {
02116         $this->_oPageNavigation = $this->generatePageNavigation( $iPositionCount );
02117         return $this->_oPageNavigation;
02118     }
02119 
02120 
02128     public function generatePageNavigation( $iPositionCount = 0 )
02129     {
02130         startProfile('generatePageNavigation');
02131 
02132         $pageNavigation = new stdClass();
02133 
02134         $pageNavigation->NrOfPages = $this->_iCntPages;
02135         $iActPage = $this->getActPage();
02136         $pageNavigation->actPage   = $iActPage + 1;
02137         $sUrl = $this->generatePageNavigationUrl();
02138 
02139         if ( $iPositionCount == 0 || ($iPositionCount >= $pageNavigation->NrOfPages) ) {
02140              $iStartNo = 2;
02141              $iFinishNo = $pageNavigation->NrOfPages;
02142              $bStart = false;
02143              $bFinish =false;
02144         } else {
02145             $iTmpVal = $iPositionCount - 3;
02146             $iTmpVal2 = floor( ( $iPositionCount - 4 ) / 2 );
02147 
02148             // actual page is at the start
02149             if ( $pageNavigation->actPage <= $iTmpVal ) {
02150                 $iStartNo = 2;
02151                 $iFinishNo = $iTmpVal + 1;
02152                 $bStart = false;
02153                 $bFinish = true;
02154             // actual page is at the end
02155             } elseif ( $pageNavigation->actPage >= $pageNavigation->NrOfPages - $iTmpVal ) {
02156                 $iStartNo = $pageNavigation->NrOfPages - $iTmpVal;
02157                 $iFinishNo = $pageNavigation->NrOfPages - 1;
02158                 $bStart = true;
02159                 $bFinish = false;
02160             // actual page is in the midle
02161             } else {
02162                 $iStartNo = $pageNavigation->actPage - $iTmpVal2;
02163                 $iFinishNo = $pageNavigation->actPage + $iTmpVal2;
02164                 $bStart = true;
02165                 $bFinish = true;
02166             }
02167         }
02168 
02169         if ( $iActPage > 0) {
02170             $pageNavigation->previousPage = $this->_addPageNrParam( $sUrl, $iActPage - 1 );
02171         }
02172 
02173         if ( $iActPage < $pageNavigation->NrOfPages - 1 ) {
02174             $pageNavigation->nextPage = $this->_addPageNrParam( $sUrl, $iActPage + 1 );
02175         }
02176 
02177         if ( $pageNavigation->NrOfPages > 1 ) {
02178 
02179             for ( $i=1; $i < $pageNavigation->NrOfPages + 1; $i++ ) {
02180 
02181                 if ( $i == 1 || $i == $pageNavigation->NrOfPages || ( $i >= $iStartNo && $i <= $iFinishNo ) ) {
02182                     $page = new stdClass();
02183                     $page->url = $this->_addPageNrParam( $sUrl, $i - 1 );
02184                     $page->selected = ( $i == $pageNavigation->actPage ) ? 1 : 0;
02185                     $pageNavigation->changePage[$i] = $page;
02186                 }
02187             }
02188 
02189             // first/last one
02190             $pageNavigation->firstpage = $this->_addPageNrParam( $sUrl, 0 );
02191             $pageNavigation->lastpage  = $this->_addPageNrParam( $sUrl, $pageNavigation->NrOfPages - 1 );
02192         }
02193 
02194         stopProfile('generatePageNavigation');
02195 
02196         return $pageNavigation;
02197     }
02198 
02205     public function render()
02206     {
02207         foreach ( array_keys( $this->_oaComponents ) as $sComponentName ) {
02208             $this->_aViewData[$sComponentName] = $this->_oaComponents[$sComponentName]->render();
02209         }
02210 
02211         parent::render();
02212 
02213         if ( $this->getIsOrderStep() ) {
02214 
02215             // disabling navigation during order ...
02216             if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) ) {
02217                 $this->_iNewsRealStatus = 1;
02218                 $this->setShowNewsletter( 0 );
02219             }
02220         }
02221         return $this->_sThisTemplate;
02222     }
02223 
02229     public function getViewProduct()
02230     {
02231         return $this->getProduct();
02232     }
02233 
02241     public function setViewProduct( $oProduct )
02242     {
02243         $this->_oProduct = $oProduct;
02244     }
02245 
02251     public function getViewProductList()
02252     {
02253         return $this->_aArticleList;
02254     }
02255 
02261     public function getActPage()
02262     {
02263         if ( $this->_iActPage === null ) {
02264             $this->_iActPage = ( int ) oxConfig::getParameter( 'pgNr' );
02265             $this->_iActPage = ( $this->_iActPage < 0 ) ? 0 : $this->_iActPage;
02266         }
02267         return $this->_iActPage;
02268     }
02269 
02277     public function getActTag()
02278     {
02279         if ( $this->_oActTag === null ) {
02280             $this->_oActTag = new stdClass();
02281             $this->_oActTag->sTag = $sTag = oxConfig::getParameter("searchtag", 1);
02282             $oSeoEncoderTag = oxRegistry::get("oxSeoEncoderTag");
02283 
02284             $sLink = false;
02285             if ( oxRegistry::getUtils()->seoIsActive() ) {
02286                 $sLink = $oSeoEncoderTag->getTagUrl( $sTag, oxRegistry::getLang()->getBaseLanguage() );
02287             }
02288 
02289             $this->_oActTag->link = $sLink ? $sLink : $this->getConfig()->getShopHomeURL().$oSeoEncoderTag->getStdTagUri( $sTag, false );
02290         }
02291         return $this->_oActTag;
02292     }
02293 
02301     public function getActVendor()
02302     {
02303         // if active vendor is not set yet - trying to load it from request params
02304         // this may be usefull when category component was unable to load active vendor
02305         // and we still need some object to mount navigation info
02306         if ( $this->_oActVendor === null ) {
02307             $this->_oActVendor = false;
02308             $sVendorId = oxConfig::getParameter( 'cnid' );
02309             $sVendorId = $sVendorId ? str_replace( 'v_', '', $sVendorId ) : $sVendorId;
02310             $oVendor = oxNew( 'oxvendor' );
02311             if ( $oVendor->load( $sVendorId ) ) {
02312                 $this->_oActVendor = $oVendor;
02313             }
02314         }
02315 
02316         return $this->_oActVendor;
02317     }
02318 
02326     public function getActManufacturer()
02327     {
02328         // if active Manufacturer is not set yet - trying to load it from request params
02329         // this may be usefull when category component was unable to load active Manufacturer
02330         // and we still need some object to mount navigation info
02331         if ( $this->_oActManufacturer === null ) {
02332 
02333             $this->_oActManufacturer = false;
02334             $sManufacturerId = oxConfig::getParameter( 'mnid' );
02335             $oManufacturer = oxNew( 'oxmanufacturer' );
02336             if ( $oManufacturer->load( $sManufacturerId ) ) {
02337                 $this->_oActManufacturer = $oManufacturer;
02338             }
02339         }
02340 
02341         return $this->_oActManufacturer;
02342     }
02343 
02351     public function setActVendor( $oVendor )
02352     {
02353         $this->_oActVendor = $oVendor;
02354     }
02355 
02363     public function setActManufacturer( $oManufacturer )
02364     {
02365         $this->_oActManufacturer = $oManufacturer;
02366     }
02367 
02373     public function getActSearch()
02374     {
02375         if ( $this->_oActSearch === null ) {
02376             $this->_oActSearch = new stdClass();
02377             $sUrl = $this->getConfig()->getShopHomeURL();
02378             $this->_oActSearch->link = "{$sUrl}cl=search";
02379         }
02380         return $this->_oActSearch;
02381     }
02382 
02388     public function getCategoryTree()
02389     {
02390         return $this->_oCategoryTree;
02391     }
02392 
02400     public function setCategoryTree( $oCatTree )
02401     {
02402         $this->_oCategoryTree = $oCatTree;
02403     }
02404 
02410     public function getManufacturerTree()
02411     {
02412         return $this->_oManufacturerTree;
02413     }
02414 
02422     public function setManufacturerTree( $oManufacturerTree )
02423     {
02424         $this->_oManufacturerTree = $oManufacturerTree;
02425     }
02426 
02432     public function getAddUrlParams()
02433     {
02434     }
02435 
02444     public function getTop5ArticleList( $iCount = null )
02445     {
02446         if ( $this->_blTop5Action ) {
02447             if ( $this->_aTop5ArticleList === null ) {
02448                 $this->_aTop5ArticleList = false;
02449                 $myConfig = $this->getConfig();
02450                 if ( $myConfig->getConfigParam( 'bl_perfLoadAktion' ) ) {
02451                     // top 5 articles
02452                     $oArtList = oxNew( 'oxarticlelist' );
02453                     $oArtList->loadTop5Articles( $iCount );
02454                     if ( $oArtList->count() ) {
02455                         $this->_aTop5ArticleList = $oArtList;
02456                     }
02457                 }
02458             }
02459         }
02460         return $this->_aTop5ArticleList;
02461     }
02462 
02469     public function getBargainArticleList()
02470     {
02471         if ( $this->_blBargainAction ) {
02472             if ( $this->_aBargainArticleList === null ) {
02473                 $this->_aBargainArticleList = array();
02474                 if ( $this->getConfig()->getConfigParam( 'bl_perfLoadAktion' ) ) {
02475                     $oArtList = oxNew( 'oxarticlelist' );
02476                     $oArtList->loadActionArticles( 'OXBARGAIN' );
02477                     if ( $oArtList->count() ) {
02478                         $this->_aBargainArticleList = $oArtList;
02479                     }
02480                 }
02481             }
02482         }
02483         return $this->_aBargainArticleList;
02484     }
02485 
02492     public function isLowOrderPrice()
02493     {
02494         if ( $this->_blLowOrderPrice === null && ( $oBasket = $this->getSession()->getBasket() ) ) {
02495             $this->_blLowOrderPrice = $oBasket->isBelowMinOrderPrice();
02496         }
02497 
02498         return $this->_blLowOrderPrice;
02499     }
02500 
02506     public function getMinOrderPrice()
02507     {
02508         if ( $this->_sMinOrderPrice === null && $this->isLowOrderPrice() ) {
02509             $dMinOrderPrice = oxPrice::getPriceInActCurrency( $this->getConfig()->getConfigParam( 'iMinOrderPrice' ) );
02510             $this->_sMinOrderPrice = oxRegistry::getLang()->formatCurrency( $dMinOrderPrice );
02511         }
02512         return $this->_sMinOrderPrice;
02513     }
02514 
02520     public function getNewsRealStatus()
02521     {
02522         return $this->_iNewsRealStatus;
02523     }
02524 
02530     protected function _canRedirect()
02531     {
02532         foreach ( $this->_aBlockRedirectParams as $sParam ) {
02533             if ( oxConfig::getParameter( $sParam ) !== null ) {
02534                 return false;
02535             }
02536         }
02537 
02538         return true;
02539     }
02540 
02546     public function getProduct()
02547     {
02548     }
02549 
02555     public function getManufacturerlist()
02556     {
02557         return $this->_aManufacturerlist;
02558     }
02559 
02567     public function setManufacturerlist( $aList )
02568     {
02569         $this->_aManufacturerlist = $aList;
02570     }
02571 
02579     public function setRootVendor( $oVendor )
02580     {
02581         $this->_oRootVendor = $oVendor;
02582     }
02583 
02589     public function getRootVendor()
02590     {
02591         return $this->_oRootVendor;
02592     }
02593 
02601     public function setRootManufacturer( $oManufacturer )
02602     {
02603         $this->_oRootManufacturer = $oManufacturer;
02604     }
02605 
02611     public function getRootManufacturer()
02612     {
02613         return $this->_oRootManufacturer;
02614     }
02615 
02621     public function getVendorId()
02622     {
02623         if ( $this->_sVendorId === null ) {
02624             $this->_sVendorId = false;
02625             if ( ( $oVendor = $this->getActVendor() ) ) {
02626                 $this->_sVendorId = $oVendor->getId();
02627             }
02628         }
02629         return $this->_sVendorId;
02630     }
02631 
02637     public function getManufacturerId()
02638     {
02639         if ( $this->_sManufacturerId === null ) {
02640             $this->_sManufacturerId = false;
02641             if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
02642                 $this->_sManufacturerId = $oManufacturer->getId();
02643             }
02644         }
02645         return $this->_sManufacturerId;
02646     }
02647 
02655     public function getSearchCatTree()
02656     {
02657         return $this->_aSearchCatTree;
02658     }
02659 
02669     public function setSearchCatTree( $aTree )
02670     {
02671         $this->_aSearchCatTree = $aTree;
02672     }
02673 
02679     public function getCatMoreUrl()
02680     {
02681         return $this->getConfig()->getShopHomeURL().'cnid=oxmore';
02682     }
02683 
02689     public function getCatTreePath()
02690     {
02691         return $this->_sCatTreePath;
02692     }
02693 
02701     public function getContentByIdent( $sIdent )
02702     {
02703         if ( !isset( $this->_aContents[$sIdent] ) ) {
02704             $this->_aContents[$sIdent] = oxNew( 'oxcontent' );
02705             $this->_aContents[$sIdent]->loadByIdent( $sIdent );
02706         }
02707         return $this->_aContents[$sIdent];
02708     }
02709 
02715     public function getContentCategory()
02716     {
02717         return false;
02718     }
02719 
02725     public function getMustFillFields()
02726     {
02727         if ( $this->_aMustFillFields === null ) {
02728             $this->_aMustFillFields = false;
02729 
02730             // passing must-be-filled-fields info
02731             $aMustFillFields = $this->getConfig()->getConfigParam( 'aMustFillFields' );
02732             if ( is_array( $aMustFillFields ) ) {
02733                 $this->_aMustFillFields = array_flip( $aMustFillFields );
02734             }
02735         }
02736         return $this->_aMustFillFields;
02737     }
02738 
02746     public function isFieldRequired( $sField )
02747     {
02748         if ( $aMustFillFields = $this->getMustFillFields() ) {
02749             if ( isset( $aMustFillFields[$sField] ) ) {
02750                 return true;
02751             }
02752         }
02753 
02754         return false;
02755     }
02756 
02762     public function getFormId()
02763     {
02764         if ( $this->_sFormId === null ) {
02765             $this->_sFormId = oxUtilsObject::getInstance()->generateUId();
02766             oxSession::setVar( 'sessionuformid', $this->_sFormId );
02767         }
02768 
02769         return $this->_sFormId;
02770     }
02771 
02777     public function canAcceptFormData()
02778     {
02779         if ( $this->_blCanAcceptFormData === null ) {
02780             $this->_blCanAcceptFormData = false;
02781 
02782             $sFormId = oxConfig::getParameter( "uformid" );
02783             $sSessionFormId = oxSession::getVar( "sessionuformid" );
02784 
02785             // testing if form and session ids matches
02786             if ( $sFormId && $sFormId === $sSessionFormId ) {
02787                 $this->_blCanAcceptFormData = true;
02788             }
02789 
02790             // regenerating form data
02791             $this->getFormId();
02792         }
02793         return $this->_blCanAcceptFormData;
02794     }
02795 
02801     public function getPromoFinishedList()
02802     {
02803         if (isset($this->_oPromoFinishedList)) {
02804             return $this->_oPromoFinishedList;
02805         }
02806         $this->_oPromoFinishedList = oxNew( 'oxActionList' );
02807         $this->_oPromoFinishedList->loadFinishedByCount(2);
02808         return $this->_oPromoFinishedList;
02809     }
02810 
02816     public function getPromoCurrentList()
02817     {
02818         if (isset($this->_oPromoCurrentList)) {
02819             return $this->_oPromoCurrentList;
02820         }
02821         $this->_oPromoCurrentList = oxNew( 'oxActionList' );
02822         $this->_oPromoCurrentList->loadCurrent();
02823         return $this->_oPromoCurrentList;
02824     }
02825 
02831     public function getPromoFutureList()
02832     {
02833         if (isset($this->_oPromoFutureList)) {
02834             return $this->_oPromoFutureList;
02835         }
02836         $this->_oPromoFutureList = oxNew( 'oxActionList' );
02837         $this->_oPromoFutureList->loadFutureByCount(2);
02838         return $this->_oPromoFutureList;
02839     }
02840 
02846     public function getShowPromotionList()
02847     {
02848         if (isset($this->_blShowPromotions)) {
02849             return $this->_blShowPromotions;
02850         }
02851         $this->_blShowPromotions = false;
02852         if (oxNew('oxActionList')->areAnyActivePromotions()) {
02853             $this->_blShowPromotions = ( count( $this->getPromoFinishedList() ) + count( $this->getPromoCurrentList() ) + count( $this->getPromoFutureList() ) ) > 0;
02854         }
02855         return $this->_blShowPromotions;
02856     }
02857 
02863     public function isEnabledPrivateSales()
02864     {
02865         if ( $this->_blEnabledPrivateSales === null ) {
02866             $this->_blEnabledPrivateSales = (bool) $this->getConfig()->getConfigParam( 'blPsLoginEnabled' );
02867             if ( $this->_blEnabledPrivateSales && ( $blCanPreview = oxRegistry::getUtils()->canPreview() ) !== null ) {
02868                 $this->_blEnabledPrivateSales = !$blCanPreview;
02869             }
02870         }
02871         return $this->_blEnabledPrivateSales;
02872     }
02873 
02879     public function getFieldValidationErrors()
02880     {
02881         return oxRegistry::get("oxInputValidator")->getFieldValidationErrors();
02882     }
02883 
02889     public function getBreadCrumb()
02890     {
02891         return null;
02892     }
02893 
02901     public function setRootCatChanged( $blRootCatChanged )
02902     {
02903         $this->_blRootCatChanged = $blRootCatChanged;
02904     }
02905 
02911     public function isRootCatChanged()
02912     {
02913         return $this->_blRootCatChanged;
02914     }
02915 
02921     public function getInvoiceAddress()
02922     {
02923         if ( $this->_aInvoiceAddress == null ) {
02924             $aAddress = oxConfig::getParameter( 'invadr');
02925             if ( $aAddress ) {
02926                 $this->_aInvoiceAddress = $aAddress;
02927             }
02928         }
02929         return $this->_aInvoiceAddress;
02930     }
02931 
02937     public function getDeliveryAddress()
02938     {
02939         if ( $this->_aDeliveryAddress == null ) {
02940             $oConfig = $this->getConfig();
02941             //do not show deladr if address was reloaded
02942             if ( !$oConfig->getRequestParameter( 'reloadaddress' ) ) {
02943                 $this->_aDeliveryAddress = $oConfig->getRequestParameter( 'deladr');
02944             }
02945         }
02946         return $this->_aDeliveryAddress;
02947     }
02948 
02956     public function setDeliveryAddress($aDeliveryAddress)
02957     {
02958         $this->_aDeliveryAddress = $aDeliveryAddress;
02959     }
02960 
02968     public function setInvoiceAddress( $aAddress )
02969     {
02970         $this->_aInvoiceAddress = $aAddress;
02971     }
02972 
02978     public function getActiveUsername()
02979     {
02980         if ( $this->_sActiveUsername == null ) {
02981             $this->_sActiveUsername = false;
02982             $sUsername = oxConfig::getParameter( 'lgn_usr' );
02983             if ( $sUsername ) {
02984                 $this->_sActiveUsername = $sUsername;
02985             } elseif ( $oUser = $this->getUser() ) {
02986                 $this->_sActiveUsername = $oUser->oxuser__oxusername->value;
02987             }
02988         }
02989         return $this->_sActiveUsername;
02990     }
02991 
02997     public function getWishlistUserId()
02998     {
02999         return oxConfig::getParameter( 'wishid' );
03000     }
03001 
03007     public function getSearchCatId()
03008     {
03009     }
03010 
03016     public function getSearchVendor()
03017     {
03018     }
03019 
03025     public function getSearchManufacturer()
03026     {
03027     }
03028 
03034     public function getLastProducts()
03035     {
03036 
03037     }
03038 
03044     public function getNewBasketItemMsgType()
03045     {
03046         return (int) $this->getConfig()->getConfigParam( "iNewBasketItemMessage" );
03047     }
03048 
03056     public function isActive( $sName )
03057     {
03058         return $this->getConfig()->getConfigParam( "bl".$sName."Enabled" );
03059     }
03060 
03066     public function isFbWidgetVisible()
03067     {
03068         if ( $this->_blFbWidgetsOn === null ) {
03069             $oUtils = oxRegistry::get("oxUtilsServer");
03070 
03071             // reading ..
03072             $this->_blFbWidgetsOn = (bool) $oUtils->getOxCookie( "fbwidgetson" );
03073         }
03074         return $this->_blFbWidgetsOn;
03075     }
03076 
03082     public function isEnabledDownloadableFiles()
03083     {
03084         return (bool) $this->getConfig()->getConfigParam( "blEnableDownloads" );
03085     }
03086 
03092     public function showRememberMe()
03093     {
03094         return (bool) $this->getConfig()->getConfigParam('blShowRememberMe');
03095     }
03096 
03103     public function isVatIncluded()
03104     {
03105         $blResult = true;
03106         $oUser = $this->getUser();
03107         $oConfig = $this->getConfig();
03108 
03109         if ( $oConfig->getConfigParam( 'blShowNetPrice' ) || $oConfig->getConfigParam( 'bl_perfCalcVatOnlyForBasketOrder' ) ) {
03110             $blResult = false;
03111         } elseif ( $oUser && $oUser->isPriceViewModeNetto() ) {
03112             $blResult = false;
03113         }
03114 
03115         return $blResult;
03116     }
03117 
03123     public function isPriceCalculated()
03124     {
03125         return (bool) $this->getConfig()->getConfigParam( 'bl_perfLoadPrice' );
03126     }
03127 
03133     public function showTags()
03134     {
03135          return (bool) $this->_blShowTagCloud && $this->getConfig()->getConfigParam( "blShowTags" );
03136     }
03137 
03143     public function getWishlistName()
03144     {
03145         if ( $this->getUser() ) {
03146             $sUserId = oxConfig::getParameter( 'wishid') ? oxConfig::getParameter( 'wishid' ): oxSession::getVar( 'wishid');
03147             if ( $sUserId ) {
03148                 $oWishUser = oxNew( 'oxuser' );
03149                 if ( $oWishUser->load( $sUserId ) ) {
03150                     return $oWishUser;
03151                 }
03152             }
03153         }
03154         return false;
03155     }
03156 
03157 }