Public Member Functions | |
ilNestedSetXML () | |
Constructor initilize netsed-set variables public. | |
startElement ($parser, $name, $attrs) | |
Method is called, at an introductory TAG private. | |
endElement ($parser, $name) | |
method called at a closing tag private | |
import ($xmldata, $obj_id, $obj_type) | |
Import-Function. | |
setParameterModifier (&$a_object, $a_method) | |
export ($obj_id, $type) | |
Export-Function. | |
init ($obj_id, $obj_type) | |
initilialize Nested-Set-Structur | |
getTagName () | |
find first tag-name | |
setTagName ($tagName) | |
set tag-name | |
getTagValue () | |
get tag content | |
setTagValue ($value) | |
set tag-content | |
getXpathNodes (&$doc, $qry) | |
get node in dom-structure | |
initDom () | |
inits dom-object from given xml-content | |
addXMLNode ($xPath, $xml, $index=0) | |
parse XML code and add it to a given DOM object as a new node | |
getFirstDomContent ($xPath) | |
returns first content of this node | |
deleteDomNode ($xPath, $name, $index=0) | |
deletes node | |
addDomNode ($xPath, $name, $value="", $attributes="", $index=0) | |
adds node to DOM-Structure | |
clean (&$meta) | |
updateDomNode ($xPath, $meta, $no=0) | |
updates dom node | |
getDomContent ($xPath, $name="", $index=0) | |
returns all contents of this node | |
replaceDomContent ($xPath, $name="", $index=0, $newNode) | |
updates content of this node | |
replace_content (&$node, &$new_content) | |
Replace node contents. | |
updateDomContent ($xPath, $name="", $index=0, $newNode) | |
updates content of this node | |
getFirstDomNode ($xPath) | |
first dom-node | |
updateFromDom () | |
imports new xml-data from dom into nested set public | |
deleteAllDbData () | |
deletes current db-data of $this->obj_id and $this->obj_type private | |
_deleteAllChildMetaData ($a_ids) | |
Delete meta data of a content object (pages, chapters) public. | |
_getAllChildIds ($a_obj_id) | |
Get all child ids of a content object public. | |
ilNestedSetXML () | |
Constructor initilize netsed-set variables public. | |
startElement ($parser, $name, $attrs) | |
Method is called, at an introductory TAG private. | |
endElement ($parser, $name) | |
method called at a closing tag private | |
import ($xmldata, $obj_id, $obj_type) | |
Import-Function. | |
setParameterModifier (&$a_object, $a_method) | |
export ($obj_id, $type) | |
Export-Function. | |
init ($obj_id, $obj_type) | |
initilialize Nested-Set-Structur | |
getTagName () | |
find first tag-name | |
setTagName ($tagName) | |
set tag-name | |
getTagValue () | |
get tag content | |
setTagValue ($value) | |
set tag-content | |
getXpathNodes (&$doc, $qry) | |
get node in dom-structure | |
initDom () | |
inits dom-object from given xml-content | |
addXMLNode ($xPath, $xml, $index=0) | |
parse XML code and add it to a given DOM object as a new node | |
getFirstDomContent ($xPath) | |
returns first content of this node | |
deleteDomNode ($xPath, $name, $index=0) | |
deletes node | |
addDomNode ($xPath, $name, $value="", $attributes="", $index=0) | |
adds node to DOM-Structure | |
clean (&$meta) | |
updateDomNode ($xPath, $meta, $no=0) | |
updates dom node | |
getDomContent ($xPath, $name="", $index=0) | |
returns all contents of this node | |
replaceDomContent ($xPath, $name="", $index=0, $newNode) | |
updates content of this node | |
replace_content (&$node, &$new_content) | |
Replace node contents. | |
updateDomContent ($xPath, $name="", $index=0, $newNode) | |
updates content of this node | |
getFirstDomNode ($xPath) | |
first dom-node | |
updateFromDom () | |
imports new xml-data from dom into nested set public | |
deleteAllDbData () | |
deletes current db-data of $this->obj_id and $this->obj_type private | |
_deleteAllChildMetaData ($a_ids) | |
Delete meta data of a content object (pages, chapters) public. | |
_getAllChildIds ($a_obj_id) | |
Get all child ids of a content object public. | |
Data Fields | |
$db | |
Datenbank-handle. | |
$LEFT = 0 | |
Left and right edge tags. | |
$RIGHT = 0 | |
$DEPTH = 0 | |
Nesting level of the tags. | |
$obj_id | |
book-Obj-ID | |
$obj_type | |
The type of the data to those this entry belongs. | |
$xml_parser | |
SAX-Parser-Handle. | |
$lastTag = "" | |
last Tag-Name found | |
$ilias | |
$dom |
Definition at line 37 of file class.ilNestedSetXML.php.
ilNestedSetXML::_deleteAllChildMetaData | ( | $ | a_ids | ) |
Delete meta data of a content object (pages, chapters) public.
array | of child ids |
Definition at line 1398 of file class.ilNestedSetXML.php.
References $ilBench, $query, $res, and $row.
{ global $ilBench,$ilDB; #$ilBench->start('NestedSet','deleteAllChildMetaData'); // STEP TWO: DELETE ENTRIES IN xmlnestedset GET ALL tag_fks $in = " IN ('"; $in .= implode("','", $a_ids); $in .= "')"; $query = "SELECT ns_tag_fk FROM xmlnestedset ". "WHERE ns_book_fk ".$in; $res = $ilDB->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $tag_fks[$row->ns_tag_fk] = $row->ns_tag_fk; } $ilDB->query("DELETE FROM xmlnestedset WHERE ns_book_fk ".$in); // FINALLY DELETE $in = " IN ('"; $in .= implode("','", $tag_fks); $in .= "')"; $ilDB->query("DELETE FROM xmlparam WHERE tag_fk ".$in); $ilDB->query("DELETE FROM xmlvalue WHERE tag_fk ".$in); $ilDB->query("DELETE FROM xmltags WHERE tag_pk ".$in); #$ilBench->stop('NestedSet','deleteAllChildMetaData'); return true; }
ilNestedSetXML::_deleteAllChildMetaData | ( | $ | a_ids | ) |
Delete meta data of a content object (pages, chapters) public.
array | of child ids |
Definition at line 1395 of file class.ilNestedSetXML.php.
References $ilBench, $query, $res, and $row.
{ global $ilBench,$ilDB; #$ilBench->start('NestedSet','deleteAllChildMetaData'); // STEP TWO: DELETE ENTRIES IN xmlnestedset GET ALL tag_fks $in = " IN ('"; $in .= implode("','", $a_ids); $in .= "')"; $query = "SELECT ns_tag_fk FROM xmlnestedset ". "WHERE ns_book_fk ".$in; $res = $ilDB->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $tag_fks[$row->ns_tag_fk] = $row->ns_tag_fk; } $ilDB->query("DELETE FROM xmlnestedset WHERE ns_book_fk ".$in); // FINALLY DELETE $in = " IN ('"; $in .= implode("','", $tag_fks); $in .= "')"; $ilDB->query("DELETE FROM xmlparam WHERE tag_fk ".$in); $ilDB->query("DELETE FROM xmlvalue WHERE tag_fk ".$in); $ilDB->query("DELETE FROM xmltags WHERE tag_pk ".$in); #$ilBench->stop('NestedSet','deleteAllChildMetaData'); return true; }
ilNestedSetXML::_getAllChildIds | ( | $ | a_obj_id | ) |
Get all child ids of a content object public.
int | obj_id |
Definition at line 1438 of file class.ilNestedSetXML.php.
ilNestedSetXML::_getAllChildIds | ( | $ | a_obj_id | ) |
Get all child ids of a content object public.
int | obj_id |
Definition at line 1435 of file class.ilNestedSetXML.php.
ilNestedSetXML::addDomNode | ( | $ | xPath, | |
$ | name, | |||
$ | value = "" , |
|||
$ | attributes = "" , |
|||
$ | index = 0 | |||
) |
adds node to DOM-Structure
string | xPath | |
string | name | |
string | value | |
array | attributes | |
integer | index |
Definition at line 726 of file class.ilNestedSetXML.php.
References getXpathNodes().
{ $nodes = $this->getXpathNodes($this->dom, $xPath); if (count($nodes) > 0) { $node = $this->dom->create_element($name); if ($value != "") { $node->set_content(utf8_encode($value)); } if (is_array($attributes)) { for ($i = 0; $i < count($attributes); $i++) { $node->set_attribute($attributes[$i]["name"], utf8_encode($attributes[$i]["value"])); } } $nodes[$index]->append_child($node); return true; } else { return false; } }
ilNestedSetXML::addDomNode | ( | $ | xPath, | |
$ | name, | |||
$ | value = "" , |
|||
$ | attributes = "" , |
|||
$ | index = 0 | |||
) |
adds node to DOM-Structure
string | xPath | |
string | name | |
string | value | |
array | attributes | |
integer | index |
Definition at line 728 of file class.ilNestedSetXML.php.
References getXpathNodes().
{ $nodes = $this->getXpathNodes($this->dom, $xPath); if (count($nodes) > 0) { $node = $this->dom->create_element($name); if ($value != "") { $node->set_content(utf8_encode($value)); } if (is_array($attributes)) { for ($i = 0; $i < count($attributes); $i++) { $node->set_attribute($attributes[$i]["name"], utf8_encode($attributes[$i]["value"])); } } $nodes[$index]->append_child($node); return true; } else { return false; } }
ilNestedSetXML::addXMLNode | ( | $ | xPath, | |
$ | xml, | |||
$ | index = 0 | |||
) |
parse XML code and add it to a given DOM object as a new node
string | xPath path | |
string | xml xml to add | |
integer | index index to add |
Definition at line 614 of file class.ilNestedSetXML.php.
References getXpathNodes().
Referenced by updateDomNode().
{ $newDOM = new XML2DOM($xml); //echo "<br>addXMLNode:-".htmlspecialchars($this->dom->dump_mem(0)); $nodes = $this->getXpathNodes($this->dom, $xPath); if (count($nodes) > 0) { $newDOM->insertNode($this->dom, $nodes[$index]); return true; } else { return false; } }
ilNestedSetXML::addXMLNode | ( | $ | xPath, | |
$ | xml, | |||
$ | index = 0 | |||
) |
parse XML code and add it to a given DOM object as a new node
string | xPath path | |
string | xml xml to add | |
integer | index index to add |
Definition at line 613 of file class.ilNestedSetXML.php.
References getXpathNodes().
{ include_once "./classes/class.ilXML2DOM.php"; $newDOM = new XML2DOM($xml); //echo "<br>addXMLNode:-".htmlspecialchars($this->dom->dump_mem(0)); $nodes = $this->getXpathNodes($this->dom, $xPath); if (count($nodes) > 0) { $newDOM->insertNode($this->dom, $nodes[$index]); return true; } else { return false; } }
ilNestedSetXML::clean | ( | &$ | meta | ) |
Definition at line 754 of file class.ilNestedSetXML.php.
References $key, and ilUtil::stripSlashes().
Referenced by clean(), startElement(), and updateDomNode().
{ if(is_array($meta)) { foreach($meta as $key => $value) { if(is_array($meta[$key])) { $this->clean($meta[$key]); } else { $meta[$key] = ilUtil::stripSlashes($meta[$key]); $meta[$key] = preg_replace("/&(?!amp;|lt;|gt;|quot;)/","&",$meta[$key]); $meta[$key] = preg_replace("/\"/",""",$meta[$key]); $meta[$key] = preg_replace("/</","<",$meta[$key]); $meta[$key] = preg_replace("/>/",">",$meta[$key]); } } } return true; }
ilNestedSetXML::clean | ( | &$ | meta | ) |
Definition at line 752 of file class.ilNestedSetXML.php.
{ if(is_array($meta)) { foreach($meta as $key => $value) { if(is_array($meta[$key])) { $this->clean($meta[$key]); } else { $meta[$key] = preg_replace("/&(?!amp;|lt;|gt;|quot;)/","&",$meta[$key]); $meta[$key] = preg_replace("/\"/",""",$meta[$key]); $meta[$key] = preg_replace("/</","<",$meta[$key]); $meta[$key] = preg_replace("/>/",">",$meta[$key]); } } } return true; }
ilNestedSetXML::deleteAllDbData | ( | ) |
deletes current db-data of $this->obj_id and $this->obj_type private
Definition at line 1374 of file class.ilNestedSetXML.php.
References $ilBench, $res, and $row.
Referenced by import(), and updateFromDom().
{ global $ilBench; #$ilBench->start('NestedSet','deleteAllDBData'); $res = $this->db->query("SELECT * FROM xmlnestedset WHERE ns_book_fk='".$this->obj_id."' AND ns_type='".$this->obj_type."' "); while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { $this->db->query("DELETE FROM xmlparam WHERE tag_fk='".$row["ns_tag_fk"]."' "); $this->db->query("DELETE FROM xmlvalue WHERE tag_fk='".$row["ns_tag_fk"]."' "); $this->db->query("DELETE FROM xmltags WHERE tag_pk='".$row["ns_tag_fk"]."' "); } $this->db->query("DELETE FROM xmlnestedset WHERE ns_book_fk='".$this->obj_id."' AND ns_type='".$this->obj_type."' "); #$ilBench->stop('NestedSet','deleteAllDBData'); }
ilNestedSetXML::deleteAllDbData | ( | ) |
deletes current db-data of $this->obj_id and $this->obj_type private
Definition at line 1371 of file class.ilNestedSetXML.php.
References $ilBench, $res, and $row.
{ global $ilBench; #$ilBench->start('NestedSet','deleteAllDBData'); $res = $this->db->query("SELECT * FROM xmlnestedset WHERE ns_book_fk='".$this->obj_id."' AND ns_type='".$this->obj_type."' "); while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { $this->db->query("DELETE FROM xmlparam WHERE tag_fk='".$row["ns_tag_fk"]."' "); $this->db->query("DELETE FROM xmlvalue WHERE tag_fk='".$row["ns_tag_fk"]."' "); $this->db->query("DELETE FROM xmltags WHERE tag_pk='".$row["ns_tag_fk"]."' "); } $this->db->query("DELETE FROM xmlnestedset WHERE ns_book_fk='".$this->obj_id."' AND ns_type='".$this->obj_type."' "); #$ilBench->stop('NestedSet','deleteAllDBData'); }
ilNestedSetXML::deleteDomNode | ( | $ | xPath, | |
$ | name, | |||
$ | index = 0 | |||
) |
deletes node
string | xPath path | |
string | name name | |
integer | index index |
Definition at line 673 of file class.ilNestedSetXML.php.
References getXpathNodes().
{ if ($index == "") { $index = 0; } if (strpos($index, ",")) { $indices = explode(",", $index); $nodes = $this->getXpathNodes($this->dom, $xPath); if (count($nodes) > 0) { $children = $nodes[$indices[0]]->child_nodes(); if (count($children) > 0) { $j = 0; for ($i = 0; $i < count($children); $i++) { if ($children[$i]->node_name() == $name) { if ($j == $indices[1]) { $children[$i]->unlink_node(); return true; } $j++; } } } } } else { $nodes = $this->getXpathNodes($this->dom, $xPath . "/" . $name); if (count($nodes) > 0) { $nodes[$index]->unlink_node(); return true; } } return false; }
ilNestedSetXML::deleteDomNode | ( | $ | xPath, | |
$ | name, | |||
$ | index = 0 | |||
) |
deletes node
string | xPath path | |
string | name name | |
integer | index index |
Definition at line 671 of file class.ilNestedSetXML.php.
References getXpathNodes().
{ if ($index == "") { $index = 0; } if (strpos($index, ",")) { $indices = explode(",", $index); $nodes = $this->getXpathNodes($this->dom, $xPath); if (count($nodes) > 0) { $children = $nodes[$indices[0]]->child_nodes(); if (count($children) > 0) { $j = 0; for ($i = 0; $i < count($children); $i++) { if ($children[$i]->node_name() == $name) { if ($j == $indices[1]) { $children[$i]->unlink_node(); return true; } $j++; } } } } } else { $nodes = $this->getXpathNodes($this->dom, $xPath . "/" . $name); if (count($nodes) > 0) { $nodes[$index]->unlink_node(); return true; } } return false; }
ilNestedSetXML::endElement | ( | $ | parser, | |
$ | name | |||
) |
method called at a closing tag private
parser | parser xml-parser-handle | |
string | name name of the closing tag |
Definition at line 217 of file class.ilNestedSetXML.php.
{ // {{{ $this->DEPTH--; $this->LEFT += 1; $this->lastTag = ""; // }}} }
ilNestedSetXML::endElement | ( | $ | parser, | |
$ | name | |||
) |
method called at a closing tag private
parser | parser xml-parser-handle | |
string | name name of the closing tag |
Definition at line 216 of file class.ilNestedSetXML.php.
{ // {{{ $this->DEPTH--; $this->LEFT += 1; $this->lastTag = ""; // }}} }
ilNestedSetXML::export | ( | $ | obj_id, | |
$ | type | |||
) |
Export-Function.
creates xml out of nested-set-structure
int | obj_id book-id | |
string | type Object-Type of XML-Struktur |
public
Definition at line 312 of file class.ilNestedSetXML.php.
References $q, $query, $result, and $row.
{ // {{{ $query = "SELECT * FROM xmlnestedset,xmltags WHERE ns_tag_fk=tag_pk AND ns_book_fk='$obj_id' AND ns_type='$type' ORDER BY ns_l"; $result = $this->db->query($query); if (DB::isError($result)) { die($this->className."::checkTable(): ".$result->getMessage().":<br>".$q); } $xml = ""; $lastDepth = -1; while (is_array($row = $result->fetchRow(DB_FETCHMODE_ASSOC) ) ) { // {{{ tags $Anfang = "<".$row[tag_name]; $query = "SELECT * FROM xmlparam WHERE tag_fk='$row[tag_pk]'"; $result_param = $this->db->query($query); while (is_array($row_param = $result_param->fetchRow(DB_FETCHMODE_ASSOC) ) ) { $param_value = $row_param[param_value]; if (is_object($this->param_modifier)) { $obj =& $this->param_modifier; $method = $this->param_modifier_method; $param_value = $obj->$method($row[tag_name], $row_param[param_name], $param_value); } $Anfang .= " ".$row_param[param_name]."=\"".$param_value."\""; } $Anfang .= ">"; $Ende = "</".$row[tag_name].">"; // }}} // {{{ TagValue if ($row[tag_name]=="TAGVALUE") { $query = "SELECT * FROM xmlvalue WHERE tag_fk='$row[tag_pk]' "; $result_value = $this->db->query($query); $row_value = $result_value->fetchRow(DB_FETCHMODE_ASSOC); $Anfang = $row_value["tag_value"]; $Ende = ""; $Anfang = htmlspecialchars($Anfang); // $Anfang = utf8_encode($Anfang); } // }}} $D = $row[tag_depth]; if ($D==$lastDepth) { $xml .= $xmlE[$D]; $xml .= $Anfang; $xmlE[$D] = $Ende; } else if ($D>$lastDepth) { $xml .= $Anfang; $xmlE[$D] = $Ende; } else { for ($i=$lastDepth;$i>=$D;$i--) { $xml .= $xmlE[$i]; } $xml .= $Anfang; $xmlE[$D] = $Ende; } $lastDepth = $D; } for ($i=$lastDepth;$i>0;$i--) { $xml .= $xmlE[$i]; } return($xml); // }}} }
ilNestedSetXML::export | ( | $ | obj_id, | |
$ | type | |||
) |
Export-Function.
creates xml out of nested-set-structure
int | obj_id book-id | |
string | type Object-Type of XML-Struktur |
public
Definition at line 313 of file class.ilNestedSetXML.php.
References $q, $query, $result, and $row.
Referenced by initDom().
{ // {{{ $query = "SELECT * FROM xmlnestedset,xmltags WHERE ns_tag_fk=tag_pk AND ns_book_fk='$obj_id' AND ns_type='$type' ORDER BY ns_l"; $result = $this->db->query($query); if (DB::isError($result)) { die($this->className."::checkTable(): ".$result->getMessage().":<br>".$q); } $xml = ""; $lastDepth = -1; while (is_array($row = $result->fetchRow(DB_FETCHMODE_ASSOC) ) ) { // {{{ tags $Anfang = "<".$row[tag_name]; $query = "SELECT * FROM xmlparam WHERE tag_fk='$row[tag_pk]'"; $result_param = $this->db->query($query); while (is_array($row_param = $result_param->fetchRow(DB_FETCHMODE_ASSOC) ) ) { $param_value = $row_param[param_value]; if (is_object($this->param_modifier)) { $obj =& $this->param_modifier; $method = $this->param_modifier_method; $param_value = $obj->$method($row[tag_name], $row_param[param_name], $param_value); } $Anfang .= " ".$row_param[param_name]."=\"".$param_value."\""; } $Anfang .= ">"; $Ende = "</".$row[tag_name].">"; // }}} // {{{ TagValue if ($row[tag_name]=="TAGVALUE") { $query = "SELECT * FROM xmlvalue WHERE tag_fk='$row[tag_pk]' "; $result_value = $this->db->query($query); $row_value = $result_value->fetchRow(DB_FETCHMODE_ASSOC); $Anfang = $row_value["tag_value"]; $Ende = ""; $Anfang = htmlspecialchars($Anfang); // $Anfang = utf8_encode($Anfang); } // }}} $D = $row[tag_depth]; if ($D==$lastDepth) { $xml .= $xmlE[$D]; $xml .= $Anfang; $xmlE[$D] = $Ende; } else if ($D>$lastDepth) { $xml .= $Anfang; $xmlE[$D] = $Ende; } else { for ($i=$lastDepth;$i>=$D;$i--) { $xml .= $xmlE[$i]; } $xml .= $Anfang; $xmlE[$D] = $Ende; } $lastDepth = $D; } for ($i=$lastDepth;$i>0;$i--) { $xml .= $xmlE[$i]; } return($xml); // }}} }
ilNestedSetXML::getDomContent | ( | $ | xPath, | |
$ | name = "" , |
|||
$ | index = 0 | |||
) |
returns all contents of this node
string | xPath | |
string | name | |
integer | index |
Definition at line 1201 of file class.ilNestedSetXML.php.
References getXpathNodes().
{ if ($index == "") { $index = 0; } # echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n"; $nodes = $this->getXpathNodes($this->dom, $xPath); if (count($nodes) > 0) { $children = $nodes[$index]->child_nodes(); if (count($children) > 0) { $k = 0; for ($i = 0; $i < count($children); $i++) { //echo "<br>ilNestedSetXML::getDomContent-".$children[$i]->node_name()."-".$name; if ($name == "" || $children[$i]->node_name() == $name) { $content[$k]["value"] = $children[$i]->get_content(); $a = $children[$i]->attributes(); for ($j = 0; $j < count($a); $j++) { $content[$k][$a[$j]->name()] = $a[$j]->value(); } $k++; } } # vd($content); return($content); } } return false; }
ilNestedSetXML::getDomContent | ( | $ | xPath, | |
$ | name = "" , |
|||
$ | index = 0 | |||
) |
returns all contents of this node
string | xPath | |
string | name | |
integer | index |
Definition at line 1198 of file class.ilNestedSetXML.php.
References getXpathNodes().
{ if ($index == "") { $index = 0; } # echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n"; $nodes = $this->getXpathNodes($this->dom, $xPath); if (count($nodes) > 0) { $children = $nodes[$index]->child_nodes(); if (count($children) > 0) { $k = 0; for ($i = 0; $i < count($children); $i++) { //echo "<br>ilNestedSetXML::getDomContent-".$children[$i]->node_name()."-".$name; if ($name == "" || $children[$i]->node_name() == $name) { $content[$k]["value"] = $children[$i]->get_content(); $a = $children[$i]->attributes(); for ($j = 0; $j < count($a); $j++) { $content[$k][$a[$j]->name()] = $a[$j]->value(); } $k++; } } # vd($content); return($content); } } return false; }
ilNestedSetXML::getFirstDomContent | ( | $ | xPath | ) |
returns first content of this node
string | xPath path |
Definition at line 640 of file class.ilNestedSetXML.php.
References getXpathNodes().
{ //echo "<br>ilNestedSetXML::getFirstDomContent-start-$xPath-"; flush(); $content = ""; if (is_object($this->dom)) { $node = $this->getXpathNodes($this->dom,$xPath); if (is_array($node)) { $c = $node[0]->children(); //$content = $c[0]->content; // ## changed if (is_object($c[0])) { $content = $c[0]->get_content(); // ## changed } } } //echo "<br>ilNestedSetXML::getFirstDomContent-stop-$content-"; flush(); return($content); }
ilNestedSetXML::getFirstDomContent | ( | $ | xPath | ) |
returns first content of this node
string | xPath path |
Definition at line 639 of file class.ilNestedSetXML.php.
References getXpathNodes().
{ //echo "<br>ilNestedSetXML::getFirstDomContent-start-$xPath-"; flush(); $content = ""; if (is_object($this->dom)) { $node = $this->getXpathNodes($this->dom,$xPath); if (is_array($node)) { if (is_object($node[0])) { $c = $node[0]->children(); //$content = $c[0]->content; // ## changed if (is_object($c[0])) { $content = $c[0]->get_content(); // ## changed } } } } //echo "<br>ilNestedSetXML::getFirstDomContent-stop-$content-"; flush(); return($content); }
ilNestedSetXML::getFirstDomNode | ( | $ | xPath | ) |
first dom-node
string | xPath path |
Definition at line 1349 of file class.ilNestedSetXML.php.
References getXpathNodes().
{ $node = $this->getXpathNodes($this->dom,$xPath); return($node[0]); }
ilNestedSetXML::getFirstDomNode | ( | $ | xPath | ) |
first dom-node
string | xPath path |
Definition at line 1352 of file class.ilNestedSetXML.php.
References getXpathNodes().
{ $node = $this->getXpathNodes($this->dom,$xPath); return($node[0]); }
ilNestedSetXML::getTagName | ( | ) |
find first tag-name
public
Definition at line 429 of file class.ilNestedSetXML.php.
References $query, $result, and $row.
{ $query = "SELECT * FROM xmlnestedset,xmltags WHERE ns_book_fk='".$this->obj_id."' AND ns_type='".$this->obj_type."' AND ns_l='".$this->LEFT."' AND ns_r='".$this->RIGHT."' AND ns_tag_fk=tag_pk LIMIT 1"; $result = $this->db->query($query); $row = $result->fetchRow(DB_FETCHMODE_ASSOC); return($row["tag_name"]); }
ilNestedSetXML::getTagName | ( | ) |
find first tag-name
public
Definition at line 428 of file class.ilNestedSetXML.php.
References $query, $result, and $row.
{ $query = "SELECT * FROM xmlnestedset,xmltags WHERE ns_book_fk='".$this->obj_id."' AND ns_type='".$this->obj_type."' AND ns_l='".$this->LEFT."' AND ns_r='".$this->RIGHT."' AND ns_tag_fk=tag_pk LIMIT 1"; $result = $this->db->query($query); $row = $result->fetchRow(DB_FETCHMODE_ASSOC); return($row["tag_name"]); }
ilNestedSetXML::getTagValue | ( | ) |
get tag content
Definition at line 469 of file class.ilNestedSetXML.php.
References $obj_id, $obj_type, $query, $result, and $row.
{ $V = array(); $query = "SELECT * FROM xmlnestedset,xmltags WHERE ns_tag_fk=tag_pk AND ns_book_fk='".$this->obj_id."' AND ns_type='".$this->obj_type."' AND ns_l>='".$this->LEFT."' AND ns_r<='".$this->RIGHT."' AND tag_depth='".($this->DEPTH+1)."' ORDER BY ns_l"; $result = $this->db->query($query); while (is_array($row = $result->fetchRow(DB_FETCHMODE_ASSOC) ) ) { if ($row[tag_name]=="TAGVALUE") { $query = "SELECT * FROM xmlvalue WHERE tag_fk='".$row[tag_pk]."' "; $result2 = $this->db->query($query); $row2 = $result2->fetchRow(DB_FETCHMODE_ASSOC); $V[] = $row2[tag_value]; } else { $xml = new ilNestedSetXml(); $xml->LEFT = $row["ns_l"]; $xml->RIGHT = $row["ns_r"]; $xml->DEPTH = $row["tag_depth"]; $xml->obj_id = $obj_id; $xml->obj_type = $obj_type; $V[] = $xml; } } return($V); }
ilNestedSetXML::getTagValue | ( | ) |
get tag content
Definition at line 470 of file class.ilNestedSetXML.php.
References $obj_id, $obj_type, $query, $result, and $row.
{ $V = array(); $query = "SELECT * FROM xmlnestedset,xmltags WHERE ns_tag_fk=tag_pk AND ns_book_fk='".$this->obj_id."' AND ns_type='".$this->obj_type."' AND ns_l>='".$this->LEFT."' AND ns_r<='".$this->RIGHT."' AND tag_depth='".($this->DEPTH+1)."' ORDER BY ns_l"; $result = $this->db->query($query); while (is_array($row = $result->fetchRow(DB_FETCHMODE_ASSOC) ) ) { if ($row[tag_name]=="TAGVALUE") { $query = "SELECT * FROM xmlvalue WHERE tag_fk='".$row[tag_pk]."' "; $result2 = $this->db->query($query); $row2 = $result2->fetchRow(DB_FETCHMODE_ASSOC); $V[] = $row2[tag_value]; } else { $xml = new ilNestedSetXml(); $xml->LEFT = $row["ns_l"]; $xml->RIGHT = $row["ns_r"]; $xml->DEPTH = $row["tag_depth"]; $xml->obj_id = $obj_id; $xml->obj_type = $obj_type; $V[] = $xml; } } return($V); }
ilNestedSetXML::getXpathNodes | ( | &$ | doc, | |
$ | qry | |||
) |
get node in dom-structure
object | doc | |
string | qry path to node |
Definition at line 551 of file class.ilNestedSetXML.php.
References $result.
ilNestedSetXML::getXpathNodes | ( | &$ | doc, | |
$ | qry | |||
) |
get node in dom-structure
object | doc | |
string | qry path to node |
Definition at line 552 of file class.ilNestedSetXML.php.
References $result.
Referenced by addDomNode(), addXMLNode(), deleteDomNode(), getDomContent(), getFirstDomContent(), getFirstDomNode(), replaceDomContent(), updateDomContent(), and updateDomNode().
{ if (is_object($doc)) { $xpath = $doc->xpath_init(); $ctx = $doc->xpath_new_context(); //echo "<br><b>ilNestedSetXML::getXpathNodes</b>"; $result = $ctx->xpath_eval($qry); if (is_array($result->nodeset)) { return($result->nodeset); } } return Null; }
ilNestedSetXML::ilNestedSetXML | ( | ) |
Constructor initilize netsed-set variables public.
Definition at line 99 of file class.ilNestedSetXML.php.
References $ilias.
{ global $ilias,$ilDB; $this->ilias =& $ilias; $this->db =& $ilDB; $this->LEFT = 0; $this->RIGHT = 0; $this->DEPTH = 0; $this->param_modifier = ""; }
ilNestedSetXML::ilNestedSetXML | ( | ) |
Constructor initilize netsed-set variables public.
Definition at line 98 of file class.ilNestedSetXML.php.
References $ilias.
{ global $ilias,$ilDB; $this->ilias =& $ilias; $this->db =& $ilDB; $this->LEFT = 0; $this->RIGHT = 0; $this->DEPTH = 0; $this->param_modifier = ""; }
ilNestedSetXML::import | ( | $ | xmldata, | |
$ | obj_id, | |||
$ | obj_type | |||
) |
Import-Function.
String | xmldata xml-structure | |
int | obj_id book-ID | |
string | obj_type Object-Type |
public
drop temporary table
create new temp-Table
initialize XML-Parser
transfer nested-set-structure ito table and drop temp-Table
Definition at line 233 of file class.ilNestedSetXML.php.
References $obj_id, $obj_type, and deleteAllDbData().
{ // {{{ $this->db->query("DROP TABLE IF EXISTS NestedSetTemp"); $Q = "CREATE TEMPORARY TABLE NestedSetTemp ( ns_book_fk int(11) NOT NULL, ns_type char(50) NOT NULL, ns_tag_fk int(11) NOT NULL, ns_l int(11) NOT NULL, ns_r int(11) NOT NULL, KEY ns_tag_fk (ns_tag_fk), KEY ns_l (ns_l), KEY ns_r (ns_r), KEY ns_book_fk (ns_book_fk) ) TYPE=MyISAM "; $this->db->query($Q); $this->obj_id = $obj_id; $this->obj_type = $obj_type; $this->DEPTH = 0; $this->LEFT = 0; $this->RIGHT = 0; $this->db->query("DELETE FROM NestedSetTemp"); $this->xml_parser = xml_parser_create("UTF-8"); xml_parser_set_option($this->xml_parser, XML_OPTION_CASE_FOLDING, false); xml_set_object($this->xml_parser,$this); xml_set_element_handler($this->xml_parser, "startElement", "endElement"); xml_set_character_data_handler($this->xml_parser, "characterData"); if (!xml_parse($this->xml_parser, $xmldata)) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->xml_parser)),xml_get_current_line_number($this->xml_parser))); } xml_parser_free($this->xml_parser); $this->deleteAllDbData(); $this->db->query("INSERT INTO xmlnestedset SELECT * FROM NestedSetTemp"); $this->db->query("DROP TABLE IF EXISTS NestedSetTemp"); // }}} }
ilNestedSetXML::import | ( | $ | xmldata, | |
$ | obj_id, | |||
$ | obj_type | |||
) |
Import-Function.
String | xmldata xml-structure | |
int | obj_id book-ID | |
string | obj_type Object-Type |
public
drop temporary table
create new temp-Table
initialize XML-Parser
transfer nested-set-structure ito table and drop temp-Table
Definition at line 234 of file class.ilNestedSetXML.php.
References $obj_id, $obj_type, and deleteAllDbData().
{ // {{{ $this->db->query("DROP TABLE IF EXISTS NestedSetTemp"); $Q = "CREATE TEMPORARY TABLE NestedSetTemp ( ns_book_fk int(11) NOT NULL, ns_type char(50) NOT NULL, ns_tag_fk int(11) NOT NULL, ns_l int(11) NOT NULL, ns_r int(11) NOT NULL, KEY ns_tag_fk (ns_tag_fk), KEY ns_l (ns_l), KEY ns_r (ns_r), KEY ns_book_fk (ns_book_fk) ) TYPE=MyISAM "; $this->db->query($Q); $this->obj_id = $obj_id; $this->obj_type = $obj_type; $this->DEPTH = 0; $this->LEFT = 0; $this->RIGHT = 0; $this->db->query("DELETE FROM NestedSetTemp"); $this->xml_parser = xml_parser_create("UTF-8"); xml_parser_set_option($this->xml_parser, XML_OPTION_CASE_FOLDING, false); xml_set_object($this->xml_parser,$this); xml_set_element_handler($this->xml_parser, "startElement", "endElement"); xml_set_character_data_handler($this->xml_parser, "characterData"); if (!xml_parse($this->xml_parser, $xmldata)) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->xml_parser)),xml_get_current_line_number($this->xml_parser))); } xml_parser_free($this->xml_parser); $this->deleteAllDbData(); $this->db->query("INSERT INTO xmlnestedset SELECT * FROM NestedSetTemp"); $this->db->query("DROP TABLE IF EXISTS NestedSetTemp"); // }}} }
ilNestedSetXML::init | ( | $ | obj_id, | |
$ | obj_type | |||
) |
initilialize Nested-Set-Structur
integer | obj_id object-id | |
string | obj_type type of object public |
Definition at line 406 of file class.ilNestedSetXML.php.
References $obj_id, $obj_type, $query, $result, and $row.
{ // {{{ $query = "SELECT * FROM xmlnestedset,xmltags WHERE ns_book_fk='".$obj_id."' AND ns_type='". $obj_type."' AND ns_tag_fk=tag_pk ORDER BY ns_l LIMIT 1"; $result = $this->db->query($query); $row = $result->fetchRow(DB_FETCHMODE_ASSOC); $this->LEFT = $row["ns_l"]; $this->RIGHT = $row["ns_r"]; $this->DEPTH = $row["tag_depth"]; $this->obj_id = $obj_id; $this->obj_type = $obj_type; // }}} }
ilNestedSetXML::init | ( | $ | obj_id, | |
$ | obj_type | |||
) |
initilialize Nested-Set-Structur
integer | obj_id object-id | |
string | obj_type type of object public |
Definition at line 405 of file class.ilNestedSetXML.php.
References $obj_id, $obj_type, $query, $result, and $row.
{ // {{{ $query = "SELECT * FROM xmlnestedset,xmltags WHERE ns_book_fk='".$obj_id."' AND ns_type='". $obj_type."' AND ns_tag_fk=tag_pk ORDER BY ns_l LIMIT 1"; $result = $this->db->query($query); $row = $result->fetchRow(DB_FETCHMODE_ASSOC); $this->LEFT = $row["ns_l"]; $this->RIGHT = $row["ns_r"]; $this->DEPTH = $row["tag_depth"]; $this->obj_id = $obj_id; $this->obj_type = $obj_type; // }}} }
ilNestedSetXML::initDom | ( | ) |
inits dom-object from given xml-content
Definition at line 573 of file class.ilNestedSetXML.php.
References domxml_open_mem(), and export().
{ $xml = $this->export($this->obj_id, $this->obj_type); /* for testing $xml_test = ' <MetaData> <General Structure="Atomic"> <Identifier Catalog="ILIAS" Entry="34">Identifier 34 in ILIAS</Identifier> <Identifier Catalog="ILIAS" Entry="45">Identifier 45 in ILIAS</Identifier> <Identifier Catalog="ILIAS" Entry="67">Identifier 67 in ILIAS</Identifier> </General> </MetaData> '; $xml = $xml_test; */ if ($xml=="") { return(false); } else { $this->dom = domxml_open_mem($xml); return(true); } }
ilNestedSetXML::initDom | ( | ) |
inits dom-object from given xml-content
Definition at line 574 of file class.ilNestedSetXML.php.
References domxml_open_mem(), and export().
{ $xml = $this->export($this->obj_id, $this->obj_type); /* for testing $xml_test = ' <MetaData> <General Structure="Atomic"> <Identifier Catalog="ILIAS" Entry="34">Identifier 34 in ILIAS</Identifier> <Identifier Catalog="ILIAS" Entry="45">Identifier 45 in ILIAS</Identifier> <Identifier Catalog="ILIAS" Entry="67">Identifier 67 in ILIAS</Identifier> </General> </MetaData> '; $xml = $xml_test; */ if ($xml=="") { return(false); } else { $this->dom = domxml_open_mem($xml); return(true); } }
ilNestedSetXML::replace_content | ( | &$ | node, | |
&$ | new_content | |||
) |
Replace node contents.
Needed as a workaround for bug/feature of set_content This version puts the content as the first child of the new node. If you need it somewhere else, simply move $newnode->set_content() where you want it.
Definition at line 1286 of file class.ilNestedSetXML.php.
Referenced by replaceDomContent().
{ $newnode =& $this->dom->create_element( $node->tagname() ); $newnode->set_content( $new_content ); $atts =& $node->attributes(); foreach ( $atts as $att ) { $newnode->set_attribute( $att->name(), $att->value() ); } $kids =& $node->child_nodes(); foreach ( $kids as $kid ) { if ( $kid->node_type() != XML_TEXT_NODE ) { $newnode->append_child( $kid ); } } $node->replace_node( $newnode ); }
ilNestedSetXML::replace_content | ( | &$ | node, | |
&$ | new_content | |||
) |
Replace node contents.
Needed as a workaround for bug/feature of set_content This version puts the content as the first child of the new node. If you need it somewhere else, simply move $newnode->set_content() where you want it.
Definition at line 1283 of file class.ilNestedSetXML.php.
{ $newnode =& $this->dom->create_element( $node->tagname() ); $newnode->set_content( $new_content ); $atts =& $node->attributes(); foreach ( $atts as $att ) { $newnode->set_attribute( $att->name(), $att->value() ); } $kids =& $node->child_nodes(); foreach ( $kids as $kid ) { if ( $kid->node_type() != XML_TEXT_NODE ) { $newnode->append_child( $kid ); } } $node->replace_node( $newnode ); }
ilNestedSetXML::replaceDomContent | ( | $ | xPath, | |
$ | name = "" , |
|||
$ | index = 0 , |
|||
$ | newNode | |||
) |
updates content of this node
string | xPath | |
string | name | |
integer | index | |
array | newNode public |
Definition at line 1242 of file class.ilNestedSetXML.php.
References $key, getXpathNodes(), and replace_content().
{ # echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n"; $nodes = $this->getXpathNodes($this->dom, $xPath); if (count($nodes) > 0) { $children = $nodes[$index]->child_nodes(); if (count($children) > 0) { for ($i = 0; $i < count($children); $i++) { if ($children[$i]->node_name() == $name && is_array($newNode)) { foreach ($newNode as $key => $val) { if ($key == "value") { $this->replace_content($children[$i], $val); } else { $children[$i]->set_attribute($key, $val); } } } } } } }
ilNestedSetXML::replaceDomContent | ( | $ | xPath, | |
$ | name = "" , |
|||
$ | index = 0 , |
|||
$ | newNode | |||
) |
updates content of this node
string | xPath | |
string | name | |
integer | index | |
array | newNode public |
Definition at line 1245 of file class.ilNestedSetXML.php.
References $key, getXpathNodes(), and replace_content().
{ # echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n"; $nodes = $this->getXpathNodes($this->dom, $xPath); if (count($nodes) > 0) { $children = $nodes[$index]->child_nodes(); if (count($children) > 0) { for ($i = 0; $i < count($children); $i++) { if ($children[$i]->node_name() == $name && is_array($newNode)) { foreach ($newNode as $key => $val) { if ($key == "value") { $this->replace_content($children[$i], $val); } else { $children[$i]->set_attribute($key, $val); } } } } } } }
ilNestedSetXML::setParameterModifier | ( | &$ | a_object, | |
$ | a_method | |||
) |
obj | a_object | |
String | a_method Function-Name |
Definition at line 295 of file class.ilNestedSetXML.php.
{ $this->param_modifier =& $a_object; $this->param_modifier_method = $a_method; }
ilNestedSetXML::setParameterModifier | ( | &$ | a_object, | |
$ | a_method | |||
) |
obj | a_object | |
String | a_method Function-Name |
Definition at line 296 of file class.ilNestedSetXML.php.
{ $this->param_modifier =& $a_object; $this->param_modifier_method = $a_method; }
ilNestedSetXML::setTagName | ( | $ | tagName | ) |
set tag-name
string | tagName name of tag to be changed |
public
Definition at line 449 of file class.ilNestedSetXML.php.
References $query, $result, and $row.
{ $query = "SELECT * FROM xmlnestedset WHERE ns_book_fk='".$this->obj_id."' AND ns_type='".$this->obj_type."' AND ns_l='".$this->LEFT."' AND ns_r='".$this->RIGHT."' LIMIT 1"; $result = $this->db->query($query); $row = $result->fetchRow(DB_FETCHMODE_ASSOC); $query = "UPDATE xmltags SET tag_name='$tagName' WHERE tag_pk='".$row["ns_tag_fk"]."'"; $this->db->query($query); return($row["tagName"]); }
ilNestedSetXML::setTagName | ( | $ | tagName | ) |
set tag-name
string | tagName name of tag to be changed |
public
Definition at line 448 of file class.ilNestedSetXML.php.
References $query, $result, and $row.
{ $query = "SELECT * FROM xmlnestedset WHERE ns_book_fk='".$this->obj_id."' AND ns_type='".$this->obj_type."' AND ns_l='".$this->LEFT."' AND ns_r='".$this->RIGHT."' LIMIT 1"; $result = $this->db->query($query); $row = $result->fetchRow(DB_FETCHMODE_ASSOC); $query = "UPDATE xmltags SET tag_name='$tagName' WHERE tag_pk='".$row["ns_tag_fk"]."'"; $this->db->query($query); return($row["tagName"]); }
ilNestedSetXML::setTagValue | ( | $ | value | ) |
set tag-content
string | value public |
add new
Definition at line 510 of file class.ilNestedSetXML.php.
References $query, $result, and $row.
{ $V = array(); $query = "SELECT * FROM xmlnestedset,xmltags LEFT JOIN xmlvalue ON xmltags.tag_pk=xmlvalue.tag_fk WHERE ns_tag_fk=tag_pk AND ns_book_fk='".$this->obj_id."' AND ns_type='".$this->obj_type."' AND ns_l>='".$this->LEFT."' AND ns_r<='".$this->RIGHT."' AND tag_depth='".($this->DEPTH+1)."' AND tag_name = 'TAGVALUE' ORDER BY ns_l"; $result = $this->db->query($query); if (is_array($row = $result->fetchRow(DB_FETCHMODE_ASSOC) ) ) { $query = "UPDATE xmlvalue SET tag_value='".addslashes($value)."' WHERE tag_value_pk='".$row["tag_value_pk"]."' "; $this->db->query($query); } else { } }
ilNestedSetXML::setTagValue | ( | $ | value | ) |
set tag-content
string | value public |
add new
Definition at line 509 of file class.ilNestedSetXML.php.
References $query, $result, and $row.
{ $V = array(); $query = "SELECT * FROM xmlnestedset,xmltags LEFT JOIN xmlvalue ON xmltags.tag_pk=xmlvalue.tag_fk WHERE ns_tag_fk=tag_pk AND ns_book_fk='".$this->obj_id."' AND ns_type='".$this->obj_type."' AND ns_l>='".$this->LEFT."' AND ns_r<='".$this->RIGHT."' AND tag_depth='".($this->DEPTH+1)."' AND tag_name = 'TAGVALUE' ORDER BY ns_l"; $result = $this->db->query($query); if (is_array($row = $result->fetchRow(DB_FETCHMODE_ASSOC) ) ) { $query = "UPDATE xmlvalue SET tag_value='".addslashes($value)."' WHERE tag_value_pk='".$row["tag_value_pk"]."' "; $this->db->query($query); } else { } }
ilNestedSetXML::startElement | ( | $ | parser, | |
$ | name, | |||
$ | attrs | |||
) |
Method is called, at an introductory TAG private.
parser | parser xml-parser-handle | |
string | name the tag-name | |
array | attrs assoziativ-array of all attributes inside the tag |
Insert Tag-Name
Definition at line 124 of file class.ilNestedSetXML.php.
References $key, $row, and clean().
{ // {{{ $this->lastTag = $name; $this->LEFT += 1; $this->RIGHT = $this->LEFT + 1; $this->DEPTH++; $this->db->query("INSERT INTO xmltags ( tag_name,tag_depth ) VALUES ('".$name."','".$this->DEPTH."') "); // $pk = mysql_insert_id(); $r = $this->db->query("SELECT LAST_INSERT_ID()"); $row = $r->fetchRow(); $pk = $row[0]; $Q = "UPDATE NestedSetTemp SET ns_r=ns_r+2 WHERE ns_r>='".($this->LEFT)."' AND ns_book_fk='".$this->obj_id."' "; $this->db->query($Q); $Q = "INSERT INTO NestedSetTemp (ns_book_fk,ns_type,ns_tag_fk,ns_l,ns_r) VALUES ('".$this->obj_id."','".$this->obj_type."','".$pk."',".$this->LEFT.",".$this->RIGHT.") "; $this->db->query($Q); $this->clean($attrs); if (is_array($attrs) && count($attrs)>0) { reset ($attrs); while (list ($key, $val) = each ($attrs)) { $this->db->query("INSERT INTO xmlparam ( tag_fk,param_name,param_value ) VALUES ('".$pk."','$key','".addslashes($val)."') "); } } return($pk); // }}} }
ilNestedSetXML::startElement | ( | $ | parser, | |
$ | name, | |||
$ | attrs | |||
) |
Method is called, at an introductory TAG private.
parser | parser xml-parser-handle | |
string | name the tag-name | |
array | attrs assoziativ-array of all attributes inside the tag |
Insert Tag-Name
Definition at line 123 of file class.ilNestedSetXML.php.
References $key, $row, and clean().
{ // {{{ $this->lastTag = $name; $this->LEFT += 1; $this->RIGHT = $this->LEFT + 1; $this->DEPTH++; $this->db->query("INSERT INTO xmltags ( tag_name,tag_depth ) VALUES ('".$name."','".$this->DEPTH."') "); // $pk = mysql_insert_id(); $r = $this->db->query("SELECT LAST_INSERT_ID()"); $row = $r->fetchRow(); $pk = $row[0]; $Q = "UPDATE NestedSetTemp SET ns_r=ns_r+2 WHERE ns_r>='".($this->LEFT)."' AND ns_book_fk='".$this->obj_id."' "; $this->db->query($Q); $Q = "INSERT INTO NestedSetTemp (ns_book_fk,ns_type,ns_tag_fk,ns_l,ns_r) VALUES ('".$this->obj_id."','".$this->obj_type."','".$pk."',".$this->LEFT.",".$this->RIGHT.") "; $this->db->query($Q); $this->clean($attrs); if (is_array($attrs) && count($attrs)>0) { reset ($attrs); while (list ($key, $val) = each ($attrs)) { $this->db->query("INSERT INTO xmlparam ( tag_fk,param_name,param_value ) VALUES ('".$pk."','$key','".addslashes($val)."') "); } } return($pk); // }}} }
ilNestedSetXML::updateDomContent | ( | $ | xPath, | |
$ | name = "" , |
|||
$ | index = 0 , |
|||
$ | newNode | |||
) |
updates content of this node
string | xPath | |
string | name | |
integer | index | |
array | newNode public |
Definition at line 1311 of file class.ilNestedSetXML.php.
References $key, and getXpathNodes().
{ // echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n"; $nodes = $this->getXpathNodes($this->dom, $xPath); if (count($nodes) > 0) { $children = $nodes[$index]->child_nodes(); if (count($children) > 0) { for ($i = 0; $i < count($children); $i++) { if ($children[$i]->node_name() == $name && is_array($newNode)) { foreach ($newNode as $key => $val) { if ($key == "value") { $children[$i]->set_content($val); } else { $children[$i]->set_attribute($key, $val); } } } } } } }
ilNestedSetXML::updateDomContent | ( | $ | xPath, | |
$ | name = "" , |
|||
$ | index = 0 , |
|||
$ | newNode | |||
) |
updates content of this node
string | xPath | |
string | name | |
integer | index | |
array | newNode public |
Definition at line 1314 of file class.ilNestedSetXML.php.
References $key, and getXpathNodes().
{ // echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n"; $nodes = $this->getXpathNodes($this->dom, $xPath); if (count($nodes) > 0) { $children = $nodes[$index]->child_nodes(); if (count($children) > 0) { for ($i = 0; $i < count($children); $i++) { if ($children[$i]->node_name() == $name && is_array($newNode)) { foreach ($newNode as $key => $val) { if ($key == "value") { $children[$i]->set_content($val); } else { $children[$i]->set_attribute($key, $val); } } } } } } }
ilNestedSetXML::updateDomNode | ( | $ | xPath, | |
$ | meta, | |||
$ | no = 0 | |||
) |
updates dom node
string | xPath | |
string | meta | |
integer | no public |
Definition at line 784 of file class.ilNestedSetXML.php.
References addXMLNode(), clean(), getXpathNodes(), and ilUtil::stripSlashes().
{ $this->clean($meta); $update = false; if ($xPath == "//Bibliography") { $nodes = $this->getXpathNodes($this->dom, $xPath . "/BibItem[" . ($no+1) . "]"); } else { $nodes = $this->getXpathNodes($this->dom, $xPath); } if (count($nodes) > 0) { /* BibItem */ if ($nodes[0]->node_name() == "BibItem") { $xml = '<BibItem Type="' . ilUtil::stripSlashes($meta["Type"]) . '" Label="' . ilUtil::stripSlashes($meta["Label"]["Value"]) . '">'; $xml .= '<Identifier Catalog="' . ilUtil::stripSlashes($meta["Identifier"]["Catalog"]) . '" Entry="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Identifier"]["Entry"])) . '"/>'; for ($i = 0; $i < count($meta["Language"]); $i++) { $xml .= '<Language Language="' . ilUtil::stripSlashes($meta["Language"][$i]["Language"]) . '"/>'; } for ($i = 0; $i < count($meta["Author"]); $i++) { $xml .= '<Author>'; # for ($j = 0; $j < count($meta["Author"][$i]["FirstName"]); $j++) # { $xml .= '<FirstName>' . ilUtil::stripSlashes($meta["Author"][$i]["FirstName"]) . '</FirstName>'; # } # for ($j = 0; $j < count($meta["Author"][$i]["MiddleName"]); $j++) # { $xml .= '<MiddleName>' . ilUtil::stripSlashes($meta["Author"][$i]["MiddleName"]) . '</MiddleName>'; # } # for ($j = 0; $j < count($meta["Author"][$i]["LastName"]); $j++) # { $xml .= '<LastName>' . ilUtil::stripSlashes($meta["Author"][$i]["LastName"]) . '</LastName>'; # } $xml .= '</Author>'; } $xml .= '<Booktitle Language="' . ilUtil::stripSlashes($meta["Booktitle"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Booktitle"]["Value"]) . '</Booktitle>'; for ($i = 0; $i < count($meta["CrossRef"]); $i++) { $xml .= '<CrossRef>' . ilUtil::stripSlashes($meta["CrossRef"][$i]["Value"]) . '</CrossRef>'; } $xml .= '<Edition>' . ilUtil::stripSlashes($meta["Edition"]["Value"]) . '</Edition>'; for ($i = 0; $i < count($meta["Editor"]); $i++) { $xml .= '<Editor>' . ilUtil::stripSlashes($meta["Editor"][$i]["Value"]) . '</Editor>'; } $xml .= '<HowPublished Type="' . ilUtil::stripSlashes($meta["HowPublished"]["Type"]) . '"/>'; for ($i = 0; $i < count($meta["WherePublished"]); $i++) { $xml .= '<WherePublished>' . ilUtil::stripSlashes($meta["WherePublished"][$i]["Value"]) . '</WherePublished>'; } for ($i = 0; $i < count($meta["Institution"]); $i++) { $xml .= '<Institution>' . ilUtil::stripSlashes($meta["Institution"][$i]["Value"]) . '</Institution>'; } if (is_array($meta["Journal"])) { $xml .= '<Journal Note="' . ilUtil::stripSlashes($meta["Journal"]["Note"]) . '" Number="' . ilUtil::stripSlashes($meta["Journal"]["Number"]) . '" Organization="' . ilUtil::stripSlashes($meta["Journal"]["Organization"]) . '"/>'; } for ($i = 0; $i < count($meta["Keyword"]); $i++) { $xml .= '<Keyword Language="' . ilUtil::stripSlashes($meta["Keyword"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Keyword"][$i]["Value"]) . '</Keyword>'; } if (is_array($meta["Month"])) { $xml .= '<Month>' . ilUtil::stripSlashes($meta["Month"]["Value"]) . '</Month>'; } if (is_array($meta["Pages"])) { $xml .= '<Pages>' . ilUtil::stripSlashes($meta["Pages"]["Value"]) . '</Pages>'; } $xml .= '<Publisher>' . ilUtil::stripSlashes($meta["Publisher"]["Value"]) . '</Publisher>'; for ($i = 0; $i < count($meta["School"]); $i++) { $xml .= '<School>' . ilUtil::stripSlashes($meta["School"][$i]["Value"]) . '</School>'; } if (is_array($meta["Series"])) { $xml .= '<Series>'; $xml .= '<SeriesTitle>' . ilUtil::stripSlashes($meta["Series"]["SeriesTitle"]) . '</SeriesTitle>'; # for ($i = 0; $i < count($meta["Series"]["SeriesEditor"]); $i++) if (isset($meta["Series"]["SeriesEditor"])) { # $xml .= '<SeriesEditor>' . ilUtil::stripSlashes($meta["Series"]["SeriesEditor"][$i]) . '</SeriesEditor>'; $xml .= '<SeriesEditor>' . ilUtil::stripSlashes($meta["Series"]["SeriesEditor"]) . '</SeriesEditor>'; } if (isset($meta["Series"]["SeriesVolume"])) { $xml .= '<SeriesVolume>' . ilUtil::stripSlashes($meta["Series"]["SeriesVolume"]) . '</SeriesVolume>'; } $xml .= '</Series>'; } $xml .= '<Year>' . ilUtil::stripSlashes($meta["Year"]["Value"]) . '</Year>'; if ($meta["URL_ISBN_ISSN"]["Type"] == "URL") { $xml .= '<URL>' . ilUtil::stripSlashes($meta["URL_ISBN_ISSN"]["Value"]) . '</URL>'; } else if ($meta["URL_ISBN_ISSN"]["Type"] == "ISBN") { $xml .= '<ISBN>' . ilUtil::stripSlashes($meta["URL_ISBN_ISSN"]["Value"]) . '</ISBN>'; } else if ($meta["URL_ISBN_ISSN"]["Type"] == "ISSN") { $xml .= '<ISSN>' . ilUtil::stripSlashes($meta["URL_ISBN_ISSN"]["Value"]) . '</ISSN>'; } $xml .= '</BibItem>'; # echo htmlspecialchars($xml); $update = true; } /* General */ else if ($nodes[0]->node_name() == "General") { $xml = '<General Structure="' . ilUtil::stripSlashes($meta["Structure"]) . '">'; for ($i = 0; $i < count($meta["Identifier"]); $i++) { $xml .= '<Identifier Catalog="' . ilUtil::stripSlashes($meta["Identifier"][$i]["Catalog"]) . '" Entry="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Identifier"][$i]["Entry"])) . '"/>'; } $xml .= '<Title Language="' . ilUtil::stripSlashes($meta["Title"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Title"]["Value"]) . '</Title>'; for ($i = 0; $i < count($meta["Language"]); $i++) { $xml .= '<Language Language="' . ilUtil::stripSlashes($meta["Language"][$i]["Language"]) . '"/>'; } for ($i = 0; $i < count($meta["Description"]); $i++) { $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Description"][$i]["Value"]) . '</Description>'; } for ($i = 0; $i < count($meta["Keyword"]); $i++) { $xml .= '<Keyword Language="' . ilUtil::stripSlashes($meta["Keyword"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Keyword"][$i]["Value"]) . '</Keyword>'; } if ($meta["Coverage"] != "") { $xml .= '<Coverage Language="' . ilUtil::stripSlashes($meta["Coverage"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Coverage"]["Value"]) . '</Coverage>'; } $xml .= '</General>'; //echo "<br><br>".htmlspecialchars($xml); $update = true; } /* Lifecycle */ else if ($nodes[0]->node_name() == "Lifecycle") { $xml = '<Lifecycle Status="' . $meta["Status"] . '">'; $xml .= '<Version Language="' . ilUtil::stripSlashes($meta["Version"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Version"]["Value"]) . '</Version>'; for ($i = 0; $i < count($meta["Contribute"]); $i++) { $xml .= '<Contribute Role="' . ilUtil::stripSlashes($meta["Contribute"][$i]["Role"]) . '">'; $xml .= '<Date>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Date"]) . '</Date>'; for ($j = 0; $j < count($meta["Contribute"][$i]["Entity"]); $j++) { $xml .= '<Entity>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Entity"][$j]) . '</Entity>'; } $xml .= '</Contribute>'; } $xml .= '</Lifecycle>'; # echo htmlspecialchars($xml); $update = true; } /* Meta-Metadata */ else if ($nodes[0]->node_name() == "Meta-Metadata") { $xml = '<Meta-Metadata MetadataScheme="LOM v 1.0" Language="' . ilUtil::stripSlashes($meta["Language"]) . '">'; for ($i = 0; $i < count($meta["Identifier"]); $i++) { $xml .= '<Identifier Catalog="' . ilUtil::stripSlashes($meta["Identifier"][$i]["Catalog"]) . '" Entry="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Identifier"][$i]["Entry"])) . '"/>'; } for ($i = 0; $i < count($meta["Contribute"]); $i++) { $xml .= '<Contribute Role="' . ilUtil::stripSlashes($meta["Contribute"][$i]["Role"]) . '">'; $xml .= '<Date>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Date"]) . '</Date>'; for ($j = 0; $j < count($meta["Contribute"][$i]["Entity"]); $j++) { $xml .= '<Entity>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Entity"][$j]) . '</Entity>'; } $xml .= '</Contribute>'; } $xml .= '</Meta-Metadata>'; # echo htmlspecialchars($xml); $update = true; } /* Technical */ else if ($nodes[0]->node_name() == "Technical") { $xml = '<Technical>'; for ($i = 0; $i < count($meta["Format"]); $i++) { $xml .= '<Format>' . ilUtil::stripSlashes($meta["Format"][$i]) . '</Format>'; } if ($meta["Size"] != "") { $xml .= '<Size>' . ilUtil::stripSlashes($meta["Size"]) . '</Size>'; } for ($i = 0; $i < count($meta["Location"]); $i++) { $xml .= '<Location Type="' . ilUtil::stripSlashes($meta["Location"][$i]["Type"]) . '">' . ilUtil::stripSlashes($meta["Location"][$i]["Value"]) . '</Location>'; } if (is_array($meta["Requirement"])) { for ($i = 0; $i < count($meta["Requirement"]); $i++) { $xml .= '<Requirement>'; $xml .= '<Type>'; if (is_array($meta["Requirement"][$i]["Type"]["OperatingSystem"])) { $xml .= '<OperatingSystem Name="' . ilUtil::stripSlashes($meta["Requirement"][$i]["Type"]["OperatingSystem"]["Name"]) . '" MinimumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Requirement"][$i]["Type"]["OperatingSystem"]["MinimumVersion"])) . '" MaximumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Requirement"][$i]["Type"]["OperatingSystem"]["MaximumVersion"])) . '"/>'; } if (is_array($meta["Requirement"][$i]["Type"]["Browser"])) { $xml .= '<Browser Name="' . ilUtil::stripSlashes($meta["Requirement"][$i]["Type"]["Browser"]["Name"]) . '" MinimumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Requirement"][$i]["Type"]["Browser"]["MinimumVersion"])) . '" MaximumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Requirement"][$i]["Type"]["Browser"]["MaximumVersion"])) . '"/>'; } $xml .= '</Type>'; $xml .= '</Requirement>'; } } else if (is_array($meta["OrComposite"])) { for ($j = 0; $j < count($meta["OrComposite"]); $j++) { $xml .= '<OrComposite>'; for ($i = 0; $i < count($meta["OrComposite"][$j]["Requirement"]); $i++) { $xml .= '<Requirement>'; $xml .= '<Type>'; if (is_array($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["OperatingSystem"])) { $xml .= '<OperatingSystem Name="' . ilUtil::stripSlashes($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["OperatingSystem"]["Name"]) . '" MinimumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["OperatingSystem"]["MinimumVersion"])) . '" MaximumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["OperatingSystem"]["MaximumVersion"])) . '"/>'; } if (is_array($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["Browser"])) { $xml .= '<Browser Name="' . ilUtil::stripSlashes($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["Browser"]["Name"]) . '" MinimumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["Browser"]["MinimumVersion"])) . '" MaximumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["Browser"]["MaximumVersion"])) . '"/>'; } $xml .= '</Type>'; $xml .= '</Requirement>'; } $xml .= '</OrComposite>'; } } if (is_array($meta["InstallationRemarks"])) { $xml .= '<InstallationRemarks Language="' . ilUtil::stripSlashes($meta["InstallationRemarks"]["Language"]) . '">' . ilUtil::stripSlashes($meta["InstallationRemarks"]["Value"]) . '</InstallationRemarks>'; } if (is_array($meta["OtherPlattformRequirements"])) { $xml .= '<OtherPlattformRequirements Language="' . ilUtil::stripSlashes($meta["OtherPlattformRequirements"]["Language"]) . '">' . ilUtil::stripSlashes($meta["OtherPlattformRequirements"]["Value"]) . '</OtherPlattformRequirements>'; } if ($meta["Duration"] != "") { $xml .= '<Duration>' . ilUtil::stripSlashes($meta["Duration"]) . '</Duration>'; } $xml .= '</Technical>'; # echo htmlspecialchars($xml); $update = true; } /* Educational */ else if ($nodes[0]->node_name() == "Educational") { $xml = '<Educational InteractivityType="' . ilUtil::stripSlashes($meta["InteractivityType"]) . '" LearningResourceType="' . ilUtil::stripSlashes($meta["LearningResourceType"]) . '" InteractivityLevel="' . ilUtil::stripSlashes($meta["InteractivityLevel"]) . '" SemanticDensity="' . ilUtil::stripSlashes($meta["SemanticDensity"]) . '" IntendedEndUserRole="' . ilUtil::stripSlashes($meta["IntendedEndUserRole"]) . '" Context="' . ilUtil::stripSlashes($meta["Context"]) . '" Difficulty="' . ilUtil::stripSlashes($meta["Difficulty"]) . '">'; $xml .= '<TypicalLearningTime>' . ilUtil::stripSlashes($meta["TypicalLearningTime"]) . '</TypicalLearningTime>'; for ($i = 0; $i < count($meta["TypicalAgeRange"]); $i++) { $xml .= '<TypicalAgeRange Language="' . ilUtil::stripSlashes($meta["TypicalAgeRange"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["TypicalAgeRange"][$i]["Value"]) . '</TypicalAgeRange>'; } for ($i = 0; $i < count($meta["Description"]); $i++) { $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Description"][$i]["Value"]) . '</Description>'; } for ($i = 0; $i < count($meta["Language"]); $i++) { $xml .= '<Language Language="' . ilUtil::stripSlashes($meta["Language"][$i]["Language"]) . '"/>'; } $xml .= '</Educational>'; $update = true; } /* Rights */ else if ($nodes[0]->node_name() == "Rights") { $xml = '<Rights Cost="' . ilUtil::stripSlashes($meta["Cost"]) . '" CopyrightAndOtherRestrictions="' . ilUtil::stripSlashes($meta["CopyrightAndOtherRestrictions"]) . '">'; for ($i = 0; $i < count($meta["Description"]); $i++) { $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Description"][$i]["Value"]) . '</Description>'; } $xml .= '</Rights>'; $update = true; } /* Relation */ else if ($nodes[0]->node_name() == "Relation") { # for ($j = 0; $j < count($meta["Relation"]); $j++) # { $meta["Relation"][0] = $meta; $j = 0; $xml = '<Relation Kind="' . ilUtil::stripSlashes($meta["Relation"][$j]["Kind"]) . '">'; $xml .= '<Resource>'; for ($i = 0; $i < count($meta["Relation"][$j]["Resource"]["Identifier"]); $i++) { $xml .= '<Identifier_ Catalog="' . ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Identifier"][$i]["Catalog"]) . '" Entry="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Identifier"][$i]["Entry"])) . '"/>'; } for ($i = 0; $i < count($meta["Relation"][$j]["Resource"]["Description"]); $i++) { $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Description"][$i]["Value"]) . '</Description>'; } $xml .= '</Resource>'; $xml .= '</Relation>'; # echo htmlspecialchars($xml); # } $update = true; } /* Annotation */ else if ($nodes[0]->node_name() == "Annotation") { # for ($i = 0; $i < count($meta["Annotation"]); $i++) # { $meta["Annotation"][0] = $meta; $i = 0; $xml = '<Annotation>'; $xml .= '<Entity>' . ilUtil::stripSlashes($meta["Annotation"][$i]["Entity"]) . '</Entity>'; $xml .= '<Date>' . ilUtil::stripSlashes($meta["Annotation"][$i]["Date"]) . '</Date>'; $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Annotation"][$i]["Description"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Annotation"][$i]["Description"]["Value"]) . '</Description>'; $xml .= '</Annotation>'; # echo htmlspecialchars($xml); # } $update = true; } /* Classification */ else if ($nodes[0]->node_name() == "Classification") { # for ($j = 0; $j < count($meta["Classification"]); $j++) # { $meta["Classification"][0] = $meta; $j = 0; $xml = '<Classification Purpose="' . ilUtil::stripSlashes($meta["Classification"][$j]["Purpose"]) . '">'; for ($k = 0; $k < count($meta["Classification"][$j]["TaxonPath"]); $k++) { $xml .= '<TaxonPath>'; $xml .= '<Source Language="' . ilUtil::stripSlashes($meta["Classification"][$j]["TaxonPath"][$k]["Source"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Classification"][$j]["TaxonPath"][$k]["Source"]["Value"]) . '</Source>'; for ($i = 0; $i < count($meta["Classification"][$j]["TaxonPath"][$k]["Taxon"]); $i++) { $xml .= '<Taxon Language="' . ilUtil::stripSlashes($meta["Classification"][$j]["TaxonPath"][$k]["Taxon"][$i]["Language"]) . '" Id="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Classification"][$j]["TaxonPath"][$k]["Taxon"][$i]["Id"])) . '">' . ilUtil::stripSlashes($meta["Classification"][$j]["TaxonPath"][$k]["Taxon"][$i]["Value"]) . '</Taxon>'; } $xml .= '</TaxonPath>'; } $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Classification"][$j]["Description"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Classification"][$j]["Description"]["Value"]) . '</Description>'; for ($i = 0; $i < count($meta["Classification"][$j]["Keyword"]); $i++) { $xml .= '<Keyword Language="' . ilUtil::stripSlashes($meta["Classification"][$j]["Keyword"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Classification"][$j]["Keyword"][$i]["Value"]) . '</Keyword>'; } $xml .= '</Classification>'; # echo htmlspecialchars($xml); # } $update = true; } if ($update) { $nodes[0]->unlink_node(); if ($xPath != "//Bibliography") { $xPath = "//MetaData"; } //echo "<br><br>savedA:".htmlspecialchars($this->dom->dump_mem(0)); $this->addXMLNode($xPath, $xml); //echo "<br><br>savedB:".htmlspecialchars($this->dom->dump_mem(0)); } return true; } else { return false; } }
ilNestedSetXML::updateDomNode | ( | $ | xPath, | |
$ | meta, | |||
$ | no = 0 | |||
) |
updates dom node
string | xPath | |
string | meta | |
integer | no public |
Definition at line 781 of file class.ilNestedSetXML.php.
References addXMLNode(), clean(), getXpathNodes(), and ilUtil::stripSlashes().
{ $this->clean($meta); $update = false; if ($xPath == "//Bibliography") { $nodes = $this->getXpathNodes($this->dom, $xPath . "/BibItem[" . ($no+1) . "]"); } else { $nodes = $this->getXpathNodes($this->dom, $xPath); } if (count($nodes) > 0) { /* BibItem */ if ($nodes[0]->node_name() == "BibItem") { $xml = '<BibItem Type="' . ilUtil::stripSlashes($meta["Type"]) . '" Label="' . ilUtil::stripSlashes($meta["Label"]["Value"]) . '">'; $xml .= '<Identifier Catalog="' . ilUtil::stripSlashes($meta["Identifier"]["Catalog"]) . '" Entry="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Identifier"]["Entry"])) . '"/>'; for ($i = 0; $i < count($meta["Language"]); $i++) { $xml .= '<Language Language="' . ilUtil::stripSlashes($meta["Language"][$i]["Language"]) . '"/>'; } for ($i = 0; $i < count($meta["Author"]); $i++) { $xml .= '<Author>'; # for ($j = 0; $j < count($meta["Author"][$i]["FirstName"]); $j++) # { $xml .= '<FirstName>' . ilUtil::stripSlashes($meta["Author"][$i]["FirstName"]) . '</FirstName>'; # } # for ($j = 0; $j < count($meta["Author"][$i]["MiddleName"]); $j++) # { $xml .= '<MiddleName>' . ilUtil::stripSlashes($meta["Author"][$i]["MiddleName"]) . '</MiddleName>'; # } # for ($j = 0; $j < count($meta["Author"][$i]["LastName"]); $j++) # { $xml .= '<LastName>' . ilUtil::stripSlashes($meta["Author"][$i]["LastName"]) . '</LastName>'; # } $xml .= '</Author>'; } $xml .= '<Booktitle Language="' . ilUtil::stripSlashes($meta["Booktitle"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Booktitle"]["Value"]) . '</Booktitle>'; for ($i = 0; $i < count($meta["CrossRef"]); $i++) { $xml .= '<CrossRef>' . ilUtil::stripSlashes($meta["CrossRef"][$i]["Value"]) . '</CrossRef>'; } $xml .= '<Edition>' . ilUtil::stripSlashes($meta["Edition"]["Value"]) . '</Edition>'; for ($i = 0; $i < count($meta["Editor"]); $i++) { $xml .= '<Editor>' . ilUtil::stripSlashes($meta["Editor"][$i]["Value"]) . '</Editor>'; } $xml .= '<HowPublished Type="' . ilUtil::stripSlashes($meta["HowPublished"]["Type"]) . '"/>'; for ($i = 0; $i < count($meta["WherePublished"]); $i++) { $xml .= '<WherePublished>' . ilUtil::stripSlashes($meta["WherePublished"][$i]["Value"]) . '</WherePublished>'; } for ($i = 0; $i < count($meta["Institution"]); $i++) { $xml .= '<Institution>' . ilUtil::stripSlashes($meta["Institution"][$i]["Value"]) . '</Institution>'; } if (is_array($meta["Journal"])) { $xml .= '<Journal Note="' . ilUtil::stripSlashes($meta["Journal"]["Note"]) . '" Number="' . ilUtil::stripSlashes($meta["Journal"]["Number"]) . '" Organization="' . ilUtil::stripSlashes($meta["Journal"]["Organization"]) . '"/>'; } for ($i = 0; $i < count($meta["Keyword"]); $i++) { $xml .= '<Keyword Language="' . ilUtil::stripSlashes($meta["Keyword"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Keyword"][$i]["Value"]) . '</Keyword>'; } if (is_array($meta["Month"])) { $xml .= '<Month>' . ilUtil::stripSlashes($meta["Month"]["Value"]) . '</Month>'; } if (is_array($meta["Pages"])) { $xml .= '<Pages>' . ilUtil::stripSlashes($meta["Pages"]["Value"]) . '</Pages>'; } $xml .= '<Publisher>' . ilUtil::stripSlashes($meta["Publisher"]["Value"]) . '</Publisher>'; for ($i = 0; $i < count($meta["School"]); $i++) { $xml .= '<School>' . ilUtil::stripSlashes($meta["School"][$i]["Value"]) . '</School>'; } if (is_array($meta["Series"])) { $xml .= '<Series>'; $xml .= '<SeriesTitle>' . ilUtil::stripSlashes($meta["Series"]["SeriesTitle"]) . '</SeriesTitle>'; # for ($i = 0; $i < count($meta["Series"]["SeriesEditor"]); $i++) if (isset($meta["Series"]["SeriesEditor"])) { # $xml .= '<SeriesEditor>' . ilUtil::stripSlashes($meta["Series"]["SeriesEditor"][$i]) . '</SeriesEditor>'; $xml .= '<SeriesEditor>' . ilUtil::stripSlashes($meta["Series"]["SeriesEditor"]) . '</SeriesEditor>'; } if (isset($meta["Series"]["SeriesVolume"])) { $xml .= '<SeriesVolume>' . ilUtil::stripSlashes($meta["Series"]["SeriesVolume"]) . '</SeriesVolume>'; } $xml .= '</Series>'; } $xml .= '<Year>' . ilUtil::stripSlashes($meta["Year"]["Value"]) . '</Year>'; if ($meta["URL_ISBN_ISSN"]["Type"] == "URL") { $xml .= '<URL>' . ilUtil::stripSlashes($meta["URL_ISBN_ISSN"]["Value"]) . '</URL>'; } else if ($meta["URL_ISBN_ISSN"]["Type"] == "ISBN") { $xml .= '<ISBN>' . ilUtil::stripSlashes($meta["URL_ISBN_ISSN"]["Value"]) . '</ISBN>'; } else if ($meta["URL_ISBN_ISSN"]["Type"] == "ISSN") { $xml .= '<ISSN>' . ilUtil::stripSlashes($meta["URL_ISBN_ISSN"]["Value"]) . '</ISSN>'; } $xml .= '</BibItem>'; # echo htmlspecialchars($xml); $update = true; } /* General */ else if ($nodes[0]->node_name() == "General") { $xml = '<General Structure="' . ilUtil::stripSlashes($meta["Structure"]) . '">'; for ($i = 0; $i < count($meta["Identifier"]); $i++) { $xml .= '<Identifier Catalog="' . ilUtil::stripSlashes($meta["Identifier"][$i]["Catalog"]) . '" Entry="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Identifier"][$i]["Entry"])) . '"/>'; } $xml .= '<Title Language="' . ilUtil::stripSlashes($meta["Title"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Title"]["Value"]) . '</Title>'; for ($i = 0; $i < count($meta["Language"]); $i++) { $xml .= '<Language Language="' . ilUtil::stripSlashes($meta["Language"][$i]["Language"]) . '"/>'; } for ($i = 0; $i < count($meta["Description"]); $i++) { $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Description"][$i]["Value"]) . '</Description>'; } for ($i = 0; $i < count($meta["Keyword"]); $i++) { $xml .= '<Keyword Language="' . ilUtil::stripSlashes($meta["Keyword"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Keyword"][$i]["Value"]) . '</Keyword>'; } if ($meta["Coverage"] != "") { $xml .= '<Coverage Language="' . ilUtil::stripSlashes($meta["Coverage"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Coverage"]["Value"]) . '</Coverage>'; } $xml .= '</General>'; //echo "<br><br>".htmlspecialchars($xml); $update = true; } /* Lifecycle */ else if ($nodes[0]->node_name() == "Lifecycle") { $xml = '<Lifecycle Status="' . $meta["Status"] . '">'; $xml .= '<Version Language="' . ilUtil::stripSlashes($meta["Version"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Version"]["Value"]) . '</Version>'; for ($i = 0; $i < count($meta["Contribute"]); $i++) { $xml .= '<Contribute Role="' . ilUtil::stripSlashes($meta["Contribute"][$i]["Role"]) . '">'; $xml .= '<Date>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Date"]) . '</Date>'; for ($j = 0; $j < count($meta["Contribute"][$i]["Entity"]); $j++) { $xml .= '<Entity>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Entity"][$j]) . '</Entity>'; } $xml .= '</Contribute>'; } $xml .= '</Lifecycle>'; # echo htmlspecialchars($xml); $update = true; } /* Meta-Metadata */ else if ($nodes[0]->node_name() == "Meta-Metadata") { $xml = '<Meta-Metadata MetadataScheme="LOM v 1.0" Language="' . ilUtil::stripSlashes($meta["Language"]) . '">'; for ($i = 0; $i < count($meta["Identifier"]); $i++) { $xml .= '<Identifier Catalog="' . ilUtil::stripSlashes($meta["Identifier"][$i]["Catalog"]) . '" Entry="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Identifier"][$i]["Entry"])) . '"/>'; } for ($i = 0; $i < count($meta["Contribute"]); $i++) { $xml .= '<Contribute Role="' . ilUtil::stripSlashes($meta["Contribute"][$i]["Role"]) . '">'; $xml .= '<Date>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Date"]) . '</Date>'; for ($j = 0; $j < count($meta["Contribute"][$i]["Entity"]); $j++) { $xml .= '<Entity>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Entity"][$j]) . '</Entity>'; } $xml .= '</Contribute>'; } $xml .= '</Meta-Metadata>'; # echo htmlspecialchars($xml); $update = true; } /* Technical */ else if ($nodes[0]->node_name() == "Technical") { $xml = '<Technical>'; for ($i = 0; $i < count($meta["Format"]); $i++) { $xml .= '<Format>' . ilUtil::stripSlashes($meta["Format"][$i]) . '</Format>'; } if ($meta["Size"] != "") { $xml .= '<Size>' . ilUtil::stripSlashes($meta["Size"]) . '</Size>'; } for ($i = 0; $i < count($meta["Location"]); $i++) { $xml .= '<Location Type="' . ilUtil::stripSlashes($meta["Location"][$i]["Type"]) . '">' . ilUtil::stripSlashes($meta["Location"][$i]["Value"]) . '</Location>'; } if (is_array($meta["Requirement"])) { for ($i = 0; $i < count($meta["Requirement"]); $i++) { $xml .= '<Requirement>'; $xml .= '<Type>'; if (is_array($meta["Requirement"][$i]["Type"]["OperatingSystem"])) { $xml .= '<OperatingSystem Name="' . ilUtil::stripSlashes($meta["Requirement"][$i]["Type"]["OperatingSystem"]["Name"]) . '" MinimumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Requirement"][$i]["Type"]["OperatingSystem"]["MinimumVersion"])) . '" MaximumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Requirement"][$i]["Type"]["OperatingSystem"]["MaximumVersion"])) . '"/>'; } if (is_array($meta["Requirement"][$i]["Type"]["Browser"])) { $xml .= '<Browser Name="' . ilUtil::stripSlashes($meta["Requirement"][$i]["Type"]["Browser"]["Name"]) . '" MinimumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Requirement"][$i]["Type"]["Browser"]["MinimumVersion"])) . '" MaximumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Requirement"][$i]["Type"]["Browser"]["MaximumVersion"])) . '"/>'; } $xml .= '</Type>'; $xml .= '</Requirement>'; } } else if (is_array($meta["OrComposite"])) { for ($j = 0; $j < count($meta["OrComposite"]); $j++) { $xml .= '<OrComposite>'; for ($i = 0; $i < count($meta["OrComposite"][$j]["Requirement"]); $i++) { $xml .= '<Requirement>'; $xml .= '<Type>'; if (is_array($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["OperatingSystem"])) { $xml .= '<OperatingSystem Name="' . ilUtil::stripSlashes($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["OperatingSystem"]["Name"]) . '" MinimumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["OperatingSystem"]["MinimumVersion"])) . '" MaximumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["OperatingSystem"]["MaximumVersion"])) . '"/>'; } if (is_array($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["Browser"])) { $xml .= '<Browser Name="' . ilUtil::stripSlashes($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["Browser"]["Name"]) . '" MinimumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["Browser"]["MinimumVersion"])) . '" MaximumVersion="' . str_replace("\"", "", ilUtil::stripSlashes($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["Browser"]["MaximumVersion"])) . '"/>'; } $xml .= '</Type>'; $xml .= '</Requirement>'; } $xml .= '</OrComposite>'; } } if (is_array($meta["InstallationRemarks"])) { $xml .= '<InstallationRemarks Language="' . ilUtil::stripSlashes($meta["InstallationRemarks"]["Language"]) . '">' . ilUtil::stripSlashes($meta["InstallationRemarks"]["Value"]) . '</InstallationRemarks>'; } if (is_array($meta["OtherPlattformRequirements"])) { $xml .= '<OtherPlattformRequirements Language="' . ilUtil::stripSlashes($meta["OtherPlattformRequirements"]["Language"]) . '">' . ilUtil::stripSlashes($meta["OtherPlattformRequirements"]["Value"]) . '</OtherPlattformRequirements>'; } if ($meta["Duration"] != "") { $xml .= '<Duration>' . ilUtil::stripSlashes($meta["Duration"]) . '</Duration>'; } $xml .= '</Technical>'; # echo htmlspecialchars($xml); $update = true; } /* Educational */ else if ($nodes[0]->node_name() == "Educational") { $xml = '<Educational InteractivityType="' . ilUtil::stripSlashes($meta["InteractivityType"]) . '" LearningResourceType="' . ilUtil::stripSlashes($meta["LearningResourceType"]) . '" InteractivityLevel="' . ilUtil::stripSlashes($meta["InteractivityLevel"]) . '" SemanticDensity="' . ilUtil::stripSlashes($meta["SemanticDensity"]) . '" IntendedEndUserRole="' . ilUtil::stripSlashes($meta["IntendedEndUserRole"]) . '" Context="' . ilUtil::stripSlashes($meta["Context"]) . '" Difficulty="' . ilUtil::stripSlashes($meta["Difficulty"]) . '">'; $xml .= '<TypicalLearningTime>' . ilUtil::stripSlashes($meta["TypicalLearningTime"]) . '</TypicalLearningTime>'; for ($i = 0; $i < count($meta["TypicalAgeRange"]); $i++) { $xml .= '<TypicalAgeRange Language="' . ilUtil::stripSlashes($meta["TypicalAgeRange"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["TypicalAgeRange"][$i]["Value"]) . '</TypicalAgeRange>'; } for ($i = 0; $i < count($meta["Description"]); $i++) { $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Description"][$i]["Value"]) . '</Description>'; } for ($i = 0; $i < count($meta["Language"]); $i++) { $xml .= '<Language Language="' . ilUtil::stripSlashes($meta["Language"][$i]["Language"]) . '"/>'; } $xml .= '</Educational>'; $update = true; } /* Rights */ else if ($nodes[0]->node_name() == "Rights") { $xml = '<Rights Cost="' . ilUtil::stripSlashes($meta["Cost"]) . '" CopyrightAndOtherRestrictions="' . ilUtil::stripSlashes($meta["CopyrightAndOtherRestrictions"]) . '">'; for ($i = 0; $i < count($meta["Description"]); $i++) { $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Description"][$i]["Value"]) . '</Description>'; } $xml .= '</Rights>'; $update = true; } /* Relation */ else if ($nodes[0]->node_name() == "Relation") { # for ($j = 0; $j < count($meta["Relation"]); $j++) # { $meta["Relation"][0] = $meta; $j = 0; $xml = '<Relation Kind="' . ilUtil::stripSlashes($meta["Relation"][$j]["Kind"]) . '">'; $xml .= '<Resource>'; for ($i = 0; $i < count($meta["Relation"][$j]["Resource"]["Identifier"]); $i++) { $xml .= '<Identifier_ Catalog="' . ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Identifier"][$i]["Catalog"]) . '" Entry="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Identifier"][$i]["Entry"])) . '"/>'; } for ($i = 0; $i < count($meta["Relation"][$j]["Resource"]["Description"]); $i++) { $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Description"][$i]["Value"]) . '</Description>'; } $xml .= '</Resource>'; $xml .= '</Relation>'; # echo htmlspecialchars($xml); # } $update = true; } /* Annotation */ else if ($nodes[0]->node_name() == "Annotation") { # for ($i = 0; $i < count($meta["Annotation"]); $i++) # { $meta["Annotation"][0] = $meta; $i = 0; $xml = '<Annotation>'; $xml .= '<Entity>' . ilUtil::stripSlashes($meta["Annotation"][$i]["Entity"]) . '</Entity>'; $xml .= '<Date>' . ilUtil::stripSlashes($meta["Annotation"][$i]["Date"]) . '</Date>'; $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Annotation"][$i]["Description"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Annotation"][$i]["Description"]["Value"]) . '</Description>'; $xml .= '</Annotation>'; # echo htmlspecialchars($xml); # } $update = true; } /* Classification */ else if ($nodes[0]->node_name() == "Classification") { # for ($j = 0; $j < count($meta["Classification"]); $j++) # { $meta["Classification"][0] = $meta; $j = 0; $xml = '<Classification Purpose="' . ilUtil::stripSlashes($meta["Classification"][$j]["Purpose"]) . '">'; for ($k = 0; $k < count($meta["Classification"][$j]["TaxonPath"]); $k++) { $xml .= '<TaxonPath>'; $xml .= '<Source Language="' . ilUtil::stripSlashes($meta["Classification"][$j]["TaxonPath"][$k]["Source"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Classification"][$j]["TaxonPath"][$k]["Source"]["Value"]) . '</Source>'; for ($i = 0; $i < count($meta["Classification"][$j]["TaxonPath"][$k]["Taxon"]); $i++) { $xml .= '<Taxon Language="' . ilUtil::stripSlashes($meta["Classification"][$j]["TaxonPath"][$k]["Taxon"][$i]["Language"]) . '" Id="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Classification"][$j]["TaxonPath"][$k]["Taxon"][$i]["Id"])) . '">' . ilUtil::stripSlashes($meta["Classification"][$j]["TaxonPath"][$k]["Taxon"][$i]["Value"]) . '</Taxon>'; } $xml .= '</TaxonPath>'; } $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Classification"][$j]["Description"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Classification"][$j]["Description"]["Value"]) . '</Description>'; for ($i = 0; $i < count($meta["Classification"][$j]["Keyword"]); $i++) { $xml .= '<Keyword Language="' . ilUtil::stripSlashes($meta["Classification"][$j]["Keyword"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Classification"][$j]["Keyword"][$i]["Value"]) . '</Keyword>'; } $xml .= '</Classification>'; # echo htmlspecialchars($xml); # } $update = true; } if ($update) { $nodes[0]->unlink_node(); if ($xPath != "//Bibliography") { $xPath = "//MetaData"; } //echo "<br><br>savedA:".htmlspecialchars($this->dom->dump_mem(0)); $this->addXMLNode($xPath, $xml); //echo "<br><br>savedB:".htmlspecialchars($this->dom->dump_mem(0)); } return true; } else { return false; } }
ilNestedSetXML::updateFromDom | ( | ) |
imports new xml-data from dom into nested set public
Definition at line 1359 of file class.ilNestedSetXML.php.
References deleteAllDbData().
{ $this->deleteAllDbData(); $xml = $this->dom->dump_mem(0); $this->import($xml,$this->obj_id,$this->obj_type); }
ilNestedSetXML::updateFromDom | ( | ) |
imports new xml-data from dom into nested set public
Definition at line 1362 of file class.ilNestedSetXML.php.
References deleteAllDbData().
{ $this->deleteAllDbData(); $xml = $this->dom->dump_mem(0); $this->import($xml,$this->obj_id,$this->obj_type); }
ilNestedSetXML::$db |
Datenbank-handle.
Definition at line 44 of file class.ilNestedSetXML.php.
ilNestedSetXML::$DEPTH = 0 |
Nesting level of the tags.
stored in database
Definition at line 56 of file class.ilNestedSetXML.php.
ilNestedSetXML::$dom |
Definition at line 90 of file class.ilNestedSetXML.php.
ilNestedSetXML::$ilias |
Definition at line 83 of file class.ilNestedSetXML.php.
Referenced by ilNestedSetXML().
ilNestedSetXML::$lastTag = "" |
last Tag-Name found
Definition at line 76 of file class.ilNestedSetXML.php.
ilNestedSetXML::$LEFT = 0 |
Left and right edge tags.
Definition at line 49 of file class.ilNestedSetXML.php.
ilNestedSetXML::$obj_id |
book-Obj-ID
Definition at line 61 of file class.ilNestedSetXML.php.
Referenced by getTagValue(), import(), and init().
ilNestedSetXML::$obj_type |
The type of the data to those this entry belongs.
Definition at line 66 of file class.ilNestedSetXML.php.
Referenced by getTagValue(), import(), and init().
ilNestedSetXML::$RIGHT = 0 |
Definition at line 50 of file class.ilNestedSetXML.php.
ilNestedSetXML::$xml_parser |
SAX-Parser-Handle.
Definition at line 71 of file class.ilNestedSetXML.php.