ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
All Data Structures Namespaces Files Functions Variables Typedefs Modules Pages
ilECSTreeReader Class Reference

Reads and store cms tree in database. More...

+ Collaboration diagram for ilECSTreeReader:

Public Member Functions

 __construct ($server_id, $mid)
 Constructor. More...
 
 read ()
 Read trees from ecs. More...
 

Protected Member Functions

 storeTree ($tree_id, $a_nodes)
 

Private Attributes

 $server_id
 
 $mid
 

Detailed Description

Reads and store cms tree in database.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e $Id$

Definition at line 10 of file class.ilECSTreeReader.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSTreeReader::__construct (   $server_id,
  $mid 
)

Constructor.

Parameters
<type>$server_id
<type>$mid

Definition at line 20 of file class.ilECSTreeReader.php.

References $mid, and $server_id.

21  {
22  $this->server_id = $server_id;
23  $this->mid = $mid;
24  }

Member Function Documentation

◆ read()

ilECSTreeReader::read ( )

Read trees from ecs.

Exceptions
ilECSConnectorException

Definition at line 33 of file class.ilECSTreeReader.php.

References $GLOBALS, $result, array, ilECSSetting\getInstanceByServerId(), storeTree(), and ilECSCmsData\treeExists().

34  {
35  $GLOBALS['ilLog']->write(__METHOD__ . ': Begin read');
36  try {
37  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSDirectoryTreeConnector.php';
38  $dir_reader = new ilECSDirectoryTreeConnector(
39  ilECSSetting::getInstanceByServerId($this->server_id)
40  );
41  $trees = $dir_reader->getDirectoryTrees();
42  $GLOBALS['ilLog']->write(__METHOD__ . ' ' . print_r($trees, true));
43  if ($trees instanceof ilECSUriList) {
44  foreach ((array) $trees->getLinkIds() as $tree_id) {
45  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
46  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
47 
48  if (!ilECSCmsData::treeExists($this->server_id, $this->mid, $tree_id)) {
49  $result = $dir_reader->getDirectoryTree($tree_id);
50  $this->storeTree($tree_id, $result->getResult());
51  }
52  }
53  }
54  } catch (ilECSConnectorException $e) {
55  throw $e;
56  }
57  }
static getInstanceByServerId($a_server_id)
Get singleton instance per server.
static treeExists($a_server_id, $a_mid, $a_tree_id)
$result
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Presentation of ecs uril (http://...campusconnect/courselinks)
Create styles array
The data for the language used.
storeTree($tree_id, $a_nodes)
+ Here is the call graph for this function:

◆ storeTree()

ilECSTreeReader::storeTree (   $tree_id,
  $a_nodes 
)
protected

Definition at line 59 of file class.ilECSTreeReader.php.

References $data, array, and ilECSCmsData\lookupObjId().

Referenced by read().

60  {
61  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
62  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
63 
64  $tree = new ilECSCmsTree($tree_id);
65 
66 
67  $cms_tree = $a_nodes;
68 
69  $data = new ilECSCmsData();
70  $data->setServerId($this->server_id);
71  $data->setMid($this->mid);
72  $data->setCmsId($cms_tree->rootID);
73  $data->setTreeId($tree_id);
74  $data->setTitle($node->directoryTitle);
75  $data->setTerm($node->term);
76  $data->save();
77 
78  $tree->insertRootNode($tree_id, $data->getObjId());
79  $tree->setRootId($data->getObjId());
80 
81 
82  foreach ((array) $cms_tree->nodes as $node) {
83  // Add data entry
84  $data = new ilECSCmsData();
85  $data->setServerId($this->server_id);
86  $data->setMid($this->mid);
87  $data->setCmsId($node->id);
88  $data->setTreeId($tree_id);
89  $data->setTitle($node->title);
90  $data->setTerm($node->term);
91  $data->save();
92 
93  // add to tree
94  if ($node->parent->id) {
95  $parent_id = ilECSCmsData::lookupObjId(
96  $this->server_id,
97  $this->mid,
98  $tree_id,
99  (int) $node->parent->id
100  );
101  $tree->insertNode($data->getObjId(), $parent_id);
102  }
103  }
104  }
static lookupObjId($a_server_id, $a_mid, $a_tree_id, $cms_id)
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $mid

ilECSTreeReader::$mid
private

Definition at line 13 of file class.ilECSTreeReader.php.

Referenced by __construct().

◆ $server_id

ilECSTreeReader::$server_id
private

Definition at line 12 of file class.ilECSTreeReader.php.

Referenced by __construct().


The documentation for this class was generated from the following file: