ILIAS  release_8 Revision v8.24
class.ilBiblAdminFieldTableGUI.php
Go to the documentation of this file.
1<?php
23{
24 use \ILIAS\Modules\OrgUnit\ARHelper\DIC;
25
26 public const TBL_ID = 'tbl_bibl_fields';
27 protected \ilBiblAdminFactoryFacadeInterface $facade;
28 protected int $position_index = 1;
29 protected array $filter = [];
30
35 public function __construct(?object $a_parent_obj, ilBiblAdminFactoryFacadeInterface $facade)
36 {
37 $this->facade = $facade;
38 $this->parent_obj = $a_parent_obj;
39
40 $this->setId(self::TBL_ID);
41 $this->setPrefix(self::TBL_ID);
42 $this->setFormName(self::TBL_ID);
43 $this->ctrl()->saveParameter($a_parent_obj, $this->getNavParameter());
44
45 parent::__construct($a_parent_obj);
46 $this->parent_obj = $a_parent_obj;
47 $this->setRowTemplate('tpl.bibl_administration_fields_list_row.html', 'Modules/Bibliographic');
48
49 $this->setFormAction($this->ctrl()->getFormAction($this->parent_obj));
50
51 $this->setExternalSorting(true);
52
53 $this->setDefaultOrderField("identifier");
54 $this->setDefaultOrderDirection("asc");
55 $this->setExternalSegmentation(true);
56 $this->setEnableHeader(true);
57
58 $this->initColumns();
59
60 if ($this->parent_obj->checkPermissionBoolAndReturn('write')) {
61 $this->addCommandButton(ilBiblAdminFieldGUI::CMD_SAVE, $this->lng()->txt("save"));
62 }
63
64 $this->addFilterItems();
65 $this->parseData();
66 }
67
68 protected function initColumns(): void
69 {
70 $this->addColumn($this->lng()->txt('order'));
71 $this->addColumn($this->lng()->txt('identifier'));
72 $this->addColumn($this->lng()->txt('translation'));
73 $this->addColumn($this->lng()->txt('standard'));
74 $this->addColumn($this->lng()->txt('actions'), '', '150px');
75 }
76
77 protected function addFilterItems(): void
78 {
79 $field = new ilTextInputGUI($this->lng()->txt('identifier'), 'identifier');
80 $this->addAndReadFilterItem($field);
81 }
82
83 protected function addAndReadFilterItem(ilTableFilterItem $field): void
84 {
85 $this->addFilterItem($field);
86 $field->readFromSession();
87 $this->filter[$field->getPostVar()] = $field instanceof ilCheckboxInputGUI ? $field->getChecked() : $field->getValue();
88 }
89
93 public function fillRow(array $a_set): void
94 {
95 $field = $this->facade->fieldFactory()->findById($a_set['id']);
96
97 $this->tpl->setVariable('FIELD_ID', $field->getId());
98 $this->tpl->setCurrentBlock("POSITION");
99 $this->tpl->setVariable('POSITION_VALUE', $this->position_index);
100 $this->tpl->parseCurrentBlock();
101
102 $this->tpl->setCurrentBlock("IDENTIFIER");
103 $this->tpl->setVariable('IDENTIFIER_VALUE', $field->getIdentifier());
104 $this->tpl->parseCurrentBlock();
105
106 $this->tpl->setCurrentBlock("TRANSLATION");
107 $this->tpl->setVariable('VAL_TRANSLATION', $this->facade->translationFactory()->translate($field));
108 $this->tpl->parseCurrentBlock();
109
110 $this->tpl->setCurrentBlock("STANDARD");
111 if ($field->isStandardField()) {
112 $this->tpl->setVariable('IS_STANDARD_VALUE', $this->lng()->txt('standard'));
113 } else {
114 $this->tpl->setVariable('IS_STANDARD_VALUE', $this->lng()->txt('custom'));
115 }
116
117 $this->tpl->parseCurrentBlock();
118 if ($this->parent_obj->checkPermissionBoolAndReturn('write')) {
119 $this->addActionMenu($field);
120 }
121
122 $this->position_index++;
123 }
124
125 protected function addActionMenu(ilBiblFieldInterface $field): void
126 {
127 $selectionList = new ilAdvancedSelectionListGUI();
128 $selectionList->setListTitle($this->lng->txt('actions'));
129 $selectionList->setId($field->getIdentifier());
130
131 $this->ctrl()
132 ->setParameter($this->parent_obj, ilBiblAdminRisFieldGUI::FIELD_IDENTIFIER, $field->getId());
133 $this->ctrl()
134 ->setParameterByClass(
135 ilBiblTranslationGUI::class,
137 $field->getId()
138 );
139
140 $txt = $this->lng()->txt('translate');
141 $selectionList->addItem($txt, '', $this->ctrl()
142 ->getLinkTargetByClass(
143 ilBiblTranslationGUI::class,
145 ));
146
147 $this->tpl->setVariable('VAL_ACTIONS', $selectionList->getHTML());
148 }
149
150 protected function parseData(): void
151 {
153 $this->determineLimit();
154
155 $q = new ilBiblTableQueryInfo();
156
157 foreach ($this->filter as $filter_key => $filter_value) {
158 switch ($filter_key) {
159 case 'identifier':
161 $filter->setFieldName($filter_key);
162 $filter->setFieldValue('%' . $filter_value . '%');
163 $filter->setOperator("LIKE");
164 $q->addFilter($filter);
165 break;
166 }
167 }
168 $q->setSortingColumn('position');
169 $q->setSortingDirection('ASC');
170
171 $data = $this->facade->fieldFactory()
172 ->filterAllFieldsForTypeAsArray($this->facade->type(), $q);
173
174 $this->setData($data);
175 }
176}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilBiblAdminFactoryFacadeInterface $facade
fillRow(array $a_set)
Fills table rows with content from $a_set.
addAndReadFilterItem(ilTableFilterItem $field)
__construct(?object $a_parent_obj, ilBiblAdminFactoryFacadeInterface $facade)
ilBiblAdminFieldTableGUI constructor.
addActionMenu(ilBiblFieldInterface $field)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
determineOffsetAndOrder(bool $a_omit_offset=false)
setExternalSegmentation(bool $a_val)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setFormName(string $a_name="")
setPrefix(string $a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
setFormAction(string $a_form_action, bool $a_multipart=false)
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)
setDefaultOrderField(string $a_defaultorderfield)
setExternalSorting(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
This class represents a text property in a property form.
$txt
Definition: error.php:13
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc