ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilAdvancedMDFieldTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
32 include_once('Services/Table/classes/class.ilTable2GUI.php');
33 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
34 
36 {
45  public function __construct($a_parent_obj,$a_parent_cmd = '')
46  {
47  global $lng,$ilCtrl;
48 
49  $this->lng = $lng;
50  $this->ctrl = $ilCtrl;
51 
52  parent::__construct($a_parent_obj,$a_parent_cmd);
53  $this->addColumn('','f',1);
54  $this->addColumn($this->lng->txt('position'),'position',"5%");
55  $this->addColumn($this->lng->txt('title'),'title',"30%");
56  $this->addColumn($this->lng->txt('md_adv_field_fields'),'fields',"35%");
57  $this->addColumn($this->lng->txt('options'),'obj_types',"30%");
58 
59  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
60  $this->setRowTemplate("tpl.edit_fields_row.html","Services/AdvancedMetaData");
61  $this->setDefaultOrderField("position");
62  #$this->setDefaultOrderDirection("desc");
63  }
64 
72  public function fillRow($a_set)
73  {
74  $this->tpl->setVariable('TXT_SEARCHABLE',$this->lng->txt('md_adv_searchable'));
75  $this->tpl->setVariable('ASS_ID',$a_set['id']);
76  if($a_set['searchable'])
77  {
78  $this->tpl->setVariable('ASS_CHECKED','checked="checked"');
79  }
80  $this->tpl->setVariable('VAL_POS',$a_set['position']);
81 
82  $this->tpl->setVariable('VAL_ID',$a_set['id']);
83  $this->tpl->setVariable('VAL_TITLE',$a_set['title']);
84  if(strlen($a_set['description']))
85  {
86  $this->tpl->setVariable('VAL_DESCRIPTION',$a_set['description']);
87  }
88 
89  foreach($a_set['values'] as $value)
90  {
91  $this->tpl->setCurrentBlock('field_value');
92  $this->tpl->setVariable('FIELD_VAL',$value);
93  $this->tpl->parseCurrentBlock();
94  }
95  if(count($a_set['values']))
96  {
97 # $this->tpl->setCurrentBlock('field_select');
98 # $this->tpl->parseCurrentBlock();
99  }
100  switch($a_set['type'])
101  {
103  $this->tpl->setVariable('FIELD_TYPE',$this->lng->txt('udf_type_text'));
104  break;
105 
107  $this->tpl->setVariable('FIELD_TYPE',$this->lng->txt('udf_type_select'));
108  break;
109 
111  $this->tpl->setVariable('FIELD_TYPE',$this->lng->txt('udf_type_date'));
112  break;
113 
115  $this->tpl->setVariable('FIELD_TYPE',$this->lng->txt('udf_type_datetime'));
116  break;
117  }
118  $this->ctrl->setParameter($this->parent_obj,'field_id',$a_set['id']);
119  $this->tpl->setVariable('EDIT_LINK',$this->ctrl->getLinkTarget($this->parent_obj,'editField'));
120  $this->tpl->setVariable('TXT_EDIT_RECORD',$this->lng->txt('edit'));
121  }
122 
123 
131  public function parseDefinitions($a_definitions)
132  {
133  $counter = 1;
134  foreach($a_definitions as $definition)
135  {
136  $tmp_arr['position'] = sprintf("%.1f",$counter++);
137  $tmp_arr['id'] = $definition->getFieldId();
138  $tmp_arr['title'] = $definition->getTitle();
139  $tmp_arr['description'] = $definition->getDescription();
140  $tmp_arr['fields'] = array();
141  $tmp_arr['searchable'] = $definition->isSearchable();
142  $tmp_arr['type'] = $definition->getFieldType();
143  $tmp_arr['values'] = $definition->getFieldValues();
144 
145  $defs_arr[] = $tmp_arr;
146  }
147  $this->setData($defs_arr ? $defs_arr : array());
148  }
149 
150 }
151 
152 
153 ?>