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 
00159     public function init()
00160     {
00161         // setting current view class name
00162         $this->_sThisAction = strtolower( get_class( $this ) );
00163 
00164         if ( !$this->_blIsComponent ) {
00165             // assume that cached components does not affect this method ...
00166             $this->addGlobalParams();
00167         }
00168     }
00169 
00177     public function setIsCallForCache( $blIsCallForCache = null )
00178     {
00179         $this->_blIsCallForCache = $blIsCallForCache;
00180     }
00181 
00187     public function getIsCallForCache()
00188     {
00189         return $this->_blIsCallForCache;
00190     }
00191 
00197     public function getViewId()
00198     {
00199     }
00200 
00206     public function render()
00207     {
00208         return $this->_sThisTemplate;
00209     }
00210 
00224     public function addGlobalParams( $oShop = null)
00225     {
00226         // by default we allways display newsletter bar
00227         $this->_iNewsStatus = 1;
00228 
00229         // assigning shop to view config ..
00230         $oViewConf = $this->getViewConfig();
00231         if ( $oShop ) {
00232             $oViewConf->setViewShop( $oShop, $this->_aViewData );
00233         }
00234 
00235         //sending all view to smarty
00236         $this->_aViewData['oView'] = $this;
00237         $this->_aViewData['oViewConf'] = $this->getViewConfig();
00238 
00239         return $oViewConf;
00240     }
00241 
00250     public function addTplParam( $sPara, $sValue )
00251     {
00252         $this->_aViewData[$sPara] = $sValue;
00253     }
00254 
00266     protected function _setAdditionalParams()
00267     {
00268         $this->getAdditionalParams();
00269     }
00270 
00276     public function getBelboonParam()
00277     {
00278         if ( $sBelboon = oxSession::getVar( 'belboon' ) ) {
00279             return $sBelboon;
00280         }
00281         if ( ( $sBelboon = oxConfig::getParameter( 'belboon' ) ) ) {
00282             oxSession::setVar( 'belboon', $sBelboon );
00283         }
00284 
00285         return $sBelboon;
00286     }
00287 
00293     public function getViewConfig()
00294     {
00295         if ( $this->_oViewConf === null ) {
00296             $this->_oViewConf = oxNew( 'oxViewConfig' );
00297         }
00298 
00299         return $this->_oViewConf;
00300     }
00301 
00307     public function getTemplateName()
00308     {
00309         return $this->_sThisTemplate;
00310     }
00311 
00319     public function setClassName( $sClassName )
00320     {
00321         $this->_sClass = $sClassName;
00322     }
00323 
00329     public function getClassName()
00330     {
00331         return $this->_sClass;
00332     }
00333 
00341     public function setFncName( $sFncName )
00342     {
00343         $this->_sFnc = $sFncName;
00344     }
00345 
00351     public function getFncName()
00352     {
00353         return $this->_sFnc;
00354     }
00355 
00363     public function setViewData( $aViewData = null )
00364     {
00365         $this->_aViewData = $aViewData;
00366     }
00367 
00373     public function getViewData()
00374     {
00375         return $this->_aViewData;
00376     }
00377 
00385     public function getViewDataElement( $sParamId = null )
00386     {
00387         if ( $sParamId && isset( $this->_aViewData[$sParamId] ) ) {
00388             return $this->_aViewData[$sParamId];
00389         }
00390     }
00391 
00399     public function setClassLocation( $sClassLocation = null )
00400     {
00401         $this->_sClassLocation = $sClassLocation;
00402     }
00408     public function getClassLocation()
00409     {
00410         return $this->_sClassLocation;
00411     }
00412 
00420     public function setThisAction( $sThisAction = null )
00421     {
00422         $this->_sThisAction = $sThisAction;
00423     }
00424 
00430     public function getThisAction()
00431     {
00432         return $this->_sThisAction;
00433     }
00434 
00442     public function setParent( $oParent = null )
00443     {
00444         $this->_oParent = $oParent;
00445     }
00446 
00452     public function getParent()
00453     {
00454         return $this->_oParent;
00455     }
00456 
00464     public function setIsComponent( $blIsComponent = null )
00465     {
00466         $this->_blIsComponent = $blIsComponent;
00467     }
00468 
00474     public function getIsComponent()
00475     {
00476         return $this->_blIsComponent;
00477     }
00478 
00489     public function executeFunction( $sFunction )
00490     {
00491         // execute
00492         if ( $sFunction && !self::$_blExecuted ) {
00493             if ( method_exists( $this, $sFunction ) ) {
00494 
00495 
00496                 $sNewAction = $this->$sFunction();
00497                 self::$_blExecuted = true;
00498 
00499                 if (isset($sNewAction)) {
00500                     $this->_executeNewAction( $sNewAction );
00501                 }
00502             } else {
00503                 // was not executed on any level ?
00504                 if ( !$this->_blIsComponent ) {
00505                     $oEx = oxNew( 'oxSystemComponentException' );
00506                     $oEx->setMessage( 'ERROR_MESSAGE_SYSTEMCOMPONENT_FUNCTIONNOTFOUND' );
00507                     $oEx->setComponent( $sFunction );
00508                     throw $oEx;
00509                 }
00510             }
00511         }
00512     }
00513 
00523     protected function _executeNewAction( $sNewAction )
00524     {
00525         if ( $sNewAction ) {
00526             $myConfig  = $this->getConfig();
00527 
00528             // page parameters is the part which goes after '?'
00529             $aParams = explode( '?', $sNewAction );
00530 
00531             // action parameters is the part before '?'
00532             $sPageParams = isset( $aParams[1] )?$aParams[1]:null;
00533 
00534             // looking for function name
00535             $aParams    = explode( '/', $aParams[0] );
00536             $sClassName = $aParams[0];
00537 
00538             // building redirect path ...
00539             $sHeader  = ( $sClassName )?"cl=$sClassName&":'';  // adding view name
00540             $sHeader .= ( $sPageParams )?"$sPageParams&":'';   // adding page params
00541             $sHeader .= $this->getSession()->sid();            // adding session Id
00542 
00543             $sUrl = $myConfig->getCurrentShopUrl($this->isAdmin());
00544 
00545             $sUrl = "{$sUrl}index.php?{$sHeader}";
00546 
00547             $sUrl = oxUtilsUrl::getInstance()->processUrl($sUrl);
00548 
00549             //#M341 do not add redirect parameter
00550             oxUtils::getInstance()->redirect( $sUrl, (bool) oxConfig::getParameter( 'redirected' ), 302 );
00551         }
00552     }
00553 
00559     public function getAdditionalParams()
00560     {
00561         return oxUtilsUrl::getInstance()->processUrl( '', false );
00562     }
00563 
00569     public function getTrustedShopId()
00570     {
00571         if ( $this->_sTrustedShopId == null ) {
00572             $this->_sTrustedShopId = false;
00573             $oConfig = $this->getConfig();
00574             $aTsType   = $oConfig->getConfigParam( 'tsSealType' );
00575             $sTsActive = $oConfig->getConfigParam( 'tsSealActive' );
00576             $aTrustedShopIds = $oConfig->getConfigParam( 'iShopID_TrustedShops' );
00577             $iLangId = (int) oxLang::getInstance()->getBaseLanguage();
00578             if ( $sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'CLASSIC' ) {
00579                 // compatibility to old data
00580                 if ( !is_array( $aTrustedShopIds ) && $iLangId == 0 ) {
00581                     $this->_sTrustedShopId = $aTrustedShopIds;
00582                 }
00583                 if ( is_array( $aTrustedShopIds ) ) {
00584                     $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
00585                 }
00586                 if ( strlen( $this->_sTrustedShopId ) != 33 || substr( $this->_sTrustedShopId, 0, 1 ) != 'X' ) {
00587                     $this->_sTrustedShopId = false;
00588                 }
00589             }
00590         }
00591         return $this->_sTrustedShopId;
00592     }
00593 
00599     public function getTSExcellenceId()
00600     {
00601         if ( $this->_sTSExcellenceId == null ) {
00602             $this->_sTSExcellenceId = false;
00603             $oConfig   = $this->getConfig();
00604             $aTsType   = $oConfig->getConfigParam( 'tsSealType' );
00605             $sTsActive = $oConfig->getConfigParam( 'tsSealActive' );
00606             $aTrustedShopIds = $oConfig->getConfigParam( 'iShopID_TrustedShops' );
00607             $iLangId = (int) oxLang::getInstance()->getBaseLanguage();
00608             if ( $sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'EXCELLENCE' ) {
00609                 $this->_sTSExcellenceId = $aTrustedShopIds[$iLangId];
00610             }
00611         }
00612         return $this->_sTSExcellenceId;
00613     }
00614 
00620     public function getCharSet()
00621     {
00622         if ( $this->_sCharSet == null ) {
00623             $this->_sCharSet = oxLang::getInstance()->translateString( 'charset' );
00624         }
00625         return $this->_sCharSet;
00626     }
00627 
00633     public function getShopVersion()
00634     {
00635         if ( $this->_sVersion == null ) {
00636             $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
00637         }
00638         return $this->_sVersion;
00639     }
00640 
00646     public function getShopEdition()
00647     {
00648         return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
00649     }
00650 
00656     public function getRevision()
00657     {
00658         return $this->getConfig()->getRevision();
00659     }
00660 
00666     public function getShopFullEdition()
00667     {
00668         $sEdition = $this->getShopEdition();
00669         $sFullEdition = "Community Edition";
00670         if ( $sEdition == "PE" ) {
00671             $sFullEdition = "Professional Edition";
00672         }
00673 
00674         if ( $sEdition == "EE" ) {
00675             $sFullEdition = "Enterprise Edition";
00676         }
00677 
00678         return $sFullEdition;
00679     }
00680 
00681 
00687     public function isDemoVersion()
00688     {
00689         if ( $this->_blDemoVersion == null ) {
00690             $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
00691         }
00692         return $this->_blDemoVersion;
00693     }
00694 
00700     public function isDemoShop()
00701     {
00702         if ( $this->_blDemoShop == null ) {
00703             $this->_blDemoShop = $this->getConfig()->isDemoShop();
00704         }
00705         return $this->_blDemoShop;
00706     }
00707 
00713     public function showNewsletter()
00714     {
00715         if ( $this->_iNewsStatus === null) {
00716             return 1;
00717         }
00718         return $this->_iNewsStatus;
00719     }
00720 
00728     public function setShowNewsletter( $blShow )
00729     {
00730         $this->_iNewsStatus = $blShow;
00731     }
00732 
00738     public function getShopLogo()
00739     {
00740         return $this->_sShopLogo;
00741     }
00742 
00750     public function setShopLogo( $sLogo )
00751     {
00752         $this->_sShopLogo = $sLogo;
00753     }
00754 
00762     public function getActCategory()
00763     {
00764         // if active category is not set yet - trying to load it from request params
00765         // this may be usefull when category component was unable to load active category
00766         // and we still need some object to mount navigation info
00767         if ( $this->_oClickCat === null ) {
00768 
00769             $this->_oClickCat = false;
00770             $oCategory = oxNew( 'oxcategory' );
00771             if ( $oCategory->load( $this->getCategoryId() ) ) {
00772                 $this->_oClickCat = $oCategory;
00773             }
00774         }
00775 
00776         return $this->_oClickCat;
00777     }
00778 
00786     public function setActCategory( $oCategory )
00787     {
00788         $this->_oClickCat = $oCategory;
00789     }
00790 
00796     public function getCategoryId()
00797     {
00798         if ( $this->_sCategoryId == null && ( $sCatId = oxConfig::getParameter( 'cnid' ) ) ) {
00799             $this->_sCategoryId = $sCatId;
00800         }
00801 
00802         return $this->_sCategoryId;
00803     }
00804 
00812     public function setCategoryId( $sCategoryId )
00813     {
00814         $this->_sCategoryId = $sCategoryId;
00815     }
00816 
00822     public function getErrorDestination()
00823     {
00824     }
00825 
00832     public function getActionClassName()
00833     {
00834         return $this->getClassName();
00835     }
00836 
00842     public function isConnectedWithFb()
00843     {
00844         $myConfig = $this->getConfig();
00845 
00846         if ( $myConfig->getConfigParam( "bl_showFbConnect" ) ) {
00847             $oFb = oxFb::getInstance();
00848             return $oFb->isConnected();
00849         }
00850 
00851         return false;
00852     }
00853 
00859     public function getFbUserId()
00860     {
00861         if ( $this->getConfig()->getConfigParam( "bl_showFbConnect" ) ) {
00862             $oFb = oxFb::getInstance();
00863             return $oFb->getUser();
00864         }
00865     }
00866 
00873     public function showFbConnectToAccountMsg()
00874     {
00875         if ( $this->getConfig()->getParameter( "fblogin" ) ) {
00876             if ( !$this->getUser() || ($this->getUser() && oxSession::getVar( '_blFbUserIdUpdated' ) ) ) {
00877                 return true;
00878             } else {
00879                 return false;
00880             }
00881         }
00882 
00883         return false;
00884     }
00885 
00891     public function isMall()
00892     {
00893             return false;
00894     }
00895 
00896 }