ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilLTIConsumerProviderUsageTableGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
13{
14
18 protected $table;
19
25 public function __construct(ilLTIConsumerAdministrationGUI $a_parent_obj, $a_parent_cmd)
26 {
27 global $DIC; /* @var \ILIAS\DI\Container $DIC */
28
29 $this->setId('usages');
30 parent::__construct($a_parent_obj, $a_parent_cmd);
31
32 //$this->setFormAction($DIC->ctrl()->getFormAction($a_parent_obj, $a_parent_cmd));
33 $this->setRowTemplate('tpl.lti_consume_provider_usage_table_row.html', 'Modules/LTIConsumer');
34
35 $this->setTitle($DIC->language()->txt('tbl_provider_usage_header'));
36 $this->setDescription($DIC->language()->txt('tbl_provider_usage_header_info'));
37 }
38
39 /*
40 public function getTitle()
41 {
42 return $this->title;
43 }
44 */
45 public function init()
46 {
47 parent::determineSelectedColumns();
48 $this->initColumns();
49 }
50
51 protected function initColumns()
52 {
53 global $DIC; /* @var \ILIAS\DI\Container $DIC */
54
55 $this->addColumn($DIC->language()->txt('tbl_lti_prov_icon'), 'icon');
56 $this->addColumn($DIC->language()->txt('tbl_lti_prov_title'), 'title');
57 $this->addColumn($DIC->language()->txt('tbl_lti_prov_usages_trashed'), 'usedByIsTrashed');
58 $this->addColumn($DIC->language()->txt('tbl_lti_prov_used_by'), 'used_by');
59 }
60
61 protected function fillRow($data)
62 {
63 global $DIC; /* @var \ILIAS\DI\Container $DIC */
64 // TITLE
65 $this->tpl->setVariable('TITLE', $data['title']);
66
67 // TRASHED
68 $this->tpl->setCurrentBlock('usages_trashed');
69 $usagesTrashed = $data['usedByIsTrashed'] && $this->isTrashEnabled() ? $DIC->language()->txt('yes') : '';
70 $this->tpl->setVariable('USAGES_TRASHED', $usagesTrashed);
71 $this->tpl->parseCurrentBlock();
72
73 // USED BY
74 $this->tpl->setCurrentBlock('used_by');
75 $tree = $this->buildLinkToUsedBy($data['usedByObjId'], $data['usedByRefId'], (string) $data['usedByTitle'], (bool) $usagesTrashed);
76 $this->tpl->setVariable('TREE_TO_USED_BY', $tree['tree']);
77 $this->tpl->parseCurrentBlock();
78
79 // ICON
80 if ($data['icon']) {
81 $this->tpl->setVariable('ICON_SRC', $data['icon']);
82 $this->tpl->setVariable('ICON_ALT', basename($data['icon']));
83 } else {
84 $icon = ilObject::_getIcon("", "small", "lti");
85 $this->tpl->setVariable('ICON_SRC', $icon);
86 $this->tpl->setVariable('ICON_ALT', 'lti');
87 }
88 }
89
90 protected function buildLinkToUsedBy(int $objId, int $refId, string $title, $trashed)
91 {
92 global $DIC; /* @var \ILIAS\DI\Container $DIC */
93
94 $tree = $DIC->repositoryTree()->getPathFull($refId);
95 $treeNodes = [];
96 foreach ($tree as $node) {
97 $node['title'] = (int) $node['parent'] === 0 ? $DIC->language()->txt('repository') : $node['title'];
98 $treeNodes[] = $trashed === true ? $node['title'] : '<a href="' . ilLink::_getLink($node['ref_id']) . '">' . $node['title'] . '</a>';
99 }
100 $endnode = '<a href="' . ilLink::_getLink($refId) . '">' . $title . '</a>';
101 if ($trashed === true) {
102 $treeNodes[] = $title;
103 }
104
105 return ['endnode' => $endnode, 'tree' => implode(' > ', $treeNodes)];
106 }
107
108 protected static function isTrashEnabled()
109 {
110 global $DIC; /* @var \ILIAS\DI\Container $DIC */
111 return (bool) $DIC->settings()->get('enable_trash', 0);
112 }
113} // EOF class
An exception for terminatinating execution or to throw for unit testing.
buildLinkToUsedBy(int $objId, int $refId, string $title, $trashed)
__construct(ilLTIConsumerAdministrationGUI $a_parent_obj, $a_parent_cmd)
ilLTIConsumerProviderUsageTableGUI constructor.
Class ilTable2GUI.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
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.
setDescription($a_val)
Set description.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46
$objId
Definition: xapitoken.php:41
$refId
Definition: xapitoken.php:42