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             if ( oxRegistry::getUtils()->seoIsActive() && $sSeoUrl = oxRegistry::get( "oxSeoEncoder" )->getStaticUrl( $sUrl ) ) {
00573                 $sUrl = $sSeoUrl;
00574             }
00575 
00576 
00577             //#M341 do not add redirect parameter
00578             oxRegistry::getUtils()->redirect( $sUrl, (bool) $myConfig->getRequestParameter( 'redirected' ), 302 );
00579         }
00580     }
00581 
00587     public function getAdditionalParams()
00588     {
00589         return oxRegistry::get("oxUtilsUrl")->processUrl( '', false );
00590     }
00591 
00597     public function getTrustedShopId()
00598     {
00599         if ( $this->_sTrustedShopId == null ) {
00600             $this->_sTrustedShopId = false;
00601             $oConfig = $this->getConfig();
00602             $aTsType   = $oConfig->getConfigParam( 'tsSealType' );
00603             $sTsActive = $oConfig->getConfigParam( 'tsSealActive' );
00604             $aTrustedShopIds = $oConfig->getConfigParam( 'iShopID_TrustedShops' );
00605             $iLangId = (int) oxRegistry::getLang()->getBaseLanguage();
00606             if ( $sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'CLASSIC' ) {
00607                 // compatibility to old data
00608                 if ( !is_array( $aTrustedShopIds ) && $iLangId == 0 ) {
00609                     $this->_sTrustedShopId = $aTrustedShopIds;
00610                 }
00611                 if ( is_array( $aTrustedShopIds ) ) {
00612                     $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
00613                 }
00614                 if ( strlen( $this->_sTrustedShopId ) != 33 || substr( $this->_sTrustedShopId, 0, 1 ) != 'X' ) {
00615                     $this->_sTrustedShopId = false;
00616                 }
00617             }
00618         }
00619         return $this->_sTrustedShopId;
00620     }
00621 
00627     public function getTSExcellenceId()
00628     {
00629         if ( $this->_sTSExcellenceId == null ) {
00630             $this->_sTSExcellenceId = false;
00631             $oConfig   = $this->getConfig();
00632             $aTsType   = $oConfig->getConfigParam( 'tsSealType' );
00633             $sTsActive = $oConfig->getConfigParam( 'tsSealActive' );
00634             $aTrustedShopIds = $oConfig->getConfigParam( 'iShopID_TrustedShops' );
00635             $iLangId = (int) oxRegistry::getLang()->getBaseLanguage();
00636             if ( $sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'EXCELLENCE' ) {
00637                 $this->_sTSExcellenceId = $aTrustedShopIds[$iLangId];
00638             }
00639         }
00640         return $this->_sTSExcellenceId;
00641     }
00642 
00648     public function getCharSet()
00649     {
00650         if ( $this->_sCharSet == null ) {
00651             $this->_sCharSet = oxRegistry::getLang()->translateString( 'charset' );
00652         }
00653         return $this->_sCharSet;
00654     }
00655 
00661     public function getShopVersion()
00662     {
00663         if ( $this->_sVersion == null ) {
00664             $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
00665         }
00666         return $this->_sVersion;
00667     }
00668 
00674     public function getShopEdition()
00675     {
00676         return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
00677     }
00678 
00684     public function getRevision()
00685     {
00686         return $this->getConfig()->getRevision();
00687     }
00688 
00694     public function getPackageInfo()
00695     {
00696         return $this->getConfig()->getPackageInfo();
00697     }
00698 
00704     public function getShopFullEdition()
00705     {
00706         $sEdition = $this->getShopEdition();
00707         $sFullEdition = "Community Edition";
00708         if ( $sEdition == "PE" ) {
00709             $sFullEdition = "Professional Edition";
00710         }
00711 
00712         if ( $sEdition == "EE" ) {
00713             $sFullEdition = "Enterprise Edition";
00714         }
00715 
00716         return $sFullEdition;
00717     }
00718 
00719 
00725     public function isDemoVersion()
00726     {
00727         if ( $this->_blDemoVersion == null ) {
00728             $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
00729         }
00730         return $this->_blDemoVersion;
00731     }
00732 
00738     public function isBetaVersion()
00739     {
00740         $blbetaVersion = false;
00741 
00742         if ( stripos( $this->getConfig()->getVersion(), 'beta' ) !== false ) {
00743             $blbetaVersion = true;
00744         }
00745 
00746         return $blbetaVersion;
00747     }
00748 
00754     public function isRCVersion()
00755     {
00756         $blRCVersion = false;
00757 
00758         if ( stripos( $this->getConfig()->getVersion(), 'rc' ) !== false ) {
00759             $blRCVersion = true;
00760         }
00761 
00762         return $blRCVersion;
00763     }
00764 
00770     public function showBetaNote()
00771     {
00772         $blBetaNote = false;
00773 
00774         if ( $this->isBetaVersion() || $this->isRCVersion() ) {
00775             $blBetaNote = true;
00776         }
00777 
00778         return $blBetaNote;
00779     }
00780 
00786     public function isDemoShop()
00787     {
00788         if ( $this->_blDemoShop == null ) {
00789             $this->_blDemoShop = $this->getConfig()->isDemoShop();
00790         }
00791         return $this->_blDemoShop;
00792     }
00793 
00799     public function showNewsletter()
00800     {
00801         if ( $this->_iNewsStatus === null) {
00802             return 1;
00803         }
00804         return $this->_iNewsStatus;
00805     }
00806 
00814     public function setShowNewsletter( $blShow )
00815     {
00816         $this->_iNewsStatus = $blShow;
00817     }
00818 
00826     public function getShopLogo()
00827     {
00828         if ( $this->_sShopLogo === null ) {
00829             $this->setShopLogo( $this->getConfig()->getConfigParam( 'sShopLogo' ) );
00830         }
00831 
00832         return $this->_sShopLogo;
00833     }
00834 
00844     public function setShopLogo( $sLogo )
00845     {
00846         $this->_sShopLogo = $sLogo;
00847     }
00848 
00858     public function getActCategory()
00859     {
00860         // if active category is not set yet - trying to load it from request params
00861         // this may be usefull when category component was unable to load active category
00862         // and we still need some object to mount navigation info
00863         if ( $this->_oClickCat === null ) {
00864 
00865             $this->_oClickCat = false;
00866             $oCategory = oxNew( 'oxcategory' );
00867             if ( $oCategory->load( $this->getCategoryId() ) ) {
00868                 $this->_oClickCat = $oCategory;
00869             }
00870         }
00871 
00872         return $this->_oClickCat;
00873     }
00874 
00884     public function setActCategory( $oCategory )
00885     {
00886         $this->_oClickCat = $oCategory;
00887     }
00888 
00894     public function getCategoryId()
00895     {
00896         if ( $this->_sCategoryId == null && ( $sCatId = $this->getConfig()->getRequestParameter( 'cnid' ) ) ) {
00897             $this->_sCategoryId = $sCatId;
00898         }
00899 
00900         return $this->_sCategoryId;
00901     }
00902 
00910     public function setCategoryId( $sCategoryId )
00911     {
00912         $this->_sCategoryId = $sCategoryId;
00913     }
00914 
00920     public function getErrorDestination()
00921     {
00922     }
00923 
00930     public function getActionClassName()
00931     {
00932         return $this->getClassName();
00933     }
00934 
00940     public function isConnectedWithFb()
00941     {
00942         $myConfig = $this->getConfig();
00943 
00944         if ( $myConfig->getConfigParam( "bl_showFbConnect" ) ) {
00945             $oFb = oxRegistry::get("oxFb");
00946             return $oFb->isConnected();
00947         }
00948 
00949         return false;
00950     }
00951 
00957     public function getFbUserId()
00958     {
00959         if ( $this->getConfig()->getConfigParam( "bl_showFbConnect" ) ) {
00960             $oFb = oxRegistry::get("oxFb");
00961             return $oFb->getUser();
00962         }
00963     }
00964 
00971     public function showFbConnectToAccountMsg()
00972     {
00973         if ( $this->getConfig()->getRequestParameter( "fblogin" ) ) {
00974             if ( !$this->getUser() || ($this->getUser() && $this->getSession()->getVariable( '_blFbUserIdUpdated' ) ) ) {
00975                 return true;
00976             } else {
00977                 return false;
00978             }
00979         }
00980 
00981         return false;
00982     }
00983 
00989     public function isMall()
00990     {
00991             return false;
00992     }
00993 
00999     public function showRdfa()
01000     {
01001         return false;
01002     }
01003 
01004 
01012     public function getSidForWidget()
01013     {
01014         $sRet = null;
01015         $oSession = $this->getSession();
01016 
01017         if (!$oSession->isActualSidInCookie() ) {
01018             $sRet = $oSession->getId();
01019         }
01020 
01021         return $sRet;
01022     }
01023 
01024 }