Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($_SERVER['argv']) && count($_SERVER['argv']) > 1) {
  4. $doc = file_get_contents($_SERVER['argv'][1]);
  5.  
  6. $xml = new SimpleXMLElement($doc);
  7.  
  8. process($xml, "Missed pages:", 'messagebox_warning');
  9. process($xml, "Questions:", 'help');
  10. markersList($xml, "Won't be implemented in first version:", 'stop-sign');
  11. markersList($xml, "Already implemented:", 'button_ok');
  12.  
  13. estimate($xml, "Estimate:");
  14. } else {
  15. echo "No mindmaps in parameters passed\n";
  16. exit();
  17. }
  18.  
  19. function estimate($xml, $title) {
  20. $content = "\n$title\n\n";
  21. $total = 0;
  22. $result = $xml->xpath('//node');
  23. foreach ($result as $key => $value) {
  24. if($value->count() > 0) {
  25. foreach ($value->children() as $child) {
  26. if ($child->getName() == 'attribute' && $child->attributes()["NAME"] == 'estimate') {
  27. $content .= ' - ' . $value->attributes()['TEXT']->__toString() . ', ' . $child->attributes()["VALUE"] . "h\n";
  28. $total += $child->attributes()["VALUE"];
  29. }
  30. }
  31. }
  32. }
  33. echo $content;
  34. echo "\nTotal: {$total}h\n";
  35. }
  36.  
  37. function markersList($xml, $title, $icon) {
  38. $content = "\n$title\n\n";
  39. $result = $xml->xpath('//node');
  40. foreach ($result as $key => $value) {
  41. if($value->count() > 0) {
  42. foreach ($value->children() as $child) {
  43. if ($child->getName() == 'icon' && $child->attributes()["BUILTIN"] == $icon) {
  44. $content .= ' - ' . $value->attributes()['TEXT']->__toString() . "\n";
  45. }
  46. }
  47. }
  48. }
  49. echo $content;
  50. }
  51.  
  52.  
  53. function process($xml, $title, $icon) {
  54. $content = "\n$title\n\n";
  55. $result = $xml->xpath('//node');
  56. $num = 1;
  57.  
  58. foreach ($result as $key => $value) {
  59. // var_dump(strip_tags($value->html->asXML()));
  60. if($value->count() > 0 && $value->children()[0]->getName() == 'richcontent') {
  61. foreach ($value->children() as $child) {
  62. if ($child->getName() == 'icon' && $child->attributes()["BUILTIN"] == $icon) {
  63. $content .= " $num. " . $value->attributes()['TEXT']->__toString() . ":\n - ";
  64. $text = preg_replace('/\s{2,}/m', "\n", trim(strip_tags($value->children()[0]->asXML())));
  65. $content .= implode("\n - ", explode("\n", $text)) . "\n";
  66. $num++;
  67. }
  68. }
  69. }
  70. }
  71.  
  72. echo $content;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement