• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

webservice/soap/classes/class.ilSoapLMStructureReader.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003    +-----------------------------------------------------------------------------+
00004    | ILIAS open source                                                           |
00005    +-----------------------------------------------------------------------------+
00006    | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007    |                                                                             |
00008    | This program is free software; you can redistribute it and/or               |
00009    | modify it under the terms of the GNU General Public License                 |
00010    | as published by the Free Software Foundation; either version 2              |
00011    | of the License, or (at your option) any later version.                      |
00012    |                                                                             |
00013    | This program is distributed in the hope that it will be useful,             |
00014    | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015    | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016    | GNU General Public License for more details.                                |
00017    |                                                                             |
00018    | You should have received a copy of the GNU General Public License           |
00019    | along with this program; if not, write to the Free Software                 |
00020    | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021    +-----------------------------------------------------------------------------+
00022   */
00023 
00024 
00034 include_once "./webservice/soap/classes/class.ilSoapStructureReader.php";
00035 include_once "./webservice/soap/classes/class.ilSoapStructureObjectFactory.php";
00036 
00037 class ilSoapLMStructureReader extends ilSoapStructureReader
00038 {
00039 
00040         function ilSoapLMStructureReader ($object)
00041         {
00042                 parent::ilSoapStructureReader($object);
00043         }
00044 
00045         function _parseStructure () {
00046                 // get all child nodes in LM
00047                 $ctree =& $this->object->getLMTree();
00048 
00049                 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
00050 
00051                 $currentParentStructureObject = $this->structureObject;
00052                 $currentParent = 1;
00053 
00054                 $parents = array ();
00055                 $parents [$currentParent]= $currentParentStructureObject;
00056 
00057                 $lastStructureObject = null;
00058                 $lastNode = null;
00059                 $i =0;
00060                 foreach($nodes as $node)
00061                 {
00062 
00063                         // only pages and chapters
00064                         if($node["type"] == "st" || $node["type"] == "pg")
00065                         {
00066 //                              print_r($node);
00067 //                              echo $node["parent"]."<br>";
00068 //                              echo $node["obj_id"]."<br>";
00069 //                              echo $node["title"]."<br>";
00070 //                              print_r($parents);
00071 //                              echo "<br>";
00072 
00073                                 // parent has changed, to build a tree
00074                                 if ($currentParent != $node["parent"])
00075                                 {
00076                                         // did we passed this parent before?
00077 
00078                                         if (array_key_exists($node["parent"], $parents))
00079                                         {
00080 //                                              echo "current_parent:".$currentParent."\n";
00081 //                                              echo "parent:".$node["parent"]."\n";
00082 //                                              // yes, we did, so use the known parent object
00083 //                                              print_r($parents);
00084                                                 $currentParentStructureObject = $parents[$node["parent"]];
00085 
00086 //                                              print_r($currentParentStructureObject);
00087 //
00088 //                                              die();
00089                                         }
00090                                         else
00091                                         {
00092                                                 // no, we did not, so use the last inserted structure as new parent
00093                                                 if ($lastNode["type"] != "pg")
00094                                                 {
00095                                                         $parents[$lastNode["child"]] = $lastStructureObject;
00096                                                         $currentParentStructureObject = $lastStructureObject;
00097                                                 }
00098 
00099                                         }
00100                                          $i++;
00101                                         $currentParent = $lastNode["child"];
00102                                 }
00103 
00104                                 $lastNode = $node;
00105 
00106                                 $lastStructureObject = ilSoapStructureObjectFactory::getInstance ($node["obj_id"],$node["type"], $node["title"], $node["description"], $this->getObject()->getRefId());
00107 
00108                                 $currentParentStructureObject->addStructureObject( $lastStructureObject);
00109 
00110                         }
00111                 }
00112 
00113 //              print_r($this->structureObject);
00114 //
00115 //              die();
00116         }
00117 
00118 
00119 
00120 
00121 }
00122 
00123 ?>

Generated on Fri Dec 13 2013 13:52:16 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1