oxubase.php

Go to the documentation of this file.
00001 <?php
00002 
00006 require_once getShopBasePath() . 'views/oxview.php' ;
00007 
00013 class oxUBase extends oxView
00014 {
00021     protected $_blCommonAdded = false;
00022 
00028     protected $_aComponentNames = array(
00029                                     'oxcmp_user'       => 1, // 0 means dont init if cached
00030                                     'oxcmp_lang'       => 1,
00031                                     'oxcmp_cur'        => 1,
00032                                     'oxcmp_shop'       => 1,
00033                                     'oxcmp_categories' => 0,
00034                                     'oxcmp_utils'      => 1,
00035                                     'oxcmp_news'       => 0,
00036                                     'oxcmp_basket'     => 1
00037                                   );
00038 
00044     protected $_aUserComponentNames = array();
00045 
00051     protected $_oProduct = null;
00052 
00057     protected $_iActPage = null;
00058 
00063     protected $_aArticleList = null;
00064 
00069     protected $_oVendorTree  = null;
00070 
00075     protected $_oCategoryTree  = null;
00076 
00081     protected $_aTop5ArticleList  = null;
00082 
00087     protected $_aBargainArticleList  = null;
00088 
00093     protected $_iLowOrderPrice  = null;
00094 
00099     protected $_sMinOrderPrice  = null;
00100 
00105     protected $_iNewsRealStatus  = null;
00106 
00114     protected $_aBlockRedirectParams = array( 'fnc' );
00115 
00120     protected $_aVendorlist = null;
00121 
00126     protected $_oRootVendor = null;
00127 
00132     protected $_sVendorId = null;
00133 
00138     protected $_aSearchCatTree = null;
00139 
00144     protected $_oCatMore = null;
00145 
00150     protected $_blNewsSubscribed = null;
00151 
00156     protected $_blShowShipAddress = null;
00157 
00162     protected $_oDelAddress = null;
00163 
00168     protected $_sCatTreePath = null;
00169 
00178     protected function _processRequest()
00179     {
00180         $myUtils = oxUtils::getInstance();
00181 
00182         // non admin, request is not empty and was not processed by seo engine
00183         if ( $myUtils->seoIsActive() && !$this->isAdmin() && !isSearchEngineUrl() && ( $sStdUrl = getRequestUrl( '', true ) ) ) {
00184 
00185             // fetching standard url and looking for it in seo table
00186             if ( $this->_canRedirect() && ( $sRedirectUrl = oxNew('oxSeoDecoder')->fetchSeoUrl( $sStdUrl ) ) ) {
00187                 $myUtils->redirect( $this->getConfig()->getShopURL() . $sRedirectUrl, false );
00188             } else {
00189                 // emitting not found header + continuing output
00190                 @header( "HTTP/1.0 404 Not Found" );
00191 
00192                 $sShopId = $this->getConfig()->getShopId();
00193                 $sLangId = oxLang::getInstance()->getBaseLanguage();
00194                 $sIdent  = md5( strtolower( $sStdUrl ) . $sShopId . $sLangId );
00195 
00196                 // logging "not found" url
00197                 $oDb = oxDb::getDb();
00198                 $oDb->execute( "replace oxseologs ( oxstdurl, oxident, oxshopid, oxlang )
00199                                 values ( " . $oDb->quote( $sStdUrl ) . ", '{$sIdent}', '{$sShopId}', '{$sLangId}' ) " );
00200             }
00201         }
00202 
00203     }
00204 
00211     public function init()
00212     {
00213         $this->_processRequest();
00214 
00215         if ( oxConfig::getParameter( '_force_no_basket_cmp' ) ) {
00216             unset( $this->_aComponentNames['oxcmp_basket'] );
00217         }
00218 
00219         // as the objects are cached by dispatcher we have to watch out, that we don't add these components twice
00220         if ( !$this->_blCommonAdded ) {
00221             $this->_aComponentNames = array_merge( $this->_aComponentNames, $this->_aUserComponentNames );
00222             $this->_blCommonAdded = true;
00223         }
00224 
00225         // setting list type if needed
00226         $this->_setListType();
00227 
00228         parent::init();
00229     }
00230 
00236     protected function _setListType()
00237     {
00238         if ( !oxConfig::getParameter( 'listtype' ) && isset( $this->_sListType ) ) {
00239             oxConfig::getInstance()->setGlobalParameter( 'listtype', $this->_sListType );
00240         }
00241     }
00242 
00250     public function generatePageNavigationUrl()
00251     {
00252 //        $sClass = $this->_sThisAction;
00253         return $this->getConfig()->getShopHomeURL().$this->_getRequestParams( false );
00254     }
00255 
00265     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null )
00266     {
00267         if ( $iPage >= 0 ) {
00268             $sUrl .= ( ( strpos( $sUrl, '?' ) === false ) ? '?' : '&amp;' ) . 'pgNr='.$iPage;
00269         }
00270         return $sUrl;
00271     }
00272 
00278     public function generatePageNavigation( )
00279     {
00280 
00281         startProfile('generatePageNavigation');
00282         // generate the page navigation
00283         $pageNavigation = new stdClass();
00284         $pageNavigation->NrOfPages = $this->_iCntPages;
00285         $pageNavigation->iArtCnt   = $this->_iAllArtCnt;
00286         $iActPage = $this->getActPage();
00287         $pageNavigation->actPage   = $iActPage + 1;
00288 
00289         $sUrl = $this->generatePageNavigationUrl( );
00290 
00291         if ( $iActPage > 0) {
00292             $pageNavigation->previousPage = $this->_addPageNrParam( $sUrl, $iActPage - 1 );
00293         }
00294 
00295         if ( $iActPage < $pageNavigation->NrOfPages - 1 ) {
00296             $pageNavigation->nextPage = $this->_addPageNrParam( $sUrl, $iActPage + 1 );
00297         }
00298 
00299         if ( $pageNavigation->NrOfPages > 1 ) {
00300             for ( $i=1; $i < $pageNavigation->NrOfPages + 1; $i++ ) {
00301                 $page = new Oxstdclass();
00302                 $page->url = $this->_addPageNrParam( $sUrl, $i - 1 );
00303                 $page->selected = 0;
00304                 if ( $i == $pageNavigation->actPage ) {
00305                     $page->selected = 1;
00306                 }
00307                 $pageNavigation->changePage[$i] = $page;
00308             }
00309 
00310             // first/last one
00311             $pageNavigation->firstpage = $this->_addPageNrParam( $sUrl, 0 );
00312             $pageNavigation->lastpage  = $this->_addPageNrParam( $sUrl, $pageNavigation->NrOfPages - 1 );
00313         }
00314 
00315         stopProfile('generatePageNavigation');
00316 
00317         return $pageNavigation;
00318     }
00319 
00325     public function prepareMinimumOrderPrice4View()
00326     {
00327         $myConfig = $this->getConfig();
00328         $iMinOrderPrice = $myConfig->getConfigParam( 'iMinOrderPrice' );
00329         if ( isset( $iMinOrderPrice ) && $iMinOrderPrice) {
00330             $oBasket = $this->getSession()->getBasket();
00331             if ( !$oBasket || ( $oBasket && !$oBasket->getProductsCount() ) ) {
00332                 return;
00333             }
00334             $oCur    = $myConfig->getActShopCurrencyObject();
00335             $dMinOrderPrice = $iMinOrderPrice * $oCur->rate;
00336             // Coupons and discounts should be considered in "Min order price" check
00337             if ( $dMinOrderPrice > ( $oBasket->getDiscountProductsPrice()->getBruttoSum() - $oBasket->getTotalDiscount()->getBruttoPrice() - $oBasket->getVoucherDiscount()->getBruttoPrice()) ) {
00338                 $this->_iLowOrderPrice = 1;
00339                 $this->_sMinOrderPrice = oxLang::getInstance()->formatCurrency( $dMinOrderPrice, $oCur );
00340             }
00341         }
00342     }
00343 
00350     public function render()
00351     {
00352         parent::render();
00353 
00354         if ( $this->getIsOrderStep() ) {
00355 
00356             // min. order price check
00357             $this->prepareMinimumOrderPrice4View();
00358 
00359             // disabling navigation during order ...
00360             if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) ) {
00361                 $this->_iNewsRealStatus = 1;
00362                 $this->setShowNewsletter(0);
00363                 // for old tpl. will be removed later
00364                 $this->_aViewData['isnewsletter'] = 0;
00365                 $this->setShowRightBasket(0);
00366                 $this->setShowLeftBasket(0);
00367                 $this->setShowTopBasket(0);
00368             }
00369         }
00370         // show baskets
00371         $this->_aViewData['bl_perfShowLeftBasket']  = $this->showLeftBasket();
00372         $this->_aViewData['bl_perfShowRightBasket'] = $this->showRightBasket();
00373         $this->_aViewData['bl_perfShowTopBasket']   = $this->showTopBasket();
00374 
00375         $this->_aViewData['loworderprice']      = $this->isLowOrderPrice();
00376         $this->_aViewData['minorderprice']      = $this->getMinOrderPrice();
00377         $this->_aViewData['isnewsletter_truth'] = $this->getNewsRealStatus();
00378 
00379         $this->_aViewData['noindex'] = $this->noIndex();
00380     }
00381 
00387     public function getViewProduct()
00388     {
00389         if ( $this->_oProduct ) {
00390             return $this->_oProduct;
00391         }
00392     }
00393 
00401     public function setViewProduct( $oProduct )
00402     {
00403         $this->_oProduct = $oProduct;
00404     }
00405 
00411     public function getViewProductList()
00412     {
00413         return $this->_aArticleList;
00414     }
00415 
00421     public function getActPage()
00422     {
00423         if ( $this->_iActPage === null ) {
00424             $this->_iActPage = ( int ) oxConfig::getParameter( 'pgNr' );
00425             $this->_iActPage = ( $this->_iActPage < 0 ) ? 0 : $this->_iActPage;
00426         }
00427         return $this->_iActPage;
00428     }
00429 
00437     public function getActCategory()
00438     {
00439         // if active category is not set yet - trying to load it from request params
00440         // this may be usefull when category component was unable to load active category
00441         // and we still need some object to mount navigation info
00442         if ( $this->_oClickCat === null ) {
00443 
00444             $this->_oClickCat = false;
00445             $oCategory = oxNew( 'oxcategory' );
00446             if ( $oCategory->load( $this->getCategoryId() ) ) {
00447                 $this->_oClickCat = $oCategory;
00448             }
00449         }
00450 
00451         return $this->_oClickCat;
00452     }
00453 
00461     public function setActCategory( $oCategory )
00462     {
00463         $this->_oClickCat = $oCategory;
00464     }
00465 
00473     public function getActTag()
00474     {
00475         if ( $this->_oActTag === null ) {
00476             $this->_oActTag = new Oxstdclass();
00477             $this->_oActTag->sTag = oxConfig::getParameter("searchtag", 1);
00478 
00479             $sUrl = $this->getConfig()->getShopHomeURL();
00480             $this->_oActTag->link = "{$sUrl}cl=tag";
00481         }
00482         return $this->_oActTag;
00483     }
00484 
00492     public function getActVendor()
00493     {
00494         // if active vendor is not set yet - trying to load it from request params
00495         // this may be usefull when category component was unable to load active vendor
00496         // and we still need some object to mount navigation info
00497         if ( $this->_oActVendor === null ) {
00498 
00499             $this->_oActVendor = false;
00500             $sVendorId = oxConfig::getParameter( 'cnid' );
00501             $sVendorId = $sVendorId ? str_replace( 'v_', '', $sVendorId ) : $sVendorId;
00502 
00503             $oVendor = oxNew( 'oxvendor' );
00504 
00505             if ( 'root' == $sVendorId ) {
00506                 $oVendor->setId( $sVendorId );
00507                 $oVendor->oxvendor__oxtitle     = new oxField( oxLang::getInstance()->translateString( 'byBrand' ) );
00508                 $oVendor->oxcategories__oxtitle = clone( $oVendor->oxvendor__oxtitle );
00509                 $this->_oActVendor = $oVendor;
00510             } elseif ( $oVendor->load( $sVendorId ) ) {
00511                 $this->_oActVendor = $oVendor;
00512             }
00513         }
00514 
00515         return $this->_oActVendor;
00516     }
00517 
00525     public function setActVendor( $oVendor )
00526     {
00527         $this->_oActVendor = $oVendor;
00528     }
00529 
00535     public function getActSearch()
00536     {
00537         if ( $this->_oActSearch === null ) {
00538             $this->_oActSearch = new oxStdClass();
00539             $sUrl = $this->getConfig()->getShopHomeURL();
00540             $this->_oActSearch->link = "{$sUrl}cl=search";
00541         }
00542         return $this->_oActSearch;
00543     }
00544 
00550     public function getActRecommList()
00551     {
00552         if ( $this->_oActRecomm === null ) {
00553             $this->_oActVendor = false;
00554             $sRecommId = oxConfig::getParameter( 'recommid' );
00555 
00556             $oRecommList = oxNew( 'oxrecommlist' );
00557 
00558             if ( $oRecommList->load( $sRecommId ) ) {
00559                 $this->_oActRecomm = $oRecommList;
00560             }
00561         }
00562         return $this->_oActRecomm;
00563     }
00564 
00570     public function getCategoryTree()
00571     {
00572         return $this->_oCategoryTree;
00573     }
00574 
00582     public function setCategoryTree( $oCatTree )
00583     {
00584         $this->_oCategoryTree = $oCatTree;
00585     }
00586 
00592     public function getVendorTree()
00593     {
00594         return $this->_oVendorTree;
00595     }
00596 
00604     public function setVendorTree( $oVendorTree )
00605     {
00606         $this->_oVendorTree = $oVendorTree;
00607     }
00608 
00618     protected function _loadActions()
00619     {
00620         $this->_aViewData['articlebargainlist'] = $this->getBargainArticleList();
00621         $this->_aViewData['aTop5Articles']      = $this->getTop5ArticleList();
00622     }
00623 
00632     public function setSessionCategoryId( $sCategoryId )
00633     {
00634         oxSession::setVar( 'cnid', $sCategoryId );
00635     }
00636 
00642     public function getSessionCategoryId()
00643     {
00644         return oxSession::getVar( 'cnid' );
00645     }
00646 
00652     protected function _processListArticles()
00653     {
00654         $sAddParams = $this->getAddUrlParams();
00655         if ( $sAddParams && $this->_aArticleList ) {
00656             foreach ( $this->_aArticleList as $oArticle ) {
00657                 $oArticle->appendLink( $sAddParams );
00658             }
00659         }
00660     }
00661 
00667     public function getAddUrlParams()
00668     {
00669     }
00670 
00678     public function getLink($iLang = null)
00679     {
00680         $sLink = parent::getLink($iLang);
00681         if ($iPg = $this->getActPage()) {
00682             $sLink = $this->_addPageNrParam( $sLink, $iPg, $iLang );
00683         }
00684         return $sLink;
00685     }
00686 
00692     public function getTop5ArticleList()
00693     {
00694         if ( $this->_aTop5ArticleList === null ) {
00695             $this->_aTop5ArticleList = false;
00696             $myConfig = $this->getConfig();
00697             if ( $myConfig->getConfigParam( 'bl_perfLoadAktion' ) ) {
00698                 // top 5 articles
00699                 $oArtList = oxNew( 'oxarticlelist' );
00700                 $oArtList->loadTop5Articles();
00701                 if ( $oArtList->count() ) {
00702                     $this->_aTop5ArticleList = $oArtList;
00703                 }
00704             }
00705         }
00706         return $this->_aTop5ArticleList;
00707     }
00708 
00714     public function getBargainArticleList()
00715     {
00716         if ( $this->_aBargainArticleList === null ) {
00717             $this->_aBargainArticleList = array();
00718             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadAktion' ) ) {
00719                 $oArtList = oxNew( 'oxarticlelist' );
00720                 $oArtList->loadAktionArticles( 'OXBARGAIN' );
00721                 if ( $oArtList->count() ) {
00722                     $this->_aBargainArticleList = $oArtList;
00723                 }
00724             }
00725         }
00726         return $this->_aBargainArticleList;
00727     }
00728 
00734     public function isLowOrderPrice()
00735     {
00736         return $this->_iLowOrderPrice;
00737     }
00738 
00744     public function getMinOrderPrice()
00745     {
00746         return $this->_sMinOrderPrice;
00747     }
00748 
00754     public function getNewsRealStatus()
00755     {
00756         return $this->_iNewsRealStatus;
00757     }
00758 
00764     protected function _canRedirect()
00765     {
00766         foreach ( $this->_aBlockRedirectParams as $sParam ) {
00767             if ( oxConfig::getParameter( $sParam ) !== null ) {
00768                 return false;
00769             }
00770         }
00771 
00772         return true;
00773     }
00774 
00780     public function getProduct()
00781     {
00782     }
00783 
00789     public function getVendorlist()
00790     {
00791         return $this->_aVendorlist;
00792     }
00793 
00801     public function setVendorlist( $aList )
00802     {
00803         $this->_aVendorlist = $aList;
00804     }
00805 
00813     public function setRootVendor( $oVendor )
00814     {
00815         $this->_oRootVendor = $oVendor;
00816     }
00817 
00823     public function getRootVendor()
00824     {
00825         return $this->_oRootVendor;
00826     }
00827 
00833     public function getVendorId()
00834     {
00835         if ( $this->_sVendorId === null ) {
00836             if ( ( $oVendor = $this->getActVendor() ) ) {
00837                 $this->_sVendorId = $oVendor->getId();
00838             }
00839         }
00840         return $this->_sVendorId;
00841     }
00842 
00848     public function getSearchCatTree()
00849     {
00850         return $this->_aSearchCatTree;
00851     }
00852 
00860     public function setSearchCatTree( $aTree )
00861     {
00862         $this->_aSearchCatTree = $aTree;
00863     }
00864 
00870     public function getCatMore()
00871     {
00872         return $this->_oCatMore;
00873     }
00874 
00882     public function setCatMore( $oCat )
00883     {
00884         $this->_oCatMore = $oCat;
00885     }
00886 
00892     public function isNewsSubscribed()
00893     {
00894         return $this->_blNewsSubscribed;
00895     }
00896 
00904     public function setNewsSubscribed( $blNewsSubscribed )
00905     {
00906         $this->_blNewsSubscribed = $blNewsSubscribed;
00907     }
00908 
00914     public function showShipAddress()
00915     {
00916         return $this->_blShowShipAddress;
00917     }
00918 
00926     public function setShowShipAddress( $blShowShipAddress )
00927     {
00928         $this->_blShowShipAddress = $blShowShipAddress;
00929     }
00930 
00936     public function getDelAddress()
00937     {
00938         return $this->_oDelAddress;
00939     }
00940 
00948     public function setDelAddress( $oDelAddress )
00949     {
00950         $this->_oDelAddress = $oDelAddress;
00951     }
00952 
00958     public function getCatTreePath()
00959     {
00960         return $this->_sCatTreePath;
00961     }
00962 }

Generated on Thu Dec 4 12:04:57 2008 for OXID eShop CE by  doxygen 1.5.5