ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAdvancedMDFieldTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
26 {
28  protected bool $may_edit_pos;
29 
33  protected string $active_language;
34 
35  public function __construct(
36  $a_parent_obj,
37  $a_parent_cmd,
38  ilAdvancedMDPermissionHelper $a_permissions,
39  bool $a_may_edit_pos,
40  string $active_language
41  ) {
42  global $DIC;
43 
44  $lng = $DIC['lng'];
45  $ilCtrl = $DIC['ilCtrl'];
46 
47  $this->lng = $lng;
48  $this->ctrl = $ilCtrl;
49  $this->permissions = $a_permissions;
50  $this->may_edit_pos = $a_may_edit_pos;
51  $this->active_language = $active_language;
52 
53  parent::__construct($a_parent_obj, $a_parent_cmd);
54  $this->addColumn('', 'f', '1');
55  $this->addColumn($this->lng->txt('position'), 'position', "5%");
56  $this->addColumn($this->lng->txt('title'), 'title', "30%");
57  $this->addColumn($this->lng->txt('md_adv_field_fields'), 'type', "35%");
58  $this->addColumn($this->lng->txt('options'), 'searchable', "30%");
59 
60  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
61  $this->setRowTemplate("tpl.edit_fields_row.html", "Services/AdvancedMetaData");
62  $this->setDefaultOrderField("position");
63  /*
64  * BT 35830: disable pagination to prevent that and similar issues due to
65  * this object being a sort of table/form hybrid. There should rarely be more
66  * than 10 rows anyways, and the fix is only temporary until the switch to KS.
67  */
68  $this->setLimit(9999);
69  }
70 
71  public function numericOrdering(string $a_field): bool
72  {
73  if ($a_field === 'position') {
74  return true;
75  }
76  return false;
77  }
78 
79  protected function fillRow(array $a_set): void
80  {
81  $this->tpl->setVariable('TXT_SEARCHABLE', $this->lng->txt('md_adv_searchable'));
82  $this->tpl->setVariable('ASS_ID', $a_set['id']);
83  if ($a_set['searchable']) {
84  $this->tpl->setVariable('ASS_CHECKED', 'checked="checked"');
85  }
87  !(bool) $a_set['supports_search']) {
88  $this->tpl->setVariable('ASS_DISABLED', ' disabled="disabled"');
89  }
90 
91  $this->tpl->setVariable('VAL_POS', $a_set['position']);
92  if (!$this->may_edit_pos) {
93  $this->tpl->setVariable('POS_DISABLED', ' disabled="disabled"');
94  }
95 
96  $this->tpl->setVariable('VAL_ID', $a_set['id']);
97  $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
98  if (strlen($a_set['description'])) {
99  $this->tpl->setVariable('VAL_DESCRIPTION', $a_set['description']);
100  }
101 
102  $this->tpl->setVariable('FIELD_TYPE', $a_set['type']);
103 
104  foreach ((array) $a_set['properties'] as $key => $value) {
105  $this->tpl->setCurrentBlock('field_value');
106  $this->tpl->setVariable('FIELD_KEY', $key);
107  $this->tpl->setVariable('FIELD_VAL', $value);
108  $this->tpl->parseCurrentBlock();
109  }
110 
112  $this->ctrl->setParameter($this->parent_obj, 'field_id', $a_set['id']);
113  $this->tpl->setVariable('EDIT_LINK', $this->ctrl->getLinkTarget($this->parent_obj, 'editField'));
114  $this->tpl->setVariable('TXT_EDIT_RECORD', $this->lng->txt('edit'));
115  }
116  }
117 
118  public function parseDefinitions(array $a_definitions): void
119  {
120  $counter = 0;
121  $defs_arr = [];
122  foreach ($a_definitions as $definition) {
123  $field_translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($definition->getRecordId());
124 
125  $tmp_arr['position'] = ++$counter * 10;
126  $tmp_arr['id'] = $definition->getFieldId();
127  $tmp_arr['title'] = $field_translations->getTitleForLanguage(
128  $definition->getFieldId(),
130  );
131  $tmp_arr['description'] = $field_translations->getDescriptionForLanguage(
132  $definition->getFieldId(),
134  );
135  $tmp_arr['searchable'] = $definition->isSearchable();
136  $tmp_arr['type'] = $this->lng->txt($definition->getTypeTitle());
137  $tmp_arr['properties'] = $definition->getFieldDefinitionForTableGUI($this->active_language);
138  $tmp_arr['supports_search'] = $definition->isSearchSupported();
139 
140  $tmp_arr['perm'] = $this->permissions->hasPermissions(
142  (string) $definition->getFieldId(),
143  array(
145  ,
148  )
149  )
150  );
151 
152  $defs_arr[] = $tmp_arr;
153  }
154  $this->setData($defs_arr);
155  }
156 }
setData(array $a_data)
setFormAction(string $a_form_action, bool $a_multipart=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilLanguage $lng
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Advanced metadata permission helper.
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
ilClaimingPermissionHelper $permissions
string $key
Consumer key/client ID value.
Definition: System.php:193
__construct(Container $dic, ilPlugin $plugin)
setLimit(int $a_limit=0, int $a_default_limit=0)
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)
__construct( $a_parent_obj, $a_parent_cmd, ilAdvancedMDPermissionHelper $a_permissions, bool $a_may_edit_pos, string $active_language)