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)
153 while (list ($key, $val) = each ($attrs))
155 $this->db->query(
"INSERT INTO xmlparam ( tag_fk,param_name,param_value ) VALUES (".$ilDB->quote($pk).
",".$ilDB->quote($key).
",".$ilDB->quote($val).
") ");
187 if ($this->lastTag ==
"TAGVALUE")
189 $Q =
"UPDATE xmlvalue SET tag_value = concat(tag_value,".$ilDB->quote(
$data).
") WHERE tag_value_pk = ".$ilDB->quote($value_pk).
" ";
190 $this->db->query($Q);
195 $this->
endElement($this->xml_parser,
"TAGVALUE");
197 $Q =
"INSERT INTO xmlvalue (tag_fk,tag_value) VALUES (".$ilDB->quote($tag_pk).
",".$ilDB->quote(
$data).
") ";
198 $this->db->query($Q);
200 $Q =
"SELECT LAST_INSERT_ID()";
201 $r = $this->db->query($Q);
205 $this->lastTag =
"TAGVALUE";
242 $this->db->query(
"DROP TABLE IF EXISTS NestedSetTemp");
247 $Q =
"CREATE TEMPORARY TABLE NestedSetTemp ( 248 ns_book_fk int(11) NOT NULL, 249 ns_type char(50) NOT NULL, 250 ns_tag_fk int(11) NOT NULL, 251 ns_l int(11) NOT NULL, 252 ns_r int(11) NOT NULL, 253 KEY ns_tag_fk (ns_tag_fk), 256 KEY ns_book_fk (ns_book_fk) 258 $this->db->query($Q);
266 $this->db->query(
"DELETE FROM NestedSetTemp");
272 $this->xml_parser = xml_parser_create(
"UTF-8");
273 xml_parser_set_option($this->xml_parser, XML_OPTION_CASE_FOLDING,
false);
274 xml_set_object($this->xml_parser,$this);
275 xml_set_element_handler($this->xml_parser,
"startElement",
"endElement");
276 xml_set_character_data_handler($this->xml_parser,
"characterData");
278 if (!xml_parse($this->xml_parser, $xmldata)) {
279 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)));
281 xml_parser_free($this->xml_parser);
288 $this->db->query(
"INSERT INTO xmlnestedset SELECT * FROM NestedSetTemp");
289 $this->db->query(
"DROP TABLE IF EXISTS NestedSetTemp");
300 $this->param_modifier =& $a_object;
301 $this->param_modifier_method = $a_method;
320 $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";
324 die($this->className.
"::checkTable(): ".
$result->getMessage().
":<br>".
$query);
334 $Anfang =
"<".$row[tag_name];
335 $query =
"SELECT * FROM xmlparam WHERE tag_fk = ".$ilDB->quote(
$row[tag_pk]).
" ";
336 $result_param = $this->db->query(
$query);
339 $param_value = $row_param[param_value];
340 if (is_object($this->param_modifier))
342 $obj =& $this->param_modifier;
343 $method = $this->param_modifier_method;
344 $param_value = $obj->$method(
$row[tag_name], $row_param[param_name], $param_value);
346 $Anfang .=
" ".$row_param[param_name].
"=\"".$param_value.
"\"";
350 $Ende =
"</".$row[tag_name].
">";
354 if (
$row[tag_name]==
"TAGVALUE")
356 $query =
"SELECT * FROM xmlvalue WHERE tag_fk = ".$ilDB->quote(
$row[tag_pk]).
" ";
357 $result_value = $this->db->query(
$query);
359 $Anfang = $row_value[
"tag_value"];
362 $Anfang = htmlspecialchars($Anfang);
367 $D =
$row[tag_depth];
375 else if ($D>$lastDepth)
382 for ($i=$lastDepth;$i>=$D;$i--)
394 for ($i=$lastDepth;$i>0;$i--)
410 function init($obj_id,$obj_type)
415 $this->db->setLimit(1);
416 $query =
"SELECT * FROM xmlnestedset,xmltags WHERE ns_book_fk = ".$ilDB->quote($obj_id).
" AND ns_type =".
417 $ilDB->quote($obj_type).
" AND ns_tag_fk=tag_pk ORDER BY ns_l";
421 $this->LEFT =
$row[
"ns_l"];
422 $this->RIGHT =
$row[
"ns_r"];
423 $this->DEPTH =
$row[
"tag_depth"];
440 $this->db->setLimit(1);
441 $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";
445 return(
$row[
"tag_name"]);
462 $this->db->setLimit(1);
463 $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);
467 $query =
"UPDATE xmltags SET tag_name= ".$ilDB->quote($tagName).
" WHERE tag_pk = ".$ilDB->quote(
$row[
"ns_tag_fk"]);
470 return(
$row[
"tagName"]);
487 $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";
491 if (
$row[tag_name]==
"TAGVALUE")
493 $query =
"SELECT * FROM xmlvalue WHERE tag_fk = ".$ilDB->quote(
$row[tag_pk]).
" ";
494 $result2 = $this->db->query(
$query);
496 $V[] = $row2[tag_value];
500 $xml =
new ilNestedSetXml();
502 $xml->LEFT =
$row[
"ns_l"];
503 $xml->RIGHT =
$row[
"ns_r"];
504 $xml->DEPTH =
$row[
"tag_depth"];
528 $query =
"SELECT * FROM xmlnestedset,xmltags 529 LEFT JOIN xmlvalue ON xmltags.tag_pk=xmlvalue.tag_fk 530 WHERE ns_tag_fk = tag_pk AND 531 ns_book_fk = ".$ilDB->quote($this->obj_id).
" AND 532 ns_type = ".$ilDB->quote($this->obj_type).
" AND 533 ns_l >= ".$ilDB->quote($this->LEFT).
" AND 534 ns_r <= ".$ilDB->quote($this->RIGHT).
" AND 535 tag_depth = ".$ilDB->quote(($this->DEPTH+1)).
" AND 536 tag_name = 'TAGVALUE' 543 $query =
"UPDATE xmlvalue SET tag_value = ".$ilDB->quote($value).
" WHERE tag_value_pk = ".$ilDB->quote(
$row[
"tag_value_pk"]).
" ";
570 $xpath = $doc->xpath_init();
571 $ctx = $doc->xpath_new_context();
573 $result = $ctx->xpath_eval($qry);
574 if (is_array(
$result->nodeset))
590 $xml = $this->
export($this->obj_id, $this->obj_type);
630 include_once
"./Services/Xml/classes/class.ilXML2DOM.php";
636 if (count($nodes) > 0)
638 $newDOM->insertNode($this->dom, $nodes[$index]);
659 if (is_object($this->dom))
664 $c = $node[0]->children();
666 if (is_object($c[0]))
668 $content = $c[0]->get_content();
692 if (strpos($index,
","))
694 $indices = explode(
",", $index);
696 if (count($nodes) > 0)
698 $children = $nodes[$indices[0]]->child_nodes();
699 if (count($children) > 0)
702 for ($i = 0; $i < count($children); $i++)
704 if ($children[$i]->node_name() == $name)
706 if ($j == $indices[1])
708 $children[$i]->unlink_node();
719 $nodes = $this->
getXpathNodes($this->dom, $xPath .
"/" . $name);
720 if (count($nodes) > 0)
722 $nodes[$index]->unlink_node();
741 function addDomNode($xPath, $name, $value =
"", $attributes =
"", $index = 0)
744 if (count($nodes) > 0)
746 $node = $this->dom->create_element($name);
749 $node->set_content(utf8_encode($value));
751 if (is_array($attributes))
753 for ($i = 0; $i < count($attributes); $i++)
755 $node->set_attribute($attributes[$i][
"name"], utf8_encode($attributes[$i][
"value"]));
758 $nodes[$index]->append_child($node);
771 foreach($meta as $key => $value)
773 if(is_array($meta[$key]))
775 $this->
clean($meta[$key]);
779 $meta[$key] = preg_replace(
"/&(?!amp;|lt;|gt;|quot;)/",
"&",$meta[$key]);
780 $meta[$key] = preg_replace(
"/\"/",
""",$meta[$key]);
781 $meta[$key] = preg_replace(
"/</",
"<",$meta[$key]);
782 $meta[$key] = preg_replace(
"/>/",
">",$meta[$key]);
800 if ($xPath ==
"//Bibliography")
802 $nodes = $this->
getXpathNodes($this->dom, $xPath .
"/BibItem[" . ($no+1) .
"]");
808 if (count($nodes) > 0)
812 if ($nodes[0]->node_name() ==
"BibItem")
816 for ($i = 0; $i < count($meta[
"Language"]); $i++)
818 $xml .=
'<Language Language="' .
ilUtil::stripSlashes($meta[
"Language"][$i][
"Language"]) .
'"/>';
820 for ($i = 0; $i < count($meta[
"Author"]); $i++)
823 # for ($j = 0; $j < count($meta["Author"][$i]["FirstName"]); $j++) 825 $xml .=
'<FirstName>' .
ilUtil::stripSlashes($meta[
"Author"][$i][
"FirstName"]) .
'</FirstName>';
827 # for ($j = 0; $j < count($meta["Author"][$i]["MiddleName"]); $j++) 829 $xml .=
'<MiddleName>' .
ilUtil::stripSlashes($meta[
"Author"][$i][
"MiddleName"]) .
'</MiddleName>';
831 # for ($j = 0; $j < count($meta["Author"][$i]["LastName"]); $j++) 838 for ($i = 0; $i < count($meta[
"CrossRef"]); $i++)
843 for ($i = 0; $i < count($meta[
"Editor"]); $i++)
848 for ($i = 0; $i < count($meta[
"WherePublished"]); $i++)
850 $xml .=
'<WherePublished>' .
ilUtil::stripSlashes($meta[
"WherePublished"][$i][
"Value"]) .
'</WherePublished>';
852 for ($i = 0; $i < count($meta[
"Institution"]); $i++)
854 $xml .=
'<Institution>' .
ilUtil::stripSlashes($meta[
"Institution"][$i][
"Value"]) .
'</Institution>';
856 if (is_array($meta[
"Journal"]))
860 for ($i = 0; $i < count($meta[
"Keyword"]); $i++)
864 if (is_array($meta[
"Month"]))
868 if (is_array($meta[
"Pages"]))
873 for ($i = 0; $i < count($meta[
"School"]); $i++)
877 if (is_array($meta[
"Series"]))
880 $xml .=
'<SeriesTitle>' .
ilUtil::stripSlashes($meta[
"Series"][
"SeriesTitle"]) .
'</SeriesTitle>';
881 # for ($i = 0; $i < count($meta["Series"]["SeriesEditor"]); $i++) 882 if (isset($meta[
"Series"][
"SeriesEditor"]))
884 # $xml .= '<SeriesEditor>' . ilUtil::stripSlashes($meta["Series"]["SeriesEditor"][$i]) . '</SeriesEditor>'; 885 $xml .=
'<SeriesEditor>' .
ilUtil::stripSlashes($meta[
"Series"][
"SeriesEditor"]) .
'</SeriesEditor>';
887 if (isset($meta[
"Series"][
"SeriesVolume"]))
889 $xml .=
'<SeriesVolume>' .
ilUtil::stripSlashes($meta[
"Series"][
"SeriesVolume"]) .
'</SeriesVolume>';
894 if ($meta[
"URL_ISBN_ISSN"][
"Type"] ==
"URL")
898 else if ($meta[
"URL_ISBN_ISSN"][
"Type"] ==
"ISBN")
902 else if ($meta[
"URL_ISBN_ISSN"][
"Type"] ==
"ISSN")
906 $xml .=
'</BibItem>';
907 # echo htmlspecialchars($xml); 913 else if ($nodes[0]->node_name() ==
"General")
917 for ($i = 0; $i < count($meta[
"Identifier"]); $i++)
919 $xml .=
'<Identifier Catalog="' .
ilUtil::stripSlashes($meta[
"Identifier"][$i][
"Catalog"]) .
'" Entry="' .
923 $xml .=
'<Title Language="' .
926 for ($i = 0; $i < count($meta[
"Language"]); $i++)
928 $xml .=
'<Language Language="' .
ilUtil::stripSlashes($meta[
"Language"][$i][
"Language"]) .
'"/>';
930 for ($i = 0; $i < count($meta[
"Description"]); $i++)
934 for ($i = 0; $i < count($meta[
"Keyword"]); $i++)
938 if ($meta[
"Coverage"] !=
"")
942 $xml .=
'</General>';
949 else if ($nodes[0]->node_name() ==
"Lifecycle")
951 $xml =
'<Lifecycle Status="' . $meta[
"Status"] .
'">';
953 for ($i = 0; $i < count($meta[
"Contribute"]); $i++)
957 for ($j = 0; $j < count($meta[
"Contribute"][$i][
"Entity"]); $j++)
961 $xml .=
'</Contribute>';
963 $xml .=
'</Lifecycle>';
964 # echo htmlspecialchars($xml); 970 else if ($nodes[0]->node_name() ==
"Meta-Metadata")
973 $xml =
'<Meta-Metadata MetadataScheme="LOM v 1.0" Language="' .
ilUtil::stripSlashes($meta[
"Language"]) .
'">';
974 for ($i = 0; $i < count($meta[
"Identifier"]); $i++)
978 for ($i = 0; $i < count($meta[
"Contribute"]); $i++)
982 for ($j = 0; $j < count($meta[
"Contribute"][$i][
"Entity"]); $j++)
986 $xml .=
'</Contribute>';
988 $xml .=
'</Meta-Metadata>';
989 # echo htmlspecialchars($xml); 995 else if ($nodes[0]->node_name() ==
"Technical")
998 $xml =
'<Technical>';
999 for ($i = 0; $i < count($meta[
"Format"]); $i++)
1003 if ($meta[
"Size"] !=
"")
1007 for ($i = 0; $i < count($meta[
"Location"]); $i++)
1011 if (is_array($meta[
"Requirement"]))
1013 for ($i = 0; $i < count($meta[
"Requirement"]); $i++)
1015 $xml .=
'<Requirement>';
1017 if (is_array($meta[
"Requirement"][$i][
"Type"][
"OperatingSystem"]))
1019 $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"])) .
'"/>';
1021 if (is_array($meta[
"Requirement"][$i][
"Type"][
"Browser"]))
1023 $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"])) .
'"/>';
1026 $xml .=
'</Requirement>';
1029 else if (is_array($meta[
"OrComposite"]))
1031 for ($j = 0; $j < count($meta[
"OrComposite"]); $j++)
1033 $xml .=
'<OrComposite>';
1034 for ($i = 0; $i < count($meta[
"OrComposite"][$j][
"Requirement"]); $i++)
1036 $xml .=
'<Requirement>';
1038 if (is_array($meta[
"OrComposite"][$j][
"Requirement"][$i][
"Type"][
"OperatingSystem"]))
1040 $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"])) .
'"/>';
1042 if (is_array($meta[
"OrComposite"][$j][
"Requirement"][$i][
"Type"][
"Browser"]))
1044 $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"])) .
'"/>';
1047 $xml .=
'</Requirement>';
1049 $xml .=
'</OrComposite>';
1052 if (is_array($meta[
"InstallationRemarks"]))
1054 $xml .=
'<InstallationRemarks Language="' .
ilUtil::stripSlashes($meta[
"InstallationRemarks"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"InstallationRemarks"][
"Value"]) .
'</InstallationRemarks>';
1056 if (is_array($meta[
"OtherPlattformRequirements"]))
1058 $xml .=
'<OtherPlattformRequirements Language="' .
ilUtil::stripSlashes($meta[
"OtherPlattformRequirements"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"OtherPlattformRequirements"][
"Value"]) .
'</OtherPlattformRequirements>';
1060 if ($meta[
"Duration"] !=
"")
1064 $xml .=
'</Technical>';
1065 # echo htmlspecialchars($xml); 1071 else if ($nodes[0]->node_name() ==
"Educational")
1075 $xml .=
'<TypicalLearningTime>' .
ilUtil::stripSlashes($meta[
"TypicalLearningTime"]) .
'</TypicalLearningTime>';
1076 for ($i = 0; $i < count($meta[
"TypicalAgeRange"]); $i++)
1078 $xml .=
'<TypicalAgeRange Language="' .
ilUtil::stripSlashes($meta[
"TypicalAgeRange"][$i][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"TypicalAgeRange"][$i][
"Value"]) .
'</TypicalAgeRange>';
1080 for ($i = 0; $i < count($meta[
"Description"]); $i++)
1084 for ($i = 0; $i < count($meta[
"Language"]); $i++)
1086 $xml .=
'<Language Language="' .
ilUtil::stripSlashes($meta[
"Language"][$i][
"Language"]) .
'"/>';
1088 $xml .=
'</Educational>';
1094 else if ($nodes[0]->node_name() ==
"Rights")
1098 for ($i = 0; $i < count($meta[
"Description"]); $i++)
1102 $xml .=
'</Rights>';
1108 else if ($nodes[0]->node_name() ==
"Relation")
1111 # for ($j = 0; $j < count($meta["Relation"]); $j++) 1113 $meta[
"Relation"][0] = $meta;
1116 $xml .=
'<Resource>';
1117 for ($i = 0; $i < count($meta[
"Relation"][$j][
"Resource"][
"Identifier"]); $i++)
1119 $xml .=
'<Identifier_ Catalog="' .
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Identifier"][$i][
"Catalog"]) .
'" Entry="' . str_replace(
"\"",
"",
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Identifier"][$i][
"Entry"])) .
'"/>';
1121 for ($i = 0; $i < count($meta[
"Relation"][$j][
"Resource"][
"Description"]); $i++)
1123 $xml .=
'<Description Language="' .
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Description"][$i][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Description"][$i][
"Value"]) .
'</Description>';
1125 $xml .=
'</Resource>';
1126 $xml .=
'</Relation>';
1127 # echo htmlspecialchars($xml); 1134 else if ($nodes[0]->node_name() ==
"Annotation")
1137 # for ($i = 0; $i < count($meta["Annotation"]); $i++) 1139 $meta[
"Annotation"][0] = $meta;
1141 $xml =
'<Annotation>';
1144 $xml .=
'<Description Language="' .
ilUtil::stripSlashes($meta[
"Annotation"][$i][
"Description"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Annotation"][$i][
"Description"][
"Value"]) .
'</Description>';
1145 $xml .=
'</Annotation>';
1146 # echo htmlspecialchars($xml); 1153 else if ($nodes[0]->node_name() ==
"Classification")
1156 # for ($j = 0; $j < count($meta["Classification"]); $j++) 1158 $meta[
"Classification"][0] = $meta;
1160 $xml =
'<Classification Purpose="' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Purpose"]) .
'">';
1161 for ($k = 0; $k < count($meta[
"Classification"][$j][
"TaxonPath"]); $k++)
1163 $xml .=
'<TaxonPath>';
1164 $xml .=
'<Source Language="' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"TaxonPath"][$k][
"Source"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"TaxonPath"][$k][
"Source"][
"Value"]) .
'</Source>';
1165 for ($i = 0; $i < count($meta[
"Classification"][$j][
"TaxonPath"][$k][
"Taxon"]); $i++)
1167 $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>';
1169 $xml .=
'</TaxonPath>';
1171 $xml .=
'<Description Language="' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Description"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Description"][
"Value"]) .
'</Description>';
1172 for ($i = 0; $i < count($meta[
"Classification"][$j][
"Keyword"]); $i++)
1174 $xml .=
'<Keyword Language="' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Keyword"][$i][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Keyword"][$i][
"Value"]) .
'</Keyword>';
1176 $xml .=
'</Classification>';
1177 # echo htmlspecialchars($xml); 1185 $nodes[0]->unlink_node();
1187 if ($xPath !=
"//Bibliography")
1189 $xPath =
"//MetaData";
1219 # echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n"; 1221 if (count($nodes) > 0)
1223 $children = $nodes[$index]->child_nodes();
1224 if (count($children) > 0)
1227 for ($i = 0; $i < count($children); $i++)
1231 $children[$i]->node_name() == $name)
1233 $content[$k][
"value"] = $children[$i]->get_content();
1234 $a = $children[$i]->attributes();
1235 for ($j = 0; $j < count($a); $j++)
1237 $content[$k][$a[$j]->name()] = $a[$j]->value();
1259 # echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n"; 1261 if (count($nodes) > 0)
1263 $children = $nodes[$index]->child_nodes();
1264 if (count($children) > 0)
1266 for ($i = 0; $i < count($children); $i++)
1268 if ($children[$i]->node_name() == $name &&
1271 foreach ($newNode as $key => $val)
1273 if ($key ==
"value")
1279 $children[$i]->set_attribute($key, $val);
1300 $newnode =& $this->dom->create_element( $node->tagname() );
1301 $newnode->set_content( $new_content );
1302 $atts =& $node->attributes();
1303 foreach ( $atts as $att )
1305 $newnode->set_attribute( $att->name(), $att->value() );
1307 $kids =& $node->child_nodes();
1308 foreach ( $kids as $kid )
1310 if ( $kid->node_type() != XML_TEXT_NODE )
1312 $newnode->append_child( $kid );
1315 $node->replace_node( $newnode );
1330 if (count($nodes) > 0)
1332 $children = $nodes[$index]->child_nodes();
1333 if (count($children) > 0)
1335 for ($i = 0; $i < count($children); $i++)
1337 if ($children[$i]->node_name() == $name &&
1340 foreach ($newNode as $key => $val)
1342 if ($key ==
"value")
1344 $children[$i]->set_content($val);
1348 $children[$i]->set_attribute($key, $val);
1377 $xml = $this->dom->dump_mem(0);
1390 #$ilBench->start('NestedSet','deleteAllDBData'); 1391 $res = $this->db->query(
"SELECT * FROM xmlnestedset WHERE ns_book_fk = ".$ilDB->quote($this->obj_id).
" AND ns_type = ".$ilDB->quote($this->obj_type).
" ");
1394 $this->db->query(
"DELETE FROM xmlparam WHERE tag_fk = ".$ilDB->quote(
$row[
"ns_tag_fk"]).
" ");
1395 $this->db->query(
"DELETE FROM xmlvalue WHERE tag_fk = ".$ilDB->quote(
$row[
"ns_tag_fk"]).
" ");
1396 $this->db->query(
"DELETE FROM xmltags WHERE tag_pk = ".$ilDB->quote(
$row[
"ns_tag_fk"]).
" ");
1398 $this->db->query(
"DELETE FROM xmlnestedset WHERE ns_book_fk = ".$ilDB->quote($this->obj_id).
" AND ns_type = ".$ilDB->quote($this->obj_type).
" ");
1399 #$ilBench->stop('NestedSet','deleteAllDBData'); 1414 #$ilBench->start('NestedSet','deleteAllChildMetaData'); 1421 $query =
"SELECT ns_tag_fk FROM xmlnestedset ".
1422 "WHERE ns_book_fk ".$in;
1426 $tag_fks[
$row->ns_tag_fk] =
$row->ns_tag_fk;
1428 $ilDB->query(
"DELETE FROM xmlnestedset WHERE ns_book_fk ".
$in);
1436 $ilDB->query(
"DELETE FROM xmlparam WHERE tag_fk ".
$in);
1437 $ilDB->query(
"DELETE FROM xmlvalue WHERE tag_fk ".
$in);
1438 $ilDB->query(
"DELETE FROM xmltags WHERE tag_pk ".
$in);
1440 #$ilBench->stop('NestedSet','deleteAllChildMetaData'); 1454 $query =
"SELECT obj_id FROM lm_data WHERE lm_id = ".$ilDB->quote($a_obj_id).
" ";
1460 $ids[$a_obj_id] = $a_obj_id;
1462 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
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
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
domxml_open_mem($str, $mode=0, &$error=NULL)
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