ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilContainerStartObjectsTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once('./Services/Table/classes/class.ilTable2GUI.php');
5 
14 {
15  protected $start_obj; // [ilContainerStartObjects]
16 
17  public function __construct($a_parent_obj, $a_parent_cmd, ilContainerStartObjects $a_start_objects)
18  {
19  global $lng, $ilCtrl;
20 
21  $this->lng = $lng;
22  $this->ctrl = $ilCtrl;
23  $this->lng->loadLanguageModule('crs');
24 
25  $this->start_obj = $a_start_objects;
26 
27  parent::__construct($a_parent_obj, $a_parent_cmd);
28 
29  $this->addColumn('','', 1);
30 
31  if($a_parent_cmd == 'listStructure')
32  {
33  $this->addColumn($this->lng->txt('cntr_ordering'),'pos', '5%');
34  }
35 
36  $this->addColumn($this->lng->txt('type'),'type', 1);
37  $this->addColumn($this->lng->txt('title'),'title');
38  $this->addColumn($this->lng->txt('description'),'description');
39 
40  // add
41  if($a_parent_cmd != 'listStructure')
42  {
43  $this->setTitle($this->lng->txt('crs_select_starter'));
44  $this->addMultiCommand('addStarter', $this->lng->txt('crs_add_starter'));
45  $this->addCommandButton('listStructure', $this->lng->txt('cancel'));
46 
47  $this->setDefaultOrderField('title');
48  $this->setDefaultOrderDirection('asc');
49  }
50  // list
51  else
52  {
53  $this->setTitle($this->lng->txt('crs_start_objects'));
54  $this->addMultiCommand('askDeleteStarter', $this->lng->txt('delete'));
55  $this->addCommandButton('saveSorting', $this->lng->txt('sorting_save'));
56 
57  $this->setDefaultOrderField('pos');
58  $this->setDefaultOrderDirection('asc');
59  }
60 
61  $this->setRowTemplate("tpl.start_objects_row.html", "Services/Container");
62  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
63  $this->setSelectAllCheckbox('starter');
64 
65  $data = array();
66 
67  // add
68  if($a_parent_cmd != 'listStructure')
69  {
70  $data = $this->getPossibleObjects();
71  }
72  // list
73  else
74  {
75  $data = $this->getStartObjects();
76  }
77 
78  $this->setData($data);
79  }
80 
81  protected function getPossibleObjects()
82  {
83  $data = array();
84  foreach($this->start_obj->getPossibleStarters() as $item_ref_id)
85  {
86  $tmp_obj = ilObjectFactory::getInstanceByRefId($item_ref_id);
87 
88  $data[$item_ref_id]['id'] = $item_ref_id;
89  $data[$item_ref_id]['title'] = $tmp_obj->getTitle();
90  $data[$item_ref_id]['type'] = $this->lng->txt('obj_'.$tmp_obj->getType());
91  $data[$item_ref_id]['icon'] = ilObject::_getIcon($tmp_obj->getId(), 'tiny');
92 
93  if(strlen($tmp_obj->getDescription()))
94  {
95  $data[$item_ref_id]['description'] = $tmp_obj->getDescription();
96  }
97  }
98 
99  return $data;
100  }
101 
102  protected function getStartObjects()
103  {
104  $data = array();
105  $counter = 0;
106  foreach($this->start_obj->getStartObjects() as $start_id => $item)
107  {
108  $tmp_obj = ilObjectFactory::getInstanceByRefId($item['item_ref_id']);
109 
110  $data[$item['item_ref_id']]['id'] = $start_id;
111  $data[$item['item_ref_id']]['title'] = $tmp_obj->getTitle();
112  $data[$item['item_ref_id']]['type'] = $this->lng->txt('obj_'.$tmp_obj->getType());
113  $data[$item['item_ref_id']]['icon'] = ilObject::_getIcon($tmp_obj->getId(), 'tiny');
114 
115  $counter += 10;
116  $data[$item['item_ref_id']]['pos'] = $counter;
117 
118  if(strlen($tmp_obj->getDescription()))
119  {
120  $data[$item['item_ref_id']]['description'] = $tmp_obj->getDescription();
121  }
122  }
123 
124  return $data;
125  }
126 
127  public function fillRow($a_set)
128  {
129  if($this->getParentCmd() == 'listStructure')
130  {
131  $this->tpl->setCurrentBlock('pos_bl');
132  $this->tpl->setVariable("POS_ID", $a_set["id"]);
133  $this->tpl->setVariable("POS", $a_set["pos"]);
134  $this->tpl->parseCurrentBlock();
135  }
136 
137  $this->tpl->setVariable("ID", $a_set["id"]);
138  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
139  $this->tpl->setVariable("TXT_DESCRIPTION", $a_set["description"]);
140  $this->tpl->setVariable("ICON_SRC", $a_set["icon"]);
141  $this->tpl->setVariable("ICON_ALT", $a_set["type"]);
142  }
143 }
144 
145 ?>