4 require_once
"./classes/class.ilXML2DOM.php";
95 $this->unique_import_id =
'';
97 $this->param_modifier =
"";
115 $this->lastTag =
$name;
117 $this->RIGHT = $this->LEFT + 1;
124 $nextId = $this->db->nextId(
'xmltags');
125 $this->db->manipulateF(
'INSERT INTO xmltags ( tag_pk,tag_name,tag_depth ) VALUES (%s,%s,%s)',
126 array(
'integer',
'text',
'integer'), array($nextId,
$name, $this->DEPTH));
129 $this->db->manipulateF(
'
130 UPDATE xmlnestedsettmp SET ns_r = ns_r+2
131 WHERE ns_r >= %s AND ns_book_fk = %s AND ns_unique_id = %s',
132 array(
'integer',
'integer',
'text'), array($this->LEFT, $this->obj_id, $this->unique_import_id));
134 $this->db->manipulateF(
'
135 INSERT INTO xmlnestedsettmp (ns_unique_id, ns_book_fk, ns_type, ns_tag_fk, ns_l, ns_r) VALUES (%s,%s,%s,%s,%s,%s)',
136 array(
'text',
'integer',
'text',
'integer',
'integer',
'integer'),
137 array($this->unique_import_id, $this->obj_id, $this->obj_type, $pk, $this->LEFT, $this->RIGHT));
139 $this->
clean($attrs);
140 if (is_array($attrs) && count($attrs)>0)
143 while (list ($key, $val) = each ($attrs))
145 $this->db->manipulateF(
'INSERT INTO xmlparam ( tag_fk,param_name,param_value ) VALUES (%s,%s,%s)',
146 array(
'integer',
'text',
'text'),
147 array($pk,$key,addslashes($val)));
163 function characterData($parser,
$data)
174 if(1 or trim(
$data)!=
"") {
177 if ($this->lastTag ==
"TAGVALUE")
179 $this->db->manipulateF(
'UPDATE xmlvalue SET tag_value = %s WHERE tag_value_pk = %s',
180 array(
'text',
'integer'), array(concat(tag_value,addslashes(
$data)),$value_pk));
184 $tag_pk = $this->
startElement($this->xml_parser,
"TAGVALUE",array());
185 $this->
endElement($this->xml_parser,
"TAGVALUE");
187 $nextId = $this->db->nextId(
'xmlvalue');
190 $this->db->manipulateF(
'INSERT INTO xmlvalue (tag_value_pk, tag_fk, tag_value) VALUES (%s,%s,%s)',
191 array(
'integer',
'integer',
'text'), array($nextId,$tag_pk,addslashes(
$data)));
195 $this->lastTag =
"TAGVALUE";
240 $this->unique_import_id = $ilUser->getId();
242 $this->db->manipulateF(
243 "DELETE FROM xmlnestedsettmp WHERE ns_unique_id = %s",
245 array($this->unique_import_id)
252 $this->xml_parser = xml_parser_create(
"UTF-8");
253 xml_parser_set_option($this->xml_parser, XML_OPTION_CASE_FOLDING,
false);
254 xml_set_object($this->xml_parser,$this);
255 xml_set_element_handler($this->xml_parser,
"startElement",
"endElement");
256 xml_set_character_data_handler($this->xml_parser,
"characterData");
258 if (!xml_parse($this->xml_parser, $xmldata)) {
259 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)));
261 xml_parser_free($this->xml_parser);
268 $this->db->manipulateF(
269 "INSERT INTO xmlnestedset (SELECT ns_book_fk, ns_type, ns_tag_fk, ns_l, ns_r FROM xmlnestedsettmp WHERE ns_unique_id = %s)",
271 array($this->unique_import_id)
274 $this->db->manipulateF(
275 "DELETE FROM xmlnestedsettmp WHERE ns_unique_id = %s",
277 array($this->unique_import_id)
289 $this->param_modifier =& $a_object;
290 $this->param_modifier_method = $a_method;
308 $result = $this->db->queryF(
'
309 SELECT * FROM xmlnestedset,xmltags
310 WHERE ns_tag_fk = tag_pk
314 array(
'integer',
'text'),
319 die($this->className.
"::checkTable(): ".$result->getMessage().
":<br>".$q);
325 while (is_array(
$row = $this->db->fetchAssoc($result)))
329 $Anfang =
"<".$row[tag_name];
331 $result_param = $this->db->queryF(
'SELECT * FROM xmlparam WHERE tag_fk = %s',array(
'integer'),array(
$row[tag_pk]));
332 while (is_array($row_param = $this->db->fetchAssoc($result_param)))
334 $param_value = $row_param[param_value];
335 if (is_object($this->param_modifier))
337 $obj =& $this->param_modifier;
338 $method = $this->param_modifier_method;
339 $param_value = $obj->$method(
$row[tag_name], $row_param[param_name], $param_value);
341 $Anfang .=
" ".$row_param[param_name].
"=\"".$param_value.
"\"";
345 $Ende =
"</".$row[tag_name].
">";
349 if (
$row[tag_name]==
"TAGVALUE")
351 $result_value = $this->db->queryF(
'SELECT * FROM xmlvalue WHERE tag_fk = %s', array(
'integer'),array(
$row[tag_pk]));
352 $row_value = $this->db->fetchAssoc($result_value);
354 $Anfang = $row_value[
"tag_value"];
357 $Anfang = htmlspecialchars($Anfang);
362 $D =
$row[tag_depth];
370 else if ($D>$lastDepth)
377 for ($i=$lastDepth;$i>=$D;$i--)
389 for ($i=$lastDepth;$i>0;$i--)
408 $this->db->setLimit(1);
410 $result = $this->db->queryF(
'
411 SELECT * FROM xmlnestedset,xmltags
412 WHERE ns_book_fk = %s
414 AND ns_tag_fk = tag_pk
416 array(
'integer',
'text'),
419 $row = $this->db->fetchAssoc($result);
421 $this->LEFT =
$row[
"ns_l"];
422 $this->RIGHT =
$row[
"ns_r"];
423 $this->DEPTH =
$row[
"tag_depth"];
439 $this->db->setLimit(1);
441 $result = $this->db->queryF(
'
442 SELECT * FROM xmlnestedset,xmltags
443 WHERE ns_book_fk = %s
447 AND ns_tag_fk = tag_pk',
448 array(
'integer',
'text',
'integer',
'integer'),
449 array($this->obj_id,$this->obj_type,$this->LEFT,$this->RIGHT));
451 $row = $this->db->fetchAssoc($result);
453 return(
$row[
"tag_name"]);
469 $this->db->setLimit(1);
471 $result = $this->db->queryF(
'
472 SELECT * FROM xmlnestedset
473 WHERE ns_book_fk = %s
477 array(
'integer',
'text',
'integer',
'integer'),
478 array($this->obj_id,$this->obj_type,$this->LEFT,$this->RIGHT));
480 $row = $this->db->fetchAssoc($result);
482 $this->db->manipulateF(
'UPDATE xmltags SET tag_name = %s WHERE tag_pk = %s',
483 array(
'text',
'integer'), array($tagName,
$row[
"ns_tag_fk"]));
486 return(
$row[
"tagName"]);
502 $result = $this->db->queryF(
'
503 SELECT * FROM xmlnestedset,xmltags
504 WHERE ns_tag_fk = tag_pk
511 array(
'integer',
'text',
'integer',
'integer',
'integer'),
512 array($this->obj_id,$this->obj_type,$this->LEFT,$this->RIGHT,$this->DEPTH+1));
514 while (is_array(
$row = $this->db->fetchAssoc($result) ) )
516 if (
$row[tag_name]==
"TAGVALUE")
518 $result2 = $this->db->queryF(
'SELECT * FROM xmlvalue WHERE tag_fk = %s', array(
'integer'),array(
$row[tag_pk]));
519 $row2 = $this->db->fetchAssoc($result2);
520 $V[] = $row2[tag_value];
524 $xml =
new ilNestedSetXml();
526 $xml->LEFT =
$row[
"ns_l"];
527 $xml->RIGHT =
$row[
"ns_r"];
528 $xml->DEPTH =
$row[
"tag_depth"];
551 $result = $this->db->queryF(
'
552 SELECT * FROM xmlnestedset,xmltags
553 LEFT JOIN xmlvalue ON xmltags.tag_pk = xmlvalue.tag_fk
554 WHERE ns_tag_fk = tag_pk
562 array(
'integer',
'text',
'integer',
'integer',
'integer',
'text'),
563 array($this->obj_id, $this->obj_type, $this->LEFT, $this->RIGHT, $this->DEPTH+1,
'TAGVALUE')
566 if (is_array(
$row = $this->db->fetchAssoc($result) ) )
568 $this->db->manipulateF(
'UPDATE xmlvalue SET tag_value = %s WHERE tag_value_pk = %s',
569 array(
'text',
'integer'), array($value,
$row[
"tag_value_pk"]));
595 $xpath = $doc->xpath_init();
596 $ctx = $doc->xpath_new_context();
598 $result = $ctx->xpath_eval($qry);
599 if (is_array($result->nodeset))
601 return($result->nodeset);
615 $xml = $this->
export($this->obj_id, $this->obj_type);
659 if (count($nodes) > 0)
661 $newDOM->insertNode($this->dom, $nodes[$index]);
682 if (is_object($this->dom))
687 if (is_object($node[0]))
689 $c = $node[0]->children();
691 if (is_object($c[0]))
693 $content = $c[0]->get_content();
718 if (strpos($index,
","))
720 $indices = explode(
",", $index);
722 if (count($nodes) > 0)
724 $children = $nodes[$indices[0]]->child_nodes();
725 if (count($children) > 0)
728 for ($i = 0; $i < count($children); $i++)
730 if ($children[$i]->node_name() ==
$name)
732 if ($j == $indices[1])
734 $children[$i]->unlink_node();
746 if (count($nodes) > 0)
748 $nodes[$index]->unlink_node();
770 if (count($nodes) > 0)
772 $node = $this->dom->create_element(
$name);
775 $node->set_content(utf8_encode($value));
777 if (is_array($attributes))
779 for ($i = 0; $i < count($attributes); $i++)
781 $node->set_attribute($attributes[$i][
"name"], utf8_encode($attributes[$i][
"value"]));
784 $nodes[$index]->append_child($node);
797 foreach($meta as $key => $value)
799 if(is_array($meta[$key]))
801 $this->
clean($meta[$key]);
806 $meta[$key] = preg_replace(
"/&(?!amp;|lt;|gt;|quot;)/",
"&",$meta[$key]);
807 $meta[$key] = preg_replace(
"/\"/",
""",$meta[$key]);
808 $meta[$key] = preg_replace(
"/</",
"<",$meta[$key]);
809 $meta[$key] = preg_replace(
"/>/",
">",$meta[$key]);
827 if ($xPath ==
"//Bibliography")
829 $nodes = $this->
getXpathNodes($this->dom, $xPath .
"/BibItem[" . ($no+1) .
"]");
835 if (count($nodes) > 0)
839 if ($nodes[0]->node_name() ==
"BibItem")
843 for ($i = 0; $i < count($meta[
"Language"]); $i++)
845 $xml .=
'<Language Language="' .
ilUtil::stripSlashes($meta[
"Language"][$i][
"Language"]) .
'"/>';
847 for ($i = 0; $i < count($meta[
"Author"]); $i++)
850 # for ($j = 0; $j < count($meta["Author"][$i]["FirstName"]); $j++)
852 $xml .=
'<FirstName>' .
ilUtil::stripSlashes($meta[
"Author"][$i][
"FirstName"]) .
'</FirstName>';
854 # for ($j = 0; $j < count($meta["Author"][$i]["MiddleName"]); $j++)
856 $xml .=
'<MiddleName>' .
ilUtil::stripSlashes($meta[
"Author"][$i][
"MiddleName"]) .
'</MiddleName>';
858 # for ($j = 0; $j < count($meta["Author"][$i]["LastName"]); $j++)
865 for ($i = 0; $i < count($meta[
"CrossRef"]); $i++)
870 for ($i = 0; $i < count($meta[
"Editor"]); $i++)
875 for ($i = 0; $i < count($meta[
"WherePublished"]); $i++)
877 $xml .=
'<WherePublished>' .
ilUtil::stripSlashes($meta[
"WherePublished"][$i][
"Value"]) .
'</WherePublished>';
879 for ($i = 0; $i < count($meta[
"Institution"]); $i++)
881 $xml .=
'<Institution>' .
ilUtil::stripSlashes($meta[
"Institution"][$i][
"Value"]) .
'</Institution>';
883 if (is_array($meta[
"Journal"]))
887 for ($i = 0; $i < count($meta[
"Keyword"]); $i++)
891 if (is_array($meta[
"Month"]))
895 if (is_array($meta[
"Pages"]))
900 for ($i = 0; $i < count($meta[
"School"]); $i++)
904 if (is_array($meta[
"Series"]))
907 $xml .=
'<SeriesTitle>' .
ilUtil::stripSlashes($meta[
"Series"][
"SeriesTitle"]) .
'</SeriesTitle>';
908 # for ($i = 0; $i < count($meta["Series"]["SeriesEditor"]); $i++)
909 if (isset($meta[
"Series"][
"SeriesEditor"]))
911 # $xml .= '<SeriesEditor>' . ilUtil::stripSlashes($meta["Series"]["SeriesEditor"][$i]) . '</SeriesEditor>';
912 $xml .=
'<SeriesEditor>' .
ilUtil::stripSlashes($meta[
"Series"][
"SeriesEditor"]) .
'</SeriesEditor>';
914 if (isset($meta[
"Series"][
"SeriesVolume"]))
916 $xml .=
'<SeriesVolume>' .
ilUtil::stripSlashes($meta[
"Series"][
"SeriesVolume"]) .
'</SeriesVolume>';
921 if ($meta[
"URL_ISBN_ISSN"][
"Type"] ==
"URL")
925 else if ($meta[
"URL_ISBN_ISSN"][
"Type"] ==
"ISBN")
929 else if ($meta[
"URL_ISBN_ISSN"][
"Type"] ==
"ISSN")
933 $xml .=
'</BibItem>';
934 # echo htmlspecialchars($xml);
940 else if ($nodes[0]->node_name() ==
"General")
944 for ($i = 0; $i < count($meta[
"Identifier"]); $i++)
946 $xml .=
'<Identifier Catalog="' .
ilUtil::stripSlashes($meta[
"Identifier"][$i][
"Catalog"]) .
'" Entry="' .
950 $xml .=
'<Title Language="' .
953 for ($i = 0; $i < count($meta[
"Language"]); $i++)
955 $xml .=
'<Language Language="' .
ilUtil::stripSlashes($meta[
"Language"][$i][
"Language"]) .
'"/>';
957 for ($i = 0; $i < count($meta[
"Description"]); $i++)
961 for ($i = 0; $i < count($meta[
"Keyword"]); $i++)
965 if ($meta[
"Coverage"] !=
"")
969 $xml .=
'</General>';
976 else if ($nodes[0]->node_name() ==
"Lifecycle")
978 $xml =
'<Lifecycle Status="' . $meta[
"Status"] .
'">';
980 for ($i = 0; $i < count($meta[
"Contribute"]); $i++)
984 for ($j = 0; $j < count($meta[
"Contribute"][$i][
"Entity"]); $j++)
988 $xml .=
'</Contribute>';
990 $xml .=
'</Lifecycle>';
991 # echo htmlspecialchars($xml);
997 else if ($nodes[0]->node_name() ==
"Meta-Metadata")
1000 $xml =
'<Meta-Metadata MetadataScheme="LOM v 1.0" Language="' .
ilUtil::stripSlashes($meta[
"Language"]) .
'">';
1001 for ($i = 0; $i < count($meta[
"Identifier"]); $i++)
1005 for ($i = 0; $i < count($meta[
"Contribute"]); $i++)
1009 for ($j = 0; $j < count($meta[
"Contribute"][$i][
"Entity"]); $j++)
1011 $xml .=
'<Entity>' .
ilUtil::stripSlashes($meta[
"Contribute"][$i][
"Entity"][$j]) .
'</Entity>';
1013 $xml .=
'</Contribute>';
1015 $xml .=
'</Meta-Metadata>';
1016 # echo htmlspecialchars($xml);
1022 else if ($nodes[0]->node_name() ==
"Technical")
1025 $xml =
'<Technical>';
1026 for ($i = 0; $i < count($meta[
"Format"]); $i++)
1030 if ($meta[
"Size"] !=
"")
1034 for ($i = 0; $i < count($meta[
"Location"]); $i++)
1038 if (is_array($meta[
"Requirement"]))
1040 for ($i = 0; $i < count($meta[
"Requirement"]); $i++)
1042 $xml .=
'<Requirement>';
1044 if (is_array($meta[
"Requirement"][$i][
"Type"][
"OperatingSystem"]))
1046 $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"])) .
'"/>';
1048 if (is_array($meta[
"Requirement"][$i][
"Type"][
"Browser"]))
1050 $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"])) .
'"/>';
1053 $xml .=
'</Requirement>';
1056 else if (is_array($meta[
"OrComposite"]))
1058 for ($j = 0; $j < count($meta[
"OrComposite"]); $j++)
1060 $xml .=
'<OrComposite>';
1061 for ($i = 0; $i < count($meta[
"OrComposite"][$j][
"Requirement"]); $i++)
1063 $xml .=
'<Requirement>';
1065 if (is_array($meta[
"OrComposite"][$j][
"Requirement"][$i][
"Type"][
"OperatingSystem"]))
1067 $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"])) .
'"/>';
1069 if (is_array($meta[
"OrComposite"][$j][
"Requirement"][$i][
"Type"][
"Browser"]))
1071 $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"])) .
'"/>';
1074 $xml .=
'</Requirement>';
1076 $xml .=
'</OrComposite>';
1079 if (is_array($meta[
"InstallationRemarks"]))
1081 $xml .=
'<InstallationRemarks Language="' .
ilUtil::stripSlashes($meta[
"InstallationRemarks"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"InstallationRemarks"][
"Value"]) .
'</InstallationRemarks>';
1083 if (is_array($meta[
"OtherPlattformRequirements"]))
1085 $xml .=
'<OtherPlattformRequirements Language="' .
ilUtil::stripSlashes($meta[
"OtherPlattformRequirements"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"OtherPlattformRequirements"][
"Value"]) .
'</OtherPlattformRequirements>';
1087 if ($meta[
"Duration"] !=
"")
1091 $xml .=
'</Technical>';
1092 # echo htmlspecialchars($xml);
1098 else if ($nodes[0]->node_name() ==
"Educational")
1102 $xml .=
'<TypicalLearningTime>' .
ilUtil::stripSlashes($meta[
"TypicalLearningTime"]) .
'</TypicalLearningTime>';
1103 for ($i = 0; $i < count($meta[
"TypicalAgeRange"]); $i++)
1105 $xml .=
'<TypicalAgeRange Language="' .
ilUtil::stripSlashes($meta[
"TypicalAgeRange"][$i][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"TypicalAgeRange"][$i][
"Value"]) .
'</TypicalAgeRange>';
1107 for ($i = 0; $i < count($meta[
"Description"]); $i++)
1111 for ($i = 0; $i < count($meta[
"Language"]); $i++)
1113 $xml .=
'<Language Language="' .
ilUtil::stripSlashes($meta[
"Language"][$i][
"Language"]) .
'"/>';
1115 $xml .=
'</Educational>';
1121 else if ($nodes[0]->node_name() ==
"Rights")
1125 for ($i = 0; $i < count($meta[
"Description"]); $i++)
1129 $xml .=
'</Rights>';
1135 else if ($nodes[0]->node_name() ==
"Relation")
1138 # for ($j = 0; $j < count($meta["Relation"]); $j++)
1140 $meta[
"Relation"][0] = $meta;
1143 $xml .=
'<Resource>';
1144 for ($i = 0; $i < count($meta[
"Relation"][$j][
"Resource"][
"Identifier"]); $i++)
1146 $xml .=
'<Identifier_ Catalog="' .
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Identifier"][$i][
"Catalog"]) .
'" Entry="' . str_replace(
"\"",
"",
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Identifier"][$i][
"Entry"])) .
'"/>';
1148 for ($i = 0; $i < count($meta[
"Relation"][$j][
"Resource"][
"Description"]); $i++)
1150 $xml .=
'<Description Language="' .
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Description"][$i][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Description"][$i][
"Value"]) .
'</Description>';
1152 $xml .=
'</Resource>';
1153 $xml .=
'</Relation>';
1154 # echo htmlspecialchars($xml);
1161 else if ($nodes[0]->node_name() ==
"Annotation")
1164 # for ($i = 0; $i < count($meta["Annotation"]); $i++)
1166 $meta[
"Annotation"][0] = $meta;
1168 $xml =
'<Annotation>';
1171 $xml .=
'<Description Language="' .
ilUtil::stripSlashes($meta[
"Annotation"][$i][
"Description"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Annotation"][$i][
"Description"][
"Value"]) .
'</Description>';
1172 $xml .=
'</Annotation>';
1173 # echo htmlspecialchars($xml);
1180 else if ($nodes[0]->node_name() ==
"Classification")
1183 # for ($j = 0; $j < count($meta["Classification"]); $j++)
1185 $meta[
"Classification"][0] = $meta;
1187 $xml =
'<Classification Purpose="' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Purpose"]) .
'">';
1188 for ($k = 0; $k < count($meta[
"Classification"][$j][
"TaxonPath"]); $k++)
1190 $xml .=
'<TaxonPath>';
1191 $xml .=
'<Source Language="' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"TaxonPath"][$k][
"Source"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"TaxonPath"][$k][
"Source"][
"Value"]) .
'</Source>';
1192 for ($i = 0; $i < count($meta[
"Classification"][$j][
"TaxonPath"][$k][
"Taxon"]); $i++)
1194 $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>';
1196 $xml .=
'</TaxonPath>';
1198 $xml .=
'<Description Language="' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Description"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Description"][
"Value"]) .
'</Description>';
1199 for ($i = 0; $i < count($meta[
"Classification"][$j][
"Keyword"]); $i++)
1201 $xml .=
'<Keyword Language="' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Keyword"][$i][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Keyword"][$i][
"Value"]) .
'</Keyword>';
1203 $xml .=
'</Classification>';
1204 # echo htmlspecialchars($xml);
1212 $nodes[0]->unlink_node();
1214 if ($xPath !=
"//Bibliography")
1216 $xPath =
"//MetaData";
1246 # echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n";
1248 if (count($nodes) > 0)
1250 $children = $nodes[$index]->child_nodes();
1251 if (count($children) > 0)
1254 for ($i = 0; $i < count($children); $i++)
1258 $children[$i]->node_name() ==
$name)
1260 $content[$k][
"value"] = $children[$i]->get_content();
1261 $a = $children[$i]->attributes();
1262 for ($j = 0; $j < count($a); $j++)
1264 $content[$k][$a[$j]->name()] = $a[$j]->value();
1286 # echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n";
1288 if (count($nodes) > 0)
1290 $children = $nodes[$index]->child_nodes();
1291 if (count($children) > 0)
1293 for ($i = 0; $i < count($children); $i++)
1295 if ($children[$i]->node_name() ==
$name &&
1298 foreach ($newNode as $key => $val)
1300 if ($key ==
"value")
1306 $children[$i]->set_attribute($key, $val);
1327 $newnode =& $this->dom->create_element( $node->tagname() );
1328 $newnode->set_content( $new_content );
1329 $atts =& $node->attributes();
1330 foreach ( $atts as $att )
1332 $newnode->set_attribute( $att->name(), $att->value() );
1334 $kids =& $node->child_nodes();
1335 foreach ( $kids as $kid )
1337 if ( $kid->node_type() != XML_TEXT_NODE )
1339 $newnode->append_child( $kid );
1342 $node->replace_node( $newnode );
1357 if (count($nodes) > 0)
1359 $children = $nodes[$index]->child_nodes();
1360 if (count($children) > 0)
1362 for ($i = 0; $i < count($children); $i++)
1364 if ($children[$i]->node_name() ==
$name &&
1367 foreach ($newNode as $key => $val)
1369 if ($key ==
"value")
1371 $children[$i]->set_content($val);
1375 $children[$i]->set_attribute($key, $val);
1404 $xml = $this->dom->dump_mem(0);
1417 #$ilBench->start('NestedSet','deleteAllDBData');
1418 $res = $this->db->queryF(
'
1419 SELECT * FROM xmlnestedset WHERE ns_book_fk = %s AND ns_type = %s ',
1420 array(
'integer',
'text'), array($this->obj_id,$this->obj_type));
1422 while (
$row = $this->db->fetchAssoc(
$res))
1424 $this->db->manipulateF(
'DELETE FROM xmlparam WHERE tag_fk = %s',array(
'integer'), array(
$row[
"ns_tag_fk"]));
1425 $this->db->manipulateF(
'DELETE FROM xmlvalue WHERE tag_fk = %s',array(
'integer'), array(
$row[
"ns_tag_fk"]));
1426 $this->db->manipulateF(
'DELETE FROM xmltags WHERE tag_pk = %s',array(
'integer'), array(
$row[
"ns_tag_fk"]));
1428 $this->db->manipulateF(
'DELETE FROM xmlnestedset WHERE ns_book_fk = %s AND ns_type = %s',
1429 array(
'integer',
'text'), array($this->obj_id,$this->obj_type));
1430 #$ilBench->stop('NestedSet','deleteAllDBData');
1445 #$ilBench->start('NestedSet','deleteAllChildMetaData');
1449 $in .= implode(
"','", $a_ids);
1452 $query =
"SELECT ns_tag_fk FROM xmlnestedset ".
1453 "WHERE ns_book_fk ".$in;
1455 while(
$row = $ilDB->fetchObject(
$res))
1457 $tag_fks[
$row->ns_tag_fk] =
$row->ns_tag_fk;
1459 $ilDB->manipulate(
"DELETE FROM xmlnestedset WHERE ns_book_fk ".
$in);
1464 if ($tag_fks != null)
1467 $in .= implode(
"','", $tag_fks);
1470 $ilDB->manipulate(
"DELETE FROM xmlparam WHERE tag_fk ".
$in);
1471 $ilDB->manipulate(
"DELETE FROM xmlvalue WHERE tag_fk ".
$in);
1472 $ilDB->manipulate(
"DELETE FROM xmltags WHERE tag_pk ".
$in);
1476 #$ilBench->stop('NestedSet','deleteAllChildMetaData');
1490 $res = $ilDB->queryF(
'SELECT obj_id FROM lm_data WHERE lm_id = %s',array(
'integer'),array($a_obj_id));
1491 while(
$row = $ilDB->fetchObject(
$res))
1495 $ids[$a_obj_id] = $a_obj_id;
1497 return $ids ? $ids : array();