ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjectCopySelectionTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
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, bool $copy_page)
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", "components/ILIAS/ILIASObject");
56 $this->setEnableTitle(true);
57 $this->setEnableNumInfo(true);
58 $this->setLimit(999999);
59
60 $this->addHiddenInput('copy_page', $copy_page ? '1' : '0');
61
62 $this->setFormName('cmd');
63
64 $submit_button_label = $this->lng->txt('obj_' . $this->type . '_duplicate');
65 if ($this->parent_obj->getSubMode() === ilObjectCopyGUI::SUBMODE_CONTENT_ONLY) {
66 $submit_button_label = $this->lng->txt('cntr_adopt_content');
67 }
68 $this->addCommandButton('copyContainerToTargets', $submit_button_label);
69 }
70
71 public function getType(): string
72 {
73 return $this->type;
74 }
75
76 public function parseSource(int $source): void
77 {
78 $first = true;
79 foreach ($this->tree->getSubTree($root = $this->tree->getNodeData($source)) as $node) {
80 if ($node['type'] == 'rolf') {
81 continue;
82 }
83 if (!$this->access->checkAccess('visible', '', (int) $node['child'])) {
84 continue;
85 }
86
87 $r = [];
88 $r['last'] = false;
89 $r['source'] = $first;
90 $r['ref_id'] = $node['child'];
91 $r['depth'] = $node['depth'] - $root['depth'];
92 $r['type'] = $node['type'];
93 $r['title'] = $node['title'];
94 $r['copy'] = $this->obj_definition->allowCopy($node['type']);
95 $r['perm_copy'] = $this->access->checkAccess('copy', '', (int) $node['child']);
96 $r['link'] = $this->obj_definition->allowLink($node['type']);
97 $r['perm_link'] = true;
98
99 if (!trim($r['title']) && $r['type'] == 'sess') {
100 // use session date as title if no object title
101 $app_info = ilSessionAppointment::_lookupAppointment((int) $node["obj_id"]);
102 $r['title'] = ilSessionAppointment::_appointmentToString((int) $app_info['start'], (int) $app_info['end'], (bool) $app_info['fullday']);
103 }
104
105 $rows[] = $r;
106 $first = false;
107 }
108
109 $rows[] = ['last' => true];
110 $this->setData($rows);
111 }
112
113 protected function fillRow(array $set): void
114 {
115 if ($set['last']) {
116 $this->tpl->setCurrentBlock('footer_copy');
117 $this->tpl->setVariable('TXT_COPY_ALL', $this->lng->txt('copy_all'));
118 $this->tpl->parseCurrentBlock();
119 $this->tpl->setCurrentBlock('footer_link');
120 $this->tpl->setVariable('TXT_LINK_ALL', $this->lng->txt('link_all'));
121 $this->tpl->parseCurrentBlock();
122 $this->tpl->setCurrentBlock('footer_omit');
123 $this->tpl->setVariable('TXT_OMIT_ALL', $this->lng->txt('omit_all'));
124 $this->tpl->parseCurrentBlock();
125 return;
126 }
127
128 for ($i = 0; $i < $set['depth']; $i++) {
129 $this->tpl->touchBlock('padding');
130 $this->tpl->touchBlock('end_padding');
131 }
132 $this->tpl->setVariable('TREE_IMG', ilObject::_getIcon(ilObject::_lookupObjId((int) $set['ref_id']), "tiny", $set['type']));
133 $this->tpl->setVariable('TREE_ALT_IMG', $this->lng->txt('obj_' . $set['type']));
134 $this->tpl->setVariable('TREE_TITLE', $set['title']);
135
136 if ($set['source']) {
137 return;
138 }
139
140 // Copy
141 if ($set['perm_copy'] and $set['copy']) {
142 $this->tpl->setCurrentBlock('radio_copy');
143 $this->tpl->setVariable('TXT_COPY', $this->lng->txt('copy'));
144 $this->tpl->setVariable('NAME_COPY', 'cp_options[' . $set['ref_id'] . '][type]');
145 $this->tpl->setVariable('VALUE_COPY', ilCopyWizardOptions::COPY_WIZARD_COPY);
146 $this->tpl->setVariable('ID_COPY', $set['depth'] . '_' . $set['type'] . '_' . $set['ref_id'] . '_copy');
147 $this->tpl->setVariable('COPY_CHECKED', 'checked="checked"');
148 $this->tpl->parseCurrentBlock();
149 } elseif ($set['copy']) {
150 $this->tpl->setCurrentBlock('missing_copy_perm');
151 $this->tpl->setVariable('TXT_MISSING_COPY_PERM', $this->lng->txt('missing_perm'));
152 $this->tpl->parseCurrentBlock();
153 }
154
155 // Link
156 if ($set['perm_link'] and $set['link']) {
157 $this->tpl->setCurrentBlock('radio_link');
158 $this->tpl->setVariable('TXT_LINK', $this->lng->txt('link'));
159 $this->tpl->setVariable('NAME_LINK', 'cp_options[' . $set['ref_id'] . '][type]');
160 $this->tpl->setVariable('VALUE_LINK', ilCopyWizardOptions::COPY_WIZARD_LINK);
161 $this->tpl->setVariable('ID_LINK', $set['depth'] . '_' . $set['type'] . '_' . $set['ref_id'] . '_link');
162 if (!$set['copy'] or !$set['perm_copy']) {
163 $this->tpl->setVariable('LINK_CHECKED', 'checked="checked"');
164 }
165 $this->tpl->parseCurrentBlock();
166 } elseif ($set['link']) {
167 $this->tpl->setCurrentBlock('missing_link_perm');
168 $this->tpl->setVariable('TXT_MISSING_LINK_PERM', $this->lng->txt('missing_perm'));
169 $this->tpl->parseCurrentBlock();
170 }
171
172 // Omit
173 $this->tpl->setCurrentBlock('omit_radio');
174 $this->tpl->setVariable('TXT_OMIT', $this->lng->txt('omit'));
175 $this->tpl->setVariable('NAME_OMIT', 'cp_options[' . $set['ref_id'] . '][type]');
176 $this->tpl->setVariable('VALUE_OMIT', ilCopyWizardOptions::COPY_WIZARD_OMIT);
177 $this->tpl->setVariable('ID_OMIT', $set['depth'] . '_' . $set['type'] . '_' . $set['ref_id'] . '_omit');
178 if ((!$set['copy'] or !$set['perm_copy']) and (!$set['link'])) {
179 $this->tpl->setVariable('OMIT_CHECKED', 'checked="checked"');
180 }
181
182 $this->tpl->parseCurrentBlock();
183 }
184}
User class.
fillRow(array $set)
Standard Version of Fill Row.
__construct(?object $parent_class, string $parent_cmd, string $type, bool $copy_page)
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="")
addHiddenInput(string $a_name, string $a_value)
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.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26