ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 include_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  {
33  $this->setTitle($this->lng->txt('crs_select_starter'));
34 
35  $this->addMultiCommand('addStarter', $this->lng->txt('crs_add_starter'));
36  }
37  // list
38  else
39  {
40  $this->setTitle($this->lng->txt('crs_start_objects'));
41 
42  $this->addMultiCommand('askDeleteStarter', $this->lng->txt('delete'));
43  }
44 
45  $this->setRowTemplate("tpl.crs_add_starter.html","Modules/Course");
46  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
47  $this->setSelectAllCheckbox('starter');
48 
49  $this->setDefaultOrderField('title');
50  $this->setDefaultOrderDirection('asc');
51 
52 
53  $data = array();
54 
55  include_once './Modules/Course/classes/class.ilCourseStart.php';
56  $crs_start = new ilCourseStart($a_obj_course->getRefId(), $a_obj_course->getId());
57 
58  // add
59  if($a_parent_cmd != 'listStructure')
60  {
61  $data = $this->getPossibleObjects($a_obj_course, $crs_start);
62  }
63  // list
64  else
65  {
66  $data = $this->getStartObjects($a_obj_course, $crs_start);
67  }
68 
69  $this->setData($data);
70  }
71 
72  protected function getPossibleObjects($a_obj_course, $crs_start)
73  {
74  $data = array();
75  foreach($crs_start->getPossibleStarters() as $item_ref_id)
76  {
77  $tmp_obj = ilObjectFactory::getInstanceByRefId($item_ref_id);
78 
79  $data[$item_ref_id]['id'] = $item_ref_id;
80  $data[$item_ref_id]['title'] = $tmp_obj->getTitle();
81  $data[$item_ref_id]['type'] = $this->lng->txt('obj_'.$tmp_obj->getType());
82  $data[$item_ref_id]['icon'] = ilObject::_getIcon($tmp_obj->getId(), 'tiny');
83 
84  if(strlen($tmp_obj->getDescription()))
85  {
86  $data[$item_ref_id]['description'] = $tmp_obj->getDescription();
87  }
88  }
89 
90  return $data;
91  }
92 
93  protected function getStartObjects($a_obj_course, $crs_start)
94  {
95  $starters = $crs_start->getStartObjects();
96 
97  /*
98  if(!count($starters))
99  {
100  ilUtil::sendInfo($this->lng->txt('crs_no_starter_created'));
101  }
102  */
103 
104  $data = array();
105  foreach($starters as $start_id => $item)
106  {
107  $tmp_obj = ilObjectFactory::getInstanceByRefId($item['item_ref_id']);
108 
109  $data[$item['item_ref_id']]['id'] = $start_id;
110  $data[$item['item_ref_id']]['title'] = $tmp_obj->getTitle();
111  $data[$item['item_ref_id']]['type'] = $this->lng->txt('obj_'.$tmp_obj->getType());
112  $data[$item['item_ref_id']]['icon'] = ilObject::_getIcon($tmp_obj->getId(), 'tiny');
113 
114  if(strlen($tmp_obj->getDescription()))
115  {
116  $data[$item['item_ref_id']]['description'] = $tmp_obj->getDescription();
117  }
118  }
119 
120  return $data;
121  }
122 
123  public function fillRow($a_set)
124  {
125  $this->tpl->setVariable("ID", $a_set["id"]);
126  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
127  $this->tpl->setVariable("TXT_DESCRIPTION", $a_set["description"]);
128  $this->tpl->setVariable("ICON_SRC", $a_set["icon"]);
129  $this->tpl->setVariable("ICON_ALT", $a_set["type"]);
130  }
131 }
132 
133 ?>