ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjectCustomUserFieldsTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/Table/classes/class.ilTable2GUI.php';
5 
13 {
17  public function __construct($a_parent_obj, $a_parent_cmd)
18  {
19  global $ilCtrl,$lng;
20 
21  $this->ctrl = $ilCtrl;
22  $this->lng = $lng;
23 
24  parent::__construct($a_parent_obj,$a_parent_cmd);
25 
26  $this->setFormAction($this->ctrl->getFormAction($this->getParentObject(),$this->getParentCmd()));
27 
28  $this->setTitle($this->lng->txt(ilObject::_lookupType($this->getParentObject()->getObjId()).'_custom_user_fields'));
29 
30  $this->addColumn('','',1);
31  $this->addColumn($this->lng->txt('ps_cdf_name'),'name','30%');
32  $this->addColumn($this->lng->txt('ps_cdf_type'),'type','30%');
33  $this->addColumn($this->lng->txt('ps_cdf_required'),'','20%');
34  $this->addColumn('','','20%');
35 
36  $this->setDefaultOrderField('name');
37  $this->setDefaultOrderDirection('asc');
38 
39  $this->addMultiCommand('confirmDeleteFields', $this->lng->txt('delete'));
40  $this->addCommandButton('saveFields', $this->lng->txt('save'));
41 
42  $this->setSelectAllCheckbox('field_ids[]');
43 
44  $this->enable('sort');
45  $this->enable('header');
46  $this->enable('numinfo');
47  $this->enable('select_all');
48 
49  $this->setRowTemplate('tpl.mem_cust_user_data_table_row.html','Services/Membership');
50  }
51 
57  public function fillRow($row)
58  {
59  $this->tpl->setVariable('VAL_ID',$row['field_id']);
60  $this->tpl->setVariable('VAL_NAME',$row['name']);
61  $this->tpl->setVariable('VAL_TYPE',$row['type']);
62  $this->tpl->setVariable('REQUIRED_CHECKED',$row['required'] ? 'checked="checked"' : '');
63 
64  $this->ctrl->setParameter($this->getParentObject(),'field_id',$row['field_id']);
65  $this->tpl->setVariable('EDIT_LINK',$this->ctrl->getLinkTarget($this->getParentObject(),'editField'));
66  $this->tpl->setVariable('TXT_EDIT',$this->lng->txt('edit'));
67  }
68 
74  public function parse($a_defs)
75  {
76  $rows = array();
77  foreach($a_defs as $def)
78  {
79  $rows[$def->getId()]['field_id'] = $def->getId();
80  $rows[$def->getId()]['name'] = $def->getName();
81 
82  switch($def->getType())
83  {
84  case IL_CDF_TYPE_SELECT:
85  $rows[$def->getId()]['type'] = $this->lng->txt('ps_type_select');
86  break;
87 
88  case IL_CDF_TYPE_TEXT:
89  $rows[$def->getId()]['type'] = $this->lng->txt('ps_type_text');
90  break;
91  }
92 
93  $rows[$def->getId()]['required'] = (bool) $def->isRequired();
94  }
95  $this->setData($rows);
96  if(!sizeof($rows))
97  {
98  $this->clearCommandButtons();
99  }
100  }
101 }
102 ?>