diff --git a/module/convert/model.php b/module/convert/model.php index cb82ec0ef7..54944af734 100644 --- a/module/convert/model.php +++ b/module/convert/model.php @@ -320,41 +320,37 @@ class convertModel extends model $file = $filePath . $fileName; $handle = fopen($file, "r"); - $headerList = array(' '', ' '', ' '', ' '', ' '', ' '', ' '', ' '', ' '', ' '', ' '', ' '', ' '', ' '', ' ''); + $tagList = array(' '', ' '', ' '', ' '', ' '', ' '', ' '', ' '', ' '', ' '', ' '', ' '', ' '', ' '', ' ''); while(!feof($handle)) { $itemStr = fgets($handle); - foreach($headerList as $object) + foreach($tagList as $startName => $endName) { - $itemName = $object; - $itemName .= ' '; - - if(strpos($itemStr, $itemName) === false) continue; + $startName .= ' '; + if(strpos($itemStr, $startName) === false) continue; if(strpos($itemStr, '/>') === false) { - $end = $footerList[$object]; while(true) { $followItemStr = fgets($handle); $itemStr .= $followItemStr; - if(strpos($itemStr, $end) !== false) break; + if(strpos($itemStr, $endName) !== false) break; } } - $object = str_replace('<', '', $object); - $object = strtolower($object); + $object = str_replace('<', '', $startName); + $object = trim(strtolower($object)); $data = preg_replace ('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $itemStr); if(!file_exists($filePath . $object . '.xml')) $data = "\n \n" . $data; file_put_contents($filePath . $object . '.xml', $data, FILE_APPEND); } } - foreach($headerList as $object) + foreach($tagList as $startName => $endName) { - $object = str_replace('<', '', $object); + $object = str_replace('<', '', $startName); $object = strtolower($object); $filename = $filePath . $object . '.xml'; if(file_exists($filename)) file_put_contents($filename, '', FILE_APPEND);