ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  private $server_id = 0;
15  private $mid = 0;
16 
24  public function __construct($a_server_id, $a_mid, $a_parent_obj, $a_parent_cmd)
25  {
26  global $DIC;
27 
28  $lng = $DIC['lng'];
29  $ilCtrl = $DIC['ilCtrl'];
30 
31  $this->lng = $lng;
32  $this->ctrl = $ilCtrl;
33 
34  $this->server_id = $a_server_id;
35  $this->mid = $a_mid;
36 
37  // TODO: set id
38  $this->setId('ecs_node_mapping_table');
39 
40  parent::__construct($a_parent_obj, $a_parent_cmd);
41 
42  $this->setTitle($this->lng->txt('ecs_cms_directory_trees_tbl'));
43  $this->addColumn($this->lng->txt('title'), '', "80%");
44  $this->addColumn($this->lng->txt('actions'), '', "20%");
45  $this->setRowTemplate("tpl.ecs_node_mapping_tree_table_row.html", "Services/WebServices/ECS");
46 
47  $this->setEnableHeader(true);
48  }
49 
54  public function getServer()
55  {
56  return ilECSSetting::getInstanceByServerId($this->server_id);
57  }
58 
63  public function getMid()
64  {
65  return $this->mid;
66  }
67 
72  public function fillRow($a_set)
73  {
74  global $DIC;
75 
76  $ilCtrl = $DIC['ilCtrl'];
77 
78 
79  // show title if available
80  if ($a_set['term']) {
81  $this->tpl->setVariable('VAL_TITLE', $a_set['term']);
82  } else {
83  $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
84  }
85  $this->tpl->setVariable('TXT_STATUS', $this->lng->txt('status'));
86  $this->tpl->setVariable('VAL_STATUS', ilECSMappingUtils::mappingStatusToString($a_set['status']));
87 
88  // Actions
89  include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
91  $list->setSelectionHeaderClass('small');
92  $list->setItemLinkClass('small');
93  $list->setId('actl_' . $a_set['id']);
94  $list->setListTitle($this->lng->txt('actions'));
95 
96  $ilCtrl->setParameter($this->getParentObject(), 'tid', $a_set['id']);
97  $this->tpl->setVariable('EDIT_TITLE', $this->ctrl->getLinkTarget($this->getParentObject(), 'dInitEditTree'));
98 
99  $list->addItem($this->lng->txt('edit'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'dInitEditTree'));
100 
101  include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingSettings.php';
102  if ($a_set['status'] != ilECSMappingUtils::MAPPED_UNMAPPED &&
103  ilECSNodeMappingSettings::getInstanceByServerMid($this->getServer()->getServerId(), $this->getMid())->isDirectoryMappingEnabled()) {
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  $root = new ilECSCmsTree($tree_id);
130  $node = new ilECSCmsData($root->getRootId());
131 
132  $data[$counter]['id'] = $tree_id;
133  $data[$counter]['status'] = ilECSMappingUtils::lookupMappingStatus(
134  $this->getServer()->getServerId(),
135  $this->getMid(),
136  $tree_id
137  );
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 }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
static getInstanceByServerId($a_server_id)
Get singleton instance per server.
global $DIC
Definition: saml.php:7
static getInstanceByServerMid($a_server_id, $a_mid)
Get instance.
static lookupMappingStatus($a_server_id, $a_mid, $a_tree_id)
Lookup mapping status.
getParentObject()
Get parent object.
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
static mappingStatusToString($a_status)
Get mapping status as string.
Class ilTable2GUI.
static lookupTopTerm($a_server_id, $a_mid, $a_tree_id)
Lookup term (highest term in cms tree) <type> $ilDB.
$root
Definition: sabredav.php:45
setRowTemplate($a_template, $a_template_dir="")
Set row template.
User interface class for advanced drop-down selection lists.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
__construct($a_server_id, $a_mid, $a_parent_obj, $a_parent_cmd)
Table gui constructor <type> $lng <type> $ilCtrl.
setEnableHeader($a_enableheader)
Set Enable Header.
static lookupTreeIds($a_server_id, $a_mid)