ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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  $this->ctrl()->setParameter(
128  $this->parent_obj,
130  $field->getId()
131  );
132  $this->ctrl()->setParameterByClass(
133  ilBiblTranslationGUI::class,
135  $field->getId()
136  );
137 
138  // build translate action entry
139  $action_entries['translate'] = $this->ui()->factory()->button()->shy(
140  $this->lng()->txt('translate'),
141  $this->ctrl()->getLinkTargetByClass(ilBiblTranslationGUI::class, ilBiblTranslationGUI::CMD_DEFAULT)
142  );
143  // build actions dropdown
144  $actions = $this->ui()->factory()->dropdown()->standard($action_entries)->withLabel($this->lng->txt("actions"));
145  $rendered_actions = $this->ui()->renderer()->render($actions);
146 
147  $this->tpl->setVariable('VAL_ACTIONS', $rendered_actions);
148  }
149 
150  protected function parseData(): void
151  {
152  $this->determineOffsetAndOrder();
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':
160  $filter = new ilBiblTableQueryFilter();
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 }
setData(array $a_data)
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...
setFormAction(string $a_form_action, bool $a_multipart=false)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
ilBiblAdminFactoryFacadeInterface $facade
setFormName(string $a_name="")
__construct(?object $a_parent_obj, ilBiblAdminFactoryFacadeInterface $facade)
ilBiblAdminFieldTableGUI constructor.
setId(string $a_val)
setExternalSorting(bool $a_val)
__construct(VocabulariesInterface $vocabularies)
setDefaultOrderField(string $a_defaultorderfield)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
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...
$q
Definition: shib_logout.php:21
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)
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
addAndReadFilterItem(ilTableFilterItem $field)
fillRow(array $a_set)
Fills table rows with content from $a_set.
determineOffsetAndOrder(bool $a_omit_offset=false)
setEnableHeader(bool $a_enableheader)
setExternalSegmentation(bool $a_val)
setPrefix(string $a_prefix)