ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
34 include_once "./webservice/soap/classes/class.ilSoapStructureReader.php";
35 include_once "./webservice/soap/classes/class.ilSoapStructureObjectFactory.php";
36 
38 {
39 
41  {
43  }
44 
45  function _parseStructure () {
46  // get all child nodes in LM
47  $ctree =& $this->object->getLMTree();
48 
49  $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
50 
51  $currentParentStructureObject = $this->structureObject;
52  $currentParent = 1;
53 
54  $parents = array ();
55  $parents [$currentParent]= $currentParentStructureObject;
56 
57  $lastStructureObject = null;
58  $lastNode = null;
59  $i =0;
60  foreach($nodes as $node)
61  {
62 
63  // only pages and chapters
64  if($node["type"] == "st" || $node["type"] == "pg")
65  {
66 // print_r($node);
67 // echo $node["parent"]."<br>";
68 // echo $node["obj_id"]."<br>";
69 // echo $node["title"]."<br>";
70 // print_r($parents);
71 // echo "<br>";
72 
73  // parent has changed, to build a tree
74  if ($currentParent != $node["parent"])
75  {
76  // did we passed this parent before?
77 
78  if (array_key_exists($node["parent"], $parents))
79  {
80 // echo "current_parent:".$currentParent."\n";
81 // echo "parent:".$node["parent"]."\n";
82 // // yes, we did, so use the known parent object
83 // print_r($parents);
84  $currentParentStructureObject = $parents[$node["parent"]];
85 
86 // print_r($currentParentStructureObject);
87 //
88 // die();
89  }
90  else
91  {
92  // no, we did not, so use the last inserted structure as new parent
93  if ($lastNode["type"] != "pg")
94  {
95  $parents[$lastNode["child"]] = $lastStructureObject;
96  $currentParentStructureObject = $lastStructureObject;
97  }
98 
99  }
100  $i++;
101  $currentParent = $lastNode["child"];
102  }
103 
104  $lastNode = $node;
105 
106  $lastStructureObject = ilSoapStructureObjectFactory::getInstance ($node["obj_id"],$node["type"], $node["title"], $node["description"], $this->getObject()->getRefId());
107 
108  $currentParentStructureObject->addStructureObject( $lastStructureObject);
109 
110  }
111  }
112 
113 // print_r($this->structureObject);
114 //
115 // die();
116  }
117 
118 
119 
120 
121 }
122 
123 ?>