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         $this->_aViewData['belboon'] = $this->getBelboonParam();
00189 
00190         // by default we allways display newsletter bar
00191         $this->_iNewsStatus = 1;
00192 
00193         $this->_aViewData['charset']       = $this->getCharSet();
00194         $this->_aViewData['version']       = $this->getShopVersion();
00195         $this->_aViewData['revision']      = $this->getRevision();
00196         $this->_aViewData['edition']       = $this->getShopEdition();
00197         $this->_aViewData['fulledition']   = $this->getShopFullEdition();
00198         $this->_aViewData['isdemoversion'] = $this->isDemoVersion();
00199 
00200 
00201         // set additional params
00202         $this->_aViewData["additionalparams"] = $this->getAdditionalParams();
00203 
00204         // assigning shop to view config ..
00205         $oViewConf = $this->getViewConfig();
00206         if ( $oShop ) {
00207             $oViewConf->setViewShop( $oShop, $this->_aViewData );
00208         }
00209 
00210         //sending all view to smarty
00211         $this->_aViewData['oView'] = $this;
00212         $this->_aViewData['oViewConf'] = $this->getViewConfig();
00213 
00214         // @deprecated
00215         $this->_aViewData['shop'] = $this->getViewConfig();
00216 
00217         return $oViewConf;
00218     }
00219 
00228     public function addTplParam( $sPara, $sValue )
00229     {
00230         $this->_aViewData[$sPara] = $sValue;
00231     }
00232 
00244     protected function _setAdditionalParams()
00245     {
00246         $this->getAdditionalParams();
00247     }
00248 
00254     public function getBelboonParam()
00255     {
00256         if ( $sBelboon = oxSession::getVar( 'belboon' ) ) {
00257             return $sBelboon;
00258         }
00259         if ( ( $sBelboon = oxConfig::getParameter( 'belboon' ) ) ) {
00260             oxSession::setVar( 'belboon', $sBelboon );
00261         }
00262 
00263         return $sBelboon;
00264     }
00265 
00271     public function getViewConfig()
00272     {
00273         if ( $this->_oViewConf === null ) {
00274             $this->_oViewConf = oxNew( 'oxViewConfig' );
00275         }
00276 
00277         return $this->_oViewConf;
00278     }
00279 
00285     public function getTemplateName()
00286     {
00287         return $this->_sThisTemplate;
00288     }
00289 
00297     public function setClassName( $sClassName )
00298     {
00299         $this->_sClass = $sClassName;
00300     }
00301 
00307     public function getClassName()
00308     {
00309         return $this->_sClass;
00310     }
00311 
00319     public function setFncName( $sFncName )
00320     {
00321         $this->_sFnc = $sFncName;
00322     }
00323 
00329     public function getFncName()
00330     {
00331         return $this->_sFnc;
00332     }
00333 
00341     public function setViewData( $aViewData = null )
00342     {
00343         $this->_aViewData = $aViewData;
00344     }
00345 
00351     public function getViewData()
00352     {
00353         return $this->_aViewData;
00354     }
00355 
00363     public function getViewDataElement( $sParamId = null )
00364     {
00365         if ( $sParamId && isset( $this->_aViewData[$sParamId] ) ) {
00366             return $this->_aViewData[$sParamId];
00367         }
00368     }
00369 
00377     public function setClassLocation( $sClassLocation = null )
00378     {
00379         $this->_sClassLocation = $sClassLocation;
00380     }
00386     public function getClassLocation()
00387     {
00388         return $this->_sClassLocation;
00389     }
00390 
00398     public function setThisAction( $sThisAction = null )
00399     {
00400         $this->_sThisAction = $sThisAction;
00401     }
00402 
00408     public function getThisAction()
00409     {
00410         return $this->_sThisAction;
00411     }
00412 
00420     public function setParent( $oParent = null )
00421     {
00422         $this->_oParent = $oParent;
00423     }
00424 
00430     public function getParent()
00431     {
00432         return $this->_oParent;
00433     }
00434 
00442     public function setIsComponent( $blIsComponent = null )
00443     {
00444         $this->_blIsComponent = $blIsComponent;
00445     }
00446 
00452     public function getIsComponent()
00453     {
00454         return $this->_blIsComponent;
00455     }
00456 
00467     public function executeFunction( $sFunction )
00468     {
00469         $sNewAction = null;
00470 
00471         // execute
00472         if ( $sFunction && !self::$_blExecuted ) {
00473             if ( method_exists( $this, $sFunction ) ) {
00474 
00475 
00476                 $sNewAction = $this->$sFunction();
00477                 self::$_blExecuted = true;
00478             }
00479 
00480             // was not executed on any level ?
00481             if ( !$this->_blIsComponent && !self::$_blExecuted ) {
00482                 $oEx = oxNew( 'oxSystemComponentException' );
00483                 $oEx->setMessage( 'EXCEPTION_SYSTEMCOMPONENT_FUNCTIONNOTFOUND' );
00484                 $oEx->setComponent( $sFunction );
00485                 throw $oEx;
00486             }
00487         }
00488 
00489         $this->_executeNewAction( $sNewAction );
00490     }
00491 
00501     protected function _executeNewAction( $sNewAction )
00502     {
00503         if ( $sNewAction ) {
00504             $myConfig  = $this->getConfig();
00505 
00506             // page parameters is the part which goes after '?'
00507             $aParams = explode( '?', $sNewAction );
00508 
00509             // action parameters is the part before '?'
00510             $sPageParams = isset( $aParams[1] )?$aParams[1]:null;
00511 
00512             // looking for function name
00513             $aParams    = explode( '/', $aParams[0] );
00514             $sClassName = $aParams[0];
00515 
00516             // building redirect path ...
00517             $sHeader  = ( $sClassName )?"cl=$sClassName&":'';  // adding view name
00518             $sHeader .= ( $sPageParams )?"$sPageParams&":'';   // adding page params
00519             $sHeader .= $this->getSession()->sid();            // adding session Id
00520 
00521             // choosing URL to redirect
00522             $sUrl = $myConfig->isSsl()?$myConfig->getSslShopUrl():$myConfig->getShopUrl();
00523 
00524             // different redirect URL in SEO mode
00525             if ( $this->isAdmin() ) {
00526                 $sUrl .= $myConfig->getConfigParam( 'sAdminDir' ) . '/';
00527             }
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 && ( $aTrustedShopIds = $this->getConfig()->getConfigParam( 'iShopID_TrustedShops' ) ) ) {
00556             $this->_sTrustedShopId = false;
00557             $iLangId = (int) oxLang::getInstance()->getBaseLanguage();
00558             // compatibility to old data
00559             if ( !is_array( $aTrustedShopIds ) && $iLangId == 0 ) {
00560                 $this->_sTrustedShopId = $aTrustedShopIds;
00561             }
00562             if ( is_array( $aTrustedShopIds ) ) {
00563                 $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
00564             }
00565             if ( strlen( $this->_sTrustedShopId ) != 33 || substr( $this->_sTrustedShopId, 0, 1 ) != 'X' ) {
00566                 $this->_sTrustedShopId = false;
00567             }
00568         }
00569         return $this->_sTrustedShopId;
00570     }
00571 
00577     public function getCharSet()
00578     {
00579         if ( $this->_sCharSet == null ) {
00580             $this->_sCharSet = oxLang::getInstance()->translateString( 'charset' );
00581         }
00582         return $this->_sCharSet;
00583     }
00584 
00590     public function getShopVersion()
00591     {
00592         if ( $this->_sVersion == null ) {
00593             $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
00594         }
00595         return $this->_sVersion;
00596     }
00597 
00603     public function getShopEdition()
00604     {
00605         return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
00606     }
00607 
00613     public function getRevision()
00614     {
00615         return $this->getConfig()->getRevision();
00616     }
00617 
00623     public function getShopFullEdition()
00624     {
00625         $sEdition = $this->getShopEdition();
00626         $sFullEdition = "Community Edition";
00627         if ( $sEdition == "PE" ) {
00628             $sFullEdition = "Professional Edition";
00629         }
00630 
00631         if ( $sEdition == "EE" ) {
00632             $sFullEdition = "Enterprise Edition";
00633         }
00634 
00635         return $sFullEdition;
00636     }
00637 
00638 
00644     public function isDemoVersion()
00645     {
00646         if ( $this->_blDemoVersion == null ) {
00647             $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
00648         }
00649         return $this->_blDemoVersion;
00650     }
00651 
00657     public function isDemoShop()
00658     {
00659         if ( $this->_blDemoShop == null ) {
00660             $this->_blDemoShop = $this->getConfig()->isDemoShop();
00661         }
00662         return $this->_blDemoShop;
00663     }
00664 
00670     public function showNewsletter()
00671     {
00672         if ( $this->_iNewsStatus === null) {
00673             return 1;
00674         }
00675         return $this->_iNewsStatus;
00676     }
00677 
00685     public function setShowNewsletter( $blShow )
00686     {
00687         $this->_iNewsStatus = $blShow;
00688     }
00689 
00695     public function getShopLogo()
00696     {
00697         return $this->_sShopLogo;
00698     }
00699 
00707     public function setShopLogo( $sLogo )
00708     {
00709         $this->_sShopLogo = $sLogo;
00710     }
00711 
00719     public function getActCategory()
00720     {
00721         // if active category is not set yet - trying to load it from request params
00722         // this may be usefull when category component was unable to load active category
00723         // and we still need some object to mount navigation info
00724         if ( $this->_oClickCat === null ) {
00725 
00726             $this->_oClickCat = false;
00727             $oCategory = oxNew( 'oxcategory' );
00728             if ( $oCategory->load( $this->getCategoryId() ) ) {
00729                 $this->_oClickCat = $oCategory;
00730             }
00731         }
00732 
00733         return $this->_oClickCat;
00734     }
00735 
00743     public function setActCategory( $oCategory )
00744     {
00745         $this->_oClickCat = $oCategory;
00746     }
00747 
00753     public function getCategoryId()
00754     {
00755         if ( $this->_sCategoryId == null && ( $sCatId = oxConfig::getParameter( 'cnid' ) ) ) {
00756             $this->_sCategoryId = $sCatId;
00757         }
00758 
00759         return $this->_sCategoryId;
00760     }
00761 
00769     public function setCategoryId( $sCategoryId )
00770     {
00771         $this->_sCategoryId = $sCategoryId;
00772     }
00773 
00779     public function getErrorDestination()
00780     {
00781     }
00782 }

Generated by  doxygen 1.6.2