本文整理汇总了PHP中xpath_eval函数的典型用法代码示例。如果您正苦于以下问题:PHP xpath_eval函数的具体用法?PHP xpath_eval怎么用?PHP xpath_eval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xpath_eval函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCategories
function getCategories($root)
{
$xpath = xpath_new_context($root);
$listNode = xpath_eval($xpath, "UL");
if (sizeof($listNode->nodeset) == 0) {
$xpath = xpath_new_context($root);
$nodes = xpath_eval($xpath, "LI");
} else {
$xpath = xpath_new_context($listNode->nodeset[0]);
$nodes = xpath_eval($xpath, "LI");
}
return $nodes->nodeset;
}
示例2: exportRekursiv
/**
* export lm_data-table to xml-structure
*
* @param integer obj_id
* @param integer depth
* @param integer left left border of nested-set-structure
* @param integer right right border of nested-set-structure
* @access public
* @return string xml
*/
function exportRekursiv($obj_id, $depth, $left, $right)
{
global $ilDB;
// Jetzt alle lm_data anhand der obj_id auslesen.
$query = "SELECT *\n FROM lm_tree, lm_data\n WHERE lm_tree.lm_id = " . $ilDB->quote($obj_id, "integer") . " \n AND lm_tree.child = lm_data.obj_id \n AND ( lm_data.type = 'st' OR lm_data.type = 'pg' )\n AND lm_tree.depth = " . $ilDB->quote($depth, "integer") . "\n AND lm_tree.lft > " . $ilDB->quote($left, "integer") . " and lm_tree.rgt < " . $ilDB->quote($right, "integer") . "\n ORDER BY lm_tree.lft";
$result = $ilDB->query($query);
while (is_array($row = $ilDB->fetchAssoc($result))) {
if ($row["type"] == "st") {
$xml .= "<StructureObject>";
$nested = new ilNestedSetXML();
$xml .= $nested->export($row["obj_id"], "st");
$xml .= "\n";
$xml .= $this->exportRekursiv($obj_id, $depth + 1, $row["lft"], $row["rgt"]);
$xml .= "</StructureObject>";
}
if ($row["type"] == "pg") {
$query = "SELECT * FROM page_object WHERE page_id= " . $ilDB->quote($row["obj_id"], "integer");
$result2 = $this->ilias->db->query($query);
$row2 = $result2->fetchRow(DB_FETCHMODE_ASSOC);
$PO = $row2["content"] . "\n";
if (stristr($PO, "MediaObject")) {
$dom = domxml_open_mem($PO);
$xpc = xpath_new_context($dom);
$path = "//MediaObject/MediaAlias";
$res =& xpath_eval($xpc, $path);
for ($i = 0; $i < count($res->nodeset); $i++) {
$id_arr = explode("_", $res->nodeset[$i]->get_attribute("OriginId"));
$mob_id = $id_arr[count($id_arr) - 1];
$this->mob_ids[$mob_id] = true;
}
}
$nested = new ilNestedSetXML();
$mdxml = $nested->export($row["obj_id"], "pg");
$PO = str_replace("<PageObject>", "<PageObject>\n{$mdxml}\n", $PO);
$xml .= $PO;
}
}
return $xml;
}
示例3: importHtml
function importHtml($lng, $htmlTable)
{
$dummy = ilUtil::stripSlashes($htmlTable, false);
//echo htmlentities($dummy);
$dom = @domxml_open_mem($dummy, DOMXML_LOAD_PARSING, $error);
if ($dom) {
$xpc = @xpath_new_context($dom);
// extract first table object
$path = "//table[1] | //Table[1]";
$res = @xpath_eval($xpc, $path);
if (count($res->nodeset) == 0) {
$error = "Could not find a table root node";
}
if (empty($error)) {
for ($i = 0; $i < count($res->nodeset); $i++) {
$node = $res->nodeset[$i];
$this->importTableAttributes($node);
if ($node->has_child_nodes()) {
foreach ($node->child_nodes() as $n) {
if ($n->node_type() == XML_ELEMENT_NODE && strcasecmp($n->node_name(), "tr") == 0) {
$this->importRow($lng, $n);
}
}
}
}
}
$dom->free();
}
if (is_array($error)) {
$errmsg = "";
foreach ($error as $errorline) {
# Loop through all errors
$errmsg .= "[" . $errorline['line'] . ", " . $errorline['col'] . "]: " . $errorline['errormessage'] . " at Node '" . $errorline['nodename'] . "'<br />";
}
} else {
$errmsg = $error;
}
if (empty($errmsg)) {
return true;
}
$_SESSION["message"] = $errmsg;
return false;
}
示例4: xpath_eval
function xpath_eval($eval_str)
{
return xpath_eval($this, $eval_str);
}
示例5: wms_layer4html
function wms_layer4html($layer)
{
$estilos = wms_estilos($layer);
if (count($estilos) > 0) {
$ctxl = xpath_new_context($layer);
$xp_namel = xpath_eval($ctxl, "/Name");
if (wms_xpnode2content($xp_namel) == "") {
$xp_namel = xpath_eval($ctxl, "/name");
}
$txt_namel = wms_xpnode2content($xp_namel);
$html .= wms_layer3html($layer);
foreach ($estilos as $estilo) {
$html .= wms_layer2html($estilo, "estilo", $txt_namel);
}
} else {
$html .= wms_layer2html($layer, "tema", "");
}
return $html;
}
示例6: generatePreview
private function generatePreview()
{
$xml = $this->getXMLContent();
$dom = @domxml_open_mem($xml, DOMXML_LOAD_PARSING, $error);
$xpc = xpath_new_context($dom);
$path = "////PlaceHolder";
$res =& xpath_eval($xpc, $path);
foreach ($res->nodeset as $item) {
$height = $item->get_attribute("Height");
$height = eregi_replace("px", "", $height);
$height = $height / 10;
$item->set_attribute("Height", $height . "px");
}
$xsl = file_get_contents($this->getXSLPath());
$xml = $dom->dump_mem(0, "UTF-8");
$args = array('/_xml' => $xml, '/_xsl' => $xsl);
$xh = xslt_create();
$output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
xslt_error($xh);
xslt_free($xh);
return $output;
}
示例7: getLayoutLinkTargets
function getLayoutLinkTargets()
{
if (!is_object($this->layout_doc)) {
return array();
}
$xpc = xpath_new_context($this->layout_doc);
$path = "/ilLayout/ilLinkTargets/LinkTarget";
$res = xpath_eval($xpc, $path);
$targets = array();
for ($i = 0; $i < count($res->nodeset); $i++) {
$type = $res->nodeset[$i]->get_attribute("Type");
$frame = $res->nodeset[$i]->get_attribute("Frame");
$onclick = $res->nodeset[$i]->get_attribute("OnClick");
$targets[$type] = array("Type" => $type, "Frame" => $frame, "OnClick" => $onclick);
}
return $targets;
}
示例8: _makeXSLTInclude
function _makeXSLTInclude(&$main_xsl)
{
$xpath = xpath_new_context($main_xsl);
$res = xpath_eval($xpath, "//include");
$num = sizeof($res->nodeset);
$needReCall = false;
for ($i = 0; $i < $num; $i++) {
$type = $res->nodeset[$i]->get_attribute("type");
if ($type != 'subtemplate') {
/*
$dom = new DomDocument("1.0");
$node = $dom->createElement("xsl:call-template", "");
/*
= new DomElement( "xsl:call-template", "",
"http://www.w3.org/1999/XSL/Transform");
// $dom->appendChild($node);
$node->setAttribute( "name", "InsertBlock" );
$param = $dom->createElement("xsl:with-param");
$node->appendChild($param);
*/
// ñîçäàåì ýëåìåíò
// $dom = domxml_new_doc("1.0");
$dom = $this->_xslt;
$node = $this->_xslt->create_element("xsl:call-template", "");
$node->set_attribute("name", "InsertBlock");
//
// $param = $dom->createElement("xsl:with-param", "");
// $param = $node->appendChild($param);
$param = $node->new_child("xsl:with-param");
if (empty($type) || $type == 'default') {
$param->set_content($res->nodeset[$i]->get_attribute("object"));
} else {
if ($type == 'condition') {
$childs = $res->nodeset[$i]->child_nodes();
//print_r( $childs );
if (is_array($childs)) {
$cnum = sizeof($childs);
for ($j = 0; $j < $cnum; $j++) {
$clone = $childs[$j]->clone_node(true);
//$clone->set_namespace( $childs[$j]prefix();
$param->append_child($clone);
}
//foreach ( $childs as $child ) {
//}
}
}
}
$param->set_attribute("name", "id");
$res->nodeset[$i]->replace_node($node);
} else {
$name = $res->nodeset[$i]->get_attribute("name");
if (isset($this->_templates['sub']) && array_key_exists($name, $this->_templates['sub'])) {
$nodes = $this->_templates['sub'][$name]->getText();
if (is_array($nodes)) {
$nnum = sizeof($nodes);
for ($j = 0; $j < $nnum; $j++) {
//print_r( $nodes[$j] );
// TODO: analyze it nafig
// echo $res->nodeset[$i]->get_content();
//print_r($res->nodeset[$i]);
/*
echo $j."of $nnum vs $i<hr/>";
print_r($nodes[$j]);
echo "<hr/>";
print_r($res->nodeset[$i]);
echo "<hr/>";
print_r($res->nodeset[$i]);
echo "<hr/>";
*/
// echo $res->nodeset[$i]->get_content();
// $res->nodeset[$i]->insert_before( $nodes[$j], $res->nodeset[$i]);
$res->nodeset[$i]->append_sibling($nodes[$j]);
// if (in_array($))
/*
if ($res->nodeset[$i]->get_content() != "")
$res->nodeset[$i]->insert_before( $nodes[$i], $res->nodeset[$i] );
else
$res->nodeset[$i]->append_child( $nodes[$j], $res->nodeset[$i] );
*/
/*
if ( $nodes[$j]->type == 1 ) {
$this->_makeXSLTInclude( $nodes[$j] );
}*/
}
}
}
$p = $res->nodeset[$i]->parent_node();
//print_r( $p );
$p->remove_child($res->nodeset[$i]);
$needReCall = true;
}
}
/**/
if ($needReCall) {
$this->_makeXSLTInclude($main_xsl);
}
/**/
}
示例9: getInitialOpenedContent
/**
* Get initial opened content
*
* @param
*/
function getInitialOpenedContent()
{
$this->buildDom();
$xpc = xpath_new_context($this->dom);
$path = "//PageObject/InitOpenedContent";
$res = xpath_eval($xpc, $path);
$il_node = null;
if (count($res->nodeset) > 0) {
$init_node = $res->nodeset[0];
$childs = $init_node->child_nodes();
for ($i = 0; $i < count($childs); $i++) {
if ($childs[$i]->node_name() == "IntLink") {
$il_node = $childs[$i];
}
}
}
if (!is_null($il_node)) {
$id = $il_node->get_attribute("Target");
$link_type = $il_node->get_attribute("Type");
$target = $il_node->get_attribute("TargetFrame");
switch ($link_type) {
case "MediaObject":
$type = "media";
break;
case "PageObject":
$type = "page";
break;
case "GlossaryItem":
$type = "term";
break;
}
include_once "./Services/Link/classes/class.ilInternalLink.php";
$id = ilInternalLink::_extractObjIdOfTarget($id);
return array("id" => $id, "type" => $type, "target" => $target);
}
return array();
}
示例10: deleteAllMapAreas
/**
* Delete all map areas
*/
function deleteAllMapAreas()
{
$xpc = xpath_new_context($this->dom);
$path = "//PageContent[@HierId = '" . $this->hier_id . "']/" . $this->parent_node_name . "/MediaAliasItem[@Purpose='" . $this->purpose . "']/MapArea";
$res =& xpath_eval($xpc, $path);
for ($i = 0; $i < count($res->nodeset); $i++) {
$res->nodeset[$i]->unlink_node($res->nodeset[$i]);
}
}
示例11: modifyPageContentPostXsl
/**
* Modify page content after xsl
*
* @param string $a_output
* @return string
*/
function modifyPageContentPostXsl($a_output, $outputmode = "presentation")
{
$dom = $this->getPage()->getDom();
$xpc = xpath_new_context($dom);
$path = "//Paragraph";
//"[@Characteristic = 'Code']";
$res =& xpath_eval($xpc, $path);
for ($i = 0; $i < count($res->nodeset); $i++) {
$context_node = $res->nodeset[$i];
$char = $context_node->get_attribute('Characteristic');
if ($char != "Code") {
continue;
}
$n = $context_node->parent_node();
$char = $context_node->get_attribute('Characteristic');
$subchar = $context_node->get_attribute('SubCharacteristic');
$showlinenumbers = $context_node->get_attribute('ShowLineNumbers');
$downloadtitle = $context_node->get_attribute('DownloadTitle');
$autoindent = $context_node->get_attribute('AutoIndent');
$content = "";
// get XML Content
$childs = $context_node->child_nodes();
for ($j = 0; $j < count($childs); $j++) {
$content .= $dom->dump_node($childs[$j]);
}
while ($context_node->has_child_nodes()) {
$node_del = $context_node->first_child();
$context_node->remove_child($node_del);
}
$content = str_replace("<br />", "<br/>", utf8_decode($content));
$content = str_replace("<br/>", "\n", $content);
$rownums = count(split("\n", $content));
$plain_content = html_entity_decode($content);
$plain_content = preg_replace("/\\&#x([1-9a-f]{2});?/ise", "chr (base_convert (\\1, 16, 10))", $plain_content);
$plain_content = preg_replace("/\\&#(\\d+);?/ise", "chr (\\1)", $plain_content);
$content = utf8_encode($this->highlightText($plain_content, $subchar, $autoindent));
$content = str_replace("&lt;", "<", $content);
$content = str_replace("&gt;", ">", $content);
// $content = str_replace("&", "&", $content);
//var_dump($content);
$rows = "<tr valign=\"top\">";
$rownumbers = "";
$linenumbers = "";
//if we have to show line numbers
if (strcmp($showlinenumbers, "y") == 0) {
$linenumbers = "<td nowrap=\"nowrap\" class=\"ilc_LineNumbers\" >";
$linenumbers .= "<pre class=\"ilc_Code\">";
for ($j = 0; $j < $rownums; $j++) {
$indentno = strlen($rownums) - strlen($j + 1) + 2;
$rownumeration = $j + 1;
$linenumbers .= "<span class=\"ilc_LineNumber\">{$rownumeration}</span>";
if ($j < $rownums - 1) {
$linenumbers .= "\n";
}
}
$linenumbers .= "</pre>";
$linenumbers .= "</td>";
}
$rows .= $linenumbers . "<td class=\"ilc_Sourcecode\"><pre class=\"ilc_Code\">" . $content . "</pre></td>";
$rows .= "</tr>";
// fix for ie explorer which is not able to produce empty line feeds with <br /><br />;
// workaround: add a space after each br.
$newcontent = str_replace("\n", "<br/>", $rows);
// fix for IE
$newcontent = str_replace("<br/><br/>", "<br/> <br/>", $newcontent);
// falls drei hintereinander...
$newcontent = str_replace("<br/><br/>", "<br/> <br/>", $newcontent);
// workaround for preventing template engine
// from hiding paragraph text that is enclosed
// in curly brackets (e.g. "{a}", see ilLMEditorGUI::executeCommand())
$newcontent = str_replace("{", "{", $newcontent);
$newcontent = str_replace("}", "}", $newcontent);
//echo htmlentities($newcontent);
$a_output = str_replace("[[[[[Code;" . ($i + 1) . "]]]]]", $newcontent, $a_output);
if ($outputmode != "presentation" && is_object($this->getPage()->getOfflineHandler()) && trim($downloadtitle) != "") {
// call code handler for offline versions
$this->getPage()->getOfflineHandler()->handleCodeParagraph($this->getPage()->getId(), $i + 1, $downloadtitle, $plain_content);
}
}
return $a_output;
}
示例12: performAutomaticModifications
/**
* Perform automatic modifications (may be overwritten by sub classes)
*/
function performAutomaticModifications()
{
if ($this->getGlossaryId() > 0) {
// we fix glossary links here
$this->buildDom();
$xpc = xpath_new_context($this->dom);
$path = "//IntLink[@Type='GlossaryItem']";
$res =& xpath_eval($xpc, $path);
for ($i = 0; $i < count($res->nodeset); $i++) {
$target = $res->nodeset[$i]->get_attribute("Target");
//echo "<br>".$target;
$tarr = explode("_", $target);
$term_id = $tarr[count($tarr) - 1];
if (is_int(strpos($target, "__")) && $term_id > 0) {
include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
//echo "<br>-".ilGlossaryTerm::_lookGlossaryID($term_id)."-".$this->getGlossaryId()."-";
if (ilGlossaryTerm::_lookGlossaryID($term_id) != $this->getGlossaryId()) {
// copy the glossary term from glossary a to b
$new_id = ilGlossaryTerm::_copyTerm($term_id, $this->getGlossaryId());
$res->nodeset[$i]->set_attribute("Target", "il__git_" . $new_id);
}
}
}
}
//exit;
}
示例13: editData
/**
* Edit data of table
*/
function editData()
{
global $lng, $ilCtrl;
if (!ilPageEditorGUI::_doJSEditing()) {
return $this->editDataCl();
}
//var_dump($_GET);
//var_dump($_POST);
$this->setTabs();
$this->displayValidationError();
include_once "./Services/COPage/classes/class.ilPCParagraph.php";
$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tabledata2.html", "Services/COPage");
$dtpl = $this->tpl;
//$dtpl = new ilTemplate("tpl.tabledata.html", true, true, "Services/COPage");
$dtpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "tableAction"));
// $dtpl->setVariable("BB_MENU", $this->getBBMenu("cell_0_0"));
// $this->tpl->addJavascript("./Services/COPage/phpBB/3_0_5/editor.js");
// $this->tpl->addJavascript("./Services/COPage/js/page_editing.js");
$this->tpl->setVariable("WYSIWYG_ACTION", $ilCtrl->getFormAction($this, "updateJS"));
// get all rows
$xpc = xpath_new_context($this->dom);
$path = "//PageContent[@HierId='" . $this->getHierId() . "']" . "/Table/TableRow";
$res =& xpath_eval($xpc, $path);
for ($i = 0; $i < count($res->nodeset); $i++) {
$xpc2 = xpath_new_context($this->dom);
$path2 = "//PageContent[@HierId='" . $this->getHierId() . "']" . "/Table/TableRow[{$i}+1]/TableData";
$res2 =& xpath_eval($xpc2, $path2);
// if this is the first row -> col icons
if ($i == 0) {
for ($j = 0; $j < count($res2->nodeset); $j++) {
if ($j == 0) {
$dtpl->touchBlock("empty_td");
}
if ($j == 0) {
if (count($res2->nodeset) == 1) {
$move_type = "none";
} else {
$move_type = "forward";
}
} else {
if ($j == count($res2->nodeset) - 1) {
$move_type = "backward";
} else {
$move_type = "both";
}
}
$dtpl->setCurrentBlock("col_icon");
$dtpl->setVariable("COL_ICON_ALT", $lng->txt("content_column"));
$dtpl->setVariable("COL_ICON", ilUtil::getImagePath("col.png"));
$dtpl->setVariable("COL_ONCLICK", "COL_" . $move_type);
$dtpl->setVariable("NR", $j);
$dtpl->parseCurrentBlock();
}
$dtpl->setCurrentBlock("row");
$dtpl->parseCurrentBlock();
}
for ($j = 0; $j < count($res2->nodeset); $j++) {
// first col: row icons
if ($j == 0) {
if ($i == 0) {
if (count($res->nodeset) == 1) {
$move_type = "none";
} else {
$move_type = "forward";
}
} else {
if ($i == count($res->nodeset) - 1) {
$move_type = "backward";
} else {
$move_type = "both";
}
}
$dtpl->setCurrentBlock("row_icon");
$dtpl->setVariable("ROW_ICON_ALT", $lng->txt("content_row"));
$dtpl->setVariable("ROW_ICON", ilUtil::getImagePath("row.png"));
$dtpl->setVariable("ROW_ONCLICK", "ROW_" . $move_type);
$dtpl->setVariable("NR", $i);
$dtpl->parseCurrentBlock();
}
// cell
if ($res2->nodeset[$j]->get_attribute("Hidden") != "Y") {
$dtpl->setCurrentBlock("cell");
if (is_array($_POST["cmd"]) && key($_POST["cmd"]) == "update") {
$s_text = ilUtil::stripSlashes("cell_" . $i . "_" . $j, false);
} else {
$s_text = ilPCParagraph::xml2output($this->content_obj->getCellText($i, $j), true, false);
include_once "./Services/COPage/classes/class.ilPCParagraphGUI.php";
$s_text = ilPCParagraphGUI::xml2outputJS($s_text, "TableContent", $this->content_obj->readPCId() . "_" . $i . "_" . $j);
}
$dtpl->setVariable("PAR_TA_NAME", "cell[" . $i . "][" . $j . "]");
$dtpl->setVariable("PAR_TA_ID", "cell_" . $i . "_" . $j);
$dtpl->setVariable("PAR_TA_CONTENT", $s_text);
$cs = $res2->nodeset[$j]->get_attribute("ColSpan");
$rs = $res2->nodeset[$j]->get_attribute("RowSpan");
$dtpl->setVariable("WIDTH", "140");
$dtpl->setVariable("HEIGHT", "80");
if ($cs > 1) {
//.........这里部分代码省略.........
示例14: getXpathChildValues
/**
* get the values as an array from the childtags from the first match of the xpath expression
*
* @param string xpath expression
* @return array with key->value of subtags
* @access public
*/
function getXpathChildValues($expr)
{
$xpath = $this->xmldoc->xpath_new_context();
$xnode = xpath_eval($xpath, $expr);
if (isset($xnode->nodeset[0])) {
foreach ($xnode->nodeset[0]->children() as $child) {
$children = $child->children();
$value[$child->{$this->tagname}] = $children[0]->content;
}
return $value;
}
return null;
}
示例15: setData
/**
* Set data of cells
*/
function setData($a_data)
{
$ok = true;
//var_dump($a_data);
if (is_array($a_data)) {
foreach ($a_data as $i => $row) {
if (is_array($row)) {
foreach ($row as $j => $cell) {
//echo "<br><br>=".$cell."=";
$temp_dom = @domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $cell . '</Paragraph>', DOMXML_LOAD_PARSING, $error);
$par_node = $this->getCellNode($i, $j);
//echo "<br>=".htmlentities($this->dom->dump_node($par_node))."=";
//echo "<br>-$i-$j-$cell-";
// remove all childs
if (empty($error) && is_object($par_node)) {
// delete children of paragraph node
$children = $par_node->child_nodes();
for ($k = 0; $k < count($children); $k++) {
$par_node->remove_child($children[$k]);
}
// copy new content children in paragraph node
$xpc = xpath_new_context($temp_dom);
$path = "//Paragraph";
$res =& xpath_eval($xpc, $path);
if (count($res->nodeset) == 1) {
$new_par_node =& $res->nodeset[0];
$new_childs = $new_par_node->child_nodes();
for ($l = 0; $l < count($new_childs); $l++) {
$cloned_child = $new_childs[$l]->clone_node(true);
$par_node->append_child($cloned_child);
//echo "<br>=".htmlentities($this->dom->dump_node($cloned_child))."=";
}
}
} else {
if (!empty($error)) {
return $error;
}
}
}
}
}
}
//exit;
return true;
}