3declare(strict_types=1);
 
    5use GuzzleHttp\Psr7\ServerRequest;
 
  103        $this->ctrl = $ilCtrl;
 
  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);
 
  134                        $this->ctrl->redirect($this, 
'view');
 
  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($link),
 
  179                $this->ui_renderer->render($usr),
 
  180                $this->ui_renderer->render($actions),
 
  185            return strnatcmp(
$a[4], 
$b[4]);
 
  189        $table->setData(
$data);
 
  191        $this->tpl->setContent(
 
  192            $this->ui_renderer->render($collected_modals)
 
  203        $form->setValuesByPost();
 
  206        $cat_ref_id = $form->getInput(self::F_CATEGORY_REF);
 
  207        $current_ref_id = $form->getInput(self::F_CATEGORY_ORIGINAL_REF);
 
  215            !is_null($current_ref_id) &&
 
  216            $current_ref_id !== $cat_ref_id
 
  218            $ids = [(int) $current_ref_id];
 
  219            $this->
getObject()->deleteAutomaticContentCategories($ids);
 
  223        $this->
getObject()->storeAutomaticContentCategory(
 
  230        $get = $this->request->getQueryParams();
 
  231        $post = $this->request->getParsedBody();
 
  234        $field_ids_in_get = array_key_exists($field, $get);
 
  235        $field_ids_in_post = array_key_exists($field, $post);
 
  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');
 
  245            $this->ctrl->redirect($this, self::CMD_VIEW);
 
  248        $cat_ids = base64_encode($cat_ids);
 
  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);
 
  256            $this->button_factory->standard($this->lng->txt(
'prg_confirm_delete'), $delete),
 
  257            $this->button_factory->standard($this->lng->txt(
'prg_cancel'), $cancel)
 
  260        $message_box = $this->message_box_factory->confirmation($msg)->withButtons($buttons);
 
  262        $this->tpl->setContent($this->ui_renderer->render($message_box));
 
  265    protected function delete()
 
  268        $get = $this->request->getQueryParams();
 
  270        if (!array_key_exists($field, $get)) {
 
  272            $this->ctrl->redirect($this, self::CMD_VIEW);
 
  275        $cat_ids = base64_decode($get[$field]);
 
  276        $cat_ids = explode(
' ', trim($cat_ids));
 
  277        $cat_ids = array_map(
'intval', $cat_ids);
 
  279        $this->
getObject()->deleteAutomaticContentCategories($cat_ids);
 
  281        $msg = $this->lng->txt(
'prg_delete_single_success');
 
  282        if (count($cat_ids) > 1) {
 
  283            $msg = $this->lng->txt(
'prg_delete_success');
 
  286        ilUtil::sendSuccess($msg, 
true);
 
  287        $this->ctrl->redirect($this, self::CMD_VIEW);
 
  305        if ($this->
object === 
null ||
 
  306            (
int) $this->object->getRefId() !== $this->prg_ref_id
 
  313    protected function getModal($current_ref_id = 
null)
 
  315        if (!is_null($current_ref_id)) {
 
  316            $this->ctrl->setParameter($this, self::CHECKBOX_CATEGORY_REF_IDS, $current_ref_id);
 
  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(
 
  323        )->withAsyncRenderUrl(
 
  332        $current_ref_id = 
null;
 
  333        if (array_key_exists(self::CHECKBOX_CATEGORY_REF_IDS, 
$_GET)) {
 
  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; });";
 
  343        $modal = $this->ui_factory->modal()->roundtrip(
 
  344            $this->lng->txt(
'modal_categories_title'),
 
  345            $this->ui_factory->legacy($form->getHtml())
 
  346        )->withActionButtons([$submit]);
 
  348        echo $this->ui_renderer->renderAsync($modal);
 
  352    protected function getForm($current_ref_id = 
null)
 
  356        if (is_null($current_ref_id)) {
 
  357            $current_ref_id = 
"";
 
  359        $form->setId(uniqid((
string) $current_ref_id));
 
  361        $form->setFormAction($this->ctrl->getFormAction($this, 
"save"));
 
  363            $this->lng->txt(
"category"),
 
  364            self::F_CATEGORY_REF,
 
  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);
 
  374        $cat->getExplorerGUI()->setAjax(
false);
 
  375        $form->addItem($cat);
 
  378        $hi->setValue($current_ref_id);
 
  389        $btn = $this->ui_factory->button()->primary($this->lng->txt(
'add_category'), 
'')
 
  390                                ->withOnClick($add_cat_signal);
 
  391        $this->toolbar->addComponent($btn);
 
  399        $items[] = $this->ui_factory
 
  401            ->shy($this->lng->txt(
'edit'), 
'')
 
  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);
 
  409        $items[] = $this->ui_factory
 
  411            ->shy($this->lng->txt(
'delete'), $link)
 
  414        $dd = $this->ui_factory->dropdown()->standard($items);
 
  422        $editor = implode(
' ', [
 
  423            $username[
'firstname'],
 
  424            $username[
'lastname'],
 
  425            '(' . $username[
'login'] . 
')' 
  429        if (!$usr->hasPublicProfile()) {
 
  430            $url = $this->ctrl->getLinkTarget($this, self::CMD_PROFILE_NOT_PUBLIC);
 
  432        return $this->ui_factory->button()->shy($editor, 
$url);
 
  443            $this->tree->getPathFull($cat_ref_id)
 
  445        $path = implode(
' > ', $hops);
 
  446        $title = array_pop($hops);
 
  447        return [$title, $this->ui_factory->button()->shy($path, 
$url)];
 
An exception for terminatinating execution or to throw for unit testing.
Builds a Color from either hex- or rgb values.
This class provides processing control methods.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getStaticLink( $a_ref_id, $a_type='', $a_fallback_goto=true, $append="")
Get static link.
Class ilObjStudyProgrammeAutoCategoriesGUI.
getToolbar(Signal $add_cat_signal)
Setup toolbar.
getItemPath(int $cat_ref_id)
save()
Store data from (modal-)form.
getModal($current_ref_id=null)
getItemAction(int $cat_ref_id, Signal $signal)
getObject()
Get current StudyProgramme-object.
view(bool $profile_not_public=false)
Render.
const CHECKBOX_CATEGORY_REF_IDS
const F_CATEGORY_ORIGINAL_REF
__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)
setRefId(int $prg_ref_id)
Set ref-id of StudyProgramme before using this GUI.
getUserRepresentation(int $usr_id)
const CMD_GET_ASYNC_MODAL
const CMD_DELETE_CONFIRMATION
const CMD_PROFILE_NOT_PUBLIC
getForm($current_ref_id=null)
static getInstanceByRefId($a_ref_id)
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
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilObjStudyProgrammeAutoCategoriesGUI.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
This describes a Standard Dropdown.
This is how the factory for UI elements looks.
An entity that renders components to a string output.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples