ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSoapLMStructureReader.php
Go to the documentation of this file.
1<?php
25{
26 public function _parseStructure(): void
27 {
29 $obect = $this->object;
30
31 $ctree = $obect->getLMTree();
32
33 $nodes = $ctree->getSubTree($ctree->getNodeData($ctree->getRootId()));
34
35 $currentParentStructureObject = $this->structureObject;
36 $currentParent = 1;
37
38 $parents = [];
39 $parents[$currentParent] = $currentParentStructureObject;
40
41 $lastStructureObject = null;
42 $lastNode = null;
43 foreach ($nodes as $node) {
44 // only pages and chapters
45 if ($node["type"] === "st" || $node["type"] === "pg") {
46 // parent has changed, to build a tree
47 if ((int) $currentParent !== (int) $node["parent"]) {
48 // did we passed this parent before?
49
50 if (array_key_exists($node["parent"], $parents)) {
51 $currentParentStructureObject = $parents[$node["parent"]];
52 } elseif ($lastNode["type"] !== "pg") {
53 // no, we did not, so use the last inserted structure as new parent
54 $parents[$lastNode["child"]] = $lastStructureObject;
55 $currentParentStructureObject = $lastStructureObject;
56 }
57 $currentParent = $lastNode["child"];
58 }
59
60 $lastNode = $node;
61
62 $lastStructureObject = ilSoapStructureObjectFactory::getInstance(
63 $node["obj_id"],
64 $node["type"],
65 $node["title"],
66 $node["description"],
67 $this->getObject()->getRefId()
68 );
69
70 $currentParentStructureObject->addStructureObject($lastStructureObject);
71 }
72 }
73 }
74}
getInstance(int $objId, string $type, string $title, string $description, int $parentRefId)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilSoapStructureObject $structureObject