oxubase.php

Go to the documentation of this file.
00001 <?php
00002 
00006 require_once getShopBasePath() . 'views/oxview.php' ;
00007 
00008 // view indexing state for search engines:
00009 define( 'VIEW_INDEXSTATE_INDEX', 0 );           //  index without limitations
00010 define( 'VIEW_INDEXSTATE_NOINDEXNOFOLLOW', 1 ); //  no index / no follow
00011 define( 'VIEW_INDEXSTATE_NOINDEXFOLLOW', 2 );   //  no index / follow
00012 
00018 class oxUBase extends oxView
00019 {
00024     protected $_blFbWidgetsOn = null;
00025 
00030     protected $_sRemoveMetaChars = '.\+*?[^]$(){}=!<>|:&';
00031 
00037     protected $_oaComponents = array();
00038 
00044     protected $_blIsOrderStep = false;
00045 
00051     protected $_sListType = null;
00052 
00058     protected $_aListDisplayTypes = array( 'grid', 'line', 'infogrid' );
00059 
00065     protected $_sListDisplayType = null;
00066 
00072     protected $_oActCategory = null;
00073 
00079     protected $_oActManufacturer = null;
00080 
00086     protected $_oActVendor = null;
00087 
00092     protected $_oActiveRecommList = null;
00093 
00099     protected $_oActSearch = null;
00100 
00105     protected $_blShowSorting = false;
00106 
00111     protected $_blShowRightBasket = null;
00112 
00117     protected $_blShowTopBasket = null;
00118 
00123     protected $_blShowLeftBasket = null;
00124 
00129     protected $_blLoadCurrency = null;
00130 
00135     protected $_blLoadVendorTree = null;
00136 
00141     protected $_blLoadManufacturerTree = null;
00142 
00147     protected $_blDontShowEmptyCats = null;
00148 
00153     protected $_blLoadLanguage = null;
00154 
00159     protected $_blShowTopCatNav = null;
00160 
00165     protected $_iTopCatNavItmCnt = null;
00166 
00171     protected $_aRssLinks = null;
00172 
00177     protected $_sListOrderBy = null;
00178 
00183     protected $_sListOrderDir = null;
00184 
00189     protected $_sMetaDescription = null;
00190 
00195     protected $_sMetaKeywords = null;
00196 
00202     protected $_sMetaDescriptionIdent = null;
00203 
00209     protected $_sMetaKeywordsIdent = null;
00210 
00215     protected $_sAdditionalParams = null;
00216 
00221     protected $_oActCurrency = null;
00222 
00227     protected $_blEnabledPrivateSales = null;
00228 
00235     protected $_blCommonAdded = false;
00236 
00243     protected $_iViewIndexState = VIEW_INDEXSTATE_INDEX;
00244 
00251     protected $_blForceNoIndex = false;
00252 
00257     protected $_sWishlistName = null;
00258 
00263     protected $_iCompItemsCnt = null;
00264 
00270     protected $_sContentId = null;
00271 
00277     protected $_oContent = null;
00278 
00284     protected $_sViewResetID = null;
00285 
00290     protected $_blActiveSorting = null;
00291 
00296     protected $_aMenueList = null;
00297 
00303     protected $_aComponentNames = array(
00304                                     'oxcmp_user'       => 1, // 0 means dont init if cached
00305                                     'oxcmp_lang'       => 0,
00306                                     'oxcmp_cur'        => 1,
00307                                     'oxcmp_shop'       => 1,
00308                                     'oxcmp_categories' => 0,
00309                                     'oxcmp_utils'      => 1,
00310                                     'oxcmp_news'       => 0,
00311                                     'oxcmp_basket'     => 1
00312                                   );
00313 
00319     protected $_aUserComponentNames = array();
00320 
00326     protected $_oProduct = null;
00327 
00332     protected $_iActPage = null;
00333 
00338     protected $_aArticleList = null;
00339 
00344     protected $_oVendorTree  = null;
00345 
00350     protected $_oManufacturerTree  = null;
00351 
00356     protected $_oCategoryTree  = null;
00357 
00362     protected $_aTop5ArticleList  = null;
00363 
00368     protected $_aBargainArticleList  = null;
00369 
00374     protected $_blLowOrderPrice = null;
00375 
00380     protected $_sMinOrderPrice  = null;
00381 
00386     protected $_iNewsRealStatus  = null;
00387 
00393     protected $_aBlockRedirectParams = array( 'fnc', 'stoken', 'force_sid', 'force_admin_sid' );
00394 
00399     protected $_aVendorlist = null;
00400 
00405     protected $_oRootVendor = null;
00406 
00411     protected $_sVendorId = null;
00412 
00417     protected $_aManufacturerlist = null;
00418 
00423     protected $_oRootManufacturer = null;
00424 
00429     protected $_sManufacturerId = null;
00430 
00435     protected $_aSearchCatTree = null;
00436 
00441     protected $_oCatMore = null;
00442 
00447     protected $_blNewsSubscribed = null;
00448 
00453     protected $_oDelAddress = null;
00454 
00459     protected $_sCatTreePath = null;
00460 
00465     protected $_aContents = array();
00466 
00471     protected $_blTop5Action = true;
00472 
00477     protected $_blBargainAction = false;
00478 
00484     protected $_aMustFillFields = null;
00485 
00490     protected $_blShowTagCloud = true;
00491 
00496     protected $_blRootCatChanged = false;
00497 
00502     protected $_aInvoiceAddress = null;
00503 
00508     protected $_aDeliveryAddress = null;
00509 
00514     protected $_sActiveUsername = null;
00515 
00521     protected static $_aCollectedComponentNames = null;
00522 
00528     protected function _getComponentNames()
00529     {
00530         if ( self::$_aCollectedComponentNames === null ) {
00531             self::$_aCollectedComponentNames = array_merge( $this->_aComponentNames, $this->_aUserComponentNames );
00532 
00533             // #1721: custom component handling. At the moment it is not possible to override this variable in oxubase,
00534             // so we added this array to config.inc.php file
00535             if ( ( $aUserCmps = $this->getConfig()->getConfigParam( 'aUserComponentNames' ) ) ) {
00536                 self::$_aCollectedComponentNames = array_merge( self::$_aCollectedComponentNames, $aUserCmps );
00537             }
00538 
00539             if ( oxConfig::getParameter( '_force_no_basket_cmp' ) ) {
00540                 unset( self::$_aCollectedComponentNames['oxcmp_basket'] );
00541             }
00542         }
00543 
00544         // resetting array pointer
00545         reset( self::$_aCollectedComponentNames );
00546         return self::$_aCollectedComponentNames;
00547     }
00548 
00557     protected function _processRequest()
00558     {
00559         $myUtils = oxUtils::getInstance();
00560 
00561         // non admin, request is not empty and was not processed by seo engine
00562         if ( !isSearchEngineUrl() && $myUtils->seoIsActive() && ( $sStdUrl = getRequestUrl( '', true ) ) ) {
00563 
00564             // fetching standard url and looking for it in seo table
00565             if ( $this->_canRedirect() && ( $sRedirectUrl = oxSeoEncoder::getInstance()->fetchSeoUrl( $sStdUrl ) ) ) {
00566                 $myUtils->redirect( $this->getConfig()->getCurrentShopUrl() . $sRedirectUrl, false );
00567             } elseif (VIEW_INDEXSTATE_INDEX == $this->noIndex()) {
00568                 // forcing to set noindex/follow meta
00569                 $this->_forceNoIndex();
00570 
00571                 if (!$this->getConfig()->isProductiveMode() || $this->getConfig()->getConfigParam('blSeoLogging')) {
00572                     $sShopId = $this->getConfig()->getShopId();
00573                     $sLangId = oxLang::getInstance()->getBaseLanguage();
00574                     $sIdent  = md5( strtolower( $sStdUrl ) . $sShopId . $sLangId );
00575 
00576                     // logging "not found" url
00577                     $oDb = oxDb::getDb();
00578                     $oDb->execute( "replace oxseologs ( oxstdurl, oxident, oxshopid, oxlang )
00579                                     values ( " . $oDb->quote( $sStdUrl ) . ", '{$sIdent}', '{$sShopId}', '{$sLangId}' ) " );
00580                 }
00581             }
00582         }
00583     }
00584 
00591     public function init()
00592     {
00593         $this->_processRequest();
00594 
00595         // storing current view
00596         $blInit = true;
00597 
00598 
00599         // init all components if there are any
00600         foreach ( $this->_getComponentNames() as $sComponentName => $blNotCacheable ) {
00601             // do not override initiated components
00602             if ( !isset( $this->_oaComponents[$sComponentName] ) ) {
00603                 // component objects MUST be created to support user called functions
00604                 $oComponent = oxNew( $sComponentName );
00605                 $oComponent->setParent( $this );
00606                 $oComponent->setThisAction( $sComponentName );
00607                 $this->_oaComponents[$sComponentName] = $oComponent;
00608             }
00609 
00610             // do we really need to initiate them ?
00611             if ( $blInit ) {
00612                 $this->_oaComponents[$sComponentName]->init();
00613 
00614                 // executing only is view does not have action method
00615                 if ( !method_exists( $this, $this->getFncName() ) ) {
00616                     $this->_oaComponents[$sComponentName]->executeFunction( $this->getFncName() );
00617                 }
00618             }
00619         }
00620 
00621         parent::init();
00622 
00623         // enable sorting ?
00624         if ( $this->showSorting() ) {
00625             $this->prepareSortColumns();
00626         }
00627     }
00628 
00635     public function getViewId()
00636     {
00637         if ( $this->_sViewId ) {
00638             return $this->_sViewId;
00639         }
00640 
00641         $myConfig = $this->getConfig();
00642         $iLang = oxLang::getInstance()->getBaseLanguage();
00643         $iCur  = (int) $myConfig->getShopCurrency();
00644 
00645 
00646             $this->_sViewId =  "ox|$iLang|$iCur";
00647 
00648         $this->_sViewId .= "|".( (int) $this->_blForceNoIndex ).'|'.((int)$this->isRootCatChanged());
00649 
00650         // #0004798: SSL should be included in viewId
00651         if ($myConfig->isSsl()) {
00652             $this->_sViewId .= "|ssl";
00653         }
00654 
00655         // #0002866: external global viewID addition
00656         if (function_exists('customGetViewId')) {
00657             $oExtViewId = customGetViewId();
00658 
00659             if ($oExtViewId !== null) {
00660                 $this->_sViewId .= '|'.md5(serialize($oExtViewId));
00661             }
00662         }
00663 
00664         return $this->_sViewId;
00665     }
00666 
00667 
00673     public function showSorting()
00674     {
00675         return $this->_blShowSorting && $this->getConfig()->getConfigParam( 'blShowSorting' );
00676     }
00677 
00685     public function setComponents( $aComponents = null )
00686     {
00687         $this->_oaComponents = $aComponents;
00688     }
00689 
00695     public function getComponents()
00696     {
00697         return $this->_oaComponents;
00698     }
00699 
00707     public function setIsOrderStep( $blIsOrderStep = null )
00708     {
00709         $this->_blIsOrderStep = $blIsOrderStep;
00710     }
00711 
00717     public function getIsOrderStep()
00718     {
00719         return $this->_blIsOrderStep;
00720     }
00721 
00722 
00730     public function setActiveCategory( $oCategory )
00731     {
00732         $this->_oActCategory = $oCategory;
00733     }
00734 
00740     public function getActiveCategory()
00741     {
00742         return $this->_oActCategory;
00743     }
00744 
00750     public function getListType()
00751     {
00752         if ( $this->_sListType == null ) {
00753             if ( $sListType = oxConfig::getParameter( 'listtype' ) ) {
00754                 $this->_sListType = $sListType;
00755             } elseif ( $sListType = $this->getConfig()->getGlobalParameter( 'listtype' ) ) {
00756                 $this->_sListType = $sListType;
00757             }
00758         }
00759         return $this->_sListType;
00760     }
00761 
00767     public function getListDisplayType()
00768     {
00769         if ( $this->_sListDisplayType == null ) {
00770             $this->_sListDisplayType = oxConfig::getParameter( 'ldtype' );
00771 
00772             if ( !$this->_sListDisplayType ) {
00773                 $this->_sListDisplayType = oxSession::getVar( 'ldtype' );
00774             }
00775 
00776             if ( !$this->_sListDisplayType ) {
00777                 $this->_sListDisplayType = $this->getConfig()->getConfigParam( 'sDefaultListDisplayType' );
00778             }
00779 
00780             $this->_sListDisplayType = in_array( ( string ) $this->_sListDisplayType, $this->_aListDisplayTypes ) ? $this->_sListDisplayType : 'infogrid';
00781 
00782             // writing to session
00783             if ( oxConfig::getParameter( 'ldtype' ) ) {
00784                 oxSession::setVar( 'ldtype', $this->_sListDisplayType );
00785             }
00786         }
00787         return $this->_sListDisplayType;
00788     }
00789 
00797     public function setListType( $sType )
00798     {
00799         $this->_sListType = $sType;
00800         $this->getConfig()->setGlobalParameter( 'listtype', $sType );
00801     }
00802 
00808     public function showRightBasket()
00809     {
00810         if ( $this->_blShowRightBasket === null ) {
00811             if ( $blShowRightBasket = $this->getConfig()->getConfigParam( 'bl_perfShowRightBasket' ) ) {
00812                 $this->_blShowRightBasket = $blShowRightBasket;
00813             }
00814         }
00815         return $this->_blShowRightBasket;
00816     }
00817 
00825     public function setShowRightBasket( $blShowBasket )
00826     {
00827         $this->_blShowRightBasket = $blShowBasket;
00828     }
00829 
00835     public function showLeftBasket()
00836     {
00837         if ( $this->_blShowLeftBasket === null ) {
00838             if ( $blShowLeftBasket = $this->getConfig()->getConfigParam( 'bl_perfShowLeftBasket' ) ) {
00839                 $this->_blShowLeftBasket = $blShowLeftBasket;
00840             }
00841         }
00842         return $this->_blShowLeftBasket;
00843     }
00844 
00852     public function setShowLeftBasket( $blShowBasket )
00853     {
00854         $this->_blShowLeftBasket = $blShowBasket;
00855     }
00856 
00862     public function showTopBasket()
00863     {
00864         if ( $this->_blShowTopBasket === null ) {
00865             if ( $blShowTopBasket = $this->getConfig()->getConfigParam( 'bl_perfShowTopBasket' ) ) {
00866                 $this->_blShowTopBasket = $blShowTopBasket;
00867             }
00868         }
00869         return $this->_blShowTopBasket;
00870     }
00871 
00879     public function setShowTopBasket( $blShowBasket )
00880     {
00881         $this->_blShowTopBasket = $blShowBasket;
00882     }
00883 
00889     public function loadCurrency()
00890     {
00891         if ( $this->_blLoadCurrency == null ) {
00892             $this->_blLoadCurrency = false;
00893             if ( $blLoadCurrency = $this->getConfig()->getConfigParam( 'bl_perfLoadCurrency' ) ) {
00894                 $this->_blLoadCurrency = $blLoadCurrency;
00895             }
00896         }
00897         return $this->_blLoadCurrency;
00898     }
00899 
00907     public function loadVendorTree()
00908     {
00909         if ( $this->_blLoadVendorTree == null ) {
00910             $this->_blLoadVendorTree = false;
00911             if ( $blLoadVendorTree = $this->getConfig()->getConfigParam( 'bl_perfLoadVendorTree' ) ) {
00912                 $this->_blLoadVendorTree = $blLoadVendorTree;
00913             }
00914         }
00915         return $this->_blLoadVendorTree;
00916     }
00917 
00923     public function loadManufacturerTree()
00924     {
00925         if ( $this->_blLoadManufacturerTree == null ) {
00926             $this->_blLoadManufacturerTree = false;
00927             if ( $blLoadManufacturerTree = $this->getConfig()->getConfigParam( 'bl_perfLoadManufacturerTree' ) ) {
00928                 $this->_blLoadManufacturerTree = $blLoadManufacturerTree;
00929             }
00930         }
00931         return $this->_blLoadManufacturerTree;
00932     }
00933 
00939     public function dontShowEmptyCategories()
00940     {
00941         if ( $this->_blDontShowEmptyCats == null ) {
00942             $this->_blDontShowEmptyCats = false;
00943             if ( $blDontShowEmptyCats = $this->getConfig()->getConfigParam( 'blDontShowEmptyCategories' ) ) {
00944                 $this->_blDontShowEmptyCats = $blDontShowEmptyCats;
00945             }
00946         }
00947         return $this->_blDontShowEmptyCats;
00948     }
00949 
00955     public function showCategoryArticlesCount()
00956     {
00957         return $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' );
00958     }
00959 
00965     public function isLanguageLoaded()
00966     {
00967         if ( $this->_blLoadLanguage == null ) {
00968             $this->_blLoadLanguage = false;
00969             if ( $blLoadLanguage = $this->getConfig()->getConfigParam( 'bl_perfLoadLanguages' ) ) {
00970                 $this->_blLoadLanguage = $blLoadLanguage;
00971             }
00972         }
00973         return $this->_blLoadLanguage;
00974     }
00975 
00981     public function showTopCatNavigation()
00982     {
00983         if ( $this->_blShowTopCatNav == null ) {
00984             $this->_blShowTopCatNav = false;
00985             if ( $blShowTopCatNav = $this->getConfig()->getConfigParam( 'blTopNaviLayout' ) ) {
00986                 $this->_blShowTopCatNav = $blShowTopCatNav;
00987             }
00988         }
00989         return $this->_blShowTopCatNav;
00990     }
00991 
00997     public function getTopNavigationCatCnt()
00998     {
00999         if ( $this->_iTopCatNavItmCnt == null ) {
01000             $iTopCatNavItmCnt = $this->getConfig()->getConfigParam( 'iTopNaviCatCount' );
01001             $this->_iTopCatNavItmCnt = $iTopCatNavItmCnt ? $iTopCatNavItmCnt : 5;
01002         }
01003         return $this->_iTopCatNavItmCnt;
01004     }
01005 
01015     public function addRssFeed($sTitle, $sUrl, $key = null)
01016     {
01017         if (!is_array($this->_aRssLinks)) {
01018             $this->_aRssLinks = array();
01019         }
01020 
01021         $sUrl = oxUtilsUrl::getInstance()->prepareUrlForNoSession($sUrl);
01022 
01023         if ($key === null) {
01024             $this->_aRssLinks[] = array('title'=>$sTitle, 'link' => $sUrl);
01025         } else {
01026             $this->_aRssLinks[$key] = array('title'=>$sTitle, 'link' => $sUrl);
01027         }
01028     }
01029 
01035     public function getSortOrderByParameterName()
01036     {
01037         return 'listorderby';
01038     }
01039 
01045     public function getSortOrderParameterName()
01046     {
01047         return 'listorder';
01048     }
01049 
01060     public function prepareSortColumns()
01061     {
01062         $aSortColumns = $this->getConfig()->getConfigParam( 'aSortCols' );
01063         $aSortDir = array( 'desc', 'asc' );
01064         if ( count( $aSortColumns ) > 0 ) {
01065 
01066             $this->_blActiveSorting = true;
01067             $this->_aSortColumns = $aSortColumns;
01068 
01069             $sCnid = oxConfig::getParameter( 'cnid' );
01070 
01071 
01072             $sSortBy  = oxConfig::getParameter( $this->getSortOrderByParameterName() );
01073             $sSortDir = oxConfig::getParameter( $this->getSortOrderParameterName() );
01074 
01075             $oStr = getStr();
01076             if ( (!$sSortBy || !in_array( $oStr->strtolower($sSortBy), $aSortColumns) || !in_array( $oStr->strtolower($sSortDir), $aSortDir) ) && $aSorting = $this->getSorting( $sCnid ) ) {
01077                 $sSortBy  = $aSorting['sortby'];
01078                 $sSortDir = $aSorting['sortdir'];
01079             }
01080 
01081             if ( $sSortBy && oxDb::getInstance()->isValidFieldName( $sSortBy ) &&
01082                  $sSortDir && oxUtils::getInstance()->isValidAlpha( $sSortDir ) ) {
01083 
01084                 $this->_sListOrderBy  = $sSortBy;
01085                 $this->_sListOrderDir = $sSortDir;
01086 
01087                 // caching sorting config
01088                 $this->setItemSorting( $sCnid, $sSortBy, $sSortDir );
01089             }
01090         }
01091     }
01092 
01098     public function getListOrderBy()
01099     {
01100         //if column is with table name split it
01101         $aColums = explode('.', $this->_sListOrderBy);
01102 
01103         if ( is_array($aColums) && count($aColums) > 1 ) {
01104            return $aColums[1];
01105         }
01106 
01107         return $this->_sListOrderBy;
01108     }
01109 
01115     public function getListOrderDirection()
01116     {
01117         return $this->_sListOrderDir;
01118     }
01119 
01127     public function setMetaDescription ( $sDescription )
01128     {
01129         return $this->_sMetaDescription = $sDescription;
01130     }
01131 
01139     public function setMetaKeywords( $sKeywords )
01140     {
01141         return $this->_sMetaKeywords = $sKeywords;
01142     }
01143 
01151     protected function _getMetaFromSeo( $sDataType )
01152     {
01153         $sOxid  = $this->_getSeoObjectId();
01154         $iLang  = oxLang::getInstance()->getBaseLanguage();
01155         $sShop  = $this->getConfig()->getShopId();
01156 
01157         if ( $sOxid && oxUtils::getInstance()->seoIsActive() &&
01158              ( $sKeywords = oxSeoEncoder::getInstance()->getMetaData( $sOxid, $sDataType, $sShop, $iLang) ) ) {
01159             return $sKeywords;
01160         }
01161     }
01162 
01170     protected function _getMetaFromContent( $sMetaIdent )
01171     {
01172         if ( $sMetaIdent ) {
01173             $oContent = oxNew( 'oxcontent' );
01174             if ( $oContent->loadByIdent( $sMetaIdent ) &&
01175                  $oContent->oxcontents__oxactive->value ) {
01176                 return getStr()->strip_tags( $oContent->oxcontents__oxcontent->value );
01177             }
01178         }
01179     }
01180 
01186     public function getMetaKeywords()
01187     {
01188         if ( $this->_sMetaKeywords === null ) {
01189             $this->_sMetaKeywords = false;
01190 
01191             // set special meta keywords ?
01192             if ( ( $sKeywords = $this->_getMetaFromSeo( 'oxkeywords' ) ) ) {
01193                 $this->_sMetaKeywords = $sKeywords;
01194             } elseif ( ( $sKeywords = $this->_getMetaFromContent( $this->_sMetaKeywordsIdent ) ) ) {
01195                 $this->_sMetaKeywords = $this->_prepareMetaKeyword( $sKeywords, false );
01196             } else {
01197                 $this->_sMetaKeywords = $this->_prepareMetaKeyword( false, true );
01198             }
01199         }
01200 
01201         return $this->_sMetaKeywords;
01202     }
01203 
01209     public function getMetaDescription()
01210     {
01211         if ( $this->_sMetaDescription === null ) {
01212             $this->_sMetaDescription = false;
01213 
01214             // set special meta description ?
01215             if ( ( $sDescription = $this->_getMetaFromSeo( 'oxdescription' ) ) ) {
01216                 $this->_sMetaDescription = $sDescription;
01217             } elseif ( ( $sDescription = $this->_getMetaFromContent( $this->_sMetaDescriptionIdent ) ) ) {
01218                 $this->_sMetaDescription = $this->_prepareMetaDescription( $sDescription );
01219             } else {
01220                 $this->_sMetaDescription = $this->_prepareMetaDescription( false );
01221             }
01222         }
01223 
01224         return $this->_sMetaDescription;
01225     }
01226 
01232     public function getActCurrency()
01233     {
01234         return $this->_oActCurrency;
01235     }
01236 
01244     public function setActCurrency( $oCur )
01245     {
01246         $this->_oActCurrency = $oCur;
01247     }
01248 
01254     public function getCompareItemsCnt()
01255     {
01256         return (int)$this->_iCompItemsCnt;
01257     }
01258 
01266     public function setCompareItemsCnt( $iCount )
01267     {
01268         $this->_iCompItemsCnt = $iCount;
01269     }
01270 
01276     public function getWishlistName()
01277     {
01278         return $this->_sWishlistName;
01279     }
01280 
01288     public function setWishlistName( $sName )
01289     {
01290         $this->_sWishlistName = $sName;
01291     }
01292 
01298     protected function _forceNoIndex()
01299     {
01300         $this->_blForceNoIndex = true;
01301     }
01302 
01309     public function noIndex()
01310     {
01311         if ( $this->_blForceNoIndex ) {
01312             $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
01313         } elseif ( oxConfig::getParameter( 'cur' ) ) {
01314             $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
01315         } else {
01316             switch ( oxConfig::getParameter( 'fnc' ) ) {
01317                 case 'tocomparelist':
01318                 case 'tobasket':
01319                     $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
01320                     break;
01321             }
01322         }
01323         return $this->_iViewIndexState;
01324     }
01325 
01332     public function getContentId()
01333     {
01334         if ( $this->_sContentId === null) {
01335             $oContent = oxNew( 'oxcontent' );
01336             $oContent->loadByIdent( 'oximpressum' );
01337             $this->_sContentId = $oContent->getId();
01338         }
01339 
01340         return $this->_sContentId;
01341     }
01342 
01349     public function getContent()
01350     {
01351         if ( $this->_oContent === null) {
01352             $oContent = oxNew( 'oxcontent' );
01353             if ( $oContent->load( $this->getContentId() ) && $oContent->oxcontents__oxactive->value ) {
01354                 $this->_oContent = $oContent;
01355             }
01356         }
01357 
01358         return $this->_oContent;
01359     }
01360 
01366     public function isSortingActive()
01367     {
01368         return $this->_blActiveSorting;
01369     }
01370 
01376     public function getMenueList()
01377     {
01378         return $this->_aMenueList;
01379     }
01380 
01388     public function setMenueList( $aMenue )
01389     {
01390         $this->_aMenueList = $aMenue;
01391     }
01392 
01393 
01399     protected function _setNrOfArtPerPage()
01400     {
01401         $myConfig  = $this->getConfig();
01402 
01403         //setting default values to avoid possible errors showing article list
01404         $iNrofCatArticles = $myConfig->getConfigParam( 'iNrofCatArticles' );
01405 
01406         $iNrofCatArticles = ( $iNrofCatArticles ) ? $iNrofCatArticles : 10;
01407 
01408         // checking if all needed data is set
01409         switch ( $this->getListDisplayType() ) {
01410             case 'grid':
01411                 $aNrofCatArticles = $myConfig->getConfigParam( 'aNrofCatArticlesInGrid' );
01412                 break;
01413             case 'line':
01414             case 'infogrid':
01415             default:
01416                 $aNrofCatArticles = $myConfig->getConfigParam( 'aNrofCatArticles' );
01417         }
01418 
01419         if ( !is_array( $aNrofCatArticles ) || !isset( $aNrofCatArticles[0] ) ) {
01420             $myConfig->setConfigParam( 'aNrofCatArticles', array( $iNrofCatArticles ) );
01421         } else {
01422             $iNrofCatArticles = $aNrofCatArticles[0];
01423         }
01424 
01425         $oViewConf = $this->getViewConfig();
01426         //value from user input
01427         if ( ( $iNrofArticles = (int) oxConfig::getParameter( '_artperpage' ) ) ) {
01428             // M45 Possibility to push any "Show articles per page" number parameter
01429             $iNrofCatArticles = ( in_array( $iNrofArticles, $aNrofCatArticles ) ) ? $iNrofArticles : $iNrofCatArticles;
01430             $oViewConf->setViewConfigParam( 'iartPerPage', $iNrofCatArticles );
01431             oxSession::setVar( '_artperpage', $iNrofCatArticles );
01432         } elseif ( ( $iSessArtPerPage = oxSession::getVar( '_artperpage' ) )&& is_numeric( $iSessArtPerPage ) ) {
01433             // M45 Possibility to push any "Show articles per page" number parameter
01434             $iNrofCatArticles = ( in_array( $iSessArtPerPage, $aNrofCatArticles ) ) ? $iSessArtPerPage : $iNrofCatArticles;
01435             $oViewConf->setViewConfigParam( 'iartPerPage', $iSessArtPerPage );
01436             $iNrofCatArticles = $iSessArtPerPage;
01437         } else {
01438             $oViewConf->setViewConfigParam( 'iartPerPage', $iNrofCatArticles );
01439         }
01440 
01441         //setting number of articles per page to config value
01442         $myConfig->setConfigParam( 'iNrofCatArticles', $iNrofCatArticles );
01443     }
01444 
01450     protected function _getSeoObjectId()
01451     {
01452     }
01453 
01463     protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blRemoveDuplicatedWords = false )
01464     {
01465         if ( $sMeta ) {
01466 
01467             $oStr = getStr();
01468             if ( $iLength != -1 ) {
01469                 /* *
01470                  * performance - we dont need a huge amount of initial text.
01471                  * assume that effective text may be double longer than $iLength
01472                  * and simple turncate it
01473                  */
01474                 $iELength = ( $iLength * 2 );
01475                 $sMeta = $oStr->substr( $sMeta, 0, $iELength );
01476             }
01477 
01478             // decoding html entities
01479             $sMeta = $oStr->html_entity_decode( $sMeta );
01480             // stripping HTML tags
01481             $sMeta = $oStr->strip_tags( $sMeta );
01482 
01483             // removing some special chars
01484             $sMeta = $oStr->cleanStr( $sMeta );
01485 
01486             // removing duplicate words
01487             if ( $blRemoveDuplicatedWords ) {
01488                 $sMeta = $this->_removeDuplicatedWords( $sMeta, $this->getConfig()->getConfigParam( 'aSkipTags' ) );
01489             }
01490 
01491             // some special cases
01492             $sMeta = str_replace( ' ,', ',', $sMeta );
01493             $aPattern = array( "/,[\s\+\-\*]*,/", "/\s+,/" );
01494             $sMeta = $oStr->preg_replace( $aPattern, ',', $sMeta );
01495             $sMeta = oxUtilsString::getInstance()->minimizeTruncateString( $sMeta, $iLength );
01496             $sMeta = $oStr->htmlspecialchars( $sMeta );
01497 
01498             return trim( $sMeta );
01499         }
01500     }
01501 
01510     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
01511     {
01512 
01513         $sString = $this->_prepareMetaDescription( $sKeywords, -1, false );
01514 
01515         if ( $blRemoveDuplicatedWords ) {
01516             $sString = $this->_removeDuplicatedWords( $sString, $this->getConfig()->getConfigParam( 'aSkipTags' ) );
01517         }
01518 
01519         // removing in admin defined strings
01520 
01521         /*if ( is_array( $aSkipTags ) && $sString ) {
01522             $oStr = getStr();
01523             foreach ( $aSkipTags as $sSkip ) {
01524                 //$aPattern = array( '/\W'.$sSkip.'\W/iu', '/^'.$sSkip.'\W/iu', '/\"'.$sSkip.'$/iu' );
01525                 //$aPattern = array( '/\s+'.$sSkip.'\,/iu', '/^'.$sSkip.'\s+/iu', '/\"\s+'.$sSkip.'$/iu' );
01526                 $aPattern = array( '/\s+'.$sSkip.'\,/i', '/^'.$sSkip.',\s+/i', '/\",\s+'.$sSkip.'$/i' );
01527                 $sString  = $oStr->preg_replace( $aPattern, '', $sString );
01528             }
01529         }*/
01530 
01531         return trim( $sString );
01532     }
01533 
01542     protected function _removeDuplicatedWords( $aInput, $aSkipTags = array() )
01543     {
01544         $oStr = getStr();
01545         if ( is_array( $aInput ) ) {
01546             $aInput = implode( " ", $aInput );
01547         }
01548 
01549         // removing some usually met characters..
01550         $aInput = $oStr->preg_replace( "/[".preg_quote( $this->_sRemoveMetaChars, "/" )."]/", " ", $aInput );
01551 
01552         // splitting by word
01553         $aStrings = $oStr->preg_split( "/[\s,]+/", $aInput );
01554 
01555         if ( $sCount = count( $aSkipTags ) ) {
01556             for ( $iNum = 0; $iNum < $sCount; $iNum++ ) {
01557                 $aSkipTags[$iNum] = $oStr->strtolower( $aSkipTags[$iNum] );
01558             }
01559         }
01560         $sCount = count($aStrings);
01561         for ( $iNum = 0; $iNum < $sCount; $iNum++ ) {
01562             $aStrings[$iNum] = $oStr->strtolower( $aStrings[$iNum] );
01563             // removing in admin defined strings
01564             if ( !$aStrings[$iNum] || in_array( $aStrings[$iNum], $aSkipTags ) ) {
01565                 unset( $aStrings[$iNum] );
01566             }
01567         }
01568 
01569         // duplicates
01570         return implode( ', ', array_unique( $aStrings ) );
01571     }
01572 
01580     public function getNavigationParams()
01581     {
01582         $aParams['cnid'] = $this->getCategoryId();
01583         $aParams['mnid'] = oxConfig::getParameter( 'mnid' );
01584 
01585         $aParams['listtype'] = $this->getListType();
01586         $aParams['ldtype'] = $this->getListDisplayType();
01587 
01588         $aParams['recommid'] = oxConfig::getParameter( 'recommid' );
01589 
01590         $aParams['searchrecomm'] = oxConfig::getParameter( 'searchrecomm', true );
01591         $aParams['searchparam']  = oxConfig::getParameter( 'searchparam', true );
01592         $aParams['searchtag']    = oxConfig::getParameter( 'searchtag', true );
01593 
01594         $aParams['searchvendor'] = oxConfig::getParameter( 'searchvendor' );
01595         $aParams['searchcnid']   = oxConfig::getParameter( 'searchcnid' );
01596         $aParams['searchmanufacturer'] = oxConfig::getParameter( 'searchmanufacturer' );
01597 
01598         return $aParams;
01599     }
01600 
01610     public function setItemSorting( $sCnid, $sSortBy, $sSortDir = null )
01611     {
01612 
01613         $aSorting = oxSession::getVar( 'aSorting' );
01614         $aSorting[$sCnid]['sortby']  = $sSortBy;
01615         $aSorting[$sCnid]['sortdir'] = $sSortDir?$sSortDir:null;
01616 
01617         oxSession::setVar( 'aSorting', $aSorting );
01618     }
01619 
01627     public function getSorting( $sCnid )
01628     {
01629         $aSorting = oxSession::getVar( 'aSorting' );
01630 
01631         if ( isset( $aSorting[$sCnid] ) ) {
01632             return $aSorting[$sCnid];
01633         }
01634     }
01635 
01643     public function getSortingSql( $sCnid )
01644     {
01645         $aSorting = $this->getSorting( $sCnid );
01646         if ( is_array( $aSorting ) ) {
01647             return implode( " ", $aSorting );
01648         }
01649     }
01650 
01656     public function getTitleSuffix()
01657     {
01658         return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
01659     }
01660 
01666     public function getTitlePageSuffix()
01667     {
01668     }
01669 
01676     public function getTitlePrefix()
01677     {
01678         return $this->getConfig()->getActiveShop()->oxshops__oxtitleprefix->value;
01679     }
01680 
01681 
01682 
01691     protected function _getSubject( $iLang )
01692     {
01693         return null;
01694     }
01695 
01701     public function getDynUrlParams()
01702     {
01703         $sRet = '';
01704         $sListType = $this->getListType();
01705 
01706         switch ($sListType) {
01707             default:
01708                 break;
01709             case 'search':
01710                 $sRet .= "&amp;listtype={$sListType}";
01711                 if ( $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
01712                     $sRet .= "&amp;searchparam={$sSearchParamForLink}";
01713                 }
01714 
01715                 if ( ( $sVar = oxConfig::getParameter( 'searchcnid', true ) ) ) {
01716                     $sRet .= '&amp;searchcnid='.rawurlencode( rawurldecode( $sVar ) );
01717                 }
01718                 if ( ( $sVar = oxConfig::getParameter( 'searchvendor', true ) ) ) {
01719                     $sRet .= '&amp;searchvendor='.rawurlencode( rawurldecode( $sVar ) );
01720                 }
01721                 if ( ( $sVar = oxConfig::getParameter( 'searchmanufacturer', true ) ) ) {
01722                     $sRet .= '&amp;searchmanufacturer='.rawurlencode( rawurldecode( $sVar ) );
01723                 }
01724                 break;
01725             case 'tag':
01726                 $sRet .= "&amp;listtype={$sListType}";
01727                 if ( $sParam = rawurlencode( oxConfig::getParameter( 'searchtag', true ) ) ) {
01728                     $sRet .= "&amp;searchtag={$sParam}";
01729                 }
01730                 break;
01731         }
01732 
01733         return $sRet;
01734     }
01735 
01743     public function getLink( $iLang = null )
01744     {
01745         if ( !isset( $iLang ) ) {
01746             $iLang = oxLang::getInstance()->getBaseLanguage();
01747         }
01748 
01749         $oDisplayObj = null;
01750         $blTrySeo = false;
01751         if ( oxUtils::getInstance()->seoIsActive() ) {
01752             $blTrySeo = true;
01753             $oDisplayObj = $this->_getSubject( $iLang );
01754         }
01755         $iActPageNr = $this->getActPage();
01756 
01757         if ( $oDisplayObj ) {
01758             return $this->_addPageNrParam( $oDisplayObj->getLink( $iLang ), $iActPageNr, $iLang );
01759         }
01760 
01761         $myConfig = $this->getConfig();
01762 
01763         if ( $blTrySeo ) {
01764             $oEncoder = oxSeoEncoder::getInstance();
01765             if ( ( $sSeoUrl = $oEncoder->getStaticUrl( $myConfig->getShopHomeURL( $iLang ) . $this->_getSeoRequestParams(), $iLang ) ) ) {
01766                 return $this->_addPageNrParam( $sSeoUrl, $iActPageNr, $iLang );
01767             }
01768         }
01769 
01770         $sUrl = oxUtilsUrl::getInstance()->processUrl( $myConfig->getShopCurrentURL( $iLang ) . $this->_getRequestParams(), true, null, $iLang);
01771 
01772         // fallback to old non seo url
01773         return $this->_addPageNrParam( $sUrl, $iActPageNr, $iLang );
01774     }
01775 
01781     public function getCanonicalUrl()
01782     {
01783     }
01784 
01791     public function getSimilarRecommLists()
01792     {
01793     }
01794 
01801     public function getSearchParamForHtml()
01802     {
01803     }
01804 
01812     protected function _getRequestParams( $blAddPageNr  = true )
01813     {
01814         $sClass = $this->getClassName();
01815         $sFnc   = $this->getFncName();
01816 
01817         $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher', 'moveleft', 'moveright' );
01818         if ( in_array( $sFnc, $aFnc ) ) {
01819             $sFnc = '';
01820         }
01821 
01822         // #680
01823         $sURL = "cl={$sClass}";
01824         if ( $sFnc ) {
01825             $sURL .= "&amp;fnc={$sFnc}";
01826         }
01827         if ( $sVal = oxConfig::getParameter( 'cnid' ) ) {
01828             $sURL .= "&amp;cnid={$sVal}";
01829         }
01830         if ( $sVal = oxConfig::getParameter( 'mnid' ) ) {
01831             $sURL .= "&amp;mnid={$sVal}";
01832         }
01833         if ( $sVal= oxConfig::getParameter( 'anid' ) ) {
01834             $sURL .= "&amp;anid={$sVal}";
01835         }
01836 
01837         if ( $sVal = basename( oxConfig::getParameter( 'page' ) ) ) {
01838             $sURL .= "&amp;page={$sVal}";
01839         }
01840 
01841         if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
01842             $sURL .= "&amp;tpl={$sVal}";
01843         }
01844 
01845         $iPgNr = (int) oxConfig::getParameter( 'pgNr' );
01846         // don't include page number for navigation
01847         // it will be done in oxubase::generatePageNavigation
01848         if ( $blAddPageNr && $iPgNr > 0 ) {
01849             $sURL .= "&amp;pgNr={$iPgNr}";
01850         }
01851 
01852         // #1184M - specialchar search
01853         if ( $sVal = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
01854             $sURL .= "&amp;searchparam={$sVal}";
01855         }
01856 
01857         if ( $sVal = oxConfig::getParameter( 'searchcnid' ) ) {
01858             $sURL .= "&amp;searchcnid={$sVal}";
01859         }
01860 
01861         if ( $sVal = oxConfig::getParameter( 'searchvendor' ) ) {
01862             $sURL .= "&amp;searchvendor={$sVal}";
01863         }
01864 
01865         if ( $sVal = oxConfig::getParameter( 'searchmanufacturer' ) ) {
01866             $sURL .= "&amp;searchmanufacturer={$sVal}";
01867         }
01868 
01869         if ( $sVal = oxConfig::getParameter( 'searchrecomm' ) ) {
01870             $sURL .= "&amp;searchrecomm={$sVal}";
01871         }
01872 
01873         if ( $sVal = oxConfig::getParameter( 'searchtag' ) ) {
01874             $sURL .= "&amp;searchtag={$sVal}";
01875         }
01876 
01877         if ( $sVal = oxConfig::getParameter( 'recommid' ) ) {
01878             $sURL .= "&amp;recommid={$sVal}";
01879         }
01880 
01881         return $sURL;
01882     }
01883 
01889     protected function _getSeoRequestParams()
01890     {
01891         $sClass = $this->getClassName();
01892         $sFnc   = $this->getFncName();
01893 
01894         // #921 S
01895         $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher' );
01896         if ( in_array( $sFnc, $aFnc ) ) {
01897             $sFnc = '';
01898         }
01899 
01900         // #680
01901         $sURL = "cl={$sClass}";
01902         if ( $sFnc ) {
01903             $sURL .= "&amp;fnc={$sFnc}";
01904         }
01905         if ( $sVal = basename( oxConfig::getParameter( 'page' ) ) ) {
01906             $sURL .= "&amp;page={$sVal}";
01907         }
01908 
01909         if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
01910             $sURL .= "&amp;tpl={$sVal}";
01911         }
01912 
01913         $iPgNr = (int) oxConfig::getParameter( 'pgNr' );
01914         if ( $iPgNr > 0 ) {
01915             $sURL .= "&amp;pgNr={$iPgNr}";
01916         }
01917 
01918         return $sURL;
01919     }
01920 
01926     public function showSearch()
01927     {
01928         $blShow = true;
01929         if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) && $this->getIsOrderStep() ) {
01930             $blShow = false;
01931         }
01932         return (int) $blShow;
01933     }
01934 
01940     public function getRssLinks()
01941     {
01942         return $this->_aRssLinks;
01943     }
01944 
01950     public function getSortColumns()
01951     {
01952         return $this->_aSortColumns;
01953     }
01954 
01960     public function getEditTags()
01961     {
01962     }
01963 
01969     public function getRecommSearch()
01970     {
01971     }
01972 
01978     public function getPaymentList()
01979     {
01980     }
01981 
01987     public function getActiveRecommList()
01988     {
01989         if ( $this->_oActiveRecommList === null ) {
01990             $this->_oActiveRecommList = false;
01991             if ( $sOxid = oxConfig::getParameter( 'recommid' ) ) {
01992                 $this->_oActiveRecommList = oxNew( 'oxrecommlist' );
01993                 $this->_oActiveRecommList->load( $sOxid );
01994             }
01995         }
01996         return $this->_oActiveRecommList;
01997     }
01998 
02004     public function getAccessoires()
02005     {
02006     }
02007 
02013     public function getCrossSelling()
02014     {
02015     }
02016 
02022     public function getSimilarProducts()
02023     {
02024     }
02025 
02031     public function getAlsoBoughtTheseProducts()
02032     {
02033     }
02034 
02040     public function getArticleId()
02041     {
02042     }
02043 
02049     public function isMoreTagsVisible()
02050     {
02051         return false;
02052     }
02053 
02059     public function getTitle()
02060     {
02061         $sTranslationName = 'PAGE_TITLE_'.strtoupper($this->getConfig()->getActiveView()->getClassName());
02062         $sTranslated = oxLang::getInstance()->translateString( $sTranslationName, oxLang::getInstance()->getBaseLanguage(), false );
02063         return $sTranslationName == $sTranslated? null : $sTranslated;
02064     }
02065 
02071     public function getActiveLangAbbr()
02072     {
02073         // Performance
02074         if ( !$this->getConfig()->getConfigParam( 'bl_perfLoadLanguages' ) ) {
02075             return;
02076         }
02077 
02078         if ( !isset($this->_sActiveLangAbbr ) ) {
02079             $aLanguages = oxLang::getInstance()->getLanguageArray();
02080             while ( list( $sKey, $oVal ) = each( $aLanguages ) ) {
02081                 if ( $oVal->selected ) {
02082                     $this->_sActiveLangAbbr = $oVal->abbr;
02083                     break;
02084                 }
02085             }
02086         }
02087 
02088         return $this->_sActiveLangAbbr;
02089     }
02090 
02098     public function addGlobalParams( $oShop = null)
02099     {
02100         $oViewConf = parent::addGlobalParams( $oShop );
02101 
02102         $this->_setNrOfArtPerPage();
02103 
02104         return $oViewConf;
02105     }
02106 
02112     public function getAdditionalParams()
02113     {
02114         if ( $this->_sAdditionalParams === null ) {
02115             // #1018A
02116             $this->_sAdditionalParams  = parent::getAdditionalParams();
02117             $this->_sAdditionalParams .= 'cl='.$this->getConfig()->getActiveView()->getClassName();
02118 
02119             // #1834M - specialchar search
02120             $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) );
02121             if ( isset( $sSearchParamForLink ) ) {
02122                 $this->_sAdditionalParams .= "&amp;searchparam={$sSearchParamForLink}";
02123             }
02124             if ( ( $sVar = oxConfig::getParameter( 'searchtag' ) ) ) {
02125                 $this->_sAdditionalParams .= '&amp;searchtag='.rawurlencode( rawurldecode( $sVar ) );
02126             }
02127             if ( ( $sVar = oxConfig::getParameter( 'searchcnid' ) ) ) {
02128                 $this->_sAdditionalParams .= '&amp;searchcnid='.rawurlencode( rawurldecode( $sVar ) );
02129             }
02130             if ( ( $sVar = oxConfig::getParameter( 'searchvendor' ) ) ) {
02131                 $this->_sAdditionalParams .= '&amp;searchvendor='.rawurlencode( rawurldecode( $sVar ) );
02132             }
02133             if ( ( $sVar = oxConfig::getParameter( 'searchmanufacturer' ) ) ) {
02134                 $this->_sAdditionalParams .= '&amp;searchmanufacturer='.rawurlencode( rawurldecode( $sVar ) );
02135             }
02136             if ( ( $sVar = oxConfig::getParameter( 'cnid' ) ) ) {
02137                 $this->_sAdditionalParams .= '&amp;cnid='.rawurlencode( rawurldecode( $sVar ) );
02138             }
02139             if ( ( $sVar = oxConfig::getParameter( 'mnid' ) ) ) {
02140                 $this->_sAdditionalParams .= '&amp;mnid='.rawurlencode( rawurldecode( $sVar ) );
02141             }
02142         }
02143 
02144         return $this->_sAdditionalParams;
02145     }
02146 
02152     public function generatePageNavigationUrl()
02153     {
02154         return $this->getConfig()->getShopHomeURL().$this->_getRequestParams( false );
02155     }
02156 
02166     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null )
02167     {
02168         if ( $iPage ) {
02169             if ( ( strpos( $sUrl, 'pgNr=' ) ) ) {
02170                 $sUrl = preg_replace('/pgNr=[0-9]*/', 'pgNr='.$iPage, $sUrl);
02171             } else {
02172                 $sUrl .= ( ( strpos( $sUrl, '?' ) === false ) ? '?' : '&amp;' ) . 'pgNr='.$iPage;
02173             }
02174         } else {
02175            $sUrl = preg_replace('/pgNr=[0-9]*/', '', $sUrl);
02176            $sUrl = preg_replace('/\&amp\;\&amp\;/', '&amp;', $sUrl);
02177            $sUrl = preg_replace('/\?\&amp\;/', '?', $sUrl);
02178            $sUrl = preg_replace('/\&amp\;$/', '', $sUrl);
02179         }
02180         return $sUrl;
02181     }
02182 
02188     public function getPageNavigation()
02189     {
02190 
02191     }
02192 
02198     public function getPageNavigationLimitedTop()
02199     {
02200 
02201         $this->_oPageNavigation = $this->generatePageNavigation( 7 );
02202 
02203         return $this->_oPageNavigation;
02204     }
02205 
02211     public function getPageNavigationLimitedBottom()
02212     {
02213 
02214         $this->_oPageNavigation = $this->generatePageNavigation( 11 );
02215 
02216         return $this->_oPageNavigation;
02217     }
02218 
02219 
02227     public function generatePageNavigation( $iPositionCount = 0 )
02228     {
02229         startProfile('generatePageNavigation');
02230 
02231         $pageNavigation = new stdClass();
02232 
02233         $pageNavigation->NrOfPages = $this->_iCntPages;
02234         $iActPage = $this->getActPage();
02235         $pageNavigation->actPage   = $iActPage + 1;
02236         $sUrl = $this->generatePageNavigationUrl();
02237 
02238         if ( $iPositionCount == 0 || ($iPositionCount >= $pageNavigation->NrOfPages) ) {
02239              $iStartNo = 2;
02240              $iFinishNo = $pageNavigation->NrOfPages;
02241              $bStart = false;
02242              $bFinish =false;
02243         } else {
02244             $iTmpVal = $iPositionCount - 3;
02245             $iTmpVal2 = floor( ( $iPositionCount - 4 ) / 2 );
02246 
02247             // actual page is at the start
02248             if ( $pageNavigation->actPage <= $iTmpVal ) {
02249                 $iStartNo = 2;
02250                 $iFinishNo = $iTmpVal + 1;
02251                 $bStart = false;
02252                 $bFinish = true;
02253             // actual page is at the end
02254             } elseif ( $pageNavigation->actPage >= $pageNavigation->NrOfPages - $iTmpVal ) {
02255                 $iStartNo = $pageNavigation->NrOfPages - $iTmpVal;
02256                 $iFinishNo = $pageNavigation->NrOfPages - 1;
02257                 $bStart = true;
02258                 $bFinish = false;
02259             // actual page is in the midle
02260             } else {
02261                 $iStartNo = $pageNavigation->actPage - $iTmpVal2;
02262                 $iFinishNo = $pageNavigation->actPage + $iTmpVal2;
02263                 $bStart = true;
02264                 $bFinish = true;
02265             }
02266         }
02267 
02268         if ( $iActPage > 0) {
02269             $pageNavigation->previousPage = $this->_addPageNrParam( $sUrl, $iActPage - 1 );
02270         }
02271 
02272         if ( $iActPage < $pageNavigation->NrOfPages - 1 ) {
02273             $pageNavigation->nextPage = $this->_addPageNrParam( $sUrl, $iActPage + 1 );
02274         }
02275 
02276         if ( $pageNavigation->NrOfPages > 1 ) {
02277 
02278             for ( $i=1; $i < $pageNavigation->NrOfPages + 1; $i++ ) {
02279 
02280                 if ( $i == 1 || $i == $pageNavigation->NrOfPages || ( $i >= $iStartNo && $i <= $iFinishNo ) ) {
02281                     $page = new Oxstdclass();
02282                     $page->url = $this->_addPageNrParam( $sUrl, $i - 1 );
02283                     $page->selected = ( $i == $pageNavigation->actPage ) ? 1 : 0;
02284                     $pageNavigation->changePage[$i] = $page;
02285                 }
02286             }
02287 
02288             // first/last one
02289             $pageNavigation->firstpage = $this->_addPageNrParam( $sUrl, 0 );
02290             $pageNavigation->lastpage  = $this->_addPageNrParam( $sUrl, $pageNavigation->NrOfPages - 1 );
02291         }
02292 
02293         stopProfile('generatePageNavigation');
02294 
02295         return $pageNavigation;
02296     }
02297 
02304     public function getArticleCount()
02305     {
02306         return $this->_iAllArtCnt;
02307     }
02308 
02315     public function render()
02316     {
02317         foreach ( array_keys( $this->_oaComponents ) as $sComponentName ) {
02318             $this->_aViewData[$sComponentName] = $this->_oaComponents[$sComponentName]->render();
02319         }
02320 
02321         parent::render();
02322 
02323         if ( $this->getIsOrderStep() ) {
02324 
02325             // disabling navigation during order ...
02326             if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) ) {
02327                 $this->_iNewsRealStatus = 1;
02328                 $this->setShowNewsletter( 0 );
02329                 $this->setShowRightBasket( 0 );
02330                 $this->setShowLeftBasket( 0 );
02331                 $this->setShowTopBasket( 0 );
02332             }
02333         }
02334         return $this->_sThisTemplate;
02335     }
02336 
02342     public function getViewProduct()
02343     {
02344         return $this->getProduct();
02345     }
02346 
02354     public function setViewProduct( $oProduct )
02355     {
02356         $this->_oProduct = $oProduct;
02357     }
02358 
02364     public function getViewProductList()
02365     {
02366         return $this->_aArticleList;
02367     }
02368 
02374     public function getActPage()
02375     {
02376         if ( $this->_iActPage === null ) {
02377             $this->_iActPage = ( int ) oxConfig::getParameter( 'pgNr' );
02378             $this->_iActPage = ( $this->_iActPage < 0 ) ? 0 : $this->_iActPage;
02379         }
02380         return $this->_iActPage;
02381     }
02382 
02390     public function getActTag()
02391     {
02392         if ( $this->_oActTag === null ) {
02393             $this->_oActTag = new Oxstdclass();
02394             $this->_oActTag->sTag = $sTag = oxConfig::getParameter("searchtag", 1);
02395             $oSeoEncoderTag = oxSeoEncoderTag::getInstance();
02396 
02397             $sLink = false;
02398             if ( oxUtils::getInstance()->seoIsActive() ) {
02399                 $sLink = $oSeoEncoderTag->getTagUrl( $sTag, oxLang::getInstance()->getBaseLanguage() );
02400             }
02401 
02402             $this->_oActTag->link = $sLink ? $sLink : $this->getConfig()->getShopHomeURL().$oSeoEncoderTag->getStdTagUri( $sTag, false );
02403         }
02404         return $this->_oActTag;
02405     }
02406 
02414     public function getActVendor()
02415     {
02416         // if active vendor is not set yet - trying to load it from request params
02417         // this may be usefull when category component was unable to load active vendor
02418         // and we still need some object to mount navigation info
02419         if ( $this->_oActVendor === null ) {
02420             $this->_oActVendor = false;
02421             $sVendorId = oxConfig::getParameter( 'cnid' );
02422             $sVendorId = $sVendorId ? str_replace( 'v_', '', $sVendorId ) : $sVendorId;
02423             $oVendor = oxNew( 'oxvendor' );
02424             if ( $oVendor->load( $sVendorId ) ) {
02425                 $this->_oActVendor = $oVendor;
02426             }
02427         }
02428 
02429         return $this->_oActVendor;
02430     }
02431 
02439     public function getActManufacturer()
02440     {
02441         // if active Manufacturer is not set yet - trying to load it from request params
02442         // this may be usefull when category component was unable to load active Manufacturer
02443         // and we still need some object to mount navigation info
02444         if ( $this->_oActManufacturer === null ) {
02445 
02446             $this->_oActManufacturer = false;
02447             $sManufacturerId = oxConfig::getParameter( 'mnid' );
02448             $oManufacturer = oxNew( 'oxmanufacturer' );
02449             if ( $oManufacturer->load( $sManufacturerId ) ) {
02450                 $this->_oActManufacturer = $oManufacturer;
02451             }
02452         }
02453 
02454         return $this->_oActManufacturer;
02455     }
02456 
02464     public function setActVendor( $oVendor )
02465     {
02466         $this->_oActVendor = $oVendor;
02467     }
02468 
02476     public function setActManufacturer( $oManufacturer )
02477     {
02478         $this->_oActManufacturer = $oManufacturer;
02479     }
02480 
02486     public function getActSearch()
02487     {
02488         if ( $this->_oActSearch === null ) {
02489             $this->_oActSearch = new oxStdClass();
02490             $sUrl = $this->getConfig()->getShopHomeURL();
02491             $this->_oActSearch->link = "{$sUrl}cl=search";
02492         }
02493         return $this->_oActSearch;
02494     }
02495 
02501     public function getCategoryTree()
02502     {
02503         return $this->_oCategoryTree;
02504     }
02505 
02513     public function setCategoryTree( $oCatTree )
02514     {
02515         $this->_oCategoryTree = $oCatTree;
02516     }
02517 
02523     public function getVendorTree()
02524     {
02525         return $this->_oVendorTree;
02526     }
02527 
02535     public function setVendorTree( $oVendorTree )
02536     {
02537         $this->_oVendorTree = $oVendorTree;
02538     }
02539 
02545     public function getManufacturerTree()
02546     {
02547         return $this->_oManufacturerTree;
02548     }
02549 
02557     public function setManufacturerTree( $oManufacturerTree )
02558     {
02559         $this->_oManufacturerTree = $oManufacturerTree;
02560     }
02561 
02567     public function getAddUrlParams()
02568     {
02569     }
02570 
02577     public function getTop5ArticleList()
02578     {
02579         if ( $this->_blTop5Action ) {
02580             if ( $this->_aTop5ArticleList === null ) {
02581                 $this->_aTop5ArticleList = false;
02582                 $myConfig = $this->getConfig();
02583                 if ( $myConfig->getConfigParam( 'bl_perfLoadAktion' ) ) {
02584                     // top 5 articles
02585                     $oArtList = oxNew( 'oxarticlelist' );
02586                     $oArtList->loadTop5Articles();
02587                     if ( $oArtList->count() ) {
02588                         $this->_aTop5ArticleList = $oArtList;
02589                     }
02590                 }
02591             }
02592         }
02593         return $this->_aTop5ArticleList;
02594     }
02595 
02602     public function getBargainArticleList()
02603     {
02604         if ( $this->_blBargainAction ) {
02605             if ( $this->_aBargainArticleList === null ) {
02606                 $this->_aBargainArticleList = array();
02607                 if ( $this->getConfig()->getConfigParam( 'bl_perfLoadAktion' ) ) {
02608                     $oArtList = oxNew( 'oxarticlelist' );
02609                     $oArtList->loadAktionArticles( 'OXBARGAIN' );
02610                     if ( $oArtList->count() ) {
02611                         $this->_aBargainArticleList = $oArtList;
02612                     }
02613                 }
02614             }
02615         }
02616         return $this->_aBargainArticleList;
02617     }
02618 
02625     public function isLowOrderPrice()
02626     {
02627         if ( $this->_blLowOrderPrice === null && ( $oBasket = $this->getSession()->getBasket() ) ) {
02628             $this->_blLowOrderPrice = $oBasket->isBelowMinOrderPrice();
02629         }
02630 
02631         return $this->_blLowOrderPrice;
02632     }
02633 
02639     public function getMinOrderPrice()
02640     {
02641         if ( $this->_sMinOrderPrice === null && $this->isLowOrderPrice() ) {
02642             $dMinOrderPrice = oxPrice::getPriceInActCurrency( $this->getConfig()->getConfigParam( 'iMinOrderPrice' ) );
02643             $this->_sMinOrderPrice = oxLang::getInstance()->formatCurrency( $dMinOrderPrice );
02644         }
02645         return $this->_sMinOrderPrice;
02646     }
02647 
02653     public function getNewsRealStatus()
02654     {
02655         return $this->_iNewsRealStatus;
02656     }
02657 
02663     protected function _canRedirect()
02664     {
02665         foreach ( $this->_aBlockRedirectParams as $sParam ) {
02666             if ( oxConfig::getParameter( $sParam ) !== null ) {
02667                 return false;
02668             }
02669         }
02670 
02671         return true;
02672     }
02673 
02679     public function getProduct()
02680     {
02681     }
02682 
02688     public function getVendorlist()
02689     {
02690         return $this->_aVendorlist;
02691     }
02692 
02700     public function setVendorlist( $aList )
02701     {
02702         $this->_aVendorlist = $aList;
02703     }
02704 
02710     public function getManufacturerlist()
02711     {
02712         return $this->_aManufacturerlist;
02713     }
02714 
02722     public function setManufacturerlist( $aList )
02723     {
02724         $this->_aManufacturerlist = $aList;
02725     }
02726 
02734     public function setRootVendor( $oVendor )
02735     {
02736         $this->_oRootVendor = $oVendor;
02737     }
02738 
02744     public function getRootVendor()
02745     {
02746         return $this->_oRootVendor;
02747     }
02748 
02756     public function setRootManufacturer( $oManufacturer )
02757     {
02758         $this->_oRootManufacturer = $oManufacturer;
02759     }
02760 
02766     public function getRootManufacturer()
02767     {
02768         return $this->_oRootManufacturer;
02769     }
02770 
02776     public function getVendorId()
02777     {
02778         if ( $this->_sVendorId === null ) {
02779             $this->_sVendorId = false;
02780             if ( ( $oVendor = $this->getActVendor() ) ) {
02781                 $this->_sVendorId = $oVendor->getId();
02782             }
02783         }
02784         return $this->_sVendorId;
02785     }
02786 
02792     public function getManufacturerId()
02793     {
02794         if ( $this->_sManufacturerId === null ) {
02795             $this->_sManufacturerId = false;
02796             if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
02797                 $this->_sManufacturerId = $oManufacturer->getId();
02798             }
02799         }
02800         return $this->_sManufacturerId;
02801     }
02802 
02808     public function getSearchCatTree()
02809     {
02810         return $this->_aSearchCatTree;
02811     }
02812 
02820     public function setSearchCatTree( $aTree )
02821     {
02822         $this->_aSearchCatTree = $aTree;
02823     }
02824 
02830     public function getCatMoreUrl()
02831     {
02832         return $this->getConfig()->getShopHomeURL().'cnid=oxmore';
02833     }
02834 
02840     public function getCatMore()
02841     {
02842         return $this->_oCatMore;
02843     }
02844 
02852     public function setCatMore( $oCat )
02853     {
02854         $this->_oCatMore = $oCat;
02855     }
02856 
02862     public function getCatTreePath()
02863     {
02864         return $this->_sCatTreePath;
02865     }
02866 
02874     public function getContentByIdent( $sIdent )
02875     {
02876         if ( !isset( $this->_aContents[$sIdent] ) ) {
02877             $this->_aContents[$sIdent] = oxNew( 'oxcontent' );
02878             $this->_aContents[$sIdent]->loadByIdent( $sIdent );
02879         }
02880         return $this->_aContents[$sIdent];
02881     }
02882 
02888     public function getContentCategory()
02889     {
02890         return false;
02891     }
02892 
02898     public function getMustFillFields()
02899     {
02900         if ( $this->_aMustFillFields === null ) {
02901             $this->_aMustFillFields = false;
02902 
02903             // passing must-be-filled-fields info
02904             $aMustFillFields = $this->getConfig()->getConfigParam( 'aMustFillFields' );
02905             if ( is_array( $aMustFillFields ) ) {
02906                 $this->_aMustFillFields = array_flip( $aMustFillFields );
02907             }
02908         }
02909         return $this->_aMustFillFields;
02910     }
02911 
02919     public function isFieldRequired( $sField )
02920     {
02921         if ( $aMustFillFields = $this->getMustFillFields() ) {
02922             if ( isset( $aMustFillFields[$sField] ) ) {
02923                 return true;
02924             }
02925         }
02926 
02927         return false;
02928     }
02929 
02935     public function getFormId()
02936     {
02937         if ( $this->_sFormId === null ) {
02938             $this->_sFormId = oxUtilsObject::getInstance()->generateUId();
02939             oxSession::setVar( 'sessionuformid', $this->_sFormId );
02940         }
02941 
02942         return $this->_sFormId;
02943     }
02944 
02950     public function canAcceptFormData()
02951     {
02952         if ( $this->_blCanAcceptFormData === null ) {
02953             $this->_blCanAcceptFormData = false;
02954 
02955             $sFormId = oxConfig::getParameter( "uformid" );
02956             $sSessionFormId = oxSession::getVar( "sessionuformid" );
02957 
02958             // testing if form and session ids matches
02959             if ( $sFormId && $sFormId === $sSessionFormId ) {
02960                 $this->_blCanAcceptFormData = true;
02961             }
02962 
02963             // regenerating form data
02964             $this->getFormId();
02965         }
02966         return $this->_blCanAcceptFormData;
02967     }
02968 
02974     public function getPromoFinishedList()
02975     {
02976         if (isset($this->_oPromoFinishedList)) {
02977             return $this->_oPromoFinishedList;
02978         }
02979         $this->_oPromoFinishedList = oxNew( 'oxActionList' );
02980         $this->_oPromoFinishedList->loadFinishedByCount(2);
02981         return $this->_oPromoFinishedList;
02982     }
02983 
02989     public function getPromoCurrentList()
02990     {
02991         if (isset($this->_oPromoCurrentList)) {
02992             return $this->_oPromoCurrentList;
02993         }
02994         $this->_oPromoCurrentList = oxNew( 'oxActionList' );
02995         $this->_oPromoCurrentList->loadCurrent();
02996         return $this->_oPromoCurrentList;
02997     }
02998 
03004     public function getPromoFutureList()
03005     {
03006         if (isset($this->_oPromoFutureList)) {
03007             return $this->_oPromoFutureList;
03008         }
03009         $this->_oPromoFutureList = oxNew( 'oxActionList' );
03010         $this->_oPromoFutureList->loadFutureByCount(2);
03011         return $this->_oPromoFutureList;
03012     }
03013 
03019     public function getShowPromotionList()
03020     {
03021         if (isset($this->_blShowPromotions)) {
03022             return $this->_blShowPromotions;
03023         }
03024         $this->_blShowPromotions = false;
03025         if (oxNew('oxActionList')->areAnyActivePromotions()) {
03026             $this->_blShowPromotions = ( count( $this->getPromoFinishedList() ) + count( $this->getPromoCurrentList() ) + count( $this->getPromoFutureList() ) ) > 0;
03027         }
03028         return $this->_blShowPromotions;
03029     }
03030 
03036     public function isEnabledPrivateSales()
03037     {
03038         if ( $this->_blEnabledPrivateSales === null ) {
03039             $this->_blEnabledPrivateSales = (bool) $this->getConfig()->getConfigParam( 'blPsLoginEnabled' );
03040             if ( $this->_blEnabledPrivateSales && ( $blCanPreview = oxUtils::getInstance()->canPreview() ) !== null ) {
03041                 $this->_blEnabledPrivateSales = !$blCanPreview;
03042             }
03043         }
03044         return $this->_blEnabledPrivateSales;
03045     }
03046 
03052     public function getTagCloudManager()
03053     {
03054         if ( $this->_blShowTagCloud ) {
03055             return oxNew( "oxTagCloud" );
03056         } else {
03057             return false;
03058         }
03059     }
03060 
03066     public function getFieldValidationErrors()
03067     {
03068         return oxInputValidator::getInstance()->getFieldValidationErrors();
03069     }
03070 
03076     public function getBreadCrumb()
03077     {
03078         return null;
03079     }
03080 
03088     public function setRootCatChanged( $blRootCatChanged )
03089     {
03090         $this->_blRootCatChanged = $blRootCatChanged;
03091     }
03092 
03098     public function isRootCatChanged()
03099     {
03100         return $this->_blRootCatChanged;
03101     }
03102 
03108     public function getInvoiceAddress()
03109     {
03110         if ( $this->_aInvoiceAddress == null ) {
03111             $aAddress = oxConfig::getParameter( 'invadr');
03112             if ( $aAddress ) {
03113                 $this->_aInvoiceAddress = $aAddress;
03114             }
03115         }
03116         return $this->_aInvoiceAddress;
03117     }
03118 
03124     public function getDeliveryAddress()
03125     {
03126         if ( $this->_aDeliveryAddress == null ) {
03127             $aAddress = oxConfig::getParameter( 'deladr');
03128             //do not show deladr if address was reloaded
03129             if ( $aAddress && !oxConfig::getParameter( 'reloadaddress' )) {
03130                 $this->_aDeliveryAddress = $aAddress;
03131             }
03132         }
03133         return $this->_aDeliveryAddress;
03134     }
03135 
03143     public function setInvoiceAddress( $aAddress )
03144     {
03145         $this->_aInvoiceAddress = $aAddress;
03146     }
03147 
03153     public function getActiveUsername()
03154     {
03155         if ( $this->_sActiveUsername == null ) {
03156             $this->_sActiveUsername = false;
03157             $sUsername = oxConfig::getParameter( 'lgn_usr' );
03158             if ( $sUsername ) {
03159                 $this->_sActiveUsername = $sUsername;
03160             } elseif ( $oUser = $this->getUser() ) {
03161                 $this->_sActiveUsername = $oUser->oxuser__oxusername->value;
03162             }
03163         }
03164         return $this->_sActiveUsername;
03165     }
03166 
03172     public function getWishlistUserId()
03173     {
03174         return oxConfig::getParameter( 'wishid' );
03175     }
03176 
03182     public function getSearchCatId()
03183     {
03184     }
03185 
03191     public function getSearchVendor()
03192     {
03193     }
03194 
03200     public function getSearchManufacturer()
03201     {
03202     }
03203 
03209     public function getLastProducts()
03210     {
03211 
03212     }
03213 
03219     public function getNewBasketItemMsgType()
03220     {
03221         return (int) $this->getConfig()->getConfigParam( "iNewBasketItemMessage" );
03222     }
03223 
03229     public function showTags()
03230     {
03231         return (bool) $this->getConfig()->getConfigParam( "blShowTags" );
03232     }
03233 
03241     public function isActive( $sName )
03242     {
03243         return $this->getConfig()->getConfigParam( "bl".$sName."Enabled" );
03244     }
03245 
03251     public function isFbWidgetVisible()
03252     {
03253         if ( $this->_blFbWidgetsOn === null ) {
03254             $oUtils = oxUtilsServer::getInstance();
03255 
03256             // reading ..
03257             $this->_blFbWidgetsOn = (bool) $oUtils->getOxCookie( "fbwidgetson" );
03258         }
03259         return $this->_blFbWidgetsOn;
03260     }
03261 
03267     public function isEnabledDownloadableFiles()
03268     {
03269         return (bool) $this->getConfig()->getConfigParam( "blEnableDownloads" );
03270     }
03271 
03277     public function showRememberMe()
03278     {
03279         return (bool) $this->getConfig()->getConfigParam('blShowRememberMe');
03280     }
03281 
03288     public function isVatIncluded()
03289     {
03290         $blResult = true;
03291         $oUser = $this->getUser();
03292         $oVatSelector = oxNew( 'oxVatSelector' );
03293         $oConfig = $this->getConfig();
03294 
03295         if ( $oConfig->getConfigParam( 'blEnterNetPrice' ) && $oConfig->getConfigParam( 'bl_perfCalcVatOnlyForBasketOrder' ) ) {
03296             $blResult = false;
03297         } elseif ( $oUser && !$oVatSelector->getUserVat( $oUser ) ) {
03298             $blResult = false;
03299         }
03300 
03301         return $blResult;
03302     }
03303 
03309     public function isPriceCalculated()
03310     {
03311         return (bool) $this->getConfig()->getConfigParam( 'bl_perfLoadPrice' );
03312     }
03313 
03314 }