ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
44  public function __construct($object)
45  {
46  parent::__construct($object);
47  }
48 
49  function _parseStructure () {
50  // get all child nodes in LM
51  $ctree =& $this->object->getLMTree();
52 
53  $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
54 
55  $currentParentStructureObject = $this->structureObject;
56  $currentParent = 1;
57 
58  $parents = array ();
59  $parents [$currentParent]= $currentParentStructureObject;
60 
61  $lastStructureObject = null;
62  $lastNode = null;
63  $i =0;
64  foreach($nodes as $node)
65  {
66 
67  // only pages and chapters
68  if($node["type"] == "st" || $node["type"] == "pg")
69  {
70 // print_r($node);
71 // echo $node["parent"]."<br>";
72 // echo $node["obj_id"]."<br>";
73 // echo $node["title"]."<br>";
74 // print_r($parents);
75 // echo "<br>";
76 
77  // parent has changed, to build a tree
78  if ($currentParent != $node["parent"])
79  {
80  // did we passed this parent before?
81 
82  if (array_key_exists($node["parent"], $parents))
83  {
84 // echo "current_parent:".$currentParent."\n";
85 // echo "parent:".$node["parent"]."\n";
86 // // yes, we did, so use the known parent object
87 // print_r($parents);
88  $currentParentStructureObject = $parents[$node["parent"]];
89 
90 // print_r($currentParentStructureObject);
91 //
92 // die();
93  }
94  else
95  {
96  // no, we did not, so use the last inserted structure as new parent
97  if ($lastNode["type"] != "pg")
98  {
99  $parents[$lastNode["child"]] = $lastStructureObject;
100  $currentParentStructureObject = $lastStructureObject;
101  }
102 
103  }
104  $i++;
105  $currentParent = $lastNode["child"];
106  }
107 
108  $lastNode = $node;
109 
110  $lastStructureObject = ilSoapStructureObjectFactory::getInstance ($node["obj_id"],$node["type"], $node["title"], $node["description"], $this->getObject()->getRefId());
111 
112  $currentParentStructureObject->addStructureObject( $lastStructureObject);
113 
114  }
115  }
116 
117 // print_r($this->structureObject);
118 //
119 // die();
120  }
121 
122 
123 
124 
125 }
126 
127 ?>
getObject()
read access to parent object
Create styles array
The data for the language used.
getInstance($objId, $type, $title, $description, $parentRefId)