OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
oxview.php
Go to the documentation of this file.
1 <?php
2 
7 class oxView extends oxSuperCfg
8 {
14  protected $_aViewData = array();
15 
21  protected $_sClassLocation = null;
22 
28  protected $_sThisAction = null;
29 
35  protected $_oParent = null;
36 
42  protected $_blIsComponent = false;
43 
49  protected $_sThisTemplate = null;
50 
56  protected $_sViewId = null;
57 
63  protected $_sClass = null;
64 
70  protected $_sFnc = null;
71 
77  protected static $_blExecuted = false;
78 
83  protected $_sTrustedShopId = null;
84 
89  protected $_sTSExcellenceId = null;
90 
95  protected $_sCharSet = null;
96 
101  protected $_sVersion = null;
102 
107  protected $_blDemoVersion = null;
108 
113  protected $_blDemoShop = null;
114 
119  protected $_iNewsStatus = null;
120 
125  protected $_sShopLogo = null;
126 
132  protected $_sCategoryId = null;
133 
138  protected $_oClickCat = null;
139 
145  protected $_blIsCallForCache = false;
146 
152  protected $_oViewConf = null;
153 
154 
160  public function init()
161  {
162  // setting current view class name
163  $this->_sThisAction = strtolower( get_class( $this ) );
164 
165  if ( !$this->_blIsComponent ) {
166  // assume that cached components does not affect this method ...
167  $this->addGlobalParams();
168  }
169  }
170 
178  public function setViewParameters( $aParams = null )
179  {
180  $this->_aViewParams = $aParams;
181  }
182 
190  public function getViewParameter( $sKey )
191  {
192  $sValue = ( isset( $this->_aViewParams[$sKey] ) ) ? $this->_aViewParams[$sKey] : $this->getConfig()->getRequestParameter( $sKey );
193 
194  return $sValue;
195  }
196 
204  public function setIsCallForCache( $blIsCallForCache = null )
205  {
206  $this->_blIsCallForCache = $blIsCallForCache;
207  }
208 
214  public function getIsCallForCache()
215  {
217  }
218 
224  public function getViewId()
225  {
226  }
227 
233  public function render()
234  {
235  return $this->getTemplateName();
236  }
237 
251  public function addGlobalParams( $oShop = null)
252  {
253  // by default we allways display newsletter bar
254  $this->_iNewsStatus = 1;
255 
256  // assigning shop to view config ..
257  $oViewConf = $this->getViewConfig();
258  if ( $oShop ) {
259  $oViewConf->setViewShop( $oShop, $this->_aViewData );
260  }
261 
262  //sending all view to smarty
263  $this->_aViewData['oView'] = $this;
264  $this->_aViewData['oViewConf'] = $this->getViewConfig();
265 
266  return $oViewConf;
267  }
268 
277  public function addTplParam( $sPara, $sValue )
278  {
279  $this->_aViewData[$sPara] = $sValue;
280  }
281 
287  public function getBelboonParam()
288  {
289  if ( $sBelboon = $this->getSession()->getVariable( 'belboon' ) ) {
290  return $sBelboon;
291  }
292  if ( ( $sBelboon = $this->getConfig()->getRequestParameter( 'belboon' ) ) ) {
293  $this->getSession()->setVariable( 'belboon', $sBelboon );
294  }
295 
296  return $sBelboon;
297  }
298 
304  public function getViewConfig()
305  {
306  if ( $this->_oViewConf === null ) {
307  $this->_oViewConf = oxNew( 'oxViewConfig' );
308  }
309 
310  return $this->_oViewConf;
311  }
312 
318  public function getTemplateName()
319  {
320  return $this->_sThisTemplate;
321  }
322 
330  public function setTemplateName( $sTemplate )
331  {
332  $this->_sThisTemplate = $sTemplate;
333  }
334 
342  public function setClassName( $sClassName )
343  {
344  $this->_sClass = $sClassName;
345  }
346 
352  public function getClassName()
353  {
354  return $this->_sClass;
355  }
356 
364  public function setFncName( $sFncName )
365  {
366  $this->_sFnc = $sFncName;
367  }
368 
374  public function getFncName()
375  {
376  return $this->_sFnc;
377  }
378 
386  public function setViewData( $aViewData = null )
387  {
388  $this->_aViewData = $aViewData;
389  }
390 
396  public function getViewData()
397  {
398  return $this->_aViewData;
399  }
400 
408  public function getViewDataElement( $sParamId = null )
409  {
410  if ( $sParamId && isset( $this->_aViewData[$sParamId] ) ) {
411  return $this->_aViewData[$sParamId];
412  }
413  }
414 
422  public function setClassLocation( $sClassLocation = null )
423  {
424  $this->_sClassLocation = $sClassLocation;
425  }
431  public function getClassLocation()
432  {
433  return $this->_sClassLocation;
434  }
435 
443  public function setThisAction( $sThisAction = null )
444  {
445  $this->_sThisAction = $sThisAction;
446  }
447 
453  public function getThisAction()
454  {
455  return $this->_sThisAction;
456  }
457 
465  public function setParent( $oParent = null )
466  {
467  $this->_oParent = $oParent;
468  }
469 
475  public function getParent()
476  {
477  return $this->_oParent;
478  }
479 
487  public function setIsComponent( $blIsComponent = null )
488  {
489  $this->_blIsComponent = $blIsComponent;
490  }
491 
497  public function getIsComponent()
498  {
499  return $this->_blIsComponent;
500  }
501 
512  public function executeFunction( $sFunction )
513  {
514  // execute
515  if ( $sFunction && !self::$_blExecuted ) {
516  if ( method_exists( $this, $sFunction ) ) {
517 
518 
519  $sNewAction = $this->$sFunction();
520  self::$_blExecuted = true;
521 
522  if ( isset ( $sNewAction ) ) {
523  $this->_executeNewAction( $sNewAction );
524  }
525  } else {
526  // was not executed on any level ?
527  if ( !$this->_blIsComponent ) {
528  $oEx = oxNew( 'oxSystemComponentException' );
529  $oEx->setMessage( 'ERROR_MESSAGE_SYSTEMCOMPONENT_FUNCTIONNOTFOUND' );
530  $oEx->setComponent( $sFunction );
531  throw $oEx;
532  }
533  }
534  }
535  }
536 
546  protected function _executeNewAction( $sNewAction )
547  {
548  if ( $sNewAction ) {
549  $myConfig = $this->getConfig();
550 
551  // page parameters is the part which goes after '?'
552  $aParams = explode( '?', $sNewAction );
553 
554  // action parameters is the part before '?'
555  $sPageParams = isset( $aParams[1] )?$aParams[1]:null;
556 
557  // looking for function name
558  $aParams = explode( '/', $aParams[0] );
559  $sClassName = $aParams[0];
560 
561  // building redirect path ...
562  $sHeader = ( $sClassName )?"cl=$sClassName&":''; // adding view name
563  $sHeader .= ( $sPageParams )?"$sPageParams&":''; // adding page params
564  $sHeader .= $this->getSession()->sid(); // adding session Id
565 
566  $sUrl = $myConfig->getCurrentShopUrl($this->isAdmin());
567 
568  $sUrl = "{$sUrl}index.php?{$sHeader}";
569 
570  $sUrl = oxRegistry::get("oxUtilsUrl")->processUrl($sUrl);
571 
572  if ( oxRegistry::getUtils()->seoIsActive() && $sSeoUrl = oxRegistry::get( "oxSeoEncoder" )->getStaticUrl( $sUrl ) ) {
573  $sUrl = $sSeoUrl;
574  }
575 
576 
577  //#M341 do not add redirect parameter
578  oxRegistry::getUtils()->redirect( $sUrl, (bool) $myConfig->getRequestParameter( 'redirected' ), 302 );
579  }
580  }
581 
587  public function getAdditionalParams()
588  {
589  return oxRegistry::get("oxUtilsUrl")->processUrl( '', false );
590  }
591 
597  public function getTrustedShopId()
598  {
599  if ( $this->_sTrustedShopId == null ) {
600  $this->_sTrustedShopId = false;
601  $oConfig = $this->getConfig();
602  $aTsType = $oConfig->getConfigParam( 'tsSealType' );
603  $sTsActive = $oConfig->getConfigParam( 'tsSealActive' );
604  $aTrustedShopIds = $oConfig->getConfigParam( 'iShopID_TrustedShops' );
605  $iLangId = (int) oxRegistry::getLang()->getBaseLanguage();
606  if ( $sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'CLASSIC' ) {
607  // compatibility to old data
608  if ( !is_array( $aTrustedShopIds ) && $iLangId == 0 ) {
609  $this->_sTrustedShopId = $aTrustedShopIds;
610  }
611  if ( is_array( $aTrustedShopIds ) ) {
612  $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
613  }
614  if ( strlen( $this->_sTrustedShopId ) != 33 || substr( $this->_sTrustedShopId, 0, 1 ) != 'X' ) {
615  $this->_sTrustedShopId = false;
616  }
617  }
618  }
619  return $this->_sTrustedShopId;
620  }
621 
627  public function getTSExcellenceId()
628  {
629  if ( $this->_sTSExcellenceId == null ) {
630  $this->_sTSExcellenceId = false;
631  $oConfig = $this->getConfig();
632  $aTsType = $oConfig->getConfigParam( 'tsSealType' );
633  $sTsActive = $oConfig->getConfigParam( 'tsSealActive' );
634  $aTrustedShopIds = $oConfig->getConfigParam( 'iShopID_TrustedShops' );
635  $iLangId = (int) oxRegistry::getLang()->getBaseLanguage();
636  if ( $sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'EXCELLENCE' ) {
637  $this->_sTSExcellenceId = $aTrustedShopIds[$iLangId];
638  }
639  }
641  }
642 
648  public function getCharSet()
649  {
650  if ( $this->_sCharSet == null ) {
651  $this->_sCharSet = oxRegistry::getLang()->translateString( 'charset' );
652  }
653  return $this->_sCharSet;
654  }
655 
661  public function getShopVersion()
662  {
663  if ( $this->_sVersion == null ) {
664  $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
665  }
666  return $this->_sVersion;
667  }
668 
674  public function getShopEdition()
675  {
676  return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
677  }
678 
684  public function getRevision()
685  {
686  return $this->getConfig()->getRevision();
687  }
688 
694  public function getPackageInfo()
695  {
696  return $this->getConfig()->getPackageInfo();
697  }
698 
704  public function getShopFullEdition()
705  {
706  $sEdition = $this->getShopEdition();
707  $sFullEdition = "Community Edition";
708  if ( $sEdition == "PE" ) {
709  $sFullEdition = "Professional Edition";
710  }
711 
712  if ( $sEdition == "EE" ) {
713  $sFullEdition = "Enterprise Edition";
714  }
715 
716  return $sFullEdition;
717  }
718 
719 
725  public function isDemoVersion()
726  {
727  if ( $this->_blDemoVersion == null ) {
728  $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
729  }
730  return $this->_blDemoVersion;
731  }
732 
738  public function isBetaVersion()
739  {
740  $blbetaVersion = false;
741 
742  if ( stripos( $this->getConfig()->getVersion(), 'beta' ) !== false ) {
743  $blbetaVersion = true;
744  }
745 
746  return $blbetaVersion;
747  }
748 
754  public function isRCVersion()
755  {
756  $blRCVersion = false;
757 
758  if ( stripos( $this->getConfig()->getVersion(), 'rc' ) !== false ) {
759  $blRCVersion = true;
760  }
761 
762  return $blRCVersion;
763  }
764 
770  public function showBetaNote()
771  {
772  $blBetaNote = false;
773 
774  if ( $this->isBetaVersion() || $this->isRCVersion() ) {
775  $blBetaNote = true;
776  }
777 
778  return $blBetaNote;
779  }
780 
786  public function isDemoShop()
787  {
788  if ( $this->_blDemoShop == null ) {
789  $this->_blDemoShop = $this->getConfig()->isDemoShop();
790  }
791  return $this->_blDemoShop;
792  }
793 
799  public function showNewsletter()
800  {
801  if ( $this->_iNewsStatus === null) {
802  return 1;
803  }
804  return $this->_iNewsStatus;
805  }
806 
814  public function setShowNewsletter( $blShow )
815  {
816  $this->_iNewsStatus = $blShow;
817  }
818 
826  public function getShopLogo()
827  {
828  if ( $this->_sShopLogo === null ) {
829  $this->setShopLogo( $this->getConfig()->getConfigParam( 'sShopLogo' ) );
830  }
831 
832  return $this->_sShopLogo;
833  }
834 
844  public function setShopLogo( $sLogo )
845  {
846  $this->_sShopLogo = $sLogo;
847  }
848 
858  public function getActCategory()
859  {
860  // if active category is not set yet - trying to load it from request params
861  // this may be usefull when category component was unable to load active category
862  // and we still need some object to mount navigation info
863  if ( $this->_oClickCat === null ) {
864 
865  $this->_oClickCat = false;
866  $oCategory = oxNew( 'oxcategory' );
867  if ( $oCategory->load( $this->getCategoryId() ) ) {
868  $this->_oClickCat = $oCategory;
869  }
870  }
871 
872  return $this->_oClickCat;
873  }
874 
884  public function setActCategory( $oCategory )
885  {
886  $this->_oClickCat = $oCategory;
887  }
888 
894  public function getCategoryId()
895  {
896  if ( $this->_sCategoryId == null && ( $sCatId = $this->getConfig()->getRequestParameter( 'cnid' ) ) ) {
897  $this->_sCategoryId = $sCatId;
898  }
899 
900  return $this->_sCategoryId;
901  }
902 
910  public function setCategoryId( $sCategoryId )
911  {
912  $this->_sCategoryId = $sCategoryId;
913  }
914 
920  public function getErrorDestination()
921  {
922  }
923 
930  public function getActionClassName()
931  {
932  return $this->getClassName();
933  }
934 
940  public function isConnectedWithFb()
941  {
942  $myConfig = $this->getConfig();
943 
944  if ( $myConfig->getConfigParam( "bl_showFbConnect" ) ) {
945  $oFb = oxRegistry::get("oxFb");
946  return $oFb->isConnected();
947  }
948 
949  return false;
950  }
951 
957  public function getFbUserId()
958  {
959  if ( $this->getConfig()->getConfigParam( "bl_showFbConnect" ) ) {
960  $oFb = oxRegistry::get("oxFb");
961  return $oFb->getUser();
962  }
963  }
964 
971  public function showFbConnectToAccountMsg()
972  {
973  if ( $this->getConfig()->getRequestParameter( "fblogin" ) ) {
974  if ( !$this->getUser() || ($this->getUser() && $this->getSession()->getVariable( '_blFbUserIdUpdated' ) ) ) {
975  return true;
976  } else {
977  return false;
978  }
979  }
980 
981  return false;
982  }
983 
989  public function isMall()
990  {
991  return false;
992  }
993 
999  public function showRdfa()
1000  {
1001  return false;
1002  }
1003 
1004 
1012  public function getSidForWidget()
1013  {
1014  $sRet = null;
1015  $oSession = $this->getSession();
1016 
1017  if (!$oSession->isActualSidInCookie() ) {
1018  $sRet = $oSession->getId();
1019  }
1020 
1021  return $sRet;
1022  }
1023 
1024 }