From 9d18931c9731b76761966a446f6970780b429735 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Mon, 30 Dec 2013 00:20:53 -0500 Subject: [PATCH] Added REST lib to OpenMeetings plugin - refs BT#7046 refs #5491 --- .../lib/openmeetings_rest_service.php | 172 ++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 plugin/openmeetings/lib/openmeetings_rest_service.php diff --git a/plugin/openmeetings/lib/openmeetings_rest_service.php b/plugin/openmeetings/lib/openmeetings_rest_service.php new file mode 100644 index 0000000000..9cb7672c22 --- /dev/null +++ b/plugin/openmeetings/lib/openmeetings_rest_service.php @@ -0,0 +1,172 @@ +loadXML($xml); + + if ($returnAttribute == "") { + //echo "XML".$xml."
"; + return $this->getArray($dom); + } else { + $returnNodeList = $dom->getElementsByTagName($returnAttribute); + $ret = array(); + foreach ($returnNodeList as $returnNode) { + if ($returnNodeList->length == 1) { + return $this->getArray($returnNode); + } else { + $ret[] = $this->getArray($returnNode); + } + } + return $ret; + } + + } + + function getArray($node) { + if (is_null($node) || !is_object($node)) { + return $node; + } + $array = false; + /* + echo("!!!!!!!! NODE " . XML_TEXT_NODE + . " :: name = " . $node->nodeName + . " :: local = " . $node->localName + . " :: childs ? " . $node->hasChildNodes() + . " :: count = " . ($node->hasChildNodes() ? $node->childNodes->length : -1) + . " :: type = " . $node->nodeType + . " :: val = " . $node->nodeValue + . "\n"); + /* + if ($node->hasAttributes()) { + foreach ($node->attributes as $attr) { + $array[$attr->nodeName] = $attr->nodeValue; + } + } + */ + if ($node->hasChildNodes()) { + foreach ($node->childNodes as $childNode) { + if ($childNode->nodeType != XML_TEXT_NODE) { + if ($node->hasAttributes()) { + foreach ($node->attributes as $attr) { + if ($attr->localName == "nil") { + return null; + } + } + } + if ($childNode->childNodes->length == 1) { + $array[$childNode->localName] = $this->getArray($childNode); + } else { + $array[$childNode->localName][] = $this->getArray($childNode); + } + } else { + return $childNode->nodeValue; + //echo("!!!!!!!! TEXT " . $childNode->nodeValue . "\n"); + //$array[$childNode->localName] + } + } + } + + return $array; + } + + function getError(){ + return false; + } + + function fault(){ + return false; + } +} \ No newline at end of file