ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 $DIC;
18
19 $lng = $DIC['lng'];
20 $ilCtrl = $DIC['ilCtrl'];
21
22 $this->lng = $lng;
23 $this->ctrl = $ilCtrl;
24 $this->lng->loadLanguageModule('crs');
25
26 parent::__construct($a_parent_obj, $a_parent_cmd);
27
28 $this->addColumn('', '', 1);
29 $this->addColumn($this->lng->txt('type'), 'type', 1);
30 $this->addColumn($this->lng->txt('title'), 'title');
31 $this->addColumn($this->lng->txt('description'), 'description');
32
33 // add
34 if ($a_parent_cmd != 'listStructure') {
35 $this->setTitle($this->lng->txt('crs_select_starter'));
36
37 $this->addMultiCommand('addStarter', $this->lng->txt('crs_add_starter'));
38 }
39 // list
40 else {
41 $this->setTitle($this->lng->txt('crs_start_objects'));
42
43 $this->addMultiCommand('askDeleteStarter', $this->lng->txt('delete'));
44 }
45
46 $this->setRowTemplate("tpl.crs_add_starter.html", "Modules/Course");
47 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
48 $this->setSelectAllCheckbox('starter');
49
50 $this->setDefaultOrderField('title');
51 $this->setDefaultOrderDirection('asc');
52
53
54 $data = array();
55
56 include_once './Modules/Course/classes/class.ilCourseStart.php';
57 $crs_start = new ilCourseStart($a_obj_course->getRefId(), $a_obj_course->getId());
58
59 // add
60 if ($a_parent_cmd != 'listStructure') {
61 $data = $this->getPossibleObjects($a_obj_course, $crs_start);
62 }
63 // list
64 else {
65 $data = $this->getStartObjects($a_obj_course, $crs_start);
66 }
67
68 $this->setData($data);
69 }
70
71 protected function getPossibleObjects($a_obj_course, $crs_start)
72 {
73 $data = array();
74 foreach ($crs_start->getPossibleStarters() as $item_ref_id) {
75 $tmp_obj = ilObjectFactory::getInstanceByRefId($item_ref_id);
76
77 $data[$item_ref_id]['id'] = $item_ref_id;
78 $data[$item_ref_id]['title'] = $tmp_obj->getTitle();
79 $data[$item_ref_id]['type'] = $this->lng->txt('obj_' . $tmp_obj->getType());
80 $data[$item_ref_id]['icon'] = ilObject::_getIcon($tmp_obj->getId(), 'tiny');
81
82 if (strlen($tmp_obj->getDescription())) {
83 $data[$item_ref_id]['description'] = $tmp_obj->getDescription();
84 }
85 }
86
87 return $data;
88 }
89
90 protected function getStartObjects($a_obj_course, $crs_start)
91 {
92 $starters = $crs_start->getStartObjects();
93
94 /*
95 if(!count($starters))
96 {
97 ilUtil::sendInfo($this->lng->txt('crs_no_starter_created'));
98 }
99 */
100
101 $data = array();
102 foreach ($starters as $start_id => $item) {
103 $tmp_obj = ilObjectFactory::getInstanceByRefId($item['item_ref_id']);
104
105 $data[$item['item_ref_id']]['id'] = $start_id;
106 $data[$item['item_ref_id']]['title'] = $tmp_obj->getTitle();
107 $data[$item['item_ref_id']]['type'] = $this->lng->txt('obj_' . $tmp_obj->getType());
108 $data[$item['item_ref_id']]['icon'] = ilObject::_getIcon($tmp_obj->getId(), 'tiny');
109
110 if (strlen($tmp_obj->getDescription())) {
111 $data[$item['item_ref_id']]['description'] = $tmp_obj->getDescription();
112 }
113 }
114
115 return $data;
116 }
117
118 public function fillRow($a_set)
119 {
120 $this->tpl->setVariable("ID", $a_set["id"]);
121 $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
122 $this->tpl->setVariable("TXT_DESCRIPTION", $a_set["description"]);
123 $this->tpl->setVariable("ICON_SRC", $a_set["icon"]);
124 $this->tpl->setVariable("ICON_ALT", $a_set["type"]);
125 }
126}
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
Class ilTable2GUI.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
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.
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
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46