ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilECSNodeMappingTreeTableGUI.php
Go to the documentation of this file.
1 <?php
2 
18 declare(strict_types=1);
19 
26 {
27  private \ILIAS\UI\Factory $ui_factory;
28  private \ILIAS\UI\Renderer $ui_renderer;
29 
30  private int $server_id;
31  private int $mid;
35  public function __construct(int $a_server_id, int $a_mid, ?object $a_parent_obj, string $a_parent_cmd)
36  {
37  global $DIC;
38  $this->server_id = $a_server_id;
39  $this->mid = $a_mid;
40 
41  // TODO: set id
42  $this->setId('ecs_node_mapping_table');
43 
44  parent::__construct($a_parent_obj, $a_parent_cmd);
45 
46  $this->setTitle($this->lng->txt('ecs_cms_directory_trees_tbl'));
47  $this->addColumn($this->lng->txt('title'), '', "80%");
48  $this->addColumn($this->lng->txt('actions'), '', "20%");
49  $this->setRowTemplate("tpl.ecs_node_mapping_tree_table_row.html", "Services/WebServices/ECS");
50 
51  $this->setEnableHeader(true);
52 
53  $this->ui_factory = $DIC->ui()->factory();
54  $this->ui_renderer = $DIC->ui()->renderer();
55  }
56 
60  public function getServer(): \ilECSSetting
61  {
62  return ilECSSetting::getInstanceByServerId($this->server_id);
63  }
64 
68  public function getMid(): int
69  {
70  return $this->mid;
71  }
72 
77  protected function fillRow(array $a_set): void
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  $items = [];
90 
91  $this->ctrl->setParameter($this->getParentObject(), 'tid', $a_set['id']);
92  $this->tpl->setVariable('EDIT_TITLE', $this->ctrl->getLinkTarget($this->getParentObject(), 'dInitEditTree'));
93 
94  $item[] = [$this->lng->txt('edit'), $this->ctrl->getLinkTarget($this->getParentObject(), 'dInitEditTree')];
95 
96  if ($a_set['status'] !== ilECSMappingUtils::MAPPED_UNMAPPED &&
97  ilECSNodeMappingSettings::getInstanceByServerMid($this->getServer()->getServerId(), $this->getMid())->isDirectoryMappingEnabled()) {
98  $items[] = [
99  $this->lng->txt('ecs_cms_tree_synchronize'),
100  $this->ctrl->getLinkTarget($this->getParentObject(), 'dSynchronizeTree')
101  ];
102  }
103 
104  $items[] = [$this->lng->txt('delete'), $this->ctrl->getLinkTarget($this->getParentObject(), 'dConfirmDeleteTree')];
105  $render_items = [];
106  foreach ($items as $item) {
107  $render_items[] = $this->ui_factory->button()->shy(...$item);
108  }
109  $this->tpl->setVariable(
110  'ACTIONS',
111  $this->ui_renderer->render($this->ui_factory->dropdown()->standard($render_items)->withLabel($this->lng->txt('actions')))
112  );
113 
114  $this->ctrl->clearParameters($this->getParentObject());
115  }
116 
120  public function parse(): void
121  {
122  $data = array();
123  $counter = 0;
124  foreach (ilECSCmsData::lookupTreeIds($this->getServer()->getServerId(), $this->getMid()) as $tree_id) {
125  $root = new ilECSCmsTree($tree_id);
126  $node = new ilECSCmsData($root->getRootId());
127 
128  $data[$counter]['id'] = $tree_id;
129  $data[$counter]['status'] = ilECSMappingUtils::lookupMappingStatus(
130  $this->getServer()->getServerId(),
131  $this->getMid(),
132  $tree_id
133  );
134  $data[$counter]['title'] = $node->getTitle();
135  $data[$counter]['term'] = ilECSCmsData::lookupTopTerm(
136  $this->getServer()->getServerId(),
137  $this->getMid(),
138  $tree_id
139  );
140  $counter++;
141  }
142  $this->setData($data);
143  }
144 }
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.
global $DIC
Definition: feed.php:28
static lookupTopTerm(int $a_server_id, int $a_mid, int $a_tree_id)
Lookup term (highest term in cms tree)
__construct(VocabulariesInterface $vocabularies)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
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)