109 $this->param_modifier =
"";
128 $this->lastTag =
$name;
130 $this->RIGHT = $this->LEFT + 1;
136 $this->db->query(
"INSERT INTO xmltags ( tag_name,tag_depth ) VALUES (" . $ilDB->quote(
$name) .
"," . $ilDB->quote($this->DEPTH) .
") ");
138 $r = $this->db->query(
"SELECT LAST_INSERT_ID()");
143 $Q =
"UPDATE NestedSetTemp SET ns_r=ns_r+2 WHERE ns_r >= " . $ilDB->quote($this->LEFT) .
" AND ns_book_fk = " . $ilDB->quote($this->obj_id) .
" ";
144 $this->db->query($Q);
146 $Q =
"INSERT INTO NestedSetTemp (ns_book_fk,ns_type,ns_tag_fk,ns_l,ns_r) VALUES (" . $ilDB->quote($this->obj_id) .
"," . $ilDB->quote($this->obj_type) .
"," . $ilDB->quote($pk) .
"," . $ilDB->quote($this->LEFT) .
"," . $ilDB->quote($this->RIGHT) .
") ";
147 $this->db->query($Q);
149 $this->
clean($attrs);
150 if (is_array($attrs) && count($attrs)>0) {
152 while (list(
$key, $val) = each($attrs)) {
153 $this->db->query(
"INSERT INTO xmlparam ( tag_fk,param_name,param_value ) VALUES (" . $ilDB->quote($pk) .
"," . $ilDB->quote(
$key) .
"," . $ilDB->quote($val) .
") ");
182 if (1 or trim(
$data)!=
"") {
183 if ($this->lastTag ==
"TAGVALUE") {
184 $Q =
"UPDATE xmlvalue SET tag_value = concat(tag_value," . $ilDB->quote(
$data) .
") WHERE tag_value_pk = " . $ilDB->quote($value_pk) .
" ";
185 $this->db->query($Q);
188 $this->
endElement($this->xml_parser,
"TAGVALUE");
190 $Q =
"INSERT INTO xmlvalue (tag_fk,tag_value) VALUES (" . $ilDB->quote($tag_pk) .
"," . $ilDB->quote(
$data) .
") ";
191 $this->db->query($Q);
193 $Q =
"SELECT LAST_INSERT_ID()";
194 $r = $this->db->query($Q);
198 $this->lastTag =
"TAGVALUE";
234 $this->db->query(
"DROP TABLE IF EXISTS NestedSetTemp");
239 $Q =
"CREATE TEMPORARY TABLE NestedSetTemp ( 240 ns_book_fk int(11) NOT NULL, 241 ns_type char(50) NOT NULL, 242 ns_tag_fk int(11) NOT NULL, 243 ns_l int(11) NOT NULL, 244 ns_r int(11) NOT NULL, 245 KEY ns_tag_fk (ns_tag_fk), 248 KEY ns_book_fk (ns_book_fk) 250 $this->db->query($Q);
258 $this->db->query(
"DELETE FROM NestedSetTemp");
264 $this->xml_parser = xml_parser_create(
"UTF-8");
265 xml_parser_set_option($this->xml_parser, XML_OPTION_CASE_FOLDING,
false);
266 xml_set_object($this->xml_parser, $this);
267 xml_set_element_handler($this->xml_parser,
"startElement",
"endElement");
268 xml_set_character_data_handler($this->xml_parser,
"characterData");
270 if (!xml_parse($this->xml_parser, $xmldata)) {
271 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)));
273 xml_parser_free($this->xml_parser);
280 $this->db->query(
"INSERT INTO xmlnestedset SELECT * FROM NestedSetTemp");
281 $this->db->query(
"DROP TABLE IF EXISTS NestedSetTemp");
292 $this->param_modifier =&$a_object;
293 $this->param_modifier_method = $a_method;
312 $query =
"SELECT * FROM xmlnestedset,xmltags WHERE ns_tag_fk = tag_pk AND ns_book_fk = " . $ilDB->quote($obj_id) .
" AND ns_type = " . $ilDB->quote(
$type) .
" ORDER BY ns_l";
315 die($this->className .
"::checkTable(): " .
$result->getMessage() .
":<br>" .
$query);
324 $Anfang =
"<" .
$row[tag_name];
325 $query =
"SELECT * FROM xmlparam WHERE tag_fk = " . $ilDB->quote(
$row[tag_pk]) .
" ";
326 $result_param = $this->db->query(
$query);
328 $param_value = $row_param[param_value];
329 if (is_object($this->param_modifier)) {
330 $obj =&$this->param_modifier;
331 $method = $this->param_modifier_method;
332 $param_value = $obj->$method(
$row[tag_name], $row_param[param_name], $param_value);
334 $Anfang .=
" " . $row_param[param_name] .
"=\"" . $param_value .
"\"";
338 $Ende =
"</" .
$row[tag_name] .
">";
342 if (
$row[tag_name]==
"TAGVALUE") {
343 $query =
"SELECT * FROM xmlvalue WHERE tag_fk = " . $ilDB->quote(
$row[tag_pk]) .
" ";
344 $result_value = $this->db->query(
$query);
346 $Anfang = $row_value[
"tag_value"];
349 $Anfang = htmlspecialchars($Anfang);
354 $D =
$row[tag_depth];
356 if ($D==$lastDepth) {
360 } elseif ($D>$lastDepth) {
364 for (
$i=$lastDepth;
$i>=$D;
$i--) {
374 for (
$i=$lastDepth;
$i>0;
$i--) {
394 $this->db->setLimit(1);
395 $query =
"SELECT * FROM xmlnestedset,xmltags WHERE ns_book_fk = " . $ilDB->quote($obj_id) .
" AND ns_type =" .
396 $ilDB->quote(
$obj_type) .
" AND ns_tag_fk=tag_pk ORDER BY ns_l";
400 $this->LEFT =
$row[
"ns_l"];
401 $this->RIGHT =
$row[
"ns_r"];
402 $this->DEPTH =
$row[
"tag_depth"];
419 $this->db->setLimit(1);
420 $query =
"SELECT * FROM xmlnestedset,xmltags WHERE ns_book_fk = " . $ilDB->quote($this->obj_id) .
" AND ns_type = " . $ilDB->quote($this->obj_type) .
" AND ns_l = " . $ilDB->quote($this->LEFT) .
" AND ns_r = " . $ilDB->quote($this->RIGHT) .
" AND ns_tag_fk = tag_pk";
424 return(
$row[
"tag_name"]);
440 $this->db->setLimit(1);
441 $query =
"SELECT * FROM xmlnestedset WHERE ns_book_fk = " . $ilDB->quote($this->obj_id) .
" AND ns_type = " . $ilDB->quote($this->obj_type) .
" AND ns_l = " . $ilDB->quote($this->LEFT) .
" AND ns_r = " . $ilDB->quote($this->RIGHT);
445 $query =
"UPDATE xmltags SET tag_name= " . $ilDB->quote($tagName) .
" WHERE tag_pk = " . $ilDB->quote(
$row[
"ns_tag_fk"]);
448 return(
$row[
"tagName"]);
464 $query =
"SELECT * FROM xmlnestedset,xmltags WHERE ns_tag_fk = tag_pk AND ns_book_fk = " . $ilDB->quote($this->obj_id) .
" AND ns_type = " . $ilDB->quote($this->obj_type) .
" AND ns_l >= " . $ilDB->quote($this->LEFT) .
" AND ns_r <= " . $ilDB->quote($this->RIGHT) .
" AND tag_depth = " . $ilDB->quote(($this->DEPTH+1)) .
" ORDER BY ns_l";
467 if (
$row[tag_name]==
"TAGVALUE") {
468 $query =
"SELECT * FROM xmlvalue WHERE tag_fk = " . $ilDB->quote(
$row[tag_pk]) .
" ";
469 $result2 = $this->db->query(
$query);
471 $V[] = $row2[tag_value];
473 $xml =
new ilNestedSetXml();
500 $query =
"SELECT * FROM xmlnestedset,xmltags 501 LEFT JOIN xmlvalue ON xmltags.tag_pk=xmlvalue.tag_fk 502 WHERE ns_tag_fk = tag_pk AND 503 ns_book_fk = " . $ilDB->quote($this->obj_id) .
" AND 504 ns_type = " . $ilDB->quote($this->obj_type) .
" AND 505 ns_l >= " . $ilDB->quote($this->LEFT) .
" AND 506 ns_r <= " . $ilDB->quote($this->RIGHT) .
" AND 507 tag_depth = " . $ilDB->quote(($this->DEPTH+1)) .
" AND 508 tag_name = 'TAGVALUE' 513 $query =
"UPDATE xmlvalue SET tag_value = " . $ilDB->quote($value) .
" WHERE tag_value_pk = " . $ilDB->quote(
$row[
"tag_value_pk"]) .
" ";
534 if (is_object($doc)) {
535 $xpath = $doc->xpath_init();
536 $ctx = $doc->xpath_new_context();
538 $result = $ctx->xpath_eval($qry);
539 if (is_array(
$result->nodeset)) {
554 $xml = $this->
export($this->obj_id, $this->obj_type);
591 include_once
"./Services/Xml/classes/class.ilXML2DOM.php";
597 if (count($nodes) > 0) {
598 $newDOM->insertNode($this->dom, $nodes[
$index]);
617 if (is_object($this->dom)) {
619 if (is_array($node)) {
620 $c = $node[0]->children();
622 if (is_object($c[0])) {
623 $content = $c[0]->get_content();
646 if (strpos(
$index,
",")) {
647 $indices = explode(
",",
$index);
649 if (count($nodes) > 0) {
650 $children = $nodes[$indices[0]]->child_nodes();
651 if (count($children) > 0) {
653 for (
$i = 0;
$i < count($children);
$i++) {
654 if ($children[
$i]->node_name() ==
$name) {
655 if ($j == $indices[1]) {
656 $children[
$i]->unlink_node();
666 if (count($nodes) > 0) {
667 $nodes[
$index]->unlink_node();
689 if (count($nodes) > 0) {
690 $node = $this->dom->create_element(
$name);
692 $node->set_content(utf8_encode($value));
699 $nodes[
$index]->append_child($node);
708 if (is_array($meta)) {
709 foreach ($meta as
$key => $value) {
710 if (is_array($meta[
$key])) {
711 $this->
clean($meta[$key]);
713 $meta[
$key] = preg_replace(
"/&(?!amp;|lt;|gt;|quot;)/",
"&", $meta[$key]);
714 $meta[
$key] = preg_replace(
"/\"/",
""", $meta[$key]);
715 $meta[
$key] = preg_replace(
"/</",
"<", $meta[$key]);
716 $meta[
$key] = preg_replace(
"/>/",
">", $meta[$key]);
734 if ($xPath ==
"//Bibliography") {
735 $nodes = $this->
getXpathNodes($this->dom, $xPath .
"/BibItem[" . ($no+1) .
"]");
739 if (count($nodes) > 0) {
742 if ($nodes[0]->node_name() ==
"BibItem") {
745 for (
$i = 0;
$i < count($meta[
"Language"]);
$i++) {
748 for (
$i = 0;
$i < count($meta[
"Author"]);
$i++) {
750 # for ($j = 0; $j < count($meta["Author"][$i]["FirstName"]); $j++) 754 # for ($j = 0; $j < count($meta["Author"][$i]["MiddleName"]); $j++) 758 # for ($j = 0; $j < count($meta["Author"][$i]["LastName"]); $j++) 765 for (
$i = 0;
$i < count($meta[
"CrossRef"]);
$i++) {
769 for (
$i = 0;
$i < count($meta[
"Editor"]);
$i++) {
773 for (
$i = 0;
$i < count($meta[
"WherePublished"]);
$i++) {
776 for (
$i = 0;
$i < count($meta[
"Institution"]);
$i++) {
779 if (is_array($meta[
"Journal"])) {
782 for (
$i = 0;
$i < count($meta[
"Keyword"]);
$i++) {
785 if (is_array($meta[
"Month"])) {
788 if (is_array($meta[
"Pages"])) {
792 for (
$i = 0;
$i < count($meta[
"School"]);
$i++) {
795 if (is_array($meta[
"Series"])) {
798 # for ($i = 0; $i < count($meta["Series"]["SeriesEditor"]); $i++) 799 if (isset($meta[
"Series"][
"SeriesEditor"])) {
800 # $xml .= '<SeriesEditor>' . ilUtil::stripSlashes($meta["Series"]["SeriesEditor"][$i]) . '</SeriesEditor>'; 803 if (isset($meta[
"Series"][
"SeriesVolume"])) {
809 if ($meta[
"URL_ISBN_ISSN"][
"Type"] ==
"URL") {
811 } elseif ($meta[
"URL_ISBN_ISSN"][
"Type"] ==
"ISBN") {
813 } elseif ($meta[
"URL_ISBN_ISSN"][
"Type"] ==
"ISSN") {
816 $xml .=
'</BibItem>';
817 # echo htmlspecialchars($xml); 823 elseif ($nodes[0]->node_name() ==
"General") {
825 for (
$i = 0;
$i < count($meta[
"Identifier"]);
$i++) {
830 $xml .=
'<Title Language="' .
833 for (
$i = 0;
$i < count($meta[
"Language"]);
$i++) {
836 for (
$i = 0;
$i < count($meta[
"Description"]);
$i++) {
839 for (
$i = 0;
$i < count($meta[
"Keyword"]);
$i++) {
842 if ($meta[
"Coverage"] !=
"") {
845 $xml .=
'</General>';
852 elseif ($nodes[0]->node_name() ==
"Lifecycle") {
853 $xml =
'<Lifecycle Status="' . $meta[
"Status"] .
'">';
855 for (
$i = 0;
$i < count($meta[
"Contribute"]);
$i++) {
858 for ($j = 0; $j < count($meta[
"Contribute"][$i][
"Entity"]); $j++) {
861 $xml .=
'</Contribute>';
863 $xml .=
'</Lifecycle>';
864 # echo htmlspecialchars($xml); 870 elseif ($nodes[0]->node_name() ==
"Meta-Metadata") {
872 for (
$i = 0;
$i < count($meta[
"Identifier"]);
$i++) {
875 for (
$i = 0;
$i < count($meta[
"Contribute"]);
$i++) {
878 for ($j = 0; $j < count($meta[
"Contribute"][$i][
"Entity"]); $j++) {
881 $xml .=
'</Contribute>';
883 $xml .=
'</Meta-Metadata>';
884 # echo htmlspecialchars($xml); 890 elseif ($nodes[0]->node_name() ==
"Technical") {
891 $xml =
'<Technical>';
892 for (
$i = 0;
$i < count($meta[
"Format"]);
$i++) {
895 if ($meta[
"Size"] !=
"") {
898 for (
$i = 0;
$i < count($meta[
"Location"]);
$i++) {
901 if (is_array($meta[
"Requirement"])) {
902 for (
$i = 0;
$i < count($meta[
"Requirement"]);
$i++) {
903 $xml .=
'<Requirement>';
905 if (is_array($meta[
"Requirement"][
$i][
"Type"][
"OperatingSystem"])) {
906 $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"])) .
'"/>';
908 if (is_array($meta[
"Requirement"][$i][
"Type"][
"Browser"])) {
909 $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"])) .
'"/>';
912 $xml .=
'</Requirement>';
914 } elseif (is_array($meta[
"OrComposite"])) {
915 for ($j = 0; $j < count($meta[
"OrComposite"]); $j++) {
916 $xml .=
'<OrComposite>';
917 for (
$i = 0;
$i < count($meta[
"OrComposite"][$j][
"Requirement"]);
$i++) {
918 $xml .=
'<Requirement>';
920 if (is_array($meta[
"OrComposite"][$j][
"Requirement"][
$i][
"Type"][
"OperatingSystem"])) {
921 $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"])) .
'"/>';
923 if (is_array($meta[
"OrComposite"][$j][
"Requirement"][$i][
"Type"][
"Browser"])) {
924 $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"])) .
'"/>';
927 $xml .=
'</Requirement>';
929 $xml .=
'</OrComposite>';
932 if (is_array($meta[
"InstallationRemarks"])) {
935 if (is_array($meta[
"OtherPlattformRequirements"])) {
936 $xml .=
'<OtherPlattformRequirements Language="' .
ilUtil::stripSlashes($meta[
"OtherPlattformRequirements"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"OtherPlattformRequirements"][
"Value"]) .
'</OtherPlattformRequirements>';
938 if ($meta[
"Duration"] !=
"") {
941 $xml .=
'</Technical>';
942 # echo htmlspecialchars($xml); 948 elseif ($nodes[0]->node_name() ==
"Educational") {
951 for (
$i = 0;
$i < count($meta[
"TypicalAgeRange"]);
$i++) {
954 for (
$i = 0;
$i < count($meta[
"Description"]);
$i++) {
957 for (
$i = 0;
$i < count($meta[
"Language"]);
$i++) {
960 $xml .=
'</Educational>';
966 elseif ($nodes[0]->node_name() ==
"Rights") {
968 for (
$i = 0;
$i < count($meta[
"Description"]);
$i++) {
977 elseif ($nodes[0]->node_name() ==
"Relation") {
979 # for ($j = 0; $j < count($meta["Relation"]); $j++) 981 $meta[
"Relation"][0] = $meta;
984 $xml .=
'<Resource>';
985 for (
$i = 0;
$i < count($meta[
"Relation"][$j][
"Resource"][
"Identifier"]);
$i++) {
986 $xml .=
'<Identifier_ Catalog="' .
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Identifier"][
$i][
"Catalog"]) .
'" Entry="' . str_replace(
"\"",
"",
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Identifier"][$i][
"Entry"])) .
'"/>';
988 for (
$i = 0;
$i < count($meta[
"Relation"][$j][
"Resource"][
"Description"]);
$i++) {
989 $xml .=
'<Description Language="' .
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Description"][
$i][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Description"][$i][
"Value"]) .
'</Description>';
991 $xml .=
'</Resource>';
992 $xml .=
'</Relation>';
993 # echo htmlspecialchars($xml); 1000 elseif ($nodes[0]->node_name() ==
"Annotation") {
1002 # for ($i = 0; $i < count($meta["Annotation"]); $i++) 1004 $meta[
"Annotation"][0] = $meta;
1006 $xml =
'<Annotation>';
1010 $xml .=
'</Annotation>';
1011 # echo htmlspecialchars($xml); 1018 elseif ($nodes[0]->node_name() ==
"Classification") {
1020 # for ($j = 0; $j < count($meta["Classification"]); $j++) 1022 $meta[
"Classification"][0] = $meta;
1025 for ($k = 0; $k < count($meta[
"Classification"][$j][
"TaxonPath"]); $k++) {
1026 $xml .=
'<TaxonPath>';
1027 $xml .=
'<Source Language="' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"TaxonPath"][$k][
"Source"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"TaxonPath"][$k][
"Source"][
"Value"]) .
'</Source>';
1028 for (
$i = 0;
$i < count($meta[
"Classification"][$j][
"TaxonPath"][$k][
"Taxon"]);
$i++) {
1029 $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>';
1031 $xml .=
'</TaxonPath>';
1033 $xml .=
'<Description Language="' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Description"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Description"][
"Value"]) .
'</Description>';
1034 for (
$i = 0;
$i < count($meta[
"Classification"][$j][
"Keyword"]);
$i++) {
1037 $xml .=
'</Classification>';
1038 # echo htmlspecialchars($xml); 1045 $nodes[0]->unlink_node();
1047 if ($xPath !=
"//Bibliography") {
1048 $xPath =
"//MetaData";
1075 # echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n"; 1077 if (count($nodes) > 0) {
1078 $children = $nodes[
$index]->child_nodes();
1079 if (count($children) > 0) {
1081 for (
$i = 0;
$i < count($children);
$i++) {
1084 $children[
$i]->node_name() ==
$name) {
1085 $content[$k][
"value"] = $children[
$i]->get_content();
1086 $a = $children[
$i]->attributes();
1087 for ($j = 0; $j < count($a); $j++) {
1088 $content[$k][$a[$j]->name()] = $a[$j]->value();
1110 # echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n"; 1112 if (count($nodes) > 0) {
1113 $children = $nodes[
$index]->child_nodes();
1114 if (count($children) > 0) {
1115 for (
$i = 0;
$i < count($children);
$i++) {
1116 if ($children[
$i]->node_name() ==
$name &&
1117 is_array($newNode)) {
1118 foreach ($newNode as
$key => $val) {
1119 if (
$key ==
"value") {
1122 $children[
$i]->set_attribute(
$key, $val);
1143 $newnode =&$this->dom->create_element($node->tagname());
1144 $newnode->set_content($new_content);
1145 $atts =&$node->attributes();
1146 foreach ($atts as $att) {
1147 $newnode->set_attribute($att->name(), $att->value());
1149 $kids =&$node->child_nodes();
1150 foreach ($kids as $kid) {
1151 if ($kid->node_type() != XML_TEXT_NODE) {
1152 $newnode->append_child($kid);
1155 $node->replace_node($newnode);
1170 if (count($nodes) > 0) {
1171 $children = $nodes[
$index]->child_nodes();
1172 if (count($children) > 0) {
1173 for (
$i = 0;
$i < count($children);
$i++) {
1174 if ($children[
$i]->node_name() ==
$name &&
1175 is_array($newNode)) {
1176 foreach ($newNode as
$key => $val) {
1177 if (
$key ==
"value") {
1178 $children[
$i]->set_content($val);
1180 $children[
$i]->set_attribute(
$key, $val);
1209 $xml = $this->dom->dump_mem(0);
1221 #$ilBench->start('NestedSet','deleteAllDBData'); 1222 $res = $this->db->query(
"SELECT * FROM xmlnestedset WHERE ns_book_fk = " . $ilDB->quote($this->obj_id) .
" AND ns_type = " . $ilDB->quote($this->obj_type) .
" ");
1224 $this->db->query(
"DELETE FROM xmlparam WHERE tag_fk = " . $ilDB->quote(
$row[
"ns_tag_fk"]) .
" ");
1225 $this->db->query(
"DELETE FROM xmlvalue WHERE tag_fk = " . $ilDB->quote(
$row[
"ns_tag_fk"]) .
" ");
1226 $this->db->query(
"DELETE FROM xmltags WHERE tag_pk = " . $ilDB->quote(
$row[
"ns_tag_fk"]) .
" ");
1228 $this->db->query(
"DELETE FROM xmlnestedset WHERE ns_book_fk = " . $ilDB->quote($this->obj_id) .
" AND ns_type = " . $ilDB->quote($this->obj_type) .
" ");
1229 #$ilBench->stop('NestedSet','deleteAllDBData'); 1243 #$ilBench->start('NestedSet','deleteAllChildMetaData'); 1250 $query =
"SELECT ns_tag_fk FROM xmlnestedset " .
1251 "WHERE ns_book_fk " .
$in;
1254 $tag_fks[
$row->ns_tag_fk] =
$row->ns_tag_fk;
1256 $ilDB->query(
"DELETE FROM xmlnestedset WHERE ns_book_fk " .
$in);
1264 $ilDB->query(
"DELETE FROM xmlparam WHERE tag_fk " .
$in);
1265 $ilDB->query(
"DELETE FROM xmlvalue WHERE tag_fk " .
$in);
1266 $ilDB->query(
"DELETE FROM xmltags WHERE tag_pk " .
$in);
1268 #$ilBench->stop('NestedSet','deleteAllChildMetaData'); 1282 $query =
"SELECT obj_id FROM lm_data WHERE lm_id = " . $ilDB->quote($a_obj_id) .
" ";
1287 $ids[$a_obj_id] = $a_obj_id;
1289 return $ids ? $ids :
array();
getTagValue()
get tag content
replace_content(&$node, &$new_content)
Replace node contents.
$xml_parser
SAX-Parser-Handle.
_deleteAllChildMetaData($a_ids)
Delete meta data of a content object (pages, chapters) public.
initDom()
inits dom-object from given xml-content
domxml_open_mem($str, $mode=0, &$error=null)
export($obj_id, $type)
Export-Function.
__construct()
Constructor initilize netsed-set variables public.
$lastTag
last Tag-Name found
_getAllChildIds($a_obj_id)
Get all child ids of a content object public.
init($obj_id, $obj_type)
initilialize Nested-Set-Structur
getFirstDomContent($xPath)
returns first content of this node
$LEFT
Left and right edge tags.
setTagName($tagName)
set tag-name
deleteDomNode($xPath, $name, $index=0)
deletes node
foreach($_POST as $key=> $value) $res
getDomContent($xPath, $name="", $index=0)
returns all contents of this node
$obj_type
The type of the data to those this entry belongs.
setTagValue($value)
set tag-content
redirection script todo: (a better solution should control the processing via a xml file) ...
getTagName()
find first tag-name
updateFromDom()
imports new xml-data from dom into nested set public
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getFirstDomNode($xPath)
first dom-node
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
$DEPTH
Nesting level of the tags.
getXpathNodes(&$doc, $qry)
get node in dom-structure
static quoteArray($a_array)
Quotes all members of an array for usage in DB query statement.
addDomNode($xPath, $name, $value="", $attributes="", $index=0)
adds node to DOM-Structure
updateDomContent($xPath, $name="", $index=0, $newNode)
updates content of this node
addXMLNode($xPath, $xml, $index=0)
parse XML code and add it to a given DOM object as a new node
endElement($parser, $name)
method called at a closing tag private
setParameterModifier(&$a_object, $a_method)
startElement($parser, $name, $attrs)
Method is called, at an introductory TAG private.
updateDomNode($xPath, $meta, $no=0)
updates dom node
replaceDomContent($xPath, $name="", $index=0, $newNode)
updates content of this node
deleteAllDbData()
deletes current db-data of $this->obj_id and $this->obj_type private