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 
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&amp;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 .= '&amp;';
00684                     }
00685                     $sParams .= "{$sName}=".rawurlencode( $sValue );
00686                 }
00687             }
00688             if ( $sParams ) {
00689                 $sParams = '&amp;'.$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 
00787     public function __get( $sVarName )
00788     {
00789         startProfile('oxviewconfig::__get');
00790 
00791         $myConfig = $this->getConfig();
00792 
00793         // cached ?
00794         if ( ( $sVarValue = $this->getViewConfigParam( $sVarName ) ) === null ) {
00795 
00796             // using magic getter instead of waisting memmory on rarelly used variables ..
00797             switch ( strtolower( $sVarName ) ) {
00798                 case 'sid' :
00799                     $sVarValue = $this->getSessionId();
00800                     break;
00801                 case 'hiddensid' :
00802                     $sVarValue = $this->getHiddenSid();
00803                     break;
00804                 case 'selflink' :
00805                     $sVarValue = $this->getSelfLink();
00806                     break;
00807                 case 'sslselflink' :
00808                     $sVarValue = $this->getSslSelfLink();
00809                     break;
00810                 //some different processing for Mall mode
00811                 case 'basedir' :
00812                     $sVarValue = $this->getBaseDir();
00813                     break;
00814                 case 'coreutilsdir' :
00815                     $sVarValue = $this->getCoreUtilsDir();
00816                     break;
00817                 case 'selfactionlink' :
00818                     $sVarValue = $this->getSelfActionLink();
00819                     break;
00820                 //https://.... or http://.... link
00821                 case 'currenthomedir' :
00822                     $sVarValue = $this->getCurrentHomeDir();
00823                     break;
00824                 case 'basketlink' :
00825                     $sVarValue = $this->getBasketLink();
00826                     break;
00827                 case 'orderlink' :
00828                     $sVarValue = $this->getOrderLink();
00829                     break;
00830                 case 'paymentlink' :
00831                     $sVarValue = $this->getPaymentLink();
00832                     break;
00833                 case 'exeorderlink' :
00834                     $sVarValue = $this->getExeOrderLink();
00835                     break;
00836                 case 'orderconfirmlink' :
00837                     $sVarValue = $this->getOrderConfirmLink();
00838                     break;
00839                 case 'basetpldir' :
00840                     $sVarValue = $this->getResourceUrl();
00841                     break;
00842                 case 'templatedir' :
00843                     $sVarValue = $this->getTemplateDir();
00844                     break;
00845                 case 'urltemplatedir' :
00846                     $sVarValue = $this->getUrlTemplateDir();
00847                     break;
00848                 case 'imagedir' :
00849                     $sVarValue = $this->getImageUrl();
00850                     break;
00851                 case 'nossl_imagedir' :
00852                     $sVarValue = $this->getNoSslImageDir();
00853                     break;
00854                 case 'dimagedir' :
00855                     $sVarValue = $this->getPictureDir();
00856                     break;
00857                 //applicable only in admin mode
00858                 //in most case admindir is set to "admin" unless you rename the admin dir
00859                 case 'admindir' :
00860                     $sVarValue = $this->getAdminDir();
00861                     break;
00862                 case 'id' :
00863                     $sVarValue = $this->getActiveShopId();
00864                     break;
00865                 case 'isssl' :
00866                     $sVarValue = $this->isSsl();
00867                     break;
00868                 case 'ip' :
00869                     $sVarValue = $this->getRemoteAddress();
00870                     break;
00871                 case 'popupident' :
00872                     $sVarValue = $this->getPopupIdent();
00873                     break;
00874                 case 'popupidentrand' :
00875                     $sVarValue = $this->getPopupIdentRand();
00876                     break;
00877                 case 'artperpageform' :
00878                     $sVarValue = $this->getArtPerPageForm();
00879                     break;
00880                 case 'buyableparent' :
00881                     $sVarValue = $this->isBuyableParent();
00882                     break;
00883                 case 'blshowbirthdayfields' :
00884                     $sVarValue = $this->showBirthdayFields();
00885                     break;
00886                 case 'blshowfinalstep' :
00887                     $sVarValue = $this->showFinalStep();
00888                     break;
00889                 case 'anrofcatarticles' :
00890                     $sVarValue = $this->getNrOfCatArticles();
00891                     break;
00892                 case 'blautosearchoncat' :
00893                     $sVarValue = $this->isAutoSearchOnCat();
00894                     break;
00895                 case 'cnid' :
00896                     $sVarValue = $this->getActCatId();
00897                     break;
00898                 case 'cl' :
00899                     $sVarValue = $this->getActiveClassName();
00900                     break;
00901                 case 'tpl' :
00902                     $sVarValue = $this->getActTplName();
00903                     break;
00904                 case 'lang' :
00905                 case 'slanguage' :
00906                     $sVarValue = $this->getActLanguageId();
00907                     break;
00908                 case 'helplink' :
00909                     $sVarValue = $this->getHelpLink();
00910                     break;
00911                 case 'logoutlink' :
00912                     $sVarValue = $this->getLogoutLink();
00913                     break;
00914                 case 'iartPerPage':
00915                     $sVarValue = $this->getArtPerPageCount();
00916                     break;
00917                 case 'navurlparams':
00918                     $sVarValue = $this->getNavUrlParams();
00919                     break;
00920                 case 'navformparams':
00921                     $sVarValue = $this->getNavFormParams();
00922                     break;
00923                 case 'blstockondefaultmessage':
00924                     $sVarValue = $this->getStockOnDefaultMessage();
00925                     break;
00926                 case 'blstockoffdefaultmessage':
00927                     $sVarValue = $this->getStockOffDefaultMessage();
00928                     break;
00929                 case 'sShopVersion':
00930                     $sVarValue = $this->getShopVersion();
00931                     break;
00932                 case 'ajaxlink':
00933                     $sVarValue = $this->getAjaxLink();
00934                     break;
00935                 case 'ismultishop':
00936                     $sVarValue = $this->isMultiShop();
00937                     break;
00938                 case 'sServiceUrl':
00939                     $sVarValue = $this->getServiceUrl();
00940                     break;
00941             }
00942         }
00943 
00944         $this->setViewConfigParam( $sVarName, $sVarValue );
00945 
00946         stopProfile('oxviewconfig::__get');
00947 
00948         return $sVarValue;
00949     }
00950 
00951     /*public funtion getLogoutLink()
00952     {
00953         //return parent::getLogoutLink() . 'xxx';
00954     }*/
00955 }

Generated on Wed Apr 22 12:26:32 2009 for OXID eShop CE by  doxygen 1.5.5