ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 265 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

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

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

◆ deleteConfirmation()

ilObjStudyProgrammeAutoCategoriesGUI::deleteConfirmation ( )
protected

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

References ilUtil\sendInfo().

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

◆ executeCommand()

ilObjStudyProgrammeAutoCategoriesGUI::executeCommand ( )

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

References getForm(), and view().

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:
128  case self::CMD_DELETE_CONFIRMATION:
129  case self::CMD_GET_ASYNC_MODAL:
130  $this->$cmd();
131  break;
132  case self::CMD_SAVE:
133  $this->$cmd();
134  $this->ctrl->redirect($this, 'view');
135  break;
136  case self::CMD_PROFILE_NOT_PUBLIC:
137  $this->view(true);
138  break;
139  default:
140  throw new ilException("ilObjStudyProgrammeAutoCategoriesGUI: " .
141  "Command not supported: $cmd");
142  }
143  }
144  }
+ Here is the call graph for this function:

◆ getAsyncModalOutput()

ilObjStudyProgrammeAutoCategoriesGUI::getAsyncModalOutput ( )
protected

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

References $_GET, exit, getForm(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

331  {
332  $current_ref_id = null;
333  if (array_key_exists(self::CHECKBOX_CATEGORY_REF_IDS, $_GET)) {
334  $current_ref_id = $_GET[self::CHECKBOX_CATEGORY_REF_IDS];
335  }
336  $form = $this->getForm($current_ref_id);
337  $form_id = "form_" . $form->getId();
338  $submit = $this->ui_factory->button()->primary($this->lng->txt('add'), "#")->withOnLoadCode(
339  function ($id) use ($form_id) {
340  return "$('#{$id}').click(function() { $('#{$form_id}').submit(); return false; });";
341  }
342  );
343  $modal = $this->ui_factory->modal()->roundtrip(
344  $this->lng->txt('modal_categories_title'),
345  $this->ui_factory->legacy($form->getHtml())
346  )->withActionButtons([$submit]);
347 
348  echo $this->ui_renderer->renderAsync($modal);
349  exit;
350  }
exit
Definition: login.php:29
$_GET["client_id"]
+ Here is the call graph for this function:

◆ getForm()

ilObjStudyProgrammeAutoCategoriesGUI::getForm (   $current_ref_id = null)
protected

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

References ilRepositorySelector2InputGUI\getExplorerGUI(), and ROOT_FOLDER_ID.

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

353  {
354  $form = new ilPropertyFormGUI();
355 
356  if (is_null($current_ref_id)) {
357  $current_ref_id = "";
358  }
359  $form->setId(uniqid((string) $current_ref_id));
360 
361  $form->setFormAction($this->ctrl->getFormAction($this, "save"));
363  $this->lng->txt("category"),
364  self::F_CATEGORY_REF,
365  false
366  );
367  $cat->getExplorerGUI()->setSelectableTypes(["cat"]);
368  $cat->getExplorerGUI()->setTypeWhiteList(["root", "cat"]);
369  if ($current_ref_id != "") {
370  $cat->getExplorerGUI()->setPathOpen($current_ref_id);
371  $cat->setValue($current_ref_id);
372  }
373  $cat->getExplorerGUI()->setRootId(ROOT_FOLDER_ID);
374  $cat->getExplorerGUI()->setAjax(false);
375  $form->addItem($cat);
376 
377  $hi = new ilHiddenInputGUI(self::F_CATEGORY_ORIGINAL_REF);
378  $hi->setValue($current_ref_id);
379  $form->addItem($hi);
380 
381  return $form;
382  }
This class represents a property form user interface.
const ROOT_FOLDER_ID
Definition: constants.php:30
This class represents a hidden form property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getItemAction()

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

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

Referenced by view().

397  : Standard {
398  $items = [];
399  $items[] = $this->ui_factory
400  ->button()
401  ->shy($this->lng->txt('edit'), '')
402  ->withOnClick($signal)
403  ;
404 
405  $this->ctrl->setParameterByClass(self::class, self::CHECKBOX_CATEGORY_REF_IDS, $cat_ref_id);
406  $link = $this->ctrl->getLinkTarget($this, self::CMD_DELETE_CONFIRMATION);
407  $this->ctrl->clearParameterByClass(self::class, self::CHECKBOX_CATEGORY_REF_IDS);
408 
409  $items[] = $this->ui_factory
410  ->button()
411  ->shy($this->lng->txt('delete'), $link)
412  ;
413 
414  $dd = $this->ui_factory->dropdown()->standard($items);
415 
416  return $dd;
417  }
This describes a standard button.
Definition: Standard.php:12
+ Here is the caller graph for this function:

◆ getItemPath()

ilObjStudyProgrammeAutoCategoriesGUI::getItemPath ( int  $cat_ref_id)
protected

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

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

Referenced by view().

435  : array
436  {
437  $url = ilLink::_getStaticLink($cat_ref_id, 'cat');
438 
439  $hops = array_map(
440  function ($c) {
441  return ilObject::_lookupTitle($c["obj_id"]);
442  },
443  $this->tree->getPathFull($cat_ref_id)
444  );
445  $path = implode(' > ', $hops);
446  $title = array_pop($hops);
447  return [$title, $this->ui_factory->button()->shy($path, $url)];
448  }
$c
Definition: cli.php:37
static _lookupTitle($a_id)
lookup object title
$url
+ 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 313 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by view().

314  {
315  if (!is_null($current_ref_id)) {
316  $this->ctrl->setParameter($this, self::CHECKBOX_CATEGORY_REF_IDS, $current_ref_id);
317  }
318  $link = $this->ctrl->getLinkTarget($this, "getAsyncModalOutput", "", true);
319  $this->ctrl->setParameter($this, self::CHECKBOX_CATEGORY_REF_IDS, null);
320  $modal = $this->ui_factory->modal()->roundtrip(
321  '',
322  []
323  )->withAsyncRenderUrl(
324  $link
325  );
326 
327  return $modal;
328  }
+ Here is the caller graph for this function:

◆ getObject()

ilObjStudyProgrammeAutoCategoriesGUI::getObject ( )
protected

Get current StudyProgramme-object.

Returns
ilObjStudyProgramme

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

References $object, $prg_ref_id, and ilObjStudyProgramme\getInstanceByRefId().

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

304  {
305  if ($this->object === null ||
306  (int) $this->object->getRefId() !== $this->prg_ref_id
307  ) {
308  $this->object = ilObjStudyProgramme::getInstanceByRefId($this->prg_ref_id);
309  }
310  return $this->object;
311  }
static getInstanceByRefId($a_ref_id)
+ 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 387 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

Referenced by view().

388  {
389  $btn = $this->ui_factory->button()->primary($this->lng->txt('add_category'), '')
390  ->withOnClick($add_cat_signal);
391  $this->toolbar->addComponent($btn);
392  }
+ Here is the caller graph for this function:

◆ getUserRepresentation()

ilObjStudyProgrammeAutoCategoriesGUI::getUserRepresentation ( int  $usr_id)
protected

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

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

Referenced by view().

419  : Shy
420  {
421  $username = ilObjUser::_lookupName($usr_id);
422  $editor = implode(' ', [
423  $username['firstname'],
424  $username['lastname'],
425  '(' . $username['login'] . ')'
426  ]);
427  $usr = ilObjectFactory::getInstanceByObjId($usr_id);
428  $url = ilLink::_getStaticLink($usr_id, 'usr');
429  if (!$usr->hasPublicProfile()) {
430  $url = $this->ctrl->getLinkTarget($this, self::CMD_PROFILE_NOT_PUBLIC);
431  }
432  return $this->ui_factory->button()->shy($editor, $url);
433  }
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
$url
+ 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 200 of file class.ilObjStudyProgrammeAutoCategoriesGUI.php.

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

201  {
202  $form = $this->getForm();
203  $form->setValuesByPost();
204  $form->checkInput();
205 
206  $cat_ref_id = $form->getInput(self::F_CATEGORY_REF);
207  $current_ref_id = $form->getInput(self::F_CATEGORY_ORIGINAL_REF);
208 
209  if (ilObject::_lookupType((int) $cat_ref_id, true) !== 'cat') {
210  \ilUtil::sendFailure(sprintf($this->lng->txt('not_a_valid_cat_id'), $cat_ref_id), true);
211  return;
212  }
213 
214  if (
215  !is_null($current_ref_id) &&
216  $current_ref_id !== $cat_ref_id
217  ) {
218  $ids = [(int) $current_ref_id];
219  $this->getObject()->deleteAutomaticContentCategories($ids);
220  }
221 
222 
223  $this->getObject()->storeAutomaticContentCategory(
224  (int) $cat_ref_id
225  );
226  }
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ 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 294 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.

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

Referenced by executeCommand().

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  list($title, $link) = $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($link),
179  $this->ui_renderer->render($usr),
180  $this->ui_renderer->render($actions),
181  $title
182  ];
183  }
184  usort($data, function ($a, $b) {
185  return strnatcmp($a[4], $b[4]);
186  });
187 
188  $table = new ilStudyProgrammeAutoCategoriesTableGUI($this, "view", "");
189  $table->setData($data);
190 
191  $this->tpl->setContent(
192  $this->ui_renderer->render($collected_modals)
193  . $table->getHTML()
194  );
195  }
$data
Definition: storeScorm.php:23
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static _lookupType($a_id, $a_reference=false)
lookup object type
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ 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 getObject(), and 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'

◆ CMD_DELETE_CONFIRMATION

const ilObjStudyProgrammeAutoCategoriesGUI::CMD_DELETE_CONFIRMATION = 'deleteConfirmation'

◆ CMD_GET_ASYNC_MODAL

const ilObjStudyProgrammeAutoCategoriesGUI::CMD_GET_ASYNC_MODAL = 'getAsyncModalOutput'

◆ CMD_PROFILE_NOT_PUBLIC

const ilObjStudyProgrammeAutoCategoriesGUI::CMD_PROFILE_NOT_PUBLIC = 'profile_not_public'

◆ CMD_SAVE

const ilObjStudyProgrammeAutoCategoriesGUI::CMD_SAVE = 'save'

◆ CMD_VIEW

const ilObjStudyProgrammeAutoCategoriesGUI::CMD_VIEW = 'view'

◆ 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: