ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups 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  // ALWAYS EDITABLE FOR FIRST RELEASE
42  //$this->addColumn($lng->txt("dcl_editable"), "editable", "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 
49  $ilCtrl->setParameterByClass("ildatacollectionfieldeditgui","table_id", $this->parent_obj->table_id);
50  $ilCtrl->setParameterByClass("ildatacollectionfieldlistgui","table_id", $this->parent_obj->table_id);
51 
52 // $img = " <img src='".ilUtil::getImagePath("cmd_add_s.png")."' /> "; // Wirklich hässlich, doch leider wird der Text, der addHeaderCommand mitgeben wird, nicht mehr angezeigt, sobald man ein Bild mitsendet...
53 //
54 // $this->addHeaderCommand(.$img);
55  $this->setFormAction($ilCtrl->getFormActionByClass("ildatacollectionfieldlistgui"));
56  $this->addCommandButton("save", $lng->txt("dcl_save"));
57 
58  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
59  $this->setFormName('field_list');
60 
61  //those two are important as we get our data as objects not as arrays.
62  $this->setExternalSegmentation(true);
63  $this->setExternalSorting(true);
64 
65  $this->setTopCommands(true);
66  $this->setEnableHeader(true);
67  $this->setShowRowsSelector(false);
68  $this->setShowTemplates(false);
69  $this->setEnableHeader(true);
70  $this->setEnableTitle(true);
71  $this->setDefaultOrderDirection("asc");
72 
73  $this->table = ilDataCollectionCache::getTableCache($table_id);
74 
75  $this->setData($this->table->getFields());
76 
77  require_once('./Modules/DataCollection/classes/class.ilDataCollectionDatatype.php'); //wird dies benötigt?
78 
79  $this->setTitle($lng->txt("dcl_table_list_fields"));
80 
81  $this->setRowTemplate("tpl.field_list_row.html", "Modules/DataCollection");
82  }
89  public function fillRow(ilDataCollectionField $a_set)
90  {
91  global $lng, $ilCtrl;
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  {
99  $this->tpl->setVariable("CHECKBOX_VISIBLE_CHECKED", "checked");
100  }
101 
102  $this->tpl->setVariable("CHECKBOX_FILTERABLE", "filterable[".$a_set->getId()."]");
103  if($a_set->isFilterable())
104  {
105  $this->tpl->setVariable("CHECKBOX_FILTERABLE_CHECKED", "checked");
106  }
107 
108  if(!$a_set->isStandardField())
109  {
110  $this->tpl->setVariable("CHECKBOX_NAME_LOCKED", "locked[".$a_set->getId()."]");
111  if($a_set->getLocked())
112  {
113  $this->tpl->setVariable("CHECKBOX_CHECKED_LOCKED", "checked");
114  }
115  }
116  else
117  {
118  $this->tpl->setVariable("NOT_LOCKED", "-");
119  }
120 
121  $this->order = $this->order + 10;
122  $this->tpl->setVariable("ORDER_NAME","order[".$a_set->getId()."]");
123  $this->tpl->setVariable("ORDER_VALUE", $this->order);
124 
125 
126  $this->tpl->setVariable('TITLE', $a_set->getTitle());
127  $this->tpl->setVariable('DESCRIPTION', $a_set->getDescription());
128  $this->tpl->setVariable('DATATYPE', $a_set->getDatatypeTitle());
129 
130  if(!$a_set->isStandardField())
131  {
132  switch($a_set->getRequired())
133  {
134  case 0:
135  $required = ilUtil::getImagePath('icon_not_ok.png');
136  break;
137  case 1:
138  $required = ilUtil::getImagePath('icon_ok.png');
139  break;
140  }
141  switch($a_set->isUnique())
142  {
143  case 0:
144  $uniq = ilUtil::getImagePath('icon_not_ok.png');
145  break;
146  case 1:
147  $uniq = ilUtil::getImagePath('icon_ok.png');
148  break;
149  }
150  $this->tpl->setVariable('REQUIRED', $required);
151  $this->tpl->setVariable('UNIQUE', $uniq);
152  }
153  else
154  {
155  $this->tpl->setVariable('NO_REQUIRED', "-");
156  $this->tpl->setVariable('NO_UNIQUE', "-");
157  }
158 
159  $ilCtrl->setParameterByClass("ildatacollectionfieldeditgui", "field_id", $a_set->getId());
160 
161  if(!$a_set->isStandardField())
162  {
163  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
164  $alist = new ilAdvancedSelectionListGUI();
165  $alist->setId($a_set->getId());
166  $alist->setListTitle($lng->txt("actions"));
167 
168  if($this->table->hasPermissionToFields($this->parent_obj->parent_obj->ref_id))
169  {
170  $alist->addItem($lng->txt('edit'), 'edit', $ilCtrl->getLinkTargetByClass("ildatacollectionfieldeditgui", 'edit'));
171  $alist->addItem($lng->txt('delete'), 'delete', $ilCtrl->getLinkTargetByClass("ildatacollectionfieldeditgui", 'confirmDelete'));
172  }
173 
174  $this->tpl->setVariable("ACTIONS", $alist->getHTML());
175  }
176  }
177 }
178 
179 ?>