ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilObjStudyProgrammeSettingsGUI Class Reference

Class ilObjStudyProgrammeSettingsGUI. More...

+ Collaboration diagram for ilObjStudyProgrammeSettingsGUI:

Public Member Functions

 __construct ($a_parent_gui, $a_ref_id)
 
 executeCommand ()
 

Data Fields

 $ctrl
 
 $tpl
 
 $object
 
 $ilias
 
 $lng
 
const PROP_TITLE = "title"
 
const PROP_DESC = "desc"
 
const PROP_TYPE = "type"
 
const PROP_POINTS = "points"
 
const PROP_STATUS = "status"
 

Protected Member Functions

 view ()
 
 update ()
 
 cancel ()
 
 buildModalHeading ($label, $current_node)
 
 buildForm (\ilObjStudyProgramme $prg, string $submit_action)
 
 updateWith (\ilObjStudyProgramme $prg, array $data)
 
 getObject ()
 

Static Protected Member Functions

static getStatusOptions ()
 

Protected Attributes

 $ilAccess
 
 $ilLog
 
 $parent_gui
 
 $tmp_heading
 
 $input_factory
 
 $renderer
 
 $request
 
 $trafo_factory
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjStudyProgrammeSettingsGUI::__construct (   $a_parent_gui,
  $a_ref_id 
)

Definition at line 85 of file class.ilObjStudyProgrammeSettingsGUI.php.

86 {
87 global $DIC;
88 $tpl = $DIC['tpl'];
89 $ilCtrl = $DIC['ilCtrl'];
90 $ilAccess = $DIC['ilAccess'];
91 $ilToolbar = $DIC['ilToolbar'];
92 $ilLocator = $DIC['ilLocator'];
93 $tree = $DIC['tree'];
94 $lng = $DIC['lng'];
95 $ilLog = $DIC['ilLog'];
96 $ilias = $DIC['ilias'];
97
98 $this->parent_gui = $a_parent_gui;
99 $this->ref_id = $a_ref_id;
100 $this->parent_gui = $a_parent_gui;
101
102 $this->tpl = $tpl;
103 $this->ctrl = $ilCtrl;
104 $this->ilAccess = $ilAccess;
105 $this->ilLocator = $ilLocator;
106 $this->tree = $tree;
107 $this->toolbar = $ilToolbar;
108 $this->ilLog = $ilLog;
109 $this->ilias = $ilias;
110 $this->lng = $lng;
111 $this->input_factory = $DIC->ui()->factory()->input();
112 $this->renderer = $DIC->ui()->renderer();
113 $this->request = $DIC->http()->request();
114 $this->trafo_factory = new \ILIAS\Transformation\Factory(); // TODO: replace this with the version from the DIC once available
115 $this->data = new \ILIAS\Data\Factory();
116 $this->validation = new \ILIAS\Validation\Factory($this->data, $this->lng);
117
118 $this->object = null;
119
120 $lng->loadLanguageModule("prg");
121 }
Class ilAccessHandler.
logging
Definition: class.ilLog.php:19
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
global $DIC
Definition: saml.php:7
$this data['403_header']

References $DIC, $ilAccess, $ilCtrl, $ilias, $ilLog, $lng, $tpl, $tree, and data.

Member Function Documentation

◆ buildForm()

ilObjStudyProgrammeSettingsGUI::buildForm ( \ilObjStudyProgramme  $prg,
string  $submit_action 
)
protected

Definition at line 226 of file class.ilObjStudyProgrammeSettingsGUI.php.

227 {
228 $ff = $this->input_factory->field();
230 $txt = function ($id) {
231 return $this->lng->txt($id);
232 };
234 $status_options = self::getStatusOptions();
235 return $this->input_factory->container()->form()->standard(
236 $submit_action,
237 [
238 $ff->section(
239 [
240 self::PROP_TITLE =>
241 $ff->text($txt("title"))
242 ->withValue($prg->getTitle())
243 ->withRequired(true),
244 self::PROP_DESC =>
245 $ff->textarea($txt("description"))
246 ->withValue($prg->getDescription() ?? "")
247 ],
248 $txt("prg_edit"),
249 ""
250 ),
251 $ff->section(
252 [
253 self::PROP_TYPE =>
254 $ff->select($txt("type"), $sp_types)
255 ->withValue($prg->getSubtypeId() == 0 ? "" : $prg->getSubtypeId())
256 ->withAdditionalTransformation($tf->custom(function ($v) {
257 if ($v == "") {
258 return 0;
259 }
260 return $v;
261 }))
262 ],
263 $txt("prg_type"),
264 ""
265 ),
266 $ff->section(
267 [
268 self::PROP_POINTS =>
269 $ff->numeric($txt("prg_points"))
270 ->withValue((string) $prg->getPoints())
271 ->withAdditionalConstraint($this->validation->greaterThan(-1)),
272 self::PROP_STATUS =>
273 $ff->select($txt("prg_status"), $status_options)
274 ->withValue((string) $prg->getStatus())
275 ->withRequired(true)
276 ],
277 $txt("prg_assessment"),
278 ""
279 )
280 ]
281 )
282 ->withAdditionalTransformation($tf->custom(function ($values) {
283 // values now contains the results of the single sections,
284 // i.e. a list of arrays that each contains keys according
285 // to the section they originated from.
286 return call_user_func_array("array_merge", $values);
287 }));
288 }
$txt
Definition: error.php:11
if(!array_key_exists('StateId', $_REQUEST)) $id
This describes a standard form.
Definition: Standard.php:11
$values

References $id, $trafo_factory, $txt, $values, ilStudyProgrammeType\getAllTypesArray(), ilObject\getDescription(), ilObjStudyProgramme\getPoints(), ilObjStudyProgramme\getStatus(), getStatusOptions(), ilObjStudyProgramme\getSubtypeId(), and ilObject\getTitle().

Referenced by view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildModalHeading()

ilObjStudyProgrammeSettingsGUI::buildModalHeading (   $label,
  $current_node 
)
protected

Definition at line 205 of file class.ilObjStudyProgrammeSettingsGUI.php.

206 {
207 if (!$current_node) {
208 $this->ctrl->saveParameterByClass('ilobjstudyprogrammesettingsgui', 'ref_id');
209 $heading_button = ilLinkButton::getInstance();
210 $heading_button->setCaption('prg_open_node');
211 $heading_button->setUrl($this->ctrl->getLinkTargetByClass('ilobjstudyprogrammetreegui', 'view'));
212
213 $heading = "<div class=''>" . $label . "<div class='pull-right'>" . $heading_button->render() . "</div></div>";
214 $this->tmp_heading = $heading;
215 } else {
216 $this->tmp_heading = "<div class=''>" . $label . "</div>";
217 }
218 }
static getInstance()
Factory.

References ilLinkButton\getInstance().

Referenced by view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancel()

ilObjStudyProgrammeSettingsGUI::cancel ( )
protected

Definition at line 198 of file class.ilObjStudyProgrammeSettingsGUI.php.

199 {
201
202 $this->ctrl->redirect($this->parent_gui);
203 }
static handleAsyncOutput($normal_content, $async_content=null, $apply_to_tpl=true)
Handles async output.
static encodeAsyncResponse(array $data=array())
Encode data as json for async output.

References ilAsyncOutputHandler\encodeAsyncResponse(), and ilAsyncOutputHandler\handleAsyncOutput().

+ Here is the call graph for this function:

◆ executeCommand()

ilObjStudyProgrammeSettingsGUI::executeCommand ( )

Definition at line 123 of file class.ilObjStudyProgrammeSettingsGUI.php.

124 {
125 $cmd = $this->ctrl->getCmd();
126
127
128 if ($cmd == "") {
129 $cmd = "view";
130 }
131
132 switch ($cmd) {
133 case "view":
134 case "update":
135 case "cancel":
136 $content = $this->$cmd();
137 break;
138 default:
139 throw new ilException("ilObjStudyProgrammeSettingsGUI: " .
140 "Command not supported: $cmd");
141 }
142
143 if (!$this->ctrl->isAsynch()) {
144 $this->tpl->setContent($content);
145 } else {
146 $output_handler = new ilAsyncOutputHandler();
147 $heading = $this->lng->txt("prg_async_" . $this->ctrl->getCmd());
148 if (isset($this->tmp_heading)) {
149 $heading = $this->tmp_heading;
150 }
151 $output_handler->setHeading($heading);
152 $output_handler->setContent($content);
153 $output_handler->terminate();
154 }
155 }
Class ilAsyncOutputHandler Handles the output for async-requests.
Base class for ILIAS Exception handling.

References $tmp_heading.

◆ getObject()

ilObjStudyProgrammeSettingsGUI::getObject ( )
protected

Definition at line 307 of file class.ilObjStudyProgrammeSettingsGUI.php.

308 {
309 if ($this->object === null) {
310 $this->object = ilObjStudyProgramme::getInstanceByRefId($this->ref_id);
311 }
312 return $this->object;
313 }
static getInstanceByRefId($a_ref_id)
Get an instance of ilObjStudyProgramme, use cache.

References $object, and ilObjStudyProgramme\getInstanceByRefId().

Referenced by update(), and view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStatusOptions()

static ilObjStudyProgrammeSettingsGUI::getStatusOptions ( )
staticprotected

Definition at line 315 of file class.ilObjStudyProgrammeSettingsGUI.php.

316 {
317 global $DIC;
318 $lng = $DIC['lng'];
319
321 => $lng->txt("prg_status_draft")
323 => $lng->txt("prg_status_active")
325 => $lng->txt("prg_status_outdated")
326 );
327 }

References $DIC, $lng, ilStudyProgramme\STATUS_ACTIVE, ilStudyProgramme\STATUS_DRAFT, and ilStudyProgramme\STATUS_OUTDATED.

Referenced by buildForm().

+ Here is the caller graph for this function:

◆ update()

ilObjStudyProgrammeSettingsGUI::update ( )
protected

Definition at line 165 of file class.ilObjStudyProgrammeSettingsGUI.php.

166 {
167 $form = $this
168 ->buildForm($this->getObject(), $this->ctrl->getFormAction($this, "update"))
169 ->withRequest($this->request);
170 $content = $form->getData();
171 $prg = $this->getObject();
172
173 // This could further improved by providing a new container for asynch-forms in the
174 // UI-Framework.
175 $update_possible = !is_null($content);
176 if ($update_possible) {
177 $this->updateWith($prg, $content);
178 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
179
180 if ($this->ctrl->isAsynch()) {
181 $response = ilAsyncOutputHandler::encodeAsyncResponse(array("success" => true, "message" => $this->lng->txt("msg_obj_modified")));
183 } else {
184 $this->ctrl->redirect($this);
185 }
186 } else {
187 ilUtil::sendFailure($this->lng->txt("msg_form_save_error"));
188
189 if ($this->ctrl->isAsynch()) {
190 $response = ilAsyncOutputHandler::encodeAsyncResponse(array("success" => false, "errors" => $form->getErrors()));
192 } else {
193 return $this->renderer->render($form);
194 }
195 }
196 }
updateWith(\ilObjStudyProgramme $prg, array $data)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$response
if(isset($_POST['submit'])) $form

References $form, $response, ilAsyncOutputHandler\encodeAsyncResponse(), getObject(), ilAsyncOutputHandler\handleAsyncOutput(), ilUtil\sendFailure(), and updateWith().

+ Here is the call graph for this function:

◆ updateWith()

ilObjStudyProgrammeSettingsGUI::updateWith ( \ilObjStudyProgramme  $prg,
array  $data 
)
protected

Definition at line 290 of file class.ilObjStudyProgrammeSettingsGUI.php.

291 {
292 $prg->setTitle($data[self::PROP_TITLE]);
293 $prg->setDescription($data[self::PROP_DESC]);
294
295 if ($prg->getSubtypeId() != $data[self::PROP_TYPE]) {
296 $prg->setSubtypeId($data[self::PROP_TYPE]);
297 $prg->updateCustomIcon();
298 $this->parent_gui->setTitleAndDescription();
299 }
300
301 $prg->setPoints($data[self::PROP_POINTS]);
302 $prg->setStatus($data[self::PROP_STATUS]);
303
304 $prg->update();
305 }
$data
Definition: bench.php:6

References $data, ilObjStudyProgramme\getSubtypeId(), ilObject\setDescription(), ilObjStudyProgramme\setPoints(), ilObjStudyProgramme\setStatus(), ilObjStudyProgramme\setSubtypeId(), ilObject\setTitle(), and ilObjStudyProgramme\update().

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ view()

ilObjStudyProgrammeSettingsGUI::view ( )
protected

Definition at line 157 of file class.ilObjStudyProgrammeSettingsGUI.php.

158 {
159 $this->buildModalHeading($this->lng->txt('prg_async_settings'), isset($_GET["currentNode"]));
160
161 $form = $this->buildForm($this->getObject(), $this->ctrl->getFormAction($this, "update"));
162 return $this->renderer->render($form);
163 }
$_GET["client_id"]
buildForm(\ilObjStudyProgramme $prg, string $submit_action)

References $_GET, $form, buildForm(), buildModalHeading(), and getObject().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilObjStudyProgrammeSettingsGUI::$ctrl

Definition at line 23 of file class.ilObjStudyProgrammeSettingsGUI.php.

◆ $ilAccess

ilObjStudyProgrammeSettingsGUI::$ilAccess
protected

Definition at line 33 of file class.ilObjStudyProgrammeSettingsGUI.php.

Referenced by __construct().

◆ $ilias

ilObjStudyProgrammeSettingsGUI::$ilias

Definition at line 48 of file class.ilObjStudyProgrammeSettingsGUI.php.

Referenced by __construct().

◆ $ilLog

ilObjStudyProgrammeSettingsGUI::$ilLog
protected

Definition at line 43 of file class.ilObjStudyProgrammeSettingsGUI.php.

Referenced by __construct().

◆ $input_factory

ilObjStudyProgrammeSettingsGUI::$input_factory
protected

Definition at line 68 of file class.ilObjStudyProgrammeSettingsGUI.php.

◆ $lng

ilObjStudyProgrammeSettingsGUI::$lng

Definition at line 53 of file class.ilObjStudyProgrammeSettingsGUI.php.

Referenced by __construct(), and getStatusOptions().

◆ $object

ilObjStudyProgrammeSettingsGUI::$object

Definition at line 38 of file class.ilObjStudyProgrammeSettingsGUI.php.

Referenced by getObject().

◆ $parent_gui

ilObjStudyProgrammeSettingsGUI::$parent_gui
protected

Definition at line 58 of file class.ilObjStudyProgrammeSettingsGUI.php.

◆ $renderer

ilObjStudyProgrammeSettingsGUI::$renderer
protected

Definition at line 73 of file class.ilObjStudyProgrammeSettingsGUI.php.

◆ $request

ilObjStudyProgrammeSettingsGUI::$request
protected

Definition at line 78 of file class.ilObjStudyProgrammeSettingsGUI.php.

◆ $tmp_heading

ilObjStudyProgrammeSettingsGUI::$tmp_heading
protected

Definition at line 63 of file class.ilObjStudyProgrammeSettingsGUI.php.

Referenced by executeCommand().

◆ $tpl

ilObjStudyProgrammeSettingsGUI::$tpl

Definition at line 28 of file class.ilObjStudyProgrammeSettingsGUI.php.

Referenced by __construct().

◆ $trafo_factory

ilObjStudyProgrammeSettingsGUI::$trafo_factory
protected

Definition at line 83 of file class.ilObjStudyProgrammeSettingsGUI.php.

Referenced by buildForm().

◆ PROP_DESC

const ilObjStudyProgrammeSettingsGUI::PROP_DESC = "desc"

Definition at line 221 of file class.ilObjStudyProgrammeSettingsGUI.php.

◆ PROP_POINTS

const ilObjStudyProgrammeSettingsGUI::PROP_POINTS = "points"

Definition at line 223 of file class.ilObjStudyProgrammeSettingsGUI.php.

◆ PROP_STATUS

const ilObjStudyProgrammeSettingsGUI::PROP_STATUS = "status"

Definition at line 224 of file class.ilObjStudyProgrammeSettingsGUI.php.

◆ PROP_TITLE

const ilObjStudyProgrammeSettingsGUI::PROP_TITLE = "title"

Definition at line 220 of file class.ilObjStudyProgrammeSettingsGUI.php.

◆ PROP_TYPE

const ilObjStudyProgrammeSettingsGUI::PROP_TYPE = "type"

Definition at line 222 of file class.ilObjStudyProgrammeSettingsGUI.php.


The documentation for this class was generated from the following file: