Created
September 21, 2017 19:59
-
-
Save mrjazz/91623625a9b72e9384d08b6c8f10e955 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (isset($_SERVER['argv']) && count($_SERVER['argv']) > 1) { | |
$doc = file_get_contents($_SERVER['argv'][1]); | |
$xml = new SimpleXMLElement($doc); | |
process($xml, "Missed pages:", 'messagebox_warning'); | |
process($xml, "Questions:", 'help'); | |
markersList($xml, "Won't be implemented in first version:", 'stop-sign'); | |
markersList($xml, "Already implemented:", 'button_ok'); | |
estimate($xml, "Estimate:"); | |
} else { | |
echo "No mindmaps in parameters passed\n"; | |
exit(); | |
} | |
function estimate($xml, $title) { | |
$content = "\n$title\n\n"; | |
$total = 0; | |
$result = $xml->xpath('//node'); | |
foreach ($result as $key => $value) { | |
if($value->count() > 0) { | |
foreach ($value->children() as $child) { | |
if ($child->getName() == 'attribute' && $child->attributes()["NAME"] == 'estimate') { | |
$content .= ' - ' . $value->attributes()['TEXT']->__toString() . ', ' . $child->attributes()["VALUE"] . "h\n"; | |
$total += $child->attributes()["VALUE"]; | |
} | |
} | |
} | |
} | |
echo $content; | |
echo "\nTotal: {$total}h\n"; | |
} | |
function markersList($xml, $title, $icon) { | |
$content = "\n$title\n\n"; | |
$result = $xml->xpath('//node'); | |
foreach ($result as $key => $value) { | |
if($value->count() > 0) { | |
foreach ($value->children() as $child) { | |
if ($child->getName() == 'icon' && $child->attributes()["BUILTIN"] == $icon) { | |
$content .= ' - ' . $value->attributes()['TEXT']->__toString() . "\n"; | |
} | |
} | |
} | |
} | |
echo $content; | |
} | |
function process($xml, $title, $icon) { | |
$content = "\n$title\n\n"; | |
$result = $xml->xpath('//node'); | |
$num = 1; | |
foreach ($result as $key => $value) { | |
// var_dump(strip_tags($value->html->asXML())); | |
if($value->count() > 0 && $value->children()[0]->getName() == 'richcontent') { | |
foreach ($value->children() as $child) { | |
if ($child->getName() == 'icon' && $child->attributes()["BUILTIN"] == $icon) { | |
$content .= " $num. " . $value->attributes()['TEXT']->__toString() . ":\n - "; | |
$text = preg_replace('/\s{2,}/m', "\n", trim(strip_tags($value->children()[0]->asXML()))); | |
$content .= implode("\n - ", explode("\n", $text)) . "\n"; | |
$num++; | |
} | |
} | |
} | |
} | |
echo $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment