import_wbw.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. include "./config.php";
  3. $workDir = $dir_mydocument;
  4. $wbwFileName = $workDir.$_GET["filename"];
  5. $outXml = "<wordlist>";
  6. echo $outXml;
  7. $rowCount=0;
  8. $xmlObj = simplexml_load_file($wbwFileName);
  9. //get word list from pcs documnt
  10. $dataBlock = $xmlObj->xpath('//block');
  11. foreach($dataBlock as $block){
  12. if($block->info->type=="wbw"){
  13. //$words=$block->data->xpath('word');
  14. foreach($block->data->children() as $ws){
  15. $id=0;
  16. $pali=$ws->real;
  17. $mean=$ws->mean;
  18. $case=$ws->case;
  19. $factors=$ws->org;
  20. $fm="";
  21. if(isset($ws->om)){
  22. $fm=$ws->om;
  23. }
  24. $parent="";
  25. if(isset($ws->parent)){
  26. $parent=$ws->parent;
  27. }
  28. $note="";
  29. if(isset($ws->note)){
  30. $note=$ws->note;
  31. }
  32. $arrCase=explode("#",$case);
  33. $type=$arrCase[0];
  34. $gramma="";
  35. if(isset($arrCase[1])){
  36. $gramma=$arrCase[1];
  37. }
  38. if(!empty($pali) && ($mean!="?" || $factors!="?" || $case!="?")){
  39. $outXml = "<word>";
  40. $outXml = $outXml."<id>$id</id>";
  41. $outXml = $outXml."<pali>$pali</pali>";
  42. $outXml = $outXml."<mean>$mean</mean>";
  43. $outXml = $outXml."<type>$type</type>";
  44. $outXml = $outXml."<gramma>$gramma</gramma>";
  45. $outXml = $outXml."<parent>$parent</parent>";
  46. $outXml = $outXml."<factors>$factors</factors>";
  47. $outXml = $outXml."<factorMean>$fm</factorMean>";
  48. $outXml = $outXml."<note>$note</note>";
  49. $outXml = $outXml."<confer></confer>";
  50. $outXml = $outXml."<status>0</status>";
  51. $outXml = $outXml."<lock>FALSE</lock>";
  52. $outXml = $outXml."<dictname>$wbwFileName</dictname>";
  53. $outXml = $outXml."<dictType>wbw</dictType>";
  54. $outXml = $outXml."<fileName>$wbwFileName</fileName>";
  55. $outXml = $outXml."<parentLevel>0</parentLevel>";
  56. $outXml = $outXml."</word>";
  57. echo $outXml;
  58. }
  59. $rowCount++;
  60. }
  61. }
  62. }
  63. $outXml = "</wordlist>";
  64. echo $outXml;
  65. ?>