ILIAS  release_4-4 Revision
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 
8 
22 {
23  /*
24  * __construct
25  */
26  public function __construct(ilDataCollectionFieldListGUI $a_parent_obj, $a_parent_cmd, $table_id)
27  {
28  global $lng, $tpl, $ilCtrl;
29 
30  parent::__construct($a_parent_obj, $a_parent_cmd);
31 
32  $this->parent_obj = $a_parent_obj;
33 
34  $this->setId("dcl_field_list");
35 
36  $this->addColumn($lng->txt("dcl_order"), null, "30px");
37  $this->addColumn($lng->txt("dcl_title"), null, "auto");
38  $this->addColumn($lng->txt("dcl_visible"), null, "30px");
39  $this->addColumn($lng->txt("dcl_filter"), null, "30px");
40  $this->addColumn($lng->txt("dcl_locked"), null, "30px");
41  $this->addColumn($lng->txt("dcl_in_export"), null, "30px");
42  $this->addColumn($lng->txt("dcl_description"), null, "auto");
43  $this->addColumn($lng->txt("dcl_field_datatype"), null, "auto");
44  $this->addColumn($lng->txt("dcl_required"), null, "auto");
45  $this->addColumn($lng->txt("dcl_unique"), null, "auto");
46  $this->addColumn($lng->txt("actions"), null, "30px");
47 
48  $ilCtrl->setParameterByClass("ildatacollectionfieldeditgui","table_id", $this->parent_obj->table_id);
49  $ilCtrl->setParameterByClass("ildatacollectionfieldlistgui","table_id", $this->parent_obj->table_id);
50 
51  $this->setFormAction($ilCtrl->getFormActionByClass("ildatacollectionfieldlistgui"));
52  $this->addCommandButton("save", $lng->txt("dcl_save"));
53 
54  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
55  $this->setFormName('field_list');
56 
57  //those two are important as we get our data as objects not as arrays.
58  $this->setExternalSegmentation(true);
59  $this->setExternalSorting(true);
60 
61  $this->setTopCommands(true);
62  $this->setEnableHeader(true);
63  $this->setShowRowsSelector(false);
64  $this->setShowTemplates(false);
65  $this->setEnableHeader(true);
66  $this->setEnableTitle(true);
67  $this->setDefaultOrderDirection("asc");
68 
69  $this->table = ilDataCollectionCache::getTableCache($table_id);
70 
71  $this->setData($this->table->getFields());
72  require_once('./Modules/DataCollection/classes/class.ilDataCollectionDatatype.php'); //wird dies benötigt?
73  $this->setTitle($lng->txt("dcl_table_list_fields"));
74  $this->setRowTemplate("tpl.field_list_row.html", "Modules/DataCollection");
75  $this->setStyle('table', $this->getStyle('table') . ' ' . 'dcl_record_list');
76  }
83  public function fillRow(ilDataCollectionField $a_set)
84  {
85  global $lng, $ilCtrl;
86 
87  $this->tpl->setVariable('NAME', "order[".$a_set->getId()."]");
88  $this->tpl->setVariable('VALUE', $this->order);
89 
90  $this->tpl->setVariable("CHECKBOX_VISIBLE", "visible[".$a_set->getId()."]");
91  if($a_set->isVisible())
92  {
93  $this->tpl->setVariable("CHECKBOX_VISIBLE_CHECKED", "checked");
94  }
95 
96  /* Don't enable setting filter for MOB fields or reference fields that reference a MOB field */
97  $showFilter = true;
99  $showFilter = false;
100  }
102  $refField = ilDataCollectionCache::getFieldCache((int) $a_set->getFieldRef());
103  if ($refField && ($refField->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_MOB || $refField->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_FILE)) {
104  $showFilter = false;
105  }
106  }
107  if($showFilter)
108  {
109  $this->tpl->setVariable("CHECKBOX_FILTERABLE", "filterable[".$a_set->getId()."]");
110  if($a_set->isFilterable())
111  {
112  $this->tpl->setVariable("CHECKBOX_FILTERABLE_CHECKED", "checked");
113  }
114  }
115  else
116  {
117  $this->tpl->setVariable("NO_FILTER", "");
118  }
119 
120  $this->tpl->setVariable("CHECKBOX_EXPORTABLE", "exportable[".$a_set->getId()."]");
121  if($a_set->getExportable())
122  {
123  $this->tpl->setVariable("CHECKBOX_EXPORTABLE_CHECKED", "checked");
124  }
125 
126  if(!$a_set->isStandardField())
127  {
128  $this->tpl->setVariable("CHECKBOX_NAME_LOCKED", "locked[".$a_set->getId()."]");
129  if($a_set->getLocked())
130  {
131  $this->tpl->setVariable("CHECKBOX_CHECKED_LOCKED", "checked");
132  }
133  }
134  else
135  {
136  $this->tpl->setVariable("NOT_LOCKED", "");
137  }
138 
139  $this->order = $this->order + 10;
140  $this->tpl->setVariable("ORDER_NAME","order[".$a_set->getId()."]");
141  $this->tpl->setVariable("ORDER_VALUE", $this->order);
142 
143 
144  $this->tpl->setVariable('TITLE', $a_set->getTitle());
145  $this->tpl->setVariable('DESCRIPTION', $a_set->getDescription());
146  $this->tpl->setVariable('DATATYPE', $a_set->getDatatypeTitle());
147 
148  if(!$a_set->isStandardField())
149  {
150  switch($a_set->getRequired())
151  {
152  case 0:
153  $required = ilUtil::getImagePath('icon_not_ok.png');
154  break;
155  case 1:
156  $required = ilUtil::getImagePath('icon_ok.png');
157  break;
158  }
159  switch($a_set->isUnique())
160  {
161  case 0:
162  $uniq = ilUtil::getImagePath('icon_not_ok.png');
163  break;
164  case 1:
165  $uniq = ilUtil::getImagePath('icon_ok.png');
166  break;
167  }
168  $this->tpl->setVariable('REQUIRED', $required);
169  $this->tpl->setVariable('UNIQUE', $uniq);
170  }
171  else
172  {
173  $this->tpl->setVariable('NO_REQUIRED', "");
174  $this->tpl->setVariable('NO_UNIQUE', "");
175  }
176 
177  $ilCtrl->setParameterByClass("ildatacollectionfieldeditgui", "field_id", $a_set->getId());
178 
179  if(!$a_set->isStandardField())
180  {
181  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
182  $alist = new ilAdvancedSelectionListGUI();
183  $alist->setId($a_set->getId());
184  $alist->setListTitle($lng->txt("actions"));
185 
186  if($this->table->hasPermissionToFields($this->parent_obj->parent_obj->ref_id))
187  {
188  $alist->addItem($lng->txt('edit'), 'edit', $ilCtrl->getLinkTargetByClass("ildatacollectionfieldeditgui", 'edit'));
189  $alist->addItem($lng->txt('delete'), 'delete', $ilCtrl->getLinkTargetByClass("ildatacollectionfieldeditgui", 'confirmDelete'));
190  }
191 
192  $this->tpl->setVariable("ACTIONS", $alist->getHTML());
193  }
194  }
195 }
196 
197 ?>
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)
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="")
Add Command button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Class ilDataCollectionField.
User interface class for advanced drop-down selection lists.
global $lng
Definition: privfeed.php:40
setFormAction($a_form_action)
Set Form action parameter.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setEnableHeader($a_enableheader)
Set Enable Header.
fillRow(ilDataCollectionField $a_set)
fill row
setEnableTitle($a_enabletitle)
Set Enable Title.
getStyle($a_element)
__construct(ilDataCollectionFieldListGUI $a_parent_obj, $a_parent_cmd, $table_id)