4 require_once
"./Services/Xml/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 $id = $this->db->nextId(
'xmlnestedsettmp');
136 $this->db->manipulateF(
' 137 INSERT INTO xmlnestedsettmp (ns_id, ns_unique_id, ns_book_fk, ns_type, ns_tag_fk, ns_l, ns_r) VALUES (%s,%s,%s,%s,%s,%s,%s)',
138 array(
'integer',
'text',
'integer',
'text',
'integer',
'integer',
'integer'),
139 array($id, $this->unique_import_id, $this->obj_id, $this->obj_type, $pk, $this->LEFT, $this->RIGHT));
141 $this->
clean($attrs);
142 if (is_array($attrs) && count($attrs)>0)
145 while (list ($key, $val) = each ($attrs))
147 $this->db->manipulateF(
'INSERT INTO xmlparam ( tag_fk,param_name,param_value ) VALUES (%s,%s,%s)',
148 array(
'integer',
'text',
'text'),
149 array($pk,$key,addslashes($val)));
165 function characterData($parser,
$data)
176 if(1 or trim(
$data)!=
"") {
179 if ($this->lastTag ==
"TAGVALUE")
181 $this->db->manipulateF(
'UPDATE xmlvalue SET tag_value = %s WHERE tag_value_pk = %s',
182 array(
'text',
'integer'), array(concat(tag_value,addslashes(
$data)),$value_pk));
186 $tag_pk = $this->
startElement($this->xml_parser,
"TAGVALUE",array());
187 $this->
endElement($this->xml_parser,
"TAGVALUE");
189 $nextId = $this->db->nextId(
'xmlvalue');
192 $this->db->manipulateF(
'INSERT INTO xmlvalue (tag_value_pk, tag_fk, tag_value) VALUES (%s,%s,%s)',
193 array(
'integer',
'integer',
'text'), array($nextId,$tag_pk,addslashes(
$data)));
197 $this->lastTag =
"TAGVALUE";
242 $this->unique_import_id = $ilUser->getId();
244 $this->db->manipulateF(
245 "DELETE FROM xmlnestedsettmp WHERE ns_unique_id = %s",
247 array($this->unique_import_id)
254 $this->xml_parser = xml_parser_create(
"UTF-8");
255 xml_parser_set_option($this->xml_parser, XML_OPTION_CASE_FOLDING,
false);
256 xml_set_object($this->xml_parser,$this);
257 xml_set_element_handler($this->xml_parser,
"startElement",
"endElement");
258 xml_set_character_data_handler($this->xml_parser,
"characterData");
260 if (!xml_parse($this->xml_parser, $xmldata)) {
261 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)));
263 xml_parser_free($this->xml_parser);
270 $res = $this->db->query(
" 271 SELECT ns_book_fk, ns_type, ns_tag_fk, ns_l, ns_r 274 " . $this->db->quote($this->unique_import_id,
"text"));
276 while(
$row = $this->db->fetchAssoc(
$res))
278 $id = $this->db->nextId(
'xmlnestedset');
280 $this->db->manipulate(
"INSERT INTO xmlnestedset (ns_id, ns_book_fk, ns_type, ns_tag_fk, ns_l, ns_r)".
282 $this->db->quote($id,
"integer").
283 ",".$this->db->quote(
$row[
'ns_book_fk'],
"integer").
284 ",".$this->db->quote(
$row[
'ns_type'],
"text").
285 ",".$this->db->quote(
$row[
'ns_tag_fk'],
"integer").
286 ",".$this->db->quote(
$row[
'ns_l'],
"integer").
287 ",".$this->db->quote(
$row[
'ns_r'],
"integer").
297 $this->db->manipulateF(
298 "DELETE FROM xmlnestedsettmp WHERE ns_unique_id = %s",
300 array($this->unique_import_id)
312 $this->param_modifier =& $a_object;
313 $this->param_modifier_method = $a_method;
332 SELECT * FROM xmlnestedset,xmltags 333 WHERE ns_tag_fk = tag_pk 337 array(
'integer',
'text'),
338 array($obj_id,$type));
342 die($this->className.
"::checkTable(): ".
$result->getMessage().
":<br>".$q);
348 while (is_array(
$row = $this->db->fetchAssoc(
$result)))
352 $Anfang =
"<".$row[tag_name];
354 $result_param = $this->db->queryF(
'SELECT * FROM xmlparam WHERE tag_fk = %s',array(
'integer'),array(
$row[tag_pk]));
355 while (is_array($row_param = $this->db->fetchAssoc($result_param)))
357 $param_value = $row_param[param_value];
358 if (is_object($this->param_modifier))
360 $obj =& $this->param_modifier;
361 $method = $this->param_modifier_method;
362 $param_value = $obj->$method(
$row[tag_name], $row_param[param_name], $param_value);
364 $Anfang .=
" ".$row_param[param_name].
"=\"".$param_value.
"\"";
368 $Ende =
"</".$row[tag_name].
">";
372 if (
$row[tag_name]==
"TAGVALUE")
374 $result_value = $this->db->queryF(
'SELECT * FROM xmlvalue WHERE tag_fk = %s', array(
'integer'),array(
$row[tag_pk]));
375 $row_value = $this->db->fetchAssoc($result_value);
377 $Anfang = $row_value[
"tag_value"];
380 $Anfang = htmlspecialchars($Anfang);
385 $D =
$row[tag_depth];
393 else if ($D>$lastDepth)
400 for ($i=$lastDepth;$i>=$D;$i--)
412 for ($i=$lastDepth;$i>0;$i--)
428 function init($obj_id,$obj_type)
431 $this->db->setLimit(1);
434 SELECT * FROM xmlnestedset,xmltags 435 WHERE ns_book_fk = %s 437 AND ns_tag_fk = tag_pk 439 array(
'integer',
'text'),
440 array($obj_id, $obj_type));
444 $this->LEFT =
$row[
"ns_l"];
445 $this->RIGHT =
$row[
"ns_r"];
446 $this->DEPTH =
$row[
"tag_depth"];
462 $this->db->setLimit(1);
465 SELECT * FROM xmlnestedset,xmltags 466 WHERE ns_book_fk = %s 470 AND ns_tag_fk = tag_pk',
471 array(
'integer',
'text',
'integer',
'integer'),
472 array($this->obj_id,$this->obj_type,$this->LEFT,$this->RIGHT));
476 return(
$row[
"tag_name"]);
492 $this->db->setLimit(1);
495 SELECT * FROM xmlnestedset 496 WHERE ns_book_fk = %s 500 array(
'integer',
'text',
'integer',
'integer'),
501 array($this->obj_id,$this->obj_type,$this->LEFT,$this->RIGHT));
505 $this->db->manipulateF(
'UPDATE xmltags SET tag_name = %s WHERE tag_pk = %s',
506 array(
'text',
'integer'), array($tagName,
$row[
"ns_tag_fk"]));
509 return(
$row[
"tagName"]);
526 SELECT * FROM xmlnestedset,xmltags 527 WHERE ns_tag_fk = tag_pk 534 array(
'integer',
'text',
'integer',
'integer',
'integer'),
535 array($this->obj_id,$this->obj_type,$this->LEFT,$this->RIGHT,$this->DEPTH+1));
537 while (is_array(
$row = $this->db->fetchAssoc(
$result) ) )
539 if (
$row[tag_name]==
"TAGVALUE")
541 $result2 = $this->db->queryF(
'SELECT * FROM xmlvalue WHERE tag_fk = %s', array(
'integer'),array(
$row[tag_pk]));
542 $row2 = $this->db->fetchAssoc($result2);
543 $V[] = $row2[tag_value];
547 $xml =
new ilNestedSetXml();
549 $xml->LEFT =
$row[
"ns_l"];
550 $xml->RIGHT =
$row[
"ns_r"];
551 $xml->DEPTH =
$row[
"tag_depth"];
575 SELECT * FROM xmlnestedset,xmltags 576 LEFT JOIN xmlvalue ON xmltags.tag_pk = xmlvalue.tag_fk 577 WHERE ns_tag_fk = tag_pk 585 array(
'integer',
'text',
'integer',
'integer',
'integer',
'text'),
586 array($this->obj_id, $this->obj_type, $this->LEFT, $this->RIGHT, $this->DEPTH+1,
'TAGVALUE')
589 if (is_array(
$row = $this->db->fetchAssoc(
$result) ) )
591 $this->db->manipulateF(
'UPDATE xmlvalue SET tag_value = %s WHERE tag_value_pk = %s',
592 array(
'text',
'integer'), array($value,
$row[
"tag_value_pk"]));
618 $xpath = $doc->xpath_init();
619 $ctx = $doc->xpath_new_context();
621 $result = $ctx->xpath_eval($qry);
622 if (is_array(
$result->nodeset))
638 $xml = $this->
export($this->obj_id, $this->obj_type);
682 if (count($nodes) > 0)
684 $newDOM->insertNode($this->dom, $nodes[$index]);
705 if (is_object($this->dom))
710 if (is_object($node[0]))
712 $c = $node[0]->children();
714 if (is_object($c[0]))
716 $content = $c[0]->get_content();
741 if (strpos($index,
","))
743 $indices = explode(
",", $index);
745 if (count($nodes) > 0)
747 $children = $nodes[$indices[0]]->child_nodes();
748 if (count($children) > 0)
751 for ($i = 0; $i < count($children); $i++)
753 if ($children[$i]->node_name() == $name)
755 if ($j == $indices[1])
757 $children[$i]->unlink_node();
768 $nodes = $this->
getXpathNodes($this->dom, $xPath .
"/" . $name);
769 if (count($nodes) > 0)
771 $nodes[$index]->unlink_node();
790 function addDomNode($xPath, $name, $value =
"", $attributes =
"", $index = 0)
793 if (count($nodes) > 0)
795 $node = $this->dom->create_element($name);
798 $node->set_content(utf8_encode($value));
800 if (is_array($attributes))
802 for ($i = 0; $i < count($attributes); $i++)
804 $node->set_attribute($attributes[$i][
"name"], utf8_encode($attributes[$i][
"value"]));
807 $nodes[$index]->append_child($node);
820 foreach($meta as $key => $value)
822 if(is_array($meta[$key]))
824 $this->
clean($meta[$key]);
829 $meta[$key] = preg_replace(
"/&(?!amp;|lt;|gt;|quot;)/",
"&",$meta[$key]);
830 $meta[$key] = preg_replace(
"/\"/",
""",$meta[$key]);
831 $meta[$key] = preg_replace(
"/</",
"<",$meta[$key]);
832 $meta[$key] = preg_replace(
"/>/",
">",$meta[$key]);
850 if ($xPath ==
"//Bibliography")
852 $nodes = $this->
getXpathNodes($this->dom, $xPath .
"/BibItem[" . ($no+1) .
"]");
858 if (count($nodes) > 0)
862 if ($nodes[0]->node_name() ==
"BibItem")
866 for ($i = 0; $i < count($meta[
"Language"]); $i++)
868 $xml .=
'<Language Language="' .
ilUtil::stripSlashes($meta[
"Language"][$i][
"Language"]) .
'"/>';
870 for ($i = 0; $i < count($meta[
"Author"]); $i++)
873 # for ($j = 0; $j < count($meta["Author"][$i]["FirstName"]); $j++) 875 $xml .=
'<FirstName>' .
ilUtil::stripSlashes($meta[
"Author"][$i][
"FirstName"]) .
'</FirstName>';
877 # for ($j = 0; $j < count($meta["Author"][$i]["MiddleName"]); $j++) 879 $xml .=
'<MiddleName>' .
ilUtil::stripSlashes($meta[
"Author"][$i][
"MiddleName"]) .
'</MiddleName>';
881 # for ($j = 0; $j < count($meta["Author"][$i]["LastName"]); $j++) 888 for ($i = 0; $i < count($meta[
"CrossRef"]); $i++)
893 for ($i = 0; $i < count($meta[
"Editor"]); $i++)
898 for ($i = 0; $i < count($meta[
"WherePublished"]); $i++)
900 $xml .=
'<WherePublished>' .
ilUtil::stripSlashes($meta[
"WherePublished"][$i][
"Value"]) .
'</WherePublished>';
902 for ($i = 0; $i < count($meta[
"Institution"]); $i++)
904 $xml .=
'<Institution>' .
ilUtil::stripSlashes($meta[
"Institution"][$i][
"Value"]) .
'</Institution>';
906 if (is_array($meta[
"Journal"]))
910 for ($i = 0; $i < count($meta[
"Keyword"]); $i++)
914 if (is_array($meta[
"Month"]))
918 if (is_array($meta[
"Pages"]))
923 for ($i = 0; $i < count($meta[
"School"]); $i++)
927 if (is_array($meta[
"Series"]))
930 $xml .=
'<SeriesTitle>' .
ilUtil::stripSlashes($meta[
"Series"][
"SeriesTitle"]) .
'</SeriesTitle>';
931 # for ($i = 0; $i < count($meta["Series"]["SeriesEditor"]); $i++) 932 if (isset($meta[
"Series"][
"SeriesEditor"]))
934 # $xml .= '<SeriesEditor>' . ilUtil::stripSlashes($meta["Series"]["SeriesEditor"][$i]) . '</SeriesEditor>'; 935 $xml .=
'<SeriesEditor>' .
ilUtil::stripSlashes($meta[
"Series"][
"SeriesEditor"]) .
'</SeriesEditor>';
937 if (isset($meta[
"Series"][
"SeriesVolume"]))
939 $xml .=
'<SeriesVolume>' .
ilUtil::stripSlashes($meta[
"Series"][
"SeriesVolume"]) .
'</SeriesVolume>';
944 if ($meta[
"URL_ISBN_ISSN"][
"Type"] ==
"URL")
948 else if ($meta[
"URL_ISBN_ISSN"][
"Type"] ==
"ISBN")
952 else if ($meta[
"URL_ISBN_ISSN"][
"Type"] ==
"ISSN")
956 $xml .=
'</BibItem>';
957 # echo htmlspecialchars($xml); 963 else if ($nodes[0]->node_name() ==
"General")
967 for ($i = 0; $i < count($meta[
"Identifier"]); $i++)
969 $xml .=
'<Identifier Catalog="' .
ilUtil::stripSlashes($meta[
"Identifier"][$i][
"Catalog"]) .
'" Entry="' .
973 $xml .=
'<Title Language="' .
976 for ($i = 0; $i < count($meta[
"Language"]); $i++)
978 $xml .=
'<Language Language="' .
ilUtil::stripSlashes($meta[
"Language"][$i][
"Language"]) .
'"/>';
980 for ($i = 0; $i < count($meta[
"Description"]); $i++)
984 for ($i = 0; $i < count($meta[
"Keyword"]); $i++)
988 if ($meta[
"Coverage"] !=
"")
992 $xml .=
'</General>';
999 else if ($nodes[0]->node_name() ==
"Lifecycle")
1001 $xml =
'<Lifecycle Status="' . $meta[
"Status"] .
'">';
1003 for ($i = 0; $i < count($meta[
"Contribute"]); $i++)
1007 for ($j = 0; $j < count($meta[
"Contribute"][$i][
"Entity"]); $j++)
1009 $xml .=
'<Entity>' .
ilUtil::stripSlashes($meta[
"Contribute"][$i][
"Entity"][$j]) .
'</Entity>';
1011 $xml .=
'</Contribute>';
1013 $xml .=
'</Lifecycle>';
1014 # echo htmlspecialchars($xml); 1020 else if ($nodes[0]->node_name() ==
"Meta-Metadata")
1023 $xml =
'<Meta-Metadata MetadataScheme="LOM v 1.0" Language="' .
ilUtil::stripSlashes($meta[
"Language"]) .
'">';
1024 for ($i = 0; $i < count($meta[
"Identifier"]); $i++)
1028 for ($i = 0; $i < count($meta[
"Contribute"]); $i++)
1032 for ($j = 0; $j < count($meta[
"Contribute"][$i][
"Entity"]); $j++)
1034 $xml .=
'<Entity>' .
ilUtil::stripSlashes($meta[
"Contribute"][$i][
"Entity"][$j]) .
'</Entity>';
1036 $xml .=
'</Contribute>';
1038 $xml .=
'</Meta-Metadata>';
1039 # echo htmlspecialchars($xml); 1045 else if ($nodes[0]->node_name() ==
"Technical")
1048 $xml =
'<Technical>';
1049 for ($i = 0; $i < count($meta[
"Format"]); $i++)
1053 if ($meta[
"Size"] !=
"")
1057 for ($i = 0; $i < count($meta[
"Location"]); $i++)
1061 if (is_array($meta[
"Requirement"]))
1063 for ($i = 0; $i < count($meta[
"Requirement"]); $i++)
1065 $xml .=
'<Requirement>';
1067 if (is_array($meta[
"Requirement"][$i][
"Type"][
"OperatingSystem"]))
1069 $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"])) .
'"/>';
1071 if (is_array($meta[
"Requirement"][$i][
"Type"][
"Browser"]))
1073 $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"])) .
'"/>';
1076 $xml .=
'</Requirement>';
1079 else if (is_array($meta[
"OrComposite"]))
1081 for ($j = 0; $j < count($meta[
"OrComposite"]); $j++)
1083 $xml .=
'<OrComposite>';
1084 for ($i = 0; $i < count($meta[
"OrComposite"][$j][
"Requirement"]); $i++)
1086 $xml .=
'<Requirement>';
1088 if (is_array($meta[
"OrComposite"][$j][
"Requirement"][$i][
"Type"][
"OperatingSystem"]))
1090 $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"])) .
'"/>';
1092 if (is_array($meta[
"OrComposite"][$j][
"Requirement"][$i][
"Type"][
"Browser"]))
1094 $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"])) .
'"/>';
1097 $xml .=
'</Requirement>';
1099 $xml .=
'</OrComposite>';
1102 if (is_array($meta[
"InstallationRemarks"]))
1104 $xml .=
'<InstallationRemarks Language="' .
ilUtil::stripSlashes($meta[
"InstallationRemarks"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"InstallationRemarks"][
"Value"]) .
'</InstallationRemarks>';
1106 if (is_array($meta[
"OtherPlattformRequirements"]))
1108 $xml .=
'<OtherPlattformRequirements Language="' .
ilUtil::stripSlashes($meta[
"OtherPlattformRequirements"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"OtherPlattformRequirements"][
"Value"]) .
'</OtherPlattformRequirements>';
1110 if ($meta[
"Duration"] !=
"")
1114 $xml .=
'</Technical>';
1115 # echo htmlspecialchars($xml); 1121 else if ($nodes[0]->node_name() ==
"Educational")
1125 $xml .=
'<TypicalLearningTime>' .
ilUtil::stripSlashes($meta[
"TypicalLearningTime"]) .
'</TypicalLearningTime>';
1126 for ($i = 0; $i < count($meta[
"TypicalAgeRange"]); $i++)
1128 $xml .=
'<TypicalAgeRange Language="' .
ilUtil::stripSlashes($meta[
"TypicalAgeRange"][$i][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"TypicalAgeRange"][$i][
"Value"]) .
'</TypicalAgeRange>';
1130 for ($i = 0; $i < count($meta[
"Description"]); $i++)
1134 for ($i = 0; $i < count($meta[
"Language"]); $i++)
1136 $xml .=
'<Language Language="' .
ilUtil::stripSlashes($meta[
"Language"][$i][
"Language"]) .
'"/>';
1138 $xml .=
'</Educational>';
1144 else if ($nodes[0]->node_name() ==
"Rights")
1148 for ($i = 0; $i < count($meta[
"Description"]); $i++)
1152 $xml .=
'</Rights>';
1158 else if ($nodes[0]->node_name() ==
"Relation")
1161 # for ($j = 0; $j < count($meta["Relation"]); $j++) 1163 $meta[
"Relation"][0] = $meta;
1166 $xml .=
'<Resource>';
1167 for ($i = 0; $i < count($meta[
"Relation"][$j][
"Resource"][
"Identifier"]); $i++)
1169 $xml .=
'<Identifier_ Catalog="' .
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Identifier"][$i][
"Catalog"]) .
'" Entry="' . str_replace(
"\"",
"",
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Identifier"][$i][
"Entry"])) .
'"/>';
1171 for ($i = 0; $i < count($meta[
"Relation"][$j][
"Resource"][
"Description"]); $i++)
1173 $xml .=
'<Description Language="' .
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Description"][$i][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Relation"][$j][
"Resource"][
"Description"][$i][
"Value"]) .
'</Description>';
1175 $xml .=
'</Resource>';
1176 $xml .=
'</Relation>';
1177 # echo htmlspecialchars($xml); 1184 else if ($nodes[0]->node_name() ==
"Annotation")
1187 # for ($i = 0; $i < count($meta["Annotation"]); $i++) 1189 $meta[
"Annotation"][0] = $meta;
1191 $xml =
'<Annotation>';
1194 $xml .=
'<Description Language="' .
ilUtil::stripSlashes($meta[
"Annotation"][$i][
"Description"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Annotation"][$i][
"Description"][
"Value"]) .
'</Description>';
1195 $xml .=
'</Annotation>';
1196 # echo htmlspecialchars($xml); 1203 else if ($nodes[0]->node_name() ==
"Classification")
1206 # for ($j = 0; $j < count($meta["Classification"]); $j++) 1208 $meta[
"Classification"][0] = $meta;
1210 $xml =
'<Classification Purpose="' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Purpose"]) .
'">';
1211 for ($k = 0; $k < count($meta[
"Classification"][$j][
"TaxonPath"]); $k++)
1213 $xml .=
'<TaxonPath>';
1214 $xml .=
'<Source Language="' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"TaxonPath"][$k][
"Source"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"TaxonPath"][$k][
"Source"][
"Value"]) .
'</Source>';
1215 for ($i = 0; $i < count($meta[
"Classification"][$j][
"TaxonPath"][$k][
"Taxon"]); $i++)
1217 $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>';
1219 $xml .=
'</TaxonPath>';
1221 $xml .=
'<Description Language="' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Description"][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Description"][
"Value"]) .
'</Description>';
1222 for ($i = 0; $i < count($meta[
"Classification"][$j][
"Keyword"]); $i++)
1224 $xml .=
'<Keyword Language="' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Keyword"][$i][
"Language"]) .
'">' .
ilUtil::stripSlashes($meta[
"Classification"][$j][
"Keyword"][$i][
"Value"]) .
'</Keyword>';
1226 $xml .=
'</Classification>';
1227 # echo htmlspecialchars($xml); 1235 $nodes[0]->unlink_node();
1237 if ($xPath !=
"//Bibliography")
1239 $xPath =
"//MetaData";
1269 # echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n"; 1271 if (count($nodes) > 0)
1273 $children = $nodes[$index]->child_nodes();
1274 if (count($children) > 0)
1277 for ($i = 0; $i < count($children); $i++)
1281 $children[$i]->node_name() == $name)
1283 $content[$k][
"value"] = $children[$i]->get_content();
1284 $a = $children[$i]->attributes();
1285 for ($j = 0; $j < count($a); $j++)
1287 $content[$k][$a[$j]->name()] = $a[$j]->value();
1309 # echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n"; 1311 if (count($nodes) > 0)
1313 $children = $nodes[$index]->child_nodes();
1314 if (count($children) > 0)
1316 for ($i = 0; $i < count($children); $i++)
1318 if ($children[$i]->node_name() == $name &&
1321 foreach ($newNode as $key => $val)
1323 if ($key ==
"value")
1329 $children[$i]->set_attribute($key, $val);
1350 $newnode =& $this->dom->create_element( $node->tagname() );
1351 $newnode->set_content( $new_content );
1352 $atts =& $node->attributes();
1353 foreach ( $atts as $att )
1355 $newnode->set_attribute( $att->name(), $att->value() );
1357 $kids =& $node->child_nodes();
1358 foreach ( $kids as $kid )
1360 if ( $kid->node_type() != XML_TEXT_NODE )
1362 $newnode->append_child( $kid );
1365 $node->replace_node( $newnode );
1380 if (count($nodes) > 0)
1382 $children = $nodes[$index]->child_nodes();
1383 if (count($children) > 0)
1385 for ($i = 0; $i < count($children); $i++)
1387 if ($children[$i]->node_name() == $name &&
1390 foreach ($newNode as $key => $val)
1392 if ($key ==
"value")
1394 $children[$i]->set_content($val);
1398 $children[$i]->set_attribute($key, $val);
1427 $xml = $this->dom->dump_mem(0);
1440 #$ilBench->start('NestedSet','deleteAllDBData'); 1441 $res = $this->db->queryF(
' 1442 SELECT * FROM xmlnestedset WHERE ns_book_fk = %s AND ns_type = %s ',
1443 array(
'integer',
'text'), array($this->obj_id,$this->obj_type));
1445 while (
$row = $this->db->fetchAssoc(
$res))
1447 $this->db->manipulateF(
'DELETE FROM xmlparam WHERE tag_fk = %s',array(
'integer'), array(
$row[
"ns_tag_fk"]));
1448 $this->db->manipulateF(
'DELETE FROM xmlvalue WHERE tag_fk = %s',array(
'integer'), array(
$row[
"ns_tag_fk"]));
1449 $this->db->manipulateF(
'DELETE FROM xmltags WHERE tag_pk = %s',array(
'integer'), array(
$row[
"ns_tag_fk"]));
1451 $this->db->manipulateF(
'DELETE FROM xmlnestedset WHERE ns_book_fk = %s AND ns_type = %s',
1452 array(
'integer',
'text'), array($this->obj_id,$this->obj_type));
1453 #$ilBench->stop('NestedSet','deleteAllDBData'); 1468 #$ilBench->start('NestedSet','deleteAllChildMetaData'); 1472 $in .= implode(
"','", $a_ids);
1475 $query =
"SELECT ns_tag_fk FROM xmlnestedset ".
1476 "WHERE ns_book_fk ".$in;
1478 while(
$row = $ilDB->fetchObject(
$res))
1480 $tag_fks[
$row->ns_tag_fk] =
$row->ns_tag_fk;
1482 $ilDB->manipulate(
"DELETE FROM xmlnestedset WHERE ns_book_fk ".
$in);
1487 if ($tag_fks != null)
1490 $in .= implode(
"','", $tag_fks);
1493 $ilDB->manipulate(
"DELETE FROM xmlparam WHERE tag_fk ".
$in);
1494 $ilDB->manipulate(
"DELETE FROM xmlvalue WHERE tag_fk ".
$in);
1495 $ilDB->manipulate(
"DELETE FROM xmltags WHERE tag_pk ".
$in);
1499 #$ilBench->stop('NestedSet','deleteAllChildMetaData'); 1513 $res = $ilDB->queryF(
'SELECT obj_id FROM lm_data WHERE lm_id = %s',array(
'integer'),array($a_obj_id));
1514 while(
$row = $ilDB->fetchObject(
$res))
1518 $ids[$a_obj_id] = $a_obj_id;
1520 return $ids ? $ids : array();
getTagValue()
get tag content
replace_content(&$node, &$new_content)
Replace node contents.
$xml_parser
SAX-Parser-Handle.
Class NestedSetXML functions for storing XML-Data into nested-set-database-strcture.
_deleteAllChildMetaData($a_ids)
Delete meta data of a content object (pages, chapters) public
domxml_open_mem($str, $mode=DOMXML_LOAD_PARSING, &$error=NULL)
initDom()
inits dom-object from given xml-content
export($obj_id, $type)
Export-Function.
$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
$DEPTH
Nesting level of the tags.
getXpathNodes(&$doc, $qry)
get node in dom-structure
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
static isDbError($a_res)
Check error.
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
ilNestedSetXML()
Constructor initilize netsed-set variables public.