ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilECSCategoryMappingTableGUI.php
Go to the documentation of this file.
1 <?php
2 
18 declare(strict_types=1);
19 
26 {
27  private ilLogger $logger;
28 
29  public function __construct($a_parent_obj, $a_parent_cmd)
30  {
31  global $DIC;
32  parent::__construct($a_parent_obj, $a_parent_cmd);
33  $this->logger = $DIC->logger()->wsrv();
34 
35  $this->addColumn('', 'f', '1px');
36  $this->addColumn($this->lng->txt('obj_cat'), 'category', '40%');
37  $this->addColumn($this->lng->txt('ecs_cat_mapping_type'), 'kind', '50%');
38  $this->addColumn('', 'edit', '10%');
39  $this->setRowTemplate('tpl.rule_row.html', 'Services/WebServices/ECS');
40  $this->setDefaultOrderField('title');
41  $this->setDefaultOrderDirection('asc');
42  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
43  $this->setSelectAllCheckbox('rules');
44  $this->setTitle($this->lng->txt('ecs_tbl_active_rules'));
45  $this->addMultiCommand('deleteCategoryMappings', $this->lng->txt('delete'));
46  }
47 
48  protected function fillRow(array $a_set): void
49  {
50  $this->tpl->setVariable('VAL_ID', $a_set['id']);
51  $this->tpl->setVariable('TXT_ID', $this->lng->txt('ecs_import_id'));
52  $this->tpl->setVariable('VAL_CAT_ID', $a_set['category_id']);
53  $this->tpl->setVariable('TXT_TITLE', $this->lng->txt('title'));
54  $this->tpl->setVariable('VAL_CAT_TITLE', $a_set['category']);
55  $this->tpl->setVariable('VAL_CONDITION', $a_set['kind']);
56  $this->tpl->setVariable('TXT_EDIT', $this->lng->txt('edit'));
57  $this->tpl->setVariable('PATH', $this->buildPath($a_set['category_id']));
58  if ($this->getParentObject()) {
59  $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'rule_id', $a_set['id']);
60  $this->tpl->setVariable(
61  'EDIT_LINK',
62  $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()), 'editCategoryMapping')
63  );
64  $this->ctrl->clearParametersByClass(get_class($this->getParentObject()));
65  } else {
66  $this->logger->error("Cannot fill Category Mapping Table due to parent object being null");
67  }
68  }
69 
74  public function parse(array $a_rules): void
75  {
76  $content = [];
77  foreach ($a_rules as $rule) {
78  $tmp_arr['id'] = $rule->getMappingId();
79  $tmp_arr['category_id'] = $rule->getContainerId();
80  $tmp_arr['category'] = ilObject::_lookupTitle(ilObject::_lookupObjId($rule->getContainerId()));
81  $tmp_arr['kind'] = $rule->conditionToString();
82 
83  $content[] = $tmp_arr;
84  }
85  $this->setData($content);
86  }
87 
88  private function buildPath(int $a_ref_id): string
89  {
90  $loc = new ilLocatorGUI();
91  $loc->setTextOnly(false);
92  $loc->addContextItems($a_ref_id);
93 
94  return $loc->getHTML();
95  }
96 }
setData(array $a_data)
setFormAction(string $a_form_action, bool $a_multipart=false)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
static _lookupObjId(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
static _lookupTitle(int $obj_id)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
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)
addMultiCommand(string $a_cmd, string $a_text)