ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilECSNodeMappingTreeTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 {
28  private \ILIAS\UI\Factory $ui_factory;
29  private \ILIAS\UI\Renderer $ui_renderer;
30 
31  private int $server_id;
32  private int $mid;
36  public function __construct(int $a_server_id, int $a_mid, ?object $a_parent_obj, string $a_parent_cmd)
37  {
38  global $DIC;
39  $this->server_id = $a_server_id;
40  $this->mid = $a_mid;
41 
42  // TODO: set id
43  $this->setId('ecs_node_mapping_table');
44 
45  parent::__construct($a_parent_obj, $a_parent_cmd);
46 
47  $this->setTitle($this->lng->txt('ecs_cms_directory_trees_tbl'));
48  $this->addColumn($this->lng->txt('title'), '', "80%");
49  $this->addColumn($this->lng->txt('actions'), '', "20%");
50  $this->setRowTemplate("tpl.ecs_node_mapping_tree_table_row.html", "components/ILIAS/WebServices/ECS");
51 
52  $this->setEnableHeader(true);
53 
54  $this->ui_factory = $DIC->ui()->factory();
55  $this->ui_renderer = $DIC->ui()->renderer();
56  }
57 
61  public function getServer(): \ilECSSetting
62  {
63  return ilECSSetting::getInstanceByServerId($this->server_id);
64  }
65 
69  public function getMid(): int
70  {
71  return $this->mid;
72  }
73 
78  protected function fillRow(array $a_set): void
79  {
80  // show title if available
81  if ($a_set['term']) {
82  $this->tpl->setVariable('VAL_TITLE', $a_set['term']);
83  } else {
84  $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
85  }
86  $this->tpl->setVariable('TXT_STATUS', $this->lng->txt('status'));
87  $this->tpl->setVariable('VAL_STATUS', ilECSMappingUtils::mappingStatusToString($a_set['status']));
88 
89  // Actions
90  $items = [];
91 
92  $this->ctrl->setParameter($this->getParentObject(), 'tid', $a_set['id']);
93  $this->tpl->setVariable('EDIT_TITLE', $this->ctrl->getLinkTarget($this->getParentObject(), 'dInitEditTree'));
94 
95  $item[] = [$this->lng->txt('edit'), $this->ctrl->getLinkTarget($this->getParentObject(), 'dInitEditTree')];
96 
97  if ($a_set['status'] !== ilECSMappingUtils::MAPPED_UNMAPPED &&
98  ilECSNodeMappingSettings::getInstanceByServerMid($this->getServer()->getServerId(), $this->getMid())->isDirectoryMappingEnabled()) {
99  $items[] = [
100  $this->lng->txt('ecs_cms_tree_synchronize'),
101  $this->ctrl->getLinkTarget($this->getParentObject(), 'dSynchronizeTree')
102  ];
103  }
104 
105  $items[] = [$this->lng->txt('delete'), $this->ctrl->getLinkTarget($this->getParentObject(), 'dConfirmDeleteTree')];
106  $render_items = [];
107  foreach ($items as $item) {
108  $render_items[] = $this->ui_factory->button()->shy(...$item);
109  }
110  $this->tpl->setVariable(
111  'ACTIONS',
112  $this->ui_renderer->render($this->ui_factory->dropdown()->standard($render_items)->withLabel($this->lng->txt('actions')))
113  );
114 
115  $this->ctrl->clearParameters($this->getParentObject());
116  }
117 
121  public function parse(): void
122  {
123  $data = array();
124  $counter = 0;
125  foreach (ilECSCmsData::lookupTreeIds($this->getServer()->getServerId(), $this->getMid()) as $tree_id) {
126  $root = new ilECSCmsTree($tree_id);
127  $node = new ilECSCmsData($root->getRootId());
128 
129  $data[$counter]['id'] = $tree_id;
130  $data[$counter]['status'] = ilECSMappingUtils::lookupMappingStatus(
131  $this->getServer()->getServerId(),
132  $this->getMid(),
133  $tree_id
134  );
135  $data[$counter]['title'] = $node->getTitle();
136  $data[$counter]['term'] = ilECSCmsData::lookupTopTerm(
137  $this->getServer()->getServerId(),
138  $this->getMid(),
139  $tree_id
140  );
141  $counter++;
142  }
143  $this->setData($data);
144  }
145 }
setData(array $a_data)
static lookupTreeIds(int $a_server_id, int $a_mid)
static getInstanceByServerMid(int $a_server_id, int $a_mid)
Get instance.
__construct(int $a_server_id, int $a_mid, ?object $a_parent_obj, string $a_parent_cmd)
Table gui constructor.
static lookupMappingStatus(int $a_server_id, int $a_mid, int $a_tree_id)
Lookup mapping status.
setId(string $a_val)
static mappingStatusToString(int $a_status)
Get mapping status as string.
static lookupTopTerm(int $a_server_id, int $a_mid, int $a_tree_id)
Lookup term (highest term in cms tree)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
global $DIC
Definition: shib_login.php:26
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
__construct(Container $dic, ilPlugin $plugin)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)