本文整理汇总了PHP中CMbString::convertHTMLToXMLEntities方法的典型用法代码示例。如果您正苦于以下问题:PHP CMbString::convertHTMLToXMLEntities方法的具体用法?PHP CMbString::convertHTMLToXMLEntities怎么用?PHP CMbString::convertHTMLToXMLEntities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMbString
的用法示例。
在下文中一共展示了CMbString::convertHTMLToXMLEntities方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sanitizeHTML
/**
* Nettoie du code HTML
*
* @param string $html the html string
*
* @return string the cleaned html
*/
static function sanitizeHTML($html)
{
//check if html is present
if (!preg_match("/<html/", $html)) {
$html = '<html><head><title>E-mail</title></head><body>' . $html . '</body></html>';
}
//=>XML
$html = CMbString::convertHTMLToXMLEntities($html);
//load & repair dom
$document = new CMbXMLDocument();
$document->preserveWhiteSpace = false;
@$document->loadHTML($html);
//remove scripts tag
$xpath = new DOMXpath($document);
$filter = array("//script", "//meta", "//applet", "//iframe");
//some dangerous
foreach ($filter as $_filter) {
$elements = $xpath->query($_filter);
foreach ($elements as $_element) {
$_element->parentNode->removeChild($_element);
}
}
$html = $document->saveHTML();
//Cleanup after save
$html = preg_replace("/<!DOCTYPE(.*?)>/", '', $html);
$html = preg_replace("/\\/\\/>/mu", "/>", $html);
$html = preg_replace("/nowrap/", '', $html);
$html = preg_replace("/<[b|h]r([^>]*)>/", "<br \$1/>", $html);
$html = preg_replace("/<img([^>]+)>/", "<img\$1/>", $html);
return $html;
}
示例2: searchSpan
/** @var $_node DOMElement */
if ($_node->nodeName === "span" && ($_node->getAttribute("class") === "name" || $_node->getAttribute("class") === "field") && $_node->childNodes->length != 1 && $_node->firstChild && ($_node->firstChild->nodeType != XML_TEXT_NODE || !preg_match("/\\[.+\\]/", $_node->nodeValue))) {
return true;
}
if ($_node->childNodes) {
searchSpan($_node);
}
}
return false;
}
$compte_rendu = new CCompteRendu();
$where = array();
$where["object_id"] = "IS NULL";
$compte_rendus = $compte_rendu->loadList($where, null, "350000");
/** @var $compte_rendus CCompteRendu[] */
$list = array();
/** @var DOMDocument $xml */
$xml = new DOMDocument('1.0', 'iso-8859-1');
foreach ($compte_rendus as $_compte_rendu) {
mbLog($_compte_rendu->_id);
$_compte_rendu->loadContent();
$content = CMbString::convertHTMLToXMLEntities($_compte_rendu->_source);
$content = utf8_encode(CHtmlToPDF::cleanWord($content));
$xml->loadXML("<div>" . $content . "</div>");
if (searchSpan($xml->documentElement)) {
$list[] = $_compte_rendu;
}
}
$smarty = new CSmartyDP();
$smarty->assign("list", $list);
$smarty->display("inc_update_class_fields.tpl");
示例3: restoreId
/**
* Patch the disappearance of an html attribute
*
* @param string $source source to control
*
* @return string
*/
static function restoreId($source)
{
if (strpos($source, '<div id="body"') === false && strpos($source, "<div id='body'") === false && strpos($source, "@media dompdf") !== false) {
$xml = new DOMDocument('1.0', 'iso-8859-1');
$xml->loadXML("<div>" . utf8_encode(CMbString::convertHTMLToXMLEntities($source)) . "</div>");
$xpath = new DOMXpath($xml);
/** @var DOMElement $last_div */
$last_div = null;
// Test header id
$elements = $xpath->query("//div[@id='header']");
if ($elements->length) {
$last_div = $elements->item(0);
$last_div = $last_div->nextSibling;
while ($last_div && $last_div->nodeType != 1) {
$last_div = $last_div->nextSibling;
}
if ($last_div->getAttribute("id") == "footer") {
$last_div = $last_div->nextSibling;
}
}
// Or footer id
if (!$last_div) {
$last_div = $xpath->query("//div[@id='footer']")->item(0);
$last_div = $last_div->nextSibling;
while ($last_div && $last_div->nodeType != 1) {
$last_div = $last_div->nextSibling;
}
}
$div_body = $xml->createElement("div");
$id_body = $xml->createAttribute("id");
$id_value = $xml->createTextNode("body");
$id_body->appendChild($id_value);
$div_body->appendChild($id_body);
$div_body = $last_div->parentNode->insertBefore($div_body, $last_div);
while ($elt_to_move = $xpath->query("//div[@id='body']")->item(0)->nextSibling) {
$div_body->appendChild($elt_to_move->parentNode->removeChild($elt_to_move));
}
// Substring to remove the header of the xml output, and div surrounded
$source = substr($xml->saveXML(), 27, -7);
}
return $source;
}
示例4: fixBlockElements
/**
* Correction de problèmes de dom
*
* @param string $str source html
*
* @return string
*/
function fixBlockElements($str)
{
$xml = new DOMDocument('1.0', 'iso-8859-1');
$str = CMbString::convertHTMLToXMLEntities($str);
$str = CHtmlToPDF::cleanWord($str);
// Suppression des caractères de contrôle
$from = array(chr(3), chr(7));
$to = array("", "");
$str = str_replace($from, $to, $str);
$xml->loadXML(utf8_encode($str));
$html =& $xml->getElementsByTagName("body")->item(0);
if (is_null($html)) {
$html =& $xml->firstChild;
}
if (is_null($html)) {
CAppUI::stepAjax("CCompteRendu-empty-doc");
CApp::rip();
}
$xpath = new DOMXpath($xml);
$elements = $xpath->query("*/div[@id='body']");
if (!is_null($elements)) {
foreach ($elements as $_element) {
CHtmlToPDF::removeAlign($_element);
}
}
// Solution temporaire pour les problèmes de mise en page avec domPDF
while ($elements = $xpath->query("//span[@class='field']")) {
if ($elements->length == 0) {
break;
}
foreach ($elements as $_element) {
foreach ($_element->childNodes as $child) {
/** @var DOMElement $child */
$_element->parentNode->insertBefore($child->cloneNode(true), $_element);
}
$_element->parentNode->removeChild($_element);
}
}
$this->recursiveRemove($html);
$this->recursiveRemoveNestedFont($html);
$this->resizeTable($html);
// Suppression des sauts de pages dans l'entête et le pied de page
$elements = $xpath->query("//div[@id='header']//hr[@class='pagebreak']");
if (!is_null($elements)) {
foreach ($elements as $_element) {
$_element->parentNode->removeChild($_element);
}
}
$elements = $xpath->query("//div[@id='footer']//hr[@class='pagebreak']");
if (!is_null($elements)) {
foreach ($elements as $_element) {
$_element->parentNode->removeChild($_element);
}
}
$str = $xml->saveHTML();
$str = preg_replace("/<br>/", "<br/>", $str);
return $str;
}
示例5: addIntervention
function addIntervention($elParent, COperation $operation, $referent = null, $light = false)
{
$identifiant = $this->addElement($elParent, "identifiant");
$this->addElement($identifiant, "emetteur", $operation->_id);
$last_idex = $operation->_ref_last_id400;
if (isset($last_idex->_id)) {
$this->addElement($identifiant, "recepteur", $last_idex->id400);
}
$sejour = $operation->loadRefSejour();
if (!$operation->plageop_id) {
$operation->completeField("date");
}
// Calcul du début de l'intervention
$mbOpDate = CValue::first($operation->_ref_plageop->date, $operation->date);
$time_operation = $operation->time_operation == "00:00:00" ? null : $operation->time_operation;
$mbOpHeureDebut = CValue::first($operation->debut_op, $operation->entree_salle, $time_operation, $operation->horaire_voulu, $operation->_ref_plageop->debut);
$mbOpDebut = CMbRange::forceInside($sejour->entree, $sejour->sortie, "{$mbOpDate} {$mbOpHeureDebut}");
// Calcul de la fin de l'intervention
$mbOpHeureFin = CValue::first($operation->fin_op, $operation->sortie_salle, CMbDT::addTime($operation->temp_operation, CMbDT::time($mbOpDebut)));
$mbOpFin = CMbRange::forceInside($sejour->entree, $sejour->sortie, "{$mbOpDate} {$mbOpHeureFin}");
$debut = $this->addElement($elParent, "debut");
$this->addElement($debut, "date", CMbDT::date($mbOpDebut));
$this->addElement($debut, "heure", CMbDT::time($mbOpDebut));
$fin = $this->addElement($elParent, "fin");
$this->addElement($fin, "date", CMbDT::date($mbOpFin));
$this->addElement($fin, "heure", CMbDT::time($mbOpFin));
if ($light) {
// Ajout des participants
$mbParticipants = array();
foreach ($operation->_ref_actes_ccam as $acte_ccam) {
$acte_ccam->loadRefExecutant();
$mbParticipant = $acte_ccam->_ref_executant;
$mbParticipants[$mbParticipant->user_id] = $mbParticipant;
}
$participants = $this->addElement($elParent, "participants");
foreach ($mbParticipants as $mbParticipant) {
$participant = $this->addElement($participants, "participant");
$medecin = $this->addElement($participant, "medecin");
$this->addProfessionnelSante($medecin, $mbParticipant);
}
// Libellé de l'opération
$this->addTexte($elParent, "libelle", $operation->libelle, 80);
} else {
$this->addUniteFonctionnelle($elParent, $operation);
// Uniquement le responsable de l’'intervention
$participants = $this->addElement($elParent, "participants");
$participant = $this->addElement($participants, "participant");
$medecin = $this->addElement($participant, "medecin");
$this->addProfessionnelSante($medecin, $operation->loadRefChir());
// Libellé de l'opération
$this->addTexte($elParent, "libelle", $operation->libelle, 4000);
// Remarques sur l'opération
$this->addTexte($elParent, "commentaire", CMbString::convertHTMLToXMLEntities("{$operation->materiel} - {$operation->rques}"), 4000);
// Conventionnée ?
$this->addElement($elParent, "convention", $operation->conventionne ? 1 : 0);
// TypeAnesthésie : nomemclature externe (idex)
if ($operation->type_anesth) {
$tag_hprimxml = $this->_ref_receiver->_tag_hprimxml;
$idexTypeAnesth = CIdSante400::getMatch("CTypeAnesth", $tag_hprimxml, null, $operation->type_anesth);
$this->addElement($elParent, "typeAnesthesie", $idexTypeAnesth->id400);
}
// Indicateurs
$indicateurs = $this->addElement($elParent, "indicateurs");
$dossier_medical = new CDossierMedical();
$dossier_medical->object_class = "CPatient";
$dossier_medical->object_id = $operation->loadRefPatient()->_id;
$dossier_medical->loadMatchingObject();
$antecedents = $dossier_medical->loadRefsAntecedents();
foreach ($antecedents as $_antecedent) {
$rques = CMbString::htmlspecialchars($_antecedent->rques);
$rques = CMbString::convertHTMLToXMLEntities($rques);
$this->addCodeLibelle($indicateurs, "indicateur", $_antecedent->_id, $rques);
}
// Extemporané
if ($operation->exam_extempo) {
$this->addCodeLibelle($indicateurs, "indicateur", "EXT", "Extemporané");
}
// Recours / Durée USCPO
$this->addElement($elParent, "recoursUscpo", $operation->duree_uscpo ? 1 : 0);
$this->addElement($elParent, "dureeUscpo", $operation->duree_uscpo ? $operation->duree_uscpo : null);
// Côté (droit|gauche|bilatéral|total|inconnu)
// D - Droit
// G - Gauche
// B - Bilatéral
// T - Total
// I - Inconnu
$cote = array("droit" => "D", "gauche" => "G", "bilatéral" => "B", "total" => "T", "inconnu" => "I", "haut" => "HT", "bas" => "BS");
$this->addCodeLibelle($elParent, "cote", $cote[$operation->cote], CMbString::capitalize($operation->cote));
}
}