ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
__construct(ilLTIConsumerAdministrationGUI $a_parent_obj, $a_parent_cmd)
ilLTIConsumerProviderUsageTableGUI constructor.
setDescription($a_val)
Set description.
$objId
Definition: xapitoken.php:39
buildLinkToUsedBy(int $objId, int $refId, string $title, $trashed)
$refId
Definition: xapitoken.php:40
setId($a_val)
Set id.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
global $DIC
Definition: goto.php:24
setRowTemplate($a_template, $a_template_dir="")
Set row template.
__construct(Container $dic, ilPlugin $plugin)
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.