ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
18 {
19 
23  protected $table;
24 
25 
31  public function __construct(ilDclFieldListGUI $a_parent_obj, $a_parent_cmd, $table_id)
32  {
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_in_export'), null, '30px');
47  $this->addColumn($lng->txt('dcl_description'), null, 'auto');
48  $this->addColumn($lng->txt('dcl_field_datatype'), null, 'auto');
49  $this->addColumn($lng->txt('dcl_unique'), null, 'auto');
50  $this->addColumn($lng->txt('actions'), null, '30px');
51  // Only add mutli command for custom fields
52  if (count($this->table->getRecordFields())) {
53  $this->setSelectAllCheckbox('dcl_field_ids[]');
54  $this->addMultiCommand('confirmDeleteFields', $lng->txt('dcl_delete_fields'));
55  }
56 
57  $ilCtrl->setParameterByClass('ildclfieldeditgui', 'table_id', $this->parent_obj->table_id);
58  $ilCtrl->setParameterByClass('ildclfieldlistgui', 'table_id', $this->parent_obj->table_id);
59 
60  $this->setFormAction($ilCtrl->getFormActionByClass('ildclfieldlistgui'));
61  $this->addCommandButton('save', $lng->txt('dcl_save'));
62 
63  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
64  $this->setFormName('field_list');
65 
66  //those two are important as we get our data as objects not as arrays.
67  $this->setExternalSegmentation(true);
68  $this->setExternalSorting(true);
69 
70  $this->setTopCommands(true);
71  $this->setEnableHeader(true);
72  $this->setShowRowsSelector(false);
73  $this->setShowTemplates(false);
74  $this->setEnableHeader(true);
75  $this->setEnableTitle(true);
76  $this->setDefaultOrderDirection('asc');
77 
78  $this->setTitle($lng->txt('dcl_table_list_fields'));
79  $this->setRowTemplate('tpl.field_list_row.html', 'Modules/DataCollection');
80  $this->setStyle('table', $this->getStyle('table') . ' ' . 'dcl_record_list');
81 
82  $this->setData($this->table->getFields());
83  }
84 
85 
89  public function fillRow($a_set)
90  {
91  global $DIC;
92  $lng = $DIC['lng'];
93  $ilCtrl = $DIC['ilCtrl'];
94 
95  if (!$a_set->isStandardField()) {
96  $this->tpl->setVariable('FIELD_ID', $a_set->getId());
97  }
98 
99  $this->tpl->setVariable('NAME', 'order[' . $a_set->getId() . ']');
100  $this->tpl->setVariable('VALUE', $this->order);
101 
102  /* Don't enable setting filter for MOB fields or reference fields that reference a MOB field */
103  $show_exportable = true;
104 
105  if ($a_set->getId() == 'comments') {
106  $show_exportable = false;
107  }
108 
109  if ($show_exportable) {
110  $this->tpl->setVariable('CHECKBOX_EXPORTABLE', 'exportable[' . $a_set->getId() . ']');
111  if ($a_set->getExportable()) {
112  $this->tpl->setVariable('CHECKBOX_EXPORTABLE_CHECKED', 'checked');
113  }
114  } else {
115  $this->tpl->setVariable('NO_FILTER_EXPORTABLE', '');
116  }
117 
118  $this->order = $this->order + 10;
119  $this->tpl->setVariable('ORDER_NAME', 'order[' . $a_set->getId() . ']');
120  $this->tpl->setVariable('ORDER_VALUE', $this->order);
121 
122  $this->tpl->setVariable('TITLE', $a_set->getTitle());
123  $this->tpl->setVariable('DESCRIPTION', $a_set->getDescription());
124  $this->tpl->setVariable('DATATYPE', $a_set->getDatatypeTitle());
125 
126  if (!$a_set->isStandardField()) {
127  switch ($a_set->isUnique()) {
128  case 0:
129  $uniq = ilUtil::getImagePath('icon_not_ok_monochrome.svg', "/Modules/DataCollection");
130  break;
131  case 1:
132  $uniq = ilUtil::getImagePath('icon_ok_monochrome.svg', "/Modules/DataCollection");
133  break;
134  }
135  $this->tpl->setVariable('UNIQUE', $uniq);
136  } else {
137  $this->tpl->setVariable('NO_UNIQUE', '');
138  }
139 
140  $ilCtrl->setParameterByClass('ildclfieldeditgui', 'field_id', $a_set->getId());
141 
142  if (!$a_set->isStandardField()) {
143  $alist = new ilAdvancedSelectionListGUI();
144  $alist->setId($a_set->getId());
145  $alist->setListTitle($lng->txt('actions'));
146 
147  if (ilObjDataCollectionAccess::hasAccessToFields($this->parent_obj->getDataCollectionObject()->ref_id, $this->table->getId())) {
148  $alist->addItem($lng->txt('edit'), 'edit', $ilCtrl->getLinkTargetByClass('ildclfieldeditgui', 'edit'));
149  $alist->addItem($lng->txt('delete'), 'delete', $ilCtrl->getLinkTargetByClass('ildclfieldeditgui', 'confirmDelete'));
150  }
151 
152  $this->tpl->setVariable('ACTIONS', $alist->getHTML());
153  }
154  }
155 }
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.
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)
static hasAccessToFields($ref_id, $table_id)
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: goto.php:24
addMultiCommand($a_cmd, $a_text)
Add Command button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
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.
__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.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setEnableHeader($a_enableheader)
Set Enable Header.
setEnableTitle($a_enabletitle)
Set Enable Title.
getStyle($a_element)