ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCopyWizardPage.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
25
36{
37 private $type;
38 private $source_id;
39 private $obj_id;
40 private $item_type;
41
42 private $tree;
43 private $lng;
45
53 public function __construct($a_source_id, $a_item_type = '')
54 {
55 global $ilObjDataCache,$tree,$lng,$objDefinition;
56
57 $this->source_id = $a_source_id;
58 $this->item_type = $a_item_type;
59 $this->obj_id = $ilObjDataCache->lookupObjId($this->source_id);
60 $this->type = $ilObjDataCache->lookupType($this->obj_id);
61 $this->tree = $tree;
62 $this->lng = $lng;
63 $this->objDefinition = $objDefinition;
64 }
65
74 public function fillTreeSelection($a_ref_id, $a_type, $a_depth)
75 {
76 global $tpl,$ilAccess;
77
78 $this->tpl = $tpl;
79
80 $perm_copy = $ilAccess->checkAccess('copy', '', $a_ref_id);
81 $copy = $this->objDefinition->allowCopy($a_type);
82 $perm_link = $ilAccess->checkAccess('write', '', $a_ref_id);
83 $link = $this->objDefinition->allowLink($a_type);
84
85 // Show radio copy
86 if ($perm_copy and $copy) {
87 $this->tpl->setCurrentBlock('radio_copy');
88 $this->tpl->setVariable('TXT_COPY', $this->lng->txt('copy'));
89 $this->tpl->setVariable('NAME_COPY', 'cp_options[' . $a_ref_id . '][type]');
90 $this->tpl->setVariable('VALUE_COPY', ilCopyWizardOptions::COPY_WIZARD_COPY);
91 $this->tpl->setVariable('ID_COPY', $a_depth . '_' . $a_type . '_' . $a_ref_id . '_copy');
92 $this->tpl->setVariable('COPY_CHECKED', 'checked="checked"');
93 $this->tpl->parseCurrentBlock();
94 } elseif ($copy) {
95 $this->tpl->setCurrentBlock('missing_copy_perm');
96 $this->tpl->setVariable('TXT_MISSING_COPY_PERM', $this->lng->txt('missing_perm'));
97 $this->tpl->parseCurrentBlock();
98 }
99
100 // Show radio link
101 if ($perm_link and $link) {
102 $this->tpl->setCurrentBlock('radio_link');
103 $this->tpl->setVariable('TXT_LINK', $this->lng->txt('link'));
104 $this->tpl->setVariable('NAME_LINK', 'cp_options[' . $a_ref_id . '][type]');
105 $this->tpl->setVariable('VALUE_LINK', ilCopyWizardOptions::COPY_WIZARD_LINK);
106 $this->tpl->setVariable('ID_LINK', $a_depth . '_' . $a_type . '_' . $a_ref_id . '_link');
107 if (!$copy or !$perm_copy) {
108 $this->tpl->setVariable('LINK_CHECKED', 'checked="checked"');
109 }
110 $this->tpl->parseCurrentBlock();
111 } elseif ($link) {
112 $this->tpl->setCurrentBlock('missing_link_perm');
113 $this->tpl->setVariable('TXT_MISSING_LINK_PERM', $this->lng->txt('missing_perm'));
114 $this->tpl->parseCurrentBlock();
115 }
116
117 // Radio omit
118 $this->tpl->setVariable('TXT_OMIT', $this->lng->txt('omit'));
119 $this->tpl->setVariable('NAME_OMIT', 'cp_options[' . $a_ref_id . '][type]');
120 $this->tpl->setVariable('VALUE_OMIT', ilCopyWizardOptions::COPY_WIZARD_OMIT);
121 $this->tpl->setVariable('ID_OMIT', $a_depth . '_' . $a_type . '_' . $a_ref_id . '_omit');
122 if (((!$copy or !$perm_copy) and (!$link or !$perm_link))) {
123 $this->tpl->setVariable('OMIT_CHECKED', 'checked="checked"');
124 }
125 }
126
127
128
135 public function getWizardPageBlockHTML()
136 {
137 $this->readItems();
138
139 if (!count($this->items)) {
140 return '';
141 }
142 }
143
149 protected function fillMainBlock()
150 {
151 if (count($this->items) > 1) {
152 $this->tpl->setCurrentBlock('obj_options');
153 $this->tpl->setVariable('NAME_OPTIONS', $this->lng->txt('omit_all'));
154 $this->tpl->setVariable('JS_FIELD', $this->item_type . '_' . ilCopyWizardOptions::COPY_WIZARD_OMIT);
155 $this->tpl->setVariable('JS_TYPE', $this->item_type . '_omit');
156 $this->tpl->parseCurrentBlock();
157
158 $this->tpl->setCurrentBlock('obj_options');
159 $this->tpl->setVariable('NAME_OPTIONS', $this->lng->txt('copy_all'));
160 $this->tpl->setVariable('OBJ_CHECKED', 'checked="checked"');
161 $this->tpl->setVariable('JS_FIELD', $this->item_type . '_' . ilCopyWizardOptions::COPY_WIZARD_COPY);
162 $this->tpl->setVariable('JS_TYPE', $this->item_type . '_copy');
163 $this->tpl->parseCurrentBlock();
164
165 if ($this->objDefinition->allowLink($this->item_type)) {
166 $this->tpl->setCurrentBlock('obj_options');
167 $this->tpl->setVariable('NAME_OPTIONS', $this->lng->txt('link_all'));
168 $this->tpl->setVariable('JS_FIELD', $this->item_type . '_' . ilCopyWizardOptions::COPY_WIZARD_LINK);
169 $this->tpl->setVariable('JS_TYPE', $this->item_type . '_link');
170 $this->tpl->parseCurrentBlock();
171 }
172 $this->tpl->setVariable('OPTION_CLASS', 'option_value');
173 } else {
174 $this->tpl->setVariable('OPTION_CLASS', 'option');
175 }
176 $this->tpl->setVariable('OBJ_IMG', ilUtil::getImagePath('icon_' . $this->item_type . '.svg'));
177 $this->tpl->setVariable('OBJ_ALT', $this->lng->txt('objs_' . $this->item_type));
178 $this->tpl->setVariable('ROWSPAN', count($this->items) + 1);
179 }
180
186 protected function fillItemBlock()
187 {
188 foreach ($this->items as $node) {
189 $selected = $this->fetchSelected($node['child']);
190
191
192 $this->tpl->setCurrentBlock('item_options');
193 $this->tpl->setVariable('ITEM_CHECK_NAME', 'cp_options[' . $node['child'] . '][type]');
194 $this->tpl->setVariable('ITEM_VALUE', ilCopyWizardOptions::COPY_WIZARD_OMIT);
195 $this->tpl->setVariable('ITEM_NAME_OPTION', $this->lng->txt('omit'));
196 if ($selected == ilCopyWizardOptions::COPY_WIZARD_OMIT) {
197 $this->tpl->setVariable('ITEM_CHECKED', 'checked="checked"');
198 }
199 $this->tpl->setVariable('ITEM_ID', $this->item_type . '_' . ilCopyWizardOptions::COPY_WIZARD_OMIT);
200 $this->tpl->parseCurrentBlock();
201
202
203 if ($this->objDefinition->allowCopy($this->item_type)) {
204 $this->tpl->setCurrentBlock('item_options');
205 if ($selected == ilCopyWizardOptions::COPY_WIZARD_COPY) {
206 $this->tpl->setVariable('ITEM_CHECKED', 'checked="checked"');
207 }
208 $this->tpl->setVariable('ITEM_CHECK_NAME', 'cp_options[' . $node['child'] . '][type]');
209 $this->tpl->setVariable('ITEM_VALUE', ilCopyWizardOptions::COPY_WIZARD_COPY);
210 $this->tpl->setVariable('ITEM_NAME_OPTION', $this->lng->txt('copy'));
211 $this->tpl->setVariable('ITEM_ID', $this->item_type . '_' . ilCopyWizardOptions::COPY_WIZARD_COPY);
212 $this->tpl->parseCurrentBlock();
213 }
214 if ($this->objDefinition->allowLink($this->item_type)) {
215 $this->tpl->setCurrentBlock('item_options');
217 $this->tpl->setVariable('ITEM_CHECKED', 'checked="checked"');
218 }
219 $this->tpl->setVariable('ITEM_CHECK_NAME', 'cp_options[' . $node['child'] . '][type]');
220 $this->tpl->setVariable('ITEM_VALUE', ilCopyWizardOptions::COPY_WIZARD_LINK);
221 $this->tpl->setVariable('ITEM_NAME_OPTION', $this->lng->txt('link'));
222 $this->tpl->setVariable('ITEM_ID', $this->item_type . '_' . ilCopyWizardOptions::COPY_WIZARD_LINK);
223 $this->tpl->parseCurrentBlock();
224 }
225
226
227 $this->tpl->setCurrentBlock('item_row');
228 $this->tpl->setVariable('ITEM_TITLE', $node['title']);
229 $this->tpl->setVariable('DESCRIPTION', $node['description']);
230 $this->tpl->parseCurrentBlock();
231 }
232 }
233
239 protected function fillAdditionalOptions()
240 {
241 }
242
248 protected function readItems()
249 {
250 $nodes = $this->tree->getSubTree($this->tree->getNodeData($this->source_id), true, $this->item_type);
251
252 $this->items = array();
253 switch ($nodes[0]['type']) {
254 case 'fold':
255 case 'grp':
256 case 'crs':
257 case 'cat':
258 foreach ($nodes as $node) {
259 if ($node['child'] != $this->source_id) {
260 $this->items[] = $node;
261 }
262 }
263 break;
264 default:
265 $this->items = $nodes;
266 break;
267 }
268 }
269
275 protected function fetchSelected($a_node_id)
276 {
277 return $_POST['cp_options'][$a_node_id]['type'] ?
278 $_POST['cp_options'][$a_node_id]['type'] :
280 }
281}
$tpl
Definition: ilias.php:10
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
fillMainBlock()
@access protected
__construct($a_source_id, $a_item_type='')
Constructor.
fillTreeSelection($a_ref_id, $a_type, $a_depth)
Fill selection template.
fillAdditionalOptions()
Fill additional options.
fetchSelected($a_node_id)
Check if it is checked.
fillItemBlock()
Fill item block.
getWizardPageBlockHTML()
Get wizard page block html.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$a_type
Definition: workflow.php:92