/** * @see parent::getMultipleTextNodes */ function getMultipleTextNodes($query, DOMNode $contextNode = null, $implode = false) { $array = array(); $query = utf8_encode($query); $nodeList = $contextNode ? parent::query($query, $contextNode) : parent::query($query); foreach ($nodeList as $n) { $array[] = utf8_decode($n->nodeValue); } return $implode ? implode("\n", $array) : $array; }
/** * @see parent::getAcknowledgment */ function getAcknowledgment() { $dom = new CMbXMLDocument("UTF-8"); $dom->loadXMLSafe($this->ack_data); $xpath = new CMbXPath($dom); $xpath->registerNamespace("rs", "urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0"); $xpath->registerNamespace("rim", "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0"); $status = $xpath->queryAttributNode(".", null, "status"); if ($status === "urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure") { $nodes = $xpath->query("//rs:RegistryErrorList/rs:RegistryError"); $ack = array(); foreach ($nodes as $_node) { $ack[] = array("status" => $xpath->queryAttributNode(".", $_node, "codeContext"), "context" => $xpath->queryAttributNode(".", $_node, "errorCode")); } } else { $nodes = $xpath->query("//rim:RegistryObjectList/rim:ObjectRef"); $ack = array(); foreach ($nodes as $_node) { $ack[] = array("status" => $xpath->queryAttributNode(".", $_node, "id"), "context" => ""); } } return $ack; }
/** * Retourne l'ensemble des valeurs d'un jeux de valeur * * @param String $name Nom du jeux de valeur * * @return array */ static function loadJV($name) { $path = "modules/xds/resources/jeux_de_valeurs/{$name}"; $dom = new CXDSXmlDocument(); $dom->load($path); $xpath = new CMbXPath($dom); $nodes = $xpath->query("//line"); $jeux_valeurs = array(); foreach ($nodes as $_node) { $id = $xpath->queryAttributNode(".", $_node, "id"); $oid = $xpath->queryAttributNode(".", $_node, "oid"); $name = $xpath->queryAttributNode(".", $_node, "name"); $jeux_valeurs["{$oid}^{$id}"] = $name; } return $jeux_valeurs; }
case 0: // Nom du médecin $query = "td[2]/span[1]"; $nom_prenom = $xpath2->queryTextNode($query, $nodeMainTr); preg_match('/^\\s*(.+)\\s+([^\\s]+)\\s*$/', $nom_prenom, $matches); $medecin->nom = $matches[1]; $medecin->prenom = $matches[2]; // RPPS $query = "td[2]/strong[1]"; $medecin->rpps = $xpath2->queryTextNode($query, $nodeMainTr); break; case 1: // Disciplines qualifiantes // Le champ discipline exercée peut ne pas être renseigné. $query = "td[2]/strong"; $medecin->disciplines = $xpath2->query($query, $nodeMainTr)->item(0)->nextSibling ? $xpath2->query($query, $nodeMainTr)->item(0)->nextSibling->nodeValue : ""; break; case 2: $query = "td[2]"; $infos = $xpath2->query($query, $nodeMainTr); $td = $infos->item(0); $child = $td->firstChild; $cp_ville = $td->lastChild; // Adresse $medecin->adresse = ""; while ($child !== $cp_ville) { if ($child->nodeName === "br") { $medecin->adresse .= "\n"; } else { $medecin->adresse .= $child->nodeValue; }
/** * Check service availability * * @throws CMbException * * @return void */ public function checkServiceAvailability() { $url = $this->wsdl_url; if ($this->wsdl_original) { $url = $this->wsdl_original; } $xml = file_get_contents($url); $dom = new CMbXMLDocument(); $dom->loadXML($xml); $xpath = new CMbXPath($dom); $xpath->registerNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/"); $xpath->registerNamespace("soap", "http://schemas.xmlsoap.org/wsdl/soap/"); $xpath->registerNamespace("soap12", "http://schemas.xmlsoap.org/wsdl/soap12"); $login = CMbArray::get($this->options, "login"); $password = CMbArray::get($this->options, "password"); $service_nodes = $xpath->query("//wsdl:service"); foreach ($service_nodes as $_service_node) { $service_name = $_service_node->getAttribute("name"); $port_nodes = $xpath->query("wsdl:port", $_service_node); foreach ($port_nodes as $_port_node) { $address = $xpath->queryAttributNode("soap:address|soap12:address", $_port_node, "location"); if (!$address) { continue; } if ($login && $password) { $address = str_replace("://", "://{$login}:{$password}@", $address); } // Url exist $url_exist = CHTTPClient::checkUrl($address, $this->check_option); if (!$url_exist) { throw new CMbException("Service '{$service_name}' injoignable à l'adresse : <em>{$address}</em>"); } } } }
/* $Id $ */ /** * @package Mediboard * @subpackage hl7 * @version $Revision: 15455 $ * @author SARL OpenXtrem * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html */ $er7 = CValue::post("er7"); $query = CValue::post("query"); $hl7_message = new CHL7v2Message(); $hl7_message->parse($er7); $xml = $hl7_message->toXML(); if ($query) { $xpath = new CMbXPath($xml); $results = @$xpath->query("//{$query}"); $nodes = array(); // Création du template $smarty = new CSmartyDP(); if ($results) { foreach ($results as $result) { $nodes[] = CMbString::highlightCode("xml", $xml->saveXML($result)); } } $smarty->assign("nodes", $nodes); $smarty->display("inc_er7_xml_result.tpl"); } else { ob_clean(); header("Content-Type: text/xml"); echo $xml->saveXML(); CApp::rip();
/** * Query nodes by XPath * * @param string $query XPath * @param CHL7v2DOMElement $contextNode Context node * * @return CHL7v2DOMElement[] */ function query($query, CHL7v2DOMElement $contextNode = null) { $xpath = new CMbXPath($this); return $xpath->query($query, $contextNode); }
$actor = CMbObject::loadFromGuid($actor_guid); $format_config = CMbObject::loadFromGuid($format_config_guid); if (!$format_config->sender_class || !$format_config->sender_id) { $format_config->sender_class = $actor->_class; $format_config->sender_id = $actor->_id; } $dom = new CMbXMLDocument(); $dom->loadXML($contents); $root_name = $dom->documentElement->nodeName; $fields = $format_config->getPlainFields(); unset($fields[$format_config->_spec->key]); unset($fields["sender_id"]); unset($fields["sender_class"]); if ($root_name == $format_config->_class) { $xpath = new CMbXPath($dom); $nodeList = $xpath->query("//{$root_name}/*"); $array_configs = array(); foreach ($nodeList as $_node) { $config = $xpath->getValueAttributNode($_node, "config"); $value = $xpath->getValueAttributNode($_node, "value"); $array_configs[$config] = $value; } if ($count = array_diff_key($array_configs, $fields)) { CAppUI::setMsg("Trop de données ('" . count($array_configs) . "') par rapport aux \n champs de l'objet ('" . count($fields) . "')", UI_MSG_ERROR); } else { foreach ($array_configs as $key => $value) { $format_config->{$key} = $value; if ($msg = $format_config->store()) { CAppUI::setMsg("Erreur lors de l'import de la configuration : " . $msg, UI_MSG_ERROR); } else { CAppUI::setMsg("Configuration correctement importée");
/** * fonction permettant de créér la structure principal des classes d'un XSD * * @return bool */ static function createClassFromXSD() { $pathXSD = "modules/cda/resources/POCD_MT000040.xsd"; $pathDir = "modules/cda/classes/classesCDA/classesGenerate/"; $dom = new CMbXMLDocument("UTF-8"); $dom->load($pathXSD); $xpath = new CMbXPath($dom); $xpath->registerNamespace("xs", "http://www.w3.org/2001/XMLSchema"); $nodeList = $xpath->query("//xs:complexType[@name] | //xs:simpleType[@name]"); foreach ($nodeList as $_node) { $tabVariable = array(); $tabProps = array(); /** @var DOMElement $_node */ $elements = $_node->getElementsByTagName("element"); $nodeAttributes = $_node->getElementsByTagName("attribute"); $nameNode = $xpath->queryAttributNode(".", $_node, "name"); $nameNode = str_replace(".", "_", $nameNode); list($tabVariable, $tabProps) = self::createPropsForElement($elements, $tabVariable, $tabProps); list($tabVariable, $tabProps) = self::createPropsForElement($nodeAttributes, $tabVariable, $tabProps); $smarty = new CSmartyDP(); $smarty->assign("name", $nameNode); $smarty->assign("variables", $tabVariable); $smarty->assign("props", $tabProps); $data = $smarty->fetch("defaultClassCDA.tpl"); file_put_contents($pathDir . "CCDA" . $nameNode . ".class.php", $data); } return true; }
/** * Lecture du fichier XML associé au rejet * * @param string $content_file contenu du fichier * @param bool $details enregistrement des informations * * @return null */ function readXML($content_file = null, $details = false) { if (!$content_file) { $file = $this->loadRefFile(); $file->updateFormFields(); $content_file = file_get_contents($file->_file_path); } $doc = new CMbXMLDocument("UTF-8"); $doc->loadXMLSafe($content_file); $xpath = new CMbXPath($doc); $xpath->registerNamespace("invoice", "http://www.forum-datenaustausch.ch/invoice"); $payload = $xpath->queryUniqueNode("//invoice:payload"); $timestamp = $xpath->getValueAttributNode($payload, "response_timestamp"); $this->date = strftime('%Y-%m-%d', $timestamp); $invoice = $xpath->queryUniqueNode("//invoice:invoice"); $this->num_facture = $xpath->getValueAttributNode($invoice, "request_id"); $this->_date_facture = $xpath->getValueAttributNode($invoice, "request_date"); $insurance = $xpath->queryUniqueNode("//invoice:insurance"); $ean_party = $xpath->getValueAttributNode($insurance, "ean_party"); $corr = new CCorrespondantPatient(); $corr->ean = $ean_party; $corr->loadMatchingObject(); $this->name_assurance = $corr->nom; $patient = $xpath->queryUniqueNode("//invoice:patient"); $this->_avs = $xpath->getValueAttributNode($patient, "ssn"); if ($company = $xpath->queryUniqueNode("//invoice:contact/invoice:company")) { $this->_contact[] = $xpath->queryTextNode("invoice:companyname", $company); $this->_contact[] = $xpath->queryTextNode("invoice:department", $company); $this->_contact[] = $xpath->queryTextNode("invoice:subaddressing", $company); $postal = $xpath->queryUniqueNode("invoice:postal", $company); $this->_contact[] = $xpath->queryTextNode("invoice:pobox", $postal); $this->_contact[] = $xpath->queryTextNode("invoice:street", $postal); $this->_contact[] = $xpath->queryTextNode("invoice:zip", $postal) . " " . $xpath->queryTextNode("invoice:city", $postal); $this->_contact[] = $xpath->queryTextNode("invoice:phone", $xpath->queryUniqueNode("invoice:telecom", $company)); $this->_contact[] = $xpath->queryTextNode("invoice:email", $xpath->queryUniqueNode("invoice:online", $company)); } if ($employee = $xpath->queryUniqueNode("//invoice:contact/invoice:employee")) { $this->_contact[] = $xpath->getValueAttributNode($employee, "salutation") . " " . $xpath->queryTextNode("invoice:givenname", $employee) . " " . $xpath->queryTextNode("invoice:familyname", $employee); $this->_contact[] = $xpath->queryTextNode("invoice:phone", $xpath->queryUniqueNode("invoice:telecom", $employee)); $this->_contact[] = $xpath->queryTextNode("invoice:email", $xpath->queryUniqueNode("invoice:online", $employee)); } if ($person = $xpath->queryUniqueNode("//invoice:contact/invoice:person")) { $this->_contact[] = $xpath->getValueAttributNode($person, "salutation") . " " . $xpath->queryTextNode("invoice:givenname", $person) . " " . $xpath->queryTextNode("invoice:familyname", $person); $this->_contact[] = $xpath->queryTextNode("invoice:phone", $xpath->queryUniqueNode("invoice:subaddressing", $person)); $postal = $xpath->queryUniqueNode("invoice:postal", $person); $this->_contact[] = $xpath->queryTextNode("invoice:pobox", $postal); $this->_contact[] = $xpath->queryTextNode("invoice:street", $postal); $this->_contact[] = $xpath->queryTextNode("invoice:zip", $postal) . " " . $xpath->queryTextNode("invoice:city", $postal); $this->_contact[] = $xpath->queryTextNode("invoice:phone", $xpath->queryUniqueNode("invoice:telecom", $person)); $this->_contact[] = $xpath->queryTextNode("invoice:email", $xpath->queryUniqueNode("invoice:online", $person)); } $this->_contact = array_filter($this->_contact); $pending = $xpath->query("//invoice:pending"); foreach ($pending as $_pending) { $explanation = $xpath->queryTextNode("invoice:explanation", $_pending); $this->motif_rejet = "{$explanation} \r\n"; $this->_commentaire = $explanation; $this->_status_in = $xpath->getValueAttributNode($_pending, "status_in"); $this->_status_out = $xpath->getValueAttributNode($_pending, "status_out"); $nb_message = 0; $messages = $xpath->query("//invoice:message"); foreach ($messages as $_message) { $code = $xpath->getValueAttributNode($_message, "code"); $text = $xpath->getValueAttributNode($_message, "text"); if (!$details) { $this->motif_rejet .= "{$code}: {$text} \r\n"; } else { $this->_erreurs[$nb_message]['code'] = $code; $this->_erreurs[$nb_message]['text'] = $text; } $nb_message++; } $this->_pending = 1; } $rejected = $xpath->query("//invoice:rejected"); foreach ($rejected as $_rejected) { $explanation = $xpath->queryTextNode("invoice:explanation", $_rejected); $this->motif_rejet = "{$explanation} \r\n"; $this->_commentaire = $explanation; $this->_status_in = $xpath->getValueAttributNode($_rejected, "status_in"); $this->_status_out = $xpath->getValueAttributNode($_rejected, "status_out"); $nb_message = 0; $messages = $xpath->query("//invoice:error"); foreach ($messages as $_message) { $code = $xpath->getValueAttributNode($_message, "code"); $text = $xpath->getValueAttributNode($_message, "text"); if (!$details) { $this->motif_rejet .= "{$code}: {$text} \r\n"; } else { $this->_erreurs[$nb_message]['code'] = $code; $this->_erreurs[$nb_message]['text'] = $text; } if ($error_value = $xpath->getValueAttributNode($_message, "error_value")) { $valid_value = $xpath->getValueAttributNode($_message, "valid_value"); if (!$details) { $this->motif_rejet .= "({$error_value}/{$valid_value})"; } else { $this->_erreurs[$nb_message]['error_value'] = $error_value; $this->_erreurs[$nb_message]['valid_value'] = $valid_value; $this->_erreurs[$nb_message]['record_id'] = $xpath->getValueAttributNode($_message, "record_id"); } } $nb_message++; } } if (!$details) { if ($msg = $this->store()) { mbTrace($msg); } } }
function query($query) { $xpath = new CMbXPath($this->ownerDocument); return $xpath->query($query, $this); }
$dom = new CMbXMLDocument(); if (!$dom->load($file['tmp_name'])) { CAppUI::redirect('m=passwordKeeper&a=vw_import_keeper&dialog=1'); } $xpath = new CMbXPath($dom); $keeperNode = $xpath->queryUniqueNode("/keeper"); $keeperName = $keeperNode->getAttribute("name"); if ($keeperNode->nodeName != "keeper") { CAppUI::redirect('m=passwordKeeper&a=vw_import_keeper&dialog=1'); } $keeper = new CPasswordKeeper(); $keeper->keeper_name = $keeperName; $keeper->_passphrase = $passphrase; $keeper->user_id = $user->_id; $keeper->store(); $categoryNodes = $xpath->query("//category"); foreach ($categoryNodes as $_categoryNode) { $category = new CPasswordCategory(); $category->category_name = $_categoryNode->getAttribute("name"); $category->password_keeper_id = $keeper->_id; $category->store(); $passwordNodes = $xpath->query(".//password", $_categoryNode); foreach ($passwordNodes as $_passwordNode) { $password = new CPasswordEntry(); $desc = $xpath->queryUniqueNode("description", $_passwordNode); $password->password_description = $desc->nodeValue; $crypted = $xpath->queryUniqueNode("crypted", $_passwordNode); $password->password = $crypted->nodeValue; $last_change = $xpath->queryUniqueNode("last_change", $_passwordNode); $password->password_last_change = $last_change->nodeValue; $iv = $xpath->queryUniqueNode("iv", $_passwordNode);