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 
00260     protected $_blActiveSorting = null;
00261 
00266     protected $_aMenueList = null;
00267 
00273     protected $_aComponentNames = array(
00274                                     'oxcmp_user'       => 1, // 0 means dont init if cached
00275                                     'oxcmp_lang'       => 0,
00276                                     'oxcmp_cur'        => 1,
00277                                     'oxcmp_shop'       => 1,
00278                                     'oxcmp_categories' => 0,
00279                                     'oxcmp_utils'      => 1,
00280                                     'oxcmp_news'       => 0,
00281                                     'oxcmp_basket'     => 1
00282                                   );
00283 
00289     protected $_aUserComponentNames = array();
00290 
00296     protected $_oProduct = null;
00297 
00302     protected $_iActPage = null;
00303 
00308     protected $_aArticleList = null;
00309 
00314     protected $_oManufacturerTree  = null;
00315 
00320     protected $_oCategoryTree  = null;
00321 
00326     protected $_aTop5ArticleList  = null;
00327 
00332     protected $_aBargainArticleList  = null;
00333 
00338     protected $_blLowOrderPrice = null;
00339 
00344     protected $_sMinOrderPrice  = null;
00345 
00350     protected $_iNewsRealStatus  = null;
00351 
00357     protected $_aBlockRedirectParams = array( 'fnc', 'stoken', 'force_sid', 'force_admin_sid' );
00358 
00363     protected $_oRootVendor = null;
00364 
00369     protected $_sVendorId = null;
00370 
00375     protected $_aManufacturerlist = null;
00376 
00381     protected $_oRootManufacturer = null;
00382 
00387     protected $_sManufacturerId = null;
00388 
00393     protected $_aSearchCatTree = null;
00394 
00399     protected $_blNewsSubscribed = null;
00400 
00405     protected $_oDelAddress = null;
00406 
00411     protected $_sCatTreePath = null;
00412 
00417     protected $_aContents = array();
00418 
00423     protected $_blTop5Action = true;
00424 
00429     protected $_blBargainAction = false;
00430 
00436     protected $_aMustFillFields = null;
00437 
00442     protected $_blShowTagCloud = true;
00443 
00448     protected $_blRootCatChanged = false;
00449 
00454     protected $_aInvoiceAddress = null;
00455 
00460     protected $_aDeliveryAddress = null;
00461 
00466     protected $_sActiveUsername = null;
00467 
00473     protected static $_aCollectedComponentNames = null;
00474 
00481     protected $_blLoadComponents = true;
00482 
00488     protected function _getComponentNames()
00489     {
00490         if ( self::$_aCollectedComponentNames === null ) {
00491             self::$_aCollectedComponentNames = array_merge( $this->_aComponentNames, $this->_aUserComponentNames );
00492 
00493             // #1721: custom component handling. At the moment it is not possible to override this variable in oxubase,
00494             // so we added this array to config.inc.php file
00495             if ( ( $aUserCmps = $this->getConfig()->getConfigParam( 'aUserComponentNames' ) ) ) {
00496                 self::$_aCollectedComponentNames = array_merge( self::$_aCollectedComponentNames, $aUserCmps );
00497             }
00498 
00499             if ( oxConfig::getParameter( '_force_no_basket_cmp' ) ) {
00500                 unset( self::$_aCollectedComponentNames['oxcmp_basket'] );
00501             }
00502         }
00503 
00504         // resetting array pointer
00505         reset( self::$_aCollectedComponentNames );
00506         return self::$_aCollectedComponentNames;
00507     }
00508 
00517     protected function _processRequest()
00518     {
00519         $myUtils = oxRegistry::getUtils();
00520 
00521         // non admin, request is not empty and was not processed by seo engine
00522         if ( !isSearchEngineUrl() && $myUtils->seoIsActive() && ( $sStdUrl = getRequestUrl( '', true ) ) ) {
00523 
00524             // fetching standard url and looking for it in seo table
00525             if ( $this->_canRedirect() && ( $sRedirectUrl = oxRegistry::get("oxSeoEncoder")->fetchSeoUrl( $sStdUrl ) ) ) {
00526                 $myUtils->redirect( $this->getConfig()->getCurrentShopUrl() . $sRedirectUrl, false );
00527             } elseif (VIEW_INDEXSTATE_INDEX == $this->noIndex()) {
00528                 // forcing to set noindex/follow meta
00529                 $this->_forceNoIndex();
00530 
00531                 if (!$this->getConfig()->isProductiveMode() || $this->getConfig()->getConfigParam('blSeoLogging')) {
00532                     $sShopId = $this->getConfig()->getShopId();
00533                     $sLangId = oxRegistry::getLang()->getBaseLanguage();
00534                     $sIdent  = md5( strtolower( $sStdUrl ) . $sShopId . $sLangId );
00535 
00536                     // logging "not found" url
00537                     $oDb = oxDb::getDb();
00538                     $oDb->execute( "replace oxseologs ( oxstdurl, oxident, oxshopid, oxlang )
00539                                     values ( " . $oDb->quote( $sStdUrl ) . ", '{$sIdent}', '{$sShopId}', '{$sLangId}' ) " );
00540                 }
00541             }
00542         }
00543     }
00544 
00551     public function init()
00552     {
00553         $this->_processRequest();
00554 
00555         // storing current view
00556         $blInit = true;
00557 
00558 
00559         // init all components if there are any
00560         if ( $this->_blLoadComponents ) {
00561             foreach ( $this->_getComponentNames() as $sComponentName => $blNotCacheable ) {
00562                 // do not override initiated components
00563                 if ( !isset( $this->_oaComponents[$sComponentName] ) ) {
00564                     // component objects MUST be created to support user called functions
00565                     $oComponent = oxNew( $sComponentName );
00566                     $oComponent->setParent( $this );
00567                     $oComponent->setThisAction( $sComponentName );
00568                     $this->_oaComponents[$sComponentName] = $oComponent;
00569                 }
00570 
00571                 // do we really need to initiate them ?
00572                 if ( $blInit ) {
00573                     $this->_oaComponents[$sComponentName]->init();
00574 
00575                     // executing only is view does not have action method
00576                     if ( !method_exists( $this, $this->getFncName() ) ) {
00577                         $this->_oaComponents[$sComponentName]->executeFunction( $this->getFncName() );
00578                     }
00579                 }
00580             }
00581         }
00582 
00583         parent::init();
00584 
00585         // enable sorting ?
00586         if ( $this->showSorting() ) {
00587             $this->prepareSortColumns();
00588         }
00589     }
00590 
00597     public function getViewId()
00598     {
00599         if ( $this->_sViewId ) {
00600             return $this->_sViewId;
00601         }
00602 
00603         $myConfig = $this->getConfig();
00604         $iLang = oxRegistry::getLang()->getBaseLanguage();
00605         $iCur  = (int) $myConfig->getShopCurrency();
00606 
00607 
00608             $this->_sViewId =  "ox|$iLang|$iCur";
00609 
00610         $this->_sViewId .= "|".( (int) $this->_blForceNoIndex ).'|'.((int)$this->isRootCatChanged());
00611 
00612         // #0002866: external global viewID addition
00613         if (function_exists('customGetViewId')) {
00614             $oExtViewId = customGetViewId();
00615 
00616             if ($oExtViewId !== null) {
00617                 $this->_sViewId .= '|'.md5(serialize($oExtViewId));
00618             }
00619         }
00620 
00621         return $this->_sViewId;
00622     }
00623 
00624 
00630     public function showSorting()
00631     {
00632         return $this->_blShowSorting && $this->getConfig()->getConfigParam( 'blShowSorting' );
00633     }
00634 
00642     public function setComponents( $aComponents = null )
00643     {
00644         $this->_oaComponents = $aComponents;
00645     }
00646 
00652     public function getComponents()
00653     {
00654         return $this->_oaComponents;
00655     }
00656 
00664     public function getComponent( $sName )
00665     {
00666         if ( $sName != null ) {
00667             return $this->_oaComponents[$sName];
00668         }
00669     }
00677     public function setIsOrderStep( $blIsOrderStep = null )
00678     {
00679         $this->_blIsOrderStep = $blIsOrderStep;
00680     }
00681 
00687     public function getIsOrderStep()
00688     {
00689         return $this->_blIsOrderStep;
00690     }
00691 
00692 
00700     public function setActiveCategory( $oCategory )
00701     {
00702         $this->_oActCategory = $oCategory;
00703     }
00704 
00710     public function getActiveCategory()
00711     {
00712         return $this->_oActCategory;
00713     }
00714 
00720     public function getListType()
00721     {
00722         if ( $this->_sListType == null ) {
00723             if ( $sListType = oxConfig::getParameter( 'listtype' ) ) {
00724                 $this->_sListType = $sListType;
00725             } elseif ( $sListType = $this->getConfig()->getGlobalParameter( 'listtype' ) ) {
00726                 $this->_sListType = $sListType;
00727             }
00728         }
00729         return $this->_sListType;
00730     }
00731 
00737     public function getListDisplayType()
00738     {
00739         if ( $this->_sListDisplayType == null ) {
00740             $this->_sListDisplayType = $this->getCustomListDisplayType();
00741 
00742             if ( !$this->_sListDisplayType ) {
00743                 $this->_sListDisplayType = $this->getConfig()->getConfigParam( 'sDefaultListDisplayType' );
00744             }
00745 
00746             $this->_sListDisplayType = in_array( ( string ) $this->_sListDisplayType, $this->_aListDisplayTypes ) ? $this->_sListDisplayType : 'infogrid';
00747 
00748             // writing to session
00749             if ( oxConfig::getParameter( 'ldtype' ) ) {
00750                 oxSession::setVar( 'ldtype', $this->_sListDisplayType );
00751             }
00752         }
00753         return $this->_sListDisplayType;
00754     }
00755 
00761     public function getCustomListDisplayType()
00762     {
00763         if ( $this->_sCustomListDisplayType == null ) {
00764             $this->_sCustomListDisplayType = oxConfig::getParameter( 'ldtype' );
00765 
00766             if ( !$this->_sCustomListDisplayType ) {
00767                 $this->_sCustomListDisplayType = oxSession::getVar( 'ldtype' );
00768             }
00769         }
00770         return $this->_sCustomListDisplayType;
00771     }
00772 
00780     public function setListType( $sType )
00781     {
00782         $this->_sListType = $sType;
00783         $this->getConfig()->setGlobalParameter( 'listtype', $sType );
00784     }
00785 
00791     public function loadCurrency()
00792     {
00793         if ( $this->_blLoadCurrency == null ) {
00794             $this->_blLoadCurrency = false;
00795             if ( $blLoadCurrency = $this->getConfig()->getConfigParam( 'bl_perfLoadCurrency' ) ) {
00796                 $this->_blLoadCurrency = $blLoadCurrency;
00797             }
00798         }
00799         return $this->_blLoadCurrency;
00800     }
00801 
00807     public function dontShowEmptyCategories()
00808     {
00809         if ( $this->_blDontShowEmptyCats == null ) {
00810             $this->_blDontShowEmptyCats = false;
00811             if ( $blDontShowEmptyCats = $this->getConfig()->getConfigParam( 'blDontShowEmptyCategories' ) ) {
00812                 $this->_blDontShowEmptyCats = $blDontShowEmptyCats;
00813             }
00814         }
00815         return $this->_blDontShowEmptyCats;
00816     }
00817 
00823     public function showCategoryArticlesCount()
00824     {
00825         return $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' );
00826     }
00827 
00833     public function isLanguageLoaded()
00834     {
00835         if ( $this->_blLoadLanguage == null ) {
00836             $this->_blLoadLanguage = false;
00837             if ( $blLoadLanguage = $this->getConfig()->getConfigParam( 'bl_perfLoadLanguages' ) ) {
00838                 $this->_blLoadLanguage = $blLoadLanguage;
00839             }
00840         }
00841         return $this->_blLoadLanguage;
00842     }
00843 
00849     public function getTopNavigationCatCnt()
00850     {
00851         if ( $this->_iTopCatNavItmCnt == null ) {
00852             $iTopCatNavItmCnt = $this->getConfig()->getConfigParam( 'iTopNaviCatCount' );
00853             $this->_iTopCatNavItmCnt = $iTopCatNavItmCnt ? $iTopCatNavItmCnt : 5;
00854         }
00855         return $this->_iTopCatNavItmCnt;
00856     }
00857 
00867     public function addRssFeed($sTitle, $sUrl, $key = null)
00868     {
00869         if (!is_array($this->_aRssLinks)) {
00870             $this->_aRssLinks = array();
00871         }
00872 
00873         $sUrl = oxRegistry::get("oxUtilsUrl")->prepareUrlForNoSession($sUrl);
00874 
00875         if ($key === null) {
00876             $this->_aRssLinks[] = array('title'=>$sTitle, 'link' => $sUrl);
00877         } else {
00878             $this->_aRssLinks[$key] = array('title'=>$sTitle, 'link' => $sUrl);
00879         }
00880     }
00881 
00887     public function getSortOrderByParameterName()
00888     {
00889         return 'listorderby';
00890     }
00891 
00897     public function getSortOrderParameterName()
00898     {
00899         return 'listorder';
00900     }
00901 
00912     public function prepareSortColumns()
00913     {
00914         $aSortColumns = $this->getConfig()->getConfigParam( 'aSortCols' );
00915         $aSortDir = array( 'desc', 'asc' );
00916         if ( count( $aSortColumns ) > 0 ) {
00917 
00918             $this->_blActiveSorting = true;
00919             $this->_aSortColumns = $aSortColumns;
00920 
00921             $sCnid = oxConfig::getParameter( 'cnid' );
00922 
00923 
00924             $sSortBy  = oxConfig::getParameter( $this->getSortOrderByParameterName() );
00925             $sSortDir = oxConfig::getParameter( $this->getSortOrderParameterName() );
00926 
00927             $oStr = getStr();
00928             if ( (!$sSortBy || !in_array( $oStr->strtolower($sSortBy), $aSortColumns) || !in_array( $oStr->strtolower($sSortDir), $aSortDir) ) && $aSorting = $this->getSorting( $sCnid ) ) {
00929                 $sSortBy  = $aSorting['sortby'];
00930                 $sSortDir = $aSorting['sortdir'];
00931             }
00932 
00933             if ( $sSortBy && oxDb::getInstance()->isValidFieldName( $sSortBy ) &&
00934                  $sSortDir && oxRegistry::getUtils()->isValidAlpha( $sSortDir ) ) {
00935 
00936                 $this->_sListOrderBy  = $sSortBy;
00937                 $this->_sListOrderDir = $sSortDir;
00938 
00939                 // caching sorting config
00940                 $this->setItemSorting( $sCnid, $sSortBy, $sSortDir );
00941             }
00942         }
00943     }
00944 
00950     public function getListOrderBy()
00951     {
00952         //if column is with table name split it
00953         $aColums = explode('.', $this->_sListOrderBy);
00954 
00955         if ( is_array($aColums) && count($aColums) > 1 ) {
00956            return $aColums[1];
00957         }
00958 
00959         return $this->_sListOrderBy;
00960     }
00961 
00967     public function getListOrderDirection()
00968     {
00969         return $this->_sListOrderDir;
00970     }
00971 
00979     public function setMetaDescription ( $sDescription )
00980     {
00981         return $this->_sMetaDescription = $sDescription;
00982     }
00983 
00991     public function setMetaKeywords( $sKeywords )
00992     {
00993         return $this->_sMetaKeywords = $sKeywords;
00994     }
00995 
01003     protected function _getMetaFromSeo( $sDataType )
01004     {
01005         $sOxid  = $this->_getSeoObjectId();
01006         $iLang  = oxRegistry::getLang()->getBaseLanguage();
01007         $sShop  = $this->getConfig()->getShopId();
01008 
01009         if ( $sOxid && oxRegistry::getUtils()->seoIsActive() &&
01010              ( $sKeywords = oxRegistry::get("oxSeoEncoder")->getMetaData( $sOxid, $sDataType, $sShop, $iLang) ) ) {
01011             return $sKeywords;
01012         }
01013     }
01014 
01022     protected function _getMetaFromContent( $sMetaIdent )
01023     {
01024         if ( $sMetaIdent ) {
01025             $oContent = oxNew( 'oxcontent' );
01026             if ( $oContent->loadByIdent( $sMetaIdent ) &&
01027                  $oContent->oxcontents__oxactive->value ) {
01028                 return getStr()->strip_tags( $oContent->oxcontents__oxcontent->value );
01029             }
01030         }
01031     }
01032 
01038     public function getMetaKeywords()
01039     {
01040         if ( $this->_sMetaKeywords === null ) {
01041             $this->_sMetaKeywords = false;
01042 
01043             // set special meta keywords ?
01044             if ( ( $sKeywords = $this->_getMetaFromSeo( 'oxkeywords' ) ) ) {
01045                 $this->_sMetaKeywords = $sKeywords;
01046             } elseif ( ( $sKeywords = $this->_getMetaFromContent( $this->_sMetaKeywordsIdent ) ) ) {
01047                 $this->_sMetaKeywords = $this->_prepareMetaKeyword( $sKeywords, false );
01048             } else {
01049                 $this->_sMetaKeywords = $this->_prepareMetaKeyword( false, true );
01050             }
01051         }
01052 
01053         return $this->_sMetaKeywords;
01054     }
01055 
01061     public function getMetaDescription()
01062     {
01063         if ( $this->_sMetaDescription === null ) {
01064             $this->_sMetaDescription = false;
01065 
01066             // set special meta description ?
01067             if ( ( $sDescription = $this->_getMetaFromSeo( 'oxdescription' ) ) ) {
01068                 $this->_sMetaDescription = $sDescription;
01069             } elseif ( ( $sDescription = $this->_getMetaFromContent( $this->_sMetaDescriptionIdent ) ) ) {
01070                 $this->_sMetaDescription = $this->_prepareMetaDescription( $sDescription );
01071             } else {
01072                 $this->_sMetaDescription = $this->_prepareMetaDescription( false );
01073             }
01074         }
01075 
01076         return $this->_sMetaDescription;
01077     }
01078 
01084     public function getActCurrency()
01085     {
01086         return $this->_oActCurrency;
01087     }
01088 
01096     public function setActCurrency( $oCur )
01097     {
01098         $this->_oActCurrency = $oCur;
01099     }
01100 
01106     public function getCompareItemCount()
01107     {
01108         if ( $this->_iCompItemsCnt === null ) {
01109             $aItems = oxSession::getVar('aFiltcompproducts');
01110             $this->_iCompItemsCnt = is_array($aItems)?count($aItems):0;
01111         }
01112         return $this->_iCompItemsCnt;
01113     }
01114 
01120     protected function _forceNoIndex()
01121     {
01122         $this->_blForceNoIndex = true;
01123     }
01124 
01131     public function noIndex()
01132     {
01133         if ( $this->_blForceNoIndex ) {
01134             $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
01135         } elseif ( oxConfig::getParameter( 'cur' ) ) {
01136             $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
01137         } else {
01138             switch ( oxConfig::getParameter( 'fnc' ) ) {
01139                 case 'tocomparelist':
01140                 case 'tobasket':
01141                     $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
01142                     break;
01143             }
01144         }
01145         return $this->_iViewIndexState;
01146     }
01147 
01153     public function isSortingActive()
01154     {
01155         return $this->_blActiveSorting;
01156     }
01157 
01163     public function getMenueList()
01164     {
01165         return $this->_aMenueList;
01166     }
01167 
01175     public function setMenueList( $aMenue )
01176     {
01177         $this->_aMenueList = $aMenue;
01178     }
01179 
01180 
01186     protected function _setNrOfArtPerPage()
01187     {
01188         $myConfig  = $this->getConfig();
01189 
01190         //setting default values to avoid possible errors showing article list
01191         $iNrofCatArticles = $myConfig->getConfigParam( 'iNrofCatArticles' );
01192 
01193         $iNrofCatArticles = ( $iNrofCatArticles ) ? $iNrofCatArticles : 10;
01194 
01195         // checking if all needed data is set
01196         switch ( $this->getListDisplayType() ) {
01197             case 'grid':
01198                 $aNrofCatArticles = $myConfig->getConfigParam( 'aNrofCatArticlesInGrid' );
01199                 break;
01200             case 'line':
01201             case 'infogrid':
01202             default:
01203                 $aNrofCatArticles = $myConfig->getConfigParam( 'aNrofCatArticles' );
01204         }
01205 
01206         if ( !is_array( $aNrofCatArticles ) || !isset( $aNrofCatArticles[0] ) ) {
01207             $myConfig->setConfigParam( 'aNrofCatArticles', array( $iNrofCatArticles ) );
01208         } else {
01209             $iNrofCatArticles = $aNrofCatArticles[0];
01210         }
01211 
01212         $oViewConf = $this->getViewConfig();
01213         //value from user input
01214         if ( ( $iNrofArticles = (int) oxConfig::getParameter( '_artperpage' ) ) ) {
01215             // M45 Possibility to push any "Show articles per page" number parameter
01216             $iNrofCatArticles = ( in_array( $iNrofArticles, $aNrofCatArticles ) ) ? $iNrofArticles : $iNrofCatArticles;
01217             $oViewConf->setViewConfigParam( 'iartPerPage', $iNrofCatArticles );
01218             oxSession::setVar( '_artperpage', $iNrofCatArticles );
01219         } elseif ( ( $iSessArtPerPage = oxSession::getVar( '_artperpage' ) )&& is_numeric( $iSessArtPerPage ) ) {
01220             // M45 Possibility to push any "Show articles per page" number parameter
01221             $iNrofCatArticles = ( in_array( $iSessArtPerPage, $aNrofCatArticles ) ) ? $iSessArtPerPage : $iNrofCatArticles;
01222             $oViewConf->setViewConfigParam( 'iartPerPage', $iSessArtPerPage );
01223             $iNrofCatArticles = $iSessArtPerPage;
01224         } else {
01225             $oViewConf->setViewConfigParam( 'iartPerPage', $iNrofCatArticles );
01226         }
01227 
01228         //setting number of articles per page to config value
01229         $myConfig->setConfigParam( 'iNrofCatArticles', $iNrofCatArticles );
01230     }
01231 
01237     protected function _getSeoObjectId()
01238     {
01239     }
01240 
01250     protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blRemoveDuplicatedWords = false )
01251     {
01252         if ( $sMeta ) {
01253 
01254             $oStr = getStr();
01255             if ( $iLength != -1 ) {
01256                 /* *
01257                  * performance - we dont need a huge amount of initial text.
01258                  * assume that effective text may be double longer than $iLength
01259                  * and simple turncate it
01260                  */
01261                 $iELength = ( $iLength * 2 );
01262                 $sMeta = $oStr->substr( $sMeta, 0, $iELength );
01263             }
01264 
01265             // decoding html entities
01266             $sMeta = $oStr->html_entity_decode( $sMeta );
01267             // stripping HTML tags
01268             $sMeta = $oStr->strip_tags( $sMeta );
01269 
01270             // removing some special chars
01271             $sMeta = $oStr->cleanStr( $sMeta );
01272 
01273             // removing duplicate words
01274             if ( $blRemoveDuplicatedWords ) {
01275                 $sMeta = $this->_removeDuplicatedWords( $sMeta, $this->getConfig()->getConfigParam( 'aSkipTags' ) );
01276             }
01277 
01278             // some special cases
01279             $sMeta = str_replace( ' ,', ',', $sMeta );
01280             $aPattern = array( "/,[\s\+\-\*]*,/", "/\s+,/" );
01281             $sMeta = $oStr->preg_replace( $aPattern, ',', $sMeta );
01282             $sMeta = oxRegistry::get("oxUtilsString")->minimizeTruncateString( $sMeta, $iLength );
01283             $sMeta = $oStr->htmlspecialchars( $sMeta );
01284 
01285             return trim( $sMeta );
01286         }
01287     }
01288 
01297     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
01298     {
01299 
01300         $sString = $this->_prepareMetaDescription( $sKeywords, -1, false );
01301 
01302         if ( $blRemoveDuplicatedWords ) {
01303             $sString = $this->_removeDuplicatedWords( $sString, $this->getConfig()->getConfigParam( 'aSkipTags' ) );
01304         }
01305 
01306         // removing in admin defined strings
01307 
01308         /*if ( is_array( $aSkipTags ) && $sString ) {
01309             $oStr = getStr();
01310             foreach ( $aSkipTags as $sSkip ) {
01311                 //$aPattern = array( '/\W'.$sSkip.'\W/iu', '/^'.$sSkip.'\W/iu', '/\"'.$sSkip.'$/iu' );
01312                 //$aPattern = array( '/\s+'.$sSkip.'\,/iu', '/^'.$sSkip.'\s+/iu', '/\"\s+'.$sSkip.'$/iu' );
01313                 $aPattern = array( '/\s+'.$sSkip.'\,/i', '/^'.$sSkip.',\s+/i', '/\",\s+'.$sSkip.'$/i' );
01314                 $sString  = $oStr->preg_replace( $aPattern, '', $sString );
01315             }
01316         }*/
01317 
01318         return trim( $sString );
01319     }
01320 
01329     protected function _removeDuplicatedWords( $aInput, $aSkipTags = array() )
01330     {
01331         $oStr = getStr();
01332         if ( is_array( $aInput ) ) {
01333             $aInput = implode( " ", $aInput );
01334         }
01335 
01336         // removing some usually met characters..
01337         $aInput = $oStr->preg_replace( "/[".preg_quote( $this->_sRemoveMetaChars, "/" )."]/", " ", $aInput );
01338 
01339         // splitting by word
01340         $aStrings = $oStr->preg_split( "/[\s,]+/", $aInput );
01341 
01342         if ( $sCount = count( $aSkipTags ) ) {
01343             for ( $iNum = 0; $iNum < $sCount; $iNum++ ) {
01344                 $aSkipTags[$iNum] = $oStr->strtolower( $aSkipTags[$iNum] );
01345             }
01346         }
01347         $sCount = count($aStrings);
01348         for ( $iNum = 0; $iNum < $sCount; $iNum++ ) {
01349             $aStrings[$iNum] = $oStr->strtolower( $aStrings[$iNum] );
01350             // removing in admin defined strings
01351             if ( !$aStrings[$iNum] || in_array( $aStrings[$iNum], $aSkipTags ) ) {
01352                 unset( $aStrings[$iNum] );
01353             }
01354         }
01355 
01356         // duplicates
01357         return implode( ', ', array_unique( $aStrings ) );
01358     }
01359 
01367     public function getNavigationParams()
01368     {
01369         $aParams['cnid'] = $this->getCategoryId();
01370         $aParams['mnid'] = oxConfig::getParameter( 'mnid' );
01371 
01372         $aParams['listtype'] = $this->getListType();
01373         $aParams['ldtype'] = $this->getCustomListDisplayType();
01374         $aParams['actcontrol'] = $this->getClassName();
01375 
01376         $aParams['recommid'] = oxConfig::getParameter( 'recommid' );
01377 
01378         $aParams['searchrecomm'] = oxConfig::getParameter( 'searchrecomm', true );
01379         $aParams['searchparam']  = oxConfig::getParameter( 'searchparam', true );
01380         $aParams['searchtag']    = oxConfig::getParameter( 'searchtag', true );
01381 
01382         $aParams['searchvendor'] = oxConfig::getParameter( 'searchvendor' );
01383         $aParams['searchcnid']   = oxConfig::getParameter( 'searchcnid' );
01384         $aParams['searchmanufacturer'] = oxConfig::getParameter( 'searchmanufacturer' );
01385 
01386         return $aParams;
01387     }
01388 
01398     public function setItemSorting( $sCnid, $sSortBy, $sSortDir = null )
01399     {
01400 
01401         $aSorting = oxSession::getVar( 'aSorting' );
01402         $aSorting[$sCnid]['sortby']  = $sSortBy;
01403         $aSorting[$sCnid]['sortdir'] = $sSortDir?$sSortDir:null;
01404 
01405         oxSession::setVar( 'aSorting', $aSorting );
01406     }
01407 
01415     public function getSorting( $sCnid )
01416     {
01417         $aSorting = oxSession::getVar( 'aSorting' );
01418 
01419         if ( isset( $aSorting[$sCnid] ) ) {
01420             return $aSorting[$sCnid];
01421         }
01422     }
01423 
01431     public function getSortingSql( $sCnid )
01432     {
01433         $aSorting = $this->getSorting( $sCnid );
01434         if ( is_array( $aSorting ) ) {
01435             return implode( " ", $aSorting );
01436         }
01437     }
01438 
01444     public function getTitleSuffix()
01445     {
01446         return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
01447     }
01448 
01454     public function getTitlePageSuffix()
01455     {
01456     }
01457 
01464     public function getTitlePrefix()
01465     {
01466         return $this->getConfig()->getActiveShop()->oxshops__oxtitleprefix->value;
01467     }
01468 
01469 
01470 
01479     protected function _getSubject( $iLang )
01480     {
01481         return null;
01482     }
01483 
01489     public function getDynUrlParams()
01490     {
01491         $sRet = '';
01492         $sListType = $this->getListType();
01493 
01494         switch ($sListType) {
01495             default:
01496                 break;
01497             case 'search':
01498                 $sRet .= "&amp;listtype={$sListType}";
01499                 if ( $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
01500                     $sRet .= "&amp;searchparam={$sSearchParamForLink}";
01501                 }
01502 
01503                 if ( ( $sVar = oxConfig::getParameter( 'searchcnid', true ) ) ) {
01504                     $sRet .= '&amp;searchcnid='.rawurlencode( rawurldecode( $sVar ) );
01505                 }
01506                 if ( ( $sVar = oxConfig::getParameter( 'searchvendor', true ) ) ) {
01507                     $sRet .= '&amp;searchvendor='.rawurlencode( rawurldecode( $sVar ) );
01508                 }
01509                 if ( ( $sVar = oxConfig::getParameter( 'searchmanufacturer', true ) ) ) {
01510                     $sRet .= '&amp;searchmanufacturer='.rawurlencode( rawurldecode( $sVar ) );
01511                 }
01512                 break;
01513             case 'tag':
01514                 $sRet .= "&amp;listtype={$sListType}";
01515                 if ( $sParam = rawurlencode( oxConfig::getParameter( 'searchtag', true ) ) ) {
01516                     $sRet .= "&amp;searchtag={$sParam}";
01517                 }
01518                 break;
01519         }
01520 
01521         return $sRet;
01522     }
01523 
01531     public function getLink( $iLang = null )
01532     {
01533         if ( !isset( $iLang ) ) {
01534             $iLang = oxRegistry::getLang()->getBaseLanguage();
01535         }
01536 
01537         $oDisplayObj = null;
01538         $blTrySeo = false;
01539         if ( oxRegistry::getUtils()->seoIsActive() ) {
01540             $blTrySeo = true;
01541             $oDisplayObj = $this->_getSubject( $iLang );
01542         }
01543         $iActPageNr = $this->getActPage();
01544 
01545         if ( $oDisplayObj ) {
01546             return $this->_addPageNrParam( $oDisplayObj->getLink( $iLang ), $iActPageNr, $iLang );
01547         }
01548 
01549         $myConfig = $this->getConfig();
01550 
01551         if ( $blTrySeo ) {
01552             $oEncoder = oxRegistry::get("oxSeoEncoder");
01553             if ( ( $sSeoUrl = $oEncoder->getStaticUrl( $myConfig->getShopHomeURL( $iLang ) . $this->_getSeoRequestParams(), $iLang ) ) ) {
01554                 return $this->_addPageNrParam( $sSeoUrl, $iActPageNr, $iLang );
01555             }
01556         }
01557 
01558         $sUrl = oxRegistry::get("oxUtilsUrl")->processUrl( $myConfig->getShopCurrentURL( $iLang ) . $this->_getRequestParams(), true, null, $iLang);
01559 
01560         // fallback to old non seo url
01561         return $this->_addPageNrParam( $sUrl, $iActPageNr, $iLang );
01562     }
01563 
01569     public function getCanonicalUrl()
01570     {
01571     }
01572 
01579     public function getSimilarRecommListIds()
01580     {
01581         return false;
01582     }
01589     public function getSearchParamForHtml()
01590     {
01591     }
01592 
01600     protected function _getRequestParams( $blAddPageNr  = true )
01601     {
01602         $sClass = $this->getClassName();
01603         $sFnc   = $this->getFncName();
01604 
01605         $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher', 'moveleft', 'moveright' );
01606         if ( in_array( $sFnc, $aFnc ) ) {
01607             $sFnc = '';
01608         }
01609 
01610         // #680
01611         $sURL = "cl={$sClass}";
01612         if ( $sFnc ) {
01613             $sURL .= "&amp;fnc={$sFnc}";
01614         }
01615         if ( $sVal = oxConfig::getParameter( 'cnid' ) ) {
01616             $sURL .= "&amp;cnid={$sVal}";
01617         }
01618         if ( $sVal = oxConfig::getParameter( 'mnid' ) ) {
01619             $sURL .= "&amp;mnid={$sVal}";
01620         }
01621         if ( $sVal= oxConfig::getParameter( 'anid' ) ) {
01622             $sURL .= "&amp;anid={$sVal}";
01623         }
01624 
01625         if ( $sVal = basename( oxConfig::getParameter( 'page' ) ) ) {
01626             $sURL .= "&amp;page={$sVal}";
01627         }
01628 
01629         if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
01630             $sURL .= "&amp;tpl={$sVal}";
01631         }
01632 
01633         if ( $sVal = oxConfig::getParameter( 'oxloadid' ) ) {
01634             $sURL .= "&amp;oxloadid={$sVal}";
01635         }
01636 
01637         $iPgNr = (int) oxConfig::getParameter( 'pgNr' );
01638         // don't include page number for navigation
01639         // it will be done in oxubase::generatePageNavigation
01640         if ( $blAddPageNr && $iPgNr > 0 ) {
01641             $sURL .= "&amp;pgNr={$iPgNr}";
01642         }
01643 
01644         // #1184M - specialchar search
01645         if ( $sVal = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
01646             $sURL .= "&amp;searchparam={$sVal}";
01647         }
01648 
01649         if ( $sVal = oxConfig::getParameter( 'searchcnid' ) ) {
01650             $sURL .= "&amp;searchcnid={$sVal}";
01651         }
01652 
01653         if ( $sVal = oxConfig::getParameter( 'searchvendor' ) ) {
01654             $sURL .= "&amp;searchvendor={$sVal}";
01655         }
01656 
01657         if ( $sVal = oxConfig::getParameter( 'searchmanufacturer' ) ) {
01658             $sURL .= "&amp;searchmanufacturer={$sVal}";
01659         }
01660 
01661         if ( $sVal = oxConfig::getParameter( 'searchrecomm' ) ) {
01662             $sURL .= "&amp;searchrecomm={$sVal}";
01663         }
01664 
01665         if ( $sVal = oxConfig::getParameter( 'searchtag' ) ) {
01666             $sURL .= "&amp;searchtag={$sVal}";
01667         }
01668 
01669         if ( $sVal = oxConfig::getParameter( 'recommid' ) ) {
01670             $sURL .= "&amp;recommid={$sVal}";
01671         }
01672 
01673         return $sURL;
01674     }
01675 
01681     protected function _getSeoRequestParams()
01682     {
01683         $sClass = $this->getClassName();
01684         $sFnc   = $this->getFncName();
01685 
01686         // #921 S
01687         $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher' );
01688         if ( in_array( $sFnc, $aFnc ) ) {
01689             $sFnc = '';
01690         }
01691 
01692         // #680
01693         $sURL = "cl={$sClass}";
01694         if ( $sFnc ) {
01695             $sURL .= "&amp;fnc={$sFnc}";
01696         }
01697         if ( $sVal = basename( oxConfig::getParameter( 'page' ) ) ) {
01698             $sURL .= "&amp;page={$sVal}";
01699         }
01700 
01701         if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
01702             $sURL .= "&amp;tpl={$sVal}";
01703         }
01704 
01705         if ( $sVal = oxConfig::getParameter( 'oxloadid' ) ) {
01706             $sURL .= "&amp;oxloadid={$sVal}";
01707         }
01708 
01709         $iPgNr = (int) oxConfig::getParameter( 'pgNr' );
01710         if ( $iPgNr > 0 ) {
01711             $sURL .= "&amp;pgNr={$iPgNr}";
01712         }
01713 
01714         return $sURL;
01715     }
01716 
01722     public function showSearch()
01723     {
01724         $blShow = true;
01725         if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) && $this->getIsOrderStep() ) {
01726             $blShow = false;
01727         }
01728         return (int) $blShow;
01729     }
01730 
01736     public function getRssLinks()
01737     {
01738         return $this->_aRssLinks;
01739     }
01740 
01746     public function getSortColumns()
01747     {
01748         return $this->_aSortColumns;
01749     }
01750 
01756     public function getEditTags()
01757     {
01758     }
01759 
01765     public function getRecommSearch()
01766     {
01767     }
01768 
01774     public function getPaymentList()
01775     {
01776     }
01777 
01783     public function getActiveRecommList()
01784     {
01785         if ( $this->_oActiveRecommList === null ) {
01786             $this->_oActiveRecommList = false;
01787             if ( $sOxid = oxConfig::getParameter( 'recommid' ) ) {
01788                 $this->_oActiveRecommList = oxNew( 'oxrecommlist' );
01789                 $this->_oActiveRecommList->load( $sOxid );
01790             }
01791         }
01792         return $this->_oActiveRecommList;
01793     }
01794 
01800     public function getAccessoires()
01801     {
01802     }
01803 
01809     public function getCrossSelling()
01810     {
01811     }
01812 
01818     public function getSimilarProducts()
01819     {
01820     }
01821 
01827     public function getAlsoBoughtTheseProducts()
01828     {
01829     }
01830 
01836     public function getArticleId()
01837     {
01838     }
01839 
01845     public function getTitle()
01846     {
01847     }
01848 
01854     public function getActiveLangAbbr()
01855     {
01856         // Performance
01857         if ( !$this->getConfig()->getConfigParam( 'bl_perfLoadLanguages' ) ) {
01858             return;
01859         }
01860 
01861         if ( !isset($this->_sActiveLangAbbr ) ) {
01862             $aLanguages = oxRegistry::getLang()->getLanguageArray();
01863             while ( list( $sKey, $oVal ) = each( $aLanguages ) ) {
01864                 if ( $oVal->selected ) {
01865                     $this->_sActiveLangAbbr = $oVal->abbr;
01866                     break;
01867                 }
01868             }
01869         }
01870 
01871         return $this->_sActiveLangAbbr;
01872     }
01873 
01881     public function addGlobalParams( $oShop = null)
01882     {
01883         $oViewConf = parent::addGlobalParams( $oShop );
01884 
01885         $this->_setNrOfArtPerPage();
01886 
01887         return $oViewConf;
01888     }
01889 
01895     public function getAdditionalParams()
01896     {
01897         if ( $this->_sAdditionalParams === null ) {
01898             // #1018A
01899             $this->_sAdditionalParams  = parent::getAdditionalParams();
01900             $this->_sAdditionalParams .= 'cl='.$this->getConfig()->getActiveView()->getClassName();
01901 
01902             // #1834M - specialchar search
01903             $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) );
01904             if ( isset( $sSearchParamForLink ) ) {
01905                 $this->_sAdditionalParams .= "&amp;searchparam={$sSearchParamForLink}";
01906             }
01907             if ( ( $sVar = oxConfig::getParameter( 'searchtag' ) ) ) {
01908                 $this->_sAdditionalParams .= '&amp;searchtag='.rawurlencode( rawurldecode( $sVar ) );
01909             }
01910             if ( ( $sVar = oxConfig::getParameter( 'searchcnid' ) ) ) {
01911                 $this->_sAdditionalParams .= '&amp;searchcnid='.rawurlencode( rawurldecode( $sVar ) );
01912             }
01913             if ( ( $sVar = oxConfig::getParameter( 'searchvendor' ) ) ) {
01914                 $this->_sAdditionalParams .= '&amp;searchvendor='.rawurlencode( rawurldecode( $sVar ) );
01915             }
01916             if ( ( $sVar = oxConfig::getParameter( 'searchmanufacturer' ) ) ) {
01917                 $this->_sAdditionalParams .= '&amp;searchmanufacturer='.rawurlencode( rawurldecode( $sVar ) );
01918             }
01919             if ( ( $sVar = oxConfig::getParameter( 'cnid' ) ) ) {
01920                 $this->_sAdditionalParams .= '&amp;cnid='.rawurlencode( rawurldecode( $sVar ) );
01921             }
01922             if ( ( $sVar = oxConfig::getParameter( 'mnid' ) ) ) {
01923                 $this->_sAdditionalParams .= '&amp;mnid='.rawurlencode( rawurldecode( $sVar ) );
01924             }
01925         }
01926 
01927         return $this->_sAdditionalParams;
01928     }
01929 
01935     public function generatePageNavigationUrl()
01936     {
01937         return $this->getConfig()->getShopHomeURL().$this->_getRequestParams( false );
01938     }
01939 
01949     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null )
01950     {
01951         if ( $iPage ) {
01952             if ( ( strpos( $sUrl, 'pgNr=' ) ) ) {
01953                 $sUrl = preg_replace('/pgNr=[0-9]*/', 'pgNr='.$iPage, $sUrl);
01954             } else {
01955                 $sUrl .= ( ( strpos( $sUrl, '?' ) === false ) ? '?' : '&amp;' ) . 'pgNr='.$iPage;
01956             }
01957         } else {
01958            $sUrl = preg_replace('/pgNr=[0-9]*/', '', $sUrl);
01959            $sUrl = preg_replace('/\&amp\;\&amp\;/', '&amp;', $sUrl);
01960            $sUrl = preg_replace('/\?\&amp\;/', '?', $sUrl);
01961            $sUrl = preg_replace('/\&amp\;$/', '', $sUrl);
01962         }
01963         return $sUrl;
01964     }
01965 
01971     public function getPageNavigation()
01972     {
01973 
01974     }
01975 
01981     public function getPageNavigationLimitedTop()
01982     {
01983 
01984         $this->_oPageNavigation = $this->generatePageNavigation( 7 );
01985 
01986         return $this->_oPageNavigation;
01987     }
01988 
01994     public function getPageNavigationLimitedBottom()
01995     {
01996 
01997         $this->_oPageNavigation = $this->generatePageNavigation( 11 );
01998 
01999         return $this->_oPageNavigation;
02000     }
02001 
02002 
02010     public function generatePageNavigation( $iPositionCount = 0 )
02011     {
02012         startProfile('generatePageNavigation');
02013 
02014         $pageNavigation = new stdClass();
02015 
02016         $pageNavigation->NrOfPages = $this->_iCntPages;
02017         $iActPage = $this->getActPage();
02018         $pageNavigation->actPage   = $iActPage + 1;
02019         $sUrl = $this->generatePageNavigationUrl();
02020 
02021         if ( $iPositionCount == 0 || ($iPositionCount >= $pageNavigation->NrOfPages) ) {
02022              $iStartNo = 2;
02023              $iFinishNo = $pageNavigation->NrOfPages;
02024              $bStart = false;
02025              $bFinish =false;
02026         } else {
02027             $iTmpVal = $iPositionCount - 3;
02028             $iTmpVal2 = floor( ( $iPositionCount - 4 ) / 2 );
02029 
02030             // actual page is at the start
02031             if ( $pageNavigation->actPage <= $iTmpVal ) {
02032                 $iStartNo = 2;
02033                 $iFinishNo = $iTmpVal + 1;
02034                 $bStart = false;
02035                 $bFinish = true;
02036             // actual page is at the end
02037             } elseif ( $pageNavigation->actPage >= $pageNavigation->NrOfPages - $iTmpVal ) {
02038                 $iStartNo = $pageNavigation->NrOfPages - $iTmpVal;
02039                 $iFinishNo = $pageNavigation->NrOfPages - 1;
02040                 $bStart = true;
02041                 $bFinish = false;
02042             // actual page is in the midle
02043             } else {
02044                 $iStartNo = $pageNavigation->actPage - $iTmpVal2;
02045                 $iFinishNo = $pageNavigation->actPage + $iTmpVal2;
02046                 $bStart = true;
02047                 $bFinish = true;
02048             }
02049         }
02050 
02051         if ( $iActPage > 0) {
02052             $pageNavigation->previousPage = $this->_addPageNrParam( $sUrl, $iActPage - 1 );
02053         }
02054 
02055         if ( $iActPage < $pageNavigation->NrOfPages - 1 ) {
02056             $pageNavigation->nextPage = $this->_addPageNrParam( $sUrl, $iActPage + 1 );
02057         }
02058 
02059         if ( $pageNavigation->NrOfPages > 1 ) {
02060 
02061             for ( $i=1; $i < $pageNavigation->NrOfPages + 1; $i++ ) {
02062 
02063                 if ( $i == 1 || $i == $pageNavigation->NrOfPages || ( $i >= $iStartNo && $i <= $iFinishNo ) ) {
02064                     $page = new stdClass();
02065                     $page->url = $this->_addPageNrParam( $sUrl, $i - 1 );
02066                     $page->selected = ( $i == $pageNavigation->actPage ) ? 1 : 0;
02067                     $pageNavigation->changePage[$i] = $page;
02068                 }
02069             }
02070 
02071             // first/last one
02072             $pageNavigation->firstpage = $this->_addPageNrParam( $sUrl, 0 );
02073             $pageNavigation->lastpage  = $this->_addPageNrParam( $sUrl, $pageNavigation->NrOfPages - 1 );
02074         }
02075 
02076         stopProfile('generatePageNavigation');
02077 
02078         return $pageNavigation;
02079     }
02080 
02087     public function render()
02088     {
02089         foreach ( array_keys( $this->_oaComponents ) as $sComponentName ) {
02090             $this->_aViewData[$sComponentName] = $this->_oaComponents[$sComponentName]->render();
02091         }
02092 
02093         parent::render();
02094 
02095         if ( $this->getIsOrderStep() ) {
02096 
02097             // disabling navigation during order ...
02098             if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) ) {
02099                 $this->_iNewsRealStatus = 1;
02100                 $this->setShowNewsletter( 0 );
02101             }
02102         }
02103         return $this->_sThisTemplate;
02104     }
02105 
02111     public function getViewProduct()
02112     {
02113         return $this->getProduct();
02114     }
02115 
02123     public function setViewProduct( $oProduct )
02124     {
02125         $this->_oProduct = $oProduct;
02126     }
02127 
02133     public function getViewProductList()
02134     {
02135         return $this->_aArticleList;
02136     }
02137 
02143     public function getActPage()
02144     {
02145         if ( $this->_iActPage === null ) {
02146             $this->_iActPage = ( int ) oxConfig::getParameter( 'pgNr' );
02147             $this->_iActPage = ( $this->_iActPage < 0 ) ? 0 : $this->_iActPage;
02148         }
02149         return $this->_iActPage;
02150     }
02151 
02159     public function getActTag()
02160     {
02161         if ( $this->_oActTag === null ) {
02162             $this->_oActTag = new stdClass();
02163             $this->_oActTag->sTag = $sTag = oxConfig::getParameter("searchtag", 1);
02164             $oSeoEncoderTag = oxRegistry::get("oxSeoEncoderTag");
02165 
02166             $sLink = false;
02167             if ( oxRegistry::getUtils()->seoIsActive() ) {
02168                 $sLink = $oSeoEncoderTag->getTagUrl( $sTag, oxRegistry::getLang()->getBaseLanguage() );
02169             }
02170 
02171             $this->_oActTag->link = $sLink ? $sLink : $this->getConfig()->getShopHomeURL().$oSeoEncoderTag->getStdTagUri( $sTag, false );
02172         }
02173         return $this->_oActTag;
02174     }
02175 
02183     public function getActVendor()
02184     {
02185         // if active vendor is not set yet - trying to load it from request params
02186         // this may be usefull when category component was unable to load active vendor
02187         // and we still need some object to mount navigation info
02188         if ( $this->_oActVendor === null ) {
02189             $this->_oActVendor = false;
02190             $sVendorId = oxConfig::getParameter( 'cnid' );
02191             $sVendorId = $sVendorId ? str_replace( 'v_', '', $sVendorId ) : $sVendorId;
02192             $oVendor = oxNew( 'oxvendor' );
02193             if ( $oVendor->load( $sVendorId ) ) {
02194                 $this->_oActVendor = $oVendor;
02195             }
02196         }
02197 
02198         return $this->_oActVendor;
02199     }
02200 
02208     public function getActManufacturer()
02209     {
02210         // if active Manufacturer is not set yet - trying to load it from request params
02211         // this may be usefull when category component was unable to load active Manufacturer
02212         // and we still need some object to mount navigation info
02213         if ( $this->_oActManufacturer === null ) {
02214 
02215             $this->_oActManufacturer = false;
02216             $sManufacturerId = oxConfig::getParameter( 'mnid' );
02217             $oManufacturer = oxNew( 'oxmanufacturer' );
02218             if ( $oManufacturer->load( $sManufacturerId ) ) {
02219                 $this->_oActManufacturer = $oManufacturer;
02220             }
02221         }
02222 
02223         return $this->_oActManufacturer;
02224     }
02225 
02233     public function setActVendor( $oVendor )
02234     {
02235         $this->_oActVendor = $oVendor;
02236     }
02237 
02245     public function setActManufacturer( $oManufacturer )
02246     {
02247         $this->_oActManufacturer = $oManufacturer;
02248     }
02249 
02255     public function getActSearch()
02256     {
02257         if ( $this->_oActSearch === null ) {
02258             $this->_oActSearch = new stdClass();
02259             $sUrl = $this->getConfig()->getShopHomeURL();
02260             $this->_oActSearch->link = "{$sUrl}cl=search";
02261         }
02262         return $this->_oActSearch;
02263     }
02264 
02270     public function getCategoryTree()
02271     {
02272         return $this->_oCategoryTree;
02273     }
02274 
02282     public function setCategoryTree( $oCatTree )
02283     {
02284         $this->_oCategoryTree = $oCatTree;
02285     }
02286 
02292     public function getManufacturerTree()
02293     {
02294         return $this->_oManufacturerTree;
02295     }
02296 
02304     public function setManufacturerTree( $oManufacturerTree )
02305     {
02306         $this->_oManufacturerTree = $oManufacturerTree;
02307     }
02308 
02314     public function getAddUrlParams()
02315     {
02316     }
02317 
02324     public function getTop5ArticleList()
02325     {
02326         if ( $this->_blTop5Action ) {
02327             if ( $this->_aTop5ArticleList === null ) {
02328                 $this->_aTop5ArticleList = false;
02329                 $myConfig = $this->getConfig();
02330                 if ( $myConfig->getConfigParam( 'bl_perfLoadAktion' ) ) {
02331                     // top 5 articles
02332                     $oArtList = oxNew( 'oxarticlelist' );
02333                     $oArtList->loadTop5Articles();
02334                     if ( $oArtList->count() ) {
02335                         $this->_aTop5ArticleList = $oArtList;
02336                     }
02337                 }
02338             }
02339         }
02340         return $this->_aTop5ArticleList;
02341     }
02342 
02349     public function getBargainArticleList()
02350     {
02351         if ( $this->_blBargainAction ) {
02352             if ( $this->_aBargainArticleList === null ) {
02353                 $this->_aBargainArticleList = array();
02354                 if ( $this->getConfig()->getConfigParam( 'bl_perfLoadAktion' ) ) {
02355                     $oArtList = oxNew( 'oxarticlelist' );
02356                     $oArtList->loadActionArticles( 'OXBARGAIN' );
02357                     if ( $oArtList->count() ) {
02358                         $this->_aBargainArticleList = $oArtList;
02359                     }
02360                 }
02361             }
02362         }
02363         return $this->_aBargainArticleList;
02364     }
02365 
02372     public function isLowOrderPrice()
02373     {
02374         if ( $this->_blLowOrderPrice === null && ( $oBasket = $this->getSession()->getBasket() ) ) {
02375             $this->_blLowOrderPrice = $oBasket->isBelowMinOrderPrice();
02376         }
02377 
02378         return $this->_blLowOrderPrice;
02379     }
02380 
02386     public function getMinOrderPrice()
02387     {
02388         if ( $this->_sMinOrderPrice === null && $this->isLowOrderPrice() ) {
02389             $dMinOrderPrice = oxPrice::getPriceInActCurrency( $this->getConfig()->getConfigParam( 'iMinOrderPrice' ) );
02390             $this->_sMinOrderPrice = oxRegistry::getLang()->formatCurrency( $dMinOrderPrice );
02391         }
02392         return $this->_sMinOrderPrice;
02393     }
02394 
02400     public function getNewsRealStatus()
02401     {
02402         return $this->_iNewsRealStatus;
02403     }
02404 
02410     protected function _canRedirect()
02411     {
02412         foreach ( $this->_aBlockRedirectParams as $sParam ) {
02413             if ( oxConfig::getParameter( $sParam ) !== null ) {
02414                 return false;
02415             }
02416         }
02417 
02418         return true;
02419     }
02420 
02426     public function getProduct()
02427     {
02428     }
02429 
02435     public function getManufacturerlist()
02436     {
02437         return $this->_aManufacturerlist;
02438     }
02439 
02447     public function setManufacturerlist( $aList )
02448     {
02449         $this->_aManufacturerlist = $aList;
02450     }
02451 
02459     public function setRootVendor( $oVendor )
02460     {
02461         $this->_oRootVendor = $oVendor;
02462     }
02463 
02469     public function getRootVendor()
02470     {
02471         return $this->_oRootVendor;
02472     }
02473 
02481     public function setRootManufacturer( $oManufacturer )
02482     {
02483         $this->_oRootManufacturer = $oManufacturer;
02484     }
02485 
02491     public function getRootManufacturer()
02492     {
02493         return $this->_oRootManufacturer;
02494     }
02495 
02501     public function getVendorId()
02502     {
02503         if ( $this->_sVendorId === null ) {
02504             $this->_sVendorId = false;
02505             if ( ( $oVendor = $this->getActVendor() ) ) {
02506                 $this->_sVendorId = $oVendor->getId();
02507             }
02508         }
02509         return $this->_sVendorId;
02510     }
02511 
02517     public function getManufacturerId()
02518     {
02519         if ( $this->_sManufacturerId === null ) {
02520             $this->_sManufacturerId = false;
02521             if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
02522                 $this->_sManufacturerId = $oManufacturer->getId();
02523             }
02524         }
02525         return $this->_sManufacturerId;
02526     }
02527 
02533     public function getSearchCatTree()
02534     {
02535         return $this->_aSearchCatTree;
02536     }
02537 
02545     public function setSearchCatTree( $aTree )
02546     {
02547         $this->_aSearchCatTree = $aTree;
02548     }
02549 
02555     public function getCatMoreUrl()
02556     {
02557         return $this->getConfig()->getShopHomeURL().'cnid=oxmore';
02558     }
02559 
02565     public function getCatTreePath()
02566     {
02567         return $this->_sCatTreePath;
02568     }
02569 
02577     public function getContentByIdent( $sIdent )
02578     {
02579         if ( !isset( $this->_aContents[$sIdent] ) ) {
02580             $this->_aContents[$sIdent] = oxNew( 'oxcontent' );
02581             $this->_aContents[$sIdent]->loadByIdent( $sIdent );
02582         }
02583         return $this->_aContents[$sIdent];
02584     }
02585 
02591     public function getContentCategory()
02592     {
02593         return false;
02594     }
02595 
02601     public function getMustFillFields()
02602     {
02603         if ( $this->_aMustFillFields === null ) {
02604             $this->_aMustFillFields = false;
02605 
02606             // passing must-be-filled-fields info
02607             $aMustFillFields = $this->getConfig()->getConfigParam( 'aMustFillFields' );
02608             if ( is_array( $aMustFillFields ) ) {
02609                 $this->_aMustFillFields = array_flip( $aMustFillFields );
02610             }
02611         }
02612         return $this->_aMustFillFields;
02613     }
02614 
02622     public function isFieldRequired( $sField )
02623     {
02624         if ( $aMustFillFields = $this->getMustFillFields() ) {
02625             if ( isset( $aMustFillFields[$sField] ) ) {
02626                 return true;
02627             }
02628         }
02629 
02630         return false;
02631     }
02632 
02638     public function getFormId()
02639     {
02640         if ( $this->_sFormId === null ) {
02641             $this->_sFormId = oxUtilsObject::getInstance()->generateUId();
02642             oxSession::setVar( 'sessionuformid', $this->_sFormId );
02643         }
02644 
02645         return $this->_sFormId;
02646     }
02647 
02653     public function canAcceptFormData()
02654     {
02655         if ( $this->_blCanAcceptFormData === null ) {
02656             $this->_blCanAcceptFormData = false;
02657 
02658             $sFormId = oxConfig::getParameter( "uformid" );
02659             $sSessionFormId = oxSession::getVar( "sessionuformid" );
02660 
02661             // testing if form and session ids matches
02662             if ( $sFormId && $sFormId === $sSessionFormId ) {
02663                 $this->_blCanAcceptFormData = true;
02664             }
02665 
02666             // regenerating form data
02667             $this->getFormId();
02668         }
02669         return $this->_blCanAcceptFormData;
02670     }
02671 
02677     public function getPromoFinishedList()
02678     {
02679         if (isset($this->_oPromoFinishedList)) {
02680             return $this->_oPromoFinishedList;
02681         }
02682         $this->_oPromoFinishedList = oxNew( 'oxActionList' );
02683         $this->_oPromoFinishedList->loadFinishedByCount(2);
02684         return $this->_oPromoFinishedList;
02685     }
02686 
02692     public function getPromoCurrentList()
02693     {
02694         if (isset($this->_oPromoCurrentList)) {
02695             return $this->_oPromoCurrentList;
02696         }
02697         $this->_oPromoCurrentList = oxNew( 'oxActionList' );
02698         $this->_oPromoCurrentList->loadCurrent();
02699         return $this->_oPromoCurrentList;
02700     }
02701 
02707     public function getPromoFutureList()
02708     {
02709         if (isset($this->_oPromoFutureList)) {
02710             return $this->_oPromoFutureList;
02711         }
02712         $this->_oPromoFutureList = oxNew( 'oxActionList' );
02713         $this->_oPromoFutureList->loadFutureByCount(2);
02714         return $this->_oPromoFutureList;
02715     }
02716 
02722     public function getShowPromotionList()
02723     {
02724         if (isset($this->_blShowPromotions)) {
02725             return $this->_blShowPromotions;
02726         }
02727         $this->_blShowPromotions = false;
02728         if (oxNew('oxActionList')->areAnyActivePromotions()) {
02729             $this->_blShowPromotions = ( count( $this->getPromoFinishedList() ) + count( $this->getPromoCurrentList() ) + count( $this->getPromoFutureList() ) ) > 0;
02730         }
02731         return $this->_blShowPromotions;
02732     }
02733 
02739     public function isEnabledPrivateSales()
02740     {
02741         if ( $this->_blEnabledPrivateSales === null ) {
02742             $this->_blEnabledPrivateSales = (bool) $this->getConfig()->getConfigParam( 'blPsLoginEnabled' );
02743             if ( $this->_blEnabledPrivateSales && ( $blCanPreview = oxRegistry::getUtils()->canPreview() ) !== null ) {
02744                 $this->_blEnabledPrivateSales = !$blCanPreview;
02745             }
02746         }
02747         return $this->_blEnabledPrivateSales;
02748     }
02749 
02755     public function getFieldValidationErrors()
02756     {
02757         return oxRegistry::get("oxInputValidator")->getFieldValidationErrors();
02758     }
02759 
02765     public function getBreadCrumb()
02766     {
02767         return null;
02768     }
02769 
02777     public function setRootCatChanged( $blRootCatChanged )
02778     {
02779         $this->_blRootCatChanged = $blRootCatChanged;
02780     }
02781 
02787     public function isRootCatChanged()
02788     {
02789         return $this->_blRootCatChanged;
02790     }
02791 
02797     public function getInvoiceAddress()
02798     {
02799         if ( $this->_aInvoiceAddress == null ) {
02800             $aAddress = oxConfig::getParameter( 'invadr');
02801             if ( $aAddress ) {
02802                 $this->_aInvoiceAddress = $aAddress;
02803             }
02804         }
02805         return $this->_aInvoiceAddress;
02806     }
02807 
02813     public function getDeliveryAddress()
02814     {
02815         if ( $this->_aDeliveryAddress == null ) {
02816             $aAddress = oxConfig::getParameter( 'deladr');
02817             //do not show deladr if address was reloaded
02818             if ( $aAddress && !oxConfig::getParameter( 'reloadaddress' )) {
02819                 $this->_aDeliveryAddress = $aAddress;
02820             }
02821         }
02822         return $this->_aDeliveryAddress;
02823     }
02824 
02832     public function setInvoiceAddress( $aAddress )
02833     {
02834         $this->_aInvoiceAddress = $aAddress;
02835     }
02836 
02842     public function getActiveUsername()
02843     {
02844         if ( $this->_sActiveUsername == null ) {
02845             $this->_sActiveUsername = false;
02846             $sUsername = oxConfig::getParameter( 'lgn_usr' );
02847             if ( $sUsername ) {
02848                 $this->_sActiveUsername = $sUsername;
02849             } elseif ( $oUser = $this->getUser() ) {
02850                 $this->_sActiveUsername = $oUser->oxuser__oxusername->value;
02851             }
02852         }
02853         return $this->_sActiveUsername;
02854     }
02855 
02861     public function getWishlistUserId()
02862     {
02863         return oxConfig::getParameter( 'wishid' );
02864     }
02865 
02871     public function getSearchCatId()
02872     {
02873     }
02874 
02880     public function getSearchVendor()
02881     {
02882     }
02883 
02889     public function getSearchManufacturer()
02890     {
02891     }
02892 
02898     public function getLastProducts()
02899     {
02900 
02901     }
02902 
02908     public function getNewBasketItemMsgType()
02909     {
02910         return (int) $this->getConfig()->getConfigParam( "iNewBasketItemMessage" );
02911     }
02912 
02920     public function isActive( $sName )
02921     {
02922         return $this->getConfig()->getConfigParam( "bl".$sName."Enabled" );
02923     }
02924 
02930     public function isFbWidgetVisible()
02931     {
02932         if ( $this->_blFbWidgetsOn === null ) {
02933             $oUtils = oxRegistry::get("oxUtilsServer");
02934 
02935             // reading ..
02936             $this->_blFbWidgetsOn = (bool) $oUtils->getOxCookie( "fbwidgetson" );
02937         }
02938         return $this->_blFbWidgetsOn;
02939     }
02940 
02946     public function isEnabledDownloadableFiles()
02947     {
02948         return (bool) $this->getConfig()->getConfigParam( "blEnableDownloads" );
02949     }
02950 
02956     public function showRememberMe()
02957     {
02958         return (bool) $this->getConfig()->getConfigParam('blShowRememberMe');
02959     }
02960 
02967     public function isVatIncluded()
02968     {
02969         $blResult = true;
02970         $oUser = $this->getUser();
02971         $oConfig = $this->getConfig();
02972 
02973         if ( $oConfig->getConfigParam( 'blShowNetPrice' ) || $oConfig->getConfigParam( 'bl_perfCalcVatOnlyForBasketOrder' ) ) {
02974             $blResult = false;
02975         } elseif ( $oUser && $oUser->isPriceViewModeNetto() ) {
02976             $blResult = false;
02977         }
02978 
02979         return $blResult;
02980     }
02981 
02987     public function isPriceCalculated()
02988     {
02989         return (bool) $this->getConfig()->getConfigParam( 'bl_perfLoadPrice' );
02990     }
02991 
02997     public function showTags()
02998     {
02999          return (bool) $this->_blShowTagCloud && $this->getConfig()->getConfigParam( "blShowTags" );
03000     }
03001 
03007     public function getWishlistName()
03008     {
03009         if ( $this->getUser() ) {
03010             $sUserId = oxConfig::getParameter( 'wishid') ? oxConfig::getParameter( 'wishid' ): oxSession::getVar( 'wishid');
03011             if ( $sUserId ) {
03012                 $oWishUser = oxNew( 'oxuser' );
03013                 if ( $oWishUser->load( $sUserId ) ) {
03014                     return $oWishUser;
03015                 }
03016             }
03017         }
03018         return false;
03019     }
03020 
03021 }