ILIAS  release_8 Revision v8.24
class.ilObjLearningModuleListGUI.php
Go to the documentation of this file.
1<?php
2
20
25{
27 private string $child_id = "";
28 protected \ILIAS\LearningModule\ReadingTime\ReadingTimeManager $reading_time_manager;
29
30 public function init(): void
31 {
32 global $DIC;
33
34 $this->static_link_enabled = true;
35 $this->delete_enabled = true;
36 $this->cut_enabled = true;
37 $this->copy_enabled = true;
38 $this->subscribe_enabled = true;
39 $this->link_enabled = true;
40 $this->info_screen_enabled = true;
41 $this->type = "lm";
42 $this->gui_class_name = "ilobjlearningmodulegui";
43
44
45 $this->request = $DIC
46 ->learningModule()
47 ->internal()
48 ->gui()
49 ->presentation()
50 ->request();
51 $this->enableLearningProgress(true);
52 $this->lng->loadLanguageModule("copg");
53
54 // general commands array
56 $this->reading_time_manager = new \ILIAS\LearningModule\ReadingTime\ReadingTimeManager();
57 }
58
59 public function setChildId(string $a_child_id): void
60 {
61 $this->child_id = $a_child_id;
62 }
63
64 public function getChildId(): string
65 {
66 return $this->child_id;
67 }
68
69 public function getCommandLink(string $cmd): string
70 {
72
73 switch ($cmd) {
74 case "continue":
75 $ctrl->setParameterByClass(ilLMPresentationGUI::class, "ref_id", $this->ref_id);
76 $cmd_link = $ctrl->getLinkTargetByClass(ilLMPresentationGUI::class, "resume");
77 break;
78
79 case "page":
80 $ctrl->setParameterByClass(ilLMPresentationGUI::class, "ref_id", $this->ref_id);
81 $ctrl->setParameterByClass(ilLMPresentationGUI::class, "obj_id", $this->getChildId());
82 $cmd_link = $ctrl->getLinkTargetByClass(ilLMPresentationGUI::class, "");
83 break;
84
85 case "view":
86 $ctrl->setParameterByClass(ilLMPresentationGUI::class, "ref_id", $this->ref_id);
87 $cmd_link = $ctrl->getLinkTargetByClass(ilLMPresentationGUI::class, "");
88 break;
89
90 case "learningProgress":
91 $ctrl->setParameterByClass(ilLMPresentationGUI::class, "ref_id", $this->ref_id);
92 $cmd_link = $ctrl->getLinkTargetByClass(
93 [ilLMPresentationGUI::class, ilLearningProgressGUI::class ],
94 ""
95 );
96 break;
97
98 case "edit":
99 $ctrl->setParameterByClass(ilObjLearningModuleGUI::class, "ref_id", $this->ref_id);
100 $cmd_link = $ctrl->getLinkTargetByClass([ilLMEditorGUI::class, ilObjLearningModuleGUI::class], "");
101 break;
102
103 case "properties":
104 $ctrl->setParameterByClass(ilObjLearningModuleGUI::class, "ref_id", $this->ref_id);
105 $cmd_link = $ctrl->getLinkTargetByClass([ilLMEditorGUI::class, ilObjLearningModuleGUI::class], "properties");
106 break;
107
108 case "infoScreen":
109 $ctrl->setParameterByClass(ilLMPresentationGUI::class, "ref_id", $this->ref_id);
110 $cmd_link = $ctrl->getLinkTargetByClass(ilLMPresentationGUI::class, "infoScreen");
111 break;
112
113 case 'downloadFile':
114 $ctrl->setParameterByClass(ilLMPresentationGUI::class, "ref_id", $this->ref_id);
115 $ctrl->setParameterByClass(ilLMPresentationGUI::class, "file_id", $this->getChildId());
116 $cmd_link = $ctrl->getLinkTargetByClass(ilLMPresentationGUI::class, "file_id");
117 break;
118
119 default:
120 $ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
121 $cmd_link = $ctrl->getLinkTargetByClass("ilrepositorygui", $cmd);
122 $ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->request->getRefId());
123 break;
124 }
125
126 return $cmd_link;
127 }
128
129 public function getCommandFrame(string $cmd): string
130 {
131 switch ($cmd) {
132 case "view":
133 case "continue":
134 case "properties":
135 case "infoScreen":
136 case "edit":
137 case 'list':
138 $frame = ilFrameTargetInfo::_getFrame("MainContent");
139 break;
140
141 default:
142 $frame = "";
143 break;
144 }
145
146 return $frame;
147 }
148
149 public function getProperties(): array
150 {
153
154 $props = parent::getProperties();
155
156 if ($rbacsystem->checkAccess('write', $this->ref_id)) {
157 $props[] = array("alert" => false, "property" => $lng->txt("type"),
158 "value" => $lng->txt("lm"));
159 }
160
161 $est_reading_time = $this->reading_time_manager->getReadingTime($this->obj_id);
162 if (!is_null($est_reading_time)) {
163 $props[] = array(
164 "alert" => false,
165 "property" => $lng->txt("copg_est_reading_time"),
166 "value" => sprintf($lng->txt("copg_x_minutes"), $est_reading_time)
167 );
168 }
169
170 return $props;
171 }
172
173 public function getInfoScreenStatus(): bool
174 {
175 return ilObjContentObjectAccess::isInfoEnabled($this->obj_id);
176 }
177
179 {
180 return true;
181 }
182}
static _getFrame(string $a_class)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
ILIAS LearningModule ReadingTime ReadingTimeManager $reading_time_manager
getCommandFrame(string $cmd)
Get command target frame.
getCommandLink(string $cmd)
Get command link url.
enableLearningProgress(bool $enabled)
ilCtrlInterface $ctrl
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
global $DIC
Definition: feed.php:28
getLinkTargetByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
Returns a link target for the given information.
setParameterByClass(string $a_class, string $a_parameter, $a_value)
Sets a parameter for the given GUI class and appends the given value as well.