OXID eShop CE  4.9.7
 All Classes 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 
85  protected $_sTrustedShopId = null;
86 
92  protected $_sTSExcellenceId = null;
93 
99  protected $_sCharSet = null;
100 
106  protected $_sVersion = null;
107 
113  protected $_blDemoVersion = null;
114 
120  protected $_blDemoShop = null;
121 
127  protected $_iNewsStatus = null;
128 
134  protected $_sShopLogo = null;
135 
141  protected $_sCategoryId = null;
142 
148  protected $_oClickCat = null;
149 
155  protected $_blIsCallForCache = false;
156 
162  protected $_oViewConf = null;
163 
164 
168  public function init()
169  {
170  // setting current view class name
171  $this->_sThisAction = strtolower(get_class($this));
172 
173  if (!$this->_blIsComponent) {
174  // assume that cached components does not affect this method ...
175  $this->addGlobalParams();
176  }
177  }
178 
184  public function setViewParameters($aParams = null)
185  {
186  $this->_aViewParams = $aParams;
187  }
188 
196  public function getViewParameter($sKey)
197  {
198  $sValue = (isset($this->_aViewParams[$sKey])) ? $this->_aViewParams[$sKey] : $this->getConfig()->getRequestParameter($sKey);
199 
200  return $sValue;
201  }
202 
208  public function setIsCallForCache($blIsCallForCache = null)
209  {
210  $this->_blIsCallForCache = $blIsCallForCache;
211  }
212 
218  public function getIsCallForCache()
219  {
221  }
222 
226  public function getViewId()
227  {
228  }
229 
235  public function render()
236  {
237  return $this->getTemplateName();
238  }
239 
253  public function addGlobalParams($oShop = null)
254  {
255  // by default we always display newsletter bar
256  $this->_iNewsStatus = 1;
257 
258  // assigning shop to view config ..
259  $oViewConf = $this->getViewConfig();
260  if ($oShop) {
261  $oViewConf->setViewShop($oShop, $this->_aViewData);
262  }
263 
264  //sending all view to smarty
265  $this->_aViewData['oView'] = $this;
266  $this->_aViewData['oViewConf'] = $this->getViewConfig();
267 
268  return $oViewConf;
269  }
270 
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 
328  public function setTemplateName($sTemplate)
329  {
330  $this->_sThisTemplate = $sTemplate;
331  }
332 
338  public function setClassName($sClassName)
339  {
340  $this->_sClass = $sClassName;
341  }
342 
348  public function getClassName()
349  {
350  return $this->_sClass;
351  }
352 
358  public function setFncName($sFncName)
359  {
360  $this->_sFnc = $sFncName;
361  }
362 
368  public function getFncName()
369  {
370  return $this->_sFnc;
371  }
372 
378  public function setViewData($aViewData = null)
379  {
380  $this->_aViewData = $aViewData;
381  }
382 
388  public function getViewData()
389  {
390  return $this->_aViewData;
391  }
392 
400  public function getViewDataElement($sParamId = null)
401  {
402  if ($sParamId && isset($this->_aViewData[$sParamId])) {
403  return $this->_aViewData[$sParamId];
404  }
405  }
406 
412  public function setClassLocation($sClassLocation = null)
413  {
414  $this->_sClassLocation = $sClassLocation;
415  }
416 
422  public function getClassLocation()
423  {
424  return $this->_sClassLocation;
425  }
426 
432  public function setThisAction($sThisAction = null)
433  {
434  $this->_sThisAction = $sThisAction;
435  }
436 
442  public function getThisAction()
443  {
444  return $this->_sThisAction;
445  }
446 
452  public function setParent($oParent = null)
453  {
454  $this->_oParent = $oParent;
455  }
456 
462  public function getParent()
463  {
464  return $this->_oParent;
465  }
466 
472  public function setIsComponent($blIsComponent = null)
473  {
474  $this->_blIsComponent = $blIsComponent;
475  }
476 
482  public function getIsComponent()
483  {
484  return $this->_blIsComponent;
485  }
486 
495  public function executeFunction($sFunction)
496  {
497  // execute
498  if ($sFunction && !self::$_blExecuted) {
499  if (method_exists($this, $sFunction)) {
500 
501 
502  $sNewAction = $this->$sFunction();
503  self::$_blExecuted = true;
504 
505  if (isset ($sNewAction)) {
506  $this->_executeNewAction($sNewAction);
507  }
508  } else {
509  // was not executed on any level ?
510  if (!$this->_blIsComponent) {
512  $oEx = oxNew('oxSystemComponentException');
513  $oEx->setMessage('ERROR_MESSAGE_SYSTEMCOMPONENT_FUNCTIONNOTFOUND');
514  $oEx->setComponent($sFunction);
515  throw $oEx;
516  }
517  }
518  }
519  }
520 
530  protected function _executeNewAction($sNewAction)
531  {
532  if ($sNewAction) {
533  $myConfig = $this->getConfig();
534 
535  // page parameters is the part which goes after '?'
536  $aParams = explode('?', $sNewAction);
537 
538  // action parameters is the part before '?'
539  $sPageParams = isset($aParams[1]) ? $aParams[1] : null;
540 
541  // looking for function name
542  $aParams = explode('/', $aParams[0]);
543  $sClassName = $aParams[0];
544  $sRealClassName = oxUtilsObject::getInstance()->getClassName($sClassName);
545 
546  if (false === class_exists($sRealClassName)) {
547  //If redirect tries to use a not existing class throw an exception.
548  //we'll be redirected to start page directly.
550  $oException = oxNew('oxSystemComponentException');
551  $oException->setMessage('ERROR_MESSAGE_SYSTEMCOMPONENT_CLASSNOTFOUND');
552  $oException->setComponent($sClassName);
553  throw $oException;
554  }
555 
556  // building redirect path ...
557  $sHeader = ($sClassName) ? "cl=$sClassName&" : ''; // adding view name
558  $sHeader .= ($sPageParams) ? "$sPageParams&" : ''; // adding page params
559  $sHeader .= $this->getSession()->sid(); // adding session Id
560 
561  $sUrl = $myConfig->getCurrentShopUrl($this->isAdmin());
562 
563  $sUrl = "{$sUrl}index.php?{$sHeader}";
564 
565  $sUrl = oxRegistry::get("oxUtilsUrl")->processUrl($sUrl);
566 
567  if (oxRegistry::getUtils()->seoIsActive() && $sSeoUrl = oxRegistry::get("oxSeoEncoder")->getStaticUrl($sUrl)) {
568  $sUrl = $sSeoUrl;
569  }
570 
571 
572  //#M341 do not add redirect parameter
573  oxRegistry::getUtils()->redirect($sUrl, (bool) $myConfig->getRequestParameter('redirected'), 302);
574  }
575  }
576 
582  public function getAdditionalParams()
583  {
584  return oxRegistry::get("oxUtilsUrl")->processUrl('', false);
585  }
586 
592  public function getTrustedShopId()
593  {
594  if ($this->_sTrustedShopId == null) {
595  $this->_sTrustedShopId = false;
596  $oConfig = $this->getConfig();
597  $aTsType = $oConfig->getConfigParam('tsSealType');
598  $sTsActive = $oConfig->getConfigParam('tsSealActive');
599  $aTrustedShopIds = $oConfig->getConfigParam('iShopID_TrustedShops');
600  $iLangId = (int) oxRegistry::getLang()->getBaseLanguage();
601  if ($sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'CLASSIC') {
602  // compatibility to old data
603  if (!is_array($aTrustedShopIds) && $iLangId == 0) {
604  $this->_sTrustedShopId = $aTrustedShopIds;
605  }
606  if (is_array($aTrustedShopIds)) {
607  $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
608  }
609  if (strlen($this->_sTrustedShopId) != 33 || substr($this->_sTrustedShopId, 0, 1) != 'X') {
610  $this->_sTrustedShopId = false;
611  }
612  }
613  }
614 
615  return $this->_sTrustedShopId;
616  }
617 
623  public function getTSExcellenceId()
624  {
625  if ($this->_sTSExcellenceId == null) {
626  $this->_sTSExcellenceId = false;
627  $oConfig = $this->getConfig();
628  $aTsType = $oConfig->getConfigParam('tsSealType');
629  $sTsActive = $oConfig->getConfigParam('tsSealActive');
630  $aTrustedShopIds = $oConfig->getConfigParam('iShopID_TrustedShops');
631  $iLangId = (int) oxRegistry::getLang()->getBaseLanguage();
632  if ($sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'EXCELLENCE') {
633  $this->_sTSExcellenceId = $aTrustedShopIds[$iLangId];
634  }
635  }
636 
638  }
639 
645  public function getCharSet()
646  {
647  if ($this->_sCharSet == null) {
648  $this->_sCharSet = oxRegistry::getLang()->translateString('charset');
649  }
650 
651  return $this->_sCharSet;
652  }
653 
659  public function getShopVersion()
660  {
661  if ($this->_sVersion == null) {
662  $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
663  }
664 
665  return $this->_sVersion;
666  }
667 
673  public function getShopEdition()
674  {
675  return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
676  }
677 
683  public function getRevision()
684  {
685  return $this->getConfig()->getRevision();
686  }
687 
693  public function getPackageInfo()
694  {
695  return $this->getConfig()->getPackageInfo();
696  }
697 
703  public function getShopFullEdition()
704  {
705  $sEdition = $this->getShopEdition();
706  $sFullEdition = "Community Edition";
707  if ($sEdition == "PE") {
708  $sFullEdition = "Professional Edition";
709  }
710 
711  if ($sEdition == "EE") {
712  $sFullEdition = "Enterprise Edition";
713  }
714 
715  return $sFullEdition;
716  }
717 
718 
724  public function isDemoVersion()
725  {
726  if ($this->_blDemoVersion == null) {
727  $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
728  }
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 
792  return $this->_blDemoShop;
793  }
794 
800  public function showNewsletter()
801  {
802  if ($this->_iNewsStatus === null) {
803  return 1;
804  }
805 
806  return $this->_iNewsStatus;
807  }
808 
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 
842  public function setShopLogo($sLogo)
843  {
844  $this->_sShopLogo = $sLogo;
845  }
846 
854  public function getActCategory()
855  {
856  // if active category is not set yet - trying to load it from request params
857  // this may be usefull when category component was unable to load active category
858  // and we still need some object to mount navigation info
859  if ($this->_oClickCat === null) {
860 
861  $this->_oClickCat = false;
862  $oCategory = oxNew('oxcategory');
863  if ($oCategory->load($this->getCategoryId())) {
864  $this->_oClickCat = $oCategory;
865  }
866  }
867 
868  return $this->_oClickCat;
869  }
870 
876  public function setActCategory($oCategory)
877  {
878  $this->_oClickCat = $oCategory;
879  }
880 
886  public function getCategoryId()
887  {
888  if ($this->_sCategoryId == null && ($sCatId = $this->getConfig()->getRequestParameter('cnid'))) {
889  $this->_sCategoryId = $sCatId;
890  }
891 
892  return $this->_sCategoryId;
893  }
894 
900  public function setCategoryId($sCategoryId)
901  {
902  $this->_sCategoryId = $sCategoryId;
903  }
904 
908  public function getErrorDestination()
909  {
910  }
911 
918  public function getActionClassName()
919  {
920  return $this->getClassName();
921  }
922 
928  public function isConnectedWithFb()
929  {
930  $myConfig = $this->getConfig();
931 
932  if ($myConfig->getConfigParam("bl_showFbConnect")) {
933  $oFb = oxRegistry::get("oxFb");
934 
935  return $oFb->isConnected();
936  }
937 
938  return false;
939  }
940 
946  public function getFbUserId()
947  {
948  if ($this->getConfig()->getConfigParam("bl_showFbConnect")) {
949  $oFb = oxRegistry::get("oxFb");
950 
951  return $oFb->getUser();
952  }
953  }
954 
961  public function showFbConnectToAccountMsg()
962  {
963  if ($this->getConfig()->getRequestParameter("fblogin")) {
964  if (!$this->getUser() || ($this->getUser() && $this->getSession()->getVariable('_blFbUserIdUpdated'))) {
965  return true;
966  } else {
967  return false;
968  }
969  }
970 
971  return false;
972  }
973 
979  public function isMall()
980  {
981  return false;
982  }
983 
989  public function showRdfa()
990  {
991  return false;
992  }
993 
994 
1002  public function getSidForWidget()
1003  {
1004  $sRet = null;
1005  $oSession = $this->getSession();
1006 
1007  if (!$oSession->isActualSidInCookie()) {
1008  $sRet = $oSession->getId();
1009  }
1010 
1011  return $sRet;
1012  }
1013 }