OXID eShop CE  4.9.6
 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 
528  protected function _executeNewAction($sNewAction)
529  {
530  if ($sNewAction) {
531  $myConfig = $this->getConfig();
532 
533  // page parameters is the part which goes after '?'
534  $aParams = explode('?', $sNewAction);
535 
536  // action parameters is the part before '?'
537  $sPageParams = isset($aParams[1]) ? $aParams[1] : null;
538 
539  // looking for function name
540  $aParams = explode('/', $aParams[0]);
541  $sClassName = $aParams[0];
542 
543  // building redirect path ...
544  $sHeader = ($sClassName) ? "cl=$sClassName&" : ''; // adding view name
545  $sHeader .= ($sPageParams) ? "$sPageParams&" : ''; // adding page params
546  $sHeader .= $this->getSession()->sid(); // adding session Id
547 
548  $sUrl = $myConfig->getCurrentShopUrl($this->isAdmin());
549 
550  $sUrl = "{$sUrl}index.php?{$sHeader}";
551 
552  $sUrl = oxRegistry::get("oxUtilsUrl")->processUrl($sUrl);
553 
554  if (oxRegistry::getUtils()->seoIsActive() && $sSeoUrl = oxRegistry::get("oxSeoEncoder")->getStaticUrl($sUrl)) {
555  $sUrl = $sSeoUrl;
556  }
557 
558 
559  //#M341 do not add redirect parameter
560  oxRegistry::getUtils()->redirect($sUrl, (bool) $myConfig->getRequestParameter('redirected'), 302);
561  }
562  }
563 
569  public function getAdditionalParams()
570  {
571  return oxRegistry::get("oxUtilsUrl")->processUrl('', false);
572  }
573 
579  public function getTrustedShopId()
580  {
581  if ($this->_sTrustedShopId == null) {
582  $this->_sTrustedShopId = false;
583  $oConfig = $this->getConfig();
584  $aTsType = $oConfig->getConfigParam('tsSealType');
585  $sTsActive = $oConfig->getConfigParam('tsSealActive');
586  $aTrustedShopIds = $oConfig->getConfigParam('iShopID_TrustedShops');
587  $iLangId = (int) oxRegistry::getLang()->getBaseLanguage();
588  if ($sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'CLASSIC') {
589  // compatibility to old data
590  if (!is_array($aTrustedShopIds) && $iLangId == 0) {
591  $this->_sTrustedShopId = $aTrustedShopIds;
592  }
593  if (is_array($aTrustedShopIds)) {
594  $this->_sTrustedShopId = $aTrustedShopIds[$iLangId];
595  }
596  if (strlen($this->_sTrustedShopId) != 33 || substr($this->_sTrustedShopId, 0, 1) != 'X') {
597  $this->_sTrustedShopId = false;
598  }
599  }
600  }
601 
602  return $this->_sTrustedShopId;
603  }
604 
610  public function getTSExcellenceId()
611  {
612  if ($this->_sTSExcellenceId == null) {
613  $this->_sTSExcellenceId = false;
614  $oConfig = $this->getConfig();
615  $aTsType = $oConfig->getConfigParam('tsSealType');
616  $sTsActive = $oConfig->getConfigParam('tsSealActive');
617  $aTrustedShopIds = $oConfig->getConfigParam('iShopID_TrustedShops');
618  $iLangId = (int) oxRegistry::getLang()->getBaseLanguage();
619  if ($sTsActive && $aTrustedShopIds && $aTsType[$iLangId] == 'EXCELLENCE') {
620  $this->_sTSExcellenceId = $aTrustedShopIds[$iLangId];
621  }
622  }
623 
625  }
626 
632  public function getCharSet()
633  {
634  if ($this->_sCharSet == null) {
635  $this->_sCharSet = oxRegistry::getLang()->translateString('charset');
636  }
637 
638  return $this->_sCharSet;
639  }
640 
646  public function getShopVersion()
647  {
648  if ($this->_sVersion == null) {
649  $this->_sVersion = $this->getConfig()->getActiveShop()->oxshops__oxversion->value;
650  }
651 
652  return $this->_sVersion;
653  }
654 
660  public function getShopEdition()
661  {
662  return $this->getConfig()->getActiveShop()->oxshops__oxedition->value;
663  }
664 
670  public function getRevision()
671  {
672  return $this->getConfig()->getRevision();
673  }
674 
680  public function getPackageInfo()
681  {
682  return $this->getConfig()->getPackageInfo();
683  }
684 
690  public function getShopFullEdition()
691  {
692  $sEdition = $this->getShopEdition();
693  $sFullEdition = "Community Edition";
694  if ($sEdition == "PE") {
695  $sFullEdition = "Professional Edition";
696  }
697 
698  if ($sEdition == "EE") {
699  $sFullEdition = "Enterprise Edition";
700  }
701 
702  return $sFullEdition;
703  }
704 
705 
711  public function isDemoVersion()
712  {
713  if ($this->_blDemoVersion == null) {
714  $this->_blDemoVersion = $this->getConfig()->detectVersion() == 1;
715  }
716 
717  return $this->_blDemoVersion;
718  }
719 
725  public function isBetaVersion()
726  {
727  $blBetaVersion = false;
728 
729  if (stripos($this->getConfig()->getVersion(), 'beta') !== false) {
730  $blBetaVersion = true;
731  }
732 
733  return $blBetaVersion;
734  }
735 
741  public function isRCVersion()
742  {
743  $blRCVersion = false;
744 
745  if (stripos($this->getConfig()->getVersion(), 'rc') !== false) {
746  $blRCVersion = true;
747  }
748 
749  return $blRCVersion;
750  }
751 
757  public function showBetaNote()
758  {
759  $blBetaNote = false;
760 
761  if ($this->isBetaVersion() || $this->isRCVersion()) {
762  $blBetaNote = true;
763  }
764 
765  return $blBetaNote;
766  }
767 
773  public function isDemoShop()
774  {
775  if ($this->_blDemoShop == null) {
776  $this->_blDemoShop = $this->getConfig()->isDemoShop();
777  }
778 
779  return $this->_blDemoShop;
780  }
781 
787  public function showNewsletter()
788  {
789  if ($this->_iNewsStatus === null) {
790  return 1;
791  }
792 
793  return $this->_iNewsStatus;
794  }
795 
801  public function setShowNewsletter($blShow)
802  {
803  $this->_iNewsStatus = $blShow;
804  }
805 
813  public function getShopLogo()
814  {
815  if ($this->_sShopLogo === null) {
816  $this->setShopLogo($this->getConfig()->getConfigParam('sShopLogo'));
817  }
818 
819  return $this->_sShopLogo;
820  }
821 
829  public function setShopLogo($sLogo)
830  {
831  $this->_sShopLogo = $sLogo;
832  }
833 
841  public function getActCategory()
842  {
843  // if active category is not set yet - trying to load it from request params
844  // this may be usefull when category component was unable to load active category
845  // and we still need some object to mount navigation info
846  if ($this->_oClickCat === null) {
847 
848  $this->_oClickCat = false;
849  $oCategory = oxNew('oxcategory');
850  if ($oCategory->load($this->getCategoryId())) {
851  $this->_oClickCat = $oCategory;
852  }
853  }
854 
855  return $this->_oClickCat;
856  }
857 
863  public function setActCategory($oCategory)
864  {
865  $this->_oClickCat = $oCategory;
866  }
867 
873  public function getCategoryId()
874  {
875  if ($this->_sCategoryId == null && ($sCatId = $this->getConfig()->getRequestParameter('cnid'))) {
876  $this->_sCategoryId = $sCatId;
877  }
878 
879  return $this->_sCategoryId;
880  }
881 
887  public function setCategoryId($sCategoryId)
888  {
889  $this->_sCategoryId = $sCategoryId;
890  }
891 
895  public function getErrorDestination()
896  {
897  }
898 
905  public function getActionClassName()
906  {
907  return $this->getClassName();
908  }
909 
915  public function isConnectedWithFb()
916  {
917  $myConfig = $this->getConfig();
918 
919  if ($myConfig->getConfigParam("bl_showFbConnect")) {
920  $oFb = oxRegistry::get("oxFb");
921 
922  return $oFb->isConnected();
923  }
924 
925  return false;
926  }
927 
933  public function getFbUserId()
934  {
935  if ($this->getConfig()->getConfigParam("bl_showFbConnect")) {
936  $oFb = oxRegistry::get("oxFb");
937 
938  return $oFb->getUser();
939  }
940  }
941 
948  public function showFbConnectToAccountMsg()
949  {
950  if ($this->getConfig()->getRequestParameter("fblogin")) {
951  if (!$this->getUser() || ($this->getUser() && $this->getSession()->getVariable('_blFbUserIdUpdated'))) {
952  return true;
953  } else {
954  return false;
955  }
956  }
957 
958  return false;
959  }
960 
966  public function isMall()
967  {
968  return false;
969  }
970 
976  public function showRdfa()
977  {
978  return false;
979  }
980 
981 
989  public function getSidForWidget()
990  {
991  $sRet = null;
992  $oSession = $this->getSession();
993 
994  if (!$oSession->isActualSidInCookie()) {
995  $sRet = $oSession->getId();
996  }
997 
998  return $sRet;
999  }
1000 }