ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilDclFieldListTableGUI.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 require_once ('./Services/Table/classes/class.ilTable2GUI.php');
6 require_once ('./Modules/DataCollection/classes/Helpers/class.ilDclCache.php');
7 
21 
25  protected $table;
26 
32  public function __construct(ilDclFieldListGUI $a_parent_obj, $a_parent_cmd, $table_id) {
33  global $DIC;
34  $lng = $DIC['lng'];
35  $ilCtrl = $DIC['ilCtrl'];
36 
37  parent::__construct($a_parent_obj, $a_parent_cmd);
38 
39  $this->parent_obj = $a_parent_obj;
40  $this->table = ilDclCache::getTableCache($table_id);
41 
42  $this->setId('dcl_field_list');
43  $this->addColumn('', '', '1', true);
44  $this->addColumn($lng->txt('dcl_order'), NULL, '30px');
45  $this->addColumn($lng->txt('dcl_fieldtitle'), NULL, 'auto');
46  $this->addColumn($lng->txt('dcl_locked'), NULL, '30px', false, "", $lng->txt('dcl_locked_tooltip'));
47  $this->addColumn($lng->txt('dcl_in_export'), NULL, '30px');
48  $this->addColumn($lng->txt('dcl_description'), NULL, 'auto');
49  $this->addColumn($lng->txt('dcl_field_datatype'), NULL, 'auto');
50  $this->addColumn($lng->txt('dcl_required'), NULL, 'auto');
51  $this->addColumn($lng->txt('dcl_unique'), NULL, 'auto');
52  $this->addColumn($lng->txt('actions'), NULL, '30px');
53  // Only add mutli command for custom fields
54  if (count($this->table->getRecordFields())) {
55  $this->setSelectAllCheckbox('dcl_field_ids[]');
56  $this->addMultiCommand('confirmDeleteFields', $lng->txt('dcl_delete_fields'));
57  }
58 
59  $ilCtrl->setParameterByClass('ildclfieldeditgui', 'table_id', $this->parent_obj->table_id);
60  $ilCtrl->setParameterByClass('ildclfieldlistgui', 'table_id', $this->parent_obj->table_id);
61 
62  $this->setFormAction($ilCtrl->getFormActionByClass('ildclfieldlistgui'));
63  $this->addCommandButton('save', $lng->txt('dcl_save'));
64 
65  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
66  $this->setFormName('field_list');
67 
68  //those two are important as we get our data as objects not as arrays.
69  $this->setExternalSegmentation(true);
70  $this->setExternalSorting(true);
71 
72  $this->setTopCommands(true);
73  $this->setEnableHeader(true);
74  $this->setShowRowsSelector(false);
75  $this->setShowTemplates(false);
76  $this->setEnableHeader(true);
77  $this->setEnableTitle(true);
78  $this->setDefaultOrderDirection('asc');
79 
80  require_once('./Modules/DataCollection/classes/Fields/Base/class.ilDclDatatype.php'); //ist dies benötigt?
81  $this->setTitle($lng->txt('dcl_table_list_fields'));
82  $this->setRowTemplate('tpl.field_list_row.html', 'Modules/DataCollection');
83  $this->setStyle('table', $this->getStyle('table') . ' ' . 'dcl_record_list');
84 
85  $this->setData($this->table->getFields());
86 
87  }
88 
89 
93  public function fillRow($a_set) {
94  global $DIC;
95  $lng = $DIC['lng'];
96  $ilCtrl = $DIC['ilCtrl'];
97 
98  if (!$a_set->isStandardField()) {
99  $this->tpl->setVariable('FIELD_ID', $a_set->getId());
100  }
101 
102  $this->tpl->setVariable('NAME', 'order[' . $a_set->getId() . ']');
103  $this->tpl->setVariable('VALUE', $this->order);
104 
105  /* Don't enable setting filter for MOB fields or reference fields that reference a MOB field */
106  $show_exportable = true;
107 
108  if ($a_set->getId() == 'comments') {
109  $show_exportable = false;
110  }
111 
112  if ($show_exportable) {
113  $this->tpl->setVariable('CHECKBOX_EXPORTABLE', 'exportable[' . $a_set->getId() . ']');
114  if ($a_set->getExportable()) {
115  $this->tpl->setVariable('CHECKBOX_EXPORTABLE_CHECKED', 'checked');
116  }
117  } else {
118  $this->tpl->setVariable('NO_FILTER_EXPORTABLE', '');
119  }
120 
121  if (!$a_set->isStandardField()) {
122  $this->tpl->setVariable('CHECKBOX_NAME_LOCKED', 'locked[' . $a_set->getId() . ']');
123  if ($a_set->getLocked()) {
124  $this->tpl->setVariable('CHECKBOX_CHECKED_LOCKED', 'checked');
125  }
126  } else {
127  $this->tpl->setVariable('NOT_LOCKED', '');
128  }
129 
130  $this->order = $this->order + 10;
131  $this->tpl->setVariable('ORDER_NAME', 'order[' . $a_set->getId() . ']');
132  $this->tpl->setVariable('ORDER_VALUE', $this->order);
133 
134  $this->tpl->setVariable('TITLE', $a_set->getTitle());
135  $this->tpl->setVariable('DESCRIPTION', $a_set->getDescription());
136  $this->tpl->setVariable('DATATYPE', $a_set->getDatatypeTitle());
137 
138  if (!$a_set->isStandardField()) {
139  switch ($a_set->getRequired()) {
140  case 0:
141  $required = ilUtil::getImagePath('icon_not_ok.svg');
142  break;
143  case 1:
144  $required = ilUtil::getImagePath('icon_ok.svg');
145  break;
146  }
147  switch ($a_set->isUnique()) {
148  case 0:
149  $uniq = ilUtil::getImagePath('icon_not_ok.svg');
150  break;
151  case 1:
152  $uniq = ilUtil::getImagePath('icon_ok.svg');
153  break;
154  }
155  $this->tpl->setVariable('REQUIRED', $required);
156  $this->tpl->setVariable('UNIQUE', $uniq);
157  } else {
158  $this->tpl->setVariable('NO_REQUIRED', '');
159  $this->tpl->setVariable('NO_UNIQUE', '');
160  }
161 
162  $ilCtrl->setParameterByClass('ildclfieldeditgui', 'field_id', $a_set->getId());
163 
164  if (!$a_set->isStandardField()) {
165  include_once('./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php');
166  $alist = new ilAdvancedSelectionListGUI();
167  $alist->setId($a_set->getId());
168  $alist->setListTitle($lng->txt('actions'));
169 
170  if (ilObjDataCollectionAccess::hasAccessToFields($this->parent_obj->getDataCollectionObject()->ref_id, $this->table->getId())) {
171  $alist->addItem($lng->txt('edit'), 'edit', $ilCtrl->getLinkTargetByClass('ildclfieldeditgui', 'edit'));
172  $alist->addItem($lng->txt('delete'), 'delete', $ilCtrl->getLinkTargetByClass('ildclfieldeditgui', 'confirmDelete'));
173  }
174 
175  $this->tpl->setVariable('ACTIONS', $alist->getHTML());
176  }
177  }
178 }
179 
180 ?>
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
setExternalSorting($a_val)
Set external sorting.
setStyle($a_element, $a_style)
setShowTemplates($a_value)
Toggle templates.
setExternalSegmentation($a_val)
Set external segmentation.
static getTableCache($table_id=0)
setId($a_val)
Set id.
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.
static hasAccessToFields($ref_id, $table_id)
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.
User interface class for advanced drop-down selection lists.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
Class ilDclFieldListTableGUI.
__construct(ilDclFieldListGUI $a_parent_obj, $a_parent_cmd, $table_id)
setFormName($a_formname="")
Set Form name.
global $lng
Definition: privfeed.php:17
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setEnableHeader($a_enableheader)
Set Enable Header.
global $DIC
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)
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.