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     public function init()
00146     {
00147         // setting current view class name
00148         $this->_sThisAction = strtolower( get_class( $this ) );
00149 
00150         if ( !$this->_blIsComponent ) {
00151             // assume that cached components does not affect this method ...
00152             $this->addGlobalParams();
00153         }
00154     }
00155 
00161     public function getViewId()
00162     {
00163     }
00164 
00170     public function render()
00171     {
00172         return $this->_sThisTemplate;
00173     }
00174 
00188     public function addGlobalParams( $oShop = null)
00189     {
00190         //deprecated template vars
00191 
00192         $this->_aViewData['isdtaus'] = true;
00193         $this->_aViewData['isstaffelpreis'] = true;
00194         $this->_aViewData['belboon'] = $this->getBelboonParam();
00195 
00196         // by default we allways display newsletter bar
00197         $this->_iNewsStatus = 1;
00198 
00199         $this->_aViewData['charset']       = $this->getCharSet();
00200         $this->_aViewData['version']       = $this->getShopVersion();
00201         $this->_aViewData['revision']      = $this->getRevision();
00202         $this->_aViewData['edition']       = $this->getShopEdition();
00203         $this->_aViewData['fulledition']   = $this->getShopFullEdition();
00204         $this->_aViewData['isdemoversion'] = $this->isDemoVersion();
00205 
00206 
00207         // set additional params
00208         $this->_aViewData["additionalparams"] = $this->getAdditionalParams();
00209 
00210         // assigning shop to view config ..
00211         $oViewConf = $this->getViewConfig();
00212         if ( $oShop ) {
00213             $oViewConf->setViewShop( $oShop, $this->_aViewData );
00214         }
00215 
00216         //sending all view to smarty
00217         $this->_aViewData['oView'] = $this;
00218         $this->_aViewData['oViewConf'] = $this->getViewConfig();
00219 
00220         // @deprecated
00221         $this->_aViewData['shop'] = $this->getViewConfig();
00222 
00223         return $oViewConf;
00224     }
00225 
00234     public function addTplParam( $sPara, $sValue )
00235     {
00236         $this->_aViewData[$sPara] = $sValue;
00237     }
00238 
00250     protected function _setAdditionalParams()
00251     {
00252         $this->getAdditionalParams();
00253     }
00254 
00260     public function getBelboonParam()
00261     {
00262         if ( $sBelboon = oxSession::getVar( 'belboon' ) ) {
00263             return $sBelboon;
00264         }
00265         if ( ( $sBelboon = oxConfig::getParameter( 'belboon' ) ) ) {
00266             oxSession::setVar( 'belboon', $sBelboon );
00267         }
00268 
00269         return $sBelboon;
00270     }
00271 
00277     public function getViewConfig()
00278     {
00279         if ( $this->_oViewConf === null ) {
00280             $this->_oViewConf = oxNew( 'oxViewConfig' );
00281         }
00282 
00283         return $this->_oViewConf;
00284     }
00285 
00291     public function getTemplateName()
00292     {
00293         return $this->_sThisTemplate;
00294     }
00295 
00303     public function setClassName( $sClassName )
00304     {
00305         $this->_sClass = $sClassName;
00306     }
00307 
00313     public function getClassName()
00314     {
00315         return $this->_sClass;
00316     }
00317 
00325     public function setFncName( $sFncName )
00326     {
00327         $this->_sFnc = $sFncName;
00328     }
00329 
00335     public function getFncName()
00336     {
00337         return $this->_sFnc;
00338     }
00339 
00347     public function setViewData( $aViewData = null )
00348     {
00349         $this->_aViewData = $aViewData;
00350     }
00351 
00357     public function getViewData()
00358     {
00359         return $this->_aViewData;
00360     }
00361 
00369     public function getViewDataElement( $sParamId = null )
00370     {
00371         if ( $sParamId && isset( $this->_aViewData[$sParamId] ) ) {
00372             return $this->_aViewData[$sParamId];
00373         }
00374     }
00375 
00383     public function setClassLocation( $sClassLocation = null )
00384     {
00385         $this->_sClassLocation = $sClassLocation;
00386     }
00392     public function getClassLocation()
00393     {
00394         return $this->_sClassLocation;
00395     }
00396 
00404     public function setThisAction( $sThisAction = null )
00405     {
00406         $this->_sThisAction = $sThisAction;
00407     }
00408 
00414     public function getThisAction()
00415     {
00416         return $this->_sThisAction;
00417     }
00418 
00426     public function setParent( $oParent = null )
00427     {
00428         $this->_oParent = $oParent;
00429     }
00430 
00436     public function getParent()
00437     {
00438         return $this->_oParent;
00439     }
00440 
00448     public function setIsComponent( $blIsComponent = null )
00449     {
00450         $this->_blIsComponent = $blIsComponent;
00451     }
00452 
00458     public function getIsComponent()
00459     {
00460         return $this->_blIsComponent;
00461     }
00462 
00473     public function executeFunction( $sFunction )
00474     {
00475         // execute
00476         if ( $sFunction && !self::$_blExecuted ) {
00477             if ( method_exists( $this, $sFunction ) ) {
00478 
00479 
00480                 $sNewAction = $this->$sFunction();
00481                 self::$_blExecuted = true;
00482 
00483                 if (isset($sNewAction)) {
00484                     $this->_executeNewAction( $sNewAction );
00485                 }
00486             } else {
00487                 // was not executed on any level ?
00488                 if ( !$this->_blIsComponent ) {
00489                     $oEx = oxNew( 'oxSystemComponentException' );
00490                     $oEx->setMessage( 'EXCEPTION_SYSTEMCOMPONENT_FUNCTIONNOTFOUND' );
00491                     $oEx->setComponent( $sFunction );
00492                     throw $oEx;
00493                 }
00494             }
00495         }
00496     }
00497 
00507     protected function _executeNewAction( $sNewAction )
00508     {
00509         if ( $sNewAction ) {
00510             $myConfig  = $this->getConfig();
00511 
00512             // page parameters is the part which goes after '?'
00513             $aParams = explode( '?', $sNewAction );
00514 
00515             // action parameters is the part before '?'
00516             $sPageParams = isset( $aParams[1] )?$aParams[1]:null;
00517 
00518             // looking for function name
00519             $aParams    = explode( '/', $aParams[0] );
00520             $sClassName = $aParams[0];
00521 
00522             // building redirect path ...
00523             $sHeader  = ( $sClassName )?"cl=$sClassName&":'';  // adding view name
00524             $sHeader .= ( $sPageParams )?"$sPageParams&":'';   // adding page params
00525             $sHeader .= $this->getSession()->sid();            // adding session Id
00526 
00527             $sUrl = $myConfig->getCurrentShopUrl($this->isAdmin());
00528 
00529             $sUrl = "{$sUrl}index.php?{$sHeader}";
00530 
00531             $sUrl = oxUtilsUrl::getInstance()->processUrl($sUrl);
00532 
00533             //#M341 do not add redirect parameter
00534             oxUtils::getInstance()->redirect( $sUrl, (bool) oxConfig::getParameter( 'redirected' ) );
00535         }
00536     }
00537 
00543     public function getAdditionalParams()
00544     {
00545         return oxUtilsUrl::getInstance()->processUrl( '', false );
00546     }
00547 
00553     public function getTrustedShopId()
00554     {
00555         if ( $this->_sTrustedShopId == null ) {
00556             $this->_sTrustedShopId = false;
00557             $oConfig = $this->getConfig();
00558             $aTsType   = $oConfig->getConfigParam( 'tsSealType' );
00559             $sTsActive = $oConfig->getConfigParam( 'tsSealActive' );
00560             $aTrustedShopIds = $oConfig->getConfigParam( 'iShopID_TrustedShops' );
00561             $iLangId = (int) oxLang::getInstance()->getBaseLanguage();
00562             if ( $sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'CLASSIC' ) {
00563                 // compatibility to old data
00564                 if ( !is_array( $aTrustedShopIds ) && $iLangId == 0 ) {
00565                     $this->_sTrustedShopId = $aTrustedShopIds;
00566                 }
00567                 if ( is_array( $aTrustedShopIds ) ) {
00568                     $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
00569                 }
00570                 if ( strlen( $this->_sTrustedShopId ) != 33 || substr( $this->_sTrustedShopId, 0, 1 ) != 'X' ) {
00571                     $this->_sTrustedShopId = false;
00572                 }
00573             }
00574         }
00575         return $this->_sTrustedShopId;
00576     }
00577 
00583     public function getTSExcellenceId()
00584     {
00585         if ( $this->_sTSExcellenceId == null ) {
00586             $this->_sTSExcellenceId = false;
00587             $oConfig   = $this->getConfig();
00588             $aTsType   = $oConfig->getConfigParam( 'tsSealType' );
00589             $sTsActive = $oConfig->getConfigParam( 'tsSealActive' );
00590             $aTrustedShopIds = $oConfig->getConfigParam( 'iShopID_TrustedShops' );
00591             $iLangId = (int) oxLang::getInstance()->getBaseLanguage();
00592             if ( $sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'EXCELLENCE' ) {
00593                 $this->_sTSExcellenceId = $aTrustedShopIds[$iLangId];
00594             }
00595         }
00596         return $this->_sTSExcellenceId;
00597     }
00598 
00604     public function getCharSet()
00605     {
00606         if ( $this->_sCharSet == null ) {
00607             $this->_sCharSet = oxLang::getInstance()->translateString( 'charset' );
00608         }
00609         return $this->_sCharSet;
00610     }
00611 
00617     public function getShopVersion()
00618     {
00619         if ( $this->_sVersion == null ) {
00620             $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
00621         }
00622         return $this->_sVersion;
00623     }
00624 
00630     public function getShopEdition()
00631     {
00632         return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
00633     }
00634 
00640     public function getRevision()
00641     {
00642         return $this->getConfig()->getRevision();
00643     }
00644 
00650     public function getShopFullEdition()
00651     {
00652         $sEdition = $this->getShopEdition();
00653         $sFullEdition = "Community Edition";
00654         if ( $sEdition == "PE" ) {
00655             $sFullEdition = "Professional Edition";
00656         }
00657 
00658         if ( $sEdition == "EE" ) {
00659             $sFullEdition = "Enterprise Edition";
00660         }
00661 
00662         return $sFullEdition;
00663     }
00664 
00665 
00671     public function isDemoVersion()
00672     {
00673         if ( $this->_blDemoVersion == null ) {
00674             $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
00675         }
00676         return $this->_blDemoVersion;
00677     }
00678 
00684     public function isDemoShop()
00685     {
00686         if ( $this->_blDemoShop == null ) {
00687             $this->_blDemoShop = $this->getConfig()->isDemoShop();
00688         }
00689         return $this->_blDemoShop;
00690     }
00691 
00697     public function showNewsletter()
00698     {
00699         if ( $this->_iNewsStatus === null) {
00700             return 1;
00701         }
00702         return $this->_iNewsStatus;
00703     }
00704 
00712     public function setShowNewsletter( $blShow )
00713     {
00714         $this->_iNewsStatus = $blShow;
00715     }
00716 
00722     public function getShopLogo()
00723     {
00724         return $this->_sShopLogo;
00725     }
00726 
00734     public function setShopLogo( $sLogo )
00735     {
00736         $this->_sShopLogo = $sLogo;
00737     }
00738 
00746     public function getActCategory()
00747     {
00748         // if active category is not set yet - trying to load it from request params
00749         // this may be usefull when category component was unable to load active category
00750         // and we still need some object to mount navigation info
00751         if ( $this->_oClickCat === null ) {
00752 
00753             $this->_oClickCat = false;
00754             $oCategory = oxNew( 'oxcategory' );
00755             if ( $oCategory->load( $this->getCategoryId() ) ) {
00756                 $this->_oClickCat = $oCategory;
00757             }
00758         }
00759 
00760         return $this->_oClickCat;
00761     }
00762 
00770     public function setActCategory( $oCategory )
00771     {
00772         $this->_oClickCat = $oCategory;
00773     }
00774 
00780     public function getCategoryId()
00781     {
00782         if ( $this->_sCategoryId == null && ( $sCatId = oxConfig::getParameter( 'cnid' ) ) ) {
00783             $this->_sCategoryId = $sCatId;
00784         }
00785 
00786         return $this->_sCategoryId;
00787     }
00788 
00796     public function setCategoryId( $sCategoryId )
00797     {
00798         $this->_sCategoryId = $sCategoryId;
00799     }
00800 
00806     public function getErrorDestination()
00807     {
00808     }
00809 
00816     public function getActionClassName()
00817     {
00818         return $this->getClassName();
00819     }
00820 
00826     public function isConnectedWithFb()
00827     {
00828         $myConfig = $this->getConfig();
00829 
00830         if ( $myConfig->getConfigParam( "bl_showFbConnect" ) ) {
00831             $oFb = oxFb::getInstance();
00832             return $oFb->isConnected();
00833         }
00834 
00835         return false;
00836     }
00837 
00843     public function getFbUserId()
00844     {
00845         if ( $this->getConfig()->getConfigParam( "bl_showFbConnect" ) ) {
00846             $oFb = oxFb::getInstance();
00847             return $oFb->getUser();
00848         }
00849     }
00850 
00857     public function showFbConnectToAccountMsg()
00858     {
00859         if ( $this->getConfig()->getParameter( "fblogin" ) ) {
00860             if ( !$this->getUser() || ($this->getUser() && oxSession::getVar( '_blFbUserIdUpdated' ) ) ) {
00861                 return true;
00862             } else {
00863                 return false;
00864             }
00865         }
00866 
00867         return false;
00868     }
00869 }