oxview.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxView extends oxSuperCfg
00008 {
00014     protected $_aViewData = array();
00015 
00021     protected $_sClassLocation = null;
00022 
00028     protected $_sThisAction = null;
00029 
00035     protected $_oParent = null;
00036 
00042     protected $_blIsComponent = false;
00043 
00049     protected $_sThisTemplate = null;
00050 
00056     protected $_sViewId = null;
00057 
00063     protected $_sClass = null;
00064 
00070     protected $_sFnc = null;
00071 
00077     protected static $_blExecuted = false;
00078 
00083     protected $_sTrustedShopId = null;
00084 
00089     protected $_sTSExcellenceId = null;
00090 
00095     protected $_sCharSet = null;
00096 
00101     protected $_sVersion = null;
00102 
00107     protected $_blDemoVersion = null;
00108 
00113     protected $_blDemoShop = null;
00114 
00119     protected $_iNewsStatus = null;
00120 
00125     protected $_sShopLogo = null;
00126 
00132     protected $_sCategoryId = null;
00133 
00138     protected $_oClickCat = null;
00139 
00145     protected $_blIsCallForCache = false;
00146 
00152     public function init()
00153     {
00154         // setting current view class name
00155         $this->_sThisAction = strtolower( get_class( $this ) );
00156 
00157         if ( !$this->_blIsComponent ) {
00158             // assume that cached components does not affect this method ...
00159             $this->addGlobalParams();
00160         }
00161     }
00162 
00170     public function setIsCallForCache( $blIsCallForCache = null )
00171     {
00172         $this->_blIsCallForCache = $blIsCallForCache;
00173     }
00174 
00180     public function getIsCallForCache()
00181     {
00182         return $this->_blIsCallForCache;
00183     }
00184 
00190     public function getViewId()
00191     {
00192     }
00193 
00199     public function render()
00200     {
00201         return $this->_sThisTemplate;
00202     }
00203 
00217     public function addGlobalParams( $oShop = null)
00218     {
00219         // by default we allways display newsletter bar
00220         $this->_iNewsStatus = 1;
00221 
00222         // assigning shop to view config ..
00223         $oViewConf = $this->getViewConfig();
00224         if ( $oShop ) {
00225             $oViewConf->setViewShop( $oShop, $this->_aViewData );
00226         }
00227 
00228         //sending all view to smarty
00229         $this->_aViewData['oView'] = $this;
00230         $this->_aViewData['oViewConf'] = $this->getViewConfig();
00231 
00232         return $oViewConf;
00233     }
00234 
00243     public function addTplParam( $sPara, $sValue )
00244     {
00245         $this->_aViewData[$sPara] = $sValue;
00246     }
00247 
00259     protected function _setAdditionalParams()
00260     {
00261         $this->getAdditionalParams();
00262     }
00263 
00269     public function getBelboonParam()
00270     {
00271         if ( $sBelboon = oxSession::getVar( 'belboon' ) ) {
00272             return $sBelboon;
00273         }
00274         if ( ( $sBelboon = oxConfig::getParameter( 'belboon' ) ) ) {
00275             oxSession::setVar( 'belboon', $sBelboon );
00276         }
00277 
00278         return $sBelboon;
00279     }
00280 
00286     public function getViewConfig()
00287     {
00288         if ( $this->_oViewConf === null ) {
00289             $this->_oViewConf = oxNew( 'oxViewConfig' );
00290         }
00291 
00292         return $this->_oViewConf;
00293     }
00294 
00300     public function getTemplateName()
00301     {
00302         return $this->_sThisTemplate;
00303     }
00304 
00312     public function setClassName( $sClassName )
00313     {
00314         $this->_sClass = $sClassName;
00315     }
00316 
00322     public function getClassName()
00323     {
00324         return $this->_sClass;
00325     }
00326 
00334     public function setFncName( $sFncName )
00335     {
00336         $this->_sFnc = $sFncName;
00337     }
00338 
00344     public function getFncName()
00345     {
00346         return $this->_sFnc;
00347     }
00348 
00356     public function setViewData( $aViewData = null )
00357     {
00358         $this->_aViewData = $aViewData;
00359     }
00360 
00366     public function getViewData()
00367     {
00368         return $this->_aViewData;
00369     }
00370 
00378     public function getViewDataElement( $sParamId = null )
00379     {
00380         if ( $sParamId && isset( $this->_aViewData[$sParamId] ) ) {
00381             return $this->_aViewData[$sParamId];
00382         }
00383     }
00384 
00392     public function setClassLocation( $sClassLocation = null )
00393     {
00394         $this->_sClassLocation = $sClassLocation;
00395     }
00401     public function getClassLocation()
00402     {
00403         return $this->_sClassLocation;
00404     }
00405 
00413     public function setThisAction( $sThisAction = null )
00414     {
00415         $this->_sThisAction = $sThisAction;
00416     }
00417 
00423     public function getThisAction()
00424     {
00425         return $this->_sThisAction;
00426     }
00427 
00435     public function setParent( $oParent = null )
00436     {
00437         $this->_oParent = $oParent;
00438     }
00439 
00445     public function getParent()
00446     {
00447         return $this->_oParent;
00448     }
00449 
00457     public function setIsComponent( $blIsComponent = null )
00458     {
00459         $this->_blIsComponent = $blIsComponent;
00460     }
00461 
00467     public function getIsComponent()
00468     {
00469         return $this->_blIsComponent;
00470     }
00471 
00482     public function executeFunction( $sFunction )
00483     {
00484         // execute
00485         if ( $sFunction && !self::$_blExecuted ) {
00486             if ( method_exists( $this, $sFunction ) ) {
00487 
00488 
00489                 $sNewAction = $this->$sFunction();
00490                 self::$_blExecuted = true;
00491 
00492                 if (isset($sNewAction)) {
00493                     $this->_executeNewAction( $sNewAction );
00494                 }
00495             } else {
00496                 // was not executed on any level ?
00497                 if ( !$this->_blIsComponent ) {
00498                     $oEx = oxNew( 'oxSystemComponentException' );
00499                     $oEx->setMessage( 'ERROR_MESSAGE_SYSTEMCOMPONENT_FUNCTIONNOTFOUND' );
00500                     $oEx->setComponent( $sFunction );
00501                     throw $oEx;
00502                 }
00503             }
00504         }
00505     }
00506 
00516     protected function _executeNewAction( $sNewAction )
00517     {
00518         if ( $sNewAction ) {
00519             $myConfig  = $this->getConfig();
00520 
00521             // page parameters is the part which goes after '?'
00522             $aParams = explode( '?', $sNewAction );
00523 
00524             // action parameters is the part before '?'
00525             $sPageParams = isset( $aParams[1] )?$aParams[1]:null;
00526 
00527             // looking for function name
00528             $aParams    = explode( '/', $aParams[0] );
00529             $sClassName = $aParams[0];
00530 
00531             // building redirect path ...
00532             $sHeader  = ( $sClassName )?"cl=$sClassName&":'';  // adding view name
00533             $sHeader .= ( $sPageParams )?"$sPageParams&":'';   // adding page params
00534             $sHeader .= $this->getSession()->sid();            // adding session Id
00535 
00536             $sUrl = $myConfig->getCurrentShopUrl($this->isAdmin());
00537 
00538             $sUrl = "{$sUrl}index.php?{$sHeader}";
00539 
00540             $sUrl = oxUtilsUrl::getInstance()->processUrl($sUrl);
00541 
00542             //#M341 do not add redirect parameter
00543             oxUtils::getInstance()->redirect( $sUrl, (bool) oxConfig::getParameter( 'redirected' ), 302 );
00544         }
00545     }
00546 
00552     public function getAdditionalParams()
00553     {
00554         return oxUtilsUrl::getInstance()->processUrl( '', false );
00555     }
00556 
00562     public function getTrustedShopId()
00563     {
00564         if ( $this->_sTrustedShopId == null ) {
00565             $this->_sTrustedShopId = false;
00566             $oConfig = $this->getConfig();
00567             $aTsType   = $oConfig->getConfigParam( 'tsSealType' );
00568             $sTsActive = $oConfig->getConfigParam( 'tsSealActive' );
00569             $aTrustedShopIds = $oConfig->getConfigParam( 'iShopID_TrustedShops' );
00570             $iLangId = (int) oxLang::getInstance()->getBaseLanguage();
00571             if ( $sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'CLASSIC' ) {
00572                 // compatibility to old data
00573                 if ( !is_array( $aTrustedShopIds ) && $iLangId == 0 ) {
00574                     $this->_sTrustedShopId = $aTrustedShopIds;
00575                 }
00576                 if ( is_array( $aTrustedShopIds ) ) {
00577                     $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
00578                 }
00579                 if ( strlen( $this->_sTrustedShopId ) != 33 || substr( $this->_sTrustedShopId, 0, 1 ) != 'X' ) {
00580                     $this->_sTrustedShopId = false;
00581                 }
00582             }
00583         }
00584         return $this->_sTrustedShopId;
00585     }
00586 
00592     public function getTSExcellenceId()
00593     {
00594         if ( $this->_sTSExcellenceId == null ) {
00595             $this->_sTSExcellenceId = false;
00596             $oConfig   = $this->getConfig();
00597             $aTsType   = $oConfig->getConfigParam( 'tsSealType' );
00598             $sTsActive = $oConfig->getConfigParam( 'tsSealActive' );
00599             $aTrustedShopIds = $oConfig->getConfigParam( 'iShopID_TrustedShops' );
00600             $iLangId = (int) oxLang::getInstance()->getBaseLanguage();
00601             if ( $sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'EXCELLENCE' ) {
00602                 $this->_sTSExcellenceId = $aTrustedShopIds[$iLangId];
00603             }
00604         }
00605         return $this->_sTSExcellenceId;
00606     }
00607 
00613     public function getCharSet()
00614     {
00615         if ( $this->_sCharSet == null ) {
00616             $this->_sCharSet = oxLang::getInstance()->translateString( 'charset' );
00617         }
00618         return $this->_sCharSet;
00619     }
00620 
00626     public function getShopVersion()
00627     {
00628         if ( $this->_sVersion == null ) {
00629             $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
00630         }
00631         return $this->_sVersion;
00632     }
00633 
00639     public function getShopEdition()
00640     {
00641         return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
00642     }
00643 
00649     public function getRevision()
00650     {
00651         return $this->getConfig()->getRevision();
00652     }
00653 
00659     public function getShopFullEdition()
00660     {
00661         $sEdition = $this->getShopEdition();
00662         $sFullEdition = "Community Edition";
00663         if ( $sEdition == "PE" ) {
00664             $sFullEdition = "Professional Edition";
00665         }
00666 
00667         if ( $sEdition == "EE" ) {
00668             $sFullEdition = "Enterprise Edition";
00669         }
00670 
00671         return $sFullEdition;
00672     }
00673 
00674 
00680     public function isDemoVersion()
00681     {
00682         if ( $this->_blDemoVersion == null ) {
00683             $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
00684         }
00685         return $this->_blDemoVersion;
00686     }
00687 
00693     public function isDemoShop()
00694     {
00695         if ( $this->_blDemoShop == null ) {
00696             $this->_blDemoShop = $this->getConfig()->isDemoShop();
00697         }
00698         return $this->_blDemoShop;
00699     }
00700 
00706     public function showNewsletter()
00707     {
00708         if ( $this->_iNewsStatus === null) {
00709             return 1;
00710         }
00711         return $this->_iNewsStatus;
00712     }
00713 
00721     public function setShowNewsletter( $blShow )
00722     {
00723         $this->_iNewsStatus = $blShow;
00724     }
00725 
00731     public function getShopLogo()
00732     {
00733         return $this->_sShopLogo;
00734     }
00735 
00743     public function setShopLogo( $sLogo )
00744     {
00745         $this->_sShopLogo = $sLogo;
00746     }
00747 
00755     public function getActCategory()
00756     {
00757         // if active category is not set yet - trying to load it from request params
00758         // this may be usefull when category component was unable to load active category
00759         // and we still need some object to mount navigation info
00760         if ( $this->_oClickCat === null ) {
00761 
00762             $this->_oClickCat = false;
00763             $oCategory = oxNew( 'oxcategory' );
00764             if ( $oCategory->load( $this->getCategoryId() ) ) {
00765                 $this->_oClickCat = $oCategory;
00766             }
00767         }
00768 
00769         return $this->_oClickCat;
00770     }
00771 
00779     public function setActCategory( $oCategory )
00780     {
00781         $this->_oClickCat = $oCategory;
00782     }
00783 
00789     public function getCategoryId()
00790     {
00791         if ( $this->_sCategoryId == null && ( $sCatId = oxConfig::getParameter( 'cnid' ) ) ) {
00792             $this->_sCategoryId = $sCatId;
00793         }
00794 
00795         return $this->_sCategoryId;
00796     }
00797 
00805     public function setCategoryId( $sCategoryId )
00806     {
00807         $this->_sCategoryId = $sCategoryId;
00808     }
00809 
00815     public function getErrorDestination()
00816     {
00817     }
00818 
00825     public function getActionClassName()
00826     {
00827         return $this->getClassName();
00828     }
00829 
00835     public function isConnectedWithFb()
00836     {
00837         $myConfig = $this->getConfig();
00838 
00839         if ( $myConfig->getConfigParam( "bl_showFbConnect" ) ) {
00840             $oFb = oxFb::getInstance();
00841             return $oFb->isConnected();
00842         }
00843 
00844         return false;
00845     }
00846 
00852     public function getFbUserId()
00853     {
00854         if ( $this->getConfig()->getConfigParam( "bl_showFbConnect" ) ) {
00855             $oFb = oxFb::getInstance();
00856             return $oFb->getUser();
00857         }
00858     }
00859 
00866     public function showFbConnectToAccountMsg()
00867     {
00868         if ( $this->getConfig()->getParameter( "fblogin" ) ) {
00869             if ( !$this->getUser() || ($this->getUser() && oxSession::getVar( '_blFbUserIdUpdated' ) ) ) {
00870                 return true;
00871             } else {
00872                 return false;
00873             }
00874         }
00875 
00876         return false;
00877     }
00878 
00884     public function isMall()
00885     {
00886             return false;
00887     }
00888 
00889 }