00001 <?php
00002
00008 class oxViewConfig extends oxSuperCfg
00009 {
00015 protected $_oShop = null;
00016
00022 protected $_aViewData = null;
00023
00029 protected $_aConfigParams = array();
00030
00036 public function getHomeLink()
00037 {
00038 if ( ( $sValue = $this->getViewConfigParam( 'homeLink' ) ) === null ) {
00039 $myConfig = $this->getConfig();
00040 $myUtils = oxUtils::getInstance();
00041
00042 $sValue = null;
00043
00044
00045 if ( $myUtils->seoIsActive() && !$sValue && $iLang = oxLang::getInstance()->getBaseLanguage() ) {
00046 $sValue = oxSeoEncoder::getInstance()->getStaticUrl( $this->getSelfLink() . 'cl=start', $iLang );
00047 }
00048
00049 if ( !$sValue ) {
00050 $sValue = $this->getSession()->processUrl( $this->getBaseDir() );
00051 }
00052
00053 $this->setViewConfigParam( 'homeLink', $sValue );
00054 }
00055 return $sValue;
00056 }
00057
00063 public function getActTplName()
00064 {
00065 $sTplName = oxConfig::getParameter( 'tpl' );
00066
00067 if ( !$sTplName ) {
00068 $sTplName = $this->getViewConfigParam('tpl');
00069 }
00070 return $sTplName ? basename( $sTplName ) : null;
00071 }
00072
00078 public function getLogoutLink()
00079 {
00080 $sClass = $this->getActiveClassName();
00081 $sCatnid = $this->getActCatId();
00082 $sTplName = $this->getActTplName();
00083
00084 $sLink = $this->getConfig()->getShopHomeURL()."cl={$sClass}&".( $sCatnid ? "cnid={$sCatnid}" : '' )."&fnc=logout".( $sTplName ? "&tpl=".basename( $sTplName ) : '' )."&redirect=1";
00085 return $this->getSession()->processUrl( $sLink );
00086 }
00087
00093 public function getHelpLink()
00094 {
00095 $sTplName = $this->getActTplName();
00096 $sClass = $this->getActiveClassName();
00097 $sLink = $this->getConfig()->getShopCurrentURL()."cl=help&page={$sClass}".( $sTplName ? "&tpl={$sTplName}" : '' );
00098 return $this->getSession()->processUrl( $sLink );
00099 }
00100
00106 public function getActCatId()
00107 {
00108 return oxConfig::getParameter( 'cnid' );
00109 }
00110
00116 public function getActManufacturerId()
00117 {
00118 return oxConfig::getParameter( 'mnid' );
00119 }
00120
00128 public function getTypeLinkParams()
00129 {
00130 $sLink = '';
00131 if ( ( $sId = $this->getActCatId() ) ) {
00132 $sLink .= "cnid={$sId}";
00133 }
00134 if ( ( $sId = $this->getActManufacturerId() ) ) {
00135 $sLink .= "mnid={$sId}";
00136 }
00137
00138 return $sLink;
00139 }
00140
00148 public function getTypeParams()
00149 {
00150 $sForm = '';
00151 if ( ( $sId = $this->getActCatId() ) ) {
00152 $sForm .= "<input type=\"hidden\" name=\"cnid\" value=\"{$sId}\">\n";
00153 }
00154 if ( ( $sId = $this->getActManufacturerId() ) ) {
00155 $sForm .= "<input type=\"hidden\" name=\"mnid\" value=\"{$sId}\">\n";
00156 }
00157
00158 return $sForm;
00159 }
00160
00172 public function setViewConfigParam( $sName, $sValue )
00173 {
00174 startProfile('oxviewconfig::setViewConfigParam');
00175
00176 $this->_aConfigParams[$sName] = $sValue;
00177
00178 stopProfile('oxviewconfig::setViewConfigParam');
00179 }
00180
00188 public function getViewConfigParam( $sName )
00189 {
00190 startProfile('oxviewconfig::getViewConfigParam');
00191
00192 if ( $this->_oShop && isset( $this->_oShop->$sName ) ) {
00193 $sValue = $this->_oShop->$sName;
00194 } elseif ( $this->_aViewData && isset( $this->_aViewData[ $sName ] ) ) {
00195 $sValue = $this->_aViewData[ $sName ];
00196 } else {
00197 $sValue = ( isset( $this->_aConfigParams[ $sName ] ) ? $this->_aConfigParams[ $sName ] : null );
00198 }
00199
00200 stopProfile('oxviewconfig::getViewConfigParam');
00201
00202 return $sValue;
00203 }
00204
00214 public function setViewShop( $oShop, $aViewData )
00215 {
00216 $this->_oShop = $oShop;
00217 $this->_aViewData = $aViewData;
00218 }
00219
00232 public function __call( $sMethodName, $sParams )
00233 {
00234 startProfile('oxviewconfig::__call');
00235 if ( stripos( $sMethodName, 'get' ) === 0 ) {
00236 return $this->getViewVar( substr( $sMethodName, 3 ) );
00237 }
00238 stopProfile('oxviewconfig::__call');
00239 }
00240
00246 public function getSessionId()
00247 {
00248 if ( ( $sValue = $this->getViewConfigParam( 'sessionid' ) ) === null ) {
00249 $sValue = $this->getSession()->getId();
00250 $this->setViewConfigParam( 'sessionid', $sValue );
00251 }
00252 return $sValue;
00253 }
00254
00260 public function getHiddenSid()
00261 {
00262 if ( ( $sValue = $this->getViewConfigParam( 'hiddensid' ) ) === null ) {
00263 $sValue = $this->getSession()->hiddenSid();
00264 $this->setViewConfigParam( 'hiddensid', $sValue );
00265 }
00266 return $sValue;
00267 }
00268
00274 public function getSelfLink()
00275 {
00276 if ( ( $sValue = $this->getViewConfigParam( 'selflink' ) ) === null ) {
00277 $sValue = $this->getConfig()->getShopHomeURL();
00278 $this->setViewConfigParam( 'selflink', $sValue );
00279 }
00280 return $sValue;
00281 }
00282
00288 public function getSslSelfLink()
00289 {
00290 if ( ( $sValue = $this->getViewConfigParam( 'sslselflink' ) ) === null ) {
00291 $sValue = $this->getConfig()->getShopSecureHomeURL();
00292 $this->setViewConfigParam( 'sslselflink', $sValue );
00293 }
00294 return $sValue;
00295 }
00296
00302 public function getBaseDir()
00303 {
00304 if ( ( $sValue = $this->getViewConfigParam( 'basedir' ) ) === null ) {
00305 $sValue = $this->getConfig()->getShopURL();
00306 $this->setViewConfigParam( 'basedir', $sValue );
00307 }
00308 return $sValue;
00309 }
00310
00316 public function getCoreUtilsDir()
00317 {
00318 if ( ( $sValue = $this->getViewConfigParam( 'coreutilsdir' ) ) === null ) {
00319 $sValue = $this->getConfig()->getCoreUtilsURL();
00320 $this->setViewConfigParam( 'coreutilsdir', $sValue );
00321 }
00322 return $sValue;
00323 }
00324
00330 public function getSelfActionLink()
00331 {
00332 if ( ( $sValue = $this->getViewConfigParam( 'selfactionlink' ) ) === null ) {
00333 $sValue = $this->getConfig()->getShopCurrentUrl();
00334 $this->setViewConfigParam( 'selfactionlink', $sValue );
00335 }
00336 return $sValue;
00337 }
00338
00344 public function getCurrentHomeDir()
00345 {
00346 if ( ( $sValue = $this->getViewConfigParam( 'currenthomedir' ) ) === null ) {
00347 $sValue = $this->getConfig()->getCurrentShopUrl();
00348 $this->setViewConfigParam( 'currenthomedir', $sValue );
00349 }
00350 return $sValue;
00351 }
00352
00358 public function getBasketLink()
00359 {
00360 if ( ( $sValue = $this->getViewConfigParam( 'basketlink' ) ) === null ) {
00361 $sValue = $this->getConfig()->getShopHomeURL() . 'cl=basket';
00362 $this->setViewConfigParam( 'basketlink', $sValue );
00363 }
00364 return $sValue;
00365 }
00366
00372 public function getOrderLink()
00373 {
00374 if ( ( $sValue = $this->getViewConfigParam( 'orderlink' ) ) === null ) {
00375 $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=user';
00376 $this->setViewConfigParam( 'orderlink', $sValue );
00377 }
00378 return $sValue;
00379 }
00380
00386 public function getPaymentLink()
00387 {
00388 if ( ( $sValue = $this->getViewConfigParam( 'paymentlink' ) ) === null ) {
00389 $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=payment';
00390 $this->setViewConfigParam( 'paymentlink', $sValue );
00391 }
00392 return $sValue;
00393 }
00394
00400 public function getExeOrderLink()
00401 {
00402 if ( ( $sValue = $this->getViewConfigParam( 'exeorderlink' ) ) === null ) {
00403 $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=order&fnc=execute';
00404 $this->setViewConfigParam( 'exeorderlink', $sValue );
00405 }
00406 return $sValue;
00407 }
00408
00414 public function getOrderConfirmLink()
00415 {
00416 if ( ( $sValue = $this->getViewConfigParam( 'orderconfirmlink' ) ) === null ) {
00417 $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=order';
00418 $this->setViewConfigParam( 'orderconfirmlink', $sValue );
00419 }
00420 return $sValue;
00421 }
00422
00428 public function getResourceUrl()
00429 {
00430 if ( ( $sValue = $this->getViewConfigParam( 'basetpldir' ) ) === null ) {
00431 $sValue = $this->getConfig()->getResourceUrl( null, $this->isAdmin() );
00432 $this->setViewConfigParam( 'basetpldir', $sValue );
00433 }
00434 return $sValue;
00435 }
00436
00442 public function getTemplateDir()
00443 {
00444 if ( ( $sValue = $this->getViewConfigParam( 'templatedir' ) ) === null ) {
00445 $sValue = $this->getConfig()->getTemplateDir( $this->isAdmin() );
00446 $this->setViewConfigParam( 'templatedir', $sValue );
00447 }
00448 return $sValue;
00449 }
00450
00456 public function getUrlTemplateDir()
00457 {
00458 if ( ( $sValue = $this->getViewConfigParam( 'urltemplatedir' ) ) === null ) {
00459 $sValue = $this->getConfig()->getTemplateUrl( $this->isAdmin() );
00460 $this->setViewConfigParam( 'urltemplatedir', $sValue );
00461 }
00462 return $sValue;
00463 }
00464
00470 public function getImageUrl()
00471 {
00472 if ( ( $sValue = $this->getViewConfigParam( 'imagedir' ) ) === null ) {
00473 $sValue = $this->getConfig()->getImageUrl( $this->isAdmin() );
00474 $this->setViewConfigParam( 'imagedir', $sValue );
00475 }
00476 return $sValue;
00477 }
00478
00484 public function getNoSslImageDir()
00485 {
00486 if ( ( $sValue = $this->getViewConfigParam( 'nossl_imagedir' ) ) === null ) {
00487 $sValue = $this->getConfig()->getImageUrl( $this->isAdmin(), false );
00488 $this->setViewConfigParam( 'nossl_imagedir', $sValue );
00489 }
00490 return $sValue;
00491 }
00492
00499 public function getPictureDir()
00500 {
00501 if ( ( $sValue = $this->getViewConfigParam( 'picturedir' ) ) === null ) {
00502 $sValue = $this->getConfig()->getPictureUrl( null, $this->isAdmin() );
00503 $this->setViewConfigParam( 'picturedir', $sValue );
00504 }
00505 return $sValue;
00506 }
00507
00513 public function getAdminDir()
00514 {
00515 if ( ( $sValue = $this->getViewConfigParam( 'sAdminDir' ) ) === null ) {
00516 $sValue = $this->getConfig()->getConfigParam( 'sAdminDir' );
00517 $this->setViewConfigParam( 'sAdminDir', $sValue );
00518 }
00519 return $sValue;
00520 }
00521
00527 public function getActiveShopId()
00528 {
00529 if ( ( $sValue = $this->getViewConfigParam( 'shopid' ) ) === null ) {
00530 $sValue = $this->getConfig()->getShopId();
00531 $this->setViewConfigParam( 'shopid', $sValue );
00532 }
00533 return $sValue;
00534 }
00535
00541 public function isSsl()
00542 {
00543 if ( ( $sValue = $this->getViewConfigParam( 'isssl' ) ) === null ) {
00544 $sValue = $this->getConfig()->isSsl();
00545 $this->setViewConfigParam( 'isssl', $sValue );
00546 }
00547 return $sValue;
00548 }
00549
00550
00556 public function getRemoteAddress()
00557 {
00558 if ( ( $sValue = $this->getViewConfigParam( 'ip' ) ) === null ) {
00559 $sValue = oxUtilsServer::getInstance()->getRemoteAddress();
00560 $this->setViewConfigParam( 'ip', $sValue );
00561 }
00562 return $sValue;
00563 }
00564
00570 public function getPopupIdent()
00571 {
00572 if ( ( $sValue = $this->getViewConfigParam( 'popupident' ) ) === null ) {
00573 $sValue = md5( $this->getConfig()->getShopUrl() );
00574 $this->setViewConfigParam( 'popupident', $sValue );
00575 }
00576 return $sValue;
00577 }
00578
00584 public function getPopupIdentRand()
00585 {
00586 if ( ( $sValue = $this->getViewConfigParam( 'popupidentrand' ) ) === null ) {
00587 $sValue = md5( time() );
00588 $this->setViewConfigParam( 'popupidentrand', $sValue );
00589 }
00590 return $sValue;
00591 }
00592
00598 public function getArtPerPageForm()
00599 {
00600 if ( ( $sValue = $this->getViewConfigParam( 'artperpageform' ) ) === null ) {
00601 $sValue = $this->getConfig()->getShopCurrentUrl();
00602 $this->setViewConfigParam( 'artperpageform', $sValue );
00603 }
00604 return $sValue;
00605 }
00606
00612 public function isBuyableParent()
00613 {
00614 return $this->getConfig()->getConfigParam( 'blVariantParentBuyable' );
00615 }
00616
00622 public function showBirthdayFields()
00623 {
00624 return $this->getConfig()->getConfigParam( 'blShowBirthdayFields' );
00625 }
00626
00632 public function showFinalStep()
00633 {
00634 return $this->getConfig()->getConfigParam( 'blShowFinalStep' );
00635 }
00636
00642 public function getNrOfCatArticles()
00643 {
00644 return $this->getConfig()->getConfigParam( 'aNrofCatArticles' );
00645 }
00646
00652 public function isAutoSearchOnCat()
00653 {
00654 return $this->getConfig()->getConfigParam( 'blAutoSearchOnCat' );
00655 }
00656
00662 public function getActLanguageId()
00663 {
00664 if ( ( $sValue = $this->getViewConfigParam( 'lang' ) ) === null ) {
00665 $iLang = oxConfig::getParameter( 'lang' );
00666 $sValue = ( $iLang !== null ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00667 $this->setViewConfigParam( 'lang', $sValue );
00668 }
00669 return $sValue;
00670 }
00671
00677 public function getActiveClassName()
00678 {
00679 return $this->getConfig()->getActiveView()->getClassName();
00680 }
00681
00687 public function getArtPerPageCount()
00688 {
00689 return $this->getViewConfigParam( 'iartPerPage' );
00690 }
00691
00697 public function getNavUrlParams()
00698 {
00699 if ( ( $sParams = $this->getViewConfigParam( 'navurlparams' ) ) === null ) {
00700 $sParams = '';
00701 $aNavParams = $this->getConfig()->getActiveView()->getNavigationParams();
00702 foreach ( $aNavParams as $sName => $sValue ) {
00703 if ( isset( $sValue ) ) {
00704 if ( $sParams ) {
00705 $sParams .= '&';
00706 }
00707 $sParams .= "{$sName}=".rawurlencode( $sValue );
00708 }
00709 }
00710 if ( $sParams ) {
00711 $sParams = '&'.$sParams;
00712 }
00713 $this->setViewConfigParam( 'navurlparams', $sParams );
00714 }
00715
00716 return $sParams;
00717 }
00718
00724 public function getNavFormParams()
00725 {
00726
00727 if ( ( $sParams = $this->getViewConfigParam( 'navformparams' ) ) === null ) {
00728 $oStr = getStr();
00729 $sParams = '';
00730 $aNavParams = $this->getConfig()->getActiveView()->getNavigationParams();
00731 foreach ( $aNavParams as $sName => $sValue ) {
00732 if ( isset( $sValue ) ) {
00733 $sParams .= "<input type=\"hidden\" name=\"{$sName}\" value=\"".$oStr->htmlentities( $sValue )."\">\n";
00734 }
00735 }
00736 $this->setViewConfigParam( 'navformparams', $sParams );
00737 }
00738 return $sParams;
00739 }
00740
00746 public function getStockOnDefaultMessage()
00747 {
00748 return $this->getConfig()->getConfigParam( 'blStockOnDefaultMessage' );
00749 }
00750
00756 public function getStockOffDefaultMessage()
00757 {
00758 return $this->getConfig()->getConfigParam( 'blStockOffDefaultMessage' );
00759 }
00760
00766 public function getShopVersion()
00767 {
00768 return $this->getViewConfigParam( 'sShopVersion' );
00769 }
00770
00776 public function getAjaxLink()
00777 {
00778 return $this->getViewConfigParam( 'ajaxlink' );
00779 }
00780
00786 public function isMultiShop()
00787 {
00788 $oShop = $this->getConfig()->getActiveShop();
00789 return isset( $oShop->oxshops__oxismultishop ) ? ( (bool) $oShop->oxshops__oxismultishop->value ) : false;
00790 }
00791
00797 public function getServiceUrl()
00798 {
00799 return $this->getViewConfigParam( 'sServiceUrl' );
00800 }
00801
00809 public function __get( $sVarName )
00810 {
00811 return $this->getViewVar( $sVarName );
00812 }
00813
00821 public function getViewVar( $sVarName )
00822 {
00823 startProfile('oxviewconfig::__get');
00824
00825 $myConfig = $this->getConfig();
00826
00827
00828 if ( ( $sVarValue = $this->getViewConfigParam( $sVarName ) ) === null ) {
00829
00830
00831 switch ( strtolower( $sVarName ) ) {
00832 case 'sid' :
00833 $sVarValue = $this->getSessionId();
00834 break;
00835 case 'hiddensid' :
00836 $sVarValue = $this->getHiddenSid();
00837 break;
00838 case 'selflink' :
00839 $sVarValue = $this->getSelfLink();
00840 break;
00841 case 'sslselflink' :
00842 $sVarValue = $this->getSslSelfLink();
00843 break;
00844
00845 case 'basedir' :
00846 $sVarValue = $this->getBaseDir();
00847 break;
00848 case 'coreutilsdir' :
00849 $sVarValue = $this->getCoreUtilsDir();
00850 break;
00851 case 'selfactionlink' :
00852 $sVarValue = $this->getSelfActionLink();
00853 break;
00854
00855 case 'currenthomedir' :
00856 $sVarValue = $this->getCurrentHomeDir();
00857 break;
00858 case 'basketlink' :
00859 $sVarValue = $this->getBasketLink();
00860 break;
00861 case 'orderlink' :
00862 $sVarValue = $this->getOrderLink();
00863 break;
00864 case 'paymentlink' :
00865 $sVarValue = $this->getPaymentLink();
00866 break;
00867 case 'exeorderlink' :
00868 $sVarValue = $this->getExeOrderLink();
00869 break;
00870 case 'orderconfirmlink' :
00871 $sVarValue = $this->getOrderConfirmLink();
00872 break;
00873 case 'basetpldir' :
00874 $sVarValue = $this->getResourceUrl();
00875 break;
00876 case 'templatedir' :
00877 $sVarValue = $this->getTemplateDir();
00878 break;
00879 case 'urltemplatedir' :
00880 $sVarValue = $this->getUrlTemplateDir();
00881 break;
00882 case 'imagedir' :
00883 $sVarValue = $this->getImageUrl();
00884 break;
00885 case 'nossl_imagedir' :
00886 $sVarValue = $this->getNoSslImageDir();
00887 break;
00888 case 'dimagedir' :
00889 $sVarValue = $this->getPictureDir();
00890 break;
00891
00892
00893 case 'admindir' :
00894 $sVarValue = $this->getAdminDir();
00895 break;
00896 case 'id' :
00897 $sVarValue = $this->getActiveShopId();
00898 break;
00899 case 'isssl' :
00900 $sVarValue = $this->isSsl();
00901 break;
00902 case 'ip' :
00903 $sVarValue = $this->getRemoteAddress();
00904 break;
00905 case 'popupident' :
00906 $sVarValue = $this->getPopupIdent();
00907 break;
00908 case 'popupidentrand' :
00909 $sVarValue = $this->getPopupIdentRand();
00910 break;
00911 case 'artperpageform' :
00912 $sVarValue = $this->getArtPerPageForm();
00913 break;
00914 case 'buyableparent' :
00915 $sVarValue = $this->isBuyableParent();
00916 break;
00917 case 'blshowbirthdayfields' :
00918 $sVarValue = $this->showBirthdayFields();
00919 break;
00920 case 'blshowfinalstep' :
00921 $sVarValue = $this->showFinalStep();
00922 break;
00923 case 'anrofcatarticles' :
00924 $sVarValue = $this->getNrOfCatArticles();
00925 break;
00926 case 'blautosearchoncat' :
00927 $sVarValue = $this->isAutoSearchOnCat();
00928 break;
00929 case 'cnid' :
00930 $sVarValue = $this->getActCatId();
00931 break;
00932 case 'cl' :
00933 $sVarValue = $this->getActiveClassName();
00934 break;
00935 case 'tpl' :
00936 $sVarValue = $this->getActTplName();
00937 break;
00938 case 'lang' :
00939 case 'slanguage' :
00940 $sVarValue = $this->getActLanguageId();
00941 break;
00942 case 'helplink' :
00943 $sVarValue = $this->getHelpLink();
00944 break;
00945 case 'logoutlink' :
00946 $sVarValue = $this->getLogoutLink();
00947 break;
00948 case 'iartPerPage':
00949 $sVarValue = $this->getArtPerPageCount();
00950 break;
00951 case 'navurlparams':
00952 $sVarValue = $this->getNavUrlParams();
00953 break;
00954 case 'navformparams':
00955 $sVarValue = $this->getNavFormParams();
00956 break;
00957 case 'blstockondefaultmessage':
00958 $sVarValue = $this->getStockOnDefaultMessage();
00959 break;
00960 case 'blstockoffdefaultmessage':
00961 $sVarValue = $this->getStockOffDefaultMessage();
00962 break;
00963 case 'sShopVersion':
00964 $sVarValue = $this->getShopVersion();
00965 break;
00966 case 'ajaxlink':
00967 $sVarValue = $this->getAjaxLink();
00968 break;
00969 case 'ismultishop':
00970 $sVarValue = $this->isMultiShop();
00971 break;
00972 case 'sServiceUrl':
00973 $sVarValue = $this->getServiceUrl();
00974 break;
00975 }
00976 }
00977
00978 $this->setViewConfigParam( $sVarName, $sVarValue );
00979
00980 stopProfile('oxviewconfig::__get');
00981
00982 return $sVarValue;
00983 }
00984
00985
00986
00987
00988
00989 }