ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCourseStartObjectsTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once('./Services/Table/classes/class.ilTable2GUI.php');
5
14{
15 public function __construct($a_parent_obj, $a_parent_cmd, $a_obj_course)
16 {
17 global $lng, $ilCtrl;
18
19 $this->lng = $lng;
20 $this->ctrl = $ilCtrl;
21 $this->lng->loadLanguageModule('crs');
22
23 parent::__construct($a_parent_obj, $a_parent_cmd);
24
25 $this->addColumn('', '', 1);
26 $this->addColumn($this->lng->txt('type'), 'type', 1);
27 $this->addColumn($this->lng->txt('title'), 'title');
28 $this->addColumn($this->lng->txt('description'), 'description');
29
30 // add
31 if ($a_parent_cmd != 'listStructure') {
32 $this->setTitle($this->lng->txt('crs_select_starter'));
33
34 $this->addMultiCommand('addStarter', $this->lng->txt('crs_add_starter'));
35 }
36 // list
37 else {
38 $this->setTitle($this->lng->txt('crs_start_objects'));
39
40 $this->addMultiCommand('askDeleteStarter', $this->lng->txt('delete'));
41 }
42
43 $this->setRowTemplate("tpl.crs_add_starter.html", "Modules/Course");
44 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
45 $this->setSelectAllCheckbox('starter');
46
47 $this->setDefaultOrderField('title');
48 $this->setDefaultOrderDirection('asc');
49
50
51 $data = array();
52
53 include_once './Modules/Course/classes/class.ilCourseStart.php';
54 $crs_start = new ilCourseStart($a_obj_course->getRefId(), $a_obj_course->getId());
55
56 // add
57 if ($a_parent_cmd != 'listStructure') {
58 $data = $this->getPossibleObjects($a_obj_course, $crs_start);
59 }
60 // list
61 else {
62 $data = $this->getStartObjects($a_obj_course, $crs_start);
63 }
64
65 $this->setData($data);
66 }
67
68 protected function getPossibleObjects($a_obj_course, $crs_start)
69 {
70 $data = array();
71 foreach ($crs_start->getPossibleStarters() as $item_ref_id) {
72 $tmp_obj = ilObjectFactory::getInstanceByRefId($item_ref_id);
73
74 $data[$item_ref_id]['id'] = $item_ref_id;
75 $data[$item_ref_id]['title'] = $tmp_obj->getTitle();
76 $data[$item_ref_id]['type'] = $this->lng->txt('obj_' . $tmp_obj->getType());
77 $data[$item_ref_id]['icon'] = ilObject::_getIcon($tmp_obj->getId(), 'tiny');
78
79 if (strlen($tmp_obj->getDescription())) {
80 $data[$item_ref_id]['description'] = $tmp_obj->getDescription();
81 }
82 }
83
84 return $data;
85 }
86
87 protected function getStartObjects($a_obj_course, $crs_start)
88 {
89 $starters = $crs_start->getStartObjects();
90
91 /*
92 if(!count($starters))
93 {
94 ilUtil::sendInfo($this->lng->txt('crs_no_starter_created'));
95 }
96 */
97
98 $data = array();
99 foreach ($starters as $start_id => $item) {
100 $tmp_obj = ilObjectFactory::getInstanceByRefId($item['item_ref_id']);
101
102 $data[$item['item_ref_id']]['id'] = $start_id;
103 $data[$item['item_ref_id']]['title'] = $tmp_obj->getTitle();
104 $data[$item['item_ref_id']]['type'] = $this->lng->txt('obj_' . $tmp_obj->getType());
105 $data[$item['item_ref_id']]['icon'] = ilObject::_getIcon($tmp_obj->getId(), 'tiny');
106
107 if (strlen($tmp_obj->getDescription())) {
108 $data[$item['item_ref_id']]['description'] = $tmp_obj->getDescription();
109 }
110 }
111
112 return $data;
113 }
114
115 public function fillRow($a_set)
116 {
117 $this->tpl->setVariable("ID", $a_set["id"]);
118 $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
119 $this->tpl->setVariable("TXT_DESCRIPTION", $a_set["description"]);
120 $this->tpl->setVariable("ICON_SRC", $a_set["icon"]);
121 $this->tpl->setVariable("ICON_ALT", $a_set["type"]);
122 }
123}
An exception for terminatinating execution or to throw for unit testing.
fillRow($a_set)
Standard Version of Fill Row.
__construct($a_parent_obj, $a_parent_cmd, $a_obj_course)
ilTable2GUI constructor.
Class ilObj<module_name>
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
Class ilTable2GUI.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
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.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
global $ilCtrl
Definition: ilias.php:18