oxnavigationtree.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class OxNavigationTree extends oxSuperCfg
00007 {
00011     protected $_oDom = null;
00012 
00016     protected $_oInitialDom = null;
00017 
00023     protected $_sDynIncludeUrl = null;
00024 
00029     protected $_aSupportedExpathXmlEncodings = array( 'utf-8', 'utf-16', 'iso-8859-1', 'us-ascii' );
00030 
00038     public function init()
00039     {
00040     }
00041 
00051     protected function _cleanEmptyParents($oDom, $sParentXPath, $sChildXPath)
00052     {
00053         $oXPath = new DomXPath( $oDom );
00054         $oNodeList = $oXPath->query( $sParentXPath );
00055 
00056         foreach ( $oNodeList as $oNode ) {
00057             $sId = $oNode->getAttribute( 'id' );
00058             $oChildList = $oXPath->query( "{$sParentXPath}[@id='$sId']/$sChildXPath" );
00059             if (!$oChildList->length) {
00060                 $oNode->parentNode->removeChild( $oNode );
00061             }
00062         }
00063     }
00064 
00072     protected function _addLinks( $oDom )
00073     {
00074         $sURL   = 'index.php?'; // session parameters will be included later (after cache processor)
00075         $oXPath = new DomXPath( $oDom );
00076 
00077         // building
00078         $oNodeList = $oXPath->query( "//SUBMENU[@cl]" );
00079         foreach ( $oNodeList as $oNode ) {
00080             // fetching class
00081             $sCl = $oNode->getAttribute( 'cl' );
00082             $sCl = $sCl?"cl=$sCl":'';
00083 
00084             // fetching params
00085             $sParam = $oNode->getAttribute( 'clparam' );
00086             $sParam = $sParam?"&$sParam":'';
00087 
00088             // setting link
00089             $oNode->setAttribute( 'link', "{$sURL}{$sCl}{$sParam}" );
00090         }
00091     }
00092 
00101     protected function _loadFromFile( $sMenuFile, $oDom )
00102     {
00103         $blMerge = false;
00104         $oDomFile = new DomDocument();
00105         $oDomFile->preserveWhiteSpace = false;
00106         if ( !@$oDomFile->load( $sMenuFile ) ) {
00107             $blMerge = true;
00108         } elseif ( is_readable( $sMenuFile ) && ( $sXml = @file_get_contents( $sMenuFile ) ) ) {
00109 
00110             // looking for non supported character encoding
00111             if ( getStr()->preg_match( "/encoding\=(.*)\?>/", $sXml, $aMatches ) !== 0 ) {
00112                if ( isset( $aMatches[1] ) ) {
00113                    $sCurrEncoding = trim( $aMatches[1], "\"" );
00114                    if ( !in_array( strtolower( $sCurrEncoding ), $this->_aSupportedExpathXmlEncodings ) ) {
00115                        $sXml = str_replace( $aMatches[1], "\"UTF-8\"", $sXml );
00116                        $sXml = iconv( $sCurrEncoding, "UTF-8", $sXml );
00117                    }
00118                }
00119             }
00120 
00121             // load XML as string
00122             if ( @$oDomFile->loadXml( $sXml ) ) {
00123                 $blMerge = true;
00124             }
00125         }
00126 
00127         if ( $blMerge ) {
00128             $this->_merge( $oDomFile, $oDom );
00129         }
00130     }
00131 
00139     protected function _addDynLinks( $oDom )
00140     {
00141         $myConfig = $this->getConfig();
00142         $myUtilsFile = oxUtilsFile::getInstance();
00143 
00144         $sURL = 'index.php?'; // session parameters will be included later (after cache processor)
00145 
00146         $oXPath = new DomXPath( $oDom );
00147         $oNodeList = $oXPath->query( "//OXMENU[@type='dyn']/MAINMENU/SUBMENU" );
00148         foreach ( $oNodeList as $oNode ) {
00149 
00150             // fetching class
00151             $sCl = $oNode->getAttribute( 'cl' );
00152             $sCl = "cl=dynscreen&menu=$sCl";
00153 
00154             // fetching params
00155             $sParam = $oNode->getAttribute( 'clparam' );
00156             $sParam = $sParam?"&$sParam":'';
00157 
00158             // setting list node if its is not set yet
00159             if ( !$oNode->getAttribute( 'list' ) ) {
00160                 $oNode->setAttribute( 'list', 'dynscreen_list' );
00161                 $oNode->setAttribute( 'listparam', 'menu='.$oNode->getAttribute( 'cl' ) );
00162             }
00163 
00164             // setting link
00165             $oNode->setAttribute( 'link', "{$sURL}{$sCl}{$sParam}" );
00166 
00167             // setting id
00168             $oNode->parentNode->setAttribute( 'id', 'dyn_menu' );
00169 
00170             // setting id to its parent
00171 
00172             // fetching class
00173             $sFile = $oNode->getAttribute( 'cl' );
00174 
00175             // always display the "about" tab no matter what licence
00176             if ( $myUtilsFile->checkFile( "{$this->_sDynIncludeUrl}pages/{$sFile}_about.php" ) ) {
00177                 $oTabElem = new DOMElement( 'TAB' );
00178                 $oNode->appendChild( $oTabElem );
00179                 $oTabElem->setAttribute( 'external', 'true' );
00180                 $oTabElem->setAttribute( 'location', "{$this->_sDynIncludeUrl}pages/{$sFile}_about.php" );
00181                 $oTabElem->setAttribute( 'id', 'dyn_about' );
00182             }
00183 
00184             // checking for technics page
00185             if ( $myUtilsFile->checkFile( "{$this->_sDynIncludeUrl}pages/{$sFile}_technics.php" ) ) {
00186                 $oTabElem = new DOMElement( 'TAB' );
00187                 $oNode->appendChild( $oTabElem );
00188                 $oTabElem->setAttribute( 'external', 'true' );
00189                 $oTabElem->setAttribute( 'location', "{$this->_sDynIncludeUrl}pages/{$sFile}_technics.php" );
00190                 $oTabElem->setAttribute( 'id', 'dyn_interface' );
00191             }
00192 
00193             // checking for setup page
00194             if ( file_exists( $myConfig->getConfigParam( 'sShopDir' ).$myConfig->getConfigParam( 'sAdminDir' )."/{$sFile}.php" ) ) {
00195                 $oTabElem = new DOMElement( 'TAB' );
00196                 $oNode->appendChild( $oTabElem );
00197                 $oTabElem->setAttribute( 'id', 'dyn_interface' );
00198                 $oTabElem->setAttribute( 'cl', $sFile );
00199             }
00200         }
00201     }
00202 
00210     protected function _sessionizeLocalUrls( $oDom )
00211     {
00212         $sURL = $this->_getAdminUrl();
00213         $oXPath = new DomXPath( $oDom );
00214         $oStr = getStr();
00215         foreach (array('url', 'link') as $sAttrType) {
00216             foreach ( $oXPath->query( "//OXMENU//*[@$sAttrType]" ) as $oNode ) {
00217                 $sLocalUrl = $oNode->getAttribute( $sAttrType );
00218                 if (strpos($sLocalUrl, 'index.php?') === 0) {
00219                     $sLocalUrl = $oStr->preg_replace('#^index.php\?#', $sURL, $sLocalUrl);
00220                     $oNode->setAttribute( $sAttrType, $sLocalUrl );
00221                 }
00222             }
00223         }
00224     }
00225 
00233     protected function _checkRights( $oDom )
00234     {
00235         $oXPath    = new DomXPath( $oDom );
00236         $oNodeList = $oXPath->query( '//*[@rights or @norights]' );
00237 
00238         foreach ( $oNodeList as $oNode ) {
00239             // only allowed modules/user rights or so
00240             if ( ( $sReq = $oNode->getAttribute( 'rights' ) ) ) {
00241                 $aPerm = explode( ',', $sReq );
00242                 foreach ( $aPerm as $sPerm ) {
00243                     if ( $sPerm && !$this->_hasRights( $sPerm ) ) {
00244                         $oNode->parentNode->removeChild( $oNode );
00245                     }
00246                 }
00247                 // not allowed modules/user rights or so
00248             } elseif ( ( $sNoReq = $oNode->getAttribute( 'norights' ) ) ) {
00249                 $aPerm = explode( ',', $sNoReq );
00250                 foreach ( $aPerm as $sPerm ) {
00251                     if ( $sPerm && $this->_hasRights( $sPerm ) ) {
00252                         $oNode->parentNode->removeChild( $oNode );
00253                     }
00254                 }
00255             }
00256         }
00257     }
00258 
00266     protected function _checkGroups( $oDom )
00267     {
00268         $oXPath    = new DomXPath( $oDom );
00269         $oNodeList = $oXPath->query( "//*[@nogroup or @group]" );
00270 
00271         foreach ( $oNodeList as $oNode ) {
00272             // allowed only for groups
00273             if ( ( $sReq = $oNode->getAttribute('group') ) ) {
00274                 $aPerm = explode( ',', $sReq );
00275                 foreach ( $aPerm as $sPerm ) {
00276                     if ( $sPerm && !$this->_hasGroup( $sPerm ) ) {
00277                         $oNode->parentNode->removeChild($oNode);
00278                     }
00279                 }
00280                 // not allowed for groups
00281             } elseif ( ( $sNoReq = $oNode->getAttribute('nogroup') ) ) {
00282                 $aPerm = explode( ',', $sNoReq );
00283                 foreach ( $aPerm as $sPerm ) {
00284                     if ( $sPerm && $this->_hasGroup( $sPerm ) ) {
00285                         $oNode->parentNode->removeChild($oNode);
00286                     }
00287                 }
00288             }
00289         }
00290     }
00291 
00299     protected function _checkDemoShopDenials( $oDom )
00300     {
00301         if (!$this->getConfig()->isDemoShop()) {
00302             // nothing to check for non demo shop
00303             return;
00304         }
00305 
00306         $oXPath    = new DomXPath( $oDom );
00307         $oNodeList = $oXPath->query( "//*[@disableForDemoShop]" );
00308         foreach ( $oNodeList as $oNode ) {
00309             if ( $oNode->getAttribute('disableForDemoShop') ) {
00310                 $oNode->parentNode->removeChild($oNode);
00311             }
00312         }
00313     }
00314 
00323     protected function _copyAttributes( $oDomElemTo, $oDomElemFrom )
00324     {
00325         foreach ( $oDomElemFrom->attributes as $oAttr ) {
00326             $oDomElemTo->setAttribute( $oAttr->nodeName, $oAttr->nodeValue );
00327         }
00328     }
00329 
00341     protected function _mergeNodes( $oDomElemTo, $oDomElemFrom, $oXPathTo, $oDomDocTo, $sQueryStart )
00342     {
00343         foreach ( $oDomElemFrom->childNodes as $oFromNode ) {
00344             if ( $oFromNode->nodeType === XML_ELEMENT_NODE ) {
00345 
00346                 $sFromAttrName = $oFromNode->getAttribute( 'id' );
00347                 $sFromNodeName = $oFromNode->tagName;
00348 
00349                 // find current item
00350                 $sQuery   = "{$sQueryStart}/{$sFromNodeName}[@id='{$sFromAttrName}']";
00351                 $oCurNode = $oXPathTo->query( $sQuery );
00352 
00353                 // if not found - append
00354                 if ( $oCurNode->length == 0 ) {
00355                     $oDomElemTo->appendChild( $oDomDocTo->importNode( $oFromNode, true ) );
00356                 } else {
00357 
00358                     $oCurNode = $oCurNode->item( 0 );
00359 
00360                     // if found copy all attributes and check childnodes
00361                     $this->_copyAttributes( $oCurNode, $oFromNode );
00362 
00363                     if ( $oFromNode->childNodes->length ) {
00364                         $this->_mergeNodes( $oCurNode, $oFromNode, $oXPathTo, $oDomDocTo, $sQuery );
00365                     }
00366                 }
00367             }
00368         }
00369     }
00370 
00379     protected function _merge( $oDomNew, $oDom )
00380     {
00381         $oXPath = new DOMXPath( $oDom );
00382         $this->_mergeNodes( $oDom->documentElement, $oDomNew->documentElement, $oXPath, $oDom, '/OX' );
00383     }
00384 
00394     public function getTabs( $sId, $iAct, $blSetActive = true )
00395     {
00396         $oXPath = new DOMXPath( $this->getDomXml() );
00397         //$oNodeList = $oXPath->query( "//SUBMENU[@cl='$sId' or @list='$sId']/TAB | //SUBMENU/../TAB[@cl='$sId']" );
00398         $oNodeList = $oXPath->query( "//SUBMENU[@cl='$sId']/TAB | //SUBMENU[@list='$sId']/TAB | //SUBMENU/../TAB[@cl='$sId']" );
00399 
00400         $iAct = ( $iAct > $oNodeList->length )?( $oNodeList->length - 1 ):$iAct;
00401 
00402         if ( $blSetActive ) {
00403             foreach ( $oNodeList as $iPos => $oNode ) {
00404                 if ( $iPos == $iAct ) {
00405                     // marking active node
00406                     $oNode->setAttribute( 'active', 1 );
00407                 }
00408             }
00409         }
00410 
00411         return $oNodeList;
00412     }
00413 
00422     public function getActiveTab( $sId, $iAct )
00423     {
00424         $sTab = null;
00425         $oNodeList = $this->getTabs( $sId, $iAct, false );
00426         $iAct = ( $iAct > $oNodeList->length )?( $oNodeList->length - 1 ):$iAct;
00427         if ( $oNodeList->length && ( $oNode = $oNodeList->item( $iAct ) ) ) {
00428             $sTab = $oNode->getAttribute( 'cl' );
00429         }
00430 
00431         return $sTab;
00432     }
00433 
00441     public function getBtn( $sClass )
00442     {
00443         $oButtons = null;
00444         $oXPath = new DOMXPath($this->getDomXml());
00445         $oNodeList = $oXPath->query("//TAB[@cl='$sClass']/../BTN");
00446         if ($oNodeList->length) {
00447             $oButtons = new OxstdClass();
00448             foreach ($oNodeList as $oNode) {
00449                 $sBtnID = $oNode->getAttribute('id');
00450                 $oButtons->$sBtnID = 1;
00451             }
00452         }
00453         return $oButtons;
00454     }
00455 
00461     protected function _getMenuFiles()
00462     {
00463         $myConfig  = $this->getConfig();
00464         $myOxUtlis = oxUtils::getInstance();
00465 
00466         $sFullAdminDir = getShopBasePath() . $myConfig->getConfigParam( 'sAdminDir' );
00467         $sMenuFile = "/menu.xml";
00468 
00469         $sTmpDir = $myConfig->getConfigParam( 'sCompileDir' );
00470         $sDynLang = $this->_getDynMenuLang();
00471         $sLocalDynPath = "{$sTmpDir}{$sDynLang}_dynscreen.xml";
00472 
00473 
00474         // including std file
00475         if ( file_exists( $sFullAdminDir.$sMenuFile ) ) {
00476             $aFilesToLoad[] = $sFullAdminDir.$sMenuFile;
00477         }
00478 
00479         // including custom file
00480         if ( file_exists( "$sFullAdminDir/user.xml" ) ) {
00481             $aFilesToLoad[] = "$sFullAdminDir/user.xml";
00482         }
00483 
00484         // including module menu files
00485         $sPath = getShopBasePath();
00486         $aPathsToCheck = array( 'modules/' );
00487         $sPathToCheck  = reset( $aPathsToCheck );
00488         while ( $sPathToCheck ) {
00489             $sFullPath = $sPath.$sPathToCheck;
00490 
00491             // missing file/folder?
00492             if ( is_dir( $sFullPath ) ) {
00493 
00494                 // adding subfolders
00495                 $aSubF = glob( $sFullPath."*", GLOB_ONLYDIR );
00496                 if ( is_array( $aSubF ) ) {
00497                     foreach ( $aSubF as $sNewFolder ) {
00498                         $aPathsToCheck[] = str_replace( $sPath, "", $sNewFolder ) . "/";
00499                     }
00500                 }
00501 
00502                 // including menu file
00503                 $sMenuFile = "{$sFullPath}menu.xml";
00504                 if ( file_exists( $sMenuFile ) && is_readable( $sMenuFile ) ) {
00505                     $aFilesToLoad[] = $sMenuFile;
00506                 }
00507             }
00508             $sPathToCheck = next( $aPathsToCheck );
00509         }
00510 
00511         $blLoadDynContents = $myConfig->getConfigParam( 'blLoadDynContents' );
00512         $sShopCountry      = $myConfig->getConfigParam( 'sShopCountry' );
00513 
00514         // including dyn menu file
00515         $sDynPath = null;
00516 
00517         if ( $blLoadDynContents ) {
00518             if ( $sShopCountry ) {
00519                 $sRemoteDynUrl = $this->_getDynMenuUrl( $sDynLang, $blLoadDynContents );
00520 
00521                 // loading remote file from server only once
00522                 $blLoadRemote = oxSession::getVar( "loadedremotexml" );
00523 
00524                 // very basic check if its valid xml file
00525                 if ( ( !isset( $blLoadRemote ) || $blLoadRemote ) && ( $sDynPath = $myOxUtlis->getRemoteCachePath( $sRemoteDynUrl, $sLocalDynPath ) ) ) {
00526                     $sDynPath = $this->_checkDynFile( $sDynPath );
00527                 }
00528 
00529                 // caching last load state
00530                 oxSession::setVar( "loadedremotexml", $sDynPath ? true : false );
00531             }
00532         } else {
00533             if ( $sShopCountry ) {
00534                 //non international country
00535             }
00536         }
00537 
00538         // loading dynpages
00539         if ( $sDynPath ) {
00540             $aFilesToLoad[] = $sDynPath;
00541         }
00542         return $aFilesToLoad;
00543     }
00544 
00552     protected function _checkDynFile( $sDynFilePath )
00553     {
00554         $sDynFile = null;
00555         if ( file_exists( $sDynFilePath ) ) {
00556             $sLine = null;
00557             if ( ( $rHandle = @fopen($sDynFilePath, 'r' ) ) ) {
00558                 $sLine = stream_get_line( $rHandle, 100, "?>");
00559                 fclose( $rHandle );
00560 
00561                 // checking xml file header
00562                 if ( $sLine && stripos( $sLine, '<?xml' ) !== false ) {
00563                     $sDynFile = $sDynFilePath;
00564                 }
00565             }
00566 
00567             // cleanup ..
00568             if ( !$sDynFile ) {
00569                 @unlink( $sDynFilePath );
00570             }
00571         }
00572 
00573         return $sDynFile;
00574     }
00575 
00588     protected function _processCachedFile( $sCacheContents )
00589     {
00590         return $sCacheContents;
00591     }
00592 
00598     protected function _getInitialDom()
00599     {
00600         if ( $this->_oInitialDom === null ) {
00601             $myOxUtlis = oxUtils::getInstance();
00602 
00603             if ( is_array( $aFilesToLoad = $this->_getMenuFiles() ) ) {
00604 
00605                 // now checking if xml files are newer than cached file
00606                 $blReload = false;
00607                 $sDynLang = $this->_getDynMenuLang();
00608 
00609                 $sCacheName = 'menu_' . $sDynLang . '_xml';
00610                 $sCacheFile = $myOxUtlis->getCacheFilePath( $sCacheName );
00611                 $sCacheContents = $myOxUtlis->fromFileCache( $sCacheName );
00612                 if ( $sCacheContents && file_exists( $sCacheFile ) && ( $iCacheModTime = filemtime( $sCacheFile ) ) ) {
00613                     foreach ( $aFilesToLoad as $sDynPath ) {
00614                         if ( $iCacheModTime < filemtime( $sDynPath ) ) {
00615                             $blReload = true;
00616                         }
00617                     }
00618                 } else {
00619                     $blReload = true;
00620                 }
00621 
00622                 $this->_oInitialDom = new DOMDocument();
00623                 if ( $blReload ) {
00624                     // fully reloading and building pathes
00625                     $this->_oInitialDom->appendChild( new DOMElement( 'OX' ) );
00626 
00627                     foreach ( $aFilesToLoad as $sDynPath ) {
00628                         $this->_loadFromFile( $sDynPath, $this->_oInitialDom );
00629                     }
00630 
00631                     // adds links to menu items
00632                     $this->_addLinks( $this->_oInitialDom );
00633 
00634                     // adds links to dynamic parts
00635                     $this->_addDynLinks( $this->_oInitialDom );
00636 
00637                     // writing to cache
00638                     $myOxUtlis->toFileCache( $sCacheName, $this->_oInitialDom->saveXML() );
00639                 } else {
00640                     $sCacheContents = $this->_processCachedFile($sCacheContents);
00641                     // loading from cached file
00642                     $this->_oInitialDom->preserveWhiteSpace = false;
00643                     $this->_oInitialDom->loadXML( $sCacheContents );
00644                 }
00645 
00646                 // add session params
00647                 $this->_sessionizeLocalUrls( $this->_oInitialDom );
00648             }
00649         }
00650         return $this->_oInitialDom;
00651     }
00652 
00658     public function getDomXml()
00659     {
00660         if ( $this->_oDom === null ) {
00661             $this->_oDom = clone $this->_getInitialDom();
00662 
00663             // removes items denied by user group
00664             $this->_checkGroups( $this->_oDom );
00665 
00666             // removes items denied by user rights
00667             $this->_checkRights( $this->_oDom );
00668 
00669             // check config params
00670             $this->_checkDemoShopDenials( $this->_oDom );
00671 
00672 
00673             $this->_cleanEmptyParents( $this->_oDom, '//SUBMENU[@id][@list]', 'TAB');
00674             $this->_cleanEmptyParents( $this->_oDom, '//MAINMENU[@id]', 'SUBMENU');
00675         }
00676 
00677         return $this->_oDom;
00678     }
00679 
00687     public function getListNodes( $aNodes )
00688     {
00689         $oXPath = new DOMXPath( $this->getDomXml() );
00690         $oNodeList = $oXPath->query( "//SUBMENU[@cl='".implode("' or @cl='", $aNodes)."']" );
00691 
00692         return ( $oNodeList->length ) ? $oNodeList : null;
00693     }
00694 
00702     public function markNodeActive( $sNodeId )
00703     {
00704         $oXPath = new DOMXPath( $this->getDomXml() );
00705         $oNodeList = $oXPath->query( "//*[@cl='{$sNodeId}' or @list='{$sNodeId}']" );
00706 
00707         if ( $oNodeList->length ) {
00708             foreach ( $oNodeList as $oNode ) {
00709                 // special case for external resources
00710                 $oNode->setAttribute( 'active', 1 );
00711                 $oNode->parentNode->setAttribute( 'active', 1 );
00712             }
00713         }
00714 
00715     }
00716 
00724     public function getListUrl( $sId )
00725     {
00726         $sUrl = null;
00727         $oXPath = new DOMXPath( $this->getDomXml() );
00728         $oNodeList = $oXPath->query( "//SUBMENU[@cl='{$sId}']" );
00729         if ( $oNodeList->length && ( $oNode = $oNodeList->item( 0 ) ) ) {
00730             $sCl = $oNode->getAttribute('list');
00731             $sCl = $sCl?"cl=$sCl":'';
00732 
00733             $sParams = $oNode->getAttribute('listparam');
00734             $sParams = $sParams?"&$sParams":'';
00735 
00736             $sUrl = "{$sCl}{$sParams}";
00737         }
00738         return $sUrl;
00739     }
00740 
00749     public function getEditUrl( $sId, $iActTab )
00750     {
00751         $sUrl = null;
00752         $oXPath = new DOMXPath( $this->getDomXml() );
00753         $oNodeList = $oXPath->query( "//SUBMENU[@cl='{$sId}']/TAB" );
00754 
00755         $iActTab = ( $iActTab > $oNodeList->length )?( $oNodeList->length - 1 ) : $iActTab;
00756         if ( $oNodeList->length && ( $oActTab = $oNodeList->item( $iActTab ) ) ) {
00757             // special case for external resources
00758             if ( $oActTab->getAttribute( 'external' ) ) {
00759                 $sUrl = $oActTab->getAttribute( 'location' );
00760             } else {
00761                 $sCl = $oActTab->getAttribute( 'cl' );
00762                 $sCl = $sCl?"cl={$sCl}":'';
00763 
00764                 $sParams = $oActTab->getAttribute( 'clparam' );
00765                 $sParams = $sParams?"&{$sParams}":'';
00766 
00767                 $sUrl = "{$sCl}{$sParams}";
00768             }
00769         }
00770         return $sUrl;
00771     }
00772 
00778     protected function _getAdminUrl()
00779     {
00780         $myConfig = $this->getConfig();
00781 
00782         if ( ( $sAdminSslUrl = $myConfig->getConfigParam( 'sAdminSSLURL' ) ) ) {
00783             $sURL = trim( $sAdminSslUrl, '/' );
00784         } else {
00785             $sURL = trim( $myConfig->getConfigParam( 'sShopURL' ), '/' ).'/admin';
00786         }
00787         return oxUtilsUrl::getInstance()->processUrl("{$sURL}/index.php", false);
00788     }
00789 
00797     protected function _hasRights( $sRights )
00798     {
00799         return $this->getUser()->oxuser__oxrights->value == $sRights;
00800     }
00801 
00809     protected function _hasGroup( $sGroupId )
00810     {
00811         return $this->getUser()->inGroup( $sGroupId );
00812     }
00813 
00821     public function getClassId( $sClassName )
00822     {
00823         $sClassId = null;
00824 
00825         $oXPath = new DOMXPath( $this->_getInitialDom() );
00826         $oNodeList = $oXPath->query( "//*[@cl='{$sClassName}' or @list='{$sClassName}']" );
00827         if ( $oNodeList->length && ( $oFirstItem = $oNodeList->item( 0 ) ) ) {
00828             $sClassId = $oFirstItem->getAttribute( 'id' );
00829         }
00830 
00831         return $sClassId;
00832     }
00833 
00841     public function getShopVersionNr()
00842     {
00843         $sVersion = "";
00844         if ( ( $sShopId = $this->getConfig()->getShopId() ) ) {
00845             $sVersion = oxDb::getDb()->getOne( "select oxversion from oxshops where oxid = '$sShopId' " );
00846             $sVersion = preg_replace( "/(^[^0-9]+)(.+)$/", "\$2", $sVersion );
00847         }
00848 
00849         return trim( $sVersion );
00850     }
00851 
00852 
00861     protected function _getDynMenuUrl( $iLang, $blLoadDynContents )
00862     {
00863         if ( !$blLoadDynContents ) {
00864             // getting dyn info from oxid server is off, so getting local menu path
00865             $sFullAdminDir = getShopBasePath() . $this->getConfig()->getConfigParam( 'sAdminDir' );
00866             $sUrl = $sFullAdminDir . "/dynscreen_local.xml";
00867         } else {
00868             $oAdminView = oxNew( 'oxadminview' );
00869             $this->_sDynIncludeUrl = $oAdminView->getServiceUrl( $iLang );
00870             $sUrl .= $this->_sDynIncludeUrl . "menue/dynscreen.xml";
00871         }
00872 
00873         return $sUrl;
00874     }
00875 
00881     protected function _getDynMenuLang()
00882     {
00883         $myConfig = $this->getConfig();
00884         $oLang = oxLang::getInstance();
00885 
00886         $iDynLang = $myConfig->getConfigParam( 'iDynInterfaceLanguage' );
00887         $iDynLang = isset( $iDynLang )?$iDynLang:( $oLang->getObjectTplLanguage() );
00888 
00889         $aLanguages = $oLang->getLanguageArray();
00890         $sLangAbr = $aLanguages[$iDynLang]->abbr;
00891 
00892         return $sLangAbr;
00893     }
00894 }