42         $oXPath = 
new DomXPath($oDom);
 
   43         $oNodeList = $oXPath->query($sParentXPath);
 
   45         foreach ($oNodeList as $oNode) {
 
   46             $sId = $oNode->getAttribute(
'id');
 
   47             $oChildList = $oXPath->query(
"{$sParentXPath}[@id='$sId']/$sChildXPath");
 
   48             if (!$oChildList->length) {
 
   49                 $oNode->parentNode->removeChild($oNode);
 
   62         $oXPath = 
new DomXPath($oDom);
 
   65         $oNodeList = $oXPath->query(
"//SUBMENU[@cl]");
 
   66         foreach ($oNodeList as $oNode) {
 
   68             $sCl = $oNode->getAttribute(
'cl');
 
   69             $sCl = $sCl ? 
"cl=$sCl" : 
'';
 
   72             $sParam = $oNode->getAttribute(
'clparam');
 
   73             $sParam = $sParam ? 
"&$sParam" : 
'';
 
   76             $oNode->setAttribute(
'link', 
"{$sURL}{$sCl}{$sParam}");
 
   89         $oDomFile = 
new DomDocument();
 
   90         $oDomFile->preserveWhiteSpace = 
false;
 
   91         if (!@$oDomFile->load($sMenuFile)) {
 
   93         } elseif (is_readable($sMenuFile) && ($sXml = @file_get_contents($sMenuFile))) {
 
   96             if (
getStr()->preg_match(
"/encoding\=(.*)\?>/", $sXml, $aMatches) !== 0) {
 
   97                 if (isset($aMatches[1])) {
 
   98                     $sCurrEncoding = trim($aMatches[1], 
"\"");
 
   99                     if (!in_array(strtolower($sCurrEncoding), $this->_aSupportedExpathXmlEncodings)) {
 
  100                         $sXml = str_replace($aMatches[1], 
"\"UTF-8\"", $sXml);
 
  101                         $sXml = iconv($sCurrEncoding, 
"UTF-8", $sXml);
 
  107             if (@$oDomFile->loadXml($sXml)) {
 
  113             $this->
_merge($oDomFile, $oDom);
 
  129         $sURL = 
'index.php?'; 
 
  131         $oXPath = 
new DomXPath($oDom);
 
  132         $oNodeList = $oXPath->query(
"//OXMENU[@type='dyn']/MAINMENU/SUBMENU");
 
  134         foreach ($oNodeList as $oNode) {
 
  137             $sCl = $oNode->getAttribute(
'cl');
 
  138             $sCl = 
"cl=dynscreen&menu=$sCl";
 
  141             $sParam = $oNode->getAttribute(
'clparam');
 
  142             $sParam = $sParam ? 
"&$sParam" : 
'';
 
  145             if (!$oNode->getAttribute(
'list')) {
 
  146                 $oNode->setAttribute(
'list', 
'dynscreen_list');
 
  147                 $oNode->setAttribute(
'listparam', 
'menu=' . $oNode->getAttribute(
'cl'));
 
  151             $oNode->setAttribute(
'link', 
"{$sURL}{$sCl}{$sParam}");
 
  154             $oNode->parentNode->setAttribute(
'id', 
'dyn_menu');
 
  159             $sFile = $oNode->getAttribute(
'cl');
 
  163             if ($myUtilsFile->checkFile(
"{$this->_sDynIncludeUrl}pages/{$sFile}_about.php")) {
 
  164                 $oTabElem = 
new DOMElement(
'TAB');
 
  165                 $oNode->appendChild($oTabElem);
 
  166                 $oTabElem->setAttribute(
'external', 
'true');
 
  167                 $oTabElem->setAttribute(
'location', 
"{$this->_sDynIncludeUrl}pages/{$sFile}_about.php");
 
  168                 $oTabElem->setAttribute(
'id', 
'dyn_about');
 
  172             if ($myUtilsFile->checkFile(
"{$this->_sDynIncludeUrl}pages/{$sFile}_technics.php")) {
 
  173                 $oTabElem = 
new DOMElement(
'TAB');
 
  174                 $oNode->appendChild($oTabElem);
 
  175                 $oTabElem->setAttribute(
'external', 
'true');
 
  176                 $oTabElem->setAttribute(
'location', 
"{$this->_sDynIncludeUrl}pages/{$sFile}_technics.php");
 
  177                 $oTabElem->setAttribute(
'id', 
'dyn_interface');
 
  181             if (file_exists(
$myConfig->getConfigParam(
'sShopDir') . 
"/application/controllers/admin/{$sFile}.php")) {
 
  182                 $oTabElem = 
new DOMElement(
'TAB');
 
  183                 $oNode->appendChild($oTabElem);
 
  184                 $oTabElem->setAttribute(
'id', 
'dyn_interface');
 
  185                 $oTabElem->setAttribute(
'cl', $sFile);
 
  198         $oXPath = 
new DomXPath($oDom);
 
  200         foreach (array(
'url', 
'link') as $sAttrType) {
 
  201             foreach ($oXPath->query(
"//OXMENU//*[@$sAttrType]") as $oNode) {
 
  202                 $sLocalUrl = $oNode->getAttribute($sAttrType);
 
  203                 if (strpos($sLocalUrl, 
'index.php?') === 0) {
 
  204                     $sLocalUrl = $oStr->preg_replace(
'#^index.php\?#', $sURL, $sLocalUrl);
 
  205                     $oNode->setAttribute($sAttrType, $sLocalUrl);
 
  218         $oXPath = 
new DomXPath($oDom);
 
  219         $oNodeList = $oXPath->query(
'//*[@rights or @norights]');
 
  221         foreach ($oNodeList as $oNode) {
 
  223             if (($sReq = $oNode->getAttribute(
'rights'))) {
 
  224                 $aPerm = explode(
',', $sReq);
 
  225                 foreach ($aPerm as $sPerm) {
 
  227                         $oNode->parentNode->removeChild($oNode);
 
  231             } elseif (($sNoReq = $oNode->getAttribute(
'norights'))) {
 
  232                 $aPerm = explode(
',', $sNoReq);
 
  233                 foreach ($aPerm as $sPerm) {
 
  235                         $oNode->parentNode->removeChild($oNode);
 
  249         $oXPath = 
new DomXPath($oDom);
 
  250         $oNodeList = $oXPath->query(
"//*[@nogroup or @group]");
 
  252         foreach ($oNodeList as $oNode) {
 
  254             if (($sReq = $oNode->getAttribute(
'group'))) {
 
  255                 $aPerm = explode(
',', $sReq);
 
  256                 foreach ($aPerm as $sPerm) {
 
  257                     if ($sPerm && !$this->
_hasGroup($sPerm)) {
 
  258                         $oNode->parentNode->removeChild($oNode);
 
  262             } elseif (($sNoReq = $oNode->getAttribute(
'nogroup'))) {
 
  263                 $aPerm = explode(
',', $sNoReq);
 
  264                 foreach ($aPerm as $sPerm) {
 
  265                     if ($sPerm && $this->
_hasGroup($sPerm)) {
 
  266                         $oNode->parentNode->removeChild($oNode);
 
  287         $oXPath = 
new DomXPath($oDom);
 
  288         $oNodeList = $oXPath->query(
"//*[@disableForDemoShop]");
 
  289         foreach ($oNodeList as $oNode) {
 
  290             if ($oNode->getAttribute(
'disableForDemoShop')) {
 
  291                 $oNode->parentNode->removeChild($oNode);
 
  305         $oXPath = 
new DomXPath($oDom);
 
  306         $oNodeList = $oXPath->query(
"//*[@visible]");
 
  307         foreach ($oNodeList as $oNode) {
 
  308             if (!$oNode->getAttribute(
'visible')) {
 
  309                 $oNode->parentNode->removeChild($oNode);
 
  322         foreach ($oDomElemFrom->attributes as $oAttr) {
 
  323             $oDomElemTo->setAttribute($oAttr->nodeName, $oAttr->nodeValue);
 
  336     protected function _mergeNodes($oDomElemTo, $oDomElemFrom, $oXPathTo, $oDomDocTo, $sQueryStart)
 
  338         foreach ($oDomElemFrom->childNodes as $oFromNode) {
 
  339             if ($oFromNode->nodeType === XML_ELEMENT_NODE) {
 
  341                 $sFromAttrName = $oFromNode->getAttribute(
'id');
 
  342                 $sFromNodeName = $oFromNode->tagName;
 
  345                 $sQuery = 
"{$sQueryStart}/{$sFromNodeName}[@id='{$sFromAttrName}']";
 
  346                 $oCurNode = $oXPathTo->query($sQuery);
 
  349                 if ($oCurNode->length == 0) {
 
  350                     $oDomElemTo->appendChild($oDomDocTo->importNode($oFromNode, 
true));
 
  353                     $oCurNode = $oCurNode->item(0);
 
  358                     if ($oFromNode->childNodes->length) {
 
  359                         $this->
_mergeNodes($oCurNode, $oFromNode, $oXPathTo, $oDomDocTo, $sQuery);
 
  372     protected function _merge($oDomNew, $oDom)
 
  374         $oXPath = 
new DOMXPath($oDom);
 
  375         $this->
_mergeNodes($oDom->documentElement, $oDomNew->documentElement, $oXPath, $oDom, 
'/OX');
 
  387     public function getTabs($sId, $iAct, $blSetActive = 
true)
 
  389         $oXPath = 
new DOMXPath($this->
getDomXml());
 
  391         $oNodeList = $oXPath->query(
"//SUBMENU[@cl='$sId']/TAB | //SUBMENU[@list='$sId']/TAB | //SUBMENU/../TAB[@cl='$sId']");
 
  393         $iAct = ($iAct > $oNodeList->length) ? ($oNodeList->length - 1) : $iAct;
 
  396             foreach ($oNodeList as $iPos => $oNode) {
 
  397                 if ($iPos == $iAct) {
 
  399                     $oNode->setAttribute(
'active', 1);
 
  418         $oNodeList = $this->
getTabs($sId, $iAct, 
false);
 
  419         $iAct = ($iAct > $oNodeList->length) ? ($oNodeList->length - 1) : $iAct;
 
  420         if ($oNodeList->length && ($oNode = $oNodeList->item($iAct))) {
 
  421             $sTab = $oNode->getAttribute(
'cl');
 
  437         $oXPath = 
new DOMXPath($this->
getDomXml());
 
  438         $oNodeList = $oXPath->query(
"//TAB[@cl='$sClass']/../BTN");
 
  439         if ($oNodeList->length) {
 
  440             $oButtons = 
new stdClass();
 
  441             foreach ($oNodeList as $oNode) {
 
  442                 $sBtnID = $oNode->getAttribute(
'id');
 
  443                 $oButtons->$sBtnID = 1;
 
  460         $sFullAdminDir = getShopBasePath() . 
'application/views/admin';
 
  461         $sMenuFile = 
"/menu.xml";
 
  463         $sTmpDir = 
$myConfig->getConfigParam(
'sCompileDir');
 
  465         $sLocalDynPath = 
"{$sTmpDir}{$sDynLang}_dynscreen.xml";
 
  469         if (file_exists($sFullAdminDir . $sMenuFile)) {
 
  470             $aFilesToLoad[] = $sFullAdminDir . $sMenuFile;
 
  474         if (file_exists(
"$sFullAdminDir/user.xml")) {
 
  475             $aFilesToLoad[] = 
"$sFullAdminDir/user.xml";
 
  479         $sPath = getShopBasePath();
 
  480         $oModulelist = 
oxNew(
'oxmodulelist');
 
  481         $aActiveModuleInfo = $oModulelist->getActiveModuleInfo();
 
  482         if (is_array($aActiveModuleInfo)) {
 
  483             foreach ($aActiveModuleInfo as $sModulePath) {
 
  484                 $sFullPath = $sPath . 
"modules/" . $sModulePath;
 
  486                 if (is_dir($sFullPath)) {
 
  488                     $sMenuFile = $sFullPath . 
"/menu.xml";
 
  489                     if (file_exists($sMenuFile) && is_readable($sMenuFile)) {
 
  490                         $aFilesToLoad[] = $sMenuFile;
 
  496         $blLoadDynContents = 
$myConfig->getConfigParam(
'blLoadDynContents');
 
  497         $sShopCountry = 
$myConfig->getConfigParam(
'sShopCountry');
 
  502         if ($blLoadDynContents) {
 
  504                 $sRemoteDynUrl = $this->
_getDynMenuUrl($sDynLang, $blLoadDynContents);
 
  510                 if ((!isset($blLoadRemote) || $blLoadRemote) && ($sDynPath = $myOxUtlis->getRemoteCachePath($sRemoteDynUrl, $sLocalDynPath))) {
 
  525             $aFilesToLoad[] = $sDynPath;
 
  528         return $aFilesToLoad;
 
  543         if (file_exists($sDynFilePath)) {
 
  545             if (($rHandle = @fopen($sDynFilePath, 
'r'))) {
 
  546                 $sLine = stream_get_line($rHandle, 100, 
"?>");
 
  550                 if ($sLine && stripos($sLine, 
'<?xml') !== 
false) {
 
  551                     $sDynFile = $sDynFilePath;
 
  557                 @unlink($sDynFilePath);
 
  578         return $sCacheContents;
 
  588         if ($this->_oInitialDom === null) {
 
  597                 $sShopId = $this->
getConfig()->getActiveShop()->getShopId();
 
  598                 $sCacheName = 
'menu_' . $sDynLang . $sShopId . 
'_xml';
 
  599                 $sCacheFile = $myOxUtlis->getCacheFilePath($sCacheName);
 
  600                 $sCacheContents = $myOxUtlis->fromFileCache($sCacheName);
 
  601                 if ($sCacheContents && file_exists($sCacheFile) && ($iCacheModTime = filemtime($sCacheFile))) {
 
  602                     foreach ($aFilesToLoad as $sDynPath) {
 
  603                         if ($iCacheModTime < filemtime($sDynPath)) {
 
  611                 $this->_oInitialDom = 
new DOMDocument();
 
  614                     $this->_oInitialDom->appendChild(
new DOMElement(
'OX'));
 
  616                     foreach ($aFilesToLoad as $sDynPath) {
 
  629                     $myOxUtlis->toFileCache($sCacheName, $this->_oInitialDom->saveXML());
 
  633                     $this->_oInitialDom->preserveWhiteSpace = 
false;
 
  634                     $this->_oInitialDom->loadXML($sCacheContents);
 
  652         if ($this->_oDom === null) {
 
  684         $oXPath = 
new DOMXPath($this->
getDomXml());
 
  685         $oNodeList = $oXPath->query(
"//SUBMENU[@cl='" . implode(
"' or @cl='", $aNodes) . 
"']");
 
  687         return ($oNodeList->length) ? $oNodeList : null;
 
  697         $oXPath = 
new DOMXPath($this->
getDomXml());
 
  698         $oNodeList = $oXPath->query(
"//*[@cl='{$sNodeId}' or @list='{$sNodeId}']");
 
  700         if ($oNodeList->length) {
 
  701             foreach ($oNodeList as $oNode) {
 
  703                 $oNode->setAttribute(
'active', 1);
 
  704                 $oNode->parentNode->setAttribute(
'active', 1);
 
  720         $oXPath = 
new DOMXPath($this->
getDomXml());
 
  721         $oNodeList = $oXPath->query(
"//SUBMENU[@cl='{$sId}']");
 
  722         if ($oNodeList->length && ($oNode = $oNodeList->item(0))) {
 
  723             $sCl = $oNode->getAttribute(
'list');
 
  724             $sCl = $sCl ? 
"cl=$sCl" : 
'';
 
  726             $sParams = $oNode->getAttribute(
'listparam');
 
  727             $sParams = $sParams ? 
"&$sParams" : 
'';
 
  729             $sUrl = 
"{$sCl}{$sParams}";
 
  746         $oXPath = 
new DOMXPath($this->
getDomXml());
 
  747         $oNodeList = $oXPath->query(
"//SUBMENU[@cl='{$sId}']/TAB");
 
  749         $iActTab = ($iActTab > $oNodeList->length) ? ($oNodeList->length - 1) : $iActTab;
 
  750         if ($oNodeList->length && ($oActTab = $oNodeList->item($iActTab))) {
 
  752             if ($oActTab->getAttribute(
'external')) {
 
  753                 $sUrl = $oActTab->getAttribute(
'location');
 
  755                 $sCl = $oActTab->getAttribute(
'cl');
 
  756                 $sCl = $sCl ? 
"cl={$sCl}" : 
'';
 
  758                 $sParams = $oActTab->getAttribute(
'clparam');
 
  759                 $sParams = $sParams ? 
"&{$sParams}" : 
'';
 
  761                 $sUrl = 
"{$sCl}{$sParams}";
 
  777         if (($sAdminSslUrl = 
$myConfig->getConfigParam(
'sAdminSSLURL'))) {
 
  778             $sURL = trim($sAdminSslUrl, 
'/');
 
  780             $sURL = trim(
$myConfig->getConfigParam(
'sShopURL'), 
'/') . 
'/admin';
 
  783         return oxRegistry::get(
"oxUtilsUrl")->processUrl(
"{$sURL}/index.php", 
false);
 
  795         return $this->
getUser()->oxuser__oxrights->value == $sRights;
 
  807         return $this->
getUser()->inGroup($sGroupId);
 
  822         $oNodeList = $oXPath->query(
"//*[@cl='{$sClassName}' or @list='{$sClassName}']");
 
  823         if ($oNodeList->length && ($oFirstItem = $oNodeList->item(0))) {
 
  824             $sClassId = $oFirstItem->getAttribute(
'id');
 
  843         if (!$blLoadDynContents) {
 
  845             $sFullAdminDir = getShopBasePath() . 
'application/views/admin';
 
  846             $sUrl = $sFullAdminDir . 
"/dynscreen_local.xml";
 
  848             $oAdminView = 
oxNew(
'oxadminview');
 
  849             $this->_sDynIncludeUrl = $oAdminView->getServiceUrl($iLang);
 
  850             $sUrl .= $this->_sDynIncludeUrl . 
"menue/dynscreen.xml";
 
  868         $iDynLang = 
$myConfig->getConfigParam(
'iDynInterfaceLanguage');
 
  869         $iDynLang = isset($iDynLang) ? $iDynLang : ($oLang->getTplLanguage());