ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ()
 inits dom-object from given xml-content More...
 
 addXMLNode ($xPath, $xml, $index=0)
 parse XML code and add it to a given DOM object as a new node More...
 
 getFirstDomContent ($xPath)
 returns first content of this node More...
 
 deleteDomNode ($xPath, $name, $index=0)
 deletes node More...
 
 addDomNode ($xPath, $name, $value="", $attributes="", $index=0)
 adds node to DOM-Structure More...
 
 clean (&$meta)
 
 updateDomNode ($xPath, $meta, $no=0)
 updates dom node More...
 
 getDomContent ($xPath, $name="", $index=0)
 returns all contents of this node More...
 
 replaceDomContent ($xPath, $name="", $index=0, $newNode)
 updates content of this node More...
 
 replace_content (&$node, &$new_content)
 Replace node contents. More...
 
 updateDomContent ($xPath, $name="", $index=0, $newNode)
 updates content of this node More...
 
 getFirstDomNode ($xPath)
 first dom-node More...
 
 updateFromDom ()
 imports new xml-data from dom into nested set @access public More...
 
 deleteAllDbData ()
 deletes current db-data of $this->obj_id and $this->obj_type @access private More...
 
 _deleteAllChildMetaData ($a_ids)
 Delete meta data of a content object (pages, chapters) @access public. More...
 
 _getAllChildIds ($a_obj_id)
 Get all child ids of a content object @access public. More...
 

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 1239 of file class.ilNestedSetXML.php.

1240 {
1241 global $ilBench, $ilDB;
1242
1243 #$ilBench->start('NestedSet','deleteAllChildMetaData');
1244
1245 // STEP TWO: DELETE ENTRIES IN xmlnestedset GET ALL tag_fks
1246 $in = " IN (";
1247 $in .= implode(",", ilUtil::quoteArray($a_ids));
1248 $in .= ")";
1249
1250 $query = "SELECT ns_tag_fk FROM xmlnestedset " .
1251 "WHERE ns_book_fk " . $in;
1252 $res = $ilDB->query($query);
1253 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1254 $tag_fks[$row->ns_tag_fk] = $row->ns_tag_fk;
1255 }
1256 $ilDB->query("DELETE FROM xmlnestedset WHERE ns_book_fk " . $in);
1257
1258
1259 // FINALLY DELETE
1260 $in = " IN (";
1261 $in .= implode(",", ilUtil::quoteArray($tag_fks));
1262 $in .= ")";
1263
1264 $ilDB->query("DELETE FROM xmlparam WHERE tag_fk " . $in);
1265 $ilDB->query("DELETE FROM xmlvalue WHERE tag_fk " . $in);
1266 $ilDB->query("DELETE FROM xmltags WHERE tag_pk " . $in);
1267
1268 #$ilBench->stop('NestedSet','deleteAllChildMetaData');
1269 return true;
1270 }
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
$row
$query
foreach($_POST as $key=> $value) $res

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 1278 of file class.ilNestedSetXML.php.

1279 {
1280 global $ilDB;
1281
1282 $query = "SELECT obj_id FROM lm_data WHERE lm_id = " . $ilDB->quote($a_obj_id) . " ";
1283 $res = $ilDB->query($query);
1284 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1285 $ids[$row->obj_id] = $row->obj_id;
1286 }
1287 $ids[$a_obj_id] = $a_obj_id;
1288
1289 return $ids ? $ids : array();
1290 }

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 686 of file class.ilNestedSetXML.php.

687 {
688 $nodes = $this->getXpathNodes($this->dom, $xPath);
689 if (count($nodes) > 0) {
690 $node = $this->dom->create_element($name);
691 if ($value != "") {
692 $node->set_content(utf8_encode($value));
693 }
694 if (is_array($attributes)) {
695 for ($i = 0; $i < count($attributes); $i++) {
696 $node->set_attribute($attributes[$i]["name"], utf8_encode($attributes[$i]["value"]));
697 }
698 }
699 $nodes[$index]->append_child($node);
700 return true;
701 } else {
702 return false;
703 }
704 }
getXpathNodes(&$doc, $qry)
get node in dom-structure
$i
Definition: disco.tpl.php:19
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85
$index
Definition: metadata.php:60

References $attributes, $i, $index, $name, $nodes, and 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 589 of file class.ilNestedSetXML.php.

590 {
591 include_once "./Services/Xml/classes/class.ilXML2DOM.php";
592
593 $newDOM = new XML2DOM($xml);
594 //echo "<br>addXMLNode:-".htmlspecialchars($this->dom->dump_mem(0));
595 $nodes = $this->getXpathNodes($this->dom, $xPath);
596
597 if (count($nodes) > 0) {
598 $newDOM->insertNode($this->dom, $nodes[$index]);
599 return true;
600 } else {
601 return false;
602 }
603 }

References $index, $nodes, $xml, and 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 706 of file class.ilNestedSetXML.php.

707 {
708 if (is_array($meta)) {
709 foreach ($meta as $key => $value) {
710 if (is_array($meta[$key])) {
711 $this->clean($meta[$key]);
712 } else {
713 $meta[$key] = preg_replace("/&(?!amp;|lt;|gt;|quot;)/", "&amp;", $meta[$key]);
714 $meta[$key] = preg_replace("/\"/", "&quot;", $meta[$key]);
715 $meta[$key] = preg_replace("/</", "&lt;", $meta[$key]);
716 $meta[$key] = preg_replace("/>/", "&gt;", $meta[$key]);
717 }
718 }
719 }
720 return true;
721 }
$key
Definition: croninfo.php:18

References $key, and 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 1217 of file class.ilNestedSetXML.php.

1218 {
1219 global $ilBench, $ilDB;
1220
1221 #$ilBench->start('NestedSet','deleteAllDBData');
1222 $res = $this->db->query("SELECT * FROM xmlnestedset WHERE ns_book_fk = " . $ilDB->quote($this->obj_id) . " AND ns_type = " . $ilDB->quote($this->obj_type) . " ");
1223 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
1224 $this->db->query("DELETE FROM xmlparam WHERE tag_fk = " . $ilDB->quote($row["ns_tag_fk"]) . " ");
1225 $this->db->query("DELETE FROM xmlvalue WHERE tag_fk = " . $ilDB->quote($row["ns_tag_fk"]) . " ");
1226 $this->db->query("DELETE FROM xmltags WHERE tag_pk = " . $ilDB->quote($row["ns_tag_fk"]) . " ");
1227 }
1228 $this->db->query("DELETE FROM xmlnestedset WHERE ns_book_fk = " . $ilDB->quote($this->obj_id) . " AND ns_type = " . $ilDB->quote($this->obj_type) . " ");
1229 #$ilBench->stop('NestedSet','deleteAllDBData');
1230 }

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 641 of file class.ilNestedSetXML.php.

642 {
643 if ($index == "") {
644 $index = 0;
645 }
646 if (strpos($index, ",")) {
647 $indices = explode(",", $index);
648 $nodes = $this->getXpathNodes($this->dom, $xPath);
649 if (count($nodes) > 0) {
650 $children = $nodes[$indices[0]]->child_nodes();
651 if (count($children) > 0) {
652 $j = 0;
653 for ($i = 0; $i < count($children); $i++) {
654 if ($children[$i]->node_name() == $name) {
655 if ($j == $indices[1]) {
656 $children[$i]->unlink_node();
657 return true;
658 }
659 $j++;
660 }
661 }
662 }
663 }
664 } else {
665 $nodes = $this->getXpathNodes($this->dom, $xPath . "/" . $name);
666 if (count($nodes) > 0) {
667 $nodes[$index]->unlink_node();
668 return true;
669 }
670 }
671 return false;
672 }

References $i, $index, $name, $nodes, and 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 211 of file class.ilNestedSetXML.php.

212 {
213 // {{{
214 $this->DEPTH--;
215 $this->LEFT += 1;
216 $this->lastTag = "";
217 // }}}
218 }

◆ 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 307 of file class.ilNestedSetXML.php.

308 {
309 // {{{
310 global $ilDB;
311
312 $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";
313 $result = $this->db->query($query);
314 if (DB::isError($result)) {
315 die($this->className . "::checkTable(): " . $result->getMessage() . ":<br>" . $query);
316 }
317
318 $xml = "";
319 $lastDepth = -1;
320
321 while (is_array($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC))) {
322
323 // {{{ tags
324 $Anfang = "<" . $row[tag_name];
325 $query = "SELECT * FROM xmlparam WHERE tag_fk = " . $ilDB->quote($row[tag_pk]) . " ";
326 $result_param = $this->db->query($query);
327 while (is_array($row_param = $result_param->fetchRow(ilDBConstants::FETCHMODE_ASSOC))) {
328 $param_value = $row_param[param_value];
329 if (is_object($this->param_modifier)) {
330 $obj = &$this->param_modifier;
331 $method = $this->param_modifier_method;
332 $param_value = $obj->$method($row[tag_name], $row_param[param_name], $param_value);
333 }
334 $Anfang .= " " . $row_param[param_name] . "=\"" . $param_value . "\"";
335 }
336
337 $Anfang .= ">";
338 $Ende = "</" . $row[tag_name] . ">";
339 // }}}
340
341 // {{{ TagValue
342 if ($row[tag_name] == "TAGVALUE") {
343 $query = "SELECT * FROM xmlvalue WHERE tag_fk = " . $ilDB->quote($row[tag_pk]) . " ";
344 $result_value = $this->db->query($query);
345 $row_value = $result_value->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
346 $Anfang = $row_value["tag_value"];
347 $Ende = "";
348
349 $Anfang = htmlspecialchars($Anfang);
350 // $Anfang = utf8_encode($Anfang);
351 }
352 // }}}
353
354 $D = $row[tag_depth];
355
356 if ($D == $lastDepth) {
357 $xml .= $xmlE[$D];
358 $xml .= $Anfang;
359 $xmlE[$D] = $Ende;
360 } elseif ($D > $lastDepth) {
361 $xml .= $Anfang;
362 $xmlE[$D] = $Ende;
363 } else {
364 for ($i = $lastDepth;$i >= $D;$i--) {
365 $xml .= $xmlE[$i];
366 }
367 $xml .= $Anfang;
368 $xmlE[$D] = $Ende;
369 }
370
371 $lastDepth = $D;
372 }
373
374 for ($i = $lastDepth;$i > 0;$i--) {
375 $xml .= $xmlE[$i];
376 }
377
378 return($xml);
379 // }}}
380 }
$result
$type

References $i, $ilDB, $obj_id, $query, $result, $row, $type, $xml, 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 1070 of file class.ilNestedSetXML.php.

1071 {
1072 if ($index == "") {
1073 $index = 0;
1074 }
1075 # echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n";
1076 $nodes = $this->getXpathNodes($this->dom, $xPath);
1077 if (count($nodes) > 0) {
1078 $children = $nodes[$index]->child_nodes();
1079 if (count($children) > 0) {
1080 $k = 0;
1081 for ($i = 0; $i < count($children); $i++) {
1082 //echo "<br>ilNestedSetXML::getDomContent-".$children[$i]->node_name()."-".$name;
1083 if ($name == "" ||
1084 $children[$i]->node_name() == $name) {
1085 $content[$k]["value"] = $children[$i]->get_content();
1086 $a = $children[$i]->attributes();
1087 for ($j = 0; $j < count($a); $j++) {
1088 $content[$k][$a[$j]->name()] = $a[$j]->value();
1089 }
1090 $k++;
1091 }
1092 }
1093 # vd($content);
1094 return($content);
1095 }
1096 }
1097 return false;
1098 }

References $i, $index, $name, $nodes, and 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 613 of file class.ilNestedSetXML.php.

614 {
615 //echo "<br>ilNestedSetXML::getFirstDomContent-start-$xPath-"; flush();
616 $content = "";
617 if (is_object($this->dom)) {
618 $node = $this->getXpathNodes($this->dom, $xPath);
619 if (is_array($node)) {
620 $c = $node[0]->children();
621 //$content = $c[0]->content; // ## changed
622 if (is_object($c[0])) {
623 $content = $c[0]->get_content(); // ## changed
624 }
625 }
626 }
627 //echo "<br>ilNestedSetXML::getFirstDomContent-stop-$content-"; flush();
628 return($content);
629 }

References $c, and 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 1196 of file class.ilNestedSetXML.php.

1197 {
1198 $node = $this->getXpathNodes($this->dom, $xPath);
1199 return($node[0]);
1200 }

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 415 of file class.ilNestedSetXML.php.

416 {
417 global $ilDB;
418
419 $this->db->setLimit(1);
420 $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";
421 $result = $this->db->query($query);
423
424 return($row["tag_name"]);
425 }

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 458 of file class.ilNestedSetXML.php.

459 {
460 global $ilDB;
461
462 $V = array();
463
464 $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";
465 $result = $this->db->query($query);
466 while (is_array($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC))) {
467 if ($row[tag_name] == "TAGVALUE") {
468 $query = "SELECT * FROM xmlvalue WHERE tag_fk = " . $ilDB->quote($row[tag_pk]) . " ";
469 $result2 = $this->db->query($query);
470 $row2 = $result2->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
471 $V[] = $row2[tag_value];
472 } else {
473 $xml = new ilNestedSetXml();
474
475 $xml->LEFT = $row["ns_l"];
476 $xml->RIGHT = $row["ns_r"];
477 $xml->DEPTH = $row["tag_depth"];
478 $xml->obj_id = $obj_id;
479 $xml->obj_type = $obj_type;
480
481 $V[] = $xml;
482 }
483 }
484
485 return($V);
486 }
$obj_type
The type of the data to those this entry belongs.

References $ilDB, $obj_id, $obj_type, $query, $result, $row, $xml, 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 532 of file class.ilNestedSetXML.php.

533 {
534 if (is_object($doc)) {
535 $xpath = $doc->xpath_init();
536 $ctx = $doc->xpath_new_context();
537 //echo "<br><b>ilNestedSetXML::getXpathNodes</b>";
538 $result = $ctx->xpath_eval($qry);
539 if (is_array($result->nodeset)) {
540 return($result->nodeset);
541 }
542 }
543 return null;
544 }

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 228 of file class.ilNestedSetXML.php.

229 {
230 // {{{
234 $this->db->query("DROP TABLE IF EXISTS NestedSetTemp");
235
239 $Q = "CREATE TEMPORARY TABLE NestedSetTemp (
240 ns_book_fk int(11) NOT NULL,
241 ns_type char(50) NOT NULL,
242 ns_tag_fk int(11) NOT NULL,
243 ns_l int(11) NOT NULL,
244 ns_r int(11) NOT NULL,
245 KEY ns_tag_fk (ns_tag_fk),
246 KEY ns_l (ns_l),
247 KEY ns_r (ns_r),
248 KEY ns_book_fk (ns_book_fk)
249 ) TYPE=MyISAM ";
250 $this->db->query($Q);
251
252 $this->obj_id = $obj_id;
253 $this->obj_type = $obj_type;
254 $this->DEPTH = 0;
255 $this->LEFT = 0;
256 $this->RIGHT = 0;
257
258 $this->db->query("DELETE FROM NestedSetTemp");
259
264 $this->xml_parser = xml_parser_create("UTF-8");
265 xml_parser_set_option($this->xml_parser, XML_OPTION_CASE_FOLDING, false);
266 xml_set_object($this->xml_parser, $this);
267 xml_set_element_handler($this->xml_parser, "startElement", "endElement");
268 xml_set_character_data_handler($this->xml_parser, "characterData");
269
270 if (!xml_parse($this->xml_parser, $xmldata)) {
271 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)));
272 }
273 xml_parser_free($this->xml_parser);
274
278 $this->deleteAllDbData();
279
280 $this->db->query("INSERT INTO xmlnestedset SELECT * FROM NestedSetTemp");
281 $this->db->query("DROP TABLE IF EXISTS NestedSetTemp");
282 // }}}
283 }
deleteAllDbData()
deletes current db-data of $this->obj_id and $this->obj_type @access private

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

+ 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 389 of file class.ilNestedSetXML.php.

390 {
391 global $ilDB;
392
393 // {{{
394 $this->db->setLimit(1);
395 $query = "SELECT * FROM xmlnestedset,xmltags WHERE ns_book_fk = " . $ilDB->quote($obj_id) . " AND ns_type =" .
396 $ilDB->quote($obj_type) . " AND ns_tag_fk=tag_pk ORDER BY ns_l";
397 $result = $this->db->query($query);
399
400 $this->LEFT = $row["ns_l"];
401 $this->RIGHT = $row["ns_r"];
402 $this->DEPTH = $row["tag_depth"];
403 $this->obj_id = $obj_id;
404 $this->obj_type = $obj_type;
405 // }}}
406 }

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 552 of file class.ilNestedSetXML.php.

553 {
554 $xml = $this->export($this->obj_id, $this->obj_type);
555
556 /*
557 for testing
558 $xml_test = '
559 <MetaData>
560 <General Structure="Atomic">
561 <Identifier Catalog="ILIAS" Entry="34">Identifier 34 in ILIAS</Identifier>
562 <Identifier Catalog="ILIAS" Entry="45">Identifier 45 in ILIAS</Identifier>
563 <Identifier Catalog="ILIAS" Entry="67">Identifier 67 in ILIAS</Identifier>
564 </General>
565 </MetaData>
566 ';
567
568 $xml = $xml_test;
569 */
570
571 if ($xml == "") {
572 return(false);
573 } else {
574 $this->dom = domxml_open_mem($xml);
575 return(true);
576 }
577 }
export($obj_id, $type)
Export-Function.
domxml_open_mem($str, $mode=0, &$error=null)

References $xml, 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 1141 of file class.ilNestedSetXML.php.

1142 {
1143 $newnode = &$this->dom->create_element($node->tagname());
1144 $newnode->set_content($new_content);
1145 $atts = &$node->attributes();
1146 foreach ($atts as $att) {
1147 $newnode->set_attribute($att->name(), $att->value());
1148 }
1149 $kids = &$node->child_nodes();
1150 foreach ($kids as $kid) {
1151 if ($kid->node_type() != XML_TEXT_NODE) {
1152 $newnode->append_child($kid);
1153 }
1154 }
1155 $node->replace_node($newnode);
1156 }

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 1108 of file class.ilNestedSetXML.php.

1109 {
1110 # echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n";
1111 $nodes = $this->getXpathNodes($this->dom, $xPath);
1112 if (count($nodes) > 0) {
1113 $children = $nodes[$index]->child_nodes();
1114 if (count($children) > 0) {
1115 for ($i = 0; $i < count($children); $i++) {
1116 if ($children[$i]->node_name() == $name &&
1117 is_array($newNode)) {
1118 foreach ($newNode as $key => $val) {
1119 if ($key == "value") {
1120 $this->replace_content($children[$i], $val);
1121 } else {
1122 $children[$i]->set_attribute($key, $val);
1123 }
1124 }
1125 }
1126 }
1127 }
1128 }
1129 }
replace_content(&$node, &$new_content)
Replace node contents.

References $i, $index, $key, $name, $nodes, 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 290 of file class.ilNestedSetXML.php.

291 {
292 $this->param_modifier = &$a_object;
293 $this->param_modifier_method = $a_method;
294 }

◆ setTagName()

ilNestedSetXML::setTagName (   $tagName)

set tag-name

Parameters
stringtagName name of tag to be changed
Returns
string old 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 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);
442 $result = $this->db->query($query);
444
445 $query = "UPDATE xmltags SET tag_name= " . $ilDB->quote($tagName) . " WHERE tag_pk = " . $ilDB->quote($row["ns_tag_fk"]);
446 $this->db->query($query);
447
448 return($row["tagName"]);
449 }

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 494 of file class.ilNestedSetXML.php.

495 {
496 global $ilDB;
497
498 $V = array();
499
500 $query = "SELECT * FROM xmlnestedset,xmltags
501 LEFT JOIN xmlvalue ON xmltags.tag_pk=xmlvalue.tag_fk
502 WHERE ns_tag_fk = tag_pk AND
503 ns_book_fk = " . $ilDB->quote($this->obj_id) . " AND
504 ns_type = " . $ilDB->quote($this->obj_type) . " AND
505 ns_l >= " . $ilDB->quote($this->LEFT) . " AND
506 ns_r <= " . $ilDB->quote($this->RIGHT) . " AND
507 tag_depth = " . $ilDB->quote(($this->DEPTH + 1)) . " AND
508 tag_name = 'TAGVALUE'
509 ORDER BY ns_l";
510 $result = $this->db->query($query);
511
512 if (is_array($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC))) {
513 $query = "UPDATE xmlvalue SET tag_value = " . $ilDB->quote($value) . " WHERE tag_value_pk = " . $ilDB->quote($row["tag_value_pk"]) . " ";
514 $this->db->query($query);
515 } else {
516
520 }
521 }

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 reset($attrs);
152 while (list($key, $val) = each($attrs)) {
153 $this->db->query("INSERT INTO xmlparam ( tag_fk,param_name,param_value ) VALUES (" . $ilDB->quote($pk) . "," . $ilDB->quote($key) . "," . $ilDB->quote($val) . ") ");
154 }
155 }
156
157 return($pk);
158 // }}}
159 }
$r
Definition: example_031.php:79

References $ilDB, $key, $name, $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 1166 of file class.ilNestedSetXML.php.

1167 {
1168 // echo "Index: " . $index . " | Path: " . $xPath . " | Name: " . $name . "<br>\n";
1169 $nodes = $this->getXpathNodes($this->dom, $xPath);
1170 if (count($nodes) > 0) {
1171 $children = $nodes[$index]->child_nodes();
1172 if (count($children) > 0) {
1173 for ($i = 0; $i < count($children); $i++) {
1174 if ($children[$i]->node_name() == $name &&
1175 is_array($newNode)) {
1176 foreach ($newNode as $key => $val) {
1177 if ($key == "value") {
1178 $children[$i]->set_content($val);
1179 } else {
1180 $children[$i]->set_attribute($key, $val);
1181 }
1182 }
1183 }
1184 }
1185 }
1186 }
1187 }

References $i, $index, $key, $name, $nodes, and 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 730 of file class.ilNestedSetXML.php.

731 {
732 $this->clean($meta);
733 $update = false;
734 if ($xPath == "//Bibliography") {
735 $nodes = $this->getXpathNodes($this->dom, $xPath . "/BibItem[" . ($no + 1) . "]");
736 } else {
737 $nodes = $this->getXpathNodes($this->dom, $xPath);
738 }
739 if (count($nodes) > 0) {
740
741 /* BibItem */
742 if ($nodes[0]->node_name() == "BibItem") {
743 $xml = '<BibItem Type="' . ilUtil::stripSlashes($meta["Type"]) . '" Label="' . ilUtil::stripSlashes($meta["Label"]["Value"]) . '">';
744 $xml .= '<Identifier Catalog="' . ilUtil::stripSlashes($meta["Identifier"]["Catalog"]) . '" Entry="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Identifier"]["Entry"])) . '"/>';
745 for ($i = 0; $i < count($meta["Language"]); $i++) {
746 $xml .= '<Language Language="' . ilUtil::stripSlashes($meta["Language"][$i]["Language"]) . '"/>';
747 }
748 for ($i = 0; $i < count($meta["Author"]); $i++) {
749 $xml .= '<Author>';
750 # for ($j = 0; $j < count($meta["Author"][$i]["FirstName"]); $j++)
751 # {
752 $xml .= '<FirstName>' . ilUtil::stripSlashes($meta["Author"][$i]["FirstName"]) . '</FirstName>';
753 # }
754 # for ($j = 0; $j < count($meta["Author"][$i]["MiddleName"]); $j++)
755 # {
756 $xml .= '<MiddleName>' . ilUtil::stripSlashes($meta["Author"][$i]["MiddleName"]) . '</MiddleName>';
757 # }
758 # for ($j = 0; $j < count($meta["Author"][$i]["LastName"]); $j++)
759 # {
760 $xml .= '<LastName>' . ilUtil::stripSlashes($meta["Author"][$i]["LastName"]) . '</LastName>';
761 # }
762 $xml .= '</Author>';
763 }
764 $xml .= '<Booktitle Language="' . ilUtil::stripSlashes($meta["Booktitle"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Booktitle"]["Value"]) . '</Booktitle>';
765 for ($i = 0; $i < count($meta["CrossRef"]); $i++) {
766 $xml .= '<CrossRef>' . ilUtil::stripSlashes($meta["CrossRef"][$i]["Value"]) . '</CrossRef>';
767 }
768 $xml .= '<Edition>' . ilUtil::stripSlashes($meta["Edition"]["Value"]) . '</Edition>';
769 for ($i = 0; $i < count($meta["Editor"]); $i++) {
770 $xml .= '<Editor>' . ilUtil::stripSlashes($meta["Editor"][$i]["Value"]) . '</Editor>';
771 }
772 $xml .= '<HowPublished Type="' . ilUtil::stripSlashes($meta["HowPublished"]["Type"]) . '"/>';
773 for ($i = 0; $i < count($meta["WherePublished"]); $i++) {
774 $xml .= '<WherePublished>' . ilUtil::stripSlashes($meta["WherePublished"][$i]["Value"]) . '</WherePublished>';
775 }
776 for ($i = 0; $i < count($meta["Institution"]); $i++) {
777 $xml .= '<Institution>' . ilUtil::stripSlashes($meta["Institution"][$i]["Value"]) . '</Institution>';
778 }
779 if (is_array($meta["Journal"])) {
780 $xml .= '<Journal Note="' . ilUtil::stripSlashes($meta["Journal"]["Note"]) . '" Number="' . ilUtil::stripSlashes($meta["Journal"]["Number"]) . '" Organization="' . ilUtil::stripSlashes($meta["Journal"]["Organization"]) . '"/>';
781 }
782 for ($i = 0; $i < count($meta["Keyword"]); $i++) {
783 $xml .= '<Keyword Language="' . ilUtil::stripSlashes($meta["Keyword"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Keyword"][$i]["Value"]) . '</Keyword>';
784 }
785 if (is_array($meta["Month"])) {
786 $xml .= '<Month>' . ilUtil::stripSlashes($meta["Month"]["Value"]) . '</Month>';
787 }
788 if (is_array($meta["Pages"])) {
789 $xml .= '<Pages>' . ilUtil::stripSlashes($meta["Pages"]["Value"]) . '</Pages>';
790 }
791 $xml .= '<Publisher>' . ilUtil::stripSlashes($meta["Publisher"]["Value"]) . '</Publisher>';
792 for ($i = 0; $i < count($meta["School"]); $i++) {
793 $xml .= '<School>' . ilUtil::stripSlashes($meta["School"][$i]["Value"]) . '</School>';
794 }
795 if (is_array($meta["Series"])) {
796 $xml .= '<Series>';
797 $xml .= '<SeriesTitle>' . ilUtil::stripSlashes($meta["Series"]["SeriesTitle"]) . '</SeriesTitle>';
798 # for ($i = 0; $i < count($meta["Series"]["SeriesEditor"]); $i++)
799 if (isset($meta["Series"]["SeriesEditor"])) {
800 # $xml .= '<SeriesEditor>' . ilUtil::stripSlashes($meta["Series"]["SeriesEditor"][$i]) . '</SeriesEditor>';
801 $xml .= '<SeriesEditor>' . ilUtil::stripSlashes($meta["Series"]["SeriesEditor"]) . '</SeriesEditor>';
802 }
803 if (isset($meta["Series"]["SeriesVolume"])) {
804 $xml .= '<SeriesVolume>' . ilUtil::stripSlashes($meta["Series"]["SeriesVolume"]) . '</SeriesVolume>';
805 }
806 $xml .= '</Series>';
807 }
808 $xml .= '<Year>' . ilUtil::stripSlashes($meta["Year"]["Value"]) . '</Year>';
809 if ($meta["URL_ISBN_ISSN"]["Type"] == "URL") {
810 $xml .= '<URL>' . ilUtil::stripSlashes($meta["URL_ISBN_ISSN"]["Value"]) . '</URL>';
811 } elseif ($meta["URL_ISBN_ISSN"]["Type"] == "ISBN") {
812 $xml .= '<ISBN>' . ilUtil::stripSlashes($meta["URL_ISBN_ISSN"]["Value"]) . '</ISBN>';
813 } elseif ($meta["URL_ISBN_ISSN"]["Type"] == "ISSN") {
814 $xml .= '<ISSN>' . ilUtil::stripSlashes($meta["URL_ISBN_ISSN"]["Value"]) . '</ISSN>';
815 }
816 $xml .= '</BibItem>';
817 # echo htmlspecialchars($xml);
818
819 $update = true;
820 }
821
822 /* General */
823 elseif ($nodes[0]->node_name() == "General") {
824 $xml = '<General Structure="' . ilUtil::stripSlashes($meta["Structure"]) . '">';
825 for ($i = 0; $i < count($meta["Identifier"]); $i++) {
826 $xml .= '<Identifier Catalog="' . ilUtil::stripSlashes($meta["Identifier"][$i]["Catalog"]) . '" Entry="' .
827 str_replace("\"", "", ilUtil::stripSlashes($meta["Identifier"][$i]["Entry"])) . '"/>';
828 }
829
830 $xml .= '<Title Language="' .
831 ilUtil::stripSlashes($meta["Title"]["Language"]) . '">' .
832 ilUtil::stripSlashes($meta["Title"]["Value"]) . '</Title>';
833 for ($i = 0; $i < count($meta["Language"]); $i++) {
834 $xml .= '<Language Language="' . ilUtil::stripSlashes($meta["Language"][$i]["Language"]) . '"/>';
835 }
836 for ($i = 0; $i < count($meta["Description"]); $i++) {
837 $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Description"][$i]["Value"]) . '</Description>';
838 }
839 for ($i = 0; $i < count($meta["Keyword"]); $i++) {
840 $xml .= '<Keyword Language="' . ilUtil::stripSlashes($meta["Keyword"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Keyword"][$i]["Value"]) . '</Keyword>';
841 }
842 if ($meta["Coverage"] != "") {
843 $xml .= '<Coverage Language="' . ilUtil::stripSlashes($meta["Coverage"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Coverage"]["Value"]) . '</Coverage>';
844 }
845 $xml .= '</General>';
846 //echo "<br><br>".htmlspecialchars($xml);
847
848 $update = true;
849 }
850
851 /* Lifecycle */
852 elseif ($nodes[0]->node_name() == "Lifecycle") {
853 $xml = '<Lifecycle Status="' . $meta["Status"] . '">';
854 $xml .= '<Version Language="' . ilUtil::stripSlashes($meta["Version"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Version"]["Value"]) . '</Version>';
855 for ($i = 0; $i < count($meta["Contribute"]); $i++) {
856 $xml .= '<Contribute Role="' . ilUtil::stripSlashes($meta["Contribute"][$i]["Role"]) . '">';
857 $xml .= '<Date>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Date"]) . '</Date>';
858 for ($j = 0; $j < count($meta["Contribute"][$i]["Entity"]); $j++) {
859 $xml .= '<Entity>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Entity"][$j]) . '</Entity>';
860 }
861 $xml .= '</Contribute>';
862 }
863 $xml .= '</Lifecycle>';
864 # echo htmlspecialchars($xml);
865
866 $update = true;
867 }
868
869 /* Meta-Metadata */
870 elseif ($nodes[0]->node_name() == "Meta-Metadata") {
871 $xml = '<Meta-Metadata MetadataScheme="LOM v 1.0" Language="' . ilUtil::stripSlashes($meta["Language"]) . '">';
872 for ($i = 0; $i < count($meta["Identifier"]); $i++) {
873 $xml .= '<Identifier Catalog="' . ilUtil::stripSlashes($meta["Identifier"][$i]["Catalog"]) . '" Entry="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Identifier"][$i]["Entry"])) . '"/>';
874 }
875 for ($i = 0; $i < count($meta["Contribute"]); $i++) {
876 $xml .= '<Contribute Role="' . ilUtil::stripSlashes($meta["Contribute"][$i]["Role"]) . '">';
877 $xml .= '<Date>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Date"]) . '</Date>';
878 for ($j = 0; $j < count($meta["Contribute"][$i]["Entity"]); $j++) {
879 $xml .= '<Entity>' . ilUtil::stripSlashes($meta["Contribute"][$i]["Entity"][$j]) . '</Entity>';
880 }
881 $xml .= '</Contribute>';
882 }
883 $xml .= '</Meta-Metadata>';
884 # echo htmlspecialchars($xml);
885
886 $update = true;
887 }
888
889 /* Technical */
890 elseif ($nodes[0]->node_name() == "Technical") {
891 $xml = '<Technical>';
892 for ($i = 0; $i < count($meta["Format"]); $i++) {
893 $xml .= '<Format>' . ilUtil::stripSlashes($meta["Format"][$i]) . '</Format>';
894 }
895 if ($meta["Size"] != "") {
896 $xml .= '<Size>' . ilUtil::stripSlashes($meta["Size"]) . '</Size>';
897 }
898 for ($i = 0; $i < count($meta["Location"]); $i++) {
899 $xml .= '<Location Type="' . ilUtil::stripSlashes($meta["Location"][$i]["Type"]) . '">' . ilUtil::stripSlashes($meta["Location"][$i]["Value"]) . '</Location>';
900 }
901 if (is_array($meta["Requirement"])) {
902 for ($i = 0; $i < count($meta["Requirement"]); $i++) {
903 $xml .= '<Requirement>';
904 $xml .= '<Type>';
905 if (is_array($meta["Requirement"][$i]["Type"]["OperatingSystem"])) {
906 $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"])) . '"/>';
907 }
908 if (is_array($meta["Requirement"][$i]["Type"]["Browser"])) {
909 $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"])) . '"/>';
910 }
911 $xml .= '</Type>';
912 $xml .= '</Requirement>';
913 }
914 } elseif (is_array($meta["OrComposite"])) {
915 for ($j = 0; $j < count($meta["OrComposite"]); $j++) {
916 $xml .= '<OrComposite>';
917 for ($i = 0; $i < count($meta["OrComposite"][$j]["Requirement"]); $i++) {
918 $xml .= '<Requirement>';
919 $xml .= '<Type>';
920 if (is_array($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["OperatingSystem"])) {
921 $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"])) . '"/>';
922 }
923 if (is_array($meta["OrComposite"][$j]["Requirement"][$i]["Type"]["Browser"])) {
924 $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"])) . '"/>';
925 }
926 $xml .= '</Type>';
927 $xml .= '</Requirement>';
928 }
929 $xml .= '</OrComposite>';
930 }
931 }
932 if (is_array($meta["InstallationRemarks"])) {
933 $xml .= '<InstallationRemarks Language="' . ilUtil::stripSlashes($meta["InstallationRemarks"]["Language"]) . '">' . ilUtil::stripSlashes($meta["InstallationRemarks"]["Value"]) . '</InstallationRemarks>';
934 }
935 if (is_array($meta["OtherPlattformRequirements"])) {
936 $xml .= '<OtherPlattformRequirements Language="' . ilUtil::stripSlashes($meta["OtherPlattformRequirements"]["Language"]) . '">' . ilUtil::stripSlashes($meta["OtherPlattformRequirements"]["Value"]) . '</OtherPlattformRequirements>';
937 }
938 if ($meta["Duration"] != "") {
939 $xml .= '<Duration>' . ilUtil::stripSlashes($meta["Duration"]) . '</Duration>';
940 }
941 $xml .= '</Technical>';
942 # echo htmlspecialchars($xml);
943
944 $update = true;
945 }
946
947 /* Educational */
948 elseif ($nodes[0]->node_name() == "Educational") {
949 $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"]) . '">';
950 $xml .= '<TypicalLearningTime>' . ilUtil::stripSlashes($meta["TypicalLearningTime"]) . '</TypicalLearningTime>';
951 for ($i = 0; $i < count($meta["TypicalAgeRange"]); $i++) {
952 $xml .= '<TypicalAgeRange Language="' . ilUtil::stripSlashes($meta["TypicalAgeRange"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["TypicalAgeRange"][$i]["Value"]) . '</TypicalAgeRange>';
953 }
954 for ($i = 0; $i < count($meta["Description"]); $i++) {
955 $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Description"][$i]["Value"]) . '</Description>';
956 }
957 for ($i = 0; $i < count($meta["Language"]); $i++) {
958 $xml .= '<Language Language="' . ilUtil::stripSlashes($meta["Language"][$i]["Language"]) . '"/>';
959 }
960 $xml .= '</Educational>';
961
962 $update = true;
963 }
964
965 /* Rights */
966 elseif ($nodes[0]->node_name() == "Rights") {
967 $xml = '<Rights Cost="' . ilUtil::stripSlashes($meta["Cost"]) . '" CopyrightAndOtherRestrictions="' . ilUtil::stripSlashes($meta["CopyrightAndOtherRestrictions"]) . '">';
968 for ($i = 0; $i < count($meta["Description"]); $i++) {
969 $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Description"][$i]["Value"]) . '</Description>';
970 }
971 $xml .= '</Rights>';
972
973 $update = true;
974 }
975
976 /* Relation */
977 elseif ($nodes[0]->node_name() == "Relation") {
978
979# for ($j = 0; $j < count($meta["Relation"]); $j++)
980 # {
981 $meta["Relation"][0] = $meta;
982 $j = 0;
983 $xml = '<Relation Kind="' . ilUtil::stripSlashes($meta["Relation"][$j]["Kind"]) . '">';
984 $xml .= '<Resource>';
985 for ($i = 0; $i < count($meta["Relation"][$j]["Resource"]["Identifier"]); $i++) {
986 $xml .= '<Identifier_ Catalog="' . ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Identifier"][$i]["Catalog"]) . '" Entry="' . str_replace("\"", "", ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Identifier"][$i]["Entry"])) . '"/>';
987 }
988 for ($i = 0; $i < count($meta["Relation"][$j]["Resource"]["Description"]); $i++) {
989 $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Description"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Relation"][$j]["Resource"]["Description"][$i]["Value"]) . '</Description>';
990 }
991 $xml .= '</Resource>';
992 $xml .= '</Relation>';
993 # echo htmlspecialchars($xml);
994 # }
995
996 $update = true;
997 }
998
999 /* Annotation */
1000 elseif ($nodes[0]->node_name() == "Annotation") {
1001
1002# for ($i = 0; $i < count($meta["Annotation"]); $i++)
1003 # {
1004 $meta["Annotation"][0] = $meta;
1005 $i = 0;
1006 $xml = '<Annotation>';
1007 $xml .= '<Entity>' . ilUtil::stripSlashes($meta["Annotation"][$i]["Entity"]) . '</Entity>';
1008 $xml .= '<Date>' . ilUtil::stripSlashes($meta["Annotation"][$i]["Date"]) . '</Date>';
1009 $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Annotation"][$i]["Description"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Annotation"][$i]["Description"]["Value"]) . '</Description>';
1010 $xml .= '</Annotation>';
1011 # echo htmlspecialchars($xml);
1012 # }
1013
1014 $update = true;
1015 }
1016
1017 /* Classification */
1018 elseif ($nodes[0]->node_name() == "Classification") {
1019
1020# for ($j = 0; $j < count($meta["Classification"]); $j++)
1021 # {
1022 $meta["Classification"][0] = $meta;
1023 $j = 0;
1024 $xml = '<Classification Purpose="' . ilUtil::stripSlashes($meta["Classification"][$j]["Purpose"]) . '">';
1025 for ($k = 0; $k < count($meta["Classification"][$j]["TaxonPath"]); $k++) {
1026 $xml .= '<TaxonPath>';
1027 $xml .= '<Source Language="' . ilUtil::stripSlashes($meta["Classification"][$j]["TaxonPath"][$k]["Source"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Classification"][$j]["TaxonPath"][$k]["Source"]["Value"]) . '</Source>';
1028 for ($i = 0; $i < count($meta["Classification"][$j]["TaxonPath"][$k]["Taxon"]); $i++) {
1029 $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>';
1030 }
1031 $xml .= '</TaxonPath>';
1032 }
1033 $xml .= '<Description Language="' . ilUtil::stripSlashes($meta["Classification"][$j]["Description"]["Language"]) . '">' . ilUtil::stripSlashes($meta["Classification"][$j]["Description"]["Value"]) . '</Description>';
1034 for ($i = 0; $i < count($meta["Classification"][$j]["Keyword"]); $i++) {
1035 $xml .= '<Keyword Language="' . ilUtil::stripSlashes($meta["Classification"][$j]["Keyword"][$i]["Language"]) . '">' . ilUtil::stripSlashes($meta["Classification"][$j]["Keyword"][$i]["Value"]) . '</Keyword>';
1036 }
1037 $xml .= '</Classification>';
1038 # echo htmlspecialchars($xml);
1039 # }
1040
1041 $update = true;
1042 }
1043
1044 if ($update) {
1045 $nodes[0]->unlink_node();
1046
1047 if ($xPath != "//Bibliography") {
1048 $xPath = "//MetaData";
1049 }
1050 //echo "<br><br>savedA:".htmlspecialchars($this->dom->dump_mem(0));
1051 $this->addXMLNode($xPath, $xml);
1052 //echo "<br><br>savedB:".htmlspecialchars($this->dom->dump_mem(0));
1053 }
1054 return true;
1055 } else {
1056 return false;
1057 }
1058 }
addXMLNode($xPath, $xml, $index=0)
parse XML code and add it to a given DOM object as a new node
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References $i, $nodes, $xml, 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 1206 of file class.ilNestedSetXML.php.

1207 {
1208 $this->deleteAllDbData();
1209 $xml = $this->dom->dump_mem(0);
1210 $this->import($xml, $this->obj_id, $this->obj_type);
1211 }

References $obj_id, $obj_type, $xml, 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: