ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilBiblAdminFieldTableGUI.php
Go to the documentation of this file.
1 <?php
9 {
10  use \ILIAS\Modules\OrgUnit\ARHelper\DIC;
11  const TBL_ID = 'tbl_bibl_fields';
15  protected $facade;
19  protected $parent_obj;
23  protected $filter = [];
27  protected $position_index = 1;
28 
29 
36  public function __construct($a_parent_obj, ilBiblAdminFactoryFacadeInterface $facade)
37  {
38  $this->facade = $facade;
39  $this->parent_obj = $a_parent_obj;
40 
41  $this->setId(self::TBL_ID);
42  $this->setPrefix(self::TBL_ID);
43  $this->setFormName(self::TBL_ID);
44  $this->ctrl()->saveParameter($a_parent_obj, $this->getNavParameter());
45 
46  parent::__construct($a_parent_obj);
47  $this->parent_obj = $a_parent_obj;
48  $this->setRowTemplate('tpl.bibl_administration_fields_list_row.html', 'Modules/Bibliographic');
49 
50  $this->setFormAction($this->ctrl()->getFormAction($this->parent_obj));
51 
52  $this->setExternalSorting(true);
53 
54  $this->setDefaultOrderField("identifier");
55  $this->setDefaultOrderDirection("asc");
56  $this->setExternalSegmentation(true);
57  $this->setEnableHeader(true);
58 
59  $this->initColumns();
60 
61  $this->addCommandButton(ilBiblAdminFieldGUI::CMD_SAVE, $this->lng()->txt("save"));
62 
63  $this->addFilterItems();
64  $this->parseData();
65  }
66 
67 
68  protected function initColumns()
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 
78  protected function addFilterItems()
79  {
80  $field = new ilTextInputGUI($this->lng()->txt('identifier'), 'identifier');
81  $this->addAndReadFilterItem($field);
82  }
83 
84 
88  protected function addAndReadFilterItem(ilFormPropertyGUI $field)
89  {
90  $this->addFilterItem($field);
91  $field->readFromSession();
92  if ($field instanceof ilCheckboxInputGUI) {
93  $this->filter[$field->getPostVar()] = $field->getChecked();
94  } else {
95  $this->filter[$field->getPostVar()] = $field->getValue();
96  }
97  }
98 
99 
105  public function fillRow($a_set)
106  {
107  $field = $this->facade->fieldFactory()->findById($a_set['id']);
108 
109  $this->tpl->setVariable('FIELD_ID', $field->getId());
110  $this->tpl->setCurrentBlock("POSITION");
111  $this->tpl->setVariable('POSITION_VALUE', $this->position_index);
112  $this->tpl->parseCurrentBlock();
113 
114  $this->tpl->setCurrentBlock("IDENTIFIER");
115  $this->tpl->setVariable('IDENTIFIER_VALUE', $field->getIdentifier());
116  $this->tpl->parseCurrentBlock();
117 
118  $this->tpl->setCurrentBlock("TRANSLATION");
119  $this->tpl->setVariable('VAL_TRANSLATION', $this->facade->translationFactory()->translate($field));
120  $this->tpl->parseCurrentBlock();
121 
122  $this->tpl->setCurrentBlock("STANDARD");
123  if ($field->getIsStandardField()) {
124  $this->tpl->setVariable('IS_STANDARD_VALUE', $this->lng()->txt("standard"));
125  } else {
126  $this->tpl->setVariable('IS_STANDARD_VALUE', $this->lng()->txt("custom"));
127  }
128 
129  $this->tpl->parseCurrentBlock();
130 
131  $this->addActionMenu($field);
132 
133  $this->position_index++;
134  }
135 
136 
140  protected function addActionMenu(ilBiblFieldInterface $field)
141  {
142  $selectionList = new ilAdvancedSelectionListGUI();
143  $selectionList->setListTitle($this->lng->txt("actions"));
144  $selectionList->setId($field->getIdentifier());
145 
146  $this->ctrl()
147  ->setParameter($this->parent_obj, ilBiblAdminRisFieldGUI::FIELD_IDENTIFIER, $field->getId());
148  $this->ctrl()
149  ->setParameterByClass(ilBiblTranslationGUI::class, ilBiblAdminRisFieldGUI::FIELD_IDENTIFIER, $field->getId());
150 
151  $txt = $this->lng()->txt("translate");
152  $selectionList->addItem($txt, "", $this->ctrl()
153  ->getLinkTargetByClass(ilBiblTranslationGUI::class, ilBiblTranslationGUI::CMD_DEFAULT));
154 
155  $this->tpl->setVariable('VAL_ACTIONS', $selectionList->getHTML());
156  }
157 
158 
159  protected function parseData()
160  {
161  $this->determineOffsetAndOrder();
162  $this->determineLimit();
163 
164  $q = new ilBiblTableQueryInfo();
165 
166  foreach ($this->filter as $filter_key => $filter_value) {
167  switch ($filter_key) {
168  case 'identifier':
170  $filter->setFieldName($filter_key);
171  $filter->setFieldValue('%' . $filter_value . '%');
172  $filter->setOperator("LIKE");
173  $q->addFilter($filter);
174  break;
175  }
176  }
177  $q->setSortingColumn('position');
178  $q->setSortingDirection('ASC');
179 
180 
181  $data = $this->facade->fieldFactory()
182  ->filterAllFieldsForTypeAsArray($this->facade->type(), $q);
183 
184  $this->setData($data);
185  }
186 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
setExternalSorting($a_val)
Set external sorting.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
Interface ilBiblEntryInterface.
getPostVar()
Get Post Variable.
setExternalSegmentation($a_val)
Set external segmentation.
This class represents a checkbox property in a property form.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
determineLimit()
Determine the limit.
setId($a_val)
Set id.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
Class ilTable2GUI.
readFromSession()
Read from session.
Class ilBiblTableQueryInfo.
This class represents a text property in a property form.
setPrefix($a_prefix)
getFormAction()
Get Form action parameter.
$txt
Definition: error.php:11
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addAndReadFilterItem(ilFormPropertyGUI $field)
addActionMenu(ilBiblFieldInterface $field)
Class ilBiblAdminFieldTableGUI.
Class ilBiblTableQueryInfo.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
User interface class for advanced drop-down selection lists.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
This class represents a property in a property form.
setFormName($a_formname="")
Set Form name.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
__construct($a_parent_obj, ilBiblAdminFactoryFacadeInterface $facade)
ilBiblAdminFieldTableGUI constructor.
setEnableHeader($a_enableheader)
Set Enable Header.
fillRow($a_set)
Fills table rows with content from $a_set.