OXID eShop CE  4.10.1
 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 
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 
594  public function getTrustedShopId()
595  {
596  if ($this->_sTrustedShopId == null) {
597  $this->_sTrustedShopId = false;
598  $oConfig = $this->getConfig();
599  $aTsType = $oConfig->getConfigParam('tsSealType');
600  $sTsActive = $oConfig->getConfigParam('tsSealActive');
601  $aTrustedShopIds = $oConfig->getConfigParam('iShopID_TrustedShops');
602  $iLangId = (int) oxRegistry::getLang()->getBaseLanguage();
603  if ($sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'CLASSIC') {
604  // compatibility to old data
605  if (!is_array($aTrustedShopIds) && $iLangId == 0) {
606  $this->_sTrustedShopId = $aTrustedShopIds;
607  }
608  if (is_array($aTrustedShopIds)) {
609  $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
610  }
611  if (strlen($this->_sTrustedShopId) != 33 || substr($this->_sTrustedShopId, 0, 1) != 'X') {
612  $this->_sTrustedShopId = false;
613  }
614  }
615  }
616 
617  return $this->_sTrustedShopId;
618  }
619 
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  }
640 
642  }
643 
649  public function getCharSet()
650  {
651  if ($this->_sCharSet == null) {
652  $this->_sCharSet = oxRegistry::getLang()->translateString('charset');
653  }
654 
655  return $this->_sCharSet;
656  }
657 
663  public function getShopVersion()
664  {
665  if ($this->_sVersion == null) {
666  $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
667  }
668 
669  return $this->_sVersion;
670  }
671 
677  public function getShopEdition()
678  {
679  return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
680  }
681 
687  public function getRevision()
688  {
689  return $this->getConfig()->getRevision();
690  }
691 
697  public function getPackageInfo()
698  {
699  return $this->getConfig()->getPackageInfo();
700  }
701 
707  public function getShopFullEdition()
708  {
709  $sEdition = $this->getShopEdition();
710  $sFullEdition = "Community Edition";
711  if ($sEdition == "PE") {
712  $sFullEdition = "Professional Edition";
713  }
714 
715  if ($sEdition == "EE") {
716  $sFullEdition = "Enterprise Edition";
717  }
718 
719  return $sFullEdition;
720  }
721 
722 
728  public function isDemoVersion()
729  {
730  if ($this->_blDemoVersion == null) {
731  $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
732  }
733 
734  return $this->_blDemoVersion;
735  }
736 
742  public function isBetaVersion()
743  {
744  $blBetaVersion = false;
745 
746  if (stripos($this->getConfig()->getVersion(), 'beta') !== false) {
747  $blBetaVersion = true;
748  }
749 
750  return $blBetaVersion;
751  }
752 
758  public function isRCVersion()
759  {
760  $blRCVersion = false;
761 
762  if (stripos($this->getConfig()->getVersion(), 'rc') !== false) {
763  $blRCVersion = true;
764  }
765 
766  return $blRCVersion;
767  }
768 
774  public function showBetaNote()
775  {
776  $blBetaNote = false;
777 
778  if ($this->isBetaVersion() || $this->isRCVersion()) {
779  $blBetaNote = true;
780  }
781 
782  return $blBetaNote;
783  }
784 
790  public function isDemoShop()
791  {
792  if ($this->_blDemoShop == null) {
793  $this->_blDemoShop = $this->getConfig()->isDemoShop();
794  }
795 
796  return $this->_blDemoShop;
797  }
798 
804  public function showNewsletter()
805  {
806  if ($this->_iNewsStatus === null) {
807  return 1;
808  }
809 
810  return $this->_iNewsStatus;
811  }
812 
818  public function setShowNewsletter($blShow)
819  {
820  $this->_iNewsStatus = $blShow;
821  }
822 
830  public function getShopLogo()
831  {
832  if ($this->_sShopLogo === null) {
833  $this->setShopLogo($this->getConfig()->getConfigParam('sShopLogo'));
834  }
835 
836  return $this->_sShopLogo;
837  }
838 
846  public function setShopLogo($sLogo)
847  {
848  $this->_sShopLogo = $sLogo;
849  }
850 
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 
880  public function setActCategory($oCategory)
881  {
882  $this->_oClickCat = $oCategory;
883  }
884 
890  public function getCategoryId()
891  {
892  if ($this->_sCategoryId == null && ($sCatId = $this->getConfig()->getRequestParameter('cnid'))) {
893  $this->_sCategoryId = $sCatId;
894  }
895 
896  return $this->_sCategoryId;
897  }
898 
904  public function setCategoryId($sCategoryId)
905  {
906  $this->_sCategoryId = $sCategoryId;
907  }
908 
912  public function getErrorDestination()
913  {
914  }
915 
922  public function getActionClassName()
923  {
924  return $this->getClassName();
925  }
926 
934  public function isConnectedWithFb()
935  {
936  $myConfig = $this->getConfig();
937 
938  if ($myConfig->getConfigParam("bl_showFbConnect")) {
939  $oFb = oxRegistry::get("oxFb");
940 
941  return $oFb->isConnected();
942  }
943 
944  return false;
945  }
946 
954  public function getFbUserId()
955  {
956  if ($this->getConfig()->getConfigParam("bl_showFbConnect")) {
957  $oFb = oxRegistry::get("oxFb");
958 
959  return $oFb->getUser();
960  }
961  }
962 
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 }