/** * @see parent::getHPrimXMLEvenements */ static function getHPrimXMLEvenements($messageServeurActivitePmsi) { $hprimxmldoc = new CMbXMLDocument(); $hprimxmldoc->loadXML($messageServeurActivitePmsi); $xpath = new CMbXPath($hprimxmldoc); $event = $xpath->queryUniqueNode("/*/*[2]"); $dom_evt = new CHPrimXMLEvenementsServeurActivitePmsi(); if ($nodeName = $event->nodeName) { $dom_evt = new CHPrimXMLEventServeurActivitePmsi::$evenements[$nodeName](); } $dom_evt->loadXML($messageServeurActivitePmsi); return $dom_evt; }
$user_id = $owner->_id; break; case "CFunctions": $function_id = $owner->_id; break; case "CGroups": $group_id = $owner->_id; } $file = $_FILES['datafile']; if (strtolower(pathinfo($file['name'], PATHINFO_EXTENSION) !== "xml")) { CAppUI::stepAjax("Fichier non reconnu", UI_MSG_ERROR); CApp::rip(); } $doc = file_get_contents($file['tmp_name']); $xml = new CMbXMLDocument(null); $xml->loadXML($doc); $root = $xml->firstChild; if ($root->nodeName == "modeles") { $root = $root->childNodes; } else { $root = array($xml->firstChild); } $modeles_ids_xml = array(); $components = array("header_id", "footer_id", "preface_id", "ending_id"); foreach ($root as $_modele) { $modele = new CCompteRendu(); $modele->user_id = $user_id; $modele->function_id = $function_id; $modele->group_id = $group_id; // Mappings des champs principaux foreach ($_modele->childNodes as $_node) {
/** * 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>"); } } } }
CAppUI::stepAjax("Analyses Importées: " . $compteur["analyses"] . ", Chapitres Importés: " . $compteur["chapitres"] . ", Sous chapitres Importés: " . $compteur["sousChapitre"], UI_MSG_OK); } // Check import configuration $clCconfig = CAppUI::conf("{$m} CCatalogueLabo"); if (null == ($remote_name = $clCconfig["remote_name"])) { CAppUI::stepAjax("Remote name not configured", UI_MSG_ERROR); } if (null == ($remote_url = $clCconfig["remote_url"])) { CAppUI::stepAjax("Remote URL not configured", UI_MSG_ERROR); } if (false === ($content = file_get_contents($remote_url))) { CAppUI::stepAjax("Couldn't connect to remote url", UI_MSG_ERROR); } // Check imported catalogue document $doc = new CMbXMLDocument(); if (!$doc->loadXML($content)) { CAppUI::stepAjax("Document is not well formed", UI_MSG_ERROR); } $tmpPath = "tmp/dPlabo/import_catalogue.xml"; CMbPath::forceDir(dirname($tmpPath)); $doc->save($tmpPath); $doc->load($tmpPath); if (!$doc->schemaValidate("modules/{$m}/remote/catalogue.xsd")) { CAppUI::stepAjax("Document is not valid", UI_MSG_ERROR); } CAppUI::stepAjax("Document is valid", UI_MSG_OK); // Check access to idSante400 $canSante400 = CModule::getCanDo("dPsante400"); if (!$canSante400->edit) { CAppUI::stepAjax("No permission for module 'dPsante400' or module not installed", UI_MSG_ERROR); }
* @version SVN: $Id:$ * @link http://www.mediboard.org */ CCanDo::checkAdmin(); $actor_guid = CValue::request("actor_guid"); $format_config_guid = CValue::request("format_config_guid"); $file = isset($_FILES['import']) ? $_FILES['import'] : null; if (!empty($file) && ($contents = file_get_contents($file['tmp_name']))) { $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)) {
$where = array(); CApp::setTimeLimit(300); $loops = CValue::get("loops", 100); $trunk = CValue::get("trunk", 100); mbTrace($loops, "loops"); mbTrace($trunk, "trunk"); $problems = array(); for ($loop = 0; $loop < $loops; $loop++) { $starting = $loop * $trunk; $ds = $doc->_spec->ds; $query = "SELECT `compte_rendu`.`compte_rendu_id`, `contenthtml`.`content` \r\n FROM compte_rendu, contenthtml\r\n WHERE compte_rendu.content_id = contenthtml.content_id\r\n ORDER BY compte_rendu_id DESC\r\n LIMIT {$starting}, {$trunk}"; $docs = $ds->loadHashList($query); foreach ($docs as $doc_id => $doc_source) { // Root node surrounding $source = utf8_encode("<div>{$doc_source}</div>"); // Entity purge $source = preg_replace("/&\\w+;/i", "", $source); // Escape warnings, returns false if really invalid $doc = new CMbXMLDocument(); if (false == ($validation = $doc->loadXML($source))) { $doc = new CCompteRendu(); $doc->load($doc_id); $problems[$doc_id] = $doc; } } } mbTrace(count($problems), "Problems count"); // Création du template $smarty = new CSmartyDP(); $smarty->assign("problems", $problems); $smarty->display("check_document.tpl");
$root = $doc->createElement("modeles"); $doc->appendChild($root); $where = array("compte_rendu_id" => CSQLDataSource::prepareIn($modeles_ids)); // Récupération des header_id, footer_id, preface_id et ending_id $ds = CSQLDataSource::get("std"); $request = new CRequest(); $request->addTable("compte_rendu"); $request->addWhere($where); $components_ids = array(); foreach (array("header_id", "footer_id", "preface_id", "ending_id") as $_component) { $request->select = array(); $request->addSelect($_component); $components_ids = array_merge($components_ids, $ds->loadColumn($request->makeSelect())); } $modeles_ids = array_unique(array_merge($components_ids, $modeles_ids)); CMbArray::removeValue("", $modeles_ids); foreach ($modeles_ids as $_modele_id) { $modele = CApp::fetch("dPcompteRendu", "ajax_export_modele", array("modele_id" => $_modele_id)); $doc_modele = new CMbXMLDocument(null); @$doc_modele->loadXML($modele); // Importation du noeud CPrescription $modele_importe = $doc->importNode($doc_modele->firstChild, true); // Ajout de ce noeud comme fils de protocoles $doc->documentElement->appendChild($modele_importe); } $filename = 'Modèles ' . ($owner ? " - {$owner}" : '') . ($object_class ? " - " . CAppUI::tr($object_class) : '') . '.xml'; $content = $doc->saveXML(); header('Content-Type: text/xml'); header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Length: ' . strlen($content) . ';'); echo $content;
/** * @see parent::isWellFormed() */ function isWellFormed($data) { $dom = new CMbXMLDocument(); if ($dom->loadXML($data, LIBXML_NOWARNING | LIBXML_NOERROR) !== false) { return $dom; } return null; }