ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilNestedSetXML Class Reference
+ Collaboration diagram for ilNestedSetXML:

Public Member Functions

 __construct ()
 Constructor initilize netsed-set variables @access public. More...
 
 startElement ($parser, $name, $attrs)
 Method is called, at an introductory TAG @access private. More...
 
 endElement ($parser, $name)
 method called at a closing tag @access private More...
 
 import ($xmldata, $obj_id, $obj_type)
 Import-Function. More...
 
 setParameterModifier (&$a_object, $a_method)
 
 export ($obj_id, $type)
 Export-Function. More...
 
 init ($obj_id, $obj_type)
 initilialize Nested-Set-Structur More...
 
 getTagName ()
 find first tag-name More...
 
 setTagName ($tagName)
 set tag-name More...
 
 getTagValue ()
 get tag content More...
 
 setTagValue ($value)
 set tag-content More...
 
 getXpathNodes (&$doc, $qry)
 get node in dom-structure More...
 
 initDom ()
 
 addXMLNode ($xPath, $xml, $index=0)
 
 getFirstDomContent ($xPath)
 
 deleteDomNode ($xPath, $name, $index=0)
 
 addDomNode ($xPath, $name, $value="", $attributes="", $index=0)
 
 clean (&$meta)
 
 updateDomNode ($xPath, $meta, $no=0)
 
 getDomContent ($xPath, $name="", $index=0)
 
 replaceDomContent ($xPath, $name="", $index=0, $newNode)
 
 replace_content (&$node, &$new_content)
 Replace node contents. More...
 
 updateDomContent ($xPath, $name="", $index=0, $newNode)
 
 getFirstDomNode ($xPath)
 first dom-node More...
 
 updateFromDom ()
 
 deleteAllDbData ()
 
 _deleteAllChildMetaData ($a_ids)
 
 _getAllChildIds ($a_obj_id)
 

Data Fields

 $db
 Datenbank-handle. More...
 
 $LEFT = 0
 Left and right edge tags. More...
 
 $RIGHT = 0
 
 $DEPTH = 0
 Nesting level of the tags. More...
 
 $obj_id
 book-Obj-ID More...
 
 $obj_type
 The type of the data to those this entry belongs. More...
 
 $xml_parser
 SAX-Parser-Handle. More...
 
 $lastTag = ""
 last Tag-Name found More...
 
 $ilias
 
 $dom
 

Detailed Description

Definition at line 36 of file class.ilNestedSetXML.php.

Constructor & Destructor Documentation

◆ __construct()

ilNestedSetXML::__construct ( )

Constructor initilize netsed-set variables @access public.

Definition at line 98 of file class.ilNestedSetXML.php.

99 {
100 global $ilias,$ilDB;
101
102 $this->ilias =& $ilias;
103
104 $this->db =& $ilDB;
105 $this->LEFT = 0;
106 $this->RIGHT = 0;
107 $this->DEPTH = 0;
108
109 $this->param_modifier = "";
110 }
redirection script todo: (a better solution should control the processing via a xml file)
global $ilDB

References $ilDB, and $ilias.

Member Function Documentation

◆ _deleteAllChildMetaData()

ilNestedSetXML::_deleteAllChildMetaData (   $a_ids)
Delete meta data of a content object (pages, chapters)

@access public

Parameters
arrayof child ids
See also
_getAllChildIds()
Returns
boolean

Definition at line 1410 of file class.ilNestedSetXML.php.

1411 {
1412 global $ilBench, $ilDB;
1413
1414 #$ilBench->start('NestedSet','deleteAllChildMetaData');
1415
1416 // STEP TWO: DELETE ENTRIES IN xmlnestedset GET ALL tag_fks
1417 $in = " IN (";
1418 $in .= implode(",", ilUtil::quoteArray($a_ids));
1419 $in .= ")";
1420
1421 $query = "SELECT ns_tag_fk FROM xmlnestedset ".
1422 "WHERE ns_book_fk ".$in;
1423 $res = $ilDB->query($query);
1424 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
1425 {
1426 $tag_fks[$row->ns_tag_fk] = $row->ns_tag_fk;
1427 }
1428 $ilDB->query("DELETE FROM xmlnestedset WHERE ns_book_fk ".$in);
1429
1430
1431 // FINALLY DELETE
1432 $in = " IN (";
1433 $in .= implode(",", ilUtil::quoteArray($tag_fks));
1434 $in .= ")";
1435
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);
1439
1440 #$ilBench->stop('NestedSet','deleteAllChildMetaData');
1441 return true;
1442 }
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
static quoteArray($a_array)
Quotes all members of an array for usage in DB query statement.
global $ilBench
Definition: ilias.php:18

References $ilBench, $ilDB, $in, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, and ilUtil\quoteArray().

+ Here is the call graph for this function:

◆ _getAllChildIds()

ilNestedSetXML::_getAllChildIds (   $a_obj_id)
Get all child ids of a content object

@access public

Parameters
intobj_id
Returns
boolean

Definition at line 1450 of file class.ilNestedSetXML.php.

1451 {
1452 global $ilDB;
1453
1454 $query = "SELECT obj_id FROM lm_data WHERE lm_id = ".$ilDB->quote($a_obj_id)." ";
1455 $res = $ilDB->query($query);
1456 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
1457 {
1458 $ids[$row->obj_id] = $row->obj_id;
1459 }
1460 $ids[$a_obj_id] = $a_obj_id;
1461
1462 return $ids ? $ids : array();
1463 }

References $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

◆ addDomNode()

ilNestedSetXML::addDomNode (   $xPath,
  $name,
  $value = "",
  $attributes = "",
  $index = 0 
)
    adds node to DOM-Structure
Parameters
stringxPath
stringname
stringvalue
arrayattributes
integerindex
Returns
boolean @access public

Definition at line 741 of file class.ilNestedSetXML.php.

742 {
743 $nodes = $this->getXpathNodes($this->dom, $xPath);
744 if (count($nodes) > 0)
745 {
746 $node = $this->dom->create_element($name);
747 if ($value != "")
748 {
749 $node->set_content(utf8_encode($value));
750 }
751 if (is_array($attributes))
752 {
753 for ($i = 0; $i < count($attributes); $i++)
754 {
755 $node->set_attribute($attributes[$i]["name"], utf8_encode($attributes[$i]["value"]));
756 }
757 }
758 $nodes[$index]->append_child($node);
759 return true;
760 }
761 else
762 {
763 return false;
764 }
765 }
getXpathNodes(&$doc, $qry)
get node in dom-structure

References getXpathNodes().

+ Here is the call graph for this function:

◆ addXMLNode()

ilNestedSetXML::addXMLNode (   $xPath,
  $xml,
  $index = 0 
)
    parse XML code and add it to a given DOM object as a new node
Parameters
stringxPath path
stringxml xml to add
integerindex index to add
Returns
boolean @access public

Definition at line 628 of file class.ilNestedSetXML.php.

629 {
630 include_once "./Services/Xml/classes/class.ilXML2DOM.php";
631
632 $newDOM = new XML2DOM($xml);
633//echo "<br>addXMLNode:-".htmlspecialchars($this->dom->dump_mem(0));
634 $nodes = $this->getXpathNodes($this->dom, $xPath);
635
636 if (count($nodes) > 0)
637 {
638 $newDOM->insertNode($this->dom, $nodes[$index]);
639 return true;
640 }
641 else
642 {
643 return false;
644 }
645 }

References getXpathNodes().

Referenced by updateDomNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clean()

ilNestedSetXML::clean ( $meta)

Definition at line 767 of file class.ilNestedSetXML.php.

768 {
769 if(is_array($meta))
770 {
771 foreach($meta as $key => $value)
772 {
773 if(is_array($meta[$key]))
774 {
775 $this->clean($meta[$key]);
776 }
777 else
778 {
779 $meta[$key] = preg_replace("/&(?!amp;|lt;|gt;|quot;)/","&amp;",$meta[$key]);
780 $meta[$key] = preg_replace("/\"/","&quot;",$meta[$key]);
781 $meta[$key] = preg_replace("/</","&lt;",$meta[$key]);
782 $meta[$key] = preg_replace("/>/","&gt;",$meta[$key]);
783 }
784 }
785 }
786 return true;
787 }

References clean().

Referenced by clean(), startElement(), and updateDomNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteAllDbData()

ilNestedSetXML::deleteAllDbData ( )
deletes current db-data of $this->obj_id and $this->obj_type

@access private

Definition at line 1386 of file class.ilNestedSetXML.php.

1387 {
1388 global $ilBench, $ilDB;
1389
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)." ");
1392 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
1393 {
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"])." ");
1397 }
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');
1400
1401 }

References $ilBench, $ilDB, $res, $row, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by import(), and updateFromDom().

+ Here is the caller graph for this function:

◆ deleteDomNode()

ilNestedSetXML::deleteDomNode (   $xPath,
  $name,
  $index = 0 
)
    deletes node
Parameters
stringxPath path
stringname name
integerindex index
Returns
boolean @access public

Definition at line 686 of file class.ilNestedSetXML.php.

687 {
688 if ($index == "")
689 {
690 $index = 0;
691 }
692 if (strpos($index, ","))
693 {
694 $indices = explode(",", $index);
695 $nodes = $this->getXpathNodes($this->dom, $xPath);
696 if (count($nodes) > 0)
697 {
698 $children = $nodes[$indices[0]]->child_nodes();
699 if (count($children) > 0)
700 {
701 $j = 0;
702 for ($i = 0; $i < count($children); $i++)
703 {
704 if ($children[$i]->node_name() == $name)
705 {
706 if ($j == $indices[1])
707 {
708 $children[$i]->unlink_node();
709 return true;
710 }
711 $j++;
712 }
713 }
714 }
715 }
716 }
717 else
718 {
719 $nodes = $this->getXpathNodes($this->dom, $xPath . "/" . $name);
720 if (count($nodes) > 0)
721 {
722 $nodes[$index]->unlink_node();
723 return true;
724 }
725 }
726 return false;
727 }

References getXpathNodes().

+ Here is the call graph for this function:

◆ endElement()

ilNestedSetXML::endElement (   $parser,
  $name 
)

method called at a closing tag @access private

Parameters
parserparser xml-parser-handle
stringname name of the closing tag

Definition at line 219 of file class.ilNestedSetXML.php.

220 {
221 // {{{
222 $this->DEPTH--;
223 $this->LEFT += 1;
224 $this->lastTag = "";
225 // }}}
226 }

◆ export()

ilNestedSetXML::export (   $obj_id,
  $type 
)

Export-Function.

creates xml out of nested-set-structure

Parameters
intobj_id book-id
stringtype Object-Type of XML-Struktur
Returns
String xml-Structur
@access    public

Definition at line 315 of file class.ilNestedSetXML.php.

316 {
317 // {{{
318 global $ilDB;
319
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";
321 $result = $this->db->query($query);
322 if (DB::isError($result))
323 {
324 die($this->className."::checkTable(): ".$result->getMessage().":<br>".$query);
325 }
326
327 $xml = "";
328 $lastDepth = -1;
329
330 while (is_array($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC) ) )
331 {
332
333 // {{{ tags
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);
337 while (is_array($row_param = $result_param->fetchRow(ilDBConstants::FETCHMODE_ASSOC) ) )
338 {
339 $param_value = $row_param[param_value];
340 if (is_object($this->param_modifier))
341 {
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);
345 }
346 $Anfang .= " ".$row_param[param_name]."=\"".$param_value."\"";
347 }
348
349 $Anfang .= ">";
350 $Ende = "</".$row[tag_name].">";
351 // }}}
352
353 // {{{ TagValue
354 if ($row[tag_name]=="TAGVALUE")
355 {
356 $query = "SELECT * FROM xmlvalue WHERE tag_fk = ".$ilDB->quote($row[tag_pk])." ";
357 $result_value = $this->db->query($query);
358 $row_value = $result_value->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
359 $Anfang = $row_value["tag_value"];
360 $Ende = "";
361
362 $Anfang = htmlspecialchars($Anfang);
363 // $Anfang = utf8_encode($Anfang);
364 }
365 // }}}
366
367 $D = $row[tag_depth];
368
369 if ($D==$lastDepth)
370 {
371 $xml .= $xmlE[$D];
372 $xml .= $Anfang;
373 $xmlE[$D] = $Ende;
374 }
375 else if ($D>$lastDepth)
376 {
377 $xml .= $Anfang;
378 $xmlE[$D] = $Ende;
379 }
380 else
381 {
382 for ($i=$lastDepth;$i>=$D;$i--)
383 {
384 $xml .= $xmlE[$i];
385 }
386 $xml .= $Anfang;
387 $xmlE[$D] = $Ende;
388 }
389
390 $lastDepth = $D;
391
392 }
393
394 for ($i=$lastDepth;$i>0;$i--)
395 {
396 $xml .= $xmlE[$i];
397 }
398
399 return($xml);
400 // }}}
401 }
$result

References $ilDB, $obj_id, $query, $result, $row, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by initDom().

+ Here is the caller graph for this function:

◆ getDomContent()

ilNestedSetXML::getDomContent (   $xPath,
  $name = "",
  $index = 0 
)
    returns all contents of this node
Parameters
stringxPath
stringname
integerindex
Returns
string content @access public

Definition at line 1213 of file class.ilNestedSetXML.php.

1214 {
1215 if ($index == "")
1216 {
1217 $index = 0;
1218 }
1219# echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n";
1220 $nodes = $this->getXpathNodes($this->dom, $xPath);
1221 if (count($nodes) > 0)
1222 {
1223 $children = $nodes[$index]->child_nodes();
1224 if (count($children) > 0)
1225 {
1226 $k = 0;
1227 for ($i = 0; $i < count($children); $i++)
1228 {
1229//echo "<br>ilNestedSetXML::getDomContent-".$children[$i]->node_name()."-".$name;
1230 if ($name == "" ||
1231 $children[$i]->node_name() == $name)
1232 {
1233 $content[$k]["value"] = $children[$i]->get_content();
1234 $a = $children[$i]->attributes();
1235 for ($j = 0; $j < count($a); $j++)
1236 {
1237 $content[$k][$a[$j]->name()] = $a[$j]->value();
1238 }
1239 $k++;
1240 }
1241 }
1242# vd($content);
1243 return($content);
1244 }
1245 }
1246 return false;
1247 }

References getXpathNodes().

+ Here is the call graph for this function:

◆ getFirstDomContent()

ilNestedSetXML::getFirstDomContent (   $xPath)
    returns first content of this node
Parameters
stringxPath path
Returns
string content of node @access public

Definition at line 655 of file class.ilNestedSetXML.php.

656 {
657//echo "<br>ilNestedSetXML::getFirstDomContent-start-$xPath-"; flush();
658 $content = "";
659 if (is_object($this->dom))
660 {
661 $node = $this->getXpathNodes($this->dom,$xPath);
662 if (is_array($node))
663 {
664 $c = $node[0]->children();
665 //$content = $c[0]->content; // ## changed
666 if (is_object($c[0]))
667 {
668 $content = $c[0]->get_content(); // ## changed
669 }
670 }
671 }
672//echo "<br>ilNestedSetXML::getFirstDomContent-stop-$content-"; flush();
673 return($content);
674 }

References getXpathNodes().

+ Here is the call graph for this function:

◆ getFirstDomNode()

ilNestedSetXML::getFirstDomNode (   $xPath)

first dom-node

Parameters
stringxPath path
Returns
object node first node @access public

Definition at line 1364 of file class.ilNestedSetXML.php.

1365 {
1366 $node = $this->getXpathNodes($this->dom,$xPath);
1367 return($node[0]);
1368 }

References getXpathNodes().

+ Here is the call graph for this function:

◆ getTagName()

ilNestedSetXML::getTagName ( )

find first tag-name

Returns
string tagname

@access public

Definition at line 436 of file class.ilNestedSetXML.php.

437 {
438 global $ilDB;
439
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";
442 $result = $this->db->query($query);
444
445 return($row["tag_name"]);
446
447 }

References $ilDB, $query, $result, $row, and ilDBConstants\FETCHMODE_ASSOC.

◆ getTagValue()

ilNestedSetXML::getTagValue ( )

get tag content

Returns
array Content or sub-tags inbetween $this->LEFT and $this->RIGHT. @access public

Definition at line 481 of file class.ilNestedSetXML.php.

482 {
483 global $ilDB;
484
485 $V = array();
486
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";
488 $result = $this->db->query($query);
489 while (is_array($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC) ) )
490 {
491 if ($row[tag_name]=="TAGVALUE")
492 {
493 $query = "SELECT * FROM xmlvalue WHERE tag_fk = ".$ilDB->quote($row[tag_pk])." ";
494 $result2 = $this->db->query($query);
495 $row2 = $result2->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
496 $V[] = $row2[tag_value];
497 }
498 else
499 {
500 $xml = new ilNestedSetXml();
501
502 $xml->LEFT = $row["ns_l"];
503 $xml->RIGHT = $row["ns_r"];
504 $xml->DEPTH = $row["tag_depth"];
505 $xml->obj_id = $obj_id;
506 $xml->obj_type = $obj_type;
507
508 $V[] = $xml;
509
510 }
511 }
512
513 return($V);
514 }
$obj_type
The type of the data to those this entry belongs.

References $ilDB, $obj_id, $obj_type, $query, $result, $row, and ilDBConstants\FETCHMODE_ASSOC.

◆ getXpathNodes()

ilNestedSetXML::getXpathNodes ( $doc,
  $qry 
)

get node in dom-structure

Parameters
objectdoc
stringqry path to node
Returns
object nodeset @access public

Definition at line 566 of file class.ilNestedSetXML.php.

567 {
568 if (is_object($doc))
569 {
570 $xpath = $doc->xpath_init();
571 $ctx = $doc->xpath_new_context();
572//echo "<br><b>ilNestedSetXML::getXpathNodes</b>";
573 $result = $ctx->xpath_eval($qry);
574 if (is_array($result->nodeset))
575 {
576 return($result->nodeset);
577 }
578 }
579 return Null;
580 }

References $result.

Referenced by addDomNode(), addXMLNode(), deleteDomNode(), getDomContent(), getFirstDomContent(), getFirstDomNode(), replaceDomContent(), updateDomContent(), and updateDomNode().

+ Here is the caller graph for this function:

◆ import()

ilNestedSetXML::import (   $xmldata,
  $obj_id,
  $obj_type 
)

Import-Function.

Parameters
Stringxmldata xml-structure
intobj_id book-ID
stringobj_type Object-Type
@access     public

drop temporary table

create new temp-Table

initialize XML-Parser

transfer nested-set-structure ito table and drop temp-Table

Definition at line 236 of file class.ilNestedSetXML.php.

237 {
238 // {{{
242 $this->db->query("DROP TABLE IF EXISTS NestedSetTemp");
243
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),
254 KEY ns_l (ns_l),
255 KEY ns_r (ns_r),
256 KEY ns_book_fk (ns_book_fk)
257 ) TYPE=MyISAM ";
258 $this->db->query($Q);
259
260 $this->obj_id = $obj_id;
261 $this->obj_type = $obj_type;
262 $this->DEPTH = 0;
263 $this->LEFT = 0;
264 $this->RIGHT = 0;
265
266 $this->db->query("DELETE FROM NestedSetTemp");
267
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");
277
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)));
280 }
281 xml_parser_free($this->xml_parser);
282
286 $this->deleteAllDbData();
287
288 $this->db->query("INSERT INTO xmlnestedset SELECT * FROM NestedSetTemp");
289 $this->db->query("DROP TABLE IF EXISTS NestedSetTemp");
290 // }}}
291 }
sprintf('%.4f', $callTime)

References $obj_id, $obj_type, deleteAllDbData(), and sprintf.

+ Here is the call graph for this function:

◆ init()

ilNestedSetXML::init (   $obj_id,
  $obj_type 
)

initilialize Nested-Set-Structur

Parameters
integerobj_id object-id
stringobj_type type of object @access public

Definition at line 410 of file class.ilNestedSetXML.php.

411 {
412 global $ilDB;
413
414 // {{{
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";
418 $result = $this->db->query($query);
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 }

References $ilDB, $obj_id, $obj_type, $query, $result, $row, and ilDBConstants\FETCHMODE_ASSOC.

◆ initDom()

ilNestedSetXML::initDom ( )
    inits dom-object from given xml-content
Returns
boolean @access public

Definition at line 588 of file class.ilNestedSetXML.php.

589 {
590 $xml = $this->export($this->obj_id, $this->obj_type);
591
592/*
593 for testing
594 $xml_test = '
595 <MetaData>
596 <General Structure="Atomic">
597 <Identifier Catalog="ILIAS" Entry="34">Identifier 34 in ILIAS</Identifier>
598 <Identifier Catalog="ILIAS" Entry="45">Identifier 45 in ILIAS</Identifier>
599 <Identifier Catalog="ILIAS" Entry="67">Identifier 67 in ILIAS</Identifier>
600 </General>
601 </MetaData>
602 ';
603
604 $xml = $xml_test;
605*/
606
607 if ($xml=="")
608 {
609 return(false);
610 }
611 else
612 {
613 $this->dom = domxml_open_mem($xml);
614 return(true);
615 }
616 }
export($obj_id, $type)
Export-Function.
domxml_open_mem($str, $mode=0, &$error=NULL)

References domxml_open_mem(), and export().

+ Here is the call graph for this function:

◆ replace_content()

ilNestedSetXML::replace_content ( $node,
$new_content 
)

Replace node contents.

Needed as a workaround for bug/feature of set_content This version puts the content as the first child of the new node. If you need it somewhere else, simply move $newnode->set_content() where you want it.

Definition at line 1298 of file class.ilNestedSetXML.php.

1299 {
1300 $newnode =& $this->dom->create_element( $node->tagname() );
1301 $newnode->set_content( $new_content );
1302 $atts =& $node->attributes();
1303 foreach ( $atts as $att )
1304 {
1305 $newnode->set_attribute( $att->name(), $att->value() );
1306 }
1307 $kids =& $node->child_nodes();
1308 foreach ( $kids as $kid )
1309 {
1310 if ( $kid->node_type() != XML_TEXT_NODE )
1311 {
1312 $newnode->append_child( $kid );
1313 }
1314 }
1315 $node->replace_node( $newnode );
1316 }

Referenced by replaceDomContent().

+ Here is the caller graph for this function:

◆ replaceDomContent()

ilNestedSetXML::replaceDomContent (   $xPath,
  $name = "",
  $index = 0,
  $newNode 
)
    updates content of this node
Parameters
stringxPath
stringname
integerindex
arraynewNode @access public

Definition at line 1257 of file class.ilNestedSetXML.php.

1258 {
1259# echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n";
1260 $nodes = $this->getXpathNodes($this->dom, $xPath);
1261 if (count($nodes) > 0)
1262 {
1263 $children = $nodes[$index]->child_nodes();
1264 if (count($children) > 0)
1265 {
1266 for ($i = 0; $i < count($children); $i++)
1267 {
1268 if ($children[$i]->node_name() == $name &&
1269 is_array($newNode))
1270 {
1271 foreach ($newNode as $key => $val)
1272 {
1273 if ($key == "value")
1274 {
1275 $this->replace_content($children[$i], $val);
1276 }
1277 else
1278 {
1279 $children[$i]->set_attribute($key, $val);
1280 }
1281 }
1282 }
1283 }
1284 }
1285 }
1286 }
replace_content(&$node, &$new_content)
Replace node contents.

References getXpathNodes(), and replace_content().

+ Here is the call graph for this function:

◆ setParameterModifier()

ilNestedSetXML::setParameterModifier ( $a_object,
  $a_method 
)
Parameters
obja_object
Stringa_method Function-Name

Definition at line 298 of file class.ilNestedSetXML.php.

299 {
300 $this->param_modifier =& $a_object;
301 $this->param_modifier_method = $a_method;
302 }

◆ setTagName()

ilNestedSetXML::setTagName (   $tagName)

set tag-name

Parameters
stringtagName name of tag to be changed
Returns
string old tagname

@access public

Definition at line 458 of file class.ilNestedSetXML.php.

459 {
460 global $ilDB;
461
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);
464 $result = $this->db->query($query);
466
467 $query = "UPDATE xmltags SET tag_name= ".$ilDB->quote($tagName)." WHERE tag_pk = ".$ilDB->quote($row["ns_tag_fk"]);
468 $this->db->query($query);
469
470 return($row["tagName"]);
471
472 }

References $ilDB, $query, $result, $row, and ilDBConstants\FETCHMODE_ASSOC.

◆ setTagValue()

ilNestedSetXML::setTagValue (   $value)

set tag-content

Parameters
stringvalue @access public

add new

Definition at line 522 of file class.ilNestedSetXML.php.

523 {
524 global $ilDB;
525
526 $V = array();
527
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'
537 ORDER BY ns_l";
538 $result = $this->db->query($query);
539
540 if (is_array($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC) ) )
541 {
542
543 $query = "UPDATE xmlvalue SET tag_value = ".$ilDB->quote($value)." WHERE tag_value_pk = ".$ilDB->quote($row["tag_value_pk"])." ";
544 $this->db->query($query);
545
546 }
547 else
548 {
549
554 }
555 }

References $ilDB, $query, $result, $row, and ilDBConstants\FETCHMODE_ASSOC.

◆ startElement()

ilNestedSetXML::startElement (   $parser,
  $name,
  $attrs 
)

Method is called, at an introductory TAG @access private.

Parameters
parserparser xml-parser-handle
stringname the tag-name
arrayattrs assoziativ-array of all attributes inside the tag
Returns
integer pk Primary-Key of inserted xmltag

Insert Tag-Name

Definition at line 123 of file class.ilNestedSetXML.php.

124 {
125 // {{{
126 global $ilDB;
127
128 $this->lastTag = $name;
129 $this->LEFT += 1;
130 $this->RIGHT = $this->LEFT + 1;
131 $this->DEPTH++;
132
136 $this->db->query("INSERT INTO xmltags ( tag_name,tag_depth ) VALUES (".$ilDB->quote($name).",".$ilDB->quote($this->DEPTH).") ");
137 // $pk = mysql_insert_id();
138 $r = $this->db->query("SELECT LAST_INSERT_ID()");
139 $row = $r->fetchRow();
140
141 $pk = $row[0];
142
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);
145
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);
148
149 $this->clean($attrs);
150 if (is_array($attrs) && count($attrs)>0)
151 {
152 reset ($attrs);
153 while (list ($key, $val) = each ($attrs))
154 {
155 $this->db->query("INSERT INTO xmlparam ( tag_fk,param_name,param_value ) VALUES (".$ilDB->quote($pk).",".$ilDB->quote($key).",".$ilDB->quote($val).") ");
156 }
157 }
158
159 return($pk);
160 // }}}
161 }
$r
Definition: example_031.php:79

References $ilDB, $r, $row, and clean().

+ Here is the call graph for this function:

◆ updateDomContent()

ilNestedSetXML::updateDomContent (   $xPath,
  $name = "",
  $index = 0,
  $newNode 
)
    updates content of this node
Parameters
stringxPath
stringname
integerindex
arraynewNode @access public

Definition at line 1326 of file class.ilNestedSetXML.php.

1327 {
1328// echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n";
1329 $nodes = $this->getXpathNodes($this->dom, $xPath);
1330 if (count($nodes) > 0)
1331 {
1332 $children = $nodes[$index]->child_nodes();
1333 if (count($children) > 0)
1334 {
1335 for ($i = 0; $i < count($children); $i++)
1336 {
1337 if ($children[$i]->node_name() == $name &&
1338 is_array($newNode))
1339 {
1340 foreach ($newNode as $key => $val)
1341 {
1342 if ($key == "value")
1343 {
1344 $children[$i]->set_content($val);
1345 }
1346 else
1347 {
1348 $children[$i]->set_attribute($key, $val);
1349 }
1350 }
1351 }
1352 }
1353 }
1354 }
1355 }

References getXpathNodes().

+ Here is the call graph for this function:

◆ updateDomNode()

ilNestedSetXML::updateDomNode (   $xPath,
  $meta,
  $no = 0 
)
    updates dom node
Parameters
stringxPath
stringmeta
integerno @access public

Definition at line 796 of file class.ilNestedSetXML.php.

797 {
798 $this->clean($meta);
799 $update = false;
800 if ($xPath == "//Bibliography")
801 {
802 $nodes = $this->getXpathNodes($this->dom, $xPath . "/BibItem[" . ($no+1) . "]");
803 }
804 else
805 {
806 $nodes = $this->getXpathNodes($this->dom, $xPath);
807 }
808 if (count($nodes) > 0)
809 {
810
811 /* BibItem */
812 if ($nodes[0]->node_name() == "BibItem")
813 {
814 $xml = '<BibItem Type="' . ilUtil::stripSlashes($meta["Type"]) . '" Label="' . ilUtil::stripSlashes($meta["Label"]["Value"]) . '">';
815 $xml .= '<Identifier Catalog="' . ilUtil::stripSlashes($meta["Identifier"]["Catalog"]) . '" Entry="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Identifier"]["Entry"])) . '"/>';
816 for ($i = 0; $i < count($meta["Language"]); $i++)
817 {
818 $xml .= '<Language Language="' . ilUtil::stripSlashes($meta["Language"][$i]["Language"]) . '"/>';
819 }
820 for ($i = 0; $i < count($meta["Author"]); $i++)
821 {
822 $xml .= '<Author>';
823# for ($j = 0; $j < count($meta["Author"][$i]["FirstName"]); $j++)
824# {
825 $xml .= '<FirstName>' . ilUtil::stripSlashes($meta["Author"][$i]["FirstName"]) . '</FirstName>';
826# }
827# for ($j = 0; $j < count($meta["Author"][$i]["MiddleName"]); $j++)
828# {
829 $xml .= '<MiddleName>' . ilUtil::stripSlashes($meta["Author"][$i]["MiddleName"]) . '</MiddleName>';
830# }
831# for ($j = 0; $j < count($meta["Author"][$i]["LastName"]); $j++)
832# {
833 $xml .= '<LastName>' . ilUtil::stripSlashes($meta["Author"][$i]["LastName"]) . '</LastName>';
834# }
835 $xml .= '</Author>';
836 }
837 $xml .= '<Booktitle Language="' . ilUtil::stripSlashes($meta["Booktitle"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Booktitle"]["Value"]) . '</Booktitle>';
838 for ($i = 0; $i < count($meta["CrossRef"]); $i++)
839 {
840 $xml .= '<CrossRef>' . ilUtil::stripSlashes($meta["CrossRef"][$i]["Value"]) . '</CrossRef>';
841 }
842 $xml .= '<Edition>' . ilUtil::stripSlashes($meta["Edition"]["Value"]) . '</Edition>';
843 for ($i = 0; $i < count($meta["Editor"]); $i++)
844 {
845 $xml .= '<Editor>' . ilUtil::stripSlashes($meta["Editor"][$i]["Value"]) . '</Editor>';
846 }
847 $xml .= '<HowPublished Type="' . ilUtil::stripSlashes($meta["HowPublished"]["Type"]) . '"/>';
848 for ($i = 0; $i < count($meta["WherePublished"]); $i++)
849 {
850 $xml .= '<WherePublished>' . ilUtil::stripSlashes($meta["WherePublished"][$i]["Value"]) . '</WherePublished>';
851 }
852 for ($i = 0; $i < count($meta["Institution"]); $i++)
853 {
854 $xml .= '<Institution>' . ilUtil::stripSlashes($meta["Institution"][$i]["Value"]) . '</Institution>';
855 }
856 if (is_array($meta["Journal"]))
857 {
858 $xml .= '<Journal Note="' . ilUtil::stripSlashes($meta["Journal"]["Note"]) . '" Number="' . ilUtil::stripSlashes($meta["Journal"]["Number"]) . '" Organization="' . ilUtil::stripSlashes($meta["Journal"]["Organization"]) . '"/>';
859 }
860 for ($i = 0; $i < count($meta["Keyword"]); $i++)
861 {
862 $xml .= '<Keyword Language="' . ilUtil::stripSlashes($meta["Keyword"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Keyword"][$i]["Value"]) . '</Keyword>';
863 }
864 if (is_array($meta["Month"]))
865 {
866 $xml .= '<Month>' . ilUtil::stripSlashes($meta["Month"]["Value"]) . '</Month>';
867 }
868 if (is_array($meta["Pages"]))
869 {
870 $xml .= '<Pages>' . ilUtil::stripSlashes($meta["Pages"]["Value"]) . '</Pages>';
871 }
872 $xml .= '<Publisher>' . ilUtil::stripSlashes($meta["Publisher"]["Value"]) . '</Publisher>';
873 for ($i = 0; $i < count($meta["School"]); $i++)
874 {
875 $xml .= '<School>' . ilUtil::stripSlashes($meta["School"][$i]["Value"]) . '</School>';
876 }
877 if (is_array($meta["Series"]))
878 {
879 $xml .= '<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"]))
883 {
884# $xml .= '<SeriesEditor>' . ilUtil::stripSlashes($meta["Series"]["SeriesEditor"][$i]) . '</SeriesEditor>';
885 $xml .= '<SeriesEditor>' . ilUtil::stripSlashes($meta["Series"]["SeriesEditor"]) . '</SeriesEditor>';
886 }
887 if (isset($meta["Series"]["SeriesVolume"]))
888 {
889 $xml .= '<SeriesVolume>' . ilUtil::stripSlashes($meta["Series"]["SeriesVolume"]) . '</SeriesVolume>';
890 }
891 $xml .= '</Series>';
892 }
893 $xml .= '<Year>' . ilUtil::stripSlashes($meta["Year"]["Value"]) . '</Year>';
894 if ($meta["URL_ISBN_ISSN"]["Type"] == "URL")
895 {
896 $xml .= '<URL>' . ilUtil::stripSlashes($meta["URL_ISBN_ISSN"]["Value"]) . '</URL>';
897 }
898 else if ($meta["URL_ISBN_ISSN"]["Type"] == "ISBN")
899 {
900 $xml .= '<ISBN>' . ilUtil::stripSlashes($meta["URL_ISBN_ISSN"]["Value"]) . '</ISBN>';
901 }
902 else if ($meta["URL_ISBN_ISSN"]["Type"] == "ISSN")
903 {
904 $xml .= '<ISSN>' . ilUtil::stripSlashes($meta["URL_ISBN_ISSN"]["Value"]) . '</ISSN>';
905 }
906 $xml .= '</BibItem>';
907# echo htmlspecialchars($xml);
908
909 $update = true;
910 }
911
912 /* General */
913 else if ($nodes[0]->node_name() == "General")
914 {
915
916 $xml = '<General Structure="' . ilUtil::stripSlashes($meta["Structure"]) . '">';
917 for ($i = 0; $i < count($meta["Identifier"]); $i++)
918 {
919 $xml .= '<Identifier Catalog="' . ilUtil::stripSlashes($meta["Identifier"][$i]["Catalog"]) . '" Entry="' .
920 str_replace("\"", "", ilUtil::stripSlashes($meta["Identifier"][$i]["Entry"])) . '"/>';
921 }
922
923 $xml .= '<Title Language="' .
924 ilUtil::stripSlashes($meta["Title"]["Language"]) . '">' .
925 ilUtil::stripSlashes($meta["Title"]["Value"]) . '</Title>';
926 for ($i = 0; $i < count($meta["Language"]); $i++)
927 {
928 $xml .= '<Language Language="' . ilUtil::stripSlashes($meta["Language"][$i]["Language"]) . '"/>';
929 }
930 for ($i = 0; $i < count($meta["Description"]); $i++)
931 {
932 $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Description"][$i]["Value"]) . '</Description>';
933 }
934 for ($i = 0; $i < count($meta["Keyword"]); $i++)
935 {
936 $xml .= '<Keyword Language="' . ilUtil::stripSlashes($meta["Keyword"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Keyword"][$i]["Value"]) . '</Keyword>';
937 }
938 if ($meta["Coverage"] != "")
939 {
940 $xml .= '<Coverage Language="' . ilUtil::stripSlashes($meta["Coverage"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Coverage"]["Value"]) . '</Coverage>';
941 }
942 $xml .= '</General>';
943//echo "<br><br>".htmlspecialchars($xml);
944
945 $update = true;
946 }
947
948 /* Lifecycle */
949 else if ($nodes[0]->node_name() == "Lifecycle")
950 {
951 $xml = '<Lifecycle Status="' . $meta["Status"] . '">';
952 $xml .= '<Version Language="' . ilUtil::stripSlashes($meta["Version"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Version"]["Value"]) . '</Version>';
953 for ($i = 0; $i < count($meta["Contribute"]); $i++)
954 {
955 $xml .= '<Contribute Role="' . ilUtil::stripSlashes($meta["Contribute"][$i]["Role"]) . '">';
956 $xml .= '<Date>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Date"]) . '</Date>';
957 for ($j = 0; $j < count($meta["Contribute"][$i]["Entity"]); $j++)
958 {
959 $xml .= '<Entity>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Entity"][$j]) . '</Entity>';
960 }
961 $xml .= '</Contribute>';
962 }
963 $xml .= '</Lifecycle>';
964# echo htmlspecialchars($xml);
965
966 $update = true;
967 }
968
969 /* Meta-Metadata */
970 else if ($nodes[0]->node_name() == "Meta-Metadata")
971 {
972
973 $xml = '<Meta-Metadata MetadataScheme="LOM v 1.0" Language="' . ilUtil::stripSlashes($meta["Language"]) . '">';
974 for ($i = 0; $i < count($meta["Identifier"]); $i++)
975 {
976 $xml .= '<Identifier Catalog="' . ilUtil::stripSlashes($meta["Identifier"][$i]["Catalog"]) . '" Entry="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Identifier"][$i]["Entry"])) . '"/>';
977 }
978 for ($i = 0; $i < count($meta["Contribute"]); $i++)
979 {
980 $xml .= '<Contribute Role="' . ilUtil::stripSlashes($meta["Contribute"][$i]["Role"]) . '">';
981 $xml .= '<Date>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Date"]) . '</Date>';
982 for ($j = 0; $j < count($meta["Contribute"][$i]["Entity"]); $j++)
983 {
984 $xml .= '<Entity>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Entity"][$j]) . '</Entity>';
985 }
986 $xml .= '</Contribute>';
987 }
988 $xml .= '</Meta-Metadata>';
989# echo htmlspecialchars($xml);
990
991 $update = true;
992 }
993
994 /* Technical */
995 else if ($nodes[0]->node_name() == "Technical")
996 {
997
998 $xml = '<Technical>';
999 for ($i = 0; $i < count($meta["Format"]); $i++)
1000 {
1001 $xml .= '<Format>' . ilUtil::stripSlashes($meta["Format"][$i]) . '</Format>';
1002 }
1003 if ($meta["Size"] != "")
1004 {
1005 $xml .= '<Size>' . ilUtil::stripSlashes($meta["Size"]) . '</Size>';
1006 }
1007 for ($i = 0; $i < count($meta["Location"]); $i++)
1008 {
1009 $xml .= '<Location Type="' . ilUtil::stripSlashes($meta["Location"][$i]["Type"]) . '">' . ilUtil::stripSlashes($meta["Location"][$i]["Value"]) . '</Location>';
1010 }
1011 if (is_array($meta["Requirement"]))
1012 {
1013 for ($i = 0; $i < count($meta["Requirement"]); $i++)
1014 {
1015 $xml .= '<Requirement>';
1016 $xml .= '<Type>';
1017 if (is_array($meta["Requirement"][$i]["Type"]["OperatingSystem"]))
1018 {
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"])) . '"/>';
1020 }
1021 if (is_array($meta["Requirement"][$i]["Type"]["Browser"]))
1022 {
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"])) . '"/>';
1024 }
1025 $xml .= '</Type>';
1026 $xml .= '</Requirement>';
1027 }
1028 }
1029 else if (is_array($meta["OrComposite"]))
1030 {
1031 for ($j = 0; $j < count($meta["OrComposite"]); $j++)
1032 {
1033 $xml .= '<OrComposite>';
1034 for ($i = 0; $i < count($meta["OrComposite"][$j]["Requirement"]); $i++)
1035 {
1036 $xml .= '<Requirement>';
1037 $xml .= '<Type>';
1038 if (is_array($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["OperatingSystem"]))
1039 {
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"])) . '"/>';
1041 }
1042 if (is_array($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["Browser"]))
1043 {
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"])) . '"/>';
1045 }
1046 $xml .= '</Type>';
1047 $xml .= '</Requirement>';
1048 }
1049 $xml .= '</OrComposite>';
1050 }
1051 }
1052 if (is_array($meta["InstallationRemarks"]))
1053 {
1054 $xml .= '<InstallationRemarks Language="' . ilUtil::stripSlashes($meta["InstallationRemarks"]["Language"]) . '">' . ilUtil::stripSlashes($meta["InstallationRemarks"]["Value"]) . '</InstallationRemarks>';
1055 }
1056 if (is_array($meta["OtherPlattformRequirements"]))
1057 {
1058 $xml .= '<OtherPlattformRequirements Language="' . ilUtil::stripSlashes($meta["OtherPlattformRequirements"]["Language"]) . '">' . ilUtil::stripSlashes($meta["OtherPlattformRequirements"]["Value"]) . '</OtherPlattformRequirements>';
1059 }
1060 if ($meta["Duration"] != "")
1061 {
1062 $xml .= '<Duration>' . ilUtil::stripSlashes($meta["Duration"]) . '</Duration>';
1063 }
1064 $xml .= '</Technical>';
1065# echo htmlspecialchars($xml);
1066
1067 $update = true;
1068 }
1069
1070 /* Educational */
1071 else if ($nodes[0]->node_name() == "Educational")
1072 {
1073
1074 $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"]) . '">';
1075 $xml .= '<TypicalLearningTime>' . ilUtil::stripSlashes($meta["TypicalLearningTime"]) . '</TypicalLearningTime>';
1076 for ($i = 0; $i < count($meta["TypicalAgeRange"]); $i++)
1077 {
1078 $xml .= '<TypicalAgeRange Language="' . ilUtil::stripSlashes($meta["TypicalAgeRange"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["TypicalAgeRange"][$i]["Value"]) . '</TypicalAgeRange>';
1079 }
1080 for ($i = 0; $i < count($meta["Description"]); $i++)
1081 {
1082 $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Description"][$i]["Value"]) . '</Description>';
1083 }
1084 for ($i = 0; $i < count($meta["Language"]); $i++)
1085 {
1086 $xml .= '<Language Language="' . ilUtil::stripSlashes($meta["Language"][$i]["Language"]) . '"/>';
1087 }
1088 $xml .= '</Educational>';
1089
1090 $update = true;
1091 }
1092
1093 /* Rights */
1094 else if ($nodes[0]->node_name() == "Rights")
1095 {
1096
1097 $xml = '<Rights Cost="' . ilUtil::stripSlashes($meta["Cost"]) . '" CopyrightAndOtherRestrictions="' . ilUtil::stripSlashes($meta["CopyrightAndOtherRestrictions"]) . '">';
1098 for ($i = 0; $i < count($meta["Description"]); $i++)
1099 {
1100 $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Description"][$i]["Value"]) . '</Description>';
1101 }
1102 $xml .= '</Rights>';
1103
1104 $update = true;
1105 }
1106
1107 /* Relation */
1108 else if ($nodes[0]->node_name() == "Relation")
1109 {
1110
1111# for ($j = 0; $j < count($meta["Relation"]); $j++)
1112# {
1113 $meta["Relation"][0] = $meta;
1114 $j = 0;
1115 $xml = '<Relation Kind="' . ilUtil::stripSlashes($meta["Relation"][$j]["Kind"]) . '">';
1116 $xml .= '<Resource>';
1117 for ($i = 0; $i < count($meta["Relation"][$j]["Resource"]["Identifier"]); $i++)
1118 {
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"])) . '"/>';
1120 }
1121 for ($i = 0; $i < count($meta["Relation"][$j]["Resource"]["Description"]); $i++)
1122 {
1123 $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Description"][$i]["Value"]) . '</Description>';
1124 }
1125 $xml .= '</Resource>';
1126 $xml .= '</Relation>';
1127# echo htmlspecialchars($xml);
1128# }
1129
1130 $update = true;
1131 }
1132
1133 /* Annotation */
1134 else if ($nodes[0]->node_name() == "Annotation")
1135 {
1136
1137# for ($i = 0; $i < count($meta["Annotation"]); $i++)
1138# {
1139 $meta["Annotation"][0] = $meta;
1140 $i = 0;
1141 $xml = '<Annotation>';
1142 $xml .= '<Entity>' . ilUtil::stripSlashes($meta["Annotation"][$i]["Entity"]) . '</Entity>';
1143 $xml .= '<Date>' . ilUtil::stripSlashes($meta["Annotation"][$i]["Date"]) . '</Date>';
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);
1147# }
1148
1149 $update = true;
1150 }
1151
1152 /* Classification */
1153 else if ($nodes[0]->node_name() == "Classification")
1154 {
1155
1156# for ($j = 0; $j < count($meta["Classification"]); $j++)
1157# {
1158 $meta["Classification"][0] = $meta;
1159 $j = 0;
1160 $xml = '<Classification Purpose="' . ilUtil::stripSlashes($meta["Classification"][$j]["Purpose"]) . '">';
1161 for ($k = 0; $k < count($meta["Classification"][$j]["TaxonPath"]); $k++)
1162 {
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++)
1166 {
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>';
1168 }
1169 $xml .= '</TaxonPath>';
1170 }
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++)
1173 {
1174 $xml .= '<Keyword Language="' . ilUtil::stripSlashes($meta["Classification"][$j]["Keyword"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Classification"][$j]["Keyword"][$i]["Value"]) . '</Keyword>';
1175 }
1176 $xml .= '</Classification>';
1177# echo htmlspecialchars($xml);
1178# }
1179
1180 $update = true;
1181 }
1182
1183 if ($update)
1184 {
1185 $nodes[0]->unlink_node();
1186
1187 if ($xPath != "//Bibliography")
1188 {
1189 $xPath = "//MetaData";
1190 }
1191//echo "<br><br>savedA:".htmlspecialchars($this->dom->dump_mem(0));
1192 $this->addXMLNode($xPath, $xml);
1193//echo "<br><br>savedB:".htmlspecialchars($this->dom->dump_mem(0));
1194 }
1195 return true;
1196 }
1197 else
1198 {
1199 return false;
1200 }
1201 }
addXMLNode($xPath, $xml, $index=0)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References addXMLNode(), clean(), getXpathNodes(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ updateFromDom()

ilNestedSetXML::updateFromDom ( )
imports new xml-data from dom into nested set

@access public

Definition at line 1374 of file class.ilNestedSetXML.php.

1375 {
1376 $this->deleteAllDbData();
1377 $xml = $this->dom->dump_mem(0);
1378 $this->import($xml,$this->obj_id,$this->obj_type);
1379
1380 }

References $obj_id, $obj_type, and deleteAllDbData().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilNestedSetXML::$db

Datenbank-handle.

Definition at line 43 of file class.ilNestedSetXML.php.

◆ $DEPTH

ilNestedSetXML::$DEPTH = 0

Nesting level of the tags.

stored in database

Definition at line 55 of file class.ilNestedSetXML.php.

◆ $dom

ilNestedSetXML::$dom

Definition at line 89 of file class.ilNestedSetXML.php.

◆ $ilias

ilNestedSetXML::$ilias

Definition at line 82 of file class.ilNestedSetXML.php.

Referenced by __construct().

◆ $lastTag

ilNestedSetXML::$lastTag = ""

last Tag-Name found

Definition at line 75 of file class.ilNestedSetXML.php.

◆ $LEFT

ilNestedSetXML::$LEFT = 0

Left and right edge tags.

Definition at line 48 of file class.ilNestedSetXML.php.

◆ $obj_id

ilNestedSetXML::$obj_id

book-Obj-ID

Definition at line 60 of file class.ilNestedSetXML.php.

Referenced by export(), getTagValue(), import(), init(), and updateFromDom().

◆ $obj_type

ilNestedSetXML::$obj_type

The type of the data to those this entry belongs.

Definition at line 65 of file class.ilNestedSetXML.php.

Referenced by getTagValue(), import(), init(), and updateFromDom().

◆ $RIGHT

ilNestedSetXML::$RIGHT = 0

Definition at line 49 of file class.ilNestedSetXML.php.

◆ $xml_parser

ilNestedSetXML::$xml_parser

SAX-Parser-Handle.

Definition at line 70 of file class.ilNestedSetXML.php.


The documentation for this class was generated from the following file: