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['revision']      = $this->getRevision();
00182         $this->_aViewData['edition']       = $this->getShopEdition();
00183         $this->_aViewData['fulledition']   = $this->getShopFullEdition();
00184         $this->_aViewData['isdemoversion'] = $this->isDemoVersion();
00185 
00186 
00187         // set additional params
00188         $this->_aViewData["additionalparams"] = $this->getAdditionalParams();
00189 
00190         // assigning shop to view config ..
00191         $oViewConf = $this->getViewConfig();
00192         if ( $oShop ) {
00193             $oViewConf->setViewShop( $oShop, $this->_aViewData );
00194         }
00195 
00196         //sending all view to smarty
00197         $this->_aViewData['oView'] = $this;
00198         $this->_aViewData['oViewConf'] = $this->getViewConfig();
00199 
00200         // @deprecated
00201         $this->_aViewData['shop'] = $this->getViewConfig();
00202 
00203         return $oViewConf;
00204     }
00205 
00214     public function addTplParam( $sPara, $sValue )
00215     {
00216         $this->_aViewData[$sPara] = $sValue;
00217     }
00218 
00230     protected function _setAdditionalParams()
00231     {
00232         $this->getAdditionalParams();
00233     }
00234 
00240     public function getViewConfig()
00241     {
00242         if ( $this->_oViewConf === null ) {
00243             $this->_oViewConf = oxNew( 'oxViewConfig' );
00244         }
00245 
00246         return $this->_oViewConf;
00247     }
00248 
00254     public function getTemplateName()
00255     {
00256         return $this->_sThisTemplate;
00257     }
00258 
00266     public function setClassName( $sClassName )
00267     {
00268         $this->_sClass = $sClassName;
00269     }
00270 
00276     public function getClassName()
00277     {
00278         return $this->_sClass;
00279     }
00280 
00288     public function setFncName( $sFncName )
00289     {
00290         $this->_sFnc = $sFncName;
00291     }
00292 
00298     public function getFncName()
00299     {
00300         return $this->_sFnc;
00301     }
00302 
00310     public function setViewData( $aViewData = null )
00311     {
00312         $this->_aViewData = $aViewData;
00313     }
00314 
00320     public function getViewData()
00321     {
00322         return $this->_aViewData;
00323     }
00324 
00332     public function getViewDataElement( $sParamId = null )
00333     {
00334         if ( $sParamId && isset( $this->_aViewData[$sParamId] ) ) {
00335             return $this->_aViewData[$sParamId];
00336         }
00337     }
00338 
00346     public function setClassLocation( $sClassLocation = null )
00347     {
00348         $this->_sClassLocation = $sClassLocation;
00349     }
00355     public function getClassLocation()
00356     {
00357         return $this->_sClassLocation;
00358     }
00359 
00367     public function setThisAction( $sThisAction = null )
00368     {
00369         $this->_sThisAction = $sThisAction;
00370     }
00371 
00377     public function getThisAction()
00378     {
00379         return $this->_sThisAction;
00380     }
00381 
00389     public function setParent( $oParent = null )
00390     {
00391         $this->_oParent = $oParent;
00392     }
00393 
00399     public function getParent()
00400     {
00401         return $this->_oParent;
00402     }
00403 
00411     public function setIsComponent( $blIsComponent = null )
00412     {
00413         $this->_blIsComponent = $blIsComponent;
00414     }
00415 
00421     public function getIsComponent()
00422     {
00423         return $this->_blIsComponent;
00424     }
00425 
00436     public function executeFunction( $sFunction )
00437     {
00438         $sNewAction = null;
00439 
00440         // execute
00441         if ( $sFunction && !self::$_blExecuted ) {
00442             if ( method_exists( $this, $sFunction ) ) {
00443 
00444 
00445                 $sNewAction = $this->$sFunction();
00446                 self::$_blExecuted = true;
00447             }
00448 
00449             // was not executed on any level ?
00450             if ( !$this->_blIsComponent && !self::$_blExecuted ) {
00451                 $oEx = oxNew( 'oxSystemComponentException' );
00452                 $oEx->setMessage( 'EXCEPTION_SYSTEMCOMPONENT_FUNCTIONNOTFOUND' );
00453                 $oEx->setComponent( $sFunction );
00454                 throw $oEx;
00455             }
00456         }
00457 
00458         $this->_executeNewAction( $sNewAction );
00459     }
00460 
00471     protected function _executeNewAction( $sNewAction )
00472     {
00473         if ( $sNewAction ) {
00474             $myConfig  = $this->getConfig();
00475 
00476             // page parameters is the part which goes after '?'
00477             $aParams = explode( '?', $sNewAction );
00478 
00479             // action parameters is the part before '?'
00480             $sPageParams = isset( $aParams[1] )?$aParams[1]:null;
00481 
00482             // looking for function name
00483             $aParams    = explode( '/', $aParams[0] );
00484             $sClassName = $aParams[0];
00485 
00486             // looking for component name
00487             $aParams    = explode( '@', $aParams[0] );
00488             $sCmpName   = ( count( $aParams ) > 1 )?$aParams[0]:null;
00489             $sClassName = ( $sCmpName !== null )?$aParams[1]:$sClassName;
00490 
00491             // building redirect path ...
00492             $sHeader  = ( $sClassName )?"cl=$sClassName&":'';  // adding view name
00493             $sHeader .= ( $sPageParams )?"$sPageParams&":'';   // adding page params
00494             $sHeader .= $this->getSession()->sid();       // adding session Id
00495 
00496             // choosing URL to redirect
00497             $sURL = $myConfig->isSsl()?$myConfig->getSslShopUrl():$myConfig->getShopUrl();
00498 
00499             // different redirect URL in SEO mode
00500             if ( $this->isAdmin() ) {
00501                 $sURL .= $myConfig->getConfigParam( 'sAdminDir' ) . '/';
00502             }
00503 
00504             $sURL = "{$sURL}index.php?{$sHeader}";
00505 
00506             //#M341 do not add redirect parameter
00507             oxUtils::getInstance()->redirect( $sURL, (bool) oxConfig::getParameter( 'redirected' ) );
00508         }
00509     }
00510 
00516     public function getAdditionalParams()
00517     {
00518         return '';
00519     }
00520 
00526     public function getTrustedShopId()
00527     {
00528         if ( $this->_sTrustedShopId == null && ( $aTrustedShopIds = $this->getConfig()->getConfigParam( 'iShopID_TrustedShops' ) ) ) {
00529             $this->_sTrustedShopId = false;
00530             $iLangId = (int) oxLang::getInstance()->getBaseLanguage();
00531             // compatibility to old data
00532             if ( !is_array( $aTrustedShopIds ) && $iLangId == 0 ) {
00533                 $this->_sTrustedShopId = $aTrustedShopIds;
00534             }
00535             if ( is_array( $aTrustedShopIds ) ) {
00536                 $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
00537             }
00538             if ( strlen( $this->_sTrustedShopId ) != 33 || substr( $this->_sTrustedShopId, 0, 1 ) != 'X' ) {
00539                 $this->_sTrustedShopId = false;
00540             }
00541         }
00542         return $this->_sTrustedShopId;
00543     }
00544 
00550     public function getCharSet()
00551     {
00552         if ( $this->_sCharSet == null ) {
00553             $this->_sCharSet = oxLang::getInstance()->translateString( 'charset' );
00554         }
00555         return $this->_sCharSet;
00556     }
00557 
00563     public function getShopVersion()
00564     {
00565         if ( $this->_sVersion == null ) {
00566             $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
00567         }
00568         return $this->_sVersion;
00569     }
00570 
00576     public function getShopEdition()
00577     {
00578         return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
00579     }
00580 
00586     public function getRevision()
00587     {
00588         return $this->getConfig()->getRevision();
00589     }
00590 
00596     public function getShopFullEdition()
00597     {
00598         $sEdition = $this->getShopEdition();
00599         $sFullEdition = "Community Edition";
00600         if ( $sEdition == "PE" ) {
00601             $sFullEdition = "Professional Edition";
00602         }
00603 
00604         if ( $sEdition == "EE" ) {
00605             $sFullEdition = "Enterprise Edition";
00606         }
00607 
00608         return $sFullEdition;
00609     }
00610 
00611 
00617     public function isDemoVersion()
00618     {
00619         if ( $this->_blDemoVersion == null ) {
00620             $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
00621         }
00622         return $this->_blDemoVersion;
00623     }
00624 
00630     public function isDemoShop()
00631     {
00632         if ( $this->_blDemoShop == null ) {
00633             $this->_blDemoShop = $this->getConfig()->isDemoShop();
00634         }
00635         return $this->_blDemoShop;
00636     }
00637 
00643     public function showNewsletter()
00644     {
00645         if ( $this->_iNewsStatus === null) {
00646             return 1;
00647         }
00648         return $this->_iNewsStatus;
00649     }
00650 
00658     public function setShowNewsletter( $blShow )
00659     {
00660         $this->_iNewsStatus = $blShow;
00661     }
00662 
00668     public function getShopLogo()
00669     {
00670         return $this->_sShopLogo;
00671     }
00672 
00680     public function setShopLogo( $sLogo )
00681     {
00682         $this->_sShopLogo = $sLogo;
00683     }
00684 }

Generated on Wed May 13 13:25:55 2009 for OXID eShop CE by  doxygen 1.5.5