ILIAS  release_8 Revision v8.24
class.ilObjectCopySelectionTableGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
27{
28 protected ilObjUser $user;
30 protected ilTree $tree;
32
33 protected string $type;
34
35 public function __construct(?object $parent_class, string $parent_cmd, string $type, string $back_cmd)
36 {
37 global $DIC;
38
39 $this->user = $DIC->user();
40 $this->obj_definition = $DIC["objDefinition"];
41 $this->tree = $DIC->repositoryTree();
42 $this->access = $DIC->access();
43
44 parent::__construct($parent_class, $parent_cmd);
45 $this->type = $type;
46
47 $this->setTitle($this->lng->txt($this->type . '_wizard_page'));
48
49 $this->addColumn($this->lng->txt('title'), '', '55%');
50 $this->addColumn($this->lng->txt('copy'), '', '15%');
51 $this->addColumn($this->lng->txt('link'), '', '15%');
52 $this->addColumn($this->lng->txt('omit'), '', '15%');
53 $this->setEnableHeader(true);
54 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
55 $this->setRowTemplate("tpl.obj_copy_selection_row.html", "Services/Object");
56 $this->setEnableTitle(true);
57 $this->setEnableNumInfo(true);
58 $this->setLimit(999999);
59
60 $this->setFormName('cmd');
61
62 $submit_button_label = $this->lng->txt('obj_' . $this->type . '_duplicate');
63 if ($this->parent_obj->getSubMode() === ilObjectCopyGUI::SUBMODE_CONTENT_ONLY) {
64 $submit_button_label = $this->lng->txt('cntr_adopt_content');
65 }
66 $this->addCommandButton('copyContainerToTargets', $submit_button_label);
67 if ($back_cmd == '') {
68 $this->addCommandButton("cancel", $this->lng->txt('cancel'));
69 } else {
70 $this->addCommandButton($back_cmd, $this->lng->txt('btn_back'));
71 }
72 }
73
74 public function getType(): string
75 {
76 return $this->type;
77 }
78
79 public function parseSource(int $source): void
80 {
81 $first = true;
82 foreach ($this->tree->getSubTree($root = $this->tree->getNodeData($source)) as $node) {
83 if ($node['type'] == 'rolf') {
84 continue;
85 }
86 if (!$this->access->checkAccess('visible', '', (int) $node['child'])) {
87 continue;
88 }
89
90 $r = [];
91 $r['last'] = false;
92 $r['source'] = $first;
93 $r['ref_id'] = $node['child'];
94 $r['depth'] = $node['depth'] - $root['depth'];
95 $r['type'] = $node['type'];
96 $r['title'] = $node['title'];
97 $r['copy'] = $this->obj_definition->allowCopy($node['type']);
98 $r['perm_copy'] = $this->access->checkAccess('copy', '', (int) $node['child']);
99 $r['link'] = $this->obj_definition->allowLink($node['type']);
100 $r['perm_link'] = true;
101
102 if (!trim($r['title']) && $r['type'] == 'sess') {
103 // use session date as title if no object title
104 $app_info = ilSessionAppointment::_lookupAppointment((int) $node["obj_id"]);
105 $r['title'] = ilSessionAppointment::_appointmentToString((int) $app_info['start'], (int) $app_info['end'], (bool) $app_info['fullday']);
106 }
107
108 $rows[] = $r;
109 $first = false;
110 }
111
112 $rows[] = ['last' => true];
113 $this->setData($rows);
114 }
115
116 protected function fillRow(array $set): void
117 {
118 if ($set['last']) {
119 $this->tpl->setCurrentBlock('footer_copy');
120 $this->tpl->setVariable('TXT_COPY_ALL', $this->lng->txt('copy_all'));
121 $this->tpl->parseCurrentBlock();
122 $this->tpl->setCurrentBlock('footer_link');
123 $this->tpl->setVariable('TXT_LINK_ALL', $this->lng->txt('link_all'));
124 $this->tpl->parseCurrentBlock();
125 $this->tpl->setCurrentBlock('footer_omit');
126 $this->tpl->setVariable('TXT_OMIT_ALL', $this->lng->txt('omit_all'));
127 $this->tpl->parseCurrentBlock();
128 return;
129 }
130
131 for ($i = 0; $i < $set['depth']; $i++) {
132 $this->tpl->touchBlock('padding');
133 $this->tpl->touchBlock('end_padding');
134 }
135 $this->tpl->setVariable('TREE_IMG', ilObject::_getIcon(ilObject::_lookupObjId((int) $set['ref_id']), "tiny", $set['type']));
136 $this->tpl->setVariable('TREE_ALT_IMG', $this->lng->txt('obj_' . $set['type']));
137 $this->tpl->setVariable('TREE_TITLE', $set['title']);
138
139 if ($set['source']) {
140 return;
141 }
142
143 // Copy
144 if ($set['perm_copy'] and $set['copy']) {
145 $this->tpl->setCurrentBlock('radio_copy');
146 $this->tpl->setVariable('TXT_COPY', $this->lng->txt('copy'));
147 $this->tpl->setVariable('NAME_COPY', 'cp_options[' . $set['ref_id'] . '][type]');
148 $this->tpl->setVariable('VALUE_COPY', ilCopyWizardOptions::COPY_WIZARD_COPY);
149 $this->tpl->setVariable('ID_COPY', $set['depth'] . '_' . $set['type'] . '_' . $set['ref_id'] . '_copy');
150 $this->tpl->setVariable('COPY_CHECKED', 'checked="checked"');
151 $this->tpl->parseCurrentBlock();
152 } elseif ($set['copy']) {
153 $this->tpl->setCurrentBlock('missing_copy_perm');
154 $this->tpl->setVariable('TXT_MISSING_COPY_PERM', $this->lng->txt('missing_perm'));
155 $this->tpl->parseCurrentBlock();
156 }
157
158 // Link
159 if ($set['perm_link'] and $set['link']) {
160 $this->tpl->setCurrentBlock('radio_link');
161 $this->tpl->setVariable('TXT_LINK', $this->lng->txt('link'));
162 $this->tpl->setVariable('NAME_LINK', 'cp_options[' . $set['ref_id'] . '][type]');
163 $this->tpl->setVariable('VALUE_LINK', ilCopyWizardOptions::COPY_WIZARD_LINK);
164 $this->tpl->setVariable('ID_LINK', $set['depth'] . '_' . $set['type'] . '_' . $set['ref_id'] . '_link');
165 if (!$set['copy'] or !$set['perm_copy']) {
166 $this->tpl->setVariable('LINK_CHECKED', 'checked="checked"');
167 }
168 $this->tpl->parseCurrentBlock();
169 } elseif ($set['link']) {
170 $this->tpl->setCurrentBlock('missing_link_perm');
171 $this->tpl->setVariable('TXT_MISSING_LINK_PERM', $this->lng->txt('missing_perm'));
172 $this->tpl->parseCurrentBlock();
173 }
174
175 // Omit
176 $this->tpl->setCurrentBlock('omit_radio');
177 $this->tpl->setVariable('TXT_OMIT', $this->lng->txt('omit'));
178 $this->tpl->setVariable('NAME_OMIT', 'cp_options[' . $set['ref_id'] . '][type]');
179 $this->tpl->setVariable('VALUE_OMIT', ilCopyWizardOptions::COPY_WIZARD_OMIT);
180 $this->tpl->setVariable('ID_OMIT', $set['depth'] . '_' . $set['type'] . '_' . $set['ref_id'] . '_omit');
181 if ((!$set['copy'] or !$set['perm_copy']) and (!$set['link'])) {
182 $this->tpl->setVariable('OMIT_CHECKED', 'checked="checked"');
183 }
184
185 $this->tpl->parseCurrentBlock();
186 }
187}
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(?object $parent_class, string $parent_cmd, string $type, string $back_cmd)
fillRow(array $set)
Standard Version of Fill Row.
parses the objects.xml it handles the xml-description of all ilias objects
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupObjId(int $ref_id)
static _lookupAppointment(int $a_obj_id)
static _appointmentToString(int $start, int $end, bool $fulltime)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setEnableNumInfo(bool $a_val)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setEnableTitle(bool $a_enabletitle)
setFormName(string $a_name="")
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)
setEnableHeader(bool $a_enableheader)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setData(array $a_data)
Set table data.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$i
Definition: metadata.php:41
$source
Definition: metadata.php:93
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$rows
Definition: xhr_table.php:10