ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilContProfileTableGUI.php
Go to the documentation of this file.
1 <?php
2 
23 
32 {
36  protected $tpl;
37  protected Factory $ui_factory;
43 
44  public function __construct(
45  $a_parent_obj,
46  string $a_parent_cmd,
47  ilContainerGlobalProfiles $a_cont_glb_profiles,
48  ilContainerLocalProfiles $a_cont_lcl_profiles
49  ) {
50  global $DIC;
51 
52  $this->ctrl = $DIC->ctrl();
53  $this->lng = $DIC->language();
54  $this->tpl = $DIC["tpl"];
55  $this->ui_factory = $DIC->ui()->factory();
56  $this->ui_renderer = $DIC->ui()->renderer();
57 
58  $this->container_global_profiles = $a_cont_glb_profiles;
59  $this->container_local_profiles = $a_cont_lcl_profiles;
60  $this->skmg_settings = new ilSkillManagementSettings();
61  $this->profile_service = $DIC->skills()->profile();
62 
63  parent::__construct($a_parent_obj, $a_parent_cmd);
64  $this->setData($this->getProfiles());
65  $this->setTitle($this->lng->txt("cont_skill_profiles"));
66 
67  $this->addColumn("", "", "1", true);
68  $this->addColumn($this->lng->txt("cont_skill_profile"), "", "1");
69  $this->addColumn($this->lng->txt("context"), "", "1");
70  $this->addColumn($this->lng->txt("actions"), "", "1");
71 
72  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
73  $this->setRowTemplate("tpl.cont_profile_row.html", "Services/Container/Skills");
74  $this->setSelectAllCheckbox("id");
75 
76  if ($this->skmg_settings->getLocalAssignmentOfProfiles()) {
77  $this->addMultiCommand("confirmRemoveSelectedGlobalProfiles", $this->lng->txt("remove"));
78  }
79  if ($this->skmg_settings->getAllowLocalProfiles()) {
80  $this->addMultiCommand("confirmDeleteSelectedLocalProfiles", $this->lng->txt("delete"));
81  }
82  }
83 
84  public function getProfiles(): array
85  {
86  $profiles = [];
87  if ($this->skmg_settings->getLocalAssignmentOfProfiles()) {
88  foreach ($this->container_global_profiles->getProfiles() as $gp) {
89  $profiles[$gp["profile_id"]] = [
90  "profile_id" => $gp["profile_id"],
91  "title" => $this->profile_service->lookupTitle($gp["profile_id"])
92  ];
93  }
94  }
95  if ($this->skmg_settings->getAllowLocalProfiles()) {
96  foreach ($this->container_local_profiles->getProfiles() as $lp) {
97  $profiles[$lp["profile_id"]] = [
98  "profile_id" => $lp["profile_id"],
99  "title" => $this->profile_service->lookupTitle($lp["profile_id"])
100  ];
101  }
102  }
103  ksort($profiles);
104 
105  return $profiles;
106  }
107 
108  protected function fillRow(array $a_set): void
109  {
110  $tpl = $this->tpl;
111  $ctrl = $this->ctrl;
112  $lng = $this->lng;
113  $ui_factory = $this->ui_factory;
114  $ui_renderer = $this->ui_renderer;
115 
116  $tpl->setVariable("TITLE", $a_set["title"]);
117  $tpl->setVariable("ID", $a_set["profile_id"]);
118 
119  if ($this->profile_service->lookupRefId($a_set["profile_id"]) > 0) {
120  $tpl->setVariable("CONTEXT", $lng->txt("skmg_context_local"));
121  } else {
122  $tpl->setVariable("CONTEXT", $lng->txt("skmg_context_global"));
123  }
124 
125  $ctrl->setParameter($this->parent_obj, "profile_id", $a_set["profile_id"]);
126  $ctrl->setParameterByClass("ilskillprofilegui", "sprof_id", $a_set["profile_id"]);
127  $ctrl->setParameterByClass("ilskillprofilegui", "local_context", true);
128 
129  if ($this->profile_service->lookupRefId($a_set["profile_id"]) > 0) {
130  $items = [
131  $ui_factory->link()->standard(
132  $lng->txt("edit"),
133  $ctrl->getLinkTargetByClass("ilskillprofilegui", "showLevelsWithLocalContext")
134  ),
135  $ui_factory->link()->standard(
136  $lng->txt("delete"),
137  $ctrl->getLinkTarget($this->parent_obj, "confirmDeleteSingleLocalProfile")
138  )
139  ];
140  } else {
141  $items = [
142  $ui_factory->link()->standard(
143  $lng->txt("remove"),
144  $ctrl->getLinkTarget($this->parent_obj, "confirmRemoveSingleGlobalProfile")
145  )
146  ];
147  }
148 
149  $dropdown = $this->ui_factory->dropdown()->standard($items)->withLabel($lng->txt("actions"));
150  $tpl->setVariable("ACTIONS", $ui_renderer->render($dropdown));
151  }
152 }
setData(array $a_data)
An entity that renders components to a string output.
Definition: Renderer.php:30
link()
description: purpose: > Links are used navigate to other resources or views of the system by clickin...
getLinkTargetByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
render($component, ?Renderer $root=null)
Render given component.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setFormAction(string $a_form_action, bool $a_multipart=false)
ilContainerLocalProfiles $container_local_profiles
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setParameterByClass(string $a_class, string $a_parameter, $a_value)
ilLanguage $lng
global $DIC
Definition: feed.php:28
TableGUI class for competence profiles in containers.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilSkillManagementSettings $skmg_settings
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
ilContainerGlobalProfiles $container_global_profiles
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
__construct(Container $dic, ilPlugin $plugin)
SkillProfileService $profile_service
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
addMultiCommand(string $a_cmd, string $a_text)
__construct( $a_parent_obj, string $a_parent_cmd, ilContainerGlobalProfiles $a_cont_glb_profiles, ilContainerLocalProfiles $a_cont_lcl_profiles)