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     protected $_sCategoryId = null;
00127 
00132     protected $_oClickCat = null;
00133 
00139     public function init()
00140     {
00141         // setting current view class name
00142         $this->_sThisAction = strtolower( get_class( $this ) );
00143 
00144         if ( !$this->_blIsComponent ) {
00145             // assume that cached components does not affect this method ...
00146             $this->addGlobalParams();
00147         }
00148     }
00149 
00155     public function getViewId()
00156     {
00157     }
00158 
00164     public function render()
00165     {
00166         return $this->_sThisTemplate;
00167     }
00168 
00182     public function addGlobalParams( $oShop = null)
00183     {
00184         //deprecated template vars
00185 
00186         $this->_aViewData['isdtaus'] = true;
00187         $this->_aViewData['isstaffelpreis'] = true;
00188 
00189         // by default we allways display newsletter bar
00190         $this->_iNewsStatus = 1;
00191 
00192         $this->_aViewData['charset']       = $this->getCharSet();
00193         $this->_aViewData['version']       = $this->getShopVersion();
00194         $this->_aViewData['revision']      = $this->getRevision();
00195         $this->_aViewData['edition']       = $this->getShopEdition();
00196         $this->_aViewData['fulledition']   = $this->getShopFullEdition();
00197         $this->_aViewData['isdemoversion'] = $this->isDemoVersion();
00198 
00199 
00200         // set additional params
00201         $this->_aViewData["additionalparams"] = $this->getAdditionalParams();
00202 
00203         // assigning shop to view config ..
00204         $oViewConf = $this->getViewConfig();
00205         if ( $oShop ) {
00206             $oViewConf->setViewShop( $oShop, $this->_aViewData );
00207         }
00208 
00209         //sending all view to smarty
00210         $this->_aViewData['oView'] = $this;
00211         $this->_aViewData['oViewConf'] = $this->getViewConfig();
00212 
00213         // @deprecated
00214         $this->_aViewData['shop'] = $this->getViewConfig();
00215 
00216         return $oViewConf;
00217     }
00218 
00227     public function addTplParam( $sPara, $sValue )
00228     {
00229         $this->_aViewData[$sPara] = $sValue;
00230     }
00231 
00243     protected function _setAdditionalParams()
00244     {
00245         $this->getAdditionalParams();
00246     }
00247 
00253     public function getViewConfig()
00254     {
00255         if ( $this->_oViewConf === null ) {
00256             $this->_oViewConf = oxNew( 'oxViewConfig' );
00257         }
00258 
00259         return $this->_oViewConf;
00260     }
00261 
00267     public function getTemplateName()
00268     {
00269         return $this->_sThisTemplate;
00270     }
00271 
00279     public function setClassName( $sClassName )
00280     {
00281         $this->_sClass = $sClassName;
00282     }
00283 
00289     public function getClassName()
00290     {
00291         return $this->_sClass;
00292     }
00293 
00301     public function setFncName( $sFncName )
00302     {
00303         $this->_sFnc = $sFncName;
00304     }
00305 
00311     public function getFncName()
00312     {
00313         return $this->_sFnc;
00314     }
00315 
00323     public function setViewData( $aViewData = null )
00324     {
00325         $this->_aViewData = $aViewData;
00326     }
00327 
00333     public function getViewData()
00334     {
00335         return $this->_aViewData;
00336     }
00337 
00345     public function getViewDataElement( $sParamId = null )
00346     {
00347         if ( $sParamId && isset( $this->_aViewData[$sParamId] ) ) {
00348             return $this->_aViewData[$sParamId];
00349         }
00350     }
00351 
00359     public function setClassLocation( $sClassLocation = null )
00360     {
00361         $this->_sClassLocation = $sClassLocation;
00362     }
00368     public function getClassLocation()
00369     {
00370         return $this->_sClassLocation;
00371     }
00372 
00380     public function setThisAction( $sThisAction = null )
00381     {
00382         $this->_sThisAction = $sThisAction;
00383     }
00384 
00390     public function getThisAction()
00391     {
00392         return $this->_sThisAction;
00393     }
00394 
00402     public function setParent( $oParent = null )
00403     {
00404         $this->_oParent = $oParent;
00405     }
00406 
00412     public function getParent()
00413     {
00414         return $this->_oParent;
00415     }
00416 
00424     public function setIsComponent( $blIsComponent = null )
00425     {
00426         $this->_blIsComponent = $blIsComponent;
00427     }
00428 
00434     public function getIsComponent()
00435     {
00436         return $this->_blIsComponent;
00437     }
00438 
00449     public function executeFunction( $sFunction )
00450     {
00451         $sNewAction = null;
00452 
00453         // execute
00454         if ( $sFunction && !self::$_blExecuted ) {
00455             if ( method_exists( $this, $sFunction ) ) {
00456 
00457 
00458                 $sNewAction = $this->$sFunction();
00459                 self::$_blExecuted = true;
00460             }
00461 
00462             // was not executed on any level ?
00463             if ( !$this->_blIsComponent && !self::$_blExecuted ) {
00464                 $oEx = oxNew( 'oxSystemComponentException' );
00465                 $oEx->setMessage( 'EXCEPTION_SYSTEMCOMPONENT_FUNCTIONNOTFOUND' );
00466                 $oEx->setComponent( $sFunction );
00467                 throw $oEx;
00468             }
00469         }
00470 
00471         $this->_executeNewAction( $sNewAction );
00472     }
00473 
00484     protected function _executeNewAction( $sNewAction )
00485     {
00486         if ( $sNewAction ) {
00487             $myConfig  = $this->getConfig();
00488 
00489             // page parameters is the part which goes after '?'
00490             $aParams = explode( '?', $sNewAction );
00491 
00492             // action parameters is the part before '?'
00493             $sPageParams = isset( $aParams[1] )?$aParams[1]:null;
00494 
00495             // looking for function name
00496             $aParams    = explode( '/', $aParams[0] );
00497             $sClassName = $aParams[0];
00498 
00499             // looking for component name
00500             $aParams    = explode( '@', $aParams[0] );
00501             $sCmpName   = ( count( $aParams ) > 1 )?$aParams[0]:null;
00502             $sClassName = ( $sCmpName !== null )?$aParams[1]:$sClassName;
00503 
00504             // building redirect path ...
00505             $sHeader  = ( $sClassName )?"cl=$sClassName&":'';  // adding view name
00506             $sHeader .= ( $sPageParams )?"$sPageParams&":'';   // adding page params
00507             $sHeader .= $this->getSession()->sid();       // adding session Id
00508 
00509             // choosing URL to redirect
00510             $sURL = $myConfig->isSsl()?$myConfig->getSslShopUrl():$myConfig->getShopUrl();
00511 
00512             // different redirect URL in SEO mode
00513             if ( $this->isAdmin() ) {
00514                 $sURL .= $myConfig->getConfigParam( 'sAdminDir' ) . '/';
00515             }
00516 
00517             $sURL = "{$sURL}index.php?{$sHeader}";
00518 
00519             //#M341 do not add redirect parameter
00520             oxUtils::getInstance()->redirect( $sURL, (bool) oxConfig::getParameter( 'redirected' ) );
00521         }
00522     }
00523 
00529     public function getAdditionalParams()
00530     {
00531         return '';
00532     }
00533 
00539     public function getTrustedShopId()
00540     {
00541         if ( $this->_sTrustedShopId == null && ( $aTrustedShopIds = $this->getConfig()->getConfigParam( 'iShopID_TrustedShops' ) ) ) {
00542             $this->_sTrustedShopId = false;
00543             $iLangId = (int) oxLang::getInstance()->getBaseLanguage();
00544             // compatibility to old data
00545             if ( !is_array( $aTrustedShopIds ) && $iLangId == 0 ) {
00546                 $this->_sTrustedShopId = $aTrustedShopIds;
00547             }
00548             if ( is_array( $aTrustedShopIds ) ) {
00549                 $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
00550             }
00551             if ( strlen( $this->_sTrustedShopId ) != 33 || substr( $this->_sTrustedShopId, 0, 1 ) != 'X' ) {
00552                 $this->_sTrustedShopId = false;
00553             }
00554         }
00555         return $this->_sTrustedShopId;
00556     }
00557 
00563     public function getCharSet()
00564     {
00565         if ( $this->_sCharSet == null ) {
00566             $this->_sCharSet = oxLang::getInstance()->translateString( 'charset' );
00567         }
00568         return $this->_sCharSet;
00569     }
00570 
00576     public function getShopVersion()
00577     {
00578         if ( $this->_sVersion == null ) {
00579             $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
00580         }
00581         return $this->_sVersion;
00582     }
00583 
00589     public function getShopEdition()
00590     {
00591         return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
00592     }
00593 
00599     public function getRevision()
00600     {
00601         return $this->getConfig()->getRevision();
00602     }
00603 
00609     public function getShopFullEdition()
00610     {
00611         $sEdition = $this->getShopEdition();
00612         $sFullEdition = "Community Edition";
00613         if ( $sEdition == "PE" ) {
00614             $sFullEdition = "Professional Edition";
00615         }
00616 
00617         if ( $sEdition == "EE" ) {
00618             $sFullEdition = "Enterprise Edition";
00619         }
00620 
00621         return $sFullEdition;
00622     }
00623 
00624 
00630     public function isDemoVersion()
00631     {
00632         if ( $this->_blDemoVersion == null ) {
00633             $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
00634         }
00635         return $this->_blDemoVersion;
00636     }
00637 
00643     public function isDemoShop()
00644     {
00645         if ( $this->_blDemoShop == null ) {
00646             $this->_blDemoShop = $this->getConfig()->isDemoShop();
00647         }
00648         return $this->_blDemoShop;
00649     }
00650 
00656     public function showNewsletter()
00657     {
00658         if ( $this->_iNewsStatus === null) {
00659             return 1;
00660         }
00661         return $this->_iNewsStatus;
00662     }
00663 
00671     public function setShowNewsletter( $blShow )
00672     {
00673         $this->_iNewsStatus = $blShow;
00674     }
00675 
00681     public function getShopLogo()
00682     {
00683         return $this->_sShopLogo;
00684     }
00685 
00693     public function setShopLogo( $sLogo )
00694     {
00695         $this->_sShopLogo = $sLogo;
00696     }
00697 
00705     public function getActCategory()
00706     {
00707         // if active category is not set yet - trying to load it from request params
00708         // this may be usefull when category component was unable to load active category
00709         // and we still need some object to mount navigation info
00710         if ( $this->_oClickCat === null ) {
00711 
00712             $this->_oClickCat = false;
00713             $oCategory = oxNew( 'oxcategory' );
00714             if ( $oCategory->load( $this->getCategoryId() ) ) {
00715                 $this->_oClickCat = $oCategory;
00716             }
00717         }
00718 
00719         return $this->_oClickCat;
00720     }
00721 
00729     public function setActCategory( $oCategory )
00730     {
00731         $this->_oClickCat = $oCategory;
00732     }
00733 
00739     public function getCategoryId()
00740     {
00741         if ( $this->_sCategoryId == null && ( $sCatId = oxConfig::getParameter( 'cnid' ) ) ) {
00742             $this->_sCategoryId = $sCatId;
00743         }
00744 
00745         return $this->_sCategoryId;
00746     }
00747 
00755     public function setCategoryId( $sCategoryId )
00756     {
00757         $this->_sCategoryId = $sCategoryId;
00758     }
00759 
00765     public function getErrorDestination()
00766     {
00767     }
00768 }

Generated on Tue Sep 29 16:45:16 2009 for OXID eShop CE by  doxygen 1.5.5