ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilContainerStartObjectsTableGUI.php
Go to the documentation of this file.
1 <?php
2 
24 {
25  protected ilContainerStartObjects $start_obj; // [ilContainerStartObjects]
26 
27  public function __construct(
28  ilContainerStartObjectsGUI $a_parent_obj,
29  string $a_parent_cmd,
30  ilContainerStartObjects $a_start_objects
31  ) {
32  global $DIC;
33 
34  $lng = $DIC->language();
35  $ilCtrl = $DIC->ctrl();
36 
37  $this->lng = $lng;
38  $this->ctrl = $ilCtrl;
39  $this->lng->loadLanguageModule('crs');
40 
41  $this->start_obj = $a_start_objects;
42 
43  parent::__construct($a_parent_obj, $a_parent_cmd);
44 
45  $this->addColumn('', '', '1');
46 
47  if ($a_parent_cmd === 'listStructure') {
48  $this->addColumn($this->lng->txt('cntr_ordering'), 'pos', '5%');
49  }
50 
51  $this->addColumn($this->lng->txt('type'), 'type', '1');
52  $this->addColumn($this->lng->txt('title'), 'title');
53  $this->addColumn($this->lng->txt('description'), 'description');
54 
55  // add
56  if ($a_parent_cmd !== 'listStructure') {
57  $this->setTitle($this->lng->txt('crs_select_starter'));
58  $this->addMultiCommand('addStarter', $this->lng->txt('crs_add_starter'));
59  $this->addCommandButton('listStructure', $this->lng->txt('cancel'));
60 
61  $this->setDefaultOrderField('title');
62  }
63  // list
64  else {
65  $this->setTitle($this->lng->txt('crs_start_objects'));
66  $this->addMultiCommand('askDeleteStarter', $this->lng->txt('remove'));
67  $this->addCommandButton('saveSorting', $this->lng->txt('sorting_save'));
68 
69  $this->setDefaultOrderField('pos');
70  }
71  $this->setDefaultOrderDirection('asc');
72 
73  $this->setRowTemplate("tpl.start_objects_row.html", "components/ILIAS/Container");
74  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
75  $this->setSelectAllCheckbox('starter');
76 
77  $data = [];
78 
79  // add
80  if ($a_parent_cmd !== 'listStructure') {
81  $data = $this->getPossibleObjects();
82  }
83  // list
84  else {
85  $data = $this->getStartObjects();
86  }
87 
88  $this->setData($data);
89  }
90 
91  protected function getPossibleObjects(): array
92  {
93  $data = [];
94  foreach ($this->start_obj->getPossibleStarters() as $item_ref_id) {
95  $tmp_obj = ilObjectFactory::getInstanceByRefId($item_ref_id);
96 
97  $data[$item_ref_id]['id'] = $item_ref_id;
98  $data[$item_ref_id]['title'] = $tmp_obj->getTitle();
99  $data[$item_ref_id]['type'] = $this->lng->txt('obj_' . $tmp_obj->getType());
100  $data[$item_ref_id]['icon'] = ilObject::_getIcon($tmp_obj->getId(), 'tiny');
101 
102  if ($tmp_obj->getDescription() !== '') {
103  $data[$item_ref_id]['description'] = $tmp_obj->getDescription();
104  }
105  }
106 
107  return $data;
108  }
109 
110  protected function getStartObjects(): array
111  {
112  $data = [];
113  $counter = 0;
114  foreach ($this->start_obj->getStartObjects() as $start_id => $item) {
115  $tmp_obj = ilObjectFactory::getInstanceByRefId($item['item_ref_id']);
116 
117  $data[$item['item_ref_id']]['id'] = $start_id;
118  $data[$item['item_ref_id']]['title'] = $tmp_obj->getTitle();
119  $data[$item['item_ref_id']]['type'] = $this->lng->txt('obj_' . $tmp_obj->getType());
120  $data[$item['item_ref_id']]['icon'] = ilObject::_getIcon($tmp_obj->getId(), 'tiny');
121 
122  $counter += 10;
123  $data[$item['item_ref_id']]['pos'] = $counter;
124 
125  if ($tmp_obj->getDescription() !== '') {
126  $data[$item['item_ref_id']]['description'] = $tmp_obj->getDescription();
127  }
128  }
129 
130  return $data;
131  }
132 
133  protected function fillRow(array $a_set): void
134  {
135  if ($this->getParentCmd() === 'listStructure') {
136  $this->tpl->setCurrentBlock('pos_bl');
137  $this->tpl->setVariable("POS_ID", $a_set["id"]);
138  $this->tpl->setVariable("POS", $a_set["pos"]);
139  $this->tpl->parseCurrentBlock();
140  }
141 
142  $this->tpl->setVariable("ID", $a_set["id"]);
143  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
144  $this->tpl->setVariable("TXT_DESCRIPTION", $a_set["description"] ?? '');
145  $this->tpl->setVariable("ICON_SRC", $a_set["icon"]);
146  $this->tpl->setVariable("ICON_ALT", $a_set["type"]);
147  }
148 }
setData(array $a_data)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
setFormAction(string $a_form_action, bool $a_multipart=false)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilLanguage $lng
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
__construct(ilContainerStartObjectsGUI $a_parent_obj, string $a_parent_cmd, ilContainerStartObjects $a_start_objects)
global $DIC
Definition: shib_login.php:22
setDefaultOrderDirection(string $a_defaultorderdirection)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
__construct(Container $dic, ilPlugin $plugin)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
addMultiCommand(string $a_cmd, string $a_text)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilContainerStartObjectsGUI.