3 declare(strict_types=1);
104 $this->toolbar = $ilToolbar;
116 $cmd = $this->ctrl->getCmd();
117 $next_class = $this->ctrl->getNextClass($this);
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);
127 case self::CMD_DELETE:
128 case self::CMD_DELETE_CONFIRMATION:
129 case self::CMD_GET_ASYNC_MODAL:
134 $this->ctrl->redirect($this,
'view');
136 case self::CMD_PROFILE_NOT_PUBLIC:
140 throw new ilException(
"ilObjStudyProgrammeAutoCategoriesGUI: " .
141 "Command not supported: $cmd");
149 protected function view(
bool $profile_not_public =
false)
151 if ($profile_not_public) {
155 $collected_modals = [];
159 $collected_modals[] = $modal;
162 foreach ($this->
getObject()->getAutomaticContentCategories() as $ac) {
163 $ref_id = $ac->getCategoryRefId();
170 $collected_modals[] = $modal;
172 $ac->getCategoryRefId(),
173 $modal->getShowSignal()
178 $this->ui_renderer->render($title),
179 $this->ui_renderer->render($usr),
180 $this->ui_renderer->render($actions)
184 $table->setData(
$data);
186 $this->tpl->setContent(
187 $this->ui_renderer->render($collected_modals)
198 $form->setValuesByPost();
201 $cat_ref_id = $form->getInput(self::F_CATEGORY_REF);
202 $current_ref_id = $form->getInput(self::F_CATEGORY_ORIGINAL_REF);
210 !is_null($current_ref_id) &&
211 $current_ref_id !== $cat_ref_id
213 $ids = [(int) $current_ref_id];
214 $this->
getObject()->deleteAutomaticContentCategories($ids);
218 $this->
getObject()->storeAutomaticContentCategory(
225 $get = $this->request->getQueryParams();
226 $post = $this->request->getParsedBody();
227 $field = self::CHECKBOX_CATEGORY_REF_IDS;
229 $field_ids_in_get = array_key_exists($field, $get);
230 $field_ids_in_post = array_key_exists($field, $post);
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');
240 $this->ctrl->redirect($this, self::CMD_VIEW);
243 $cat_ids = base64_encode($cat_ids);
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);
251 $this->button_factory->standard($this->lng->txt(
'prg_confirm_delete'), $delete),
252 $this->button_factory->standard($this->lng->txt(
'prg_cancel'), $cancel)
255 $message_box = $this->message_box_factory->confirmation($msg)->withButtons($buttons);
257 $this->tpl->setContent($this->ui_renderer->render($message_box));
260 protected function delete()
262 $field = self::CHECKBOX_CATEGORY_REF_IDS;
263 $get = $this->request->getQueryParams();
265 if (!array_key_exists($field, $get)) {
267 $this->ctrl->redirect($this, self::CMD_VIEW);
270 $cat_ids = base64_decode($get[$field]);
271 $cat_ids = explode(
' ', trim($cat_ids));
272 $cat_ids = array_map(
'intval', $cat_ids);
274 $this->
getObject()->deleteAutomaticContentCategories($cat_ids);
276 $msg = $this->lng->txt(
'prg_delete_single_success');
277 if (count($cat_ids) > 1) {
278 $msg = $this->lng->txt(
'prg_delete_success');
281 ilUtil::sendSuccess($msg,
true);
282 $this->ctrl->redirect($this, self::CMD_VIEW);
300 if ($this->
object === null ||
308 protected function getModal($current_ref_id = null)
310 if (!is_null($current_ref_id)) {
311 $this->ctrl->setParameter($this, self::CHECKBOX_CATEGORY_REF_IDS, $current_ref_id);
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(
318 )->withAsyncRenderUrl(
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];
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; });";
338 $modal = $this->ui_factory->modal()->roundtrip(
339 $this->lng->txt(
'modal_categories_title'),
340 $this->ui_factory->legacy($form->getHtml())
341 )->withActionButtons([$submit]);
343 echo $this->ui_renderer->renderAsync($modal);
347 protected function getForm($current_ref_id = null)
351 if (is_null($current_ref_id)) {
352 $current_ref_id =
"";
354 $form->setId(uniqid((
string) $current_ref_id));
356 $form->setFormAction($this->ctrl->getFormAction($this,
"save"));
358 $this->lng->txt(
"category"),
359 self::F_CATEGORY_REF,
363 $cat->getExplorerGUI()->setTypeWhiteList([
"root",
"cat"]);
364 if ($current_ref_id !=
"") {
365 $cat->getExplorerGUI()->setPathOpen($current_ref_id);
366 $cat->setValue($current_ref_id);
368 $cat->getExplorerGUI()->setRootId(ROOT_FOLDER_ID);
369 $cat->getExplorerGUI()->setAjax(
false);
370 $form->addItem($cat);
373 $hi->setValue($current_ref_id);
384 $btn = $this->ui_factory->button()->primary($this->lng->txt(
'add_category'),
'')
385 ->withOnClick($add_cat_signal);
386 $this->toolbar->addComponent($btn);
394 $items[] = $this->ui_factory
396 ->shy($this->lng->txt(
'edit'),
'')
397 ->withOnClick($signal)
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);
404 $items[] = $this->ui_factory
406 ->shy($this->lng->txt(
'delete'), $link)
409 $dd = $this->ui_factory->dropdown()->standard($items);
417 $editor = implode(
' ', [
418 $username[
'firstname'],
419 $username[
'lastname'],
420 '(' . $username[
'login'] .
')' 424 if (!$usr->hasPublicProfile()) {
425 $url = $this->ctrl->getLinkTarget($this, self::CMD_PROFILE_NOT_PUBLIC);
427 return $this->ui_factory->button()->shy($editor,
$url);
438 $this->tree->getPathFull($cat_ref_id)
440 $path = implode(
' > ', $hops);
442 return $this->ui_factory->button()->shy($path,
$url);
static _lookupName($a_user_id)
lookup user name
An entity that renders components to a string output.
setRefId(int $prg_ref_id)
Set ref-id of StudyProgramme before using this GUI.
This class provides processing control methods.
const CHECKBOX_CATEGORY_REF_IDS
static _getStaticLink( $a_ref_id, $a_type='', $a_fallback_goto=true, $append="")
Get static link.
Class ilObjStudyProgrammeAutoCategoriesGUI.
view(bool $profile_not_public=false)
Render.
static _lookupTitle($a_id)
lookup object title
const CMD_GET_ASYNC_MODAL
__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)
getToolbar(Signal $add_cat_signal)
Setup toolbar.
Class ilObjStudyProgrammeAutoCategoriesGUI.
const CMD_PROFILE_NOT_PUBLIC
static getInstanceByRefId($a_ref_id)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
getModal($current_ref_id=null)
const CMD_DELETE_CONFIRMATION
const F_CATEGORY_ORIGINAL_REF
getForm($current_ref_id=null)
save()
Store data from (modal-)form.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
getItemPath(int $cat_ref_id)
getUserRepresentation(int $usr_id)
getItemAction(int $cat_ref_id, Signal $signal)
getObject()
Get current StudyProgramme-object.
withOnLoadCode(\Closure $binder)