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 $_sCharSet = null;
00090 
00095     protected $_sVersion = null;
00096 
00101     protected $_blDemoVersion = null;
00102 
00107     protected $_blDemoShop = null;
00108 
00113     protected $_iNewsStatus = null;
00114 
00119     protected $_sShopLogo = null;
00120 
00126     public function init()
00127     {
00128         // setting current view class name
00129         $this->_sThisAction = strtolower( get_class( $this ) );
00130 
00131         if ( !$this->_blIsComponent ) {
00132             // assume that cached components does not affect this method ...
00133             $this->addGlobalParams();
00134         }
00135     }
00136 
00142     public function getViewId()
00143     {
00144     }
00145 
00151     public function render()
00152     {
00153         return $this->_sThisTemplate;
00154     }
00155 
00169     public function addGlobalParams( $oShop = null)
00170     {
00171         //deprecated template vars
00172 
00173         $this->_aViewData['isdtaus'] = true;
00174         $this->_aViewData['isstaffelpreis'] = true;
00175 
00176         // by default we allways display newsletter bar
00177         $this->_iNewsStatus = 1;
00178 
00179         $this->_aViewData['charset']       = $this->getCharSet();
00180         $this->_aViewData['version']       = $this->getShopVersion();
00181         $this->_aViewData['edition']       = $this->getShopEdition();
00182         $this->_aViewData['fulledition']   = $this->getShopFullEdition();
00183         $this->_aViewData['isdemoversion'] = $this->isDemoVersion();
00184 
00185 
00186         // set additional params
00187         $this->_aViewData["additionalparams"] = $this->getAdditionalParams();
00188 
00189         // assigning shop to view config ..
00190         $oViewConf = $this->getViewConfig();
00191         if ( $oShop ) {
00192             $oViewConf->setViewShop( $oShop, $this->_aViewData );
00193         }
00194 
00195         //sending all view to smarty
00196         $this->_aViewData['oView'] = $this;
00197         $this->_aViewData['oViewConf'] = $this->getViewConfig();
00198 
00199         // @deprecated
00200         $this->_aViewData['shop'] = $this->getViewConfig();
00201 
00202         return $oViewConf;
00203     }
00204 
00213     public function addTplParam( $sPara, $sValue )
00214     {
00215         $this->_aViewData[$sPara] = $sValue;
00216     }
00217 
00229     protected function _setAdditionalParams()
00230     {
00231         $this->getAdditionalParams();
00232     }
00233 
00239     public function getViewConfig()
00240     {
00241         if ( $this->_oViewConf === null ) {
00242             $this->_oViewConf = oxNew( 'oxViewConfig' );
00243         }
00244 
00245         return $this->_oViewConf;
00246     }
00247 
00253     public function getTemplateName()
00254     {
00255         return $this->_sThisTemplate;
00256     }
00257 
00265     public function setClassName( $sClassName )
00266     {
00267         $this->_sClass = $sClassName;
00268     }
00269 
00275     public function getClassName()
00276     {
00277         return $this->_sClass;
00278     }
00279 
00287     public function setFncName( $sFncName )
00288     {
00289         $this->_sFnc = $sFncName;
00290     }
00291 
00297     public function getFncName()
00298     {
00299         return $this->_sFnc;
00300     }
00301 
00309     public function setViewData( $aViewData = null )
00310     {
00311         $this->_aViewData = $aViewData;
00312     }
00313 
00319     public function getViewData()
00320     {
00321         return $this->_aViewData;
00322     }
00323 
00331     public function getViewDataElement( $sParamId = null )
00332     {
00333         if ( $sParamId && isset( $this->_aViewData[$sParamId] ) ) {
00334             return $this->_aViewData[$sParamId];
00335         }
00336     }
00337 
00345     public function setClassLocation( $sClassLocation = null )
00346     {
00347         $this->_sClassLocation = $sClassLocation;
00348     }
00354     public function getClassLocation()
00355     {
00356         return $this->_sClassLocation;
00357     }
00358 
00366     public function setThisAction( $sThisAction = null )
00367     {
00368         $this->_sThisAction = $sThisAction;
00369     }
00370 
00376     public function getThisAction()
00377     {
00378         return $this->_sThisAction;
00379     }
00380 
00388     public function setParent( $oParent = null )
00389     {
00390         $this->_oParent = $oParent;
00391     }
00392 
00398     public function getParent()
00399     {
00400         return $this->_oParent;
00401     }
00402 
00410     public function setIsComponent( $blIsComponent = null )
00411     {
00412         $this->_blIsComponent = $blIsComponent;
00413     }
00414 
00420     public function getIsComponent()
00421     {
00422         return $this->_blIsComponent;
00423     }
00424 
00435     public function executeFunction( $sFunction )
00436     {
00437         $sNewAction = null;
00438 
00439         // execute
00440         if ( $sFunction && !self::$_blExecuted ) {
00441             if ( method_exists( $this, $sFunction ) ) {
00442 
00443 
00444                 $sNewAction = $this->$sFunction();
00445                 self::$_blExecuted = true;
00446             }
00447 
00448             // was not executed on any level ?
00449             if ( !$this->_blIsComponent && !self::$_blExecuted ) {
00450                 $oEx = oxNew( 'oxSystemComponentException' );
00451                 $oEx->setMessage( 'EXCEPTION_SYSTEMCOMPONENT_FUNCTIONNOTFOUND' );
00452                 $oEx->setComponent( $sFunction );
00453                 throw $oEx;
00454             }
00455         }
00456 
00457         $this->_executeNewAction( $sNewAction );
00458     }
00459 
00470     protected function _executeNewAction( $sNewAction )
00471     {
00472         if ( $sNewAction ) {
00473             $myConfig  = $this->getConfig();
00474 
00475             // page parameters is the part which goes after '?'
00476             $aParams = explode( '?', $sNewAction );
00477 
00478             // action parameters is the part before '?'
00479             $sPageParams = isset( $aParams[1] )?$aParams[1]:null;
00480 
00481             // looking for function name
00482             $aParams    = explode( '/', $aParams[0] );
00483             $sClassName = $aParams[0];
00484 
00485             // looking for component name
00486             $aParams    = explode( '@', $aParams[0] );
00487             $sCmpName   = ( count( $aParams ) > 1 )?$aParams[0]:null;
00488             $sClassName = ( $sCmpName !== null )?$aParams[1]:$sClassName;
00489 
00490             // building redirect path ...
00491             $sHeader  = ( $sClassName )?"cl=$sClassName&":'';  // adding view name
00492             $sHeader .= ( $sPageParams )?"$sPageParams&":'';   // adding page params
00493             $sHeader .= $this->getSession()->sid();       // adding session Id
00494 
00495             // choosing URL to redirect
00496             $sURL = $myConfig->isSsl()?$myConfig->getSslShopUrl():$myConfig->getShopUrl();
00497 
00498             // different redirect URL in SEO mode
00499             if ( $this->isAdmin() ) {
00500                 $sURL .= $myConfig->getConfigParam( 'sAdminDir' ) . '/';
00501             }
00502 
00503             $sURL = "{$sURL}index.php?{$sHeader}";
00504 
00505             //#M341 do not add redirect parameter
00506             oxUtils::getInstance()->redirect( $sURL, (bool) oxConfig::getParameter( 'redirected' ) );
00507         }
00508     }
00509 
00515     public function getAdditionalParams()
00516     {
00517         return '';
00518     }
00519 
00525     public function getTrustedShopId()
00526     {
00527         if ( $this->_sTrustedShopId == null && ( $aTrustedShopIds = $this->getConfig()->getConfigParam( 'iShopID_TrustedShops' ) ) ) {
00528             $iLangId = (int) oxLang::getInstance()->getBaseLanguage();
00529             // compatibility to old data
00530             if ( !is_array( $aTrustedShopIds ) && $iLangId == 0 ) {
00531                 $this->_sTrustedShopId = $aTrustedShopIds;
00532             }
00533             if ( is_array( $aTrustedShopIds ) ) {
00534                 $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
00535             }
00536         }
00537         return $this->_sTrustedShopId;
00538     }
00539 
00545     public function getCharSet()
00546     {
00547         if ( $this->_sCharSet == null ) {
00548             $this->_sCharSet = oxLang::getInstance()->translateString( 'charset' );
00549         }
00550         return $this->_sCharSet;
00551     }
00552 
00558     public function getShopVersion()
00559     {
00560         if ( $this->_sVersion == null ) {
00561             $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
00562         }
00563         return $this->_sVersion;
00564     }
00565 
00571     public function getShopEdition()
00572     {
00573         return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
00574     }
00575 
00581     public function getShopFullEdition()
00582     {
00583         $sEdition = $this->getShopEdition();
00584         $sFullEdition = "Community Edition";
00585         if ( $sEdition == "PE" ) {
00586             $sFullEdition = "Professional Edition";
00587         }
00588 
00589         if ( $sEdition == "EE" ) {
00590             $sFullEdition = "Enterprise Edition";
00591         }
00592 
00593         return $sFullEdition;
00594     }
00595 
00596 
00602     public function isDemoVersion()
00603     {
00604         if ( $this->_blDemoVersion == null ) {
00605             $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
00606         }
00607         return $this->_blDemoVersion;
00608     }
00609 
00615     public function isDemoShop()
00616     {
00617         if ( $this->_blDemoShop == null ) {
00618             $this->_blDemoShop = $this->getConfig()->isDemoShop();
00619         }
00620         return $this->_blDemoShop;
00621     }
00622 
00628     public function showNewsletter()
00629     {
00630         if ( $this->_iNewsStatus === null) {
00631             return 1;
00632         }
00633         return $this->_iNewsStatus;
00634     }
00635 
00643     public function setShowNewsletter( $blShow )
00644     {
00645         $this->_iNewsStatus = $blShow;
00646     }
00647 
00653     public function getShopLogo()
00654     {
00655         return $this->_sShopLogo;
00656     }
00657 
00665     public function setShopLogo( $sLogo )
00666     {
00667         $this->_sShopLogo = $sLogo;
00668     }
00669 }

Generated on Wed Apr 22 12:26:32 2009 for OXID eShop CE by  doxygen 1.5.5