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 
00174      protected $_aContents = array();
00175 
00184     protected function _processRequest()
00185     {
00186         $myUtils = oxUtils::getInstance();
00187 
00188         // non admin, request is not empty and was not processed by seo engine
00189         if ( $myUtils->seoIsActive() && !$this->isAdmin() && !isSearchEngineUrl() && ( $sStdUrl = getRequestUrl( '', true ) ) ) {
00190 
00191             // fetching standard url and looking for it in seo table
00192             if ( $this->_canRedirect() && ( $sRedirectUrl = oxNew('oxSeoDecoder')->fetchSeoUrl( $sStdUrl ) ) ) {
00193                 $myUtils->redirect( $this->getConfig()->getShopURL() . $sRedirectUrl, false );
00194             } else {
00195                 // emitting not found header + continuing output
00196                 @header( "HTTP/1.0 404 Not Found" );
00197 
00198                 $sShopId = $this->getConfig()->getShopId();
00199                 $sLangId = oxLang::getInstance()->getBaseLanguage();
00200                 $sIdent  = md5( strtolower( $sStdUrl ) . $sShopId . $sLangId );
00201 
00202                 // logging "not found" url
00203                 $oDb = oxDb::getDb();
00204                 $oDb->execute( "replace oxseologs ( oxstdurl, oxident, oxshopid, oxlang )
00205                                 values ( " . $oDb->quote( $sStdUrl ) . ", '{$sIdent}', '{$sShopId}', '{$sLangId}' ) " );
00206             }
00207         }
00208 
00209     }
00210 
00217     public function init()
00218     {
00219         $this->_processRequest();
00220 
00221         if ( oxConfig::getParameter( '_force_no_basket_cmp' ) ) {
00222             unset( $this->_aComponentNames['oxcmp_basket'] );
00223         }
00224 
00225         // as the objects are cached by dispatcher we have to watch out, that we don't add these components twice
00226         if ( !$this->_blCommonAdded ) {
00227             $this->_aComponentNames = array_merge( $this->_aComponentNames, $this->_aUserComponentNames );
00228             $this->_blCommonAdded = true;
00229         }
00230 
00231         // setting list type if needed
00232         $this->_setListType();
00233 
00234         parent::init();
00235     }
00236 
00242     protected function _setListType()
00243     {
00244         if ( !oxConfig::getParameter( 'listtype' ) && isset( $this->_sListType ) ) {
00245             oxConfig::getInstance()->setGlobalParameter( 'listtype', $this->_sListType );
00246         }
00247     }
00248 
00256     public function generatePageNavigationUrl()
00257     {
00258 //        $sClass = $this->_sThisAction;
00259         return $this->getConfig()->getShopHomeURL().$this->_getRequestParams( false );
00260     }
00261 
00271     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null )
00272     {
00273         if ( $iPage >= 0 ) {
00274             $sUrl .= ( ( strpos( $sUrl, '?' ) === false ) ? '?' : '&amp;' ) . 'pgNr='.$iPage;
00275         }
00276         return $sUrl;
00277     }
00278 
00284     public function generatePageNavigation( )
00285     {
00286 
00287         startProfile('generatePageNavigation');
00288         // generate the page navigation
00289         $pageNavigation = new stdClass();
00290         $pageNavigation->NrOfPages = $this->_iCntPages;
00291         $pageNavigation->iArtCnt   = $this->_iAllArtCnt;
00292         $iActPage = $this->getActPage();
00293         $pageNavigation->actPage   = $iActPage + 1;
00294 
00295         $sUrl = $this->generatePageNavigationUrl( );
00296 
00297         if ( $iActPage > 0) {
00298             $pageNavigation->previousPage = $this->_addPageNrParam( $sUrl, $iActPage - 1 );
00299         }
00300 
00301         if ( $iActPage < $pageNavigation->NrOfPages - 1 ) {
00302             $pageNavigation->nextPage = $this->_addPageNrParam( $sUrl, $iActPage + 1 );
00303         }
00304 
00305         if ( $pageNavigation->NrOfPages > 1 ) {
00306             for ( $i=1; $i < $pageNavigation->NrOfPages + 1; $i++ ) {
00307                 $page = new Oxstdclass();
00308                 $page->url = $this->_addPageNrParam( $sUrl, $i - 1 );
00309                 $page->selected = 0;
00310                 if ( $i == $pageNavigation->actPage ) {
00311                     $page->selected = 1;
00312                 }
00313                 $pageNavigation->changePage[$i] = $page;
00314             }
00315 
00316             // first/last one
00317             $pageNavigation->firstpage = $this->_addPageNrParam( $sUrl, 0 );
00318             $pageNavigation->lastpage  = $this->_addPageNrParam( $sUrl, $pageNavigation->NrOfPages - 1 );
00319         }
00320 
00321         stopProfile('generatePageNavigation');
00322 
00323         return $pageNavigation;
00324     }
00325 
00331     public function prepareMinimumOrderPrice4View()
00332     {
00333         $myConfig = $this->getConfig();
00334         $iMinOrderPrice = $myConfig->getConfigParam( 'iMinOrderPrice' );
00335         if ( isset( $iMinOrderPrice ) && $iMinOrderPrice) {
00336             $oBasket = $this->getSession()->getBasket();
00337             if ( !$oBasket || ( $oBasket && !$oBasket->getProductsCount() ) ) {
00338                 return;
00339             }
00340             $oCur    = $myConfig->getActShopCurrencyObject();
00341             $dMinOrderPrice = $iMinOrderPrice * $oCur->rate;
00342             // Coupons and discounts should be considered in "Min order price" check
00343             if ( $dMinOrderPrice > ( $oBasket->getDiscountProductsPrice()->getBruttoSum() - $oBasket->getTotalDiscount()->getBruttoPrice() - $oBasket->getVoucherDiscount()->getBruttoPrice()) ) {
00344                 $this->_iLowOrderPrice = 1;
00345                 $this->_sMinOrderPrice = oxLang::getInstance()->formatCurrency( $dMinOrderPrice, $oCur );
00346             }
00347         }
00348     }
00349 
00356     public function render()
00357     {
00358         parent::render();
00359 
00360         if ( $this->getIsOrderStep() ) {
00361 
00362             // min. order price check
00363             $this->prepareMinimumOrderPrice4View();
00364 
00365             // disabling navigation during order ...
00366             if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) ) {
00367                 $this->_iNewsRealStatus = 1;
00368                 $this->setShowNewsletter(0);
00369                 // for old tpl. will be removed later
00370                 $this->_aViewData['isnewsletter'] = 0;
00371                 $this->setShowRightBasket(0);
00372                 $this->setShowLeftBasket(0);
00373                 $this->setShowTopBasket(0);
00374             }
00375         }
00376         // show baskets
00377         $this->_aViewData['bl_perfShowLeftBasket']  = $this->showLeftBasket();
00378         $this->_aViewData['bl_perfShowRightBasket'] = $this->showRightBasket();
00379         $this->_aViewData['bl_perfShowTopBasket']   = $this->showTopBasket();
00380 
00381         $this->_aViewData['loworderprice']      = $this->isLowOrderPrice();
00382         $this->_aViewData['minorderprice']      = $this->getMinOrderPrice();
00383         $this->_aViewData['isnewsletter_truth'] = $this->getNewsRealStatus();
00384 
00385         $this->_aViewData['noindex'] = $this->noIndex();
00386     }
00387 
00393     public function getViewProduct()
00394     {
00395         if ( $this->_oProduct ) {
00396             return $this->_oProduct;
00397         }
00398     }
00399 
00407     public function setViewProduct( $oProduct )
00408     {
00409         $this->_oProduct = $oProduct;
00410     }
00411 
00417     public function getViewProductList()
00418     {
00419         return $this->_aArticleList;
00420     }
00421 
00427     public function getActPage()
00428     {
00429         if ( $this->_iActPage === null ) {
00430             $this->_iActPage = ( int ) oxConfig::getParameter( 'pgNr' );
00431             $this->_iActPage = ( $this->_iActPage < 0 ) ? 0 : $this->_iActPage;
00432         }
00433         return $this->_iActPage;
00434     }
00435 
00443     public function getActCategory()
00444     {
00445         // if active category is not set yet - trying to load it from request params
00446         // this may be usefull when category component was unable to load active category
00447         // and we still need some object to mount navigation info
00448         if ( $this->_oClickCat === null ) {
00449 
00450             $this->_oClickCat = false;
00451             $oCategory = oxNew( 'oxcategory' );
00452             if ( $oCategory->load( $this->getCategoryId() ) ) {
00453                 $this->_oClickCat = $oCategory;
00454             }
00455         }
00456 
00457         return $this->_oClickCat;
00458     }
00459 
00467     public function setActCategory( $oCategory )
00468     {
00469         $this->_oClickCat = $oCategory;
00470     }
00471 
00479     public function getActTag()
00480     {
00481         if ( $this->_oActTag === null ) {
00482             $this->_oActTag = new Oxstdclass();
00483             $this->_oActTag->sTag = oxConfig::getParameter("searchtag", 1);
00484 
00485             $sUrl = $this->getConfig()->getShopHomeURL();
00486             $this->_oActTag->link = "{$sUrl}cl=tag";
00487         }
00488         return $this->_oActTag;
00489     }
00490 
00498     public function getActVendor()
00499     {
00500         // if active vendor is not set yet - trying to load it from request params
00501         // this may be usefull when category component was unable to load active vendor
00502         // and we still need some object to mount navigation info
00503         if ( $this->_oActVendor === null ) {
00504 
00505             $this->_oActVendor = false;
00506             $sVendorId = oxConfig::getParameter( 'cnid' );
00507             $sVendorId = $sVendorId ? str_replace( 'v_', '', $sVendorId ) : $sVendorId;
00508 
00509             $oVendor = oxNew( 'oxvendor' );
00510 
00511             if ( 'root' == $sVendorId ) {
00512                 $oVendor->setId( $sVendorId );
00513                 $oVendor->oxvendor__oxtitle     = new oxField( oxLang::getInstance()->translateString( 'byBrand' ) );
00514                 $oVendor->oxcategories__oxtitle = clone( $oVendor->oxvendor__oxtitle );
00515                 $this->_oActVendor = $oVendor;
00516             } elseif ( $oVendor->load( $sVendorId ) ) {
00517                 $this->_oActVendor = $oVendor;
00518             }
00519         }
00520 
00521         return $this->_oActVendor;
00522     }
00523 
00531     public function setActVendor( $oVendor )
00532     {
00533         $this->_oActVendor = $oVendor;
00534     }
00535 
00541     public function getActSearch()
00542     {
00543         if ( $this->_oActSearch === null ) {
00544             $this->_oActSearch = new oxStdClass();
00545             $sUrl = $this->getConfig()->getShopHomeURL();
00546             $this->_oActSearch->link = "{$sUrl}cl=search";
00547         }
00548         return $this->_oActSearch;
00549     }
00550 
00556     public function getActRecommList()
00557     {
00558         if ( $this->_oActRecomm === null ) {
00559             $this->_oActVendor = false;
00560             $sRecommId = oxConfig::getParameter( 'recommid' );
00561 
00562             $oRecommList = oxNew( 'oxrecommlist' );
00563 
00564             if ( $oRecommList->load( $sRecommId ) ) {
00565                 $this->_oActRecomm = $oRecommList;
00566             }
00567         }
00568         return $this->_oActRecomm;
00569     }
00570 
00576     public function getCategoryTree()
00577     {
00578         return $this->_oCategoryTree;
00579     }
00580 
00588     public function setCategoryTree( $oCatTree )
00589     {
00590         $this->_oCategoryTree = $oCatTree;
00591     }
00592 
00598     public function getVendorTree()
00599     {
00600         return $this->_oVendorTree;
00601     }
00602 
00610     public function setVendorTree( $oVendorTree )
00611     {
00612         $this->_oVendorTree = $oVendorTree;
00613     }
00614 
00624     protected function _loadActions()
00625     {
00626         $this->_aViewData['articlebargainlist'] = $this->getBargainArticleList();
00627         $this->_aViewData['aTop5Articles']      = $this->getTop5ArticleList();
00628     }
00629 
00638     public function setSessionCategoryId( $sCategoryId )
00639     {
00640         oxSession::setVar( 'cnid', $sCategoryId );
00641     }
00642 
00648     public function getSessionCategoryId()
00649     {
00650         return oxSession::getVar( 'cnid' );
00651     }
00652 
00658     protected function _processListArticles()
00659     {
00660         $sAddParams = $this->getAddUrlParams();
00661         if ( $sAddParams && $this->_aArticleList ) {
00662             foreach ( $this->_aArticleList as $oArticle ) {
00663                 $oArticle->appendLink( $sAddParams );
00664             }
00665         }
00666     }
00667 
00673     public function getAddUrlParams()
00674     {
00675     }
00676 
00684     public function getLink($iLang = null)
00685     {
00686         $sLink = parent::getLink($iLang);
00687         if ($iPg = $this->getActPage()) {
00688             $sLink = $this->_addPageNrParam( $sLink, $iPg, $iLang );
00689         }
00690         return $sLink;
00691     }
00692 
00698     public function getTop5ArticleList()
00699     {
00700         if ( $this->_aTop5ArticleList === null ) {
00701             $this->_aTop5ArticleList = false;
00702             $myConfig = $this->getConfig();
00703             if ( $myConfig->getConfigParam( 'bl_perfLoadAktion' ) ) {
00704                 // top 5 articles
00705                 $oArtList = oxNew( 'oxarticlelist' );
00706                 $oArtList->loadTop5Articles();
00707                 if ( $oArtList->count() ) {
00708                     $this->_aTop5ArticleList = $oArtList;
00709                 }
00710             }
00711         }
00712         return $this->_aTop5ArticleList;
00713     }
00714 
00720     public function getBargainArticleList()
00721     {
00722         if ( $this->_aBargainArticleList === null ) {
00723             $this->_aBargainArticleList = array();
00724             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadAktion' ) ) {
00725                 $oArtList = oxNew( 'oxarticlelist' );
00726                 $oArtList->loadAktionArticles( 'OXBARGAIN' );
00727                 if ( $oArtList->count() ) {
00728                     $this->_aBargainArticleList = $oArtList;
00729                 }
00730             }
00731         }
00732         return $this->_aBargainArticleList;
00733     }
00734 
00740     public function isLowOrderPrice()
00741     {
00742         return $this->_iLowOrderPrice;
00743     }
00744 
00750     public function getMinOrderPrice()
00751     {
00752         return $this->_sMinOrderPrice;
00753     }
00754 
00760     public function getNewsRealStatus()
00761     {
00762         return $this->_iNewsRealStatus;
00763     }
00764 
00770     protected function _canRedirect()
00771     {
00772         foreach ( $this->_aBlockRedirectParams as $sParam ) {
00773             if ( oxConfig::getParameter( $sParam ) !== null ) {
00774                 return false;
00775             }
00776         }
00777 
00778         return true;
00779     }
00780 
00786     public function getProduct()
00787     {
00788     }
00789 
00795     public function getVendorlist()
00796     {
00797         return $this->_aVendorlist;
00798     }
00799 
00807     public function setVendorlist( $aList )
00808     {
00809         $this->_aVendorlist = $aList;
00810     }
00811 
00819     public function setRootVendor( $oVendor )
00820     {
00821         $this->_oRootVendor = $oVendor;
00822     }
00823 
00829     public function getRootVendor()
00830     {
00831         return $this->_oRootVendor;
00832     }
00833 
00839     public function getVendorId()
00840     {
00841         if ( $this->_sVendorId === null ) {
00842             if ( ( $oVendor = $this->getActVendor() ) ) {
00843                 $this->_sVendorId = $oVendor->getId();
00844             }
00845         }
00846         return $this->_sVendorId;
00847     }
00848 
00854     public function getSearchCatTree()
00855     {
00856         return $this->_aSearchCatTree;
00857     }
00858 
00866     public function setSearchCatTree( $aTree )
00867     {
00868         $this->_aSearchCatTree = $aTree;
00869     }
00870 
00876     public function getCatMore()
00877     {
00878         return $this->_oCatMore;
00879     }
00880 
00888     public function setCatMore( $oCat )
00889     {
00890         $this->_oCatMore = $oCat;
00891     }
00892 
00898     public function isNewsSubscribed()
00899     {
00900         return $this->_blNewsSubscribed;
00901     }
00902 
00910     public function setNewsSubscribed( $blNewsSubscribed )
00911     {
00912         $this->_blNewsSubscribed = $blNewsSubscribed;
00913     }
00914 
00920     public function showShipAddress()
00921     {
00922         return $this->_blShowShipAddress;
00923     }
00924 
00932     public function setShowShipAddress( $blShowShipAddress )
00933     {
00934         $this->_blShowShipAddress = $blShowShipAddress;
00935     }
00936 
00942     public function getDelAddress()
00943     {
00944         return $this->_oDelAddress;
00945     }
00946 
00954     public function setDelAddress( $oDelAddress )
00955     {
00956         $this->_oDelAddress = $oDelAddress;
00957     }
00958 
00964     public function getCatTreePath()
00965     {
00966         return $this->_sCatTreePath;
00967     }
00968 
00976     public function getContentByIdent( $sIdent )
00977     {
00978         if ( !isset( $this->_aContents[$sIdent] ) ) {
00979             $this->_aContents[$sIdent] = oxNew( 'oxcontent' );
00980             $this->_aContents[$sIdent]->loadByIdent( $sIdent );
00981         }
00982         return $this->_aContents[$sIdent];
00983     }
00984 
00990     public function getContentCategory()
00991     {
00992         return false;
00993     }
00994 }

Generated on Thu Feb 19 15:02:22 2009 for OXID eShop CE by  doxygen 1.5.5