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 
00434     public function executeFunction( $sFunction )
00435     {
00436         $sNewAction = null;
00437 
00438         // execute
00439         if ( $sFunction && !self::$_blExecuted ) {
00440             if ( method_exists( $this, $sFunction ) ) {
00441 
00442 
00443                 $sNewAction = $this->$sFunction();
00444                 self::$_blExecuted = true;
00445             }
00446 
00447             // was not executed on any level ?
00448             if ( !$this->_blIsComponent && !self::$_blExecuted ) {
00449                 $oEx = oxNew( 'oxSystemComponentException' );
00450                 $oEx->setMessage( 'EXCEPTION_SYSTEMCOMPONENT_FUNCTIONNOTFOUND' );
00451                 $oEx->setComponent( $sFunction );
00452                 throw $oEx;
00453             }
00454         }
00455 
00456         $this->_executeNewAction( $sNewAction );
00457     }
00458 
00469     protected function _executeNewAction( $sNewAction )
00470     {
00471         if ( $sNewAction ) {
00472             $myConfig  = $this->getConfig();
00473 
00474             // page parameters is the part which goes after '?'
00475             $aParams = explode( '?', $sNewAction );
00476 
00477             // action parameters is the part before '?'
00478             $sPageParams = isset( $aParams[1] )?$aParams[1]:null;
00479 
00480             // looking for function name
00481             $aParams    = explode( '/', $aParams[0] );
00482             $sClassName = $aParams[0];
00483 
00484             // looking for component name
00485             $aParams    = explode( '@', $aParams[0] );
00486             $sCmpName   = ( count( $aParams ) > 1 )?$aParams[0]:null;
00487             $sClassName = ( $sCmpName !== null )?$aParams[1]:$sClassName;
00488 
00489             // building redirect path ...
00490             $sHeader  = ( $sClassName )?"cl=$sClassName&":'';  // adding view name
00491             $sHeader .= ( $sPageParams )?"$sPageParams&":'';   // adding page params
00492             $sHeader .= $this->getSession()->sid();       // adding session Id
00493 
00494             // choosing URL to redirect
00495             $sURL = $myConfig->isSsl()?$myConfig->getSslShopUrl():$myConfig->getShopUrl();
00496 
00497             // different redirect URL in SEO mode
00498             if ( $this->isAdmin() ) {
00499                 $sURL .= $myConfig->getConfigParam( 'sAdminDir' ) . '/';
00500             }
00501 
00502             $sURL = "{$sURL}index.php?{$sHeader}";
00503 
00504             //#M341 do not add redirect parameter
00505             oxUtils::getInstance()->redirect( $sURL, (bool) oxConfig::getParameter( 'redirected' ) );
00506         }
00507     }
00508 
00514     public function getAdditionalParams()
00515     {
00516         return '';
00517     }
00518 
00524     public function getTrustedShopId()
00525     {
00526         if ( $this->_sTrustedShopId == null && ( $aTrustedShopIds = $this->getConfig()->getConfigParam( 'iShopID_TrustedShops' ) ) ) {
00527             $iLangId = (int) oxLang::getInstance()->getBaseLanguage();
00528             // compatibility to old data
00529             if ( !is_array( $aTrustedShopIds ) && $iLangId == 0 ) {
00530                 $this->_sTrustedShopId = $aTrustedShopIds;
00531             }
00532             if ( is_array( $aTrustedShopIds ) ) {
00533                 $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
00534             }
00535         }
00536         return $this->_sTrustedShopId;
00537     }
00538 
00544     public function getCharSet()
00545     {
00546         if ( $this->_sCharSet == null ) {
00547             $this->_sCharSet = oxLang::getInstance()->translateString( 'charset' );
00548         }
00549         return $this->_sCharSet;
00550     }
00551 
00557     public function getShopVersion()
00558     {
00559         if ( $this->_sVersion == null ) {
00560             $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
00561         }
00562         return $this->_sVersion;
00563     }
00564 
00570     public function getShopEdition()
00571     {
00572         return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
00573     }
00574 
00580     public function getShopFullEdition()
00581     {
00582         $sEdition = $this->getShopEdition();
00583         $sFullEdition = "Community Edition";
00584         if ($sEdition == "PE")
00585             $sFullEdition = "Professional Edition";
00586 
00587         if ($sEdition == "EE")
00588             $sFullEdition = "Enterprise Edition";
00589 
00590         return $sFullEdition;
00591     }
00592 
00593 
00599     public function isDemoVersion()
00600     {
00601         if ( $this->_blDemoVersion == null ) {
00602             $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
00603         }
00604         return $this->_blDemoVersion;
00605     }
00606 
00612     public function isDemoShop()
00613     {
00614         if ( $this->_blDemoShop == null ) {
00615             $this->_blDemoShop = $this->getConfig()->isDemoShop();
00616         }
00617         return $this->_blDemoShop;
00618     }
00619 
00625     public function showNewsletter()
00626     {
00627         if ( $this->_iNewsStatus === null) {
00628             return 1;
00629         }
00630         return $this->_iNewsStatus;
00631     }
00632 
00640     public function setShowNewsletter( $blShow )
00641     {
00642         $this->_iNewsStatus = $blShow;
00643     }
00644 
00650     public function getShopLogo()
00651     {
00652         return $this->_sShopLogo;
00653     }
00654 
00662     public function setShopLogo( $sLogo )
00663     {
00664         $this->_sShopLogo = $sLogo;
00665     }
00666 }

Generated on Tue Apr 21 15:45:45 2009 for OXID eShop CE by  doxygen 1.5.5