OXID eShop CE  4.10.6
 All Classes Namespaces Files Functions Variables Pages
oxview.php
Go to the documentation of this file.
1 <?php
2 
7 class oxView extends oxSuperCfg
8 {
9 
15  protected $_aViewData = array();
16 
22  protected $_sClassLocation = null;
23 
29  protected $_sThisAction = null;
30 
36  protected $_oParent = null;
37 
43  protected $_blIsComponent = false;
44 
50  protected $_sThisTemplate = null;
51 
57  protected $_sViewId = null;
58 
64  protected $_sClass = null;
65 
71  protected $_sFnc = null;
72 
78  protected static $_blExecuted = false;
79 
87  protected $_sTrustedShopId = null;
88 
96  protected $_sTSExcellenceId = null;
97 
103  protected $_sCharSet = null;
104 
110  protected $_sVersion = null;
111 
117  protected $_blDemoVersion = null;
118 
124  protected $_blDemoShop = null;
125 
131  protected $_iNewsStatus = null;
132 
138  protected $_sShopLogo = null;
139 
145  protected $_sCategoryId = null;
146 
152  protected $_oClickCat = null;
153 
159  protected $_blIsCallForCache = false;
160 
166  protected $_oViewConf = null;
167 
168 
172  public function init()
173  {
174  // setting current view class name
175  $this->_sThisAction = strtolower(get_class($this));
176 
177  if (!$this->_blIsComponent) {
178  // assume that cached components does not affect this method ...
179  $this->addGlobalParams();
180  }
181  }
182 
188  public function setViewParameters($aParams = null)
189  {
190  $this->_aViewParams = $aParams;
191  }
192 
200  public function getViewParameter($sKey)
201  {
202  $sValue = (isset($this->_aViewParams[$sKey])) ? $this->_aViewParams[$sKey] : $this->getConfig()->getRequestParameter($sKey);
203 
204  return $sValue;
205  }
206 
212  public function setIsCallForCache($blIsCallForCache = null)
213  {
214  $this->_blIsCallForCache = $blIsCallForCache;
215  }
216 
222  public function getIsCallForCache()
223  {
225  }
226 
230  public function getViewId()
231  {
232  }
233 
239  public function render()
240  {
241  return $this->getTemplateName();
242  }
243 
257  public function addGlobalParams($oShop = null)
258  {
259  // by default we always display newsletter bar
260  $this->_iNewsStatus = 1;
261 
262  // assigning shop to view config ..
263  $oViewConf = $this->getViewConfig();
264  if ($oShop) {
265  $oViewConf->setViewShop($oShop, $this->_aViewData);
266  }
267 
268  //sending all view to smarty
269  $this->_aViewData['oView'] = $this;
270  $this->_aViewData['oViewConf'] = $this->getViewConfig();
271 
272  return $oViewConf;
273  }
274 
281  public function addTplParam($sPara, $sValue)
282  {
283  $this->_aViewData[$sPara] = $sValue;
284  }
285 
291  public function getBelboonParam()
292  {
293  if ($sBelboon = $this->getSession()->getVariable('belboon')) {
294  return $sBelboon;
295  }
296  if (($sBelboon = $this->getConfig()->getRequestParameter('belboon'))) {
297  $this->getSession()->setVariable('belboon', $sBelboon);
298  }
299 
300  return $sBelboon;
301  }
302 
308  public function getViewConfig()
309  {
310  if ($this->_oViewConf === null) {
311  $this->_oViewConf = oxNew('oxViewConfig');
312  }
313 
314  return $this->_oViewConf;
315  }
316 
322  public function getTemplateName()
323  {
324  return $this->_sThisTemplate;
325  }
326 
332  public function setTemplateName($sTemplate)
333  {
334  $this->_sThisTemplate = $sTemplate;
335  }
336 
342  public function setClassName($sClassName)
343  {
344  $this->_sClass = $sClassName;
345  }
346 
352  public function getClassName()
353  {
354  return $this->_sClass;
355  }
356 
362  public function setFncName($sFncName)
363  {
364  $this->_sFnc = $sFncName;
365  }
366 
372  public function getFncName()
373  {
374  return $this->_sFnc;
375  }
376 
382  public function setViewData($aViewData = null)
383  {
384  $this->_aViewData = $aViewData;
385  }
386 
392  public function getViewData()
393  {
394  return $this->_aViewData;
395  }
396 
404  public function getViewDataElement($sParamId = null)
405  {
406  if ($sParamId && isset($this->_aViewData[$sParamId])) {
407  return $this->_aViewData[$sParamId];
408  }
409  }
410 
416  public function setClassLocation($sClassLocation = null)
417  {
418  $this->_sClassLocation = $sClassLocation;
419  }
420 
426  public function getClassLocation()
427  {
428  return $this->_sClassLocation;
429  }
430 
436  public function setThisAction($sThisAction = null)
437  {
438  $this->_sThisAction = $sThisAction;
439  }
440 
446  public function getThisAction()
447  {
448  return $this->_sThisAction;
449  }
450 
456  public function setParent($oParent = null)
457  {
458  $this->_oParent = $oParent;
459  }
460 
466  public function getParent()
467  {
468  return $this->_oParent;
469  }
470 
476  public function setIsComponent($blIsComponent = null)
477  {
478  $this->_blIsComponent = $blIsComponent;
479  }
480 
486  public function getIsComponent()
487  {
488  return $this->_blIsComponent;
489  }
490 
499  public function executeFunction($sFunction)
500  {
501  // execute
502  if ($sFunction && !self::$_blExecuted) {
503  if (method_exists($this, $sFunction)) {
504 
505 
506  $sNewAction = $this->$sFunction();
507  self::$_blExecuted = true;
508 
509  if (isset ($sNewAction)) {
510  $this->_executeNewAction($sNewAction);
511  }
512  } else {
513  // was not executed on any level ?
514  if (!$this->_blIsComponent) {
516  $oEx = oxNew('oxSystemComponentException');
517  $oEx->setMessage('ERROR_MESSAGE_SYSTEMCOMPONENT_FUNCTIONNOTFOUND');
518  $oEx->setComponent($sFunction);
519  throw $oEx;
520  }
521  }
522  }
523  }
524 
534  protected function _executeNewAction($sNewAction)
535  {
536  if ($sNewAction) {
537  $myConfig = $this->getConfig();
538 
539  // page parameters is the part which goes after '?'
540  $aParams = explode('?', $sNewAction);
541 
542  // action parameters is the part before '?'
543  $sPageParams = isset($aParams[1]) ? $aParams[1] : null;
544 
545  // looking for function name
546  $aParams = explode('/', $aParams[0]);
547  $sClassName = $aParams[0];
548  $sRealClassName = oxUtilsObject::getInstance()->getClassName($sClassName);
549 
550  if (false === class_exists($sRealClassName)) {
551  //If redirect tries to use a not existing class throw an exception.
552  //we'll be redirected to start page directly.
554  $oException = oxNew('oxSystemComponentException');
555  $oException->setMessage('ERROR_MESSAGE_SYSTEMCOMPONENT_CLASSNOTFOUND');
556  $oException->setComponent($sClassName);
557  throw $oException;
558  }
559 
560  // building redirect path ...
561  $sHeader = ($sClassName) ? "cl=$sClassName&" : ''; // adding view name
562  $sHeader .= ($sPageParams) ? "$sPageParams&" : ''; // adding page params
563  $sHeader .= $this->getSession()->sid(); // adding session Id
564 
565  $sUrl = $myConfig->getCurrentShopUrl($this->isAdmin());
566 
567  $sUrl = "{$sUrl}index.php?{$sHeader}";
568 
569  $sUrl = oxRegistry::get("oxUtilsUrl")->processUrl($sUrl);
570 
571  if (oxRegistry::getUtils()->seoIsActive() && $sSeoUrl = oxRegistry::get("oxSeoEncoder")->getStaticUrl($sUrl)) {
572  $sUrl = $sSeoUrl;
573  }
574 
575 
576  //#M341 do not add redirect parameter
577  oxRegistry::getUtils()->redirect($sUrl, (bool) $myConfig->getRequestParameter('redirected'), 302);
578  }
579  }
580 
586  public function getAdditionalParams()
587  {
588  return oxRegistry::get("oxUtilsUrl")->processUrl('', false);
589  }
590 
598  public function getTrustedShopId()
599  {
600  if ($this->_sTrustedShopId == null) {
601  $this->_sTrustedShopId = false;
602  $oConfig = $this->getConfig();
603  $aTsType = $oConfig->getConfigParam('tsSealType');
604  $sTsActive = $oConfig->getConfigParam('tsSealActive');
605  $aTrustedShopIds = $oConfig->getConfigParam('iShopID_TrustedShops');
606  $iLangId = (int) oxRegistry::getLang()->getBaseLanguage();
607  if ($sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'CLASSIC') {
608  // compatibility to old data
609  if (!is_array($aTrustedShopIds) && $iLangId == 0) {
610  $this->_sTrustedShopId = $aTrustedShopIds;
611  }
612  if (is_array($aTrustedShopIds)) {
613  $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
614  }
615  if (strlen($this->_sTrustedShopId) != 33 || substr($this->_sTrustedShopId, 0, 1) != 'X') {
616  $this->_sTrustedShopId = false;
617  }
618  }
619  }
620 
621  return $this->_sTrustedShopId;
622  }
623 
631  public function getTSExcellenceId()
632  {
633  if ($this->_sTSExcellenceId == null) {
634  $this->_sTSExcellenceId = false;
635  $oConfig = $this->getConfig();
636  $aTsType = $oConfig->getConfigParam('tsSealType');
637  $sTsActive = $oConfig->getConfigParam('tsSealActive');
638  $aTrustedShopIds = $oConfig->getConfigParam('iShopID_TrustedShops');
639  $iLangId = (int) oxRegistry::getLang()->getBaseLanguage();
640  if ($sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'EXCELLENCE') {
641  $this->_sTSExcellenceId = $aTrustedShopIds[$iLangId];
642  }
643  }
644 
646  }
647 
653  public function getCharSet()
654  {
655  if ($this->_sCharSet == null) {
656  $this->_sCharSet = oxRegistry::getLang()->translateString('charset');
657  }
658 
659  return $this->_sCharSet;
660  }
661 
667  public function getShopVersion()
668  {
669  if ($this->_sVersion == null) {
670  $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
671  }
672 
673  return $this->_sVersion;
674  }
675 
681  public function getShopEdition()
682  {
683  return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
684  }
685 
691  public function getRevision()
692  {
693  return $this->getConfig()->getRevision();
694  }
695 
701  public function getPackageInfo()
702  {
703  return $this->getConfig()->getPackageInfo();
704  }
705 
711  public function getShopFullEdition()
712  {
713  $sEdition = $this->getShopEdition();
714  $sFullEdition = "Community Edition";
715  if ($sEdition == "PE") {
716  $sFullEdition = "Professional Edition";
717  }
718 
719  if ($sEdition == "EE") {
720  $sFullEdition = "Enterprise Edition";
721  }
722 
723  return $sFullEdition;
724  }
725 
726 
732  public function isDemoVersion()
733  {
734  if ($this->_blDemoVersion == null) {
735  $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
736  }
737 
738  return $this->_blDemoVersion;
739  }
740 
746  public function isBetaVersion()
747  {
748  $blBetaVersion = false;
749 
750  if (stripos($this->getConfig()->getVersion(), 'beta') !== false) {
751  $blBetaVersion = true;
752  }
753 
754  return $blBetaVersion;
755  }
756 
762  public function isRCVersion()
763  {
764  $blRCVersion = false;
765 
766  if (stripos($this->getConfig()->getVersion(), 'rc') !== false) {
767  $blRCVersion = true;
768  }
769 
770  return $blRCVersion;
771  }
772 
778  public function showBetaNote()
779  {
780  $blBetaNote = false;
781 
782  if ($this->isBetaVersion() || $this->isRCVersion()) {
783  $blBetaNote = true;
784  }
785 
786  return $blBetaNote;
787  }
788 
794  public function isDemoShop()
795  {
796  if ($this->_blDemoShop == null) {
797  $this->_blDemoShop = $this->getConfig()->isDemoShop();
798  }
799 
800  return $this->_blDemoShop;
801  }
802 
808  public function showNewsletter()
809  {
810  if ($this->_iNewsStatus === null) {
811  return 1;
812  }
813 
814  return $this->_iNewsStatus;
815  }
816 
822  public function setShowNewsletter($blShow)
823  {
824  $this->_iNewsStatus = $blShow;
825  }
826 
834  public function getShopLogo()
835  {
836  if ($this->_sShopLogo === null) {
837  $this->setShopLogo($this->getConfig()->getConfigParam('sShopLogo'));
838  }
839 
840  return $this->_sShopLogo;
841  }
842 
850  public function setShopLogo($sLogo)
851  {
852  $this->_sShopLogo = $sLogo;
853  }
854 
862  public function getActCategory()
863  {
864  // if active category is not set yet - trying to load it from request params
865  // this may be usefull when category component was unable to load active category
866  // and we still need some object to mount navigation info
867  if ($this->_oClickCat === null) {
868 
869  $this->_oClickCat = false;
870  $oCategory = oxNew('oxcategory');
871  if ($oCategory->load($this->getCategoryId())) {
872  $this->_oClickCat = $oCategory;
873  }
874  }
875 
876  return $this->_oClickCat;
877  }
878 
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 
908  public function setCategoryId($sCategoryId)
909  {
910  $this->_sCategoryId = $sCategoryId;
911  }
912 
916  public function getErrorDestination()
917  {
918  }
919 
926  public function getActionClassName()
927  {
928  return $this->getClassName();
929  }
930 
938  public function isConnectedWithFb()
939  {
940  $myConfig = $this->getConfig();
941 
942  if ($myConfig->getConfigParam("bl_showFbConnect")) {
943  $oFb = oxRegistry::get("oxFb");
944 
945  return $oFb->isConnected();
946  }
947 
948  return false;
949  }
950 
958  public function getFbUserId()
959  {
960  if ($this->getConfig()->getConfigParam("bl_showFbConnect")) {
961  $oFb = oxRegistry::get("oxFb");
962 
963  return $oFb->getUser();
964  }
965  }
966 
975  public function showFbConnectToAccountMsg()
976  {
977  if ($this->getConfig()->getRequestParameter("fblogin")) {
978  if (!$this->getUser() || ($this->getUser() && $this->getSession()->getVariable('_blFbUserIdUpdated'))) {
979  return true;
980  } else {
981  return false;
982  }
983  }
984 
985  return false;
986  }
987 
993  public function isMall()
994  {
995  return false;
996  }
997 
1003  public function showRdfa()
1004  {
1005  return false;
1006  }
1007 
1008 
1016  public function getSidForWidget()
1017  {
1018  $sRet = null;
1019  $oSession = $this->getSession();
1020 
1021  if (!$oSession->isActualSidInCookie()) {
1022  $sRet = $oSession->getId();
1023  }
1024 
1025  return $sRet;
1026  }
1027 }