ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPCMyCoursesGUI.php
Go to the documentation of this file.
1<?php
2
24{
25 public function __construct(
26 ilPageObject $a_pg_obj,
27 ?ilPageContent $a_content_obj,
28 string $a_hier_id,
29 string $a_pc_id = ""
30 ) {
31 global $DIC;
32
33 $this->tpl = $DIC["tpl"];
34 $this->ctrl = $DIC->ctrl();
35 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
36 }
37
38 public function executeCommand(): void
39 {
40 // get next class that processes or forwards current command
41 $next_class = $this->ctrl->getNextClass($this);
42
43 // get current command
44 $cmd = $this->ctrl->getCmd();
45
46 switch ($next_class) {
47 default:
48 $this->$cmd();
49 break;
50 }
51 }
52
53 public function insert(?ilPropertyFormGUI $a_form = null): void
54 {
56
57 /* #12816 - no form needed yet
58 $this->create();
59 */
60
62
63 if (!$a_form) {
64 $a_form = $this->initForm(true);
65 }
66 $tpl->setContent($a_form->getHTML());
67 }
68
69 public function edit(?ilPropertyFormGUI $a_form = null): void
70 {
72
74
75 if (!$a_form) {
76 $a_form = $this->initForm();
77 }
78 $tpl->setContent($a_form->getHTML());
79 }
80
81 protected function initForm($a_insert = false): ilPropertyFormGUI
82 {
83 $ilCtrl = $this->ctrl;
84
85 $form = new ilPropertyFormGUI();
86 $form->setFormAction($ilCtrl->getFormAction($this));
87 if ($a_insert) {
88 $form->setTitle($this->lng->txt("cont_insert_my_courses"));
89 } else {
90 $form->setTitle($this->lng->txt("cont_update_my_courses"));
91 }
92
93 $sort = new ilRadioGroupInputGUI($this->lng->txt("cont_mycourses_sortorder"), "sort");
94 $sort->setInfo($this->lng->txt("cont_mycourses_sortorder_info")); //#15511
95 $sort->setRequired(true);
96 $form->addItem($sort);
97
98 $sort->addOption(new ilRadioOption($this->lng->txt("cont_mycourses_sortorder_alphabetical"), "alpha"));
99 $sort->addOption(new ilRadioOption($this->lng->txt("cont_mycourses_sortorder_location"), "loc"));
100
101 if ($a_insert) {
102 $sort->setValue("alpha");
103
104 $form->addCommandButton("create_my_courses", $this->lng->txt("save"));
105 $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
106 } else {
107 $sort->setValue($this->content_obj->getSorting());
108
109 $form->addCommandButton("update", $this->lng->txt("save"));
110 $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
111 }
112
113 return $form;
114 }
115
116 public function create_my_courses(): void
117 {
118 $this->create();
119 }
120
121 public function create(): void
122 {
123 $form = $this->initForm(true);
124 if ($form->checkInput()) {
125 $sort = $form->getInput("sort");
126
127 $this->content_obj = new ilPCMyCourses($this->getPage());
128 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
129 $this->content_obj->setData($sort);
130 $this->updated = $this->pg_obj->update();
131 if ($this->updated === true) {
132 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
133 }
134 }
135
136 $form->setValuesByPost();
137 $this->insert($form);
138 }
139
140 public function update(): void
141 {
142 $form = $this->initForm();
143 if ($form->checkInput()) {
144 $sort = $form->getInput("sort");
145 $this->content_obj->setData($sort);
146 $this->updated = $this->pg_obj->update();
147 if ($this->updated === true) {
148 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
149 }
150 }
151
152 $this->pg_obj->addHierIDs();
153 $form->setValuesByPost();
154 $this->edit($form);
155 }
156}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
initForm($a_insert=false)
edit(?ilPropertyFormGUI $a_form=null)
insert(?ilPropertyFormGUI $a_form=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
ilGlobalTemplateInterface $tpl
Content object of ilPageObject (see ILIAS DTD).
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
setContent(string $a_html)
Sets content for standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26