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
00039 return $this->getBaseDir();
00040 }
00041
00047 public function getActTplName()
00048 {
00049 $sTplName = oxConfig::getParameter( 'tpl' );
00050 return $sTplName ? basename( $sTplName ) : null;
00051 }
00052
00058 public function getLogoutLink()
00059 {
00060 $sClass = $this->getActiveClassName();
00061 $sCatnid = $this->getActCatId();
00062 $sTplName = $this->getActTplName();
00063
00064 return $this->getConfig()->getShopHomeURL()."cl={$sClass}&".( $sCatnid ? "cnid={$sCatnid} " : '' )."&fnc=logout".( $sTplName ? "&tpl=".basename( $sTplName ) : '' )."&redirect=1";
00065 }
00066
00072 public function getHelpLink()
00073 {
00074 $sTplName = $this->getActTplName();
00075 $sClass = $this->getActiveClassName();
00076 return $this->getConfig()->getShopCurrentURL()."cl=help&page={$sClass}".( $sTplName ? "&tpl={$sTplName}" : '' );
00077 }
00078
00084 public function getActCatId()
00085 {
00086 return oxConfig::getParameter( 'cnid' );
00087 }
00088
00094 public function getActManufacturerId()
00095 {
00096 return oxConfig::getParameter( 'mnid' );
00097 }
00098
00106 public function getTypeLinkParams()
00107 {
00108 $sLink = '';
00109 if ( ( $sId = $this->getActCatId() ) ) {
00110 $sLink .= "cnid={$sId}";
00111 }
00112 if ( ( $sId = $this->getActManufacturerId() ) ) {
00113 $sLink .= "mnid={$sId}";
00114 }
00115
00116 return $sLink;
00117 }
00118
00126 public function getTypeParams()
00127 {
00128 $sForm = '';
00129 if ( ( $sId = $this->getActCatId() ) ) {
00130 $sForm .= "<input type=\"hidden\" name=\"cnid\" value=\"{$sId}\">\n";
00131 }
00132 if ( ( $sId = $this->getActManufacturerId() ) ) {
00133 $sForm .= "<input type=\"hidden\" name=\"mnid\" value=\"{$sId}\">\n";
00134 }
00135
00136 return $sForm;
00137 }
00138
00150 public function setViewConfigParam( $sName, $sValue )
00151 {
00152 startProfile('oxviewconfig::setViewConfigParam');
00153
00154 $this->_aConfigParams[$sName] = $sValue;
00155
00156 stopProfile('oxviewconfig::setViewConfigParam');
00157 }
00158
00166 public function getViewConfigParam( $sName )
00167 {
00168 startProfile('oxviewconfig::getViewConfigParam');
00169
00170 if ( $this->_oShop && isset( $this->_oShop->$sName ) ) {
00171 $sValue = $this->_oShop->$sName;
00172 } elseif( $this->_aViewData && isset( $this->_aViewData[ $sName ] ) ) {
00173 $sValue = $this->_aViewData[ $sName ];
00174 } else {
00175 $sValue = ( isset( $this->_aConfigParams[ $sName ] ) ? $this->_aConfigParams[ $sName ] : null );
00176 }
00177
00178 stopProfile('oxviewconfig::getViewConfigParam');
00179
00180 return $sValue;
00181 }
00182
00192 public function setViewShop( $oShop, $aViewData )
00193 {
00194 $this->_oShop = $oShop;
00195 $this->_aViewData = $aViewData;
00196 }
00197
00210 public function __call( $sMethodName, $sParams )
00211 {
00212 startProfile('oxviewconfig::__call');
00213 if ( stripos( $sMethodName, 'get' ) === 0 ) {
00214 return $this->__get( substr( $sMethodName, 3 ) );
00215 }
00216 stopProfile('oxviewconfig::__call');
00217 }
00218
00224 public function getSessionId()
00225 {
00226 if ( ( $sValue = $this->getViewConfigParam( 'sessionid' ) ) === null ) {
00227 $sValue = $this->getSession()->getId();
00228 $this->setViewConfigParam( 'sessionid', $sValue );
00229 }
00230 return $sValue;
00231 }
00232
00238 public function getHiddenSid()
00239 {
00240 if ( ( $sValue = $this->getViewConfigParam( 'hiddensid' ) ) === null ) {
00241 $sValue = $this->getSession()->hiddenSid();
00242 $this->setViewConfigParam( 'hiddensid', $sValue );
00243 }
00244 return $sValue;
00245 }
00246
00252 public function getSelfLink()
00253 {
00254 if ( ( $sValue = $this->getViewConfigParam( 'selflink' ) ) === null ) {
00255 $sValue = $this->getConfig()->getShopHomeURL();
00256 $this->setViewConfigParam( 'selflink', $sValue );
00257 }
00258 return $sValue;
00259 }
00260
00266 public function getSslSelfLink()
00267 {
00268 if ( ( $sValue = $this->getViewConfigParam( 'sslselflink' ) ) === null ) {
00269 $sValue = $this->getConfig()->getShopSecureHomeURL();
00270 $this->setViewConfigParam( 'sslselflink', $sValue );
00271 }
00272 return $sValue;
00273 }
00274
00280 public function getBaseDir()
00281 {
00282 if ( ( $sValue = $this->getViewConfigParam( 'basedir' ) ) === null ) {
00283 $sValue = $this->getConfig()->getShopURL();
00284 $this->setViewConfigParam( 'basedir', $sValue );
00285 }
00286 return $sValue;
00287 }
00288
00294 public function getCoreUtilsDir()
00295 {
00296 if ( ( $sValue = $this->getViewConfigParam( 'coreutilsdir' ) ) === null ) {
00297 $sValue = $this->getConfig()->getCoreUtilsURL();
00298 $this->setViewConfigParam( 'coreutilsdir', $sValue );
00299 }
00300 return $sValue;
00301 }
00302
00308 public function getSelfActionLink()
00309 {
00310 if ( ( $sValue = $this->getViewConfigParam( 'selfactionlink' ) ) === null ) {
00311 $sValue = $this->getConfig()->getShopCurrentUrl();
00312 $this->setViewConfigParam( 'selfactionlink', $sValue );
00313 }
00314 return $sValue;
00315 }
00316
00322 public function getCurrentHomeDir()
00323 {
00324 if ( ( $sValue = $this->getViewConfigParam( 'currenthomedir' ) ) === null ) {
00325 $sValue = $this->getConfig()->getCurrentShopUrl();
00326 $this->setViewConfigParam( 'currenthomedir', $sValue );
00327 }
00328 return $sValue;
00329 }
00330
00336 public function getBasketLink()
00337 {
00338 if ( ( $sValue = $this->getViewConfigParam( 'basketlink' ) ) === null ) {
00339 $sValue = $this->getConfig()->getShopHomeURL() . 'cl=basket';
00340 $this->setViewConfigParam( 'basketlink', $sValue );
00341 }
00342 return $sValue;
00343 }
00344
00350 public function getOrderLink()
00351 {
00352 if ( ( $sValue = $this->getViewConfigParam( 'orderlink' ) ) === null ) {
00353 $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=user';
00354 $this->setViewConfigParam( 'orderlink', $sValue );
00355 }
00356 return $sValue;
00357 }
00358
00364 public function getPaymentLink()
00365 {
00366 if ( ( $sValue = $this->getViewConfigParam( 'paymentlink' ) ) === null ) {
00367 $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=payment';
00368 $this->setViewConfigParam( 'paymentlink', $sValue );
00369 }
00370 return $sValue;
00371 }
00372
00378 public function getExeOrderLink()
00379 {
00380 if ( ( $sValue = $this->getViewConfigParam( 'exeorderlink' ) ) === null ) {
00381 $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=order&fnc=execute';
00382 $this->setViewConfigParam( 'exeorderlink', $sValue );
00383 }
00384 return $sValue;
00385 }
00386
00392 public function getOrderConfirmLink()
00393 {
00394 if ( ( $sValue = $this->getViewConfigParam( 'orderconfirmlink' ) ) === null ) {
00395 $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=order';
00396 $this->setViewConfigParam( 'orderconfirmlink', $sValue );
00397 }
00398 return $sValue;
00399 }
00400
00406 public function getResourceUrl()
00407 {
00408 if ( ( $sValue = $this->getViewConfigParam( 'basetpldir' ) ) === null ) {
00409 $sValue = $this->getConfig()->getResourceUrl( null, $this->isAdmin() );
00410 $this->setViewConfigParam( 'basetpldir', $sValue );
00411 }
00412 return $sValue;
00413 }
00414
00420 public function getTemplateDir()
00421 {
00422 if ( ( $sValue = $this->getViewConfigParam( 'templatedir' ) ) === null ) {
00423 $sValue = $this->getConfig()->getTemplateDir( $this->isAdmin() );
00424 $this->setViewConfigParam( 'templatedir', $sValue );
00425 }
00426 return $sValue;
00427 }
00428
00434 public function getUrlTemplateDir()
00435 {
00436 if ( ( $sValue = $this->getViewConfigParam( 'urltemplatedir' ) ) === null ) {
00437 $sValue = $this->getConfig()->getTemplateUrl( $this->isAdmin() );
00438 $this->setViewConfigParam( 'urltemplatedir', $sValue );
00439 }
00440 return $sValue;
00441 }
00442
00448 public function getImageUrl()
00449 {
00450 if ( ( $sValue = $this->getViewConfigParam( 'imagedir' ) ) === null ) {
00451 $sValue = $this->getConfig()->getImageUrl( $this->isAdmin() );
00452 $this->setViewConfigParam( 'imagedir', $sValue );
00453 }
00454 return $sValue;
00455 }
00456
00462 public function getNoSslImageDir()
00463 {
00464 if ( ( $sValue = $this->getViewConfigParam( 'nossl_imagedir' ) ) === null ) {
00465 $sValue = $this->getConfig()->getImageUrl( $this->isAdmin() , false );
00466 $this->setViewConfigParam( 'nossl_imagedir', $sValue );
00467 }
00468 return $sValue;
00469 }
00470
00477 public function getPictureDir()
00478 {
00479 if ( ( $sValue = $this->getViewConfigParam( 'picturedir' ) ) === null ) {
00480 $sValue = $this->getConfig()->getPictureUrl( null , $this->isAdmin() );
00481 $this->setViewConfigParam( 'picturedir', $sValue );
00482 }
00483 return $sValue;
00484 }
00485
00491 public function getAdminDir()
00492 {
00493 if ( ( $sValue = $this->getViewConfigParam( 'sAdminDir' ) ) === null ) {
00494 $sValue = $this->getConfig()->getConfigParam( 'sAdminDir' );
00495 $this->setViewConfigParam( 'sAdminDir', $sValue );
00496 }
00497 return $sValue;
00498 }
00499
00505 public function getActiveShopId()
00506 {
00507 if ( ( $sValue = $this->getViewConfigParam( 'shopid' ) ) === null ) {
00508 $sValue = $this->getConfig()->getShopId();
00509 $this->setViewConfigParam( 'shopid', $sValue );
00510 }
00511 return $sValue;
00512 }
00513
00519 public function isSsl()
00520 {
00521 if ( ( $sValue = $this->getViewConfigParam( 'isssl' ) ) === null ) {
00522 $sValue = $this->getConfig()->isSsl();
00523 $this->setViewConfigParam( 'isssl', $sValue );
00524 }
00525 return $sValue;
00526 }
00527
00528
00534 public function getRemoteAddress()
00535 {
00536 if ( ( $sValue = $this->getViewConfigParam( 'ip' ) ) === null ) {
00537 $sValue = oxUtilsServer::getInstance()->getRemoteAddress();
00538 $this->setViewConfigParam( 'ip', $sValue );
00539 }
00540 return $sValue;
00541 }
00542
00548 public function getPopupIdent()
00549 {
00550 if ( ( $sValue = $this->getViewConfigParam( 'popupident' ) ) === null ) {
00551 $sValue = md5( $this->getConfig()->getShopUrl() );
00552 $this->setViewConfigParam( 'popupident', $sValue );
00553 }
00554 return $sValue;
00555 }
00556
00562 public function getPopupIdentRand()
00563 {
00564 if ( ( $sValue = $this->getViewConfigParam( 'popupidentrand' ) ) === null ) {
00565 $sValue = md5( time() );
00566 $this->setViewConfigParam( 'popupidentrand', $sValue );
00567 }
00568 return $sValue;
00569 }
00570
00576 public function getArtPerPageForm()
00577 {
00578 if ( ( $sValue = $this->getViewConfigParam( 'artperpageform' ) ) === null ) {
00579 $sValue = $this->getConfig()->getShopCurrentUrl();
00580 $this->setViewConfigParam( 'artperpageform', $sValue );
00581 }
00582 return $sValue;
00583 }
00584
00590 public function isBuyableParent()
00591 {
00592 return $this->getConfig()->getConfigParam( 'blVariantParentBuyable' );
00593 }
00594
00600 public function showBirthdayFields()
00601 {
00602 return $this->getConfig()->getConfigParam( 'blShowBirthdayFields' );
00603 }
00604
00610 public function showFinalStep()
00611 {
00612 return $this->getConfig()->getConfigParam( 'blShowFinalStep' );
00613 }
00614
00620 public function getNrOfCatArticles()
00621 {
00622 return $this->getConfig()->getConfigParam( 'aNrofCatArticles' );
00623 }
00624
00630 public function isAutoSearchOnCat()
00631 {
00632 return $this->getConfig()->getConfigParam( 'blAutoSearchOnCat' );
00633 }
00634
00640 public function getActLanguageId()
00641 {
00642 if ( ( $sValue = $this->getViewConfigParam( 'lang' ) ) === null ) {
00643 $iLang = oxConfig::getParameter( 'lang' );
00644 $sValue = ( $iLang !== null ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00645 $this->setViewConfigParam( 'lang', $sValue );
00646 }
00647 return $sValue;
00648 }
00649
00655 public function getActiveClassName()
00656 {
00657 return $this->getConfig()->getActiveView()->getClassName();
00658 }
00659
00665 public function getArtPerPageCount()
00666 {
00667 return $this->getViewConfigParam( 'iartPerPage' );
00668 }
00669
00675 public function getNavUrlParams()
00676 {
00677 if ( ( $sParams = $this->getViewConfigParam( 'navurlparams' ) ) === null ) {
00678 $sParams = '';
00679 $aNavParams = $this->getConfig()->getActiveView()->getNavigationParams();
00680 foreach ( $aNavParams as $sName => $sValue ) {
00681 if ( isset( $sValue ) ) {
00682 if ( $sParams ) {
00683 $sParams .= '&';
00684 }
00685 $sParams .= "{$sName}=".rawurlencode( $sValue );
00686 }
00687 }
00688 if ( $sParams ) {
00689 $sParams = '&'.$sParams;
00690 }
00691 $this->setViewConfigParam( 'navurlparams', $sParams );
00692 }
00693
00694 return $sParams;
00695 }
00696
00702 public function getNavFormParams()
00703 {
00704
00705 if ( ( $sParams = $this->getViewConfigParam( 'navformparams' ) ) === null ) {
00706 $oStr = getStr();
00707 $sParams = '';
00708 $aNavParams = $this->getConfig()->getActiveView()->getNavigationParams();
00709 foreach ( $aNavParams as $sName => $sValue ) {
00710 if ( isset( $sValue ) ) {
00711 $sParams .= "<input type=\"hidden\" name=\"{$sName}\" value=\"".$oStr->htmlentities( $sValue )."\">\n";
00712 }
00713 }
00714 $this->setViewConfigParam( 'navformparams', $sParams );
00715 }
00716 return $sParams;
00717 }
00718
00724 public function getStockOnDefaultMessage()
00725 {
00726 return $this->getConfig()->getConfigParam( 'blStockOnDefaultMessage' );
00727 }
00728
00734 public function getStockOffDefaultMessage()
00735 {
00736 return $this->getConfig()->getConfigParam( 'blStockOffDefaultMessage' );
00737 }
00738
00744 public function getShopVersion()
00745 {
00746 return $this->getViewConfigParam( 'sShopVersion' );
00747 }
00748
00754 public function getAjaxLink()
00755 {
00756 return $this->getViewConfigParam( 'ajaxlink' );
00757 }
00758
00764 public function isMultiShop()
00765 {
00766 $oShop = $this->getConfig()->getActiveShop();
00767 return isset( $oShop->oxshops__oxismultishop ) ? ( (bool) $oShop->oxshops__oxismultishop->value ) : false;
00768 }
00769
00775 public function getServiceUrl()
00776 {
00777 return $this->getViewConfigParam( 'sServiceUrl' );
00778 }
00779
00785 public function __get( $sVarName )
00786 {
00787 startProfile('oxviewconfig::__get');
00788
00789 $myConfig = $this->getConfig();
00790
00791
00792 if ( ( $sVarValue = $this->getViewConfigParam( $sVarName ) ) === null ) {
00793
00794
00795 switch ( strtolower( $sVarName ) ) {
00796 case 'sid' :
00797 $sVarValue = $this->getSessionId();
00798 break;
00799 case 'hiddensid' :
00800 $sVarValue = $this->getHiddenSid();
00801 break;
00802 case 'selflink' :
00803 $sVarValue = $this->getSelfLink();
00804 break;
00805 case 'sslselflink' :
00806 $sVarValue = $this->getSslSelfLink();
00807 break;
00808
00809 case 'basedir' :
00810 $sVarValue = $this->getBaseDir();
00811 break;
00812 case 'coreutilsdir' :
00813 $sVarValue = $this->getCoreUtilsDir();
00814 break;
00815 case 'selfactionlink' :
00816 $sVarValue = $this->getSelfActionLink();
00817 break;
00818
00819 case 'currenthomedir' :
00820 $sVarValue = $this->getCurrentHomeDir();
00821 break;
00822 case 'basketlink' :
00823 $sVarValue = $this->getBasketLink();
00824 break;
00825 case 'orderlink' :
00826 $sVarValue = $this->getOrderLink();
00827 break;
00828 case 'paymentlink' :
00829 $sVarValue = $this->getPaymentLink();
00830 break;
00831 case 'exeorderlink' :
00832 $sVarValue = $this->getExeOrderLink();
00833 break;
00834 case 'orderconfirmlink' :
00835 $sVarValue = $this->getOrderConfirmLink();
00836 break;
00837 case 'basetpldir' :
00838 $sVarValue = $this->getResourceUrl();
00839 break;
00840 case 'templatedir' :
00841 $sVarValue = $this->getTemplateDir();
00842 break;
00843 case 'urltemplatedir' :
00844 $sVarValue = $this->getUrlTemplateDir();
00845 break;
00846 case 'imagedir' :
00847 $sVarValue = $this->getImageUrl();
00848 break;
00849 case 'nossl_imagedir' :
00850 $sVarValue = $this->getNoSslImageDir();
00851 break;
00852 case 'dimagedir' :
00853 $sVarValue = $this->getPictureDir();
00854 break;
00855
00856
00857 case 'admindir' :
00858 $sVarValue = $this->getAdminDir();
00859 break;
00860 case 'id' :
00861 $sVarValue = $this->getActiveShopId();
00862 break;
00863 case 'isssl' :
00864 $sVarValue = $this->isSsl();
00865 break;
00866 case 'ip' :
00867 $sVarValue = $this->getRemoteAddress();
00868 break;
00869 case 'popupident' :
00870 $sVarValue = $this->getPopupIdent();
00871 break;
00872 case 'popupidentrand' :
00873 $sVarValue = $this->getPopupIdentRand();
00874 break;
00875 case 'artperpageform' :
00876 $sVarValue = $this->getArtPerPageForm();
00877 break;
00878 case 'buyableparent' :
00879 $sVarValue = $this->isBuyableParent();
00880 break;
00881 case 'blshowbirthdayfields' :
00882 $sVarValue = $this->showBirthdayFields();
00883 break;
00884 case 'blshowfinalstep' :
00885 $sVarValue = $this->showFinalStep();
00886 break;
00887 case 'anrofcatarticles' :
00888 $sVarValue = $this->getNrOfCatArticles();
00889 break;
00890 case 'blautosearchoncat' :
00891 $sVarValue = $this->isAutoSearchOnCat();
00892 break;
00893 case 'cnid' :
00894 $sVarValue = $this->getActCatId();
00895 break;
00896 case 'cl' :
00897 $sVarValue = $this->getActiveClassName();
00898 break;
00899 case 'tpl' :
00900 $sVarValue = $this->getActTplName();
00901 break;
00902 case 'lang' :
00903 case 'slanguage' :
00904 $sVarValue = $this->getActLanguageId();
00905 break;
00906 case 'helplink' :
00907 $sVarValue = $this->getHelpLink();
00908 break;
00909 case 'logoutlink' :
00910 $sVarValue = $this->getLogoutLink();
00911 break;
00912 case 'iartPerPage':
00913 $sVarValue = $this->getArtPerPageCount();
00914 break;
00915 case 'navurlparams':
00916 $sVarValue = $this->getNavUrlParams();
00917 break;
00918 case 'navformparams':
00919 $sVarValue = $this->getNavFormParams();
00920 break;
00921 case 'blstockondefaultmessage':
00922 $sVarValue = $this->getStockOnDefaultMessage();
00923 break;
00924 case 'blstockoffdefaultmessage':
00925 $sVarValue = $this->getStockOffDefaultMessage();
00926 break;
00927 case 'sShopVersion':
00928 $sVarValue = $this->getShopVersion();
00929 break;
00930 case 'ajaxlink':
00931 $sVarValue = $this->getAjaxLink();
00932 break;
00933 case 'ismultishop':
00934 $sVarValue = $this->isMultiShop();
00935 break;
00936 case 'sServiceUrl':
00937 $sVarValue = $this->getServiceUrl();
00938 break;
00939 }
00940 }
00941
00942 $this->setViewConfigParam( $sVarName, $sVarValue );
00943
00944 stopProfile('oxviewconfig::__get');
00945
00946 return $sVarValue;
00947 }
00948
00949
00950
00951
00952
00953 }