ILIAS  release_8 Revision v8.24
class.ilMDCopyrightTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 protected bool $has_write;
29
30 public function __construct(ilObjMDSettingsGUI $a_parent_obj, string $a_parent_cmd = '', bool $a_has_write = false)
31 {
32 $this->has_write = $a_has_write;
33
34 parent::__construct($a_parent_obj, $a_parent_cmd);
35
36 if ($this->has_write) {
37 $this->addColumn('', 'f', '1');
38 $this->addColumn($this->lng->txt("position"), "order");
39 $this->addCommandButton("saveCopyrightPosition", $this->lng->txt("meta_save_order"));
40 }
41 $this->addColumn($this->lng->txt('title'), 'title', "30%");
42 $this->addColumn($this->lng->txt('md_used'), 'used', "5%");
43 $this->addColumn($this->lng->txt('md_copyright_preview'), 'preview', "50%");
44 $this->addColumn($this->lng->txt('meta_copyright_status'), 'status', "10%");
45
46 if ($this->has_write) {
47 $this->addColumn('', 'edit', "10%");
48 }
49
50 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
51 $this->setRowTemplate("tpl.show_copyright_row.html", "Services/MetaData");
52 $this->setDefaultOrderField("order");
53 $this->setDefaultOrderDirection("asc");
54 }
55
56 protected function fillRow(array $a_set): void
57 {
58 if ($this->has_write) {
59 if ($a_set['default']) {
60 $this->tpl->setVariable('DISABLED', "disabled");
61 }
62 $this->tpl->setVariable('VAL_ID', $a_set['id']);
63
64 // order
65 $this->tpl->setCurrentBlock('order_by_position');
66 if ($a_set['default']) {
67 $this->tpl->setVariable('ORDER_DISABLED', 'disabled="disabled"');
68 }
69 $this->tpl->setVariable('ORDER_ID', $a_set['id']);
70 $this->tpl->setVariable('ORDER_VALUE', $a_set['position']);
71 $this->tpl->parseCurrentBlock();
72 }
73 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
74 if ($a_set['description'] !== '') {
75 $this->tpl->setVariable('VAL_DESCRIPTION', $a_set['description']);
76 }
77 $this->tpl->setVariable('VAL_USAGE', $a_set['used']);
78 $this->tpl->setVariable('VAL_PREVIEW', $a_set['preview']);
79
80 $status = [];
81 if ($a_set['status']) {
82 $status[] = $this->lng->txt('meta_copyright_outdated');
83 } else {
84 $status[] = $this->lng->txt('meta_copyright_in_use');
85 }
86 if ($a_set['default']) {
87 $status[] = $this->lng->txt('md_copyright_default');
88 }
89
90 $this->tpl->setVariable('VAL_STATUS', implode(', ', $status));
91
92 if ($this->has_write) {
93 $this->ctrl->setParameter($this->getParentObject(), 'entry_id', $a_set['id']);
94 $this->tpl->setVariable('EDIT_LINK', $this->ctrl->getLinkTarget($this->getParentObject(), 'editEntry'));
95 $this->ctrl->clearParameters($this->getParentObject());
96
97 $this->tpl->setVariable('TXT_EDIT', $this->lng->txt('edit'));
98
99 if ((int) $a_set['used'] > 0) {
100 $this->tpl->setCurrentBlock("link_usage");
101
102 // direct redirection to ...UsageGUI
103 $this->ctrl->setParameterByClass(
104 'ilMDCopyrightUsageGUI',
105 'entry_id',
106 $a_set['id']
107 );
108 $this->tpl->setVariable(
109 'USAGE_LINK',
110 $this->ctrl->getLinkTargetByClass(
111 'ilMDCopyrightUsageGUI',
112 ''
113 )
114 );
115 $this->tpl->setVariable('TXT_USAGE', $this->lng->txt('meta_copyright_show_usages'));
116 $this->tpl->parseCurrentBlock();
117 }
118 }
119 }
120
121 public function parseSelections(): void
122 {
123 // These entries are ordered by 1. is_default, 2. position
125
126 $position = -10;
127 $entry_arr = [];
128 foreach ($entries as $entry) {
129 $tmp_arr['id'] = $entry->getEntryId();
130 $tmp_arr['title'] = $entry->getTitle();
131 $tmp_arr['description'] = $entry->getDescription();
132 $tmp_arr['used'] = $entry->getUsage();
133 $tmp_arr['preview'] = $entry->getCopyright();
134 $tmp_arr['default'] = $entry->getIsDefault();
135 $tmp_arr['status'] = $entry->getOutdated();
136 $tmp_arr['position'] = ($position += 10);
137
138 $entry_arr[] = $tmp_arr;
139 }
140
141 $this->setData($entry_arr);
142 }
143}
__construct(ilObjMDSettingsGUI $a_parent_obj, string $a_parent_cmd='', bool $a_has_write=false)
fillRow(array $a_set)
Standard Version of Fill Row.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc