ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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
55  $this->commands = ilObjLearningModuleAccess::_getCommands();
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 getProperties(): array
130  {
131  $lng = $this->lng;
133 
134  $props = parent::getProperties();
135 
136  if ($rbacsystem->checkAccess('write', $this->ref_id)) {
137  $props[] = array("alert" => false, "property" => $lng->txt("type"),
138  "value" => $lng->txt("lm"));
139  }
140 
141  $est_reading_time = $this->reading_time_manager->getReadingTime($this->obj_id);
142  if (!is_null($est_reading_time)) {
143  $props[] = array(
144  "alert" => false,
145  "property" => $lng->txt("copg_est_reading_time"),
146  "value" => sprintf($lng->txt("copg_x_minutes"), $est_reading_time)
147  );
148  }
149 
150  return $props;
151  }
152 
153  public function getInfoScreenStatus(): bool
154  {
155  return ilObjContentObjectAccess::isInfoEnabled($this->obj_id);
156  }
157 
158  public function checkInfoPageOnAsynchronousRendering(): bool
159  {
160  return true;
161  }
162 }
setParameterByClass(string $a_class, string $a_parameter, $a_value)
Sets a parameter for the given GUI class and appends the given value as well.
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...
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.
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: shib_login.php:26
ilCtrlInterface $ctrl
enableLearningProgress(bool $enabled)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS LearningModule ReadingTime ReadingTimeManager $reading_time_manager