ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ILIAS\Bibliographic\Field\Table\AssignMaterialsTable Class Reference
+ Collaboration diagram for ILIAS\Bibliographic\Field\Table\AssignMaterialsTable:

Public Member Functions

 __construct (int $top_skill_id, int $tref_id, int $basic_skill_id)
 
 getComponent ()
 

Protected Member Functions

 getColumns ()
 
 getActions ()
 
 getDataRetrieval ()
 

Protected Attributes

ilCtrl $ctrl
 
ilLanguage $lng
 
ilObjUser $user
 
ilWorkspaceTree $ws_tree
 
ilWorkspaceAccessHandler $ws_access
 
UI Factory $ui_fac
 
ServerRequestInterface $request
 
Data Factory $df
 
ilSkillTreeRepository $tree_repo
 
Node SkillTreeNodeManager $node_manager
 
Personal AssignedMaterialManager $assigned_material_manager
 
int $top_skill_id = 0
 
int $tref_id = 0
 
int $basic_skill_id = 0
 

Detailed Description

Author
Thomas Famula famul.nosp@m.a@le.nosp@m.ifos..nosp@m.de

Definition at line 33 of file class.AssignMaterialsTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::__construct ( int  $top_skill_id,
int  $tref_id,
int  $basic_skill_id 
)

Definition at line 50 of file class.AssignMaterialsTable.php.

References ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\$basic_skill_id, $DIC, ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\$top_skill_id, ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\$tref_id, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\getDataRetrieval().

51  {
52  global $DIC;
53 
54  $this->ctrl = $DIC->ctrl();
55  $this->lng = $DIC->language();
56  $this->user = $DIC->user();
57  $this->ui_fac = $DIC->ui()->factory();
58  $this->request = $DIC->http()->request();
59  $this->df = new Data\Factory();
60  $this->ws_tree = new \ilWorkspaceTree($this->user->getId());
61  if (!$this->ws_tree->readRootId()) {
62  $this->ws_tree->createTreeForUser($this->user->getId());
63  }
64  $this->ws_access = new \ilWorkspaceAccessHandler();
65 
66  $this->top_skill_id = $top_skill_id;
67  $this->tref_id = $tref_id;
68  $this->basic_skill_id = $basic_skill_id;
69 
70  $this->tree_repo = $DIC->skills()->internal()->repo()->getTreeRepo();
71  $tree_id = $this->tree_repo->getTreeIdForNodeId($this->basic_skill_id);
72  $this->node_manager = $DIC->skills()->internal()->manager()->getTreeNodeManager($tree_id);
73  $this->assigned_material_manager = $DIC->skills()->internal()->manager()->getAssignedMaterialManager();
74  }
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ getActions()

ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::getActions ( )
protected

Definition at line 111 of file class.AssignMaterialsTable.php.

References ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\$basic_skill_id, ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\$tref_id, ilObject\_lookupTitle(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\getComponent().

111  : array
112  {
113  $query_params_namespace = ["skl_assign_materials_table"];
114 
115  $uri_assign = $this->df->uri(
116  ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTargetByClass(
117  "ilpersonalskillsgui",
118  "assignMaterial"
119  )
120  );
121  $url_builder_assign = new UI\URLBuilder($uri_assign);
122  list($url_builder_assign, $action_parameter_token_assign, $row_id_token_assign) =
123  $url_builder_assign->acquireParameters(
124  $query_params_namespace,
125  "action",
126  "level_ids"
127  );
128 
129  $actions = [
130  "assign" => $this->ui_fac->table()->action()->single(
131  $this->lng->txt("skmg_assign_materials"),
132  $url_builder_assign->withParameter($action_parameter_token_assign, "assignMaterials"),
133  $row_id_token_assign
134  )
135  ];
136 
137  foreach ($this->assigned_material_manager->getAllAssignedMaterialsForSkill(
138  $this->user->getId(),
141  ) as $material) {
142  $obj_id = $this->ws_tree->lookupObjectId($material->getWorkspaceId());
143 
144  $uri_remove = $this->df->uri(
145  ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTargetByClass(
146  "ilpersonalskillsgui",
147  "removeMaterial"
148  )
149  );
150  $url_builder_remove = new UI\URLBuilder($uri_remove);
151  list($url_builder_remove, $action_parameter_token_remove, $row_id_token_remove, $wsp_token_remove) =
152  $url_builder_remove->acquireParameters(
153  $query_params_namespace,
154  "action",
155  "level_ids",
156  "wsp_id"
157  );
158  $url_builder_remove = $url_builder_remove->withParameter($wsp_token_remove, (string) $material->getWorkspaceId());
159 
160  $actions["remove_" . $material->getLevelId() . "_" . $material->getWorkspaceId()] =
161  $this->ui_fac->table()->action()->single(
162  $this->lng->txt("skmg_remove") . " '" . \ilObject::_lookupTitle($obj_id) . "'",
163  $url_builder_remove->withParameter($action_parameter_token_remove, "removeMaterial"),
164  $row_id_token_remove
165  );
166  }
167 
168  return $actions;
169  }
static _lookupTitle(int $obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColumns()

ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::getColumns ( )
protected

Definition at line 97 of file class.AssignMaterialsTable.php.

References ILIAS\Repository\lng().

Referenced by ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\getComponent().

97  : array
98  {
99  $columns = [
100  "title" => $this->ui_fac->table()->column()->text($this->lng->txt("skmg_skill_level"))
101  ->withIsSortable(false),
102  "description" => $this->ui_fac->table()->column()->text($this->lng->txt("description"))
103  ->withIsSortable(false),
104  "resources" => $this->ui_fac->table()->column()->linkListing($this->lng->txt("skmg_materials"))
105  ->withIsSortable(false)
106  ];
107 
108  return $columns;
109  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponent()

ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::getComponent ( )

Definition at line 76 of file class.AssignMaterialsTable.php.

References ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\getActions(), ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\getColumns(), and ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\getDataRetrieval().

76  : UI\Component\Table\Data
77  {
78  $columns = $this->getColumns();
79  $actions = $this->getActions();
80  $data_retrieval = $this->getDataRetrieval();
81 
82  $title = $this->node_manager->getWrittenPath($this->basic_skill_id);
83  $table = $this->ui_fac->table()
84  ->data($title, $columns, $data_retrieval)
85  ->withId(
86  self::class . "_" .
87  $this->top_skill_id . "_" .
88  $this->tref_id . "_" .
89  $this->basic_skill_id
90  )
91  ->withActions($actions)
92  ->withRequest($this->request);
93 
94  return $table;
95  }
+ Here is the call graph for this function:

◆ getDataRetrieval()

ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::getDataRetrieval ( )
protected

Definition at line 171 of file class.AssignMaterialsTable.php.

References ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\$assigned_material_manager, ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\$basic_skill_id, ILIAS\UI\Implementation\Component\Table\$range, ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\$tref_id, ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\$ui_fac, ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\$user, ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\$ws_access, ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\$ws_tree, ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\__construct(), ilObject\_lookupTitle(), ilSkillTreeNodeFactory\getInstance(), and ILIAS\Repository\int().

Referenced by ILIAS\Bibliographic\Field\Table\AssignMaterialsTable\getComponent().

171  : UI\Component\Table\DataRetrieval
172  {
173  $data_retrieval = new class (
176  $this->user,
181  ) implements UI\Component\Table\DataRetrieval {
182  use TableRecords;
183 
184  public function __construct(
185  protected int $basic_skill_id,
186  protected int $tref_id,
187  protected \ilObjUser $user,
188  protected \ilWorkspaceTree $ws_tree,
189  protected Personal\AssignedMaterialManager $assigned_material_manager,
190  protected UI\Factory $ui_fac,
192  ) {
193  }
194 
195  public function getRows(
196  UI\Component\Table\DataRowBuilder $row_builder,
197  array $visible_column_ids,
198  Data\Range $range,
199  Data\Order $order,
200  ?array $filter_data,
201  ?array $additional_parameters
202  ): \Generator {
203  $records = $this->getRecords($range);
204  foreach ($records as $idx => $record) {
205  $row_id = $record["id"];
206  $res_ids = $record["res_ids"];
207 
208  $data_row = $row_builder->buildDataRow((string) $row_id, $record);
209  foreach ($this->assigned_material_manager->getAllAssignedMaterialsForSkill(
210  $this->user->getId(),
213  ) as $material) {
214  if (!in_array($material->getWorkspaceId(), $res_ids) || $row_id != $material->getLevelId()) {
215  $data_row = $data_row->withDisabledAction(
216  "remove_" . $material->getLevelId() . "_" . $material->getWorkspaceId()
217  );
218  }
219  }
220 
221  yield $data_row;
222  }
223  }
224 
225  public function getTotalRowCount(
226  ?array $filter_data,
227  ?array $additional_parameters
228  ): ?int {
229  return count($this->getRecords());
230  }
231 
232  protected function getRecords(Data\Range $range = null): array
233  {
234  $skill = \ilSkillTreeNodeFactory::getInstance($this->basic_skill_id);
235  $records = [];
236  $i = 0;
237  foreach ($skill->getLevelData() as $level) {
238  $records[$i]["id"] = $level["id"];
239  $records[$i]["title"] = $level["title"];
240  $records[$i]["description"] = $level["description"];
241 
242  $materials = $this->assigned_material_manager->getAssignedMaterials(
243  $this->user->getId(),
245  (int) $level["id"]
246  );
247  $wsp_ids = [];
248  $obj_links = [];
249  foreach ($materials as $m) {
250  $wsp_ids[] = $m->getWorkspaceId();
251  $obj_id = $this->ws_tree->lookupObjectId($m->getWorkspaceId());
252  $obj_links[] = $this->ui_fac->link()->standard(
253  \ilObject::_lookupTitle($obj_id),
254  $this->ws_access->getGotoLink($m->getWorkspaceId(), $obj_id)
255  );
256  }
257  $records[$i]["res_ids"] = $wsp_ids;
258  $records[$i]["resources"] = $this->ui_fac->listing()->unordered($obj_links);
259 
260  $i++;
261  }
262 
263  if ($range) {
264  $records = $this->limitRecords($records, $range);
265  }
266 
267  return $records;
268  }
269  };
270 
271  return $data_retrieval;
272  }
__construct(int $top_skill_id, int $tref_id, int $basic_skill_id)
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTitle(int $obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $assigned_material_manager

Personal AssignedMaterialManager ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::$assigned_material_manager
protected

◆ $basic_skill_id

◆ $ctrl

ilCtrl ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::$ctrl
protected

Definition at line 35 of file class.AssignMaterialsTable.php.

◆ $df

Data Factory ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::$df
protected

Definition at line 42 of file class.AssignMaterialsTable.php.

◆ $lng

ilLanguage ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::$lng
protected

Definition at line 36 of file class.AssignMaterialsTable.php.

◆ $node_manager

Node SkillTreeNodeManager ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::$node_manager
protected

Definition at line 44 of file class.AssignMaterialsTable.php.

◆ $request

ServerRequestInterface ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::$request
protected

Definition at line 41 of file class.AssignMaterialsTable.php.

◆ $top_skill_id

int ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::$top_skill_id = 0
protected

◆ $tree_repo

ilSkillTreeRepository ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::$tree_repo
protected

Definition at line 43 of file class.AssignMaterialsTable.php.

◆ $tref_id

◆ $ui_fac

UI Factory ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::$ui_fac
protected

◆ $user

ilObjUser ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::$user
protected

◆ $ws_access

ilWorkspaceAccessHandler ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::$ws_access
protected

◆ $ws_tree

ilWorkspaceTree ILIAS\Bibliographic\Field\Table\AssignMaterialsTable::$ws_tree
protected

The documentation for this class was generated from the following file: