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     protected $_oViewConf = null;
00153 
00154 
00160     public function init()
00161     {
00162         // setting current view class name
00163         $this->_sThisAction = strtolower( get_class( $this ) );
00164 
00165         if ( !$this->_blIsComponent ) {
00166             // assume that cached components does not affect this method ...
00167             $this->addGlobalParams();
00168         }
00169     }
00170 
00178     public function setViewParameters( $aParams = null )
00179     {
00180         $this->_aViewParams = $aParams;
00181     }
00182 
00190     public function getViewParameter( $sKey )
00191     {
00192         $sValue = ( isset( $this->_aViewParams[$sKey] ) ) ? $this->_aViewParams[$sKey] : $this->getConfig()->getRequestParameter( $sKey );
00193 
00194         return $sValue;
00195     }
00196 
00204     public function setIsCallForCache( $blIsCallForCache = null )
00205     {
00206         $this->_blIsCallForCache = $blIsCallForCache;
00207     }
00208 
00214     public function getIsCallForCache()
00215     {
00216         return $this->_blIsCallForCache;
00217     }
00218 
00224     public function getViewId()
00225     {
00226     }
00227 
00233     public function render()
00234     {
00235         return $this->getTemplateName();
00236     }
00237 
00251     public function addGlobalParams( $oShop = null)
00252     {
00253         // by default we allways display newsletter bar
00254         $this->_iNewsStatus = 1;
00255 
00256         // assigning shop to view config ..
00257         $oViewConf = $this->getViewConfig();
00258         if ( $oShop ) {
00259             $oViewConf->setViewShop( $oShop, $this->_aViewData );
00260         }
00261 
00262         //sending all view to smarty
00263         $this->_aViewData['oView'] = $this;
00264         $this->_aViewData['oViewConf'] = $this->getViewConfig();
00265 
00266         return $oViewConf;
00267     }
00268 
00277     public function addTplParam( $sPara, $sValue )
00278     {
00279         $this->_aViewData[$sPara] = $sValue;
00280     }
00281 
00287     public function getBelboonParam()
00288     {
00289         if ( $sBelboon = $this->getSession()->getVariable( 'belboon' ) ) {
00290             return $sBelboon;
00291         }
00292         if ( ( $sBelboon = $this->getConfig()->getRequestParameter( 'belboon' ) ) ) {
00293             $this->getSession()->setVariable( 'belboon', $sBelboon );
00294         }
00295 
00296         return $sBelboon;
00297     }
00298 
00304     public function getViewConfig()
00305     {
00306         if ( $this->_oViewConf === null ) {
00307             $this->_oViewConf = oxNew( 'oxViewConfig' );
00308         }
00309 
00310         return $this->_oViewConf;
00311     }
00312 
00318     public function getTemplateName()
00319     {
00320         return $this->_sThisTemplate;
00321     }
00322 
00330     public function setTemplateName( $sTemplate )
00331     {
00332         $this->_sThisTemplate = $sTemplate;
00333     }
00334 
00342     public function setClassName( $sClassName )
00343     {
00344         $this->_sClass = $sClassName;
00345     }
00346 
00352     public function getClassName()
00353     {
00354         return $this->_sClass;
00355     }
00356 
00364     public function setFncName( $sFncName )
00365     {
00366         $this->_sFnc = $sFncName;
00367     }
00368 
00374     public function getFncName()
00375     {
00376         return $this->_sFnc;
00377     }
00378 
00386     public function setViewData( $aViewData = null )
00387     {
00388         $this->_aViewData = $aViewData;
00389     }
00390 
00396     public function getViewData()
00397     {
00398         return $this->_aViewData;
00399     }
00400 
00408     public function getViewDataElement( $sParamId = null )
00409     {
00410         if ( $sParamId && isset( $this->_aViewData[$sParamId] ) ) {
00411             return $this->_aViewData[$sParamId];
00412         }
00413     }
00414 
00422     public function setClassLocation( $sClassLocation = null )
00423     {
00424         $this->_sClassLocation = $sClassLocation;
00425     }
00431     public function getClassLocation()
00432     {
00433         return $this->_sClassLocation;
00434     }
00435 
00443     public function setThisAction( $sThisAction = null )
00444     {
00445         $this->_sThisAction = $sThisAction;
00446     }
00447 
00453     public function getThisAction()
00454     {
00455         return $this->_sThisAction;
00456     }
00457 
00465     public function setParent( $oParent = null )
00466     {
00467         $this->_oParent = $oParent;
00468     }
00469 
00475     public function getParent()
00476     {
00477         return $this->_oParent;
00478     }
00479 
00487     public function setIsComponent( $blIsComponent = null )
00488     {
00489         $this->_blIsComponent = $blIsComponent;
00490     }
00491 
00497     public function getIsComponent()
00498     {
00499         return $this->_blIsComponent;
00500     }
00501 
00512     public function executeFunction( $sFunction )
00513     {
00514         // execute
00515         if ( $sFunction && !self::$_blExecuted ) {
00516             if ( method_exists( $this, $sFunction ) ) {
00517 
00518 
00519                 $sNewAction = $this->$sFunction();
00520                 self::$_blExecuted = true;
00521 
00522                 if (isset($sNewAction)) {
00523                     $this->_executeNewAction( $sNewAction );
00524                 }
00525             } else {
00526                 // was not executed on any level ?
00527                 if ( !$this->_blIsComponent ) {
00528                     $oEx = oxNew( 'oxSystemComponentException' );
00529                     $oEx->setMessage( 'ERROR_MESSAGE_SYSTEMCOMPONENT_FUNCTIONNOTFOUND' );
00530                     $oEx->setComponent( $sFunction );
00531                     throw $oEx;
00532                 }
00533             }
00534         }
00535     }
00536 
00546     protected function _executeNewAction( $sNewAction )
00547     {
00548         if ( $sNewAction ) {
00549             $myConfig  = $this->getConfig();
00550 
00551             // page parameters is the part which goes after '?'
00552             $aParams = explode( '?', $sNewAction );
00553 
00554             // action parameters is the part before '?'
00555             $sPageParams = isset( $aParams[1] )?$aParams[1]:null;
00556 
00557             // looking for function name
00558             $aParams    = explode( '/', $aParams[0] );
00559             $sClassName = $aParams[0];
00560 
00561             // building redirect path ...
00562             $sHeader  = ( $sClassName )?"cl=$sClassName&":'';  // adding view name
00563             $sHeader .= ( $sPageParams )?"$sPageParams&":'';   // adding page params
00564             $sHeader .= $this->getSession()->sid();            // adding session Id
00565 
00566             $sUrl = $myConfig->getCurrentShopUrl($this->isAdmin());
00567 
00568             $sUrl = "{$sUrl}index.php?{$sHeader}";
00569 
00570             $sUrl = oxRegistry::get("oxUtilsUrl")->processUrl($sUrl);
00571 
00572 
00573             //#M341 do not add redirect parameter
00574             oxRegistry::getUtils()->redirect( $sUrl, (bool) $myConfig->getRequestParameter( 'redirected' ), 302 );
00575         }
00576     }
00577 
00583     public function getAdditionalParams()
00584     {
00585         return oxRegistry::get("oxUtilsUrl")->processUrl( '', false );
00586     }
00587 
00593     public function getTrustedShopId()
00594     {
00595         if ( $this->_sTrustedShopId == null ) {
00596             $this->_sTrustedShopId = false;
00597             $oConfig = $this->getConfig();
00598             $aTsType   = $oConfig->getConfigParam( 'tsSealType' );
00599             $sTsActive = $oConfig->getConfigParam( 'tsSealActive' );
00600             $aTrustedShopIds = $oConfig->getConfigParam( 'iShopID_TrustedShops' );
00601             $iLangId = (int) oxRegistry::getLang()->getBaseLanguage();
00602             if ( $sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'CLASSIC' ) {
00603                 // compatibility to old data
00604                 if ( !is_array( $aTrustedShopIds ) && $iLangId == 0 ) {
00605                     $this->_sTrustedShopId = $aTrustedShopIds;
00606                 }
00607                 if ( is_array( $aTrustedShopIds ) ) {
00608                     $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
00609                 }
00610                 if ( strlen( $this->_sTrustedShopId ) != 33 || substr( $this->_sTrustedShopId, 0, 1 ) != 'X' ) {
00611                     $this->_sTrustedShopId = false;
00612                 }
00613             }
00614         }
00615         return $this->_sTrustedShopId;
00616     }
00617 
00623     public function getTSExcellenceId()
00624     {
00625         if ( $this->_sTSExcellenceId == null ) {
00626             $this->_sTSExcellenceId = false;
00627             $oConfig   = $this->getConfig();
00628             $aTsType   = $oConfig->getConfigParam( 'tsSealType' );
00629             $sTsActive = $oConfig->getConfigParam( 'tsSealActive' );
00630             $aTrustedShopIds = $oConfig->getConfigParam( 'iShopID_TrustedShops' );
00631             $iLangId = (int) oxRegistry::getLang()->getBaseLanguage();
00632             if ( $sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'EXCELLENCE' ) {
00633                 $this->_sTSExcellenceId = $aTrustedShopIds[$iLangId];
00634             }
00635         }
00636         return $this->_sTSExcellenceId;
00637     }
00638 
00644     public function getCharSet()
00645     {
00646         if ( $this->_sCharSet == null ) {
00647             $this->_sCharSet = oxRegistry::getLang()->translateString( 'charset' );
00648         }
00649         return $this->_sCharSet;
00650     }
00651 
00657     public function getShopVersion()
00658     {
00659         if ( $this->_sVersion == null ) {
00660             $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
00661         }
00662         return $this->_sVersion;
00663     }
00664 
00670     public function getShopEdition()
00671     {
00672         return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
00673     }
00674 
00680     public function getRevision()
00681     {
00682         return $this->getConfig()->getRevision();
00683     }
00684 
00690     public function getShopFullEdition()
00691     {
00692         $sEdition = $this->getShopEdition();
00693         $sFullEdition = "Community Edition";
00694         if ( $sEdition == "PE" ) {
00695             $sFullEdition = "Professional Edition";
00696         }
00697 
00698         if ( $sEdition == "EE" ) {
00699             $sFullEdition = "Enterprise Edition";
00700         }
00701 
00702         return $sFullEdition;
00703     }
00704 
00705 
00711     public function isDemoVersion()
00712     {
00713         if ( $this->_blDemoVersion == null ) {
00714             $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
00715         }
00716         return $this->_blDemoVersion;
00717     }
00718 
00724     public function isDemoShop()
00725     {
00726         if ( $this->_blDemoShop == null ) {
00727             $this->_blDemoShop = $this->getConfig()->isDemoShop();
00728         }
00729         return $this->_blDemoShop;
00730     }
00731 
00737     public function showNewsletter()
00738     {
00739         if ( $this->_iNewsStatus === null) {
00740             return 1;
00741         }
00742         return $this->_iNewsStatus;
00743     }
00744 
00752     public function setShowNewsletter( $blShow )
00753     {
00754         $this->_iNewsStatus = $blShow;
00755     }
00756 
00762     public function getShopLogo()
00763     {
00764         if ( $this->_sShopLogo === null ) {
00765             $this->setShopLogo( $this->getConfig()->getConfigParam( 'sShopLogo' ) );
00766         }
00767 
00768         return $this->_sShopLogo;
00769     }
00770 
00778     public function setShopLogo( $sLogo )
00779     {
00780         $this->_sShopLogo = $sLogo;
00781     }
00782 
00790     public function getActCategory()
00791     {
00792         // if active category is not set yet - trying to load it from request params
00793         // this may be usefull when category component was unable to load active category
00794         // and we still need some object to mount navigation info
00795         if ( $this->_oClickCat === null ) {
00796 
00797             $this->_oClickCat = false;
00798             $oCategory = oxNew( 'oxcategory' );
00799             if ( $oCategory->load( $this->getCategoryId() ) ) {
00800                 $this->_oClickCat = $oCategory;
00801             }
00802         }
00803 
00804         return $this->_oClickCat;
00805     }
00806 
00814     public function setActCategory( $oCategory )
00815     {
00816         $this->_oClickCat = $oCategory;
00817     }
00818 
00824     public function getCategoryId()
00825     {
00826         if ( $this->_sCategoryId == null && ( $sCatId = $this->getConfig()->getRequestParameter( 'cnid' ) ) ) {
00827             $this->_sCategoryId = $sCatId;
00828         }
00829 
00830         return $this->_sCategoryId;
00831     }
00832 
00840     public function setCategoryId( $sCategoryId )
00841     {
00842         $this->_sCategoryId = $sCategoryId;
00843     }
00844 
00850     public function getErrorDestination()
00851     {
00852     }
00853 
00860     public function getActionClassName()
00861     {
00862         return $this->getClassName();
00863     }
00864 
00870     public function isConnectedWithFb()
00871     {
00872         $myConfig = $this->getConfig();
00873 
00874         if ( $myConfig->getConfigParam( "bl_showFbConnect" ) ) {
00875             $oFb = oxRegistry::get("oxFb");
00876             return $oFb->isConnected();
00877         }
00878 
00879         return false;
00880     }
00881 
00887     public function getFbUserId()
00888     {
00889         if ( $this->getConfig()->getConfigParam( "bl_showFbConnect" ) ) {
00890             $oFb = oxRegistry::get("oxFb");
00891             return $oFb->getUser();
00892         }
00893     }
00894 
00901     public function showFbConnectToAccountMsg()
00902     {
00903         if ( $this->getConfig()->getRequestParameter( "fblogin" ) ) {
00904             if ( !$this->getUser() || ($this->getUser() && $this->getSession()->getVariable( '_blFbUserIdUpdated' ) ) ) {
00905                 return true;
00906             } else {
00907                 return false;
00908             }
00909         }
00910 
00911         return false;
00912     }
00913 
00919     public function isMall()
00920     {
00921             return false;
00922     }
00923 
00929     public function showRdfa()
00930     {
00931         return false;
00932     }
00933 
00934 }