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 $_sTSExcellenceId = null;
00090 
00095     protected $_sCharSet = null;
00096 
00101     protected $_sVersion = null;
00102 
00107     protected $_blDemoVersion = null;
00108 
00113     protected $_blDemoShop = null;
00114 
00119     protected $_iNewsStatus = null;
00120 
00125     protected $_sShopLogo = null;
00126 
00132     protected $_sCategoryId = null;
00133 
00138     protected $_oClickCat = null;
00139 
00145     public function init()
00146     {
00147         // setting current view class name
00148         $this->_sThisAction = strtolower( get_class( $this ) );
00149 
00150         if ( !$this->_blIsComponent ) {
00151             // assume that cached components does not affect this method ...
00152             $this->addGlobalParams();
00153         }
00154     }
00155 
00161     public function getViewId()
00162     {
00163     }
00164 
00170     public function render()
00171     {
00172         return $this->_sThisTemplate;
00173     }
00174 
00188     public function addGlobalParams( $oShop = null)
00189     {
00190         //deprecated template vars
00191 
00192         $this->_aViewData['isdtaus'] = true;
00193         $this->_aViewData['isstaffelpreis'] = true;
00194         $this->_aViewData['belboon'] = $this->getBelboonParam();
00195 
00196         // by default we allways display newsletter bar
00197         $this->_iNewsStatus = 1;
00198 
00199         $this->_aViewData['charset']       = $this->getCharSet();
00200         $this->_aViewData['version']       = $this->getShopVersion();
00201         $this->_aViewData['revision']      = $this->getRevision();
00202         $this->_aViewData['edition']       = $this->getShopEdition();
00203         $this->_aViewData['fulledition']   = $this->getShopFullEdition();
00204         $this->_aViewData['isdemoversion'] = $this->isDemoVersion();
00205 
00206 
00207         // set additional params
00208         $this->_aViewData["additionalparams"] = $this->getAdditionalParams();
00209 
00210         // assigning shop to view config ..
00211         $oViewConf = $this->getViewConfig();
00212         if ( $oShop ) {
00213             $oViewConf->setViewShop( $oShop, $this->_aViewData );
00214         }
00215 
00216         //sending all view to smarty
00217         $this->_aViewData['oView'] = $this;
00218         $this->_aViewData['oViewConf'] = $this->getViewConfig();
00219 
00220         // @deprecated
00221         $this->_aViewData['shop'] = $this->getViewConfig();
00222 
00223         return $oViewConf;
00224     }
00225 
00234     public function addTplParam( $sPara, $sValue )
00235     {
00236         $this->_aViewData[$sPara] = $sValue;
00237     }
00238 
00250     protected function _setAdditionalParams()
00251     {
00252         $this->getAdditionalParams();
00253     }
00254 
00260     public function getBelboonParam()
00261     {
00262         if ( $sBelboon = oxSession::getVar( 'belboon' ) ) {
00263             return $sBelboon;
00264         }
00265         if ( ( $sBelboon = oxConfig::getParameter( 'belboon' ) ) ) {
00266             oxSession::setVar( 'belboon', $sBelboon );
00267         }
00268 
00269         return $sBelboon;
00270     }
00271 
00277     public function getViewConfig()
00278     {
00279         if ( $this->_oViewConf === null ) {
00280             $this->_oViewConf = oxNew( 'oxViewConfig' );
00281         }
00282 
00283         return $this->_oViewConf;
00284     }
00285 
00291     public function getTemplateName()
00292     {
00293         return $this->_sThisTemplate;
00294     }
00295 
00303     public function setClassName( $sClassName )
00304     {
00305         $this->_sClass = $sClassName;
00306     }
00307 
00313     public function getClassName()
00314     {
00315         return $this->_sClass;
00316     }
00317 
00325     public function setFncName( $sFncName )
00326     {
00327         $this->_sFnc = $sFncName;
00328     }
00329 
00335     public function getFncName()
00336     {
00337         return $this->_sFnc;
00338     }
00339 
00347     public function setViewData( $aViewData = null )
00348     {
00349         $this->_aViewData = $aViewData;
00350     }
00351 
00357     public function getViewData()
00358     {
00359         return $this->_aViewData;
00360     }
00361 
00369     public function getViewDataElement( $sParamId = null )
00370     {
00371         if ( $sParamId && isset( $this->_aViewData[$sParamId] ) ) {
00372             return $this->_aViewData[$sParamId];
00373         }
00374     }
00375 
00383     public function setClassLocation( $sClassLocation = null )
00384     {
00385         $this->_sClassLocation = $sClassLocation;
00386     }
00392     public function getClassLocation()
00393     {
00394         return $this->_sClassLocation;
00395     }
00396 
00404     public function setThisAction( $sThisAction = null )
00405     {
00406         $this->_sThisAction = $sThisAction;
00407     }
00408 
00414     public function getThisAction()
00415     {
00416         return $this->_sThisAction;
00417     }
00418 
00426     public function setParent( $oParent = null )
00427     {
00428         $this->_oParent = $oParent;
00429     }
00430 
00436     public function getParent()
00437     {
00438         return $this->_oParent;
00439     }
00440 
00448     public function setIsComponent( $blIsComponent = null )
00449     {
00450         $this->_blIsComponent = $blIsComponent;
00451     }
00452 
00458     public function getIsComponent()
00459     {
00460         return $this->_blIsComponent;
00461     }
00462 
00473     public function executeFunction( $sFunction )
00474     {
00475         $sNewAction = null;
00476 
00477         // execute
00478         if ( $sFunction && !self::$_blExecuted ) {
00479             if ( method_exists( $this, $sFunction ) ) {
00480 
00481 
00482                 $sNewAction = $this->$sFunction();
00483                 self::$_blExecuted = true;
00484             }
00485 
00486             // was not executed on any level ?
00487             if ( !$this->_blIsComponent && !self::$_blExecuted ) {
00488                 $oEx = oxNew( 'oxSystemComponentException' );
00489                 $oEx->setMessage( 'EXCEPTION_SYSTEMCOMPONENT_FUNCTIONNOTFOUND' );
00490                 $oEx->setComponent( $sFunction );
00491                 throw $oEx;
00492             }
00493         }
00494 
00495         $this->_executeNewAction( $sNewAction );
00496     }
00497 
00507     protected function _executeNewAction( $sNewAction )
00508     {
00509         if ( $sNewAction ) {
00510             $myConfig  = $this->getConfig();
00511 
00512             // page parameters is the part which goes after '?'
00513             $aParams = explode( '?', $sNewAction );
00514 
00515             // action parameters is the part before '?'
00516             $sPageParams = isset( $aParams[1] )?$aParams[1]:null;
00517 
00518             // looking for function name
00519             $aParams    = explode( '/', $aParams[0] );
00520             $sClassName = $aParams[0];
00521 
00522             // building redirect path ...
00523             $sHeader  = ( $sClassName )?"cl=$sClassName&":'';  // adding view name
00524             $sHeader .= ( $sPageParams )?"$sPageParams&":'';   // adding page params
00525             $sHeader .= $this->getSession()->sid();            // adding session Id
00526 
00527             // choosing URL to redirect
00528             $sUrl = $myConfig->isSsl()?$myConfig->getSslShopUrl():$myConfig->getShopUrl();
00529 
00530             // different redirect URL in SEO mode
00531             if ( $this->isAdmin() ) {
00532                 $sUrl .= $myConfig->getConfigParam( 'sAdminDir' ) . '/';
00533             }
00534 
00535             $sUrl = "{$sUrl}index.php?{$sHeader}";
00536 
00537             $sUrl = oxUtilsUrl::getInstance()->processUrl($sUrl);
00538 
00539             //#M341 do not add redirect parameter
00540             oxUtils::getInstance()->redirect( $sUrl, (bool) oxConfig::getParameter( 'redirected' ) );
00541         }
00542     }
00543 
00549     public function getAdditionalParams()
00550     {
00551         return oxUtilsUrl::getInstance()->processUrl( '', false );
00552     }
00553 
00559     public function getTrustedShopId()
00560     {
00561         if ( $this->_sTrustedShopId == null ) {
00562             $this->_sTrustedShopId = false;
00563             $oConfig = $this->getConfig();
00564             $aTsType   = $oConfig->getConfigParam( 'tsSealType' );
00565             $sTsActive = $oConfig->getConfigParam( 'tsSealActive' );
00566             $aTrustedShopIds = $oConfig->getConfigParam( 'iShopID_TrustedShops' );
00567             $iLangId = (int) oxLang::getInstance()->getBaseLanguage();
00568             if ( $sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'CLASSIC' ) {
00569                 // compatibility to old data
00570                 if ( !is_array( $aTrustedShopIds ) && $iLangId == 0 ) {
00571                     $this->_sTrustedShopId = $aTrustedShopIds;
00572                 }
00573                 if ( is_array( $aTrustedShopIds ) ) {
00574                     $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
00575                 }
00576                 if ( strlen( $this->_sTrustedShopId ) != 33 || substr( $this->_sTrustedShopId, 0, 1 ) != 'X' ) {
00577                     $this->_sTrustedShopId = false;
00578                 }
00579             }
00580         }
00581         return $this->_sTrustedShopId;
00582     }
00583 
00589     public function getTSExcellenceId()
00590     {
00591         if ( $this->_sTSExcellenceId == null ) {
00592             $this->_sTSExcellenceId = false;
00593             $oConfig   = $this->getConfig();
00594             $aTsType   = $oConfig->getConfigParam( 'tsSealType' );
00595             $sTsActive = $oConfig->getConfigParam( 'tsSealActive' );
00596             $aTrustedShopIds = $oConfig->getConfigParam( 'iShopID_TrustedShops' );
00597             $iLangId = (int) oxLang::getInstance()->getBaseLanguage();
00598             if ( $sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'EXCELLENCE' ) {
00599                 $this->_sTSExcellenceId = $aTrustedShopIds[$iLangId];
00600             }
00601         }
00602         return $this->_sTSExcellenceId;
00603     }
00604 
00610     public function getCharSet()
00611     {
00612         if ( $this->_sCharSet == null ) {
00613             $this->_sCharSet = oxLang::getInstance()->translateString( 'charset' );
00614         }
00615         return $this->_sCharSet;
00616     }
00617 
00623     public function getShopVersion()
00624     {
00625         if ( $this->_sVersion == null ) {
00626             $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
00627         }
00628         return $this->_sVersion;
00629     }
00630 
00636     public function getShopEdition()
00637     {
00638         return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
00639     }
00640 
00646     public function getRevision()
00647     {
00648         return $this->getConfig()->getRevision();
00649     }
00650 
00656     public function getShopFullEdition()
00657     {
00658         $sEdition = $this->getShopEdition();
00659         $sFullEdition = "Community Edition";
00660         if ( $sEdition == "PE" ) {
00661             $sFullEdition = "Professional Edition";
00662         }
00663 
00664         if ( $sEdition == "EE" ) {
00665             $sFullEdition = "Enterprise Edition";
00666         }
00667 
00668         return $sFullEdition;
00669     }
00670 
00671 
00677     public function isDemoVersion()
00678     {
00679         if ( $this->_blDemoVersion == null ) {
00680             $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
00681         }
00682         return $this->_blDemoVersion;
00683     }
00684 
00690     public function isDemoShop()
00691     {
00692         if ( $this->_blDemoShop == null ) {
00693             $this->_blDemoShop = $this->getConfig()->isDemoShop();
00694         }
00695         return $this->_blDemoShop;
00696     }
00697 
00703     public function showNewsletter()
00704     {
00705         if ( $this->_iNewsStatus === null) {
00706             return 1;
00707         }
00708         return $this->_iNewsStatus;
00709     }
00710 
00718     public function setShowNewsletter( $blShow )
00719     {
00720         $this->_iNewsStatus = $blShow;
00721     }
00722 
00728     public function getShopLogo()
00729     {
00730         return $this->_sShopLogo;
00731     }
00732 
00740     public function setShopLogo( $sLogo )
00741     {
00742         $this->_sShopLogo = $sLogo;
00743     }
00744 
00752     public function getActCategory()
00753     {
00754         // if active category is not set yet - trying to load it from request params
00755         // this may be usefull when category component was unable to load active category
00756         // and we still need some object to mount navigation info
00757         if ( $this->_oClickCat === null ) {
00758 
00759             $this->_oClickCat = false;
00760             $oCategory = oxNew( 'oxcategory' );
00761             if ( $oCategory->load( $this->getCategoryId() ) ) {
00762                 $this->_oClickCat = $oCategory;
00763             }
00764         }
00765 
00766         return $this->_oClickCat;
00767     }
00768 
00776     public function setActCategory( $oCategory )
00777     {
00778         $this->_oClickCat = $oCategory;
00779     }
00780 
00786     public function getCategoryId()
00787     {
00788         if ( $this->_sCategoryId == null && ( $sCatId = oxConfig::getParameter( 'cnid' ) ) ) {
00789             $this->_sCategoryId = $sCatId;
00790         }
00791 
00792         return $this->_sCategoryId;
00793     }
00794 
00802     public function setCategoryId( $sCategoryId )
00803     {
00804         $this->_sCategoryId = $sCategoryId;
00805     }
00806 
00812     public function getErrorDestination()
00813     {
00814     }
00815 
00822     public function getActionClassName()
00823     {
00824         return $this->getClassName();
00825     }
00826 
00832     public function isConnectedWithFb()
00833     {
00834         $myConfig = $this->getConfig();
00835 
00836         if ( $myConfig->getConfigParam( "bl_showFbConnect" ) ) {
00837             $oFb = oxFb::getInstance();
00838             return $oFb->isConnected();
00839         }
00840 
00841         return false;
00842     }
00843 
00849     public function getFbUserId()
00850     {
00851         if ( $this->getConfig()->getConfigParam( "bl_showFbConnect" ) ) {
00852             $oFb = oxFb::getInstance();
00853             return $oFb->getUser();
00854         }
00855     }
00856 
00863     public function showFbConnectToAccountMsg()
00864     {
00865         if ( $this->getConfig()->getParameter( "fblogin" ) ) {
00866             if ( !$this->getUser() || ($this->getUser() && oxSession::getVar( '_blFbUserIdUpdated' ) ) ) {
00867                 return true;
00868             } else {
00869                 return false;
00870             }
00871         }
00872 
00873         return false;
00874     }
00875 }