ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilRecommendedContentRoleTableGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12{
16 protected $ctrl;
17
21 protected $main_tpl;
22
26 protected $tree;
27
31 protected $role_id;
32
36 protected $manager;
37
38 public function __construct(
40 string $a_parent_cmd,
41 int $role_id,
43 ) {
44 global $DIC;
45
46 $this->ctrl = $DIC->ctrl();
47 $this->main_tpl = $DIC->ui()->mainTemplate();
48 $this->tree = $DIC->repositoryTree();
49
50 $this->role_id = $role_id;
51
52 $this->setId('objrolepd');
53
54 parent::__construct($a_parent_obj, $a_parent_cmd);
55
56 $this->setTitle($this->lng->txt('rep_recommended_content') .
57 ', ' . $this->lng->txt("obj_role") . ': ' . ilObjRole::_getTranslation(ilObject::_lookupTitle($this->role_id)));
58
59 $this->addColumn('', '', 1);
60 $this->addColumn($this->lng->txt('title'), 'title');
61 $this->addColumn($this->lng->txt('path'));
62
63 $this->setRowTemplate(
64 "tpl.rec_content_list_role.html",
65 "Services/Repository/RecommendedContent"
66 );
67 $this->setDefaultOrderField('title');
68
69 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
70 $this->addMultiCommand('confirmRemoveItems', $this->lng->txt('remove'));
71 $this->setSelectAllCheckbox('del_desk_item');
72
73 $this->manager = $manager;
74
75 $this->getItems();
76 }
77
81 protected function getItems()
82 {
84
85 $data = array_map(function ($ref_id) use ($tree) {
86 return [
87 "ref_id" => $ref_id,
89 "path" => $this->formatPath($tree->getPathFull($ref_id))
90 ];
91 }, $this->manager->getRecommendationsOfRole($this->role_id));
92
93 $this->setData($data);
94 }
95
100 protected function formatPath(array $a_path_arr) : string
101 {
102 return implode(" &raquo; ", array_column($a_path_arr, "title"));
103 }
104
108 public function fillRow($a_set)
109 {
110 $this->tpl->setVariable("VAL_ID", $a_set["ref_id"]);
111 $this->tpl->setVariable("VAL_TITLE", $a_set["title"]);
112 $this->tpl->setVariable("VAL_PATH", $a_set["path"]);
113 }
114}
An exception for terminatinating execution or to throw for unit testing.
static _getTranslation($a_role_title)
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
Recommended content manager (business logic)
Recommended content configuration for roles.
__construct(ilRecommendedContentRoleConfigGUI $a_parent_obj, string $a_parent_cmd, int $role_id, \ilRecommendedContentManager $manager)
Class ilTable2GUI.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc