oxviewconfig.php

Go to the documentation of this file.
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}&amp;".( $sCatnid ? "cnid={$sCatnid} " : '' )."&amp;fnc=logout".( $sTplName ? "&amp;tpl=".basename( $sTplName ) : '' )."&amp;redirect=1";
00065     }
00066 
00072     public function getHelpLink()
00073     {
00074         $sTplName = $this->getActTplName();
00075         $sClass   = $this->getActiveClassName();
00076         return $this->getConfig()->getShopCurrentURL()."cl=help&amp;page={$sClass}".( $sTplName ? "&amp;tpl={$sTplName}" : '' );
00077     }
00078 
00084     public function getActCatId()
00085     {
00086         return oxConfig::getParameter( 'cnid' );
00087     }
00088 
00100     public function setViewConfigParam( $sName, $sValue )
00101     {
00102         startProfile('oxviewconfig::setViewConfigParam');
00103 
00104         $this->_aConfigParams[$sName] = $sValue;
00105 
00106         stopProfile('oxviewconfig::setViewConfigParam');
00107     }
00108 
00116     public function getViewConfigParam( $sName )
00117     {
00118         startProfile('oxviewconfig::getViewConfigParam');
00119 
00120         if ( $this->_oShop && isset( $this->_oShop->$sName ) ) {
00121             $sValue = $this->_oShop->$sName;
00122         } elseif( $this->_aViewData && isset( $this->_aViewData[ $sName ] ) ) {
00123             $sValue = $this->_aViewData[ $sName ];
00124         } else {
00125             $sValue = ( isset( $this->_aConfigParams[ $sName ] ) ? $this->_aConfigParams[ $sName ] : null );
00126         }
00127 
00128         stopProfile('oxviewconfig::getViewConfigParam');
00129 
00130         return $sValue;
00131     }
00132 
00142     public function setViewShop( $oShop, $aViewData )
00143     {
00144         $this->_oShop     = $oShop;
00145         $this->_aViewData = $aViewData;
00146     }
00147 
00160     public function __call( $sMethodName, $sParams )
00161     {
00162         startProfile('oxviewconfig::__call');
00163         if ( stripos( $sMethodName, 'get' ) === 0 ) {
00164             return $this->__get( substr( $sMethodName, 3 ) );
00165         }
00166         stopProfile('oxviewconfig::__call');
00167     }
00168 
00174     public function getSessionId()
00175     {
00176         if ( ( $sValue = $this->getViewConfigParam( 'sessionid' ) ) === null ) {
00177             $sValue = $this->getSession()->getId();
00178             $this->setViewConfigParam( 'sessionid', $sValue );
00179         }
00180         return $sValue;
00181     }
00182 
00188     public function getHiddenSid()
00189     {
00190         if ( ( $sValue = $this->getViewConfigParam( 'hiddensid' ) ) === null ) {
00191             $sValue = $this->getSession()->hiddenSid();
00192             $this->setViewConfigParam( 'hiddensid', $sValue );
00193         }
00194         return $sValue;
00195     }
00196 
00202     public function getSelfLink()
00203     {
00204         if ( ( $sValue = $this->getViewConfigParam( 'selflink' ) ) === null ) {
00205             $sValue = $this->getConfig()->getShopHomeURL();
00206             $this->setViewConfigParam( 'selflink', $sValue );
00207         }
00208         return $sValue;
00209     }
00210 
00216     public function getSslSelfLink()
00217     {
00218         if ( ( $sValue = $this->getViewConfigParam( 'sslselflink' ) ) === null ) {
00219             $sValue = $this->getConfig()->getShopSecureHomeURL();
00220             $this->setViewConfigParam( 'sslselflink', $sValue );
00221         }
00222         return $sValue;
00223     }
00224 
00230     public function getBaseDir()
00231     {
00232         if ( ( $sValue = $this->getViewConfigParam( 'basedir' ) ) === null ) {
00233             $sValue = $this->getConfig()->getShopURL();
00234             $this->setViewConfigParam( 'basedir', $sValue );
00235         }
00236         return $sValue;
00237     }
00238 
00244     public function getCoreUtilsDir()
00245     {
00246         if ( ( $sValue = $this->getViewConfigParam( 'coreutilsdir' ) ) === null ) {
00247             $sValue = $this->getConfig()->getCoreUtilsURL();
00248             $this->setViewConfigParam( 'coreutilsdir', $sValue );
00249         }
00250         return $sValue;
00251     }
00252 
00258     public function getSelfActionLink()
00259     {
00260         if ( ( $sValue = $this->getViewConfigParam( 'selfactionlink' ) ) === null ) {
00261             $sValue = $this->getConfig()->getShopCurrentUrl();
00262             $this->setViewConfigParam( 'selfactionlink', $sValue );
00263         }
00264         return $sValue;
00265     }
00266 
00272     public function getCurrentHomeDir()
00273     {
00274         if ( ( $sValue = $this->getViewConfigParam( 'currenthomedir' ) ) === null ) {
00275             $sValue = $this->getConfig()->getCurrentShopUrl();
00276             $this->setViewConfigParam( 'currenthomedir', $sValue );
00277         }
00278         return $sValue;
00279     }
00280 
00286     public function getBasketLink()
00287     {
00288         if ( ( $sValue = $this->getViewConfigParam( 'basketlink' ) ) === null ) {
00289             $sValue = $this->getConfig()->getShopHomeURL()   . 'cl=basket';
00290             $this->setViewConfigParam( 'basketlink', $sValue );
00291         }
00292         return $sValue;
00293     }
00294 
00300     public function getOrderLink()
00301     {
00302         if ( ( $sValue = $this->getViewConfigParam( 'orderlink' ) ) === null ) {
00303             $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=user';
00304             $this->setViewConfigParam( 'orderlink', $sValue );
00305         }
00306         return $sValue;
00307     }
00308 
00314     public function getPaymentLink()
00315     {
00316         if ( ( $sValue = $this->getViewConfigParam( 'paymentlink' ) ) === null ) {
00317             $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=payment';
00318             $this->setViewConfigParam( 'paymentlink', $sValue );
00319         }
00320         return $sValue;
00321     }
00322 
00328     public function getExeOrderLink()
00329     {
00330         if ( ( $sValue = $this->getViewConfigParam( 'exeorderlink' ) ) === null ) {
00331             $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=order&amp;fnc=execute';
00332             $this->setViewConfigParam( 'exeorderlink', $sValue );
00333         }
00334         return $sValue;
00335     }
00336 
00342     public function getOrderConfirmLink()
00343     {
00344         if ( ( $sValue = $this->getViewConfigParam( 'orderconfirmlink' ) ) === null ) {
00345             $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=order';
00346             $this->setViewConfigParam( 'orderconfirmlink', $sValue );
00347         }
00348         return $sValue;
00349     }
00350 
00356     public function getResourceUrl()
00357     {
00358         if ( ( $sValue = $this->getViewConfigParam( 'basetpldir' ) ) === null ) {
00359             $sValue = $this->getConfig()->getResourceUrl( null, $this->isAdmin() );
00360             $this->setViewConfigParam( 'basetpldir', $sValue );
00361         }
00362         return $sValue;
00363     }
00364 
00370     public function getTemplateDir()
00371     {
00372         if ( ( $sValue = $this->getViewConfigParam( 'templatedir' ) ) === null ) {
00373             $sValue = $this->getConfig()->getTemplateDir( $this->isAdmin() );
00374             $this->setViewConfigParam( 'templatedir', $sValue );
00375         }
00376         return $sValue;
00377     }
00378 
00384     public function getUrlTemplateDir()
00385     {
00386         if ( ( $sValue = $this->getViewConfigParam( 'urltemplatedir' ) ) === null ) {
00387             $sValue = $this->getConfig()->getTemplateUrl( $this->isAdmin() );
00388             $this->setViewConfigParam( 'urltemplatedir', $sValue );
00389         }
00390         return $sValue;
00391     }
00392 
00398     public function getImageUrl()
00399     {
00400         if ( ( $sValue = $this->getViewConfigParam( 'imagedir' ) ) === null ) {
00401             $sValue = $this->getConfig()->getImageUrl( $this->isAdmin() );
00402             $this->setViewConfigParam( 'imagedir', $sValue );
00403         }
00404         return $sValue;
00405     }
00406 
00412     public function getNoSslImageDir()
00413     {
00414         if ( ( $sValue = $this->getViewConfigParam( 'nossl_imagedir' ) ) === null ) {
00415             $sValue = $this->getConfig()->getImageUrl( $this->isAdmin() , false );
00416             $this->setViewConfigParam( 'nossl_imagedir', $sValue );
00417         }
00418         return $sValue;
00419     }
00420 
00427     public function getPictureDir()
00428     {
00429         if ( ( $sValue = $this->getViewConfigParam( 'picturedir' ) ) === null ) {
00430             $sValue = $this->getConfig()->getPictureUrl( null , $this->isAdmin() );
00431             $this->setViewConfigParam( 'picturedir', $sValue );
00432         }
00433         return $sValue;
00434     }
00435 
00441     public function getAdminDir()
00442     {
00443         if ( ( $sValue = $this->getViewConfigParam( 'sAdminDir' ) ) === null ) {
00444             $sValue = $this->getConfig()->getConfigParam( 'sAdminDir' );
00445             $this->setViewConfigParam( 'sAdminDir', $sValue );
00446         }
00447         return $sValue;
00448     }
00449 
00455     public function getActiveShopId()
00456     {
00457         if ( ( $sValue = $this->getViewConfigParam( 'shopid' ) ) === null ) {
00458             $sValue = $this->getConfig()->getShopId();
00459             $this->setViewConfigParam( 'shopid', $sValue );
00460         }
00461         return $sValue;
00462     }
00463 
00469     public function isSsl()
00470     {
00471         if ( ( $sValue = $this->getViewConfigParam( 'isssl' ) ) === null ) {
00472             $sValue = $this->getConfig()->isSsl();
00473             $this->setViewConfigParam( 'isssl', $sValue );
00474         }
00475         return $sValue;
00476     }
00477 
00478 
00484     public function getRemoteAddress()
00485     {
00486         if ( ( $sValue = $this->getViewConfigParam( 'ip' ) ) === null ) {
00487             $sValue = oxUtilsServer::getInstance()->getRemoteAddress();
00488             $this->setViewConfigParam( 'ip', $sValue );
00489         }
00490         return $sValue;
00491     }
00492 
00498     public function getPopupIdent()
00499     {
00500         if ( ( $sValue = $this->getViewConfigParam( 'popupident' ) ) === null ) {
00501             $sValue = md5( $this->getConfig()->getShopUrl() );
00502             $this->setViewConfigParam( 'popupident', $sValue );
00503         }
00504         return $sValue;
00505     }
00506 
00512     public function getPopupIdentRand()
00513     {
00514         if ( ( $sValue = $this->getViewConfigParam( 'popupidentrand' ) ) === null ) {
00515             $sValue = md5( time() );
00516             $this->setViewConfigParam( 'popupidentrand', $sValue );
00517         }
00518         return $sValue;
00519     }
00520 
00526     public function getArtPerPageForm()
00527     {
00528         if ( ( $sValue = $this->getViewConfigParam( 'artperpageform' ) ) === null ) {
00529             $sValue = $this->getConfig()->getShopCurrentUrl();
00530             $this->setViewConfigParam( 'artperpageform', $sValue );
00531         }
00532         return $sValue;
00533     }
00534 
00540     public function isBuyableParent()
00541     {
00542         return $this->getConfig()->getConfigParam( 'blVariantParentBuyable' );
00543     }
00544 
00550     public function showBirthdayFields()
00551     {
00552         return $this->getConfig()->getConfigParam( 'blShowBirthdayFields' );
00553     }
00554 
00560     public function showFinalStep()
00561     {
00562         return $this->getConfig()->getConfigParam( 'blShowFinalStep' );
00563     }
00564 
00570     public function getNrOfCatArticles()
00571     {
00572         return $this->getConfig()->getConfigParam( 'aNrofCatArticles' );
00573     }
00574 
00580     public function isAutoSearchOnCat()
00581     {
00582         return $this->getConfig()->getConfigParam( 'blAutoSearchOnCat' );
00583     }
00584 
00590     public function getActLanguageId()
00591     {
00592         if ( ( $sValue = $this->getViewConfigParam( 'lang' ) ) === null ) {
00593             $iLang = oxConfig::getParameter( 'lang' );
00594             $sValue = ( $iLang !== null ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00595             $this->setViewConfigParam( 'lang', $sValue );
00596         }
00597         return $sValue;
00598     }
00599 
00605     public function getActiveClassName()
00606     {
00607         return $this->getConfig()->getActiveView()->getClassName();
00608     }
00609 
00615     public function getArtPerPageCount()
00616     {
00617         return $this->getViewConfigParam( 'iartPerPage' );
00618     }
00619 
00625     public function getNavUrlParams()
00626     {
00627         return $this->getViewConfigParam( 'navurlparams' );
00628     }
00629 
00635     public function getNavFormParams()
00636     {
00637         return $this->getViewConfigParam( 'navformparams' );
00638     }
00639 
00645     public function getStockOnDefaultMessage()
00646     {
00647         return $this->getConfig()->getConfigParam( 'blStockOnDefaultMessage' );
00648     }
00649 
00655     public function getStockOffDefaultMessage()
00656     {
00657         return $this->getConfig()->getConfigParam( 'blStockOffDefaultMessage' );
00658     }
00659 
00665     public function getShopVersion()
00666     {
00667         return $this->getViewConfigParam( 'sShopVersion' );
00668     }
00669 
00675     public function getAjaxLink()
00676     {
00677         return $this->getViewConfigParam( 'ajaxlink' );
00678     }
00679 
00685     public function isMultiShop()
00686     {
00687         $oShop = $this->getConfig()->getActiveShop();
00688         return isset( $oShop->oxshops__oxismultishop ) ? ( (bool) $oShop->oxshops__oxismultishop->value ) : false;
00689     }
00690 
00696     public function isAutoSave()
00697     {
00698         return $this->getConfig()->getConfigParam( 'blAutoSave' );
00699     }
00700 
00706     public function getServiceUrl()
00707     {
00708         return $this->getViewConfigParam( 'sServiceUrl' );
00709     }
00710 
00716     public function __get( $sVarName )
00717     {
00718         startProfile('oxviewconfig::__get');
00719 
00720         $myConfig = $this->getConfig();
00721 
00722         // cached ?
00723         if ( ( $sVarValue = $this->getViewConfigParam( $sVarName ) ) === null ) {
00724 
00725             // using magic getter instead of waisting memmory on rarelly used variables ..
00726             switch ( strtolower( $sVarName ) ) {
00727                 case 'sid' :
00728                     $sVarValue = $this->getSessionId();
00729                     break;
00730                 case 'hiddensid' :
00731                     $sVarValue = $this->getHiddenSid();
00732                     break;
00733                 case 'selflink' :
00734                     $sVarValue = $this->getSelfLink();
00735                     break;
00736                 case 'sslselflink' :
00737                     $sVarValue = $this->getSslSelfLink();
00738                     break;
00739                 //some different processing for Mall mode
00740                 case 'basedir' :
00741                     $sVarValue = $this->getBaseDir();
00742                     break;
00743                 case 'coreutilsdir' :
00744                     $sVarValue = $this->getCoreUtilsDir();
00745                     break;
00746                 case 'selfactionlink' :
00747                     $sVarValue = $this->getSelfActionLink();
00748                     break;
00749                 //https://.... or http://.... link
00750                 case 'currenthomedir' :
00751                     $sVarValue = $this->getCurrentHomeDir();
00752                     break;
00753                 case 'basketlink' :
00754                     $sVarValue = $this->getBasketLink();
00755                     break;
00756                 case 'orderlink' :
00757                     $sVarValue = $this->getOrderLink();
00758                     break;
00759                 case 'paymentlink' :
00760                     $sVarValue = $this->getPaymentLink();
00761                     break;
00762                 case 'exeorderlink' :
00763                     $sVarValue = $this->getExeOrderLink();
00764                     break;
00765                 case 'orderconfirmlink' :
00766                     $sVarValue = $this->getOrderConfirmLink();
00767                     break;
00768                 case 'basetpldir' :
00769                     $sVarValue = $this->getResourceUrl();
00770                     break;
00771                 case 'templatedir' :
00772                     $sVarValue = $this->getTemplateDir();
00773                     break;
00774                 case 'urltemplatedir' :
00775                     $sVarValue = $this->getUrlTemplateDir();
00776                     break;
00777                 case 'imagedir' :
00778                     $sVarValue = $this->getImageUrl();
00779                     break;
00780                 case 'nossl_imagedir' :
00781                     $sVarValue = $this->getNoSslImageDir();
00782                     break;
00783                 case 'dimagedir' :
00784                     $sVarValue = $this->getPictureDir();
00785                     break;
00786                 //applicable only in admin mode
00787                 //in most case admindir is set to "admin" unless you rename the admin dir
00788                 case 'admindir' :
00789                     $sVarValue = $this->getAdminDir();
00790                     break;
00791                 case 'id' :
00792                     $sVarValue = $this->getActiveShopId();
00793                     break;
00794                 case 'isssl' :
00795                     $sVarValue = $this->isSsl();
00796                     break;
00797                 case 'ip' :
00798                     $sVarValue = $this->getRemoteAddress();
00799                     break;
00800                 case 'popupident' :
00801                     $sVarValue = $this->getPopupIdent();
00802                     break;
00803                 case 'popupidentrand' :
00804                     $sVarValue = $this->getPopupIdentRand();
00805                     break;
00806                 case 'artperpageform' :
00807                     $sVarValue = $this->getArtPerPageForm();
00808                     break;
00809                 case 'buyableparent' :
00810                     $sVarValue = $this->isBuyableParent();
00811                     break;
00812                 case 'blshowbirthdayfields' :
00813                     $sVarValue = $this->showBirthdayFields();
00814                     break;
00815                 case 'blshowfinalstep' :
00816                     $sVarValue = $this->showFinalStep();
00817                     break;
00818                 case 'anrofcatarticles' :
00819                     $sVarValue = $this->getNrOfCatArticles();
00820                     break;
00821                 case 'blautosearchoncat' :
00822                     $sVarValue = $this->isAutoSearchOnCat();
00823                     break;
00824                 case 'cnid' :
00825                     $sVarValue = $this->getActCatId();
00826                     break;
00827                 case 'cl' :
00828                     $sVarValue = $this->getActiveClassName();
00829                     break;
00830                 case 'tpl' :
00831                     $sVarValue = $this->getActTplName();
00832                     break;
00833                 case 'lang' :
00834                 case 'slanguage' :
00835                     $sVarValue = $this->getActLanguageId();
00836                     break;
00837                 case 'helplink' :
00838                     $sVarValue = $this->getHelpLink();
00839                     break;
00840                 case 'logoutlink' :
00841                     $sVarValue = $this->getLogoutLink();
00842                     break;
00843                 case 'iartPerPage':
00844                     $sVarValue = $this->getArtPerPageCount();
00845                     break;
00846                 case 'navurlparams':
00847                     $sVarValue = $this->getNavUrlParams();
00848                     break;
00849                 case 'navformparams':
00850                     $sVarValue = $this->getNavFormParams();
00851                     break;
00852                 case 'blstockondefaultmessage':
00853                     $sVarValue = $this->getStockOnDefaultMessage();
00854                     break;
00855                 case 'blstockoffdefaultmessage':
00856                     $sVarValue = $this->getStockOffDefaultMessage();
00857                     break;
00858                 case 'sShopVersion':
00859                     $sVarValue = $this->getShopVersion();
00860                     break;
00861                 case 'ajaxlink':
00862                     $sVarValue = $this->getAjaxLink();
00863                     break;
00864                 case 'ismultishop':
00865                     $sVarValue = $this->isMultiShop();
00866                     break;
00867                 case 'blAutoSave':
00868                     $sVarValue = $this->isAutoSave();
00869                     break;
00870                 case 'sServiceUrl':
00871                     $sVarValue = $this->getServiceUrl();
00872                     break;
00873             }
00874         }
00875 
00876         $this->setViewConfigParam( $sVarName, $sVarValue );
00877 
00878         stopProfile('oxviewconfig::__get');
00879 
00880         return $sVarValue;
00881     }
00882 
00883     /*public funtion getLogoutLink()
00884     {
00885         //return parent::getLogoutLink() . 'xxx';
00886     }*/
00887 }

Generated on Thu Dec 4 12:04:57 2008 for OXID eShop CE by  doxygen 1.5.5