ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjectCopySelectionTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/Table/classes/class.ilTable2GUI.php';
5 include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
6 
14 {
15  private $type = '';
16  private $selected_reference = null;
17 
24  public function __construct($a_parent_class,$a_parent_cmd,$a_type,$a_back_cmd)
25  {
26  global $lng,$ilCtrl,$ilUser,$objDefinition;
27 
28  parent::__construct($a_parent_class,$a_parent_cmd);
29  $this->type = $a_type;
30 
31  $this->lng = $lng;
32  $this->ctrl = $ilCtrl;
33 
34  $this->setTitle($this->lng->txt($this->type.'_wizard_page'));
35 
36 
37  $this->addColumn($this->lng->txt('title'),'','55%');
38  $this->addColumn($this->lng->txt('copy'),'','15%');
39  $this->addColumn($this->lng->txt('link'),'','15%');
40  $this->addColumn($this->lng->txt('omit'),'','15%');
41 
42  $this->setEnableHeader(true);
43  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
44  $this->setRowTemplate("tpl.obj_copy_selection_row.html", "Services/Object");
45  $this->setEnableTitle(true);
46  $this->setEnableNumInfo(true);
47  $this->setLimit(999999);
48 
49  $this->setFormName('cmd');
50 
51  $this->addCommandButton('copyContainer', $this->lng->txt('obj_'.$this->type.'_duplicate'));
52  $this->addCommandButton($a_back_cmd, $this->lng->txt('btn_back'));
53  }
54 
59  public function getType()
60  {
61  return $this->type;
62  }
63 
69  public function parseSource($a_source)
70  {
71  global $tree,$objDefinition, $ilAccess;
72 
73  $first = true;
74  foreach($tree->getSubTree($root = $tree->getNodeData($a_source)) as $node)
75  {
76  if($node['type'] == 'rolf')
77  {
78  continue;
79  }
80  $r = array();
81  $r['last'] = false;
82  $r['source']= $first;
83  $r['ref_id']= $node['child'];
84  $r['depth'] = $node['depth'] - $root['depth'];
85  $r['type'] = $node['type'];
86  $r['title'] = $node['title'];
87  $r['copy'] = $objDefinition->allowCopy($node['type']);
88  $r['perm_copy'] = $ilAccess->checkAccess('copy','',$node['child']);
89  $r['link'] = $objDefinition->allowLink($node['type']);
90  $r['perm_link'] = true;
91 
92  $rows[] = $r;
93 
94  $first = false;
95  }
96  $rows[] = array('last' => true);
97  $this->setData((array) $rows);
98  }
99 
103  protected function fillRow($s)
104  {
105  if($s['last'])
106  {
107  $this->tpl->setCurrentBlock('footer_copy');
108  $this->tpl->setVariable('TXT_COPY_ALL',$this->lng->txt('copy_all'));
109  $this->tpl->parseCurrentBlock();
110  $this->tpl->setCurrentBlock('footer_link');
111  $this->tpl->setVariable('TXT_LINK_ALL',$this->lng->txt('link_all'));
112  $this->tpl->parseCurrentBlock();
113  $this->tpl->setCurrentBlock('footer_omit');
114  $this->tpl->setVariable('TXT_OMIT_ALL',$this->lng->txt('omit_all'));
115  $this->tpl->parseCurrentBlock();
116  return true;
117  }
118 
119 
120  for($i = 0; $i < $s['depth']; $i++)
121  {
122  $this->tpl->touchBlock('padding');
123  $this->tpl->touchBlock('end_padding');
124  }
125  $this->tpl->setVariable('TREE_IMG',ilUtil::getImagePath('icon_'.$s['type'].'_s.gif'));
126  $this->tpl->setVariable('TREE_ALT_IMG',$this->lng->txt('obj_'.$s['type']));
127  $this->tpl->setVariable('TREE_TITLE',$s['title']);
128 
129  if($s['source'])
130  {
131  return true;
132  }
133 
134  // Copy
135  if($s['perm_copy'] and $s['copy'])
136  {
137  $this->tpl->setCurrentBlock('radio_copy');
138  $this->tpl->setVariable('TXT_COPY',$this->lng->txt('copy'));
139  $this->tpl->setVariable('NAME_COPY','cp_options['.$s['ref_id'].'][type]');
140  $this->tpl->setVariable('VALUE_COPY',ilCopyWizardOptions::COPY_WIZARD_COPY);
141  $this->tpl->setVariable('ID_COPY',$s['depth'].'_'.$s['type'].'_'.$s['ref_id'].'_copy');
142  $this->tpl->setVariable('COPY_CHECKED','checked="checked"');
143  $this->tpl->parseCurrentBlock();
144  }
145  elseif($s['copy'])
146  {
147  $this->tpl->setCurrentBlock('missing_copy_perm');
148  $this->tpl->setVariable('TXT_MISSING_COPY_PERM',$this->lng->txt('missing_perm'));
149  $this->tpl->parseCurrentBlock();
150  }
151 
152 
153  // Link
154  if($s['perm_link'] and $s['link'])
155  {
156  $this->tpl->setCurrentBlock('radio_link');
157  $this->tpl->setVariable('TXT_LINK',$this->lng->txt('link'));
158  $this->tpl->setVariable('NAME_LINK','cp_options['.$s['ref_id'].'][type]');
159  $this->tpl->setVariable('VALUE_LINK',ilCopyWizardOptions::COPY_WIZARD_LINK);
160  $this->tpl->setVariable('ID_LINK',$s['depth'].'_'.$s['type'].'_'.$s['ref_id'].'_link');
161  if(!$s['copy'] or !$s['perm_copy'])
162  {
163  $this->tpl->setVariable('LINK_CHECKED','checked="checked"');
164  }
165  $this->tpl->parseCurrentBlock();
166  }
167  elseif($s['link'])
168  {
169  $this->tpl->setCurrentBlock('missing_link_perm');
170  $this->tpl->setVariable('TXT_MISSING_LINK_PERM',$this->lng->txt('missing_perm'));
171  $this->tpl->parseCurrentBlock();
172  }
173 
174  // Omit
175  $this->tpl->setCurrentBlock('omit_radio');
176  $this->tpl->setVariable('TXT_OMIT',$this->lng->txt('omit'));
177  $this->tpl->setVariable('NAME_OMIT','cp_options['.$s['ref_id'].'][type]');
178  $this->tpl->setVariable('VALUE_OMIT',ilCopyWizardOptions::COPY_WIZARD_OMIT);
179  $this->tpl->setVariable('ID_OMIT',$s['depth'].'_'.$s['type'].'_'.$s['ref_id'].'_omit');
180  if((!$s['copy'] or !$s['perm_copy']) and (!$s['link']))
181  {
182  $this->tpl->setVariable('OMIT_CHECKED','checked="checked"');
183  }
184  $this->tpl->parseCurrentBlock();
185 
186  }
187 
188 
189 
190 }
191 ?>