ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilNestedSetXML.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once "./Services/Xml/classes/class.ilXML2DOM.php";
5
17{
18 // {{{ Vars
19
23 var $db;
24
28 var $LEFT = 0;
29 var $RIGHT = 0;
30
35 var $DEPTH = 0;
36
40 var $obj_id;
41
45 var $obj_type;
46
50 var $xml_parser;
51
55 var $lastTag = "";
56
62 var $ilias;
63
69 var $dom;
70
76 private $unique_import_id = '';
77
78 // }}}
79
85 function ilNestedSetXML()
86 {
87 global $ilias,$ilDB;
88
89 $this->ilias =& $ilias;
90
91 $this->db =& $ilDB;
92 $this->LEFT = 0;
93 $this->RIGHT = 0;
94 $this->DEPTH = 0;
95 $this->unique_import_id = '';
96
97 $this->param_modifier = "";
98 }
99
100
111 function startElement($parser, $name, $attrs)
112 {
113 // {{{
114
115 $this->lastTag = $name;
116 $this->LEFT += 1;
117 $this->RIGHT = $this->LEFT + 1;
118 $this->DEPTH++;
119
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));
127
128 $pk = $nextId;
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));
133
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));
138
139 $this->clean($attrs);
140 if (is_array($attrs) && count($attrs)>0)
141 {
142 reset ($attrs);
143 while (list ($key, $val) = each ($attrs))
144 {
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)));
148 }
149 }
150
151 return($pk);
152 // }}}
153 }
154
163 function characterData($parser, $data)
164 {
165 // {{{
171 static $value_pk;
172
173 // we don't need this trim since expression like ' ABC < > ' will be parsed to ' ABC <>'
174 if(1 or trim($data)!="") {
175
176
177 if ($this->lastTag == "TAGVALUE")
178 {
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));
181 }
182 else
183 {
184 $tag_pk = $this->startElement($this->xml_parser,"TAGVALUE",array());
185 $this->endElement($this->xml_parser,"TAGVALUE");
186
187 $nextId = $this->db->nextId('xmlvalue');
188
189
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)));
192
193 $value_pk = $nextId;
194
195 $this->lastTag = "TAGVALUE";
196 }
197
198 }
199 // }}}
200 }
201
209 function endElement($parser, $name)
210 {
211 // {{{
212 $this->DEPTH--;
213 $this->LEFT += 1;
214 $this->lastTag = "";
215 // }}}
216 }
217
226 function import($xmldata, $obj_id, $obj_type)
227 {
228 global $ilUser;
229
230 // {{{
235 $this->obj_id = $obj_id;
236 $this->obj_type = $obj_type;
237 $this->DEPTH = 0;
238 $this->LEFT = 0;
239 $this->RIGHT = 0;
240 $this->unique_import_id = $ilUser->getId();
241
242 $this->db->manipulateF(
243 "DELETE FROM xmlnestedsettmp WHERE ns_unique_id = %s",
244 array('text'),
245 array($this->unique_import_id)
246 );
247
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");
257
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)));
260 }
261 xml_parser_free($this->xml_parser);
262
266 $this->deleteAllDbData();
267
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)",
270 array('text'),
271 array($this->unique_import_id)
272 );
273
274 $this->db->manipulateF(
275 "DELETE FROM xmlnestedsettmp WHERE ns_unique_id = %s",
276 array('text'),
277 array($this->unique_import_id)
278 );
279 // }}}
280 }
281
287 function setParameterModifier(&$a_object, $a_method)
288 {
289 $this->param_modifier =& $a_object;
290 $this->param_modifier_method = $a_method;
291 }
292
304 function export($obj_id, $type)
305 {
306 // {{{
307
308 $result = $this->db->queryF('
309 SELECT * FROM xmlnestedset,xmltags
310 WHERE ns_tag_fk = tag_pk
311 AND ns_book_fk = %s
312 AND ns_type = %s
313 ORDER BY ns_l',
314 array('integer','text'),
315 array($obj_id,$type));
316
318 {
319 die($this->className."::checkTable(): ".$result->getMessage().":<br>".$q);
320 }
321
322 $xml = "";
323 $lastDepth = -1;
324
325 while (is_array($row = $this->db->fetchAssoc($result)))
326 {
327
328 // {{{ tags
329 $Anfang = "<".$row[tag_name];
330
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)))
333 {
334 $param_value = $row_param[param_value];
335 if (is_object($this->param_modifier))
336 {
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);
340 }
341 $Anfang .= " ".$row_param[param_name]."=\"".$param_value."\"";
342 }
343
344 $Anfang .= ">";
345 $Ende = "</".$row[tag_name].">";
346 // }}}
347
348 // {{{ TagValue
349 if ($row[tag_name]=="TAGVALUE")
350 {
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);
353
354 $Anfang = $row_value["tag_value"];
355 $Ende = "";
356
357 $Anfang = htmlspecialchars($Anfang);
358 // $Anfang = utf8_encode($Anfang);
359 }
360 // }}}
361
362 $D = $row[tag_depth];
363
364 if ($D==$lastDepth)
365 {
366 $xml .= $xmlE[$D];
367 $xml .= $Anfang;
368 $xmlE[$D] = $Ende;
369 }
370 else if ($D>$lastDepth)
371 {
372 $xml .= $Anfang;
373 $xmlE[$D] = $Ende;
374 }
375 else
376 {
377 for ($i=$lastDepth;$i>=$D;$i--)
378 {
379 $xml .= $xmlE[$i];
380 }
381 $xml .= $Anfang;
382 $xmlE[$D] = $Ende;
383 }
384
385 $lastDepth = $D;
386
387 }
388
389 for ($i=$lastDepth;$i>0;$i--)
390 {
391 $xml .= $xmlE[$i];
392 }
393
394 return($xml);
395 // }}}
396 }
397
406 {
407 // {{{
408 $this->db->setLimit(1);
409
410 $result = $this->db->queryF('
411 SELECT * FROM xmlnestedset,xmltags
412 WHERE ns_book_fk = %s
413 AND ns_type = %s
414 AND ns_tag_fk = tag_pk
415 ORDER BY ns_l',
416 array('integer','text'),
417 array($obj_id, $obj_type));
418
419 $row = $this->db->fetchAssoc($result);
420
421 $this->LEFT = $row["ns_l"];
422 $this->RIGHT = $row["ns_r"];
423 $this->DEPTH = $row["tag_depth"];
424 $this->obj_id = $obj_id;
425 $this->obj_type = $obj_type;
426 // }}}
427 }
428
436 function getTagName()
437 {
438
439 $this->db->setLimit(1);
440
441 $result = $this->db->queryF('
442 SELECT * FROM xmlnestedset,xmltags
443 WHERE ns_book_fk = %s
444 AND ns_type = %s
445 AND ns_l = %s
446 AND ns_r = %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));
450
451 $row = $this->db->fetchAssoc($result);
452
453 return($row["tag_name"]);
454
455 }
456
466 function setTagName($tagName)
467 {
468
469 $this->db->setLimit(1);
470
471 $result = $this->db->queryF('
472 SELECT * FROM xmlnestedset
473 WHERE ns_book_fk = %s
474 AND ns_type = %s
475 AND ns_l = %s
476 AND ns_r = %s',
477 array('integer','text','integer','integer'),
478 array($this->obj_id,$this->obj_type,$this->LEFT,$this->RIGHT));
479
480 $row = $this->db->fetchAssoc($result);
481
482 $this->db->manipulateF('UPDATE xmltags SET tag_name = %s WHERE tag_pk = %s',
483 array('text','integer'), array($tagName,$row["ns_tag_fk"]));
484
485
486 return($row["tagName"]);
487
488 }
489
490
497 function getTagValue()
498 {
499
500 $V = array();
501
502 $result = $this->db->queryF('
503 SELECT * FROM xmlnestedset,xmltags
504 WHERE ns_tag_fk = tag_pk
505 AND ns_book_fk = %s
506 AND ns_type = %s
507 AND ns_l >= %s
508 AND ns_r <= %s
509 AND tag_depth = %s
510 ORDER BY ns_l',
511 array('integer','text','integer','integer','integer'),
512 array($this->obj_id,$this->obj_type,$this->LEFT,$this->RIGHT,$this->DEPTH+1));
513
514 while (is_array($row = $this->db->fetchAssoc($result) ) )
515 {
516 if ($row[tag_name]=="TAGVALUE")
517 {
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];
521 }
522 else
523 {
524 $xml = new ilNestedSetXml();
525
526 $xml->LEFT = $row["ns_l"];
527 $xml->RIGHT = $row["ns_r"];
528 $xml->DEPTH = $row["tag_depth"];
529 $xml->obj_id = $obj_id;
530 $xml->obj_type = $obj_type;
531
532 $V[] = $xml;
533
534 }
535 }
536
537 return($V);
538 }
539
546 function setTagValue($value)
547 {
548 $V = array();
549
550
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
555 AND ns_book_fk = %s
556 AND ns_type = %s
557 AND ns_l >= %s
558 AND ns_r <= %s
559 AND tag_depth = %s
560 AND tag_name = %s
561 AND ORDER BY ns_l',
562 array('integer','text','integer','integer','integer','text'),
563 array($this->obj_id, $this->obj_type, $this->LEFT, $this->RIGHT, $this->DEPTH+1,'TAGVALUE')
564 );
565
566 if (is_array($row = $this->db->fetchAssoc($result) ) )
567 {
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"]));
570
571 }
572 else
573 {
574
579 }
580 }
581
591 function getXpathNodes(&$doc, $qry)
592 {
593 if (is_object($doc))
594 {
595 $xpath = $doc->xpath_init();
596 $ctx = $doc->xpath_new_context();
597//echo "<br><b>ilNestedSetXML::getXpathNodes</b>";
598 $result = $ctx->xpath_eval($qry);
599 if (is_array($result->nodeset))
600 {
601 return($result->nodeset);
602 }
603 }
604 return Null;
605 }
606
613 function initDom()
614 {
615 $xml = $this->export($this->obj_id, $this->obj_type);
616
617/*
618 for testing
619 $xml_test = '
620 <MetaData>
621 <General Structure="Atomic">
622 <Identifier Catalog="ILIAS" Entry="34">Identifier 34 in ILIAS</Identifier>
623 <Identifier Catalog="ILIAS" Entry="45">Identifier 45 in ILIAS</Identifier>
624 <Identifier Catalog="ILIAS" Entry="67">Identifier 67 in ILIAS</Identifier>
625 </General>
626 </MetaData>
627 ';
628
629 $xml = $xml_test;
630*/
631
632 if ($xml=="")
633 {
634 return(false);
635 }
636 else
637 {
638 $this->dom = domxml_open_mem($xml);
639 return(true);
640 }
641 }
642
653 function addXMLNode($xPath, $xml, $index = 0)
654 {
655 $newDOM = new XML2DOM($xml);
656//echo "<br>addXMLNode:-".htmlspecialchars($this->dom->dump_mem(0));
657 $nodes = $this->getXpathNodes($this->dom, $xPath);
658
659 if (count($nodes) > 0)
660 {
661 $newDOM->insertNode($this->dom, $nodes[$index]);
662 return true;
663 }
664 else
665 {
666 return false;
667 }
668 }
669
678 function getFirstDomContent($xPath)
679 {
680//echo "<br>ilNestedSetXML::getFirstDomContent-start-$xPath-"; flush();
681 $content = "";
682 if (is_object($this->dom))
683 {
684 $node = $this->getXpathNodes($this->dom,$xPath);
685 if (is_array($node))
686 {
687 if (is_object($node[0]))
688 {
689 $c = $node[0]->children();
690 //$content = $c[0]->content; // ## changed
691 if (is_object($c[0]))
692 {
693 $content = $c[0]->get_content(); // ## changed
694 }
695 }
696 }
697 }
698//echo "<br>ilNestedSetXML::getFirstDomContent-stop-$content-"; flush();
699 return($content);
700 }
701
712 function deleteDomNode($xPath, $name, $index = 0)
713 {
714 if ($index == "")
715 {
716 $index = 0;
717 }
718 if (strpos($index, ","))
719 {
720 $indices = explode(",", $index);
721 $nodes = $this->getXpathNodes($this->dom, $xPath);
722 if (count($nodes) > 0)
723 {
724 $children = $nodes[$indices[0]]->child_nodes();
725 if (count($children) > 0)
726 {
727 $j = 0;
728 for ($i = 0; $i < count($children); $i++)
729 {
730 if ($children[$i]->node_name() == $name)
731 {
732 if ($j == $indices[1])
733 {
734 $children[$i]->unlink_node();
735 return true;
736 }
737 $j++;
738 }
739 }
740 }
741 }
742 }
743 else
744 {
745 $nodes = $this->getXpathNodes($this->dom, $xPath . "/" . $name);
746 if (count($nodes) > 0)
747 {
748 $nodes[$index]->unlink_node();
749 return true;
750 }
751 }
752 return false;
753 }
754
767 function addDomNode($xPath, $name, $value = "", $attributes = "", $index = 0)
768 {
769 $nodes = $this->getXpathNodes($this->dom, $xPath);
770 if (count($nodes) > 0)
771 {
772 $node = $this->dom->create_element($name);
773 if ($value != "")
774 {
775 $node->set_content(utf8_encode($value));
776 }
777 if (is_array($attributes))
778 {
779 for ($i = 0; $i < count($attributes); $i++)
780 {
781 $node->set_attribute($attributes[$i]["name"], utf8_encode($attributes[$i]["value"]));
782 }
783 }
784 $nodes[$index]->append_child($node);
785 return true;
786 }
787 else
788 {
789 return false;
790 }
791 }
792
793 function clean(&$meta)
794 {
795 if(is_array($meta))
796 {
797 foreach($meta as $key => $value)
798 {
799 if(is_array($meta[$key]))
800 {
801 $this->clean($meta[$key]);
802 }
803 else
804 {
805 $meta[$key] = ilUtil::stripSlashes($meta[$key]);
806 $meta[$key] = preg_replace("/&(?!amp;|lt;|gt;|quot;)/","&amp;",$meta[$key]);
807 $meta[$key] = preg_replace("/\"/","&quot;",$meta[$key]);
808 $meta[$key] = preg_replace("/</","&lt;",$meta[$key]);
809 $meta[$key] = preg_replace("/>/","&gt;",$meta[$key]);
810 }
811 }
812 }
813 return true;
814 }
823 function updateDomNode($xPath, $meta, $no = 0)
824 {
825 $this->clean($meta);
826 $update = false;
827 if ($xPath == "//Bibliography")
828 {
829 $nodes = $this->getXpathNodes($this->dom, $xPath . "/BibItem[" . ($no+1) . "]");
830 }
831 else
832 {
833 $nodes = $this->getXpathNodes($this->dom, $xPath);
834 }
835 if (count($nodes) > 0)
836 {
837
838 /* BibItem */
839 if ($nodes[0]->node_name() == "BibItem")
840 {
841 $xml = '<BibItem Type="' . ilUtil::stripSlashes($meta["Type"]) . '" Label="' . ilUtil::stripSlashes($meta["Label"]["Value"]) . '">';
842 $xml .= '<Identifier Catalog="' . ilUtil::stripSlashes($meta["Identifier"]["Catalog"]) . '" Entry="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Identifier"]["Entry"])) . '"/>';
843 for ($i = 0; $i < count($meta["Language"]); $i++)
844 {
845 $xml .= '<Language Language="' . ilUtil::stripSlashes($meta["Language"][$i]["Language"]) . '"/>';
846 }
847 for ($i = 0; $i < count($meta["Author"]); $i++)
848 {
849 $xml .= '<Author>';
850# for ($j = 0; $j < count($meta["Author"][$i]["FirstName"]); $j++)
851# {
852 $xml .= '<FirstName>' . ilUtil::stripSlashes($meta["Author"][$i]["FirstName"]) . '</FirstName>';
853# }
854# for ($j = 0; $j < count($meta["Author"][$i]["MiddleName"]); $j++)
855# {
856 $xml .= '<MiddleName>' . ilUtil::stripSlashes($meta["Author"][$i]["MiddleName"]) . '</MiddleName>';
857# }
858# for ($j = 0; $j < count($meta["Author"][$i]["LastName"]); $j++)
859# {
860 $xml .= '<LastName>' . ilUtil::stripSlashes($meta["Author"][$i]["LastName"]) . '</LastName>';
861# }
862 $xml .= '</Author>';
863 }
864 $xml .= '<Booktitle Language="' . ilUtil::stripSlashes($meta["Booktitle"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Booktitle"]["Value"]) . '</Booktitle>';
865 for ($i = 0; $i < count($meta["CrossRef"]); $i++)
866 {
867 $xml .= '<CrossRef>' . ilUtil::stripSlashes($meta["CrossRef"][$i]["Value"]) . '</CrossRef>';
868 }
869 $xml .= '<Edition>' . ilUtil::stripSlashes($meta["Edition"]["Value"]) . '</Edition>';
870 for ($i = 0; $i < count($meta["Editor"]); $i++)
871 {
872 $xml .= '<Editor>' . ilUtil::stripSlashes($meta["Editor"][$i]["Value"]) . '</Editor>';
873 }
874 $xml .= '<HowPublished Type="' . ilUtil::stripSlashes($meta["HowPublished"]["Type"]) . '"/>';
875 for ($i = 0; $i < count($meta["WherePublished"]); $i++)
876 {
877 $xml .= '<WherePublished>' . ilUtil::stripSlashes($meta["WherePublished"][$i]["Value"]) . '</WherePublished>';
878 }
879 for ($i = 0; $i < count($meta["Institution"]); $i++)
880 {
881 $xml .= '<Institution>' . ilUtil::stripSlashes($meta["Institution"][$i]["Value"]) . '</Institution>';
882 }
883 if (is_array($meta["Journal"]))
884 {
885 $xml .= '<Journal Note="' . ilUtil::stripSlashes($meta["Journal"]["Note"]) . '" Number="' . ilUtil::stripSlashes($meta["Journal"]["Number"]) . '" Organization="' . ilUtil::stripSlashes($meta["Journal"]["Organization"]) . '"/>';
886 }
887 for ($i = 0; $i < count($meta["Keyword"]); $i++)
888 {
889 $xml .= '<Keyword Language="' . ilUtil::stripSlashes($meta["Keyword"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Keyword"][$i]["Value"]) . '</Keyword>';
890 }
891 if (is_array($meta["Month"]))
892 {
893 $xml .= '<Month>' . ilUtil::stripSlashes($meta["Month"]["Value"]) . '</Month>';
894 }
895 if (is_array($meta["Pages"]))
896 {
897 $xml .= '<Pages>' . ilUtil::stripSlashes($meta["Pages"]["Value"]) . '</Pages>';
898 }
899 $xml .= '<Publisher>' . ilUtil::stripSlashes($meta["Publisher"]["Value"]) . '</Publisher>';
900 for ($i = 0; $i < count($meta["School"]); $i++)
901 {
902 $xml .= '<School>' . ilUtil::stripSlashes($meta["School"][$i]["Value"]) . '</School>';
903 }
904 if (is_array($meta["Series"]))
905 {
906 $xml .= '<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"]))
910 {
911# $xml .= '<SeriesEditor>' . ilUtil::stripSlashes($meta["Series"]["SeriesEditor"][$i]) . '</SeriesEditor>';
912 $xml .= '<SeriesEditor>' . ilUtil::stripSlashes($meta["Series"]["SeriesEditor"]) . '</SeriesEditor>';
913 }
914 if (isset($meta["Series"]["SeriesVolume"]))
915 {
916 $xml .= '<SeriesVolume>' . ilUtil::stripSlashes($meta["Series"]["SeriesVolume"]) . '</SeriesVolume>';
917 }
918 $xml .= '</Series>';
919 }
920 $xml .= '<Year>' . ilUtil::stripSlashes($meta["Year"]["Value"]) . '</Year>';
921 if ($meta["URL_ISBN_ISSN"]["Type"] == "URL")
922 {
923 $xml .= '<URL>' . ilUtil::stripSlashes($meta["URL_ISBN_ISSN"]["Value"]) . '</URL>';
924 }
925 else if ($meta["URL_ISBN_ISSN"]["Type"] == "ISBN")
926 {
927 $xml .= '<ISBN>' . ilUtil::stripSlashes($meta["URL_ISBN_ISSN"]["Value"]) . '</ISBN>';
928 }
929 else if ($meta["URL_ISBN_ISSN"]["Type"] == "ISSN")
930 {
931 $xml .= '<ISSN>' . ilUtil::stripSlashes($meta["URL_ISBN_ISSN"]["Value"]) . '</ISSN>';
932 }
933 $xml .= '</BibItem>';
934# echo htmlspecialchars($xml);
935
936 $update = true;
937 }
938
939 /* General */
940 else if ($nodes[0]->node_name() == "General")
941 {
942
943 $xml = '<General Structure="' . ilUtil::stripSlashes($meta["Structure"]) . '">';
944 for ($i = 0; $i < count($meta["Identifier"]); $i++)
945 {
946 $xml .= '<Identifier Catalog="' . ilUtil::stripSlashes($meta["Identifier"][$i]["Catalog"]) . '" Entry="' .
947 str_replace("\"", "", ilUtil::stripSlashes($meta["Identifier"][$i]["Entry"])) . '"/>';
948 }
949
950 $xml .= '<Title Language="' .
951 ilUtil::stripSlashes($meta["Title"]["Language"]) . '">' .
952 ilUtil::stripSlashes($meta["Title"]["Value"]) . '</Title>';
953 for ($i = 0; $i < count($meta["Language"]); $i++)
954 {
955 $xml .= '<Language Language="' . ilUtil::stripSlashes($meta["Language"][$i]["Language"]) . '"/>';
956 }
957 for ($i = 0; $i < count($meta["Description"]); $i++)
958 {
959 $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Description"][$i]["Value"]) . '</Description>';
960 }
961 for ($i = 0; $i < count($meta["Keyword"]); $i++)
962 {
963 $xml .= '<Keyword Language="' . ilUtil::stripSlashes($meta["Keyword"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Keyword"][$i]["Value"]) . '</Keyword>';
964 }
965 if ($meta["Coverage"] != "")
966 {
967 $xml .= '<Coverage Language="' . ilUtil::stripSlashes($meta["Coverage"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Coverage"]["Value"]) . '</Coverage>';
968 }
969 $xml .= '</General>';
970//echo "<br><br>".htmlspecialchars($xml);
971
972 $update = true;
973 }
974
975 /* Lifecycle */
976 else if ($nodes[0]->node_name() == "Lifecycle")
977 {
978 $xml = '<Lifecycle Status="' . $meta["Status"] . '">';
979 $xml .= '<Version Language="' . ilUtil::stripSlashes($meta["Version"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Version"]["Value"]) . '</Version>';
980 for ($i = 0; $i < count($meta["Contribute"]); $i++)
981 {
982 $xml .= '<Contribute Role="' . ilUtil::stripSlashes($meta["Contribute"][$i]["Role"]) . '">';
983 $xml .= '<Date>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Date"]) . '</Date>';
984 for ($j = 0; $j < count($meta["Contribute"][$i]["Entity"]); $j++)
985 {
986 $xml .= '<Entity>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Entity"][$j]) . '</Entity>';
987 }
988 $xml .= '</Contribute>';
989 }
990 $xml .= '</Lifecycle>';
991# echo htmlspecialchars($xml);
992
993 $update = true;
994 }
995
996 /* Meta-Metadata */
997 else if ($nodes[0]->node_name() == "Meta-Metadata")
998 {
999
1000 $xml = '<Meta-Metadata MetadataScheme="LOM v 1.0" Language="' . ilUtil::stripSlashes($meta["Language"]) . '">';
1001 for ($i = 0; $i < count($meta["Identifier"]); $i++)
1002 {
1003 $xml .= '<Identifier Catalog="' . ilUtil::stripSlashes($meta["Identifier"][$i]["Catalog"]) . '" Entry="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Identifier"][$i]["Entry"])) . '"/>';
1004 }
1005 for ($i = 0; $i < count($meta["Contribute"]); $i++)
1006 {
1007 $xml .= '<Contribute Role="' . ilUtil::stripSlashes($meta["Contribute"][$i]["Role"]) . '">';
1008 $xml .= '<Date>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Date"]) . '</Date>';
1009 for ($j = 0; $j < count($meta["Contribute"][$i]["Entity"]); $j++)
1010 {
1011 $xml .= '<Entity>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Entity"][$j]) . '</Entity>';
1012 }
1013 $xml .= '</Contribute>';
1014 }
1015 $xml .= '</Meta-Metadata>';
1016# echo htmlspecialchars($xml);
1017
1018 $update = true;
1019 }
1020
1021 /* Technical */
1022 else if ($nodes[0]->node_name() == "Technical")
1023 {
1024
1025 $xml = '<Technical>';
1026 for ($i = 0; $i < count($meta["Format"]); $i++)
1027 {
1028 $xml .= '<Format>' . ilUtil::stripSlashes($meta["Format"][$i]) . '</Format>';
1029 }
1030 if ($meta["Size"] != "")
1031 {
1032 $xml .= '<Size>' . ilUtil::stripSlashes($meta["Size"]) . '</Size>';
1033 }
1034 for ($i = 0; $i < count($meta["Location"]); $i++)
1035 {
1036 $xml .= '<Location Type="' . ilUtil::stripSlashes($meta["Location"][$i]["Type"]) . '">' . ilUtil::stripSlashes($meta["Location"][$i]["Value"]) . '</Location>';
1037 }
1038 if (is_array($meta["Requirement"]))
1039 {
1040 for ($i = 0; $i < count($meta["Requirement"]); $i++)
1041 {
1042 $xml .= '<Requirement>';
1043 $xml .= '<Type>';
1044 if (is_array($meta["Requirement"][$i]["Type"]["OperatingSystem"]))
1045 {
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"])) . '"/>';
1047 }
1048 if (is_array($meta["Requirement"][$i]["Type"]["Browser"]))
1049 {
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"])) . '"/>';
1051 }
1052 $xml .= '</Type>';
1053 $xml .= '</Requirement>';
1054 }
1055 }
1056 else if (is_array($meta["OrComposite"]))
1057 {
1058 for ($j = 0; $j < count($meta["OrComposite"]); $j++)
1059 {
1060 $xml .= '<OrComposite>';
1061 for ($i = 0; $i < count($meta["OrComposite"][$j]["Requirement"]); $i++)
1062 {
1063 $xml .= '<Requirement>';
1064 $xml .= '<Type>';
1065 if (is_array($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["OperatingSystem"]))
1066 {
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"])) . '"/>';
1068 }
1069 if (is_array($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["Browser"]))
1070 {
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"])) . '"/>';
1072 }
1073 $xml .= '</Type>';
1074 $xml .= '</Requirement>';
1075 }
1076 $xml .= '</OrComposite>';
1077 }
1078 }
1079 if (is_array($meta["InstallationRemarks"]))
1080 {
1081 $xml .= '<InstallationRemarks Language="' . ilUtil::stripSlashes($meta["InstallationRemarks"]["Language"]) . '">' . ilUtil::stripSlashes($meta["InstallationRemarks"]["Value"]) . '</InstallationRemarks>';
1082 }
1083 if (is_array($meta["OtherPlattformRequirements"]))
1084 {
1085 $xml .= '<OtherPlattformRequirements Language="' . ilUtil::stripSlashes($meta["OtherPlattformRequirements"]["Language"]) . '">' . ilUtil::stripSlashes($meta["OtherPlattformRequirements"]["Value"]) . '</OtherPlattformRequirements>';
1086 }
1087 if ($meta["Duration"] != "")
1088 {
1089 $xml .= '<Duration>' . ilUtil::stripSlashes($meta["Duration"]) . '</Duration>';
1090 }
1091 $xml .= '</Technical>';
1092# echo htmlspecialchars($xml);
1093
1094 $update = true;
1095 }
1096
1097 /* Educational */
1098 else if ($nodes[0]->node_name() == "Educational")
1099 {
1100
1101 $xml = '<Educational InteractivityType="' . ilUtil::stripSlashes($meta["InteractivityType"]) . '" LearningResourceType="' . ilUtil::stripSlashes($meta["LearningResourceType"]) . '" InteractivityLevel="' . ilUtil::stripSlashes($meta["InteractivityLevel"]) . '" SemanticDensity="' . ilUtil::stripSlashes($meta["SemanticDensity"]) . '" IntendedEndUserRole="' . ilUtil::stripSlashes($meta["IntendedEndUserRole"]) . '" Context="' . ilUtil::stripSlashes($meta["Context"]) . '" Difficulty="' . ilUtil::stripSlashes($meta["Difficulty"]) . '">';
1102 $xml .= '<TypicalLearningTime>' . ilUtil::stripSlashes($meta["TypicalLearningTime"]) . '</TypicalLearningTime>';
1103 for ($i = 0; $i < count($meta["TypicalAgeRange"]); $i++)
1104 {
1105 $xml .= '<TypicalAgeRange Language="' . ilUtil::stripSlashes($meta["TypicalAgeRange"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["TypicalAgeRange"][$i]["Value"]) . '</TypicalAgeRange>';
1106 }
1107 for ($i = 0; $i < count($meta["Description"]); $i++)
1108 {
1109 $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Description"][$i]["Value"]) . '</Description>';
1110 }
1111 for ($i = 0; $i < count($meta["Language"]); $i++)
1112 {
1113 $xml .= '<Language Language="' . ilUtil::stripSlashes($meta["Language"][$i]["Language"]) . '"/>';
1114 }
1115 $xml .= '</Educational>';
1116
1117 $update = true;
1118 }
1119
1120 /* Rights */
1121 else if ($nodes[0]->node_name() == "Rights")
1122 {
1123
1124 $xml = '<Rights Cost="' . ilUtil::stripSlashes($meta["Cost"]) . '" CopyrightAndOtherRestrictions="' . ilUtil::stripSlashes($meta["CopyrightAndOtherRestrictions"]) . '">';
1125 for ($i = 0; $i < count($meta["Description"]); $i++)
1126 {
1127 $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Description"][$i]["Value"]) . '</Description>';
1128 }
1129 $xml .= '</Rights>';
1130
1131 $update = true;
1132 }
1133
1134 /* Relation */
1135 else if ($nodes[0]->node_name() == "Relation")
1136 {
1137
1138# for ($j = 0; $j < count($meta["Relation"]); $j++)
1139# {
1140 $meta["Relation"][0] = $meta;
1141 $j = 0;
1142 $xml = '<Relation Kind="' . ilUtil::stripSlashes($meta["Relation"][$j]["Kind"]) . '">';
1143 $xml .= '<Resource>';
1144 for ($i = 0; $i < count($meta["Relation"][$j]["Resource"]["Identifier"]); $i++)
1145 {
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"])) . '"/>';
1147 }
1148 for ($i = 0; $i < count($meta["Relation"][$j]["Resource"]["Description"]); $i++)
1149 {
1150 $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Description"][$i]["Value"]) . '</Description>';
1151 }
1152 $xml .= '</Resource>';
1153 $xml .= '</Relation>';
1154# echo htmlspecialchars($xml);
1155# }
1156
1157 $update = true;
1158 }
1159
1160 /* Annotation */
1161 else if ($nodes[0]->node_name() == "Annotation")
1162 {
1163
1164# for ($i = 0; $i < count($meta["Annotation"]); $i++)
1165# {
1166 $meta["Annotation"][0] = $meta;
1167 $i = 0;
1168 $xml = '<Annotation>';
1169 $xml .= '<Entity>' . ilUtil::stripSlashes($meta["Annotation"][$i]["Entity"]) . '</Entity>';
1170 $xml .= '<Date>' . ilUtil::stripSlashes($meta["Annotation"][$i]["Date"]) . '</Date>';
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);
1174# }
1175
1176 $update = true;
1177 }
1178
1179 /* Classification */
1180 else if ($nodes[0]->node_name() == "Classification")
1181 {
1182
1183# for ($j = 0; $j < count($meta["Classification"]); $j++)
1184# {
1185 $meta["Classification"][0] = $meta;
1186 $j = 0;
1187 $xml = '<Classification Purpose="' . ilUtil::stripSlashes($meta["Classification"][$j]["Purpose"]) . '">';
1188 for ($k = 0; $k < count($meta["Classification"][$j]["TaxonPath"]); $k++)
1189 {
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++)
1193 {
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>';
1195 }
1196 $xml .= '</TaxonPath>';
1197 }
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++)
1200 {
1201 $xml .= '<Keyword Language="' . ilUtil::stripSlashes($meta["Classification"][$j]["Keyword"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Classification"][$j]["Keyword"][$i]["Value"]) . '</Keyword>';
1202 }
1203 $xml .= '</Classification>';
1204# echo htmlspecialchars($xml);
1205# }
1206
1207 $update = true;
1208 }
1209
1210 if ($update)
1211 {
1212 $nodes[0]->unlink_node();
1213
1214 if ($xPath != "//Bibliography")
1215 {
1216 $xPath = "//MetaData";
1217 }
1218//echo "<br><br>savedA:".htmlspecialchars($this->dom->dump_mem(0));
1219 $this->addXMLNode($xPath, $xml);
1220//echo "<br><br>savedB:".htmlspecialchars($this->dom->dump_mem(0));
1221 }
1222 return true;
1223 }
1224 else
1225 {
1226 return false;
1227 }
1228 }
1229
1240 function getDomContent($xPath, $name = "", $index = 0)
1241 {
1242 if ($index == "")
1243 {
1244 $index = 0;
1245 }
1246# echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n";
1247 $nodes = $this->getXpathNodes($this->dom, $xPath);
1248 if (count($nodes) > 0)
1249 {
1250 $children = $nodes[$index]->child_nodes();
1251 if (count($children) > 0)
1252 {
1253 $k = 0;
1254 for ($i = 0; $i < count($children); $i++)
1255 {
1256//echo "<br>ilNestedSetXML::getDomContent-".$children[$i]->node_name()."-".$name;
1257 if ($name == "" ||
1258 $children[$i]->node_name() == $name)
1259 {
1260 $content[$k]["value"] = $children[$i]->get_content();
1261 $a = $children[$i]->attributes();
1262 for ($j = 0; $j < count($a); $j++)
1263 {
1264 $content[$k][$a[$j]->name()] = $a[$j]->value();
1265 }
1266 $k++;
1267 }
1268 }
1269# vd($content);
1270 return($content);
1271 }
1272 }
1273 return false;
1274 }
1275
1284 function replaceDomContent($xPath, $name = "", $index = 0, $newNode)
1285 {
1286# echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n";
1287 $nodes = $this->getXpathNodes($this->dom, $xPath);
1288 if (count($nodes) > 0)
1289 {
1290 $children = $nodes[$index]->child_nodes();
1291 if (count($children) > 0)
1292 {
1293 for ($i = 0; $i < count($children); $i++)
1294 {
1295 if ($children[$i]->node_name() == $name &&
1296 is_array($newNode))
1297 {
1298 foreach ($newNode as $key => $val)
1299 {
1300 if ($key == "value")
1301 {
1302 $this->replace_content($children[$i], $val);
1303 }
1304 else
1305 {
1306 $children[$i]->set_attribute($key, $val);
1307 }
1308 }
1309 }
1310 }
1311 }
1312 }
1313 }
1314
1325 function replace_content( &$node, &$new_content )
1326 {
1327 $newnode =& $this->dom->create_element( $node->tagname() );
1328 $newnode->set_content( $new_content );
1329 $atts =& $node->attributes();
1330 foreach ( $atts as $att )
1331 {
1332 $newnode->set_attribute( $att->name(), $att->value() );
1333 }
1334 $kids =& $node->child_nodes();
1335 foreach ( $kids as $kid )
1336 {
1337 if ( $kid->node_type() != XML_TEXT_NODE )
1338 {
1339 $newnode->append_child( $kid );
1340 }
1341 }
1342 $node->replace_node( $newnode );
1343 }
1344
1353 function updateDomContent($xPath, $name = "", $index = 0, $newNode)
1354 {
1355// echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n";
1356 $nodes = $this->getXpathNodes($this->dom, $xPath);
1357 if (count($nodes) > 0)
1358 {
1359 $children = $nodes[$index]->child_nodes();
1360 if (count($children) > 0)
1361 {
1362 for ($i = 0; $i < count($children); $i++)
1363 {
1364 if ($children[$i]->node_name() == $name &&
1365 is_array($newNode))
1366 {
1367 foreach ($newNode as $key => $val)
1368 {
1369 if ($key == "value")
1370 {
1371 $children[$i]->set_content($val);
1372 }
1373 else
1374 {
1375 $children[$i]->set_attribute($key, $val);
1376 }
1377 }
1378 }
1379 }
1380 }
1381 }
1382 }
1383
1391 function getFirstDomNode($xPath)
1392 {
1393 $node = $this->getXpathNodes($this->dom,$xPath);
1394 return($node[0]);
1395 }
1396
1401 function updateFromDom()
1402 {
1403 $this->deleteAllDbData();
1404 $xml = $this->dom->dump_mem(0);
1405 $this->import($xml,$this->obj_id,$this->obj_type);
1406
1407 }
1408
1414 {
1415 global $ilBench;
1416
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));
1421
1422 while ($row = $this->db->fetchAssoc($res))
1423 {
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"]));
1427 }
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');
1431
1432 }
1433
1442 {
1443 global $ilBench,$ilDB;
1444
1445 #$ilBench->start('NestedSet','deleteAllChildMetaData');
1446
1447 // STEP TWO: DELETE ENTRIES IN xmlnestedset GET ALL tag_fks
1448 $in = " IN ('";
1449 $in .= implode("','", $a_ids);
1450 $in .= "')";
1451
1452 $query = "SELECT ns_tag_fk FROM xmlnestedset ".
1453 "WHERE ns_book_fk ".$in;
1454 $res = $ilDB->query($query);
1455 while($row = $ilDB->fetchObject($res))
1456 {
1457 $tag_fks[$row->ns_tag_fk] = $row->ns_tag_fk;
1458 }
1459 $ilDB->manipulate("DELETE FROM xmlnestedset WHERE ns_book_fk ".$in);
1460
1461
1462 // FINALLY DELETE
1463 // BEGIN WebDAV: Object deletion failed if no tag_fks was present.
1464 if ($tag_fks != null)
1465 {
1466 $in = " IN ('";
1467 $in .= implode("','", $tag_fks);
1468 $in .= "')";
1469
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);
1473 }
1474 // END WebDAV Object deletion failed if no tag_fks was present.
1475
1476 #$ilBench->stop('NestedSet','deleteAllChildMetaData');
1477 return true;
1478 }
1479
1486 function _getAllChildIds($a_obj_id)
1487 {
1488 global $ilDB;
1489
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))
1492 {
1493 $ids[$row->obj_id] = $row->obj_id;
1494 }
1495 $ids[$a_obj_id] = $a_obj_id;
1496
1497 return $ids ? $ids : array();
1498 }
1499
1500 // }}}
1501
1502}
1503
1504?>
$result
static isDbError($a_res)
Check error.
Definition: class.ilDB.php:515
Class NestedSetXML functions for storing XML-Data into nested-set-database-strcture.
addDomNode($xPath, $name, $value="", $attributes="", $index=0)
updateDomContent($xPath, $name="", $index=0, $newNode)
replace_content(&$node, &$new_content)
Replace node contents.
replaceDomContent($xPath, $name="", $index=0, $newNode)
$obj_type
The type of the data to those this entry belongs.
updateDomNode($xPath, $meta, $no=0)
getTagValue()
get tag content
$xml_parser
SAX-Parser-Handle.
startElement($parser, $name, $attrs)
Method is called, at an introductory TAG @access private.
$LEFT
Left and right edge tags.
getFirstDomNode($xPath)
first dom-node
endElement($parser, $name)
method called at a closing tag @access private
deleteDomNode($xPath, $name, $index=0)
$db
Datenbank-handle.
getXpathNodes(&$doc, $qry)
get node in dom-structure
$lastTag
last Tag-Name found
addXMLNode($xPath, $xml, $index=0)
ilNestedSetXML()
Constructor initilize netsed-set variables @access public.
getTagName()
find first tag-name
setTagValue($value)
set tag-content
init($obj_id, $obj_type)
initilialize Nested-Set-Structur
setTagName($tagName)
set tag-name
export($obj_id, $type)
Export-Function.
$DEPTH
Nesting level of the tags.
setParameterModifier(&$a_object, $a_method)
getDomContent($xPath, $name="", $index=0)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $ilBench
Definition: ilias.php:18
domxml_open_mem($str, $mode=DOMXML_LOAD_PARSING, &$error=NULL)
redirection script todo: (a better solution should control the processing via a xml file)
global $ilDB
global $ilUser
Definition: imgupload.php:15