ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilAdvancedMDFieldTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
32 include_once('Services/Table/classes/class.ilTable2GUI.php');
33 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
34 
36 {
37  protected $permissions; // [ilAdvancedMDPermissionHelper]
38  protected $may_edit_pos; // [bool]
39 
43  protected $active_language;
44 
53  public function __construct($a_parent_obj, $a_parent_cmd = '', ilAdvancedMDPermissionHelper $a_permissions, $a_may_edit_pos, string $active_language)
54  {
55  global $DIC;
56 
57  $lng = $DIC['lng'];
58  $ilCtrl = $DIC['ilCtrl'];
59 
60  $this->lng = $lng;
61  $this->ctrl = $ilCtrl;
62  $this->permissions = $a_permissions;
63  $this->may_edit_pos = (bool) $a_may_edit_pos;
64  $this->active_language = $active_language;
65 
66  parent::__construct($a_parent_obj, $a_parent_cmd);
67  $this->addColumn('', 'f', 1);
68  $this->addColumn($this->lng->txt('position'), 'position', "5%");
69  $this->addColumn($this->lng->txt('title'), 'title', "30%");
70  $this->addColumn($this->lng->txt('md_adv_field_fields'), 'fields', "35%");
71  $this->addColumn($this->lng->txt('options'), 'obj_types', "30%");
72 
73  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
74  $this->setRowTemplate("tpl.edit_fields_row.html", "Services/AdvancedMetaData");
75  $this->setDefaultOrderField("position");
76  #$this->setDefaultOrderDirection("desc");
77  }
78 
79  public function numericOrdering($a_field)
80  {
81  if ($a_field === 'position') {
82  return true;
83  }
84  return false;
85  }
86 
94  public function fillRow($a_set)
95  {
96  $this->tpl->setVariable('TXT_SEARCHABLE', $this->lng->txt('md_adv_searchable'));
97  $this->tpl->setVariable('ASS_ID', $a_set['id']);
98  if ($a_set['searchable']) {
99  $this->tpl->setVariable('ASS_CHECKED', 'checked="checked"');
100  }
102  !(bool) $a_set['supports_search']) {
103  $this->tpl->setVariable('ASS_DISABLED', ' disabled="disabled"');
104  }
105 
106  $this->tpl->setVariable('VAL_POS', $a_set['position']);
107  if (!$this->may_edit_pos) {
108  $this->tpl->setVariable('POS_DISABLED', ' disabled="disabled"');
109  }
110 
111  $this->tpl->setVariable('VAL_ID', $a_set['id']);
112  $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
113  if (strlen($a_set['description'])) {
114  $this->tpl->setVariable('VAL_DESCRIPTION', $a_set['description']);
115  }
116 
117  $this->tpl->setVariable('FIELD_TYPE', $a_set['type']);
118 
119  foreach ((array) $a_set['properties'] as $key => $value) {
120  $this->tpl->setCurrentBlock('field_value');
121  $this->tpl->setVariable('FIELD_KEY', $key);
122  $this->tpl->setVariable('FIELD_VAL', $value);
123  $this->tpl->parseCurrentBlock();
124  }
125 
127  $this->ctrl->setParameter($this->parent_obj, 'field_id', $a_set['id']);
128  $this->tpl->setVariable('EDIT_LINK', $this->ctrl->getLinkTarget($this->parent_obj, 'editField'));
129  $this->tpl->setVariable('TXT_EDIT_RECORD', $this->lng->txt('edit'));
130  }
131  }
132 
133 
141  public function parseDefinitions($a_definitions)
142  {
143  $counter = 0;
144  foreach ($a_definitions as $definition) {
145 
146  $field_translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($definition->getRecordId());
147 
148  $tmp_arr['position'] = ++$counter * 10;
149  $tmp_arr['id'] = $definition->getFieldId();
150  $tmp_arr['title'] = $field_translations->getTitleForLanguage($definition->getFieldId(), $this->active_language);
151  $tmp_arr['description'] = $field_translations->getDescriptionForLanguage($definition->getFieldId(), $this->active_language);
152  $tmp_arr['fields'] = array();
153  $tmp_arr['searchable'] = $definition->isSearchable();
154  $tmp_arr['type'] = $this->lng->txt($definition->getTypeTitle());
155  $tmp_arr['properties'] = $definition->getFieldDefinitionForTableGUI($this->active_language);
156  $tmp_arr['supports_search'] = $definition->isSearchSupported();
157 
158  $tmp_arr['perm'] = $this->permissions->hasPermissions(
160  $definition->getFieldId(),
161  array(
165  )
166  );
167 
168  $defs_arr[] = $tmp_arr;
169  }
170 
171 
172  $this->setData($defs_arr ? $defs_arr : array());
173  }
174 }
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
parseDefinitions($a_definitions)
parese field data
Advanced metadata permission helper.
global $DIC
Definition: goto.php:24
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
__construct($a_parent_obj, $a_parent_cmd='', ilAdvancedMDPermissionHelper $a_permissions, $a_may_edit_pos, string $active_language)
Constructor.
__construct(Container $dic, ilPlugin $plugin)
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.