ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjLearningSequenceContentTableGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
11{
12 public function __construct(
14 string $cmd,
17 ilAccess $access,
18 ilAdvancedSelectionListGUI $advanced_selection_list_gui,
19 LSItemOnlineStatus $ls_item_online_status
20 ) {
21 parent::__construct($parent_gui, $cmd);
22
23 $this->parent_gui = $parent_gui;
24 $this->ctrl = $ctrl;
25 $this->lng = $lng;
26 $this->access = $access;
27 $this->advanced_selection_list_gui = $advanced_selection_list_gui;
28 $this->ls_item_online_status = $ls_item_online_status;
29
30 $this->setTitle($this->lng->txt("table_sequence_content"));
31 $this->setRowTemplate("tpl.content_table.html", "Modules/LearningSequence");
32 $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
33 $this->setExternalSorting(true);
34 $this->setEnableAllCommand(true);
35 $this->setShowRowsSelector(false);
36 $this->setTopCommands(true);
37 $this->setEnableHeader(true);
38
39 $this->addColumn("", "", "1", true);
40 $this->addColumn("");
41 $this->addColumn($this->lng->txt("table_position"));
42 $this->addColumn($this->lng->txt("table_title"));
43 $this->addColumn($this->lng->txt("table_online"));
44 $this->addColumn($this->lng->txt("table_may_proceed"));
45 $this->addColumn($this->lng->txt("table_actions"));
46
47 $this->setLimit(9999);
48 }
49
50 protected function fillRow($set)
51 {
52 $ni = new ilNumberInputGUI(
53 "",
54 $this->parent_gui->getFieldName($this->parent_gui::FIELD_ORDER, $set->getRefId())
55 );
56 $ni->setSize("3");
57 $ni->setDisabled($this->set_is_used);
58 $ni->setValue(($set->getOrderNumber() + 1) * 10);
59
60 if ($this->ls_item_online_status->hasOnlineStatus($set->getRefId())) {
61 $cb = new ilCheckboxInputGUI(
62 "",
63 $this->parent_gui->getFieldName($this->parent_gui::FIELD_ONLINE, $set->getRefId())
64 );
65 $cb->setChecked($set->isOnline());
66 } else {
67 $cb = new ilCheckboxInputGUI("", "");
68 $cb->setChecked(true);
69 $cb->setDisabled(true);
70 }
71 $this->tpl->setVariable("ONLINE", $cb->render());
72
74 "",
75 $this->parent_gui->getFieldName($this->parent_gui::FIELD_POSTCONDITION_TYPE, $set->getRefId())
76 );
77 $options = $this->parent_gui->getPossiblePostConditionsForType($set->getType());
78
79 $si->setOptions($options);
80 $si->setValue($set->getPostCondition()->getConditionOperator());
81
82 $action_items = $this->getActionMenuItems($set->getRefId(), $set->getType());
83 $obj_link = $this->getEditLink($set->getRefId(), $set->getType(), $action_items);
84
85 $title = $set->getTitle();
86 $title = sprintf(
87 '<a href="%s">%s</a>',
88 $obj_link,
89 $title
90 );
91
92 $this->tpl->setVariable("ID", $set->getRefId());
93 $this->tpl->setVariable("IMAGE", $set->getIconPath());
94 $this->tpl->setVariable("ORDER", $ni->render());
95 $this->tpl->setVariable("TITLE", $title);
96 $this->tpl->setVariable("POST_CONDITIONS", $si->render());
97 $this->tpl->setVariable("ACTIONS", $this->getItemActionsMenu($set->getRefId(), $set->getType()));
98 $this->tpl->setVariable("TYPE", $set->getType());
99 }
100
101
102 protected function getItemActionsMenu(int $ref_id, string $type) : string
103 {
104 $item_obj_id = $this->getObjIdFor($ref_id);
105 $item_list_gui = $this->getListGuiFor($type);
106 $item_list_gui->initItem($ref_id, $item_obj_id, $type);
107
108 $item_list_gui->enableCut(true);
109 $item_list_gui->enableDelete(true);
110 $item_list_gui->enableLink(true);
111 $item_list_gui->enableTimings(false);
112
113 $lso_gui = $this->parent_gui->parent_gui;
114 $item_list_gui->setContainerObject($lso_gui);
115
116 return $item_list_gui->getCommandsHTML();
117 }
118
119 protected function getActionMenuItems(int $ref_id, string $type) : array
120 {
121 $item_obj_id = $this->getObjIdFor($ref_id);
122 $item_list_gui = $this->getListGuiFor($type);
123 $item_list_gui->initItem($ref_id, $item_obj_id, $type);
124 return $item_list_gui->getCommands();
125 }
126
130 protected function getEditLink(int $ref_id, string $type, array $action_items)
131 {
132 switch ($type) {
133 case $this->ls_item_online_status::S_LEARNMODULE_IL:
134 case $this->ls_item_online_status::S_LEARNMODULE_HTML:
135 case $this->ls_item_online_status::S_SURVEY:
136 $prop_for_type = 'properties';
137 break;
138
139 case $this->ls_item_online_status::S_SAHS:
140 case $this->ls_item_online_status::S_CONTENTPAGE:
141 case $this->ls_item_online_status::S_EXERCISE:
142 case $this->ls_item_online_status::S_FILE:
143 $prop_for_type = 'edit';
144 break;
145
146 case $this->ls_item_online_status::S_TEST:
147 $prop_for_type = 'ilObjTestSettingsGeneralGUI::showForm';
148 break;
149
150 case $this->ls_item_online_status::S_IND_ASSESSMENT:
151 default:
152 return $this->getStdLink($ref_id, $type);
153 }
154
155 $props = array_filter(
156 $action_items,
157 function ($action_item) use ($prop_for_type) {
158 //var_dump($action_item['cmd']);
159 return $action_item['cmd'] === $prop_for_type;
160 }
161 );
162
163 if (count($props) > 0) {
164 return array_shift($props)['link'];
165 }
166 return null;
167 }
168
169 protected function getObjIdFor(int $ref_id) : int
170 {
171 return ilObject::_lookupObjId($ref_id);
172 }
173
174 protected function getListGuiFor(string $type) : ilObjectListGUI
175 {
177 }
178
179 protected function getStdLink(int $ref_id, string $type) : string
180 {
181 return ilLink::_getLink($ref_id, $type);
182 }
183}
An exception for terminatinating execution or to throw for unit testing.
Class ilAccessHandler.
User interface class for advanced drop-down selection lists.
This class represents a checkbox property in a property form.
This class provides processing control methods.
language handling
This class represents a number property in a property form.
Class ilObjLearningSequenceContentGUI.
getEditLink(int $ref_id, string $type, array $action_items)
__construct(ilObjLearningSequenceContentGUI $parent_gui, string $cmd, ilCtrl $ctrl, ilLanguage $lng, ilAccess $access, ilAdvancedSelectionListGUI $advanced_selection_list_gui, LSItemOnlineStatus $ls_item_online_status)
static _getListGUIByType( $type, $context=ilObjectListGUI::CONTEXT_REPOSITORY)
Class ilObjectListGUI.
static _lookupObjId($a_id)
This class represents a selection list property in a property form.
Class ilTable2GUI.
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
setEnableHeader($a_enableheader)
Set Enable Header.
setExternalSorting($a_val)
Set external sorting.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setEnableAllCommand($a_value)
Enable actions for all entries in current result.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
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.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type