ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 $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  {
88  $this->tpl->setCurrentBlock('radio_copy');
89  $this->tpl->setVariable('TXT_COPY',$this->lng->txt('copy'));
90  $this->tpl->setVariable('NAME_COPY','cp_options['.$a_ref_id.'][type]');
91  $this->tpl->setVariable('VALUE_COPY',ilCopyWizardOptions::COPY_WIZARD_COPY);
92  $this->tpl->setVariable('ID_COPY',$a_depth.'_'.$a_type.'_'.$a_ref_id.'_copy');
93  $this->tpl->setVariable('COPY_CHECKED','checked="checked"');
94  $this->tpl->parseCurrentBlock();
95  }
96  elseif($copy)
97  {
98  $this->tpl->setCurrentBlock('missing_copy_perm');
99  $this->tpl->setVariable('TXT_MISSING_COPY_PERM',$this->lng->txt('missing_perm'));
100  $this->tpl->parseCurrentBlock();
101  }
102 
103  // Show radio link
104  if($perm_link and $link)
105  {
106  $this->tpl->setCurrentBlock('radio_link');
107  $this->tpl->setVariable('TXT_LINK',$this->lng->txt('link'));
108  $this->tpl->setVariable('NAME_LINK','cp_options['.$a_ref_id.'][type]');
109  $this->tpl->setVariable('VALUE_LINK',ilCopyWizardOptions::COPY_WIZARD_LINK);
110  $this->tpl->setVariable('ID_LINK',$a_depth.'_'.$a_type.'_'.$a_ref_id.'_link');
111  if(!$copy or !$perm_copy)
112  {
113  $this->tpl->setVariable('LINK_CHECKED','checked="checked"');
114  }
115  $this->tpl->parseCurrentBlock();
116  }
117  elseif($link)
118  {
119  $this->tpl->setCurrentBlock('missing_link_perm');
120  $this->tpl->setVariable('TXT_MISSING_LINK_PERM',$this->lng->txt('missing_perm'));
121  $this->tpl->parseCurrentBlock();
122  }
123 
124  // Radio omit
125  $this->tpl->setVariable('TXT_OMIT',$this->lng->txt('omit'));
126  $this->tpl->setVariable('NAME_OMIT','cp_options['.$a_ref_id.'][type]');
127  $this->tpl->setVariable('VALUE_OMIT',ilCopyWizardOptions::COPY_WIZARD_OMIT);
128  $this->tpl->setVariable('ID_OMIT',$a_depth.'_'.$a_type.'_'.$a_ref_id.'_omit');
129  if(((!$copy or !$perm_copy) and (!$link or !$perm_link)))
130  {
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  {
149  return '';
150  }
151  }
152 
158  protected function initTemplate()
159  {
160  $this->tpl = new ilTemplate('tpl.copy_wizard_block.html',true,true,'Services/CopyWizard');
161  }
162 
168  protected function fillMainBlock()
169  {
170 
171  if(count($this->items) > 1)
172  {
173  $this->tpl->setCurrentBlock('obj_options');
174  $this->tpl->setVariable('NAME_OPTIONS',$this->lng->txt('omit_all'));
175  $this->tpl->setVariable('JS_FIELD',$this->item_type.'_'.ilCopyWizardOptions::COPY_WIZARD_OMIT);
176  $this->tpl->setVariable('JS_TYPE',$this->item_type.'_omit');
177  $this->tpl->parseCurrentBlock();
178 
179  $this->tpl->setCurrentBlock('obj_options');
180  $this->tpl->setVariable('NAME_OPTIONS',$this->lng->txt('copy_all'));
181  $this->tpl->setVariable('OBJ_CHECKED','checked="checked"');
182  $this->tpl->setVariable('JS_FIELD',$this->item_type.'_'.ilCopyWizardOptions::COPY_WIZARD_COPY);
183  $this->tpl->setVariable('JS_TYPE',$this->item_type.'_copy');
184  $this->tpl->parseCurrentBlock();
185 
186  if($this->objDefinition->allowLink($this->item_type))
187  {
188  $this->tpl->setCurrentBlock('obj_options');
189  $this->tpl->setVariable('NAME_OPTIONS',$this->lng->txt('link_all'));
190  $this->tpl->setVariable('JS_FIELD',$this->item_type.'_'.ilCopyWizardOptions::COPY_WIZARD_LINK);
191  $this->tpl->setVariable('JS_TYPE',$this->item_type.'_link');
192  $this->tpl->parseCurrentBlock();
193 
194  }
195  $this->tpl->setVariable('OPTION_CLASS','option_value');
196  }
197  else
198  {
199  $this->tpl->setVariable('OPTION_CLASS','option');
200  }
201  $this->tpl->setVariable('OBJ_IMG',ilUtil::getImagePath('icon_'.$this->item_type.'.gif'));
202  $this->tpl->setVariable('OBJ_ALT',$this->lng->txt('objs_'.$this->item_type));
203  $this->tpl->setVariable('ROWSPAN',count($this->items) + 1);
204  }
205 
211  protected function fillItemBlock()
212  {
213  foreach($this->items as $node)
214  {
215  $selected = $this->fetchSelected($node['child']);
216 
217 
218  $this->tpl->setCurrentBlock('item_options');
219  $this->tpl->setVariable('ITEM_CHECK_NAME','cp_options['.$node['child'].'][type]');
220  $this->tpl->setVariable('ITEM_VALUE',ilCopyWizardOptions::COPY_WIZARD_OMIT);
221  $this->tpl->setVariable('ITEM_NAME_OPTION',$this->lng->txt('omit'));
223  {
224  $this->tpl->setVariable('ITEM_CHECKED','checked="checked"');
225  }
226  $this->tpl->setVariable('ITEM_ID',$this->item_type.'_'.ilCopyWizardOptions::COPY_WIZARD_OMIT);
227  $this->tpl->parseCurrentBlock();
228 
229 
230  if($this->objDefinition->allowCopy($this->item_type))
231  {
232  $this->tpl->setCurrentBlock('item_options');
234  {
235  $this->tpl->setVariable('ITEM_CHECKED','checked="checked"');
236  }
237  $this->tpl->setVariable('ITEM_CHECK_NAME','cp_options['.$node['child'].'][type]');
238  $this->tpl->setVariable('ITEM_VALUE',ilCopyWizardOptions::COPY_WIZARD_COPY);
239  $this->tpl->setVariable('ITEM_NAME_OPTION',$this->lng->txt('copy'));
240  $this->tpl->setVariable('ITEM_ID',$this->item_type.'_'.ilCopyWizardOptions::COPY_WIZARD_COPY);
241  $this->tpl->parseCurrentBlock();
242  }
243  if($this->objDefinition->allowLink($this->item_type))
244  {
245  $this->tpl->setCurrentBlock('item_options');
247  {
248  $this->tpl->setVariable('ITEM_CHECKED','checked="checked"');
249  }
250  $this->tpl->setVariable('ITEM_CHECK_NAME','cp_options['.$node['child'].'][type]');
251  $this->tpl->setVariable('ITEM_VALUE',ilCopyWizardOptions::COPY_WIZARD_LINK);
252  $this->tpl->setVariable('ITEM_NAME_OPTION',$this->lng->txt('link'));
253  $this->tpl->setVariable('ITEM_ID',$this->item_type.'_'.ilCopyWizardOptions::COPY_WIZARD_LINK);
254  $this->tpl->parseCurrentBlock();
255  }
256 
257 
258  $this->tpl->setCurrentBlock('item_row');
259  $this->tpl->setVariable('ITEM_TITLE',$node['title']);
260  $this->tpl->setVariable('DESCRIPTION',$node['description']);
261  $this->tpl->parseCurrentBlock();
262  }
263  }
264 
270  protected function fillAdditionalOptions()
271  {
272 
273  }
274 
280  protected function readItems()
281  {
282  $nodes = $this->tree->getSubTree($this->tree->getNodeData($this->source_id),true,$this->item_type);
283 
284  $this->items = array();
285  switch($nodes[0]['type'])
286  {
287  case 'fold':
288  case 'grp':
289  case 'crs':
290  case 'cat':
291  foreach($nodes as $node)
292  {
293  if($node['child'] != $this->source_id)
294  {
295  $this->items[] = $node;
296  }
297  }
298  break;
299  default:
300  $this->items = $nodes;
301  break;
302  }
303  }
304 
310  protected function fetchSelected($a_node_id)
311  {
312  return $_POST['cp_options'][$a_node_id]['type'] ?
313  $_POST['cp_options'][$a_node_id]['type'] :
315  }
316 }
317 
318 
319 ?>