ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
18  protected $ctrl;
19 
20  protected $start_obj; // [ilContainerStartObjects]
21 
22  public function __construct($a_parent_obj, $a_parent_cmd, ilContainerStartObjects $a_start_objects)
23  {
24  global $DIC;
25 
26  $lng = $DIC->language();
27  $ilCtrl = $DIC->ctrl();
28 
29  $this->lng = $lng;
30  $this->ctrl = $ilCtrl;
31  $this->lng->loadLanguageModule('crs');
32 
33  $this->start_obj = $a_start_objects;
34 
35  parent::__construct($a_parent_obj, $a_parent_cmd);
36 
37  $this->addColumn('', '', 1);
38 
39  if ($a_parent_cmd == 'listStructure') {
40  $this->addColumn($this->lng->txt('cntr_ordering'), 'pos', '5%');
41  }
42 
43  $this->addColumn($this->lng->txt('type'), 'type', 1);
44  $this->addColumn($this->lng->txt('title'), 'title');
45  $this->addColumn($this->lng->txt('description'), 'description');
46 
47  // add
48  if ($a_parent_cmd != 'listStructure') {
49  $this->setTitle($this->lng->txt('crs_select_starter'));
50  $this->addMultiCommand('addStarter', $this->lng->txt('crs_add_starter'));
51  $this->addCommandButton('listStructure', $this->lng->txt('cancel'));
52 
53  $this->setDefaultOrderField('title');
54  $this->setDefaultOrderDirection('asc');
55  }
56  // list
57  else {
58  $this->setTitle($this->lng->txt('crs_start_objects'));
59  $this->addMultiCommand('askDeleteStarter', $this->lng->txt('remove'));
60  $this->addCommandButton('saveSorting', $this->lng->txt('sorting_save'));
61 
62  $this->setDefaultOrderField('pos');
63  $this->setDefaultOrderDirection('asc');
64  }
65 
66  $this->setRowTemplate("tpl.start_objects_row.html", "Services/Container");
67  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
68  $this->setSelectAllCheckbox('starter');
69 
70  $data = array();
71 
72  // add
73  if ($a_parent_cmd != 'listStructure') {
74  $data = $this->getPossibleObjects();
75  }
76  // list
77  else {
78  $data = $this->getStartObjects();
79  }
80 
81  $this->setData($data);
82  }
83 
84  protected function getPossibleObjects()
85  {
86  $data = array();
87  foreach ($this->start_obj->getPossibleStarters() as $item_ref_id) {
88  $tmp_obj = ilObjectFactory::getInstanceByRefId($item_ref_id);
89 
90  $data[$item_ref_id]['id'] = $item_ref_id;
91  $data[$item_ref_id]['title'] = $tmp_obj->getTitle();
92  $data[$item_ref_id]['type'] = $this->lng->txt('obj_' . $tmp_obj->getType());
93  $data[$item_ref_id]['icon'] = ilObject::_getIcon($tmp_obj->getId(), 'tiny');
94 
95  if (strlen($tmp_obj->getDescription())) {
96  $data[$item_ref_id]['description'] = $tmp_obj->getDescription();
97  }
98  }
99 
100  return $data;
101  }
102 
103  protected function getStartObjects()
104  {
105  $data = array();
106  $counter = 0;
107  foreach ($this->start_obj->getStartObjects() as $start_id => $item) {
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  $data[$item['item_ref_id']]['description'] = $tmp_obj->getDescription();
120  }
121  }
122 
123  return $data;
124  }
125 
126  public function fillRow($a_set)
127  {
128  if ($this->getParentCmd() == 'listStructure') {
129  $this->tpl->setCurrentBlock('pos_bl');
130  $this->tpl->setVariable("POS_ID", $a_set["id"]);
131  $this->tpl->setVariable("POS", $a_set["pos"]);
132  $this->tpl->parseCurrentBlock();
133  }
134 
135  $this->tpl->setVariable("ID", $a_set["id"]);
136  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
137  $this->tpl->setVariable("TXT_DESCRIPTION", $a_set["description"]);
138  $this->tpl->setVariable("ICON_SRC", $a_set["icon"]);
139  $this->tpl->setVariable("ICON_ALT", $a_set["type"]);
140  }
141 }
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
global $DIC
Definition: saml.php:7
getParentCmd()
Get parent command.
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.
$counter
Class ilTable2GUI.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
__construct($a_parent_obj, $a_parent_cmd, ilContainerStartObjects $a_start_objects)
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.