ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ContSkillMemberTableBuilder.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Container\Skills;
22 
26 
28 {
29  public function __construct(
30  protected SkillInternalManagerService $manager_service,
31  protected ContainerSkillManager $cont_skill_manager,
32  protected \ilContainer $container,
33  object $parent_gui,
34  string $parent_cmd
35  ) {
36  parent::__construct($parent_gui, $parent_cmd, true);
37  }
38 
39  protected function getId(): string
40  {
41  return "cont_skll_mem_" . $this->container->getId();
42  }
43 
44  protected function getTitle(): string
45  {
46  global $DIC;
47  return $DIC->language()->txt("cont_cont_skills");
48  }
49 
50  protected function getRetrieval(): RetrievalInterface
51  {
52  return $this->manager_service->contSkillMemberRetrieval(
53  $this->cont_skill_manager,
54  $this->container
55  );
56  }
57 
58  protected function transformRow(array $data_row): array
59  {
60  global $DIC;
61  $lng = $DIC->language();
62 
63  // Format skills display
64  $skills_display = "";
65  if (!empty($data_row["skills"])) {
66  $skill_texts = [];
68  foreach ($data_row["skills"] as $skill) {
69  $path = $this->parent_gui->getPathString($skill->getBaseSkillId(), $skill->getTrefId());
70  $skill_title = \ilBasicSkill::_lookupTitle($skill->getBaseSkillId(), $skill->getTrefId());
71  $level_title = \ilBasicSkill::lookupLevelTitle($skill->getLevelId());
72 
73  $skill_text = $skill_title . ": " . $level_title;
74  if ($path !== "") {
75  $skill_text .= " (" . $path . ")";
76  }
77  $skill_texts[] = $skill_text;
78  }
79  $skills_display = implode("<br>", $skill_texts);
80  }
81 
82  return [
83  "id" => $data_row["id"],
84  "name" => $data_row["name"],
85  "login" => $data_row["login"],
86  "cont_mem_skills" => $skills_display,
87  "cont_published" => $data_row["published"] ? $lng->txt("yes") : $lng->txt("no"),
88  "published" => $data_row["published"]
89  ];
90  }
91 
92  protected function activeAction(string $action, array $data_row): bool
93  {
94  $container_publish_setting = \ilContainer::_lookupContainerSetting(
95  $this->container->getId(),
96  "cont_skill_publish",
97  '0'
98  );
99 
100  switch ($action) {
101  case "assignCompetences":
102  // Available when not published OR publish setting disabled
103  return !$data_row["published"] || $container_publish_setting === '0';
104  case "publishAssignments":
105  // Available when not published
106  return !$data_row["published"];
107  case "deassignCompetencesConfirm":
108  // Always available
109  return true;
110  }
111  return true;
112  }
113 
115  {
116  global $DIC;
117  $lng = $DIC->language();
118 
119  $table = $table
120  ->textColumn("name", $lng->txt("name"))
121  ->textColumn("login", $lng->txt("login"))
122  ->textColumn("cont_mem_skills", $lng->txt("cont_mem_skills"))
123  ->textColumn("cont_published", $lng->txt("cont_published"));
124 
125  // Add single actions
126  $table = $table
127  ->singleAction("assignCompetences", $lng->txt("cont_assign_competence"))
128  ->standardAction("deassignCompetencesConfirm", $lng->txt("cont_deassign_competence"));
129 
130  // Add multi commands based on container settings
131  $container_publish_setting = \ilContainer::_lookupContainerSetting(
132  $this->container->getId(),
133  "cont_skill_publish",
134  '0'
135  );
136 
137  if ($container_publish_setting === '1') {
138  $table = $table->standardAction("publishAssignments", $lng->txt("cont_publish_assignment"));
139  }
140 
141  return $table;
142  }
143 }
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
static lookupLevelTitle(int $a_id)
textColumn(string $key, string $title, bool $sortable=false)
$path
Definition: ltiservices.php:29
$container
Definition: wac.php:36
transformRow(array $data_row)
transform raw data array to table row data array
global $DIC
Definition: shib_login.php:26
Class ilContainer.
__construct(protected SkillInternalManagerService $manager_service, protected ContainerSkillManager $cont_skill_manager, protected \ilContainer $container, object $parent_gui, string $parent_cmd)
standardAction(string $action, string $title)
__construct(Container $dic, ilPlugin $plugin)
global $lng
Definition: privfeed.php:31
singleAction(string $action, string $title, bool $async=false)
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)