ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilECSNodeMappingTreeTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/Table/classes/class.ilTable2GUI.php';
5 
13 {
14 
15  private $server_id = 0;
16  private $mid = 0;
17 
25  public function __construct($a_server_id,$a_mid,$a_parent_obj, $a_parent_cmd)
26  {
27  global $lng,$ilCtrl;
28 
29  $this->lng = $lng;
30  $this->ctrl = $ilCtrl;
31 
32  $this->server_id = $a_server_id;
33  $this->mid = $a_mid;
34 
35  // TODO: set id
36  $this->setId('ecs_node_mapping_table');
37 
38  parent::__construct($a_parent_obj,$a_parent_cmd);
39 
40  $this->setTitle($this->lng->txt('ecs_cms_directory_trees_tbl'));
41  $this->addColumn($this->lng->txt('title'),'',"80%");
42  $this->addColumn($this->lng->txt('actions'),'',"20%");
43  $this->setRowTemplate("tpl.ecs_node_mapping_tree_table_row.html","Services/WebServices/ECS");
44 
45  $this->setEnableHeader(true);
46  }
47 
52  public function getServer()
53  {
54  return ilECSSetting::getInstanceByServerId($this->server_id);
55  }
56 
61  public function getMid()
62  {
63  return $this->mid;
64  }
65 
70  public function fillRow($a_set)
71  {
72  global $ilCtrl;
73 
74 
75  // show title if available
76  if($a_set['term'])
77  {
78  $this->tpl->setVariable('VAL_TITLE', $a_set['term']);
79  }
80  else
81  {
82  $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
83  }
84  $this->tpl->setVariable('TXT_STATUS',$this->lng->txt('status'));
85  $this->tpl->setVariable('VAL_STATUS', ilECSMappingUtils::mappingStatusToString($a_set['status']));
86 
87  // Actions
88  include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
89  $list = new ilAdvancedSelectionListGUI();
90  $list->setSelectionHeaderClass('small');
91  $list->setItemLinkClass('small');
92  $list->setId('actl_'.$a_set['id']);
93  $list->setListTitle($this->lng->txt('actions'));
94 
95  $ilCtrl->setParameter($this->getParentObject(),'tid',$a_set['id']);
96  $this->tpl->setVariable('EDIT_TITLE',$this->ctrl->getLinkTarget($this->getParentObject(),'dInitEditTree'));
97 
98  $list->addItem($this->lng->txt('edit'), '', $ilCtrl->getLinkTarget($this->getParentObject(),'dInitEditTree'));
99 
100  include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingSettings.php';
101  if($a_set['status'] != ilECSMappingUtils::MAPPED_UNMAPPED &&
102  ilECSNodeMappingSettings::getInstanceByServerMid($this->getServer()->getServerId(), $this->getMid())->isDirectoryMappingEnabled())
103  {
104  $list->addItem(
105  $this->lng->txt('ecs_cms_tree_synchronize'),
106  '',
107  $ilCtrl->getLinkTarget($this->getParentObject(),'dSynchronizeTree')
108  );
109  }
110 
111  $list->addItem($this->lng->txt('delete'), '', $ilCtrl->getLinkTarget($this->getParentObject(),'dConfirmDeleteTree'));
112  $this->tpl->setVariable('ACTIONS',$list->getHTML());
113 
114  $ilCtrl->clearParameters($this->getParentObject());
115  }
116 
120  public function parse()
121  {
122  include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
123  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
124  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
125 
126  $data = array();
127  $counter = 0;
128  foreach(ilECSCmsData::lookupTreeIds($this->getServer()->getServerId(),$this->getMid()) as $tree_id)
129  {
130  $root = new ilECSCmsTree($tree_id);
131  $node = new ilECSCmsData($root->getRootId());
132 
133  $data[$counter]['id'] = $tree_id;
134  $data[$counter]['status'] = ilECSMappingUtils::lookupMappingStatus(
135  $this->getServer()->getServerId(),
136  $this->getMid(),
137  $tree_id);
138  $data[$counter]['title'] = $node->getTitle();
139  $data[$counter]['term'] = ilECSCmsData::lookupTopTerm(
140  $this->getServer()->getServerId(),
141  $this->getMid(),
142  $tree_id
143  );
144  $counter++;
145  }
146  $this->setData($data);
147  }
148 }
149 ?>