ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
24 include_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;
44  private $objDefinition;
45 
53  public function __construct($a_source_id, $a_item_type = '')
54  {
55  global $DIC;
56 
57  $ilObjDataCache = $DIC['ilObjDataCache'];
58  $tree = $DIC['tree'];
59  $lng = $DIC['lng'];
60  $objDefinition = $DIC['objDefinition'];
61 
62  $this->source_id = $a_source_id;
63  $this->item_type = $a_item_type;
64  $this->obj_id = $ilObjDataCache->lookupObjId($this->source_id);
65  $this->type = $ilObjDataCache->lookupType($this->obj_id);
66  $this->tree = $tree;
67  $this->lng = $lng;
68  $this->objDefinition = $objDefinition;
69  }
70 
79  public function fillTreeSelection($a_ref_id, $a_type, $a_depth)
80  {
81  global $DIC;
82 
83  $tpl = $DIC['tpl'];
84  $ilAccess = $DIC['ilAccess'];
85 
86  $this->tpl = $tpl;
87 
88  $perm_copy = $ilAccess->checkAccess('copy', '', $a_ref_id);
89  $copy = $this->objDefinition->allowCopy($a_type);
90  $perm_link = $ilAccess->checkAccess('write', '', $a_ref_id);
91  $link = $this->objDefinition->allowLink($a_type);
92 
93  // Show radio copy
94  if ($perm_copy and $copy) {
95  $this->tpl->setCurrentBlock('radio_copy');
96  $this->tpl->setVariable('TXT_COPY', $this->lng->txt('copy'));
97  $this->tpl->setVariable('NAME_COPY', 'cp_options[' . $a_ref_id . '][type]');
98  $this->tpl->setVariable('VALUE_COPY', ilCopyWizardOptions::COPY_WIZARD_COPY);
99  $this->tpl->setVariable('ID_COPY', $a_depth . '_' . $a_type . '_' . $a_ref_id . '_copy');
100  $this->tpl->setVariable('COPY_CHECKED', 'checked="checked"');
101  $this->tpl->parseCurrentBlock();
102  } elseif ($copy) {
103  $this->tpl->setCurrentBlock('missing_copy_perm');
104  $this->tpl->setVariable('TXT_MISSING_COPY_PERM', $this->lng->txt('missing_perm'));
105  $this->tpl->parseCurrentBlock();
106  }
107 
108  // Show radio link
109  if ($perm_link and $link) {
110  $this->tpl->setCurrentBlock('radio_link');
111  $this->tpl->setVariable('TXT_LINK', $this->lng->txt('link'));
112  $this->tpl->setVariable('NAME_LINK', 'cp_options[' . $a_ref_id . '][type]');
113  $this->tpl->setVariable('VALUE_LINK', ilCopyWizardOptions::COPY_WIZARD_LINK);
114  $this->tpl->setVariable('ID_LINK', $a_depth . '_' . $a_type . '_' . $a_ref_id . '_link');
115  if (!$copy or !$perm_copy) {
116  $this->tpl->setVariable('LINK_CHECKED', 'checked="checked"');
117  }
118  $this->tpl->parseCurrentBlock();
119  } elseif ($link) {
120  $this->tpl->setCurrentBlock('missing_link_perm');
121  $this->tpl->setVariable('TXT_MISSING_LINK_PERM', $this->lng->txt('missing_perm'));
122  $this->tpl->parseCurrentBlock();
123  }
124 
125  // Radio omit
126  $this->tpl->setVariable('TXT_OMIT', $this->lng->txt('omit'));
127  $this->tpl->setVariable('NAME_OMIT', 'cp_options[' . $a_ref_id . '][type]');
128  $this->tpl->setVariable('VALUE_OMIT', ilCopyWizardOptions::COPY_WIZARD_OMIT);
129  $this->tpl->setVariable('ID_OMIT', $a_depth . '_' . $a_type . '_' . $a_ref_id . '_omit');
130  if (((!$copy or !$perm_copy) and (!$link or !$perm_link))) {
131  $this->tpl->setVariable('OMIT_CHECKED', 'checked="checked"');
132  }
133  }
134 
135 
136 
143  public function getWizardPageBlockHTML()
144  {
145  $this->readItems();
146 
147  if (!count($this->items)) {
148  return '';
149  }
150  }
151 
157  protected function fillMainBlock()
158  {
159  if (count($this->items) > 1) {
160  $this->tpl->setCurrentBlock('obj_options');
161  $this->tpl->setVariable('NAME_OPTIONS', $this->lng->txt('omit_all'));
162  $this->tpl->setVariable('JS_FIELD', $this->item_type . '_' . ilCopyWizardOptions::COPY_WIZARD_OMIT);
163  $this->tpl->setVariable('JS_TYPE', $this->item_type . '_omit');
164  $this->tpl->parseCurrentBlock();
165 
166  $this->tpl->setCurrentBlock('obj_options');
167  $this->tpl->setVariable('NAME_OPTIONS', $this->lng->txt('copy_all'));
168  $this->tpl->setVariable('OBJ_CHECKED', 'checked="checked"');
169  $this->tpl->setVariable('JS_FIELD', $this->item_type . '_' . ilCopyWizardOptions::COPY_WIZARD_COPY);
170  $this->tpl->setVariable('JS_TYPE', $this->item_type . '_copy');
171  $this->tpl->parseCurrentBlock();
172 
173  if ($this->objDefinition->allowLink($this->item_type)) {
174  $this->tpl->setCurrentBlock('obj_options');
175  $this->tpl->setVariable('NAME_OPTIONS', $this->lng->txt('link_all'));
176  $this->tpl->setVariable('JS_FIELD', $this->item_type . '_' . ilCopyWizardOptions::COPY_WIZARD_LINK);
177  $this->tpl->setVariable('JS_TYPE', $this->item_type . '_link');
178  $this->tpl->parseCurrentBlock();
179  }
180  $this->tpl->setVariable('OPTION_CLASS', 'option_value');
181  } else {
182  $this->tpl->setVariable('OPTION_CLASS', 'option');
183  }
184  $this->tpl->setVariable('OBJ_IMG', ilUtil::getImagePath('icon_' . $this->item_type . '.svg'));
185  $this->tpl->setVariable('OBJ_ALT', $this->lng->txt('objs_' . $this->item_type));
186  $this->tpl->setVariable('ROWSPAN', count($this->items) + 1);
187  }
188 
194  protected function fillItemBlock()
195  {
196  foreach ($this->items as $node) {
197  $selected = $this->fetchSelected($node['child']);
198 
199 
200  $this->tpl->setCurrentBlock('item_options');
201  $this->tpl->setVariable('ITEM_CHECK_NAME', 'cp_options[' . $node['child'] . '][type]');
202  $this->tpl->setVariable('ITEM_VALUE', ilCopyWizardOptions::COPY_WIZARD_OMIT);
203  $this->tpl->setVariable('ITEM_NAME_OPTION', $this->lng->txt('omit'));
204  if ($selected == ilCopyWizardOptions::COPY_WIZARD_OMIT) {
205  $this->tpl->setVariable('ITEM_CHECKED', 'checked="checked"');
206  }
207  $this->tpl->setVariable('ITEM_ID', $this->item_type . '_' . ilCopyWizardOptions::COPY_WIZARD_OMIT);
208  $this->tpl->parseCurrentBlock();
209 
210 
211  if ($this->objDefinition->allowCopy($this->item_type)) {
212  $this->tpl->setCurrentBlock('item_options');
213  if ($selected == ilCopyWizardOptions::COPY_WIZARD_COPY) {
214  $this->tpl->setVariable('ITEM_CHECKED', 'checked="checked"');
215  }
216  $this->tpl->setVariable('ITEM_CHECK_NAME', 'cp_options[' . $node['child'] . '][type]');
217  $this->tpl->setVariable('ITEM_VALUE', ilCopyWizardOptions::COPY_WIZARD_COPY);
218  $this->tpl->setVariable('ITEM_NAME_OPTION', $this->lng->txt('copy'));
219  $this->tpl->setVariable('ITEM_ID', $this->item_type . '_' . ilCopyWizardOptions::COPY_WIZARD_COPY);
220  $this->tpl->parseCurrentBlock();
221  }
222  if ($this->objDefinition->allowLink($this->item_type)) {
223  $this->tpl->setCurrentBlock('item_options');
224  if ($selected == ilCopyWizardOptions::COPY_WIZARD_LINK) {
225  $this->tpl->setVariable('ITEM_CHECKED', 'checked="checked"');
226  }
227  $this->tpl->setVariable('ITEM_CHECK_NAME', 'cp_options[' . $node['child'] . '][type]');
228  $this->tpl->setVariable('ITEM_VALUE', ilCopyWizardOptions::COPY_WIZARD_LINK);
229  $this->tpl->setVariable('ITEM_NAME_OPTION', $this->lng->txt('link'));
230  $this->tpl->setVariable('ITEM_ID', $this->item_type . '_' . ilCopyWizardOptions::COPY_WIZARD_LINK);
231  $this->tpl->parseCurrentBlock();
232  }
233 
234 
235  $this->tpl->setCurrentBlock('item_row');
236  $this->tpl->setVariable('ITEM_TITLE', $node['title']);
237  $this->tpl->setVariable('DESCRIPTION', $node['description']);
238  $this->tpl->parseCurrentBlock();
239  }
240  }
241 
247  protected function fillAdditionalOptions()
248  {
249  }
250 
256  protected function readItems()
257  {
258  $nodes = $this->tree->getSubTree($this->tree->getNodeData($this->source_id), true, $this->item_type);
259 
260  $this->items = array();
261  switch ($nodes[0]['type']) {
262  case 'fold':
263  case 'grp':
264  case 'crs':
265  case 'cat':
266  foreach ($nodes as $node) {
267  if ($node['child'] != $this->source_id) {
268  $this->items[] = $node;
269  }
270  }
271  break;
272  default:
273  $this->items = $nodes;
274  break;
275  }
276  }
277 
283  protected function fetchSelected($a_node_id)
284  {
285  return $_POST['cp_options'][$a_node_id]['type'] ?
286  $_POST['cp_options'][$a_node_id]['type'] :
288  }
289 }
__construct($a_source_id, $a_item_type='')
Constructor.
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
fetchSelected($a_node_id)
Check if it is checked.
fillAdditionalOptions()
Fill additional options.
getWizardPageBlockHTML()
Get wizard page block html.
$a_type
Definition: workflow.php:92
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
fillItemBlock()
Fill item block.
fillTreeSelection($a_ref_id, $a_type, $a_depth)
Fill selection template.
$_POST["username"]