示例#1
0
 private function getDataFromXmlFile($sFilename)
 {
     //load XML from file
     if (!file_exists($sFilename)) {
         throw new AnwBadCallException("import file not found");
     }
     $sFileContent = AnwUtils::file_get_contents($sFilename);
     $oRootNode = AnwUtils::loadXml($sFileContent);
     $aaData = array();
     $aaData['PAGEGROUPS'] = array();
     $aaData['TIME'] = $oRootNode->getAttribute("time");
     $aaData['FROM'] = AnwXml::xmlFileAttributeDecode($oRootNode->getAttribute("from"));
     $aaData['VERSION_ID'] = $oRootNode->getAttribute("version_id");
     $aaData['VERSION_NAME'] = AnwXml::xmlFileAttributeDecode($oRootNode->getAttribute("version_name"));
     $aoPageGroupsNodes = AnwXml::xmlGetChildsByTagName(self::XMLTAG_PAGEGROUP, $oRootNode);
     foreach ($aoPageGroupsNodes as $oPageGroupNode) {
         $aaDataGroup = array();
         $aaDataGroup['CONTENTCLASS'] = AnwXml::xmlFileAttributeDecode($oPageGroupNode->getAttribute("contentclass"));
         $aaDataGroup['PAGES'] = array();
         $aoTranslationsNodes = AnwXml::xmlGetChildsByTagName(self::XMLTAG_PAGE, $oPageGroupNode);
         foreach ($aoTranslationsNodes as $oPageNode) {
             $asDataPage = array();
             $asDataPage['NAME'] = AnwXml::xmlFileAttributeDecode($oPageNode->getAttribute("name"));
             $asDataPage['LANG'] = AnwXml::xmlFileAttributeDecode($oPageNode->getAttribute("lang"));
             $asDataPage['TIME'] = (int) $oPageNode->getAttribute("time");
             $asDataPage['CONTENT'] = AnwUtils::xmlDumpNodeChilds($oPageNode);
             $aaDataGroup['PAGES'][] = $asDataPage;
         }
         $aaData['PAGEGROUPS'][] = $aaDataGroup;
     }
     return $aaData;
 }