ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSoapLMStructureReader.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22 */
23
24
34include_once "./webservice/soap/classes/class.ilSoapStructureReader.php";
35include_once "./webservice/soap/classes/class.ilSoapStructureObjectFactory.php";
36
38{
39
44 public function __construct($object)
45 {
46 parent::__construct($object);
47 }
48
49 public function _parseStructure()
50 {
51 // get all child nodes in LM
52 $ctree =&$this->object->getLMTree();
53
54 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
55
56 $currentParentStructureObject = $this->structureObject;
57 $currentParent = 1;
58
59 $parents = array();
60 $parents [$currentParent]= $currentParentStructureObject;
61
62 $lastStructureObject = null;
63 $lastNode = null;
64 $i =0;
65 foreach ($nodes as $node) {
66
67 // only pages and chapters
68 if ($node["type"] == "st" || $node["type"] == "pg") {
69 // print_r($node);
70 // echo $node["parent"]."<br>";
71 // echo $node["obj_id"]."<br>";
72 // echo $node["title"]."<br>";
73 // print_r($parents);
74 // echo "<br>";
75
76 // parent has changed, to build a tree
77 if ($currentParent != $node["parent"]) {
78 // did we passed this parent before?
79
80 if (array_key_exists($node["parent"], $parents)) {
81 // echo "current_parent:".$currentParent."\n";
82 // echo "parent:".$node["parent"]."\n";
83 // // yes, we did, so use the known parent object
84 // print_r($parents);
85 $currentParentStructureObject = $parents[$node["parent"]];
86
87 // print_r($currentParentStructureObject);
88//
89// die();
90 } else {
91 // no, we did not, so use the last inserted structure as new parent
92 if ($lastNode["type"] != "pg") {
93 $parents[$lastNode["child"]] = $lastStructureObject;
94 $currentParentStructureObject = $lastStructureObject;
95 }
96 }
97 $i++;
98 $currentParent = $lastNode["child"];
99 }
100
101 $lastNode = $node;
102
103 $lastStructureObject = ilSoapStructureObjectFactory::getInstance($node["obj_id"], $node["type"], $node["title"], $node["description"], $this->getObject()->getRefId());
104
105 $currentParentStructureObject->addStructureObject($lastStructureObject);
106 }
107 }
108
109 // print_r($this->structureObject);
110//
111// die();
112 }
113}
An exception for terminatinating execution or to throw for unit testing.
getInstance($objId, $type, $title, $description, $parentRefId)
getObject()
read access to parent object
$i
Definition: disco.tpl.php:19