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         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         return $sTplName ? basename( $sTplName ) : null;
00067     }
00068 
00074     public function getLogoutLink()
00075     {
00076         $sClass   = $this->getActiveClassName();
00077         $sCatnid  = $this->getActCatId();
00078         $sTplName = $this->getActTplName();
00079 
00080         $sLink = $this->getConfig()->getShopHomeURL()."cl={$sClass}&amp;".( $sCatnid ? "cnid={$sCatnid}" : '' )."&amp;fnc=logout".( $sTplName ? "&amp;tpl=".basename( $sTplName ) : '' )."&amp;redirect=1";
00081         return $this->getSession()->processUrl( $sLink );
00082     }
00083 
00089     public function getHelpLink()
00090     {
00091         $sTplName = $this->getActTplName();
00092         $sClass   = $this->getActiveClassName();
00093         $sLink = $this->getConfig()->getShopCurrentURL()."cl=help&amp;page={$sClass}".( $sTplName ? "&amp;tpl={$sTplName}" : '' );
00094         return $this->getSession()->processUrl( $sLink );
00095     }
00096 
00102     public function getActCatId()
00103     {
00104         return oxConfig::getParameter( 'cnid' );
00105     }
00106 
00112     public function getActManufacturerId()
00113     {
00114         return oxConfig::getParameter( 'mnid' );
00115     }
00116 
00124     public function getTypeLinkParams()
00125     {
00126         $sLink = '';
00127         if ( ( $sId = $this->getActCatId() ) ) {
00128             $sLink .= "cnid={$sId}";
00129         }
00130         if ( ( $sId = $this->getActManufacturerId() ) ) {
00131             $sLink .= "mnid={$sId}";
00132         }
00133 
00134         return $sLink;
00135     }
00136 
00144     public function getTypeParams()
00145     {
00146         $sForm = '';
00147         if ( ( $sId = $this->getActCatId() ) ) {
00148             $sForm .= "<input type=\"hidden\" name=\"cnid\" value=\"{$sId}\">\n";
00149         }
00150         if ( ( $sId = $this->getActManufacturerId() ) ) {
00151             $sForm .= "<input type=\"hidden\" name=\"mnid\" value=\"{$sId}\">\n";
00152         }
00153 
00154         return $sForm;
00155     }
00156 
00168     public function setViewConfigParam( $sName, $sValue )
00169     {
00170         startProfile('oxviewconfig::setViewConfigParam');
00171 
00172         $this->_aConfigParams[$sName] = $sValue;
00173 
00174         stopProfile('oxviewconfig::setViewConfigParam');
00175     }
00176 
00184     public function getViewConfigParam( $sName )
00185     {
00186         startProfile('oxviewconfig::getViewConfigParam');
00187 
00188         if ( $this->_oShop && isset( $this->_oShop->$sName ) ) {
00189             $sValue = $this->_oShop->$sName;
00190         } elseif ( $this->_aViewData && isset( $this->_aViewData[ $sName ] ) ) {
00191             $sValue = $this->_aViewData[ $sName ];
00192         } else {
00193             $sValue = ( isset( $this->_aConfigParams[ $sName ] ) ? $this->_aConfigParams[ $sName ] : null );
00194         }
00195 
00196         stopProfile('oxviewconfig::getViewConfigParam');
00197 
00198         return $sValue;
00199     }
00200 
00210     public function setViewShop( $oShop, $aViewData )
00211     {
00212         $this->_oShop     = $oShop;
00213         $this->_aViewData = $aViewData;
00214     }
00215 
00228     public function __call( $sMethodName, $sParams )
00229     {
00230         startProfile('oxviewconfig::__call');
00231         if ( stripos( $sMethodName, 'get' ) === 0 ) {
00232             return $this->getViewVar( substr( $sMethodName, 3 ) );
00233         }
00234         stopProfile('oxviewconfig::__call');
00235     }
00236 
00242     public function getSessionId()
00243     {
00244         if ( ( $sValue = $this->getViewConfigParam( 'sessionid' ) ) === null ) {
00245             $sValue = $this->getSession()->getId();
00246             $this->setViewConfigParam( 'sessionid', $sValue );
00247         }
00248         return $sValue;
00249     }
00250 
00256     public function getHiddenSid()
00257     {
00258         if ( ( $sValue = $this->getViewConfigParam( 'hiddensid' ) ) === null ) {
00259             $sValue = $this->getSession()->hiddenSid();
00260             $this->setViewConfigParam( 'hiddensid', $sValue );
00261         }
00262         return $sValue;
00263     }
00264 
00270     public function getSelfLink()
00271     {
00272         if ( ( $sValue = $this->getViewConfigParam( 'selflink' ) ) === null ) {
00273             $sValue = $this->getConfig()->getShopHomeURL();
00274             $this->setViewConfigParam( 'selflink', $sValue );
00275         }
00276         return $sValue;
00277     }
00278 
00284     public function getSslSelfLink()
00285     {
00286         if ( ( $sValue = $this->getViewConfigParam( 'sslselflink' ) ) === null ) {
00287             $sValue = $this->getConfig()->getShopSecureHomeURL();
00288             $this->setViewConfigParam( 'sslselflink', $sValue );
00289         }
00290         return $sValue;
00291     }
00292 
00298     public function getBaseDir()
00299     {
00300         if ( ( $sValue = $this->getViewConfigParam( 'basedir' ) ) === null ) {
00301             $sValue = $this->getConfig()->getShopURL();
00302             $this->setViewConfigParam( 'basedir', $sValue );
00303         }
00304         return $sValue;
00305     }
00306 
00312     public function getCoreUtilsDir()
00313     {
00314         if ( ( $sValue = $this->getViewConfigParam( 'coreutilsdir' ) ) === null ) {
00315             $sValue = $this->getConfig()->getCoreUtilsURL();
00316             $this->setViewConfigParam( 'coreutilsdir', $sValue );
00317         }
00318         return $sValue;
00319     }
00320 
00326     public function getSelfActionLink()
00327     {
00328         if ( ( $sValue = $this->getViewConfigParam( 'selfactionlink' ) ) === null ) {
00329             $sValue = $this->getConfig()->getShopCurrentUrl();
00330             $this->setViewConfigParam( 'selfactionlink', $sValue );
00331         }
00332         return $sValue;
00333     }
00334 
00340     public function getCurrentHomeDir()
00341     {
00342         if ( ( $sValue = $this->getViewConfigParam( 'currenthomedir' ) ) === null ) {
00343             $sValue = $this->getConfig()->getCurrentShopUrl();
00344             $this->setViewConfigParam( 'currenthomedir', $sValue );
00345         }
00346         return $sValue;
00347     }
00348 
00354     public function getBasketLink()
00355     {
00356         if ( ( $sValue = $this->getViewConfigParam( 'basketlink' ) ) === null ) {
00357             $sValue = $this->getConfig()->getShopHomeURL()   . 'cl=basket';
00358             $this->setViewConfigParam( 'basketlink', $sValue );
00359         }
00360         return $sValue;
00361     }
00362 
00368     public function getOrderLink()
00369     {
00370         if ( ( $sValue = $this->getViewConfigParam( 'orderlink' ) ) === null ) {
00371             $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=user';
00372             $this->setViewConfigParam( 'orderlink', $sValue );
00373         }
00374         return $sValue;
00375     }
00376 
00382     public function getPaymentLink()
00383     {
00384         if ( ( $sValue = $this->getViewConfigParam( 'paymentlink' ) ) === null ) {
00385             $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=payment';
00386             $this->setViewConfigParam( 'paymentlink', $sValue );
00387         }
00388         return $sValue;
00389     }
00390 
00396     public function getExeOrderLink()
00397     {
00398         if ( ( $sValue = $this->getViewConfigParam( 'exeorderlink' ) ) === null ) {
00399             $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=order&amp;fnc=execute';
00400             $this->setViewConfigParam( 'exeorderlink', $sValue );
00401         }
00402         return $sValue;
00403     }
00404 
00410     public function getOrderConfirmLink()
00411     {
00412         if ( ( $sValue = $this->getViewConfigParam( 'orderconfirmlink' ) ) === null ) {
00413             $sValue = $this->getConfig()->getShopSecureHomeUrl() . 'cl=order';
00414             $this->setViewConfigParam( 'orderconfirmlink', $sValue );
00415         }
00416         return $sValue;
00417     }
00418 
00424     public function getResourceUrl()
00425     {
00426         if ( ( $sValue = $this->getViewConfigParam( 'basetpldir' ) ) === null ) {
00427             $sValue = $this->getConfig()->getResourceUrl( null, $this->isAdmin() );
00428             $this->setViewConfigParam( 'basetpldir', $sValue );
00429         }
00430         return $sValue;
00431     }
00432 
00438     public function getTemplateDir()
00439     {
00440         if ( ( $sValue = $this->getViewConfigParam( 'templatedir' ) ) === null ) {
00441             $sValue = $this->getConfig()->getTemplateDir( $this->isAdmin() );
00442             $this->setViewConfigParam( 'templatedir', $sValue );
00443         }
00444         return $sValue;
00445     }
00446 
00452     public function getUrlTemplateDir()
00453     {
00454         if ( ( $sValue = $this->getViewConfigParam( 'urltemplatedir' ) ) === null ) {
00455             $sValue = $this->getConfig()->getTemplateUrl( $this->isAdmin() );
00456             $this->setViewConfigParam( 'urltemplatedir', $sValue );
00457         }
00458         return $sValue;
00459     }
00460 
00466     public function getImageUrl()
00467     {
00468         if ( ( $sValue = $this->getViewConfigParam( 'imagedir' ) ) === null ) {
00469             $sValue = $this->getConfig()->getImageUrl( $this->isAdmin() );
00470             $this->setViewConfigParam( 'imagedir', $sValue );
00471         }
00472         return $sValue;
00473     }
00474 
00480     public function getNoSslImageDir()
00481     {
00482         if ( ( $sValue = $this->getViewConfigParam( 'nossl_imagedir' ) ) === null ) {
00483             $sValue = $this->getConfig()->getImageUrl( $this->isAdmin(), false );
00484             $this->setViewConfigParam( 'nossl_imagedir', $sValue );
00485         }
00486         return $sValue;
00487     }
00488 
00495     public function getPictureDir()
00496     {
00497         if ( ( $sValue = $this->getViewConfigParam( 'picturedir' ) ) === null ) {
00498             $sValue = $this->getConfig()->getPictureUrl( null, $this->isAdmin() );
00499             $this->setViewConfigParam( 'picturedir', $sValue );
00500         }
00501         return $sValue;
00502     }
00503 
00509     public function getAdminDir()
00510     {
00511         if ( ( $sValue = $this->getViewConfigParam( 'sAdminDir' ) ) === null ) {
00512             $sValue = $this->getConfig()->getConfigParam( 'sAdminDir' );
00513             $this->setViewConfigParam( 'sAdminDir', $sValue );
00514         }
00515         return $sValue;
00516     }
00517 
00523     public function getActiveShopId()
00524     {
00525         if ( ( $sValue = $this->getViewConfigParam( 'shopid' ) ) === null ) {
00526             $sValue = $this->getConfig()->getShopId();
00527             $this->setViewConfigParam( 'shopid', $sValue );
00528         }
00529         return $sValue;
00530     }
00531 
00537     public function isSsl()
00538     {
00539         if ( ( $sValue = $this->getViewConfigParam( 'isssl' ) ) === null ) {
00540             $sValue = $this->getConfig()->isSsl();
00541             $this->setViewConfigParam( 'isssl', $sValue );
00542         }
00543         return $sValue;
00544     }
00545 
00546 
00552     public function getRemoteAddress()
00553     {
00554         if ( ( $sValue = $this->getViewConfigParam( 'ip' ) ) === null ) {
00555             $sValue = oxUtilsServer::getInstance()->getRemoteAddress();
00556             $this->setViewConfigParam( 'ip', $sValue );
00557         }
00558         return $sValue;
00559     }
00560 
00566     public function getPopupIdent()
00567     {
00568         if ( ( $sValue = $this->getViewConfigParam( 'popupident' ) ) === null ) {
00569             $sValue = md5( $this->getConfig()->getShopUrl() );
00570             $this->setViewConfigParam( 'popupident', $sValue );
00571         }
00572         return $sValue;
00573     }
00574 
00580     public function getPopupIdentRand()
00581     {
00582         if ( ( $sValue = $this->getViewConfigParam( 'popupidentrand' ) ) === null ) {
00583             $sValue = md5( time() );
00584             $this->setViewConfigParam( 'popupidentrand', $sValue );
00585         }
00586         return $sValue;
00587     }
00588 
00594     public function getArtPerPageForm()
00595     {
00596         if ( ( $sValue = $this->getViewConfigParam( 'artperpageform' ) ) === null ) {
00597             $sValue = $this->getConfig()->getShopCurrentUrl();
00598             $this->setViewConfigParam( 'artperpageform', $sValue );
00599         }
00600         return $sValue;
00601     }
00602 
00608     public function isBuyableParent()
00609     {
00610         return $this->getConfig()->getConfigParam( 'blVariantParentBuyable' );
00611     }
00612 
00618     public function showBirthdayFields()
00619     {
00620         return $this->getConfig()->getConfigParam( 'blShowBirthdayFields' );
00621     }
00622 
00628     public function showFinalStep()
00629     {
00630         return $this->getConfig()->getConfigParam( 'blShowFinalStep' );
00631     }
00632 
00638     public function getNrOfCatArticles()
00639     {
00640         return $this->getConfig()->getConfigParam( 'aNrofCatArticles' );
00641     }
00642 
00648     public function isAutoSearchOnCat()
00649     {
00650         return $this->getConfig()->getConfigParam( 'blAutoSearchOnCat' );
00651     }
00652 
00658     public function getActLanguageId()
00659     {
00660         if ( ( $sValue = $this->getViewConfigParam( 'lang' ) ) === null ) {
00661             $iLang = oxConfig::getParameter( 'lang' );
00662             $sValue = ( $iLang !== null ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00663             $this->setViewConfigParam( 'lang', $sValue );
00664         }
00665         return $sValue;
00666     }
00667 
00673     public function getActiveClassName()
00674     {
00675         return $this->getConfig()->getActiveView()->getClassName();
00676     }
00677 
00683     public function getArtPerPageCount()
00684     {
00685         return $this->getViewConfigParam( 'iartPerPage' );
00686     }
00687 
00693     public function getNavUrlParams()
00694     {
00695         if ( ( $sParams = $this->getViewConfigParam( 'navurlparams' ) ) === null ) {
00696             $sParams = '';
00697             $aNavParams = $this->getConfig()->getActiveView()->getNavigationParams();
00698             foreach ( $aNavParams as $sName => $sValue ) {
00699                 if ( isset( $sValue ) ) {
00700                     if ( $sParams ) {
00701                         $sParams .= '&amp;';
00702                     }
00703                     $sParams .= "{$sName}=".rawurlencode( $sValue );
00704                 }
00705             }
00706             if ( $sParams ) {
00707                 $sParams = '&amp;'.$sParams;
00708             }
00709             $this->setViewConfigParam( 'navurlparams', $sParams );
00710         }
00711 
00712         return $sParams;
00713     }
00714 
00720     public function getNavFormParams()
00721     {
00722 
00723         if ( ( $sParams = $this->getViewConfigParam( 'navformparams' ) ) === null ) {
00724             $oStr = getStr();
00725             $sParams = '';
00726             $aNavParams = $this->getConfig()->getActiveView()->getNavigationParams();
00727             foreach ( $aNavParams as $sName => $sValue ) {
00728                 if ( isset( $sValue ) ) {
00729                     $sParams .= "<input type=\"hidden\" name=\"{$sName}\" value=\"".$oStr->htmlentities( $sValue )."\">\n";
00730                 }
00731             }
00732             $this->setViewConfigParam( 'navformparams', $sParams );
00733         }
00734         return $sParams;
00735     }
00736 
00742     public function getStockOnDefaultMessage()
00743     {
00744         return $this->getConfig()->getConfigParam( 'blStockOnDefaultMessage' );
00745     }
00746 
00752     public function getStockOffDefaultMessage()
00753     {
00754         return $this->getConfig()->getConfigParam( 'blStockOffDefaultMessage' );
00755     }
00756 
00762     public function getShopVersion()
00763     {
00764         return $this->getViewConfigParam( 'sShopVersion' );
00765     }
00766 
00772     public function getAjaxLink()
00773     {
00774         return $this->getViewConfigParam( 'ajaxlink' );
00775     }
00776 
00782     public function isMultiShop()
00783     {
00784         $oShop = $this->getConfig()->getActiveShop();
00785         return isset( $oShop->oxshops__oxismultishop ) ? ( (bool) $oShop->oxshops__oxismultishop->value ) : false;
00786     }
00787 
00793     public function getServiceUrl()
00794     {
00795         return $this->getViewConfigParam( 'sServiceUrl' );
00796     }
00797 
00805     public function __get( $sVarName )
00806     {
00807         return $this->getViewVar( $sVarName );
00808     }
00809 
00817     public function getViewVar( $sVarName )
00818     {
00819         startProfile('oxviewconfig::__get');
00820 
00821         $myConfig = $this->getConfig();
00822 
00823         // cached ?
00824         if ( ( $sVarValue = $this->getViewConfigParam( $sVarName ) ) === null ) {
00825 
00826             // using magic getter instead of waisting memmory on rarelly used variables ..
00827             switch ( strtolower( $sVarName ) ) {
00828                 case 'sid' :
00829                     $sVarValue = $this->getSessionId();
00830                     break;
00831                 case 'hiddensid' :
00832                     $sVarValue = $this->getHiddenSid();
00833                     break;
00834                 case 'selflink' :
00835                     $sVarValue = $this->getSelfLink();
00836                     break;
00837                 case 'sslselflink' :
00838                     $sVarValue = $this->getSslSelfLink();
00839                     break;
00840                 //some different processing for Mall mode
00841                 case 'basedir' :
00842                     $sVarValue = $this->getBaseDir();
00843                     break;
00844                 case 'coreutilsdir' :
00845                     $sVarValue = $this->getCoreUtilsDir();
00846                     break;
00847                 case 'selfactionlink' :
00848                     $sVarValue = $this->getSelfActionLink();
00849                     break;
00850                 //https://.... or http://.... link
00851                 case 'currenthomedir' :
00852                     $sVarValue = $this->getCurrentHomeDir();
00853                     break;
00854                 case 'basketlink' :
00855                     $sVarValue = $this->getBasketLink();
00856                     break;
00857                 case 'orderlink' :
00858                     $sVarValue = $this->getOrderLink();
00859                     break;
00860                 case 'paymentlink' :
00861                     $sVarValue = $this->getPaymentLink();
00862                     break;
00863                 case 'exeorderlink' :
00864                     $sVarValue = $this->getExeOrderLink();
00865                     break;
00866                 case 'orderconfirmlink' :
00867                     $sVarValue = $this->getOrderConfirmLink();
00868                     break;
00869                 case 'basetpldir' :
00870                     $sVarValue = $this->getResourceUrl();
00871                     break;
00872                 case 'templatedir' :
00873                     $sVarValue = $this->getTemplateDir();
00874                     break;
00875                 case 'urltemplatedir' :
00876                     $sVarValue = $this->getUrlTemplateDir();
00877                     break;
00878                 case 'imagedir' :
00879                     $sVarValue = $this->getImageUrl();
00880                     break;
00881                 case 'nossl_imagedir' :
00882                     $sVarValue = $this->getNoSslImageDir();
00883                     break;
00884                 case 'dimagedir' :
00885                     $sVarValue = $this->getPictureDir();
00886                     break;
00887                 //applicable only in admin mode
00888                 //in most case admindir is set to "admin" unless you rename the admin dir
00889                 case 'admindir' :
00890                     $sVarValue = $this->getAdminDir();
00891                     break;
00892                 case 'id' :
00893                     $sVarValue = $this->getActiveShopId();
00894                     break;
00895                 case 'isssl' :
00896                     $sVarValue = $this->isSsl();
00897                     break;
00898                 case 'ip' :
00899                     $sVarValue = $this->getRemoteAddress();
00900                     break;
00901                 case 'popupident' :
00902                     $sVarValue = $this->getPopupIdent();
00903                     break;
00904                 case 'popupidentrand' :
00905                     $sVarValue = $this->getPopupIdentRand();
00906                     break;
00907                 case 'artperpageform' :
00908                     $sVarValue = $this->getArtPerPageForm();
00909                     break;
00910                 case 'buyableparent' :
00911                     $sVarValue = $this->isBuyableParent();
00912                     break;
00913                 case 'blshowbirthdayfields' :
00914                     $sVarValue = $this->showBirthdayFields();
00915                     break;
00916                 case 'blshowfinalstep' :
00917                     $sVarValue = $this->showFinalStep();
00918                     break;
00919                 case 'anrofcatarticles' :
00920                     $sVarValue = $this->getNrOfCatArticles();
00921                     break;
00922                 case 'blautosearchoncat' :
00923                     $sVarValue = $this->isAutoSearchOnCat();
00924                     break;
00925                 case 'cnid' :
00926                     $sVarValue = $this->getActCatId();
00927                     break;
00928                 case 'cl' :
00929                     $sVarValue = $this->getActiveClassName();
00930                     break;
00931                 case 'tpl' :
00932                     $sVarValue = $this->getActTplName();
00933                     break;
00934                 case 'lang' :
00935                 case 'slanguage' :
00936                     $sVarValue = $this->getActLanguageId();
00937                     break;
00938                 case 'helplink' :
00939                     $sVarValue = $this->getHelpLink();
00940                     break;
00941                 case 'logoutlink' :
00942                     $sVarValue = $this->getLogoutLink();
00943                     break;
00944                 case 'iartPerPage':
00945                     $sVarValue = $this->getArtPerPageCount();
00946                     break;
00947                 case 'navurlparams':
00948                     $sVarValue = $this->getNavUrlParams();
00949                     break;
00950                 case 'navformparams':
00951                     $sVarValue = $this->getNavFormParams();
00952                     break;
00953                 case 'blstockondefaultmessage':
00954                     $sVarValue = $this->getStockOnDefaultMessage();
00955                     break;
00956                 case 'blstockoffdefaultmessage':
00957                     $sVarValue = $this->getStockOffDefaultMessage();
00958                     break;
00959                 case 'sShopVersion':
00960                     $sVarValue = $this->getShopVersion();
00961                     break;
00962                 case 'ajaxlink':
00963                     $sVarValue = $this->getAjaxLink();
00964                     break;
00965                 case 'ismultishop':
00966                     $sVarValue = $this->isMultiShop();
00967                     break;
00968                 case 'sServiceUrl':
00969                     $sVarValue = $this->getServiceUrl();
00970                     break;
00971             }
00972         }
00973 
00974         $this->setViewConfigParam( $sVarName, $sVarValue );
00975 
00976         stopProfile('oxviewconfig::__get');
00977 
00978         return $sVarValue;
00979     }
00980 
00981     /*public funtion getLogoutLink()
00982     {
00983         //return parent::getLogoutLink() . 'xxx';
00984     }*/
00985 }

Generated on Tue Aug 4 09:10:00 2009 for OXID eShop CE by  doxygen 1.5.5