ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilObjStudyProgrammeAutoCategoriesGUI Class Reference

Class ilObjStudyProgrammeAutoCategoriesGUI. More...

+ Collaboration diagram for ilObjStudyProgrammeAutoCategoriesGUI:

Public Member Functions

 __construct (ilGlobalTemplateInterface $tpl, ilCtrl $ilCtrl, ilToolbarGUI $ilToolbar, ilLanguage $lng, Factory $ui_factory, MessageBox\Factory $message_box_factory, Button\Factory $button_factory, Renderer $ui_renderer, ServerRequest $request, ilTree $tree)
 
 executeCommand ()
 
 setRefId (int $prg_ref_id)
 Set ref-id of StudyProgramme before using this GUI. More...
 

Data Fields

const F_CATEGORY_REF = 'f_cr'
 
const F_CATEGORY_ORIGINAL_REF = 'f_cr_org'
 
const CHECKBOX_CATEGORY_REF_IDS = 'c_catids'
 
const CMD_VIEW = 'view'
 
const CMD_SAVE = 'save'
 
const CMD_GET_ASYNC_MODAL = 'getAsyncModalOutput'
 
const CMD_DELETE = 'delete'
 
const CMD_DELETE_CONFIRMATION = 'deleteConfirmation'
 
const CMD_PROFILE_NOT_PUBLIC = 'profile_not_public'
 
 $tpl
 
 $ctrl
 
 $toolbar
 
 $lng
 
 $prg_ref_id
 
 $object
 
 $ui_factory
 
 $ui_renderer
 

Protected Member Functions

 view (bool $profile_not_public=false)
 Render. More...
 
 save ()
 Store data from (modal-)form. More...
 
 deleteConfirmation ()
 
 delete ()
 
 getObject ()
 Get current StudyProgramme-object. More...
 
 getModal ($current_ref_id=null)
 
 getAsyncModalOutput ()
 
 getForm ($current_ref_id=null)
 
 getToolbar (Signal $add_cat_signal)
 Setup toolbar. More...
 
 getItemAction (int $cat_ref_id, Signal $signal)
 
 getUserRepresentation (int $usr_id)
 
 getItemPath (int $cat_ref_id)
 

Protected Attributes

 $message_box_factory
 
 $button_factory
 
 $request
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjStudyProgrammeAutoCategoriesGUI::__construct ( ilGlobalTemplateInterface  $tpl,
ilCtrl  $ilCtrl,
ilToolbarGUI  $ilToolbar,
ilLanguage  $lng,
Factory  $ui_factory,
MessageBox\Factory  $message_box_factory,
Button\Factory  $button_factory,
Renderer  $ui_renderer,
ServerRequest  $request,
ilTree  $tree 
)

Member Function Documentation

◆ delete()

ilObjStudyProgrammeAutoCategoriesGUI::delete ( )
protected

Definition at line 260 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

261 {
263 $get = $this->request->getQueryParams();
264
265 if (!array_key_exists($field, $get)) {
266 ilUtil::sendFailure($this->lng->txt('prg_delete_failure'), true);
267 $this->ctrl->redirect($this, self::CMD_VIEW);
268 }
269
270 $cat_ids = base64_decode($get[$field]);
271 $cat_ids = explode(' ', trim($cat_ids));
272 $cat_ids = array_map('intval', $cat_ids);
273
274 $this->getObject()->deleteAutomaticContentCategories($cat_ids);
275
276 $msg = $this->lng->txt('prg_delete_single_success');
277 if (count($cat_ids) > 1) {
278 $msg = $this->lng->txt('prg_delete_success');
279 }
280
281 ilUtil::sendSuccess($msg, true);
282 $this->ctrl->redirect($this, self::CMD_VIEW);
283 }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References CHECKBOX_CATEGORY_REF_IDS, getObject(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ deleteConfirmation()

ilObjStudyProgrammeAutoCategoriesGUI::deleteConfirmation ( )
protected

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

224 {
225 $get = $this->request->getQueryParams();
226 $post = $this->request->getParsedBody();
228
229 $field_ids_in_get = array_key_exists($field, $get);
230 $field_ids_in_post = array_key_exists($field, $post);
231
232 if ($field_ids_in_get) {
233 $cat_ids = $get[$field];
234 $msg = $this->lng->txt('prg_delete_single_confirmation');
235 } elseif ($field_ids_in_post) {
236 $cat_ids = implode(' ', $post[$field]);
237 $msg = $this->lng->txt('prg_delete_confirmation');
238 } else {
239 ilUtil::sendInfo($this->lng->txt('prg_delete_nothing_selected'), true);
240 $this->ctrl->redirect($this, self::CMD_VIEW);
241 }
242
243 $cat_ids = base64_encode($cat_ids);
244
245 $this->ctrl->setParameterByClass(self::class, $field, $cat_ids);
246 $delete = $this->ctrl->getFormActionByClass(self::class, self::CMD_DELETE);
247 $cancel = $this->ctrl->getFormActionByClass(self::class, self::CMD_VIEW);
248 $this->ctrl->clearParameterByClass(self::class, $field);
249
250 $buttons = [
251 $this->button_factory->standard($this->lng->txt('prg_confirm_delete'), $delete),
252 $this->button_factory->standard($this->lng->txt('prg_cancel'), $cancel)
253 ];
254
255 $message_box = $this->message_box_factory->confirmation($msg)->withButtons($buttons);
256
257 $this->tpl->setContent($this->ui_renderer->render($message_box));
258 }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References CHECKBOX_CATEGORY_REF_IDS, and ilUtil\sendInfo().

+ Here is the call graph for this function:

◆ executeCommand()

ilObjStudyProgrammeAutoCategoriesGUI::executeCommand ( )

Definition at line 114 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

115 {
116 $cmd = $this->ctrl->getCmd();
117 $next_class = $this->ctrl->getNextClass($this);
118
119 switch ($next_class) {
120 case "ilpropertyformgui":
121 $form = $this->getForm($this->creation_mode ? self::MODE_CREATE : self::MODE_EDIT);
122 $this->ctrl->forwardCommand($form);
123 break;
124 default:
125 switch ($cmd) {
126 case self::CMD_VIEW:
127 case self::CMD_DELETE:
130 $this->$cmd();
131 break;
132 case self::CMD_SAVE:
133 $this->$cmd();
134 $this->ctrl->redirect($this, 'view');
135 break;
137 $this->view(true);
138 break;
139 default:
140 throw new ilException("ilObjStudyProgrammeAutoCategoriesGUI: " .
141 "Command not supported: $cmd");
142 }
143 }
144 }
Base class for ILIAS Exception handling.

References CMD_DELETE, CMD_DELETE_CONFIRMATION, CMD_GET_ASYNC_MODAL, CMD_PROFILE_NOT_PUBLIC, CMD_SAVE, CMD_VIEW, getForm(), and view().

+ Here is the call graph for this function:

◆ getAsyncModalOutput()

ilObjStudyProgrammeAutoCategoriesGUI::getAsyncModalOutput ( )
protected

Definition at line 325 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

326 {
327 $current_ref_id = null;
328 if (array_key_exists(self::CHECKBOX_CATEGORY_REF_IDS, $_GET)) {
329 $current_ref_id = $_GET[self::CHECKBOX_CATEGORY_REF_IDS];
330 }
331 $form = $this->getForm($current_ref_id);
332 $form_id = "form_" . $form->getId();
333 $submit = $this->ui_factory->button()->primary($this->lng->txt('search'), "#")->withOnLoadCode(
334 function ($id) use ($form_id) {
335 return "$('#{$id}').click(function() { $('#{$form_id}').submit(); return false; });";
336 }
337 );
338 $modal = $this->ui_factory->modal()->roundtrip(
339 $this->lng->txt('modal_categories_title'),
340 $this->ui_factory->legacy($form->getHtml())
341 )->withActionButtons([$submit]);
342
343 echo $this->ui_renderer->renderAsync($modal);
344 exit;
345 }
$_GET["client_id"]
exit
Definition: login.php:29

References $_GET, CHECKBOX_CATEGORY_REF_IDS, exit, and getForm().

+ Here is the call graph for this function:

◆ getForm()

ilObjStudyProgrammeAutoCategoriesGUI::getForm (   $current_ref_id = null)
protected

Definition at line 347 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

348 {
349 $form = new ilPropertyFormGUI();
350
351 if (is_null($current_ref_id)) {
352 $current_ref_id = "";
353 }
354 $form->setId(uniqid((string) $current_ref_id));
355
356 $form->setFormAction($this->ctrl->getFormAction($this, "save"));
358 $this->lng->txt("category"),
359 self::F_CATEGORY_REF,
360 false
361 );
362 $cat->getExplorerGUI()->setSelectableTypes(["cat"]);
363 $cat->getExplorerGUI()->setTypeWhiteList(["root", "cat"]);
364 if ($current_ref_id != "") {
365 $cat->getExplorerGUI()->setPathOpen($current_ref_id);
366 $cat->setValue($current_ref_id);
367 }
368 $cat->getExplorerGUI()->setRootId(ROOT_FOLDER_ID);
369 $cat->getExplorerGUI()->setAjax(false);
370 $form->addItem($cat);
371
372 $hi = new ilHiddenInputGUI(self::F_CATEGORY_ORIGINAL_REF);
373 $hi->setValue($current_ref_id);
374 $form->addItem($hi);
375
376 return $form;
377 }
This class represents a hidden form property in a property form.
This class represents a property form user interface.

Referenced by executeCommand(), getAsyncModalOutput(), and save().

+ Here is the caller graph for this function:

◆ getItemAction()

ilObjStudyProgrammeAutoCategoriesGUI::getItemAction ( int  $cat_ref_id,
Signal  $signal 
)
protected

Definition at line 389 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

392 : Standard {
393 $items = [];
394 $items[] = $this->ui_factory
395 ->button()
396 ->shy($this->lng->txt('edit'), '')
397 ->withOnClick($signal)
398 ;
399
400 $this->ctrl->setParameterByClass(self::class, self::CHECKBOX_CATEGORY_REF_IDS, $cat_ref_id);
401 $link = $this->ctrl->getLinkTarget($this, self::CMD_DELETE_CONFIRMATION);
402 $this->ctrl->clearParameterByClass(self::class, self::CHECKBOX_CATEGORY_REF_IDS);
403
404 $items[] = $this->ui_factory
405 ->button()
406 ->shy($this->lng->txt('delete'), $link)
407 ;
408
409 $dd = $this->ui_factory->dropdown()->standard($items);
410
411 return $dd;
412 }
withOnClick(Signal $signal)
@inheritdocs
This describes a standard button.
Definition: Standard.php:13

Referenced by view().

+ Here is the caller graph for this function:

◆ getItemPath()

ilObjStudyProgrammeAutoCategoriesGUI::getItemPath ( int  $cat_ref_id)
protected

Definition at line 430 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

430 : Shy
431 {
432 $url = ilLink::_getStaticLink($cat_ref_id, 'cat');
433
434 $hops = array_map(
435 function ($c) {
436 return ilObject::_lookupTitle($c["obj_id"]);
437 },
438 $this->tree->getPathFull($cat_ref_id)
439 );
440 $path = implode(' > ', $hops);
441
442 return $this->ui_factory->button()->shy($path, $url);
443 }
static _lookupTitle($a_id)
lookup object title
$url

References Vendor\Package\$c, $url, ilLink\_getStaticLink(), and ilObject\_lookupTitle().

Referenced by view().

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

◆ getModal()

ilObjStudyProgrammeAutoCategoriesGUI::getModal (   $current_ref_id = null)
protected

Definition at line 308 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

309 {
310 if (!is_null($current_ref_id)) {
311 $this->ctrl->setParameter($this, self::CHECKBOX_CATEGORY_REF_IDS, $current_ref_id);
312 }
313 $link = $this->ctrl->getLinkTarget($this, "getAsyncModalOutput", "", true);
314 $this->ctrl->setParameter($this, self::CHECKBOX_CATEGORY_REF_IDS, null);
315 $modal = $this->ui_factory->modal()->roundtrip(
316 '',
317 []
318 )->withAsyncRenderUrl(
319 $link
320 );
321
322 return $modal;
323 }

Referenced by view().

+ Here is the caller graph for this function:

◆ getObject()

ilObjStudyProgrammeAutoCategoriesGUI::getObject ( )
protected

Get current StudyProgramme-object.

Returns
ilObjStudyProgramme

Definition at line 298 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

299 {
300 if ($this->object === null ||
301 (int) $this->object->getRefId() !== $this->prg_ref_id
302 ) {
303 $this->object = ilObjStudyProgramme::getInstanceByRefId($this->prg_ref_id);
304 }
305 return $this->object;
306 }
static getInstanceByRefId($a_ref_id)

References $object, and ilObjStudyProgramme\getInstanceByRefId().

Referenced by delete(), save(), and view().

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

◆ getToolbar()

ilObjStudyProgrammeAutoCategoriesGUI::getToolbar ( Signal  $add_cat_signal)
protected

Setup toolbar.

Definition at line 382 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

383 {
384 $btn = $this->ui_factory->button()->primary($this->lng->txt('add_category'), '')
385 ->withOnClick($add_cat_signal);
386 $this->toolbar->addComponent($btn);
387 }

Referenced by view().

+ Here is the caller graph for this function:

◆ getUserRepresentation()

ilObjStudyProgrammeAutoCategoriesGUI::getUserRepresentation ( int  $usr_id)
protected

Definition at line 414 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

414 : Shy
415 {
416 $username = ilObjUser::_lookupName($usr_id);
417 $editor = implode(' ', [
418 $username['firstname'],
419 $username['lastname'],
420 '(' . $username['login'] . ')'
421 ]);
423 $url = ilLink::_getStaticLink($usr_id, 'usr');
424 if (!$usr->hasPublicProfile()) {
425 $url = $this->ctrl->getLinkTarget($this, self::CMD_PROFILE_NOT_PUBLIC);
426 }
427 return $this->ui_factory->button()->shy($editor, $url);
428 }
static _lookupName($a_user_id)
lookup user name
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id

References $url, ilLink\_getStaticLink(), ilObjUser\_lookupName(), and ilObjectFactory\getInstanceByObjId().

Referenced by view().

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

◆ save()

ilObjStudyProgrammeAutoCategoriesGUI::save ( )
protected

Store data from (modal-)form.

Definition at line 195 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

196 {
197 $form = $this->getForm();
198 $form->setValuesByPost();
199 $form->checkInput();
200
201 $cat_ref_id = $form->getInput(self::F_CATEGORY_REF);
202 $current_ref_id = $form->getInput(self::F_CATEGORY_ORIGINAL_REF);
203
204 if (ilObject::_lookupType((int) $cat_ref_id, true) !== 'cat') {
205 \ilUtil::sendFailure(sprintf($this->lng->txt('not_a_valid_cat_id'), $cat_ref_id), true);
206 return;
207 }
208
209 if (
210 !is_null($current_ref_id) &&
211 $current_ref_id !== $cat_ref_id
212 ) {
213 $ids = [(int) $current_ref_id];
214 $this->getObject()->deleteAutomaticContentCategories($ids);
215 }
216
217
218 $this->getObject()->storeAutomaticContentCategory(
219 (int) $cat_ref_id
220 );
221 }
static _lookupType($a_id, $a_reference=false)
lookup object type

References ilObject\_lookupType(), getForm(), getObject(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ setRefId()

ilObjStudyProgrammeAutoCategoriesGUI::setRefId ( int  $prg_ref_id)

Set ref-id of StudyProgramme before using this GUI.

Parameters
int$prg_ref_id

Definition at line 289 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

References $prg_ref_id.

◆ view()

ilObjStudyProgrammeAutoCategoriesGUI::view ( bool  $profile_not_public = false)
protected

Render.

Definition at line 149 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

150 {
151 if ($profile_not_public) {
152 ilUtil::sendInfo($this->lng->txt('prg_profile_not_public'));
153 }
154
155 $collected_modals = [];
156
157 $modal = $this->getModal();
158 $this->getToolbar($modal->getShowSignal());
159 $collected_modals[] = $modal;
160
161 $data = [];
162 foreach ($this->getObject()->getAutomaticContentCategories() as $ac) {
163 $ref_id = $ac->getCategoryRefId();
164 if (ilObject::_lookupType($ref_id, true) !== 'cat' || $this->tree->isDeleted($ref_id)) {
165 continue;
166 }
167 $title = $this->getItemPath($ref_id);
168 $usr = $this->getUserRepresentation($ac->getLastEditorId());
169 $modal = $this->getModal($ref_id);
170 $collected_modals[] = $modal;
171 $actions = $this->getItemAction(
172 $ac->getCategoryRefId(),
173 $modal->getShowSignal()
174 );
175
176 $data[] = [
177 $ac,
178 $this->ui_renderer->render($title),
179 $this->ui_renderer->render($usr),
180 $this->ui_renderer->render($actions)
181 ];
182 }
183 $table = new ilStudyProgrammeAutoCategoriesTableGUI($this, "view", "");
184 $table->setData($data);
185
186 $this->tpl->setContent(
187 $this->ui_renderer->render($collected_modals)
188 . $table->getHTML()
189 );
190 }
$data
Definition: storeScorm.php:23

References $data, ilObject\_lookupType(), getItemAction(), getItemPath(), getModal(), getObject(), getToolbar(), getUserRepresentation(), and ilUtil\sendInfo().

Referenced by executeCommand().

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

Field Documentation

◆ $button_factory

ilObjStudyProgrammeAutoCategoriesGUI::$button_factory
protected

Definition at line 72 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by __construct().

◆ $ctrl

ilObjStudyProgrammeAutoCategoriesGUI::$ctrl

◆ $lng

ilObjStudyProgrammeAutoCategoriesGUI::$lng

Definition at line 52 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by __construct().

◆ $message_box_factory

ilObjStudyProgrammeAutoCategoriesGUI::$message_box_factory
protected

Definition at line 67 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by __construct().

◆ $object

ilObjStudyProgrammeAutoCategoriesGUI::$object

Definition at line 62 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by getObject().

◆ $prg_ref_id

ilObjStudyProgrammeAutoCategoriesGUI::$prg_ref_id

Definition at line 57 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by setRefId().

◆ $request

ilObjStudyProgrammeAutoCategoriesGUI::$request
protected

Definition at line 87 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by __construct().

◆ $toolbar

ilObjStudyProgrammeAutoCategoriesGUI::$toolbar

◆ $tpl

ilObjStudyProgrammeAutoCategoriesGUI::$tpl

Definition at line 37 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by __construct().

◆ $ui_factory

ilObjStudyProgrammeAutoCategoriesGUI::$ui_factory

Definition at line 77 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by __construct().

◆ $ui_renderer

ilObjStudyProgrammeAutoCategoriesGUI::$ui_renderer

Definition at line 82 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by __construct().

◆ CHECKBOX_CATEGORY_REF_IDS

const ilObjStudyProgrammeAutoCategoriesGUI::CHECKBOX_CATEGORY_REF_IDS = 'c_catids'

◆ CMD_DELETE

const ilObjStudyProgrammeAutoCategoriesGUI::CMD_DELETE = 'delete'

Definition at line 30 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by executeCommand().

◆ CMD_DELETE_CONFIRMATION

const ilObjStudyProgrammeAutoCategoriesGUI::CMD_DELETE_CONFIRMATION = 'deleteConfirmation'

Definition at line 31 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by executeCommand().

◆ CMD_GET_ASYNC_MODAL

const ilObjStudyProgrammeAutoCategoriesGUI::CMD_GET_ASYNC_MODAL = 'getAsyncModalOutput'

Definition at line 29 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by executeCommand().

◆ CMD_PROFILE_NOT_PUBLIC

const ilObjStudyProgrammeAutoCategoriesGUI::CMD_PROFILE_NOT_PUBLIC = 'profile_not_public'

Definition at line 32 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by executeCommand().

◆ CMD_SAVE

const ilObjStudyProgrammeAutoCategoriesGUI::CMD_SAVE = 'save'

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

Referenced by executeCommand().

◆ CMD_VIEW

const ilObjStudyProgrammeAutoCategoriesGUI::CMD_VIEW = 'view'

Definition at line 27 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by executeCommand().

◆ F_CATEGORY_ORIGINAL_REF

const ilObjStudyProgrammeAutoCategoriesGUI::F_CATEGORY_ORIGINAL_REF = 'f_cr_org'

◆ F_CATEGORY_REF

const ilObjStudyProgrammeAutoCategoriesGUI::F_CATEGORY_REF = 'f_cr'

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