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         return $this->_sViewId;
00651     }
00652 
00653 
00659     public function showSorting()
00660     {
00661         return $this->_blShowSorting && $this->getConfig()->getConfigParam( 'blShowSorting' );
00662     }
00663 
00671     public function setComponents( $aComponents = null )
00672     {
00673         $this->_oaComponents = $aComponents;
00674     }
00675 
00681     public function getComponents()
00682     {
00683         return $this->_oaComponents;
00684     }
00685 
00693     public function setIsOrderStep( $blIsOrderStep = null )
00694     {
00695         $this->_blIsOrderStep = $blIsOrderStep;
00696     }
00697 
00703     public function getIsOrderStep()
00704     {
00705         return $this->_blIsOrderStep;
00706     }
00707 
00708 
00716     public function setActiveCategory( $oCategory )
00717     {
00718         $this->_oActCategory = $oCategory;
00719     }
00720 
00726     public function getActiveCategory()
00727     {
00728         return $this->_oActCategory;
00729     }
00730 
00736     public function getListType()
00737     {
00738         if ( $this->_sListType == null ) {
00739             if ( $sListType = oxConfig::getParameter( 'listtype' ) ) {
00740                 $this->_sListType = $sListType;
00741             } elseif ( $sListType = $this->getConfig()->getGlobalParameter( 'listtype' ) ) {
00742                 $this->_sListType = $sListType;
00743             }
00744         }
00745         return $this->_sListType;
00746     }
00747 
00753     public function getListDisplayType()
00754     {
00755         if ( $this->_sListDisplayType == null ) {
00756             $this->_sListDisplayType = oxConfig::getParameter( 'ldtype' );
00757 
00758             if ( !$this->_sListDisplayType ) {
00759                 $this->_sListDisplayType = oxSession::getVar( 'ldtype' );
00760             }
00761 
00762             if ( !$this->_sListDisplayType ) {
00763                 $this->_sListDisplayType = $this->getConfig()->getConfigParam( 'sDefaultListDisplayType' );
00764             }
00765 
00766             $this->_sListDisplayType = in_array( ( string ) $this->_sListDisplayType, $this->_aListDisplayTypes ) ? $this->_sListDisplayType : 'infogrid';
00767 
00768             // writing to session
00769             if ( oxConfig::getParameter( 'ldtype' ) ) {
00770                 oxSession::setVar( 'ldtype', $this->_sListDisplayType );
00771             }
00772         }
00773         return $this->_sListDisplayType;
00774     }
00775 
00783     public function setListType( $sType )
00784     {
00785         $this->_sListType = $sType;
00786         $this->getConfig()->setGlobalParameter( 'listtype', $sType );
00787     }
00788 
00794     public function showRightBasket()
00795     {
00796         if ( $this->_blShowRightBasket === null ) {
00797             if ( $blShowRightBasket = $this->getConfig()->getConfigParam( 'bl_perfShowRightBasket' ) ) {
00798                 $this->_blShowRightBasket = $blShowRightBasket;
00799             }
00800         }
00801         return $this->_blShowRightBasket;
00802     }
00803 
00811     public function setShowRightBasket( $blShowBasket )
00812     {
00813         $this->_blShowRightBasket = $blShowBasket;
00814     }
00815 
00821     public function showLeftBasket()
00822     {
00823         if ( $this->_blShowLeftBasket === null ) {
00824             if ( $blShowLeftBasket = $this->getConfig()->getConfigParam( 'bl_perfShowLeftBasket' ) ) {
00825                 $this->_blShowLeftBasket = $blShowLeftBasket;
00826             }
00827         }
00828         return $this->_blShowLeftBasket;
00829     }
00830 
00838     public function setShowLeftBasket( $blShowBasket )
00839     {
00840         $this->_blShowLeftBasket = $blShowBasket;
00841     }
00842 
00848     public function showTopBasket()
00849     {
00850         if ( $this->_blShowTopBasket === null ) {
00851             if ( $blShowTopBasket = $this->getConfig()->getConfigParam( 'bl_perfShowTopBasket' ) ) {
00852                 $this->_blShowTopBasket = $blShowTopBasket;
00853             }
00854         }
00855         return $this->_blShowTopBasket;
00856     }
00857 
00865     public function setShowTopBasket( $blShowBasket )
00866     {
00867         $this->_blShowTopBasket = $blShowBasket;
00868     }
00869 
00875     public function loadCurrency()
00876     {
00877         if ( $this->_blLoadCurrency == null ) {
00878             $this->_blLoadCurrency = false;
00879             if ( $blLoadCurrency = $this->getConfig()->getConfigParam( 'bl_perfLoadCurrency' ) ) {
00880                 $this->_blLoadCurrency = $blLoadCurrency;
00881             }
00882         }
00883         return $this->_blLoadCurrency;
00884     }
00885 
00891     public function loadVendorTree()
00892     {
00893         if ( $this->_blLoadVendorTree == null ) {
00894             $this->_blLoadVendorTree = false;
00895             if ( $blLoadVendorTree = $this->getConfig()->getConfigParam( 'bl_perfLoadVendorTree' ) ) {
00896                 $this->_blLoadVendorTree = $blLoadVendorTree;
00897             }
00898         }
00899         return $this->_blLoadVendorTree;
00900     }
00901 
00907     public function loadManufacturerTree()
00908     {
00909         if ( $this->_blLoadManufacturerTree == null ) {
00910             $this->_blLoadManufacturerTree = false;
00911             if ( $blLoadManufacturerTree = $this->getConfig()->getConfigParam( 'bl_perfLoadManufacturerTree' ) ) {
00912                 $this->_blLoadManufacturerTree = $blLoadManufacturerTree;
00913             }
00914         }
00915         return $this->_blLoadManufacturerTree;
00916     }
00917 
00923     public function dontShowEmptyCategories()
00924     {
00925         if ( $this->_blDontShowEmptyCats == null ) {
00926             $this->_blDontShowEmptyCats = false;
00927             if ( $blDontShowEmptyCats = $this->getConfig()->getConfigParam( 'blDontShowEmptyCategories' ) ) {
00928                 $this->_blDontShowEmptyCats = $blDontShowEmptyCats;
00929             }
00930         }
00931         return $this->_blDontShowEmptyCats;
00932     }
00933 
00939     public function showCategoryArticlesCount()
00940     {
00941         return $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' );
00942     }
00943 
00949     public function isLanguageLoaded()
00950     {
00951         if ( $this->_blLoadLanguage == null ) {
00952             $this->_blLoadLanguage = false;
00953             if ( $blLoadLanguage = $this->getConfig()->getConfigParam( 'bl_perfLoadLanguages' ) ) {
00954                 $this->_blLoadLanguage = $blLoadLanguage;
00955             }
00956         }
00957         return $this->_blLoadLanguage;
00958     }
00959 
00965     public function showTopCatNavigation()
00966     {
00967         if ( $this->_blShowTopCatNav == null ) {
00968             $this->_blShowTopCatNav = false;
00969             if ( $blShowTopCatNav = $this->getConfig()->getConfigParam( 'blTopNaviLayout' ) ) {
00970                 $this->_blShowTopCatNav = $blShowTopCatNav;
00971             }
00972         }
00973         return $this->_blShowTopCatNav;
00974     }
00975 
00981     public function getTopNavigationCatCnt()
00982     {
00983         if ( $this->_iTopCatNavItmCnt == null ) {
00984             $iTopCatNavItmCnt = $this->getConfig()->getConfigParam( 'iTopNaviCatCount' );
00985             $this->_iTopCatNavItmCnt = $iTopCatNavItmCnt ? $iTopCatNavItmCnt : 5;
00986         }
00987         return $this->_iTopCatNavItmCnt;
00988     }
00989 
00999     public function addRssFeed($sTitle, $sUrl, $key = null)
01000     {
01001         if (!is_array($this->_aRssLinks)) {
01002             $this->_aRssLinks = array();
01003         }
01004         if ($key === null) {
01005             $this->_aRssLinks[] = array('title'=>$sTitle, 'link' => $sUrl);
01006         } else {
01007             $this->_aRssLinks[$key] = array('title'=>$sTitle, 'link' => $sUrl);
01008         }
01009     }
01010 
01016     public function getSortOrderByParameterName()
01017     {
01018         return 'listorderby';
01019     }
01020 
01026     public function getSortOrderParameterName()
01027     {
01028         return 'listorder';
01029     }
01030 
01041     public function prepareSortColumns()
01042     {
01043         $aSortColumns = $this->getConfig()->getConfigParam( 'aSortCols' );
01044         if ( count( $aSortColumns ) > 0 ) {
01045 
01046             $this->_blActiveSorting = true;
01047             $this->_aSortColumns = $aSortColumns;
01048 
01049             $sCnid = oxConfig::getParameter( 'cnid' );
01050 
01051 
01052             $sSortBy  = oxConfig::getParameter( $this->getSortOrderByParameterName() );
01053             $sSortDir = oxConfig::getParameter( $this->getSortOrderParameterName() );
01054 
01055             if ( !$sSortBy && $aSorting = $this->getSorting( $sCnid ) ) {
01056                 $sSortBy  = $aSorting['sortby'];
01057                 $sSortDir = $aSorting['sortdir'];
01058             }
01059 
01060             if ( $sSortBy && oxDb::getInstance()->isValidFieldName( $sSortBy ) &&
01061                  $sSortDir && oxUtils::getInstance()->isValidAlpha( $sSortDir ) ) {
01062 
01063                 $this->_sListOrderBy  = $sSortBy;
01064                 $this->_sListOrderDir = $sSortDir;
01065 
01066                 // caching sorting config
01067                 $this->setItemSorting( $sCnid, $sSortBy, $sSortDir );
01068             }
01069         }
01070     }
01071 
01077     public function getListOrderBy()
01078     {
01079         //if column is with table name split it
01080         $aColums = explode('.', $this->_sListOrderBy);
01081 
01082         if ( is_array($aColums) && count($aColums) > 1 ) {
01083            return $aColums[1];
01084         }
01085 
01086         return $this->_sListOrderBy;
01087     }
01088 
01094     public function getListOrderDirection()
01095     {
01096         return $this->_sListOrderDir;
01097     }
01098 
01106     public function setMetaDescription ( $sDescription )
01107     {
01108         return $this->_sMetaDescription = $sDescription;
01109     }
01110 
01118     public function setMetaKeywords( $sKeywords )
01119     {
01120         return $this->_sMetaKeywords = $sKeywords;
01121     }
01122 
01130     protected function _getMetaFromSeo( $sDataType )
01131     {
01132         $sOxid  = $this->_getSeoObjectId();
01133         $iLang  = oxLang::getInstance()->getBaseLanguage();
01134         $sShop  = $this->getConfig()->getShopId();
01135 
01136         if ( $sOxid && oxUtils::getInstance()->seoIsActive() &&
01137              ( $sKeywords = oxSeoEncoder::getInstance()->getMetaData( $sOxid, $sDataType, $sShop, $iLang) ) ) {
01138             return $sKeywords;
01139         }
01140     }
01141 
01149     protected function _getMetaFromContent( $sMetaIdent )
01150     {
01151         if ( $sMetaIdent ) {
01152             $oContent = oxNew( 'oxcontent' );
01153             if ( $oContent->loadByIdent( $sMetaIdent ) &&
01154                  $oContent->oxcontents__oxactive->value ) {
01155                 return strip_tags( $oContent->oxcontents__oxcontent->value );
01156             }
01157         }
01158     }
01159 
01165     public function getMetaKeywords()
01166     {
01167         if ( $this->_sMetaKeywords === null ) {
01168             $this->_sMetaKeywords = false;
01169 
01170             // set special meta keywords ?
01171             if ( ( $sKeywords = $this->_getMetaFromSeo( 'oxkeywords' ) ) ) {
01172                 $this->_sMetaKeywords = $sKeywords;
01173             } elseif ( ( $sKeywords = $this->_getMetaFromContent( $this->_sMetaKeywordsIdent ) ) ) {
01174                 $this->_sMetaKeywords = $this->_prepareMetaKeyword( $sKeywords, false );
01175             } else {
01176                 $this->_sMetaKeywords = $this->_prepareMetaKeyword( false, true );
01177             }
01178         }
01179 
01180         return $this->_sMetaKeywords;
01181     }
01182 
01188     public function getMetaDescription()
01189     {
01190         if ( $this->_sMetaDescription === null ) {
01191             $this->_sMetaDescription = false;
01192 
01193             // set special meta description ?
01194             if ( ( $sDescription = $this->_getMetaFromSeo( 'oxdescription' ) ) ) {
01195                 $this->_sMetaDescription = $sDescription;
01196             } elseif ( ( $sDescription = $this->_getMetaFromContent( $this->_sMetaDescriptionIdent ) ) ) {
01197                 $this->_sMetaDescription = $this->_prepareMetaDescription( $sDescription );
01198             } else {
01199                 $this->_sMetaDescription = $this->_prepareMetaDescription( false );
01200             }
01201         }
01202 
01203         return $this->_sMetaDescription;
01204     }
01205 
01211     public function getActCurrency()
01212     {
01213         return $this->_oActCurrency;
01214     }
01215 
01223     public function setActCurrency( $oCur )
01224     {
01225         $this->_oActCurrency = $oCur;
01226     }
01227 
01233     public function getCompareItemsCnt()
01234     {
01235         return (int)$this->_iCompItemsCnt;
01236     }
01237 
01245     public function setCompareItemsCnt( $iCount )
01246     {
01247         $this->_iCompItemsCnt = $iCount;
01248     }
01249 
01255     public function getWishlistName()
01256     {
01257         return $this->_sWishlistName;
01258     }
01259 
01267     public function setWishlistName( $sName )
01268     {
01269         $this->_sWishlistName = $sName;
01270     }
01271 
01277     protected function _forceNoIndex()
01278     {
01279         $this->_blForceNoIndex = true;
01280     }
01281 
01288     public function noIndex()
01289     {
01290         if ( $this->_blForceNoIndex ) {
01291             $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
01292         } elseif ( oxConfig::getParameter( 'cur' ) ) {
01293             $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
01294         } else {
01295             switch ( oxConfig::getParameter( 'fnc' ) ) {
01296                 case 'tocomparelist':
01297                 case 'tobasket':
01298                     $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
01299                     break;
01300             }
01301         }
01302         return $this->_iViewIndexState;
01303     }
01304 
01311     public function getContentId()
01312     {
01313         if ( $this->_sContentId === null) {
01314             $oContent = oxNew( 'oxcontent' );
01315             $oContent->loadByIdent( 'oximpressum' );
01316             $this->_sContentId = $oContent->getId();
01317         }
01318 
01319         return $this->_sContentId;
01320     }
01321 
01328     public function getContent()
01329     {
01330         if ( $this->_oContent === null) {
01331             $oContent = oxNew( 'oxcontent' );
01332             if ( $oContent->load( $this->getContentId() ) && $oContent->oxcontents__oxactive->value ) {
01333                 $this->_oContent = $oContent;
01334             }
01335         }
01336 
01337         return $this->_oContent;
01338     }
01339 
01345     public function isSortingActive()
01346     {
01347         return $this->_blActiveSorting;
01348     }
01349 
01355     public function getMenueList()
01356     {
01357         return $this->_aMenueList;
01358     }
01359 
01367     public function setMenueList( $aMenue )
01368     {
01369         $this->_aMenueList = $aMenue;
01370     }
01371 
01372 
01378     protected function _setNrOfArtPerPage()
01379     {
01380         $myConfig  = $this->getConfig();
01381 
01382         //setting default values to avoid possible errors showing article list
01383         $iNrofCatArticles = $myConfig->getConfigParam( 'iNrofCatArticles' );
01384 
01385         $iNrofCatArticles = ( $iNrofCatArticles ) ? $iNrofCatArticles : 10;
01386 
01387         // checking if all needed data is set
01388         switch ( $this->getListDisplayType() ) {
01389             case 'grid':
01390                 $aNrofCatArticles = $myConfig->getConfigParam( 'aNrofCatArticlesInGrid' );
01391                 break;
01392             case 'line':
01393             case 'infogrid':
01394             default:
01395                 $aNrofCatArticles = $myConfig->getConfigParam( 'aNrofCatArticles' );
01396         }
01397 
01398         if ( !is_array( $aNrofCatArticles ) || !isset( $aNrofCatArticles[0] ) ) {
01399             $myConfig->setConfigParam( 'aNrofCatArticles', array( $iNrofCatArticles ) );
01400         } else {
01401             $iNrofCatArticles = $aNrofCatArticles[0];
01402         }
01403 
01404         $oViewConf = $this->getViewConfig();
01405         //value from user input
01406         if ( ( $iNrofArticles = (int) oxConfig::getParameter( '_artperpage' ) ) ) {
01407             // M45 Possibility to push any "Show articles per page" number parameter
01408             $iNrofCatArticles = ( in_array( $iNrofArticles, $aNrofCatArticles ) ) ? $iNrofArticles : $iNrofCatArticles;
01409             $oViewConf->setViewConfigParam( 'iartPerPage', $iNrofCatArticles );
01410             oxSession::setVar( '_artperpage', $iNrofCatArticles );
01411         } elseif ( ( $iSessArtPerPage = oxSession::getVar( '_artperpage' ) )&& is_numeric( $iSessArtPerPage ) ) {
01412             // M45 Possibility to push any "Show articles per page" number parameter
01413             $iNrofCatArticles = ( in_array( $iSessArtPerPage, $aNrofCatArticles ) ) ? $iSessArtPerPage : $iNrofCatArticles;
01414             $oViewConf->setViewConfigParam( 'iartPerPage', $iSessArtPerPage );
01415             $iNrofCatArticles = $iSessArtPerPage;
01416         } else {
01417             $oViewConf->setViewConfigParam( 'iartPerPage', $iNrofCatArticles );
01418         }
01419 
01420         //setting number of articles per page to config value
01421         $myConfig->setConfigParam( 'iNrofCatArticles', $iNrofCatArticles );
01422     }
01423 
01429     protected function _getSeoObjectId()
01430     {
01431     }
01432 
01442     protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blRemoveDuplicatedWords = false )
01443     {
01444         if ( $sMeta ) {
01445 
01446             $oStr = getStr();
01447             if ( $iLength != -1 ) {
01448                 /* *
01449                  * performance - we dont need a huge amount of initial text.
01450                  * assume that effective text may be double longer than $iLength
01451                  * and simple turncate it
01452                  */
01453                 $iELength = ( $iLength * 2 );
01454                 $sMeta = $oStr->substr( $sMeta, 0, $iELength );
01455             }
01456 
01457             // decoding html entities
01458             $sMeta = $oStr->html_entity_decode( $sMeta );
01459             // stripping HTML tags
01460             $sMeta = strip_tags( $sMeta );
01461 
01462             // removing some special chars
01463             $sMeta = $oStr->cleanStr( $sMeta );
01464 
01465             // removing duplicate words
01466             if ( $blRemoveDuplicatedWords ) {
01467                 $sMeta = $this->_removeDuplicatedWords( $sMeta, $this->getConfig()->getConfigParam( 'aSkipTags' ) );
01468             }
01469 
01470             // some special cases
01471             $sMeta = str_replace( ' ,', ',', $sMeta );
01472             $aPattern = array( "/,[\s\+\-\*]*,/", "/\s+,/" );
01473             $sMeta = $oStr->preg_replace( $aPattern, ',', $sMeta );
01474             $sMeta = oxUtilsString::getInstance()->minimizeTruncateString( $sMeta, $iLength );
01475 
01476             return trim( $sMeta );
01477         }
01478     }
01479 
01488     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
01489     {
01490 
01491         $sString = $this->_prepareMetaDescription( $sKeywords, -1, false );
01492 
01493         if ( $blRemoveDuplicatedWords ) {
01494             $sString = $this->_removeDuplicatedWords( $sString, $this->getConfig()->getConfigParam( 'aSkipTags' ) );
01495         }
01496 
01497         // removing in admin defined strings
01498 
01499         /*if ( is_array( $aSkipTags ) && $sString ) {
01500             $oStr = getStr();
01501             foreach ( $aSkipTags as $sSkip ) {
01502                 //$aPattern = array( '/\W'.$sSkip.'\W/iu', '/^'.$sSkip.'\W/iu', '/\"'.$sSkip.'$/iu' );
01503                 //$aPattern = array( '/\s+'.$sSkip.'\,/iu', '/^'.$sSkip.'\s+/iu', '/\"\s+'.$sSkip.'$/iu' );
01504                 $aPattern = array( '/\s+'.$sSkip.'\,/i', '/^'.$sSkip.',\s+/i', '/\",\s+'.$sSkip.'$/i' );
01505                 $sString  = $oStr->preg_replace( $aPattern, '', $sString );
01506             }
01507         }*/
01508 
01509         return trim( $sString );
01510     }
01511 
01520     protected function _removeDuplicatedWords( $aInput, $aSkipTags = array() )
01521     {
01522         $oStr = getStr();
01523         if ( is_array( $aInput ) ) {
01524             $aInput = implode( " ", $aInput );
01525         }
01526 
01527         // removing some usually met characters..
01528         $aInput = $oStr->preg_replace( "/[".preg_quote( $this->_sRemoveMetaChars, "/" )."]/", " ", $aInput );
01529 
01530         // splitting by word
01531         $aStrings = $oStr->preg_split( "/[\s,]+/", $aInput );
01532 
01533         if ( $sCount = count( $aSkipTags ) ) {
01534             for ( $iNum = 0; $iNum < $sCount; $iNum++ ) {
01535                 $aSkipTags[$iNum] = $oStr->strtolower( $aSkipTags[$iNum] );
01536             }
01537         }
01538         $sCount = count($aStrings);
01539         for ( $iNum = 0; $iNum < $sCount; $iNum++ ) {
01540             $aStrings[$iNum] = $oStr->strtolower( $aStrings[$iNum] );
01541             // removing in admin defined strings
01542             if ( !$aStrings[$iNum] || in_array( $aStrings[$iNum], $aSkipTags ) ) {
01543                 unset( $aStrings[$iNum] );
01544             }
01545         }
01546 
01547         // duplicates
01548         return implode( ', ', array_unique( $aStrings ) );
01549     }
01550 
01558     public function getNavigationParams()
01559     {
01560         $aParams['cnid'] = $this->getCategoryId();
01561         $aParams['mnid'] = oxConfig::getParameter( 'mnid' );
01562 
01563         $aParams['listtype'] = $this->getListType();
01564         $aParams['ldtype'] = $this->getListDisplayType();
01565 
01566         $aParams['recommid'] = oxConfig::getParameter( 'recommid' );
01567 
01568         $aParams['searchrecomm'] = oxConfig::getParameter( 'searchrecomm', true );
01569         $aParams['searchparam']  = oxConfig::getParameter( 'searchparam', true );
01570         $aParams['searchtag']    = oxConfig::getParameter( 'searchtag', true );
01571 
01572         $aParams['searchvendor'] = oxConfig::getParameter( 'searchvendor' );
01573         $aParams['searchcnid']   = oxConfig::getParameter( 'searchcnid' );
01574         $aParams['searchmanufacturer'] = oxConfig::getParameter( 'searchmanufacturer' );
01575 
01576         return $aParams;
01577     }
01578 
01588     public function setItemSorting( $sCnid, $sSortBy, $sSortDir = null )
01589     {
01590 
01591         $aSorting = oxSession::getVar( 'aSorting' );
01592         $aSorting[$sCnid]['sortby']  = $sSortBy;
01593         $aSorting[$sCnid]['sortdir'] = $sSortDir?$sSortDir:null;
01594 
01595         oxSession::setVar( 'aSorting', $aSorting );
01596     }
01597 
01605     public function getSorting( $sCnid )
01606     {
01607         $aSorting = oxSession::getVar( 'aSorting' );
01608 
01609         if ( isset( $aSorting[$sCnid] ) ) {
01610             return $aSorting[$sCnid];
01611         }
01612     }
01613 
01621     public function getSortingSql( $sCnid )
01622     {
01623         $aSorting = $this->getSorting( $sCnid );
01624         if ( is_array( $aSorting ) ) {
01625             return implode( " ", $aSorting );
01626         }
01627     }
01628 
01634     public function getTitleSuffix()
01635     {
01636         return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
01637     }
01638 
01644     public function getTitlePageSuffix()
01645     {
01646     }
01647 
01654     public function getTitlePrefix()
01655     {
01656         return $this->getConfig()->getActiveShop()->oxshops__oxtitleprefix->value;
01657     }
01658 
01659 
01660 
01669     protected function _getSubject( $iLang )
01670     {
01671         return null;
01672     }
01673 
01679     public function getDynUrlParams()
01680     {
01681         $sRet = '';
01682         $sListType = $this->getListType();
01683 
01684         switch ($sListType) {
01685             default:
01686                 break;
01687             case 'search':
01688                 $sRet .= "&amp;listtype={$sListType}";
01689                 if ( $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
01690                     $sRet .= "&amp;searchparam={$sSearchParamForLink}";
01691                 }
01692 
01693                 if ( ( $sVar = oxConfig::getParameter( 'searchcnid' ) ) ) {
01694                     $sRet .= '&amp;searchcnid='.rawurlencode( rawurldecode( $sVar ) );
01695                 }
01696                 if ( ( $sVar = oxConfig::getParameter( 'searchvendor' ) ) ) {
01697                     $sRet .= '&amp;searchvendor='.rawurlencode( rawurldecode( $sVar ) );
01698                 }
01699                 if ( ( $sVar = oxConfig::getParameter( 'searchmanufacturer' ) ) ) {
01700                     $sRet .= '&amp;searchmanufacturer='.rawurlencode( rawurldecode( $sVar ) );
01701                 }
01702                 break;
01703             case 'tag':
01704                 $sRet .= "&amp;listtype={$sListType}";
01705                 if ( $sParam = rawurlencode( oxConfig::getParameter( 'searchtag', 1 ) ) ) {
01706                     $sRet .= "&amp;searchtag={$sParam}";
01707                 }
01708                 break;
01709         }
01710 
01711         return $sRet;
01712     }
01713 
01721     public function getLink( $iLang = null )
01722     {
01723         if ( !isset( $iLang ) ) {
01724             $iLang = oxLang::getInstance()->getBaseLanguage();
01725         }
01726 
01727         $oDisplayObj = null;
01728         $blTrySeo = false;
01729         if ( oxUtils::getInstance()->seoIsActive() ) {
01730             $blTrySeo = true;
01731             $oDisplayObj = $this->_getSubject( $iLang );
01732         }
01733         $iActPageNr = $this->getActPage();
01734 
01735         if ( $oDisplayObj ) {
01736             return $this->_addPageNrParam( $oDisplayObj->getLink( $iLang ), $iActPageNr, $iLang );
01737         }
01738 
01739         $myConfig = $this->getConfig();
01740 
01741         if ( $blTrySeo ) {
01742             $oEncoder = oxSeoEncoder::getInstance();
01743             if ( ( $sSeoUrl = $oEncoder->getStaticUrl( $myConfig->getShopHomeURL( $iLang ) . $this->_getSeoRequestParams(), $iLang ) ) ) {
01744                 return $this->_addPageNrParam( $sSeoUrl, $iActPageNr, $iLang );
01745             }
01746         }
01747 
01748         $sUrl = oxUtilsUrl::getInstance()->processUrl( $myConfig->getShopCurrentURL( $iLang ) . $this->_getRequestParams(), true, null, $iLang);
01749 
01750         // fallback to old non seo url
01751         return $this->_addPageNrParam( $sUrl, $iActPageNr, $iLang );
01752     }
01753 
01759     public function getCanonicalUrl()
01760     {
01761     }
01762 
01769     public function getSimilarRecommLists()
01770     {
01771     }
01772 
01779     public function getSearchParamForHtml()
01780     {
01781     }
01782 
01790     protected function _getRequestParams( $blAddPageNr  = true )
01791     {
01792         $sClass = $this->getClassName();
01793         $sFnc   = $this->getFncName();
01794 
01795         $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher', 'moveleft', 'moveright' );
01796         if ( in_array( $sFnc, $aFnc ) ) {
01797             $sFnc = '';
01798         }
01799 
01800         // #680
01801         $sURL = "cl={$sClass}";
01802         if ( $sFnc ) {
01803             $sURL .= "&amp;fnc={$sFnc}";
01804         }
01805         if ( $sVal = oxConfig::getParameter( 'cnid' ) ) {
01806             $sURL .= "&amp;cnid={$sVal}";
01807         }
01808         if ( $sVal = oxConfig::getParameter( 'mnid' ) ) {
01809             $sURL .= "&amp;mnid={$sVal}";
01810         }
01811         if ( $sVal= oxConfig::getParameter( 'anid' ) ) {
01812             $sURL .= "&amp;anid={$sVal}";
01813         }
01814 
01815         if ( $sVal = basename( oxConfig::getParameter( 'page' ) ) ) {
01816             $sURL .= "&amp;page={$sVal}";
01817         }
01818 
01819         if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
01820             $sURL .= "&amp;tpl={$sVal}";
01821         }
01822 
01823         $iPgNr = (int) oxConfig::getParameter( 'pgNr' );
01824         // don't include page number for navigation
01825         // it will be done in oxubase::generatePageNavigation
01826         if ( $blAddPageNr && $iPgNr > 0 ) {
01827             $sURL .= "&amp;pgNr={$iPgNr}";
01828         }
01829 
01830         // #1184M - specialchar search
01831         if ( $sVal = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
01832             $sURL .= "&amp;searchparam={$sVal}";
01833         }
01834 
01835         if ( $sVal = oxConfig::getParameter( 'searchcnid' ) ) {
01836             $sURL .= "&amp;searchcnid={$sVal}";
01837         }
01838 
01839         if ( $sVal = oxConfig::getParameter( 'searchvendor' ) ) {
01840             $sURL .= "&amp;searchvendor={$sVal}";
01841         }
01842 
01843         if ( $sVal = oxConfig::getParameter( 'searchmanufacturer' ) ) {
01844             $sURL .= "&amp;searchmanufacturer={$sVal}";
01845         }
01846 
01847         if ( $sVal = oxConfig::getParameter( 'searchrecomm' ) ) {
01848             $sURL .= "&amp;searchrecomm={$sVal}";
01849         }
01850 
01851         if ( $sVal = oxConfig::getParameter( 'searchtag' ) ) {
01852             $sURL .= "&amp;searchtag={$sVal}";
01853         }
01854 
01855         if ( $sVal = oxConfig::getParameter( 'recommid' ) ) {
01856             $sURL .= "&amp;recommid={$sVal}";
01857         }
01858 
01859         return $sURL;
01860     }
01861 
01867     protected function _getSeoRequestParams()
01868     {
01869         $sClass = $this->getClassName();
01870         $sFnc   = $this->getFncName();
01871 
01872         // #921 S
01873         $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher' );
01874         if ( in_array( $sFnc, $aFnc ) ) {
01875             $sFnc = '';
01876         }
01877 
01878         // #680
01879         $sURL = "cl={$sClass}";
01880         if ( $sFnc ) {
01881             $sURL .= "&amp;fnc={$sFnc}";
01882         }
01883         if ( $sVal = basename( oxConfig::getParameter( 'page' ) ) ) {
01884             $sURL .= "&amp;page={$sVal}";
01885         }
01886 
01887         if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
01888             $sURL .= "&amp;tpl={$sVal}";
01889         }
01890 
01891         $iPgNr = (int) oxConfig::getParameter( 'pgNr' );
01892         if ( $iPgNr > 0 ) {
01893             $sURL .= "&amp;pgNr={$iPgNr}";
01894         }
01895 
01896         return $sURL;
01897     }
01898 
01904     public function showSearch()
01905     {
01906         $blShow = true;
01907         if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) && $this->getIsOrderStep() ) {
01908             $blShow = false;
01909         }
01910         return (int) $blShow;
01911     }
01912 
01918     public function getRssLinks()
01919     {
01920         return $this->_aRssLinks;
01921     }
01922 
01928     public function getSortColumns()
01929     {
01930         return $this->_aSortColumns;
01931     }
01932 
01938     public function getEditTags()
01939     {
01940     }
01941 
01947     public function getRecommSearch()
01948     {
01949     }
01950 
01956     public function getPaymentList()
01957     {
01958     }
01959 
01965     public function getActiveRecommList()
01966     {
01967         if ( $this->_oActiveRecommList === null ) {
01968             $this->_oActiveRecommList = false;
01969             if ( $sOxid = oxConfig::getParameter( 'recommid' ) ) {
01970                 $this->_oActiveRecommList = oxNew( 'oxrecommlist' );
01971                 $this->_oActiveRecommList->load( $sOxid );
01972             }
01973         }
01974         return $this->_oActiveRecommList;
01975     }
01976 
01982     public function getAccessoires()
01983     {
01984     }
01985 
01991     public function getCrossSelling()
01992     {
01993     }
01994 
02000     public function getSimilarProducts()
02001     {
02002     }
02003 
02009     public function getAlsoBoughtTheseProducts()
02010     {
02011     }
02012 
02018     public function getArticleId()
02019     {
02020     }
02021 
02027     public function isMoreTagsVisible()
02028     {
02029         return false;
02030     }
02031 
02037     public function getTitle()
02038     {
02039     }
02040 
02046     public function getActiveLangAbbr()
02047     {
02048         // Performance
02049         if ( !$this->getConfig()->getConfigParam( 'bl_perfLoadLanguages' ) ) {
02050             return;
02051         }
02052 
02053         if ( !isset($this->_sActiveLangAbbr ) ) {
02054             $aLanguages = oxLang::getInstance()->getLanguageArray();
02055             while ( list( $sKey, $oVal ) = each( $aLanguages ) ) {
02056                 if ( $oVal->selected ) {
02057                     $this->_sActiveLangAbbr = $oVal->abbr;
02058                     break;
02059                 }
02060             }
02061         }
02062 
02063         return $this->_sActiveLangAbbr;
02064     }
02065 
02073     public function addGlobalParams( $oShop = null)
02074     {
02075         $oViewConf = parent::addGlobalParams( $oShop );
02076 
02077         $this->_setNrOfArtPerPage();
02078 
02079         return $oViewConf;
02080     }
02081 
02087     public function getAdditionalParams()
02088     {
02089         if ( $this->_sAdditionalParams === null ) {
02090             // #1018A
02091             $this->_sAdditionalParams  = parent::getAdditionalParams();
02092             $this->_sAdditionalParams .= 'cl='.$this->getConfig()->getActiveView()->getClassName();
02093 
02094             // #1834M - specialchar search
02095             $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) );
02096             if ( isset( $sSearchParamForLink ) ) {
02097                 $this->_sAdditionalParams .= "&amp;searchparam={$sSearchParamForLink}";
02098             }
02099             if ( ( $sVar = oxConfig::getParameter( 'searchtag' ) ) ) {
02100                 $this->_sAdditionalParams .= '&amp;searchtag='.rawurlencode( rawurldecode( $sVar ) );
02101             }
02102             if ( ( $sVar = oxConfig::getParameter( 'searchcnid' ) ) ) {
02103                 $this->_sAdditionalParams .= '&amp;searchcnid='.rawurlencode( rawurldecode( $sVar ) );
02104             }
02105             if ( ( $sVar = oxConfig::getParameter( 'searchvendor' ) ) ) {
02106                 $this->_sAdditionalParams .= '&amp;searchvendor='.rawurlencode( rawurldecode( $sVar ) );
02107             }
02108             if ( ( $sVar = oxConfig::getParameter( 'searchmanufacturer' ) ) ) {
02109                 $this->_sAdditionalParams .= '&amp;searchmanufacturer='.rawurlencode( rawurldecode( $sVar ) );
02110             }
02111             if ( ( $sVar = oxConfig::getParameter( 'cnid' ) ) ) {
02112                 $this->_sAdditionalParams .= '&amp;cnid='.rawurlencode( rawurldecode( $sVar ) );
02113             }
02114             if ( ( $sVar = oxConfig::getParameter( 'mnid' ) ) ) {
02115                 $this->_sAdditionalParams .= '&amp;mnid='.rawurlencode( rawurldecode( $sVar ) );
02116             }
02117         }
02118 
02119         return $this->_sAdditionalParams;
02120     }
02121 
02127     public function generatePageNavigationUrl()
02128     {
02129         return $this->getConfig()->getShopHomeURL().$this->_getRequestParams( false );
02130     }
02131 
02141     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null )
02142     {
02143         if ( $iPage ) {
02144             if ( ( strpos( $sUrl, 'pgNr=' ) ) ) {
02145                 $sUrl = preg_replace('/pgNr=[0-9]*/', 'pgNr='.$iPage, $sUrl);
02146             } else {
02147                 $sUrl .= ( ( strpos( $sUrl, '?' ) === false ) ? '?' : '&amp;' ) . 'pgNr='.$iPage;
02148             }
02149         } else {
02150            $sUrl = preg_replace('/pgNr=[0-9]*/', '', $sUrl);
02151            $sUrl = preg_replace('/\&amp\;\&amp\;/', '&amp;', $sUrl);
02152            $sUrl = preg_replace('/\?\&amp\;/', '?', $sUrl);
02153            $sUrl = preg_replace('/\&amp\;$/', '', $sUrl);
02154         }
02155         return $sUrl;
02156     }
02157 
02163     public function getPageNavigation()
02164     {
02165 
02166     }
02167 
02173     public function getPageNavigationLimitedTop()
02174     {
02175 
02176         $this->_oPageNavigation = $this->generatePageNavigation( 7 );
02177 
02178         return $this->_oPageNavigation;
02179     }
02180 
02186     public function getPageNavigationLimitedBottom()
02187     {
02188 
02189         $this->_oPageNavigation = $this->generatePageNavigation( 11 );
02190 
02191         return $this->_oPageNavigation;
02192     }
02193 
02194 
02202     public function generatePageNavigation( $iPositionCount = 0 )
02203     {
02204         startProfile('generatePageNavigation');
02205 
02206         $pageNavigation = new stdClass();
02207 
02208         $pageNavigation->NrOfPages = $this->_iCntPages;
02209         $pageNavigation->iArtCnt   = $this->_iAllArtCnt;
02210         $iActPage = $this->getActPage();
02211         $pageNavigation->actPage   = $iActPage + 1;
02212         $sUrl = $this->generatePageNavigationUrl();
02213 
02214         if ( $iPositionCount == 0 || ($iPositionCount >= $pageNavigation->NrOfPages) ) {
02215              $iStartNo = 2;
02216              $iFinishNo = $pageNavigation->NrOfPages;
02217              $bStart = false;
02218              $bFinish =false;
02219         } else {
02220             $iTmpVal = $iPositionCount - 3;
02221             $iTmpVal2 = floor( ( $iPositionCount - 4 ) / 2 );
02222 
02223             // actual page is at the start
02224             if ( $pageNavigation->actPage <= $iTmpVal ) {
02225                 $iStartNo = 2;
02226                 $iFinishNo = $iTmpVal + 1;
02227                 $bStart = false;
02228                 $bFinish = true;
02229             // actual page is at the end
02230             } elseif ( $pageNavigation->actPage >= $pageNavigation->NrOfPages - $iTmpVal ) {
02231                 $iStartNo = $pageNavigation->NrOfPages - $iTmpVal;
02232                 $iFinishNo = $pageNavigation->NrOfPages - 1;
02233                 $bStart = true;
02234                 $bFinish = false;
02235             // actual page is in the midle
02236             } else {
02237                 $iStartNo = $pageNavigation->actPage - $iTmpVal2;
02238                 $iFinishNo = $pageNavigation->actPage + $iTmpVal2;
02239                 $bStart = true;
02240                 $bFinish = true;
02241             }
02242         }
02243 
02244         if ( $iActPage > 0) {
02245             $pageNavigation->previousPage = $this->_addPageNrParam( $sUrl, $iActPage - 1 );
02246         }
02247 
02248         if ( $iActPage < $pageNavigation->NrOfPages - 1 ) {
02249             $pageNavigation->nextPage = $this->_addPageNrParam( $sUrl, $iActPage + 1 );
02250         }
02251 
02252         if ( $pageNavigation->NrOfPages > 1 ) {
02253 
02254             for ( $i=1; $i < $pageNavigation->NrOfPages + 1; $i++ ) {
02255 
02256                 if ( $i == 1 || $i == $pageNavigation->NrOfPages || ( $i >= $iStartNo && $i <= $iFinishNo ) ) {
02257                     $page = new Oxstdclass();
02258                     $page->url = $this->_addPageNrParam( $sUrl, $i - 1 );
02259                     $page->selected = ( $i == $pageNavigation->actPage ) ? 1 : 0;
02260                     $pageNavigation->changePage[$i] = $page;
02261                 }
02262             }
02263 
02264             // first/last one
02265             $pageNavigation->firstpage = $this->_addPageNrParam( $sUrl, 0 );
02266             $pageNavigation->lastpage  = $this->_addPageNrParam( $sUrl, $pageNavigation->NrOfPages - 1 );
02267         }
02268 
02269         stopProfile('generatePageNavigation');
02270 
02271         return $pageNavigation;
02272     }
02273 
02279     public function getArticleCount()
02280     {
02281         return $this->_iAllArtCnt;
02282     }
02283 
02290     public function render()
02291     {
02292         foreach ( array_keys( $this->_oaComponents ) as $sComponentName ) {
02293             $this->_aViewData[$sComponentName] = $this->_oaComponents[$sComponentName]->render();
02294         }
02295 
02296         parent::render();
02297 
02298         if ( $this->getIsOrderStep() ) {
02299 
02300             // disabling navigation during order ...
02301             if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) ) {
02302                 $this->_iNewsRealStatus = 1;
02303                 $this->setShowNewsletter( 0 );
02304                 $this->setShowRightBasket( 0 );
02305                 $this->setShowLeftBasket( 0 );
02306                 $this->setShowTopBasket( 0 );
02307             }
02308         }
02309         return $this->_sThisTemplate;
02310     }
02311 
02317     public function getViewProduct()
02318     {
02319         return $this->getProduct();
02320     }
02321 
02329     public function setViewProduct( $oProduct )
02330     {
02331         $this->_oProduct = $oProduct;
02332     }
02333 
02339     public function getViewProductList()
02340     {
02341         return $this->_aArticleList;
02342     }
02343 
02349     public function getActPage()
02350     {
02351         if ( $this->_iActPage === null ) {
02352             $this->_iActPage = ( int ) oxConfig::getParameter( 'pgNr' );
02353             $this->_iActPage = ( $this->_iActPage < 0 ) ? 0 : $this->_iActPage;
02354         }
02355         return $this->_iActPage;
02356     }
02357 
02365     public function getActTag()
02366     {
02367         if ( $this->_oActTag === null ) {
02368             $this->_oActTag = new Oxstdclass();
02369             $this->_oActTag->sTag = $sTag = oxConfig::getParameter("searchtag", 1);
02370             $oSeoEncoderTag = oxSeoEncoderTag::getInstance();
02371 
02372             $sLink = false;
02373             if ( oxUtils::getInstance()->seoIsActive() ) {
02374                 $sLink = $oSeoEncoderTag->getTagUrl( $sTag, oxLang::getInstance()->getBaseLanguage() );
02375             }
02376 
02377             $this->_oActTag->link = $sLink ? $sLink : $this->getConfig()->getShopHomeURL().$oSeoEncoderTag->getStdTagUri( $sTag, false );
02378         }
02379         return $this->_oActTag;
02380     }
02381 
02389     public function getActVendor()
02390     {
02391         // if active vendor is not set yet - trying to load it from request params
02392         // this may be usefull when category component was unable to load active vendor
02393         // and we still need some object to mount navigation info
02394         if ( $this->_oActVendor === null ) {
02395             $this->_oActVendor = false;
02396             $sVendorId = oxConfig::getParameter( 'cnid' );
02397             $sVendorId = $sVendorId ? str_replace( 'v_', '', $sVendorId ) : $sVendorId;
02398             $oVendor = oxNew( 'oxvendor' );
02399             if ( $oVendor->load( $sVendorId ) ) {
02400                 $this->_oActVendor = $oVendor;
02401             }
02402         }
02403 
02404         return $this->_oActVendor;
02405     }
02406 
02414     public function getActManufacturer()
02415     {
02416         // if active Manufacturer is not set yet - trying to load it from request params
02417         // this may be usefull when category component was unable to load active Manufacturer
02418         // and we still need some object to mount navigation info
02419         if ( $this->_oActManufacturer === null ) {
02420 
02421             $this->_oActManufacturer = false;
02422             $sManufacturerId = oxConfig::getParameter( 'mnid' );
02423             $oManufacturer = oxNew( 'oxmanufacturer' );
02424             if ( $oManufacturer->load( $sManufacturerId ) ) {
02425                 $this->_oActManufacturer = $oManufacturer;
02426             }
02427         }
02428 
02429         return $this->_oActManufacturer;
02430     }
02431 
02439     public function setActVendor( $oVendor )
02440     {
02441         $this->_oActVendor = $oVendor;
02442     }
02443 
02451     public function setActManufacturer( $oManufacturer )
02452     {
02453         $this->_oActManufacturer = $oManufacturer;
02454     }
02455 
02461     public function getActSearch()
02462     {
02463         if ( $this->_oActSearch === null ) {
02464             $this->_oActSearch = new oxStdClass();
02465             $sUrl = $this->getConfig()->getShopHomeURL();
02466             $this->_oActSearch->link = "{$sUrl}cl=search";
02467         }
02468         return $this->_oActSearch;
02469     }
02470 
02476     public function getCategoryTree()
02477     {
02478         return $this->_oCategoryTree;
02479     }
02480 
02488     public function setCategoryTree( $oCatTree )
02489     {
02490         $this->_oCategoryTree = $oCatTree;
02491     }
02492 
02498     public function getVendorTree()
02499     {
02500         return $this->_oVendorTree;
02501     }
02502 
02510     public function setVendorTree( $oVendorTree )
02511     {
02512         $this->_oVendorTree = $oVendorTree;
02513     }
02514 
02520     public function getManufacturerTree()
02521     {
02522         return $this->_oManufacturerTree;
02523     }
02524 
02532     public function setManufacturerTree( $oManufacturerTree )
02533     {
02534         $this->_oManufacturerTree = $oManufacturerTree;
02535     }
02536 
02542     public function getAddUrlParams()
02543     {
02544     }
02545 
02552     public function getTop5ArticleList()
02553     {
02554         if ( $this->_blTop5Action ) {
02555             if ( $this->_aTop5ArticleList === null ) {
02556                 $this->_aTop5ArticleList = false;
02557                 $myConfig = $this->getConfig();
02558                 if ( $myConfig->getConfigParam( 'bl_perfLoadAktion' ) ) {
02559                     // top 5 articles
02560                     $oArtList = oxNew( 'oxarticlelist' );
02561                     $oArtList->loadTop5Articles();
02562                     if ( $oArtList->count() ) {
02563                         $this->_aTop5ArticleList = $oArtList;
02564                     }
02565                 }
02566             }
02567         }
02568         return $this->_aTop5ArticleList;
02569     }
02570 
02577     public function getBargainArticleList()
02578     {
02579         if ( $this->_blBargainAction ) {
02580             if ( $this->_aBargainArticleList === null ) {
02581                 $this->_aBargainArticleList = array();
02582                 if ( $this->getConfig()->getConfigParam( 'bl_perfLoadAktion' ) ) {
02583                     $oArtList = oxNew( 'oxarticlelist' );
02584                     $oArtList->loadAktionArticles( 'OXBARGAIN' );
02585                     if ( $oArtList->count() ) {
02586                         $this->_aBargainArticleList = $oArtList;
02587                     }
02588                 }
02589             }
02590         }
02591         return $this->_aBargainArticleList;
02592     }
02593 
02600     public function isLowOrderPrice()
02601     {
02602         if ( $this->_blLowOrderPrice === null && ( $oBasket = $this->getSession()->getBasket() ) ) {
02603             $this->_blLowOrderPrice = $oBasket->isBelowMinOrderPrice();
02604         }
02605 
02606         return $this->_blLowOrderPrice;
02607     }
02608 
02614     public function getMinOrderPrice()
02615     {
02616         if ( $this->_sMinOrderPrice === null && $this->isLowOrderPrice() ) {
02617             $dMinOrderPrice = oxPrice::getPriceInActCurrency( $this->getConfig()->getConfigParam( 'iMinOrderPrice' ) );
02618             $this->_sMinOrderPrice = oxLang::getInstance()->formatCurrency( $dMinOrderPrice );
02619         }
02620         return $this->_sMinOrderPrice;
02621     }
02622 
02628     public function getNewsRealStatus()
02629     {
02630         return $this->_iNewsRealStatus;
02631     }
02632 
02638     protected function _canRedirect()
02639     {
02640         foreach ( $this->_aBlockRedirectParams as $sParam ) {
02641             if ( oxConfig::getParameter( $sParam ) !== null ) {
02642                 return false;
02643             }
02644         }
02645 
02646         return true;
02647     }
02648 
02654     public function getProduct()
02655     {
02656     }
02657 
02663     public function getVendorlist()
02664     {
02665         return $this->_aVendorlist;
02666     }
02667 
02675     public function setVendorlist( $aList )
02676     {
02677         $this->_aVendorlist = $aList;
02678     }
02679 
02685     public function getManufacturerlist()
02686     {
02687         return $this->_aManufacturerlist;
02688     }
02689 
02697     public function setManufacturerlist( $aList )
02698     {
02699         $this->_aManufacturerlist = $aList;
02700     }
02701 
02709     public function setRootVendor( $oVendor )
02710     {
02711         $this->_oRootVendor = $oVendor;
02712     }
02713 
02719     public function getRootVendor()
02720     {
02721         return $this->_oRootVendor;
02722     }
02723 
02731     public function setRootManufacturer( $oManufacturer )
02732     {
02733         $this->_oRootManufacturer = $oManufacturer;
02734     }
02735 
02741     public function getRootManufacturer()
02742     {
02743         return $this->_oRootManufacturer;
02744     }
02745 
02751     public function getVendorId()
02752     {
02753         if ( $this->_sVendorId === null ) {
02754             $this->_sVendorId = false;
02755             if ( ( $oVendor = $this->getActVendor() ) ) {
02756                 $this->_sVendorId = $oVendor->getId();
02757             }
02758         }
02759         return $this->_sVendorId;
02760     }
02761 
02767     public function getManufacturerId()
02768     {
02769         if ( $this->_sManufacturerId === null ) {
02770             $this->_sManufacturerId = false;
02771             if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
02772                 $this->_sManufacturerId = $oManufacturer->getId();
02773             }
02774         }
02775         return $this->_sManufacturerId;
02776     }
02777 
02783     public function getSearchCatTree()
02784     {
02785         return $this->_aSearchCatTree;
02786     }
02787 
02795     public function setSearchCatTree( $aTree )
02796     {
02797         $this->_aSearchCatTree = $aTree;
02798     }
02799 
02805     public function getCatMoreUrl()
02806     {
02807         return $this->getConfig()->getShopHomeURL().'cnid=oxmore';
02808     }
02809 
02815     public function getCatMore()
02816     {
02817         return $this->_oCatMore;
02818     }
02819 
02827     public function setCatMore( $oCat )
02828     {
02829         $this->_oCatMore = $oCat;
02830     }
02831 
02837     public function getCatTreePath()
02838     {
02839         return $this->_sCatTreePath;
02840     }
02841 
02849     public function getContentByIdent( $sIdent )
02850     {
02851         if ( !isset( $this->_aContents[$sIdent] ) ) {
02852             $this->_aContents[$sIdent] = oxNew( 'oxcontent' );
02853             $this->_aContents[$sIdent]->loadByIdent( $sIdent );
02854         }
02855         return $this->_aContents[$sIdent];
02856     }
02857 
02863     public function getContentCategory()
02864     {
02865         return false;
02866     }
02867 
02873     public function getMustFillFields()
02874     {
02875         if ( $this->_aMustFillFields === null ) {
02876             $this->_aMustFillFields = false;
02877 
02878             // passing must-be-filled-fields info
02879             $aMustFillFields = $this->getConfig()->getConfigParam( 'aMustFillFields' );
02880             if ( is_array( $aMustFillFields ) ) {
02881                 $this->_aMustFillFields = array_flip( $aMustFillFields );
02882             }
02883         }
02884         return $this->_aMustFillFields;
02885     }
02886 
02894     public function isFieldRequired( $sField )
02895     {
02896         if ( $aMustFillFields = $this->getMustFillFields() ) {
02897             if ( isset( $aMustFillFields[$sField] ) ) {
02898                 return true;
02899             }
02900         }
02901 
02902         return false;
02903     }
02904 
02910     public function getFormId()
02911     {
02912         if ( $this->_sFormId === null ) {
02913             $this->_sFormId = oxUtilsObject::getInstance()->generateUId();
02914             oxSession::setVar( 'sessionuformid', $this->_sFormId );
02915         }
02916 
02917         return $this->_sFormId;
02918     }
02919 
02925     public function canAcceptFormData()
02926     {
02927         if ( $this->_blCanAcceptFormData === null ) {
02928             $this->_blCanAcceptFormData = false;
02929 
02930             $sFormId = oxConfig::getParameter( "uformid" );
02931             $sSessionFormId = oxSession::getVar( "sessionuformid" );
02932 
02933             // testing if form and session ids matches
02934             if ( $sFormId && $sFormId === $sSessionFormId ) {
02935                 $this->_blCanAcceptFormData = true;
02936             }
02937 
02938             // regenerating form data
02939             $this->getFormId();
02940         }
02941         return $this->_blCanAcceptFormData;
02942     }
02943 
02949     public function getPromoFinishedList()
02950     {
02951         if (isset($this->_oPromoFinishedList)) {
02952             return $this->_oPromoFinishedList;
02953         }
02954         $this->_oPromoFinishedList = oxNew( 'oxActionList' );
02955         $this->_oPromoFinishedList->loadFinishedByCount(2);
02956         return $this->_oPromoFinishedList;
02957     }
02958 
02964     public function getPromoCurrentList()
02965     {
02966         if (isset($this->_oPromoCurrentList)) {
02967             return $this->_oPromoCurrentList;
02968         }
02969         $this->_oPromoCurrentList = oxNew( 'oxActionList' );
02970         $this->_oPromoCurrentList->loadCurrent();
02971         return $this->_oPromoCurrentList;
02972     }
02973 
02979     public function getPromoFutureList()
02980     {
02981         if (isset($this->_oPromoFutureList)) {
02982             return $this->_oPromoFutureList;
02983         }
02984         $this->_oPromoFutureList = oxNew( 'oxActionList' );
02985         $this->_oPromoFutureList->loadFutureByCount(2);
02986         return $this->_oPromoFutureList;
02987     }
02988 
02994     public function getShowPromotionList()
02995     {
02996         if (isset($this->_blShowPromotions)) {
02997             return $this->_blShowPromotions;
02998         }
02999         $this->_blShowPromotions = false;
03000         if (oxNew('oxActionList')->areAnyActivePromotions()) {
03001             $this->_blShowPromotions = ( count( $this->getPromoFinishedList() ) + count( $this->getPromoCurrentList() ) + count( $this->getPromoFutureList() ) ) > 0;
03002         }
03003         return $this->_blShowPromotions;
03004     }
03005 
03011     public function isEnabledPrivateSales()
03012     {
03013         if ( $this->_blEnabledPrivateSales === null ) {
03014             $this->_blEnabledPrivateSales = (bool) $this->getConfig()->getConfigParam( 'blPsLoginEnabled' );
03015             if ( $this->_blEnabledPrivateSales && ( $blCanPreview = oxUtils::getInstance()->canPreview() ) !== null ) {
03016                 $this->_blEnabledPrivateSales = !$blCanPreview;
03017             }
03018         }
03019         return $this->_blEnabledPrivateSales;
03020     }
03021 
03027     public function getTagCloudManager()
03028     {
03029         if ( $this->_blShowTagCloud ) {
03030             return oxNew( "oxTagCloud" );
03031         } else {
03032             return false;
03033         }
03034     }
03035 
03041     public function getFieldValidationErrors()
03042     {
03043         return oxInputValidator::getInstance()->getFieldValidationErrors();
03044     }
03045 
03051     public function getBreadCrumb()
03052     {
03053         return null;
03054     }
03055 
03063     public function setRootCatChanged( $blRootCatChanged )
03064     {
03065         $this->_blRootCatChanged = $blRootCatChanged;
03066     }
03067 
03073     public function isRootCatChanged()
03074     {
03075         return $this->_blRootCatChanged;
03076     }
03077 
03083     public function getInvoiceAddress()
03084     {
03085         if ( $this->_aInvoiceAddress == null ) {
03086             $aAddress = oxConfig::getParameter( 'invadr');
03087             if ( $aAddress ) {
03088                 $this->_aInvoiceAddress = $aAddress;
03089             }
03090         }
03091         return $this->_aInvoiceAddress;
03092     }
03093 
03099     public function getDeliveryAddress()
03100     {
03101         if ( $this->_aDeliveryAddress == null ) {
03102             $aAddress = oxConfig::getParameter( 'deladr');
03103             if ( $aAddress ) {
03104                 $this->_aDeliveryAddress = $aAddress;
03105             }
03106         }
03107         return $this->_aDeliveryAddress;
03108     }
03109 
03117     public function setInvoiceAddress( $aAddress )
03118     {
03119         $this->_aInvoiceAddress = $aAddress;
03120     }
03121 
03127     public function getActiveUsername()
03128     {
03129         if ( $this->_sActiveUsername == null ) {
03130             $this->_sActiveUsername = false;
03131             $sUsername = oxConfig::getParameter( 'lgn_usr' );
03132             if ( $sUsername ) {
03133                 $this->_sActiveUsername = $sUsername;
03134             } elseif ( $oUser = $this->getUser() ) {
03135                 $this->_sActiveUsername = $oUser->oxuser__oxusername->value;
03136             }
03137         }
03138         return $this->_sActiveUsername;
03139     }
03140 
03146     public function getWishlistUserId()
03147     {
03148         return oxConfig::getParameter( 'wishid' );
03149     }
03150 
03156     public function getSearchCatId()
03157     {
03158     }
03159 
03165     public function getSearchVendor()
03166     {
03167     }
03168 
03174     public function getSearchManufacturer()
03175     {
03176     }
03177 
03183     public function getLastProducts()
03184     {
03185 
03186     }
03187 
03193     public function getNewBasketItemMsgType()
03194     {
03195         return (int) $this->getConfig()->getConfigParam( "iNewBasketItemMessage" );
03196     }
03197 
03203     public function showTags()
03204     {
03205         return (bool) $this->getConfig()->getConfigParam( "blShowTags" );
03206     }
03207 
03215     public function isActive( $sName )
03216     {
03217         return $this->getConfig()->getConfigParam( "bl".$sName."Enabled" );
03218     }
03219 
03225     public function isFbWidgetWisible()
03226     {
03227         if ( $this->_blFbWidgetsOn === null ) {
03228             $oUtils = oxUtilsServer::getInstance();
03229 
03230             // reading ..
03231             $this->_blFbWidgetsOn = (bool) $oUtils->getOxCookie( "fbwidgetson" );
03232 
03233             // .. and setting back
03234             $oUtils->setOxCookie( "fbwidgetson", $this->_blFbWidgetsOn ? 1 : 0 );
03235         }
03236         return $this->_blFbWidgetsOn;
03237     }
03238 }