ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilPCMyCoursesGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5require_once("./Modules/Portfolio/classes/class.ilPCMyCourses.php");
6require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
7
19{
24 public function __construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id = "")
25 {
26 global $DIC;
27
28 $this->tpl = $DIC["tpl"];
29 $this->ctrl = $DIC->ctrl();
30 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
31 }
32
36 public function executeCommand()
37 {
38 // get next class that processes or forwards current command
39 $next_class = $this->ctrl->getNextClass($this);
40
41 // get current command
42 $cmd = $this->ctrl->getCmd();
43
44 switch ($next_class) {
45 default:
46 $ret = &$this->$cmd();
47 break;
48 }
49
50 return $ret;
51 }
52
58 public function insert(ilPropertyFormGUI $a_form = null)
59 {
61
62 /* #12816 - no form needed yet
63 $this->create();
64 */
65
67
68 if (!$a_form) {
69 $a_form = $this->initForm(true);
70 }
71 $tpl->setContent($a_form->getHTML());
72 }
73
79 public function edit(ilPropertyFormGUI $a_form = null)
80 {
82
84
85 if (!$a_form) {
86 $a_form = $this->initForm();
87 }
88 $tpl->setContent($a_form->getHTML());
89 }
90
97 protected function initForm($a_insert = false)
98 {
100
101 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
102 $form = new ilPropertyFormGUI();
103 $form->setFormAction($ilCtrl->getFormAction($this));
104 if ($a_insert) {
105 $form->setTitle($this->lng->txt("cont_insert_my_courses"));
106 } else {
107 $form->setTitle($this->lng->txt("cont_update_my_courses"));
108 }
109
110 $sort = new ilRadioGroupInputGUI($this->lng->txt("cont_mycourses_sortorder"), "sort");
111 $sort->setInfo($this->lng->txt("cont_mycourses_sortorder_info")); //#15511
112 $sort->setRequired(true);
113 $form->addItem($sort);
114
115 $sort->addOption(new ilRadioOption($this->lng->txt("cont_mycourses_sortorder_alphabetical"), "alpha"));
116 $sort->addOption(new ilRadioOption($this->lng->txt("cont_mycourses_sortorder_location"), "loc"));
117
118 if ($a_insert) {
119 $sort->setValue("alpha");
120
121 $form->addCommandButton("create_my_courses", $this->lng->txt("save"));
122 $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
123 } else {
124 $sort->setValue($this->content_obj->getSorting());
125
126 $form->addCommandButton("update", $this->lng->txt("save"));
127 $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
128 }
129
130 return $form;
131 }
132
136 public function create()
137 {
138 $form = $this->initForm(true);
139 if ($form->checkInput()) {
140 $sort = $form->getInput("sort");
141
142 $this->content_obj = new ilPCMyCourses($this->getPage());
143 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
144 $this->content_obj->setData($sort);
145 $this->updated = $this->pg_obj->update();
146 if ($this->updated === true) {
147 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
148 }
149 }
150
151 $form->setValuesByPost();
152 return $this->insert($form);
153 }
154
158 public function update()
159 {
160 $form = $this->initForm();
161 if ($form->checkInput()) {
162 $sort = $form->getInput("sort");
163
164 $this->content_obj->setData($sort);
165 $this->updated = $this->pg_obj->update();
166 if ($this->updated === true) {
167 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
168 }
169 }
170
171 $this->pg_obj->addHierIDs();
172 $form->setValuesByPost();
173 return $this->edit($form);
174 }
175}
An exception for terminatinating execution or to throw for unit testing.
Class ilPCMyCoursesGUI.
__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
initForm($a_insert=false)
Init courses form.
create()
Create new courses.
edit(ilPropertyFormGUI $a_form=null)
Edit courses form.
insert(ilPropertyFormGUI $a_form=null)
Insert courses form.
executeCommand()
execute command
Class ilPCMyCourses.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
displayValidationError()
display validation errors
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.
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7