ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilDataCollectionFieldListTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once('./Services/Table/classes/class.ilTable2GUI.php');
6 require_once 'class.ilDataCollectionCache.php';
7 
21 
27  public function __construct(ilDataCollectionFieldListGUI $a_parent_obj, $a_parent_cmd, $table_id) {
28  global $lng, $ilCtrl;
29 
30  parent::__construct($a_parent_obj, $a_parent_cmd);
31 
32  $this->parent_obj = $a_parent_obj;
33  $this->table = ilDataCollectionCache::getTableCache($table_id);
34 
35  $this->setId('dcl_field_list');
36  $this->addColumn('', '', '1', true);
37  $this->addColumn($lng->txt('dcl_order'), NULL, '30px');
38  $this->addColumn($lng->txt('dcl_title'), NULL, 'auto');
39  $this->addColumn($lng->txt('dcl_visible'), NULL, '30px');
40  $this->addColumn($lng->txt('dcl_filter'), NULL, '30px');
41  $this->addColumn($lng->txt('dcl_locked'), NULL, '30px', false, "", $lng->txt('dcl_locked_tooltip'));
42  $this->addColumn($lng->txt('dcl_in_export'), NULL, '30px');
43  $this->addColumn($lng->txt('dcl_description'), NULL, 'auto');
44  $this->addColumn($lng->txt('dcl_field_datatype'), NULL, 'auto');
45  $this->addColumn($lng->txt('dcl_required'), NULL, 'auto');
46  $this->addColumn($lng->txt('dcl_unique'), NULL, 'auto');
47  $this->addColumn($lng->txt('actions'), NULL, '30px');
48  // Only add mutli command for custom fields
49  if (count($this->table->getRecordFields())) {
50  $this->setSelectAllCheckbox('dcl_field_ids[]');
51  $this->addMultiCommand('confirmDeleteFields', $lng->txt('dcl_delete_fields'));
52  }
53 
54  $ilCtrl->setParameterByClass('ildatacollectionfieldeditgui', 'table_id', $this->parent_obj->table_id);
55  $ilCtrl->setParameterByClass('ildatacollectionfieldlistgui', 'table_id', $this->parent_obj->table_id);
56 
57  $this->setFormAction($ilCtrl->getFormActionByClass('ildatacollectionfieldlistgui'));
58  $this->addCommandButton('save', $lng->txt('dcl_save'));
59 
60  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
61  $this->setFormName('field_list');
62 
63  //those two are important as we get our data as objects not as arrays.
64  $this->setExternalSegmentation(true);
65  $this->setExternalSorting(true);
66 
67  $this->setTopCommands(true);
68  $this->setEnableHeader(true);
69  $this->setShowRowsSelector(false);
70  $this->setShowTemplates(false);
71  $this->setEnableHeader(true);
72  $this->setEnableTitle(true);
73  $this->setDefaultOrderDirection('asc');
74 
75  $this->setData($this->table->getFields());
76  require_once('./Modules/DataCollection/classes/class.ilDataCollectionDatatype.php'); //wird dies benötigt?
77  $this->setTitle($lng->txt('dcl_table_list_fields'));
78  $this->setRowTemplate('tpl.field_list_row.html', 'Modules/DataCollection');
79  $this->setStyle('table', $this->getStyle('table') . ' ' . 'dcl_record_list');
80  }
81 
82 
86  public function fillRow(ilDataCollectionField $a_set) {
87  global $lng, $ilCtrl;
88 
89  if (!$a_set->isStandardField()) {
90  $this->tpl->setVariable('FIELD_ID', $a_set->getId());
91  }
92 
93  $this->tpl->setVariable('NAME', 'order[' . $a_set->getId() . ']');
94  $this->tpl->setVariable('VALUE', $this->order);
95 
96  $this->tpl->setVariable('CHECKBOX_VISIBLE', 'visible[' . $a_set->getId() . ']');
97  if ($a_set->isVisible()) {
98  $this->tpl->setVariable('CHECKBOX_VISIBLE_CHECKED', 'checked');
99  }
100 
101  /* Don't enable setting filter for MOB fields or reference fields that reference a MOB field */
102  $show_filter = true;
103  $show_exportable = true;
106  ) {
107  $show_filter = false;
108  }
110  $ref_field = ilDataCollectionCache::getFieldCache((int)$a_set->getFieldRef());
111  if ($ref_field
112  && ($ref_field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_MOB
113  || $ref_field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_FILE)
114  ) {
115  $show_filter = false;
116  }
117  }
118  if ($a_set->getId() == 'comments') {
119  $show_filter = false;
120  $show_exportable = false;
121  }
122  if ($show_filter) {
123  $this->tpl->setVariable('CHECKBOX_FILTERABLE', 'filterable[' . $a_set->getId() . ']');
124  if ($a_set->isFilterable()) {
125  $this->tpl->setVariable('CHECKBOX_FILTERABLE_CHECKED', 'checked');
126  }
127  } else {
128  $this->tpl->setVariable('NO_FILTER', '');
129  }
130 
131  if ($show_exportable) {
132  $this->tpl->setVariable('CHECKBOX_EXPORTABLE', 'exportable[' . $a_set->getId() . ']');
133  if ($a_set->getExportable()) {
134  $this->tpl->setVariable('CHECKBOX_EXPORTABLE_CHECKED', 'checked');
135  }
136  } else {
137  $this->tpl->setVariable('NO_FILTER_EXPORTABLE', '');
138  }
139 
140  if (!$a_set->isStandardField()) {
141  $this->tpl->setVariable('CHECKBOX_NAME_LOCKED', 'locked[' . $a_set->getId() . ']');
142  if ($a_set->getLocked()) {
143  $this->tpl->setVariable('CHECKBOX_CHECKED_LOCKED', 'checked');
144  }
145  } else {
146  $this->tpl->setVariable('NOT_LOCKED', '');
147  }
148 
149  $this->order = $this->order + 10;
150  $this->tpl->setVariable('ORDER_NAME', 'order[' . $a_set->getId() . ']');
151  $this->tpl->setVariable('ORDER_VALUE', $this->order);
152 
153  $this->tpl->setVariable('TITLE', $a_set->getTitle());
154  $this->tpl->setVariable('DESCRIPTION', $a_set->getDescription());
155  $this->tpl->setVariable('DATATYPE', $a_set->getDatatypeTitle());
156 
157  if (!$a_set->isStandardField()) {
158  switch ($a_set->getRequired()) {
159  case 0:
160  $required = ilUtil::getImagePath('icon_not_ok.svg');
161  break;
162  case 1:
163  $required = ilUtil::getImagePath('icon_ok.svg');
164  break;
165  }
166  switch ($a_set->isUnique()) {
167  case 0:
168  $uniq = ilUtil::getImagePath('icon_not_ok.svg');
169  break;
170  case 1:
171  $uniq = ilUtil::getImagePath('icon_ok.svg');
172  break;
173  }
174  $this->tpl->setVariable('REQUIRED', $required);
175  $this->tpl->setVariable('UNIQUE', $uniq);
176  } else {
177  $this->tpl->setVariable('NO_REQUIRED', '');
178  $this->tpl->setVariable('NO_UNIQUE', '');
179  }
180 
181  $ilCtrl->setParameterByClass('ildatacollectionfieldeditgui', 'field_id', $a_set->getId());
182 
183  if (!$a_set->isStandardField()) {
184  include_once('./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php');
185  $alist = new ilAdvancedSelectionListGUI();
186  $alist->setId($a_set->getId());
187  $alist->setListTitle($lng->txt('actions'));
188 
189  if ($this->table->hasPermissionToFields($this->parent_obj->parent_obj->ref_id)) {
190  $alist->addItem($lng->txt('edit'), 'edit', $ilCtrl->getLinkTargetByClass('ildatacollectionfieldeditgui', 'edit'));
191  $alist->addItem($lng->txt('delete'), 'delete', $ilCtrl->getLinkTargetByClass('ildatacollectionfieldeditgui', 'confirmDelete'));
192  }
193 
194  $this->tpl->setVariable('ACTIONS', $alist->getHTML());
195  }
196  }
197 }
198 
199 ?>
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
setFormName($a_formname)
Set Form name.
setExternalSorting($a_val)
Set external sorting.
setStyle($a_element, $a_style)
setShowTemplates($a_value)
Toggle templates.
Class ilDataCollectionFieldListTableGUI.
setExternalSegmentation($a_val)
Set external segmentation.
Class ilDataCollectionFieldListGUI.
setId($a_val)
Set id.
getRequired()
Get Required Required.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
addMultiCommand($a_cmd, $a_text)
Add Command button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Class ilDataCollectionField.
User interface class for advanced drop-down selection lists.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
global $lng
Definition: privfeed.php:40
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setEnableHeader($a_enableheader)
Set Enable Header.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
setEnableTitle($a_enabletitle)
Set Enable Title.
getStyle($a_element)
__construct(ilDataCollectionFieldListGUI $a_parent_obj, $a_parent_cmd, $table_id)