00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
00025
00035 class ilCopyWizardPage
00036 {
00037 private $type;
00038 private $source_id;
00039 private $obj_id;
00040 private $item_type;
00041
00042 private $tree;
00043 private $lng;
00044 private $objDefinition;
00045
00053 public function __construct($a_source_id,$a_item_type = '')
00054 {
00055 global $ilObjDataCache,$tree,$lng,$objDefinition;
00056
00057 $this->source_id = $a_source_id;
00058 $this->item_type = $a_item_type;
00059 $this->obj_id = $ilObjDataCache->lookupObjId($this->source_id);
00060 $this->type = $ilObjDataCache->lookupType($this->obj_id);
00061 $this->tree = $tree;
00062 $this->lng = $lng;
00063 $this->objDefinition = $objDefinition;
00064 }
00065
00074 public function fillTreeSelection($a_ref_id,$a_type,$a_depth)
00075 {
00076 global $tpl,$ilAccess;
00077
00078 $this->tpl = $tpl;
00079
00080 $perm_copy = $ilAccess->checkAccess('copy','',$a_ref_id);
00081 $copy = $this->objDefinition->allowCopy($a_type);
00082 $perm_link = $ilAccess->checkAccess('write','',$a_ref_id);
00083 $link = $this->objDefinition->allowLink($a_type);
00084
00085
00086 if($perm_copy and $copy)
00087 {
00088 $this->tpl->setCurrentBlock('radio_copy');
00089 $this->tpl->setVariable('TXT_COPY',$this->lng->txt('copy'));
00090 $this->tpl->setVariable('NAME_COPY','cp_options['.$a_ref_id.'][type]');
00091 $this->tpl->setVariable('VALUE_COPY',ilCopyWizardOptions::COPY_WIZARD_COPY);
00092 $this->tpl->setVariable('ID_COPY',$a_depth.'_'.$a_type.'_'.$a_ref_id.'_copy');
00093 $this->tpl->setVariable('COPY_CHECKED','checked="checked"');
00094 $this->tpl->parseCurrentBlock();
00095 }
00096 elseif($copy)
00097 {
00098 $this->tpl->setCurrentBlock('missing_copy_perm');
00099 $this->tpl->setVariable('TXT_MISSING_COPY_PERM',$this->lng->txt('missing_perm'));
00100 $this->tpl->parseCurrentBlock();
00101 }
00102
00103
00104 if($perm_link and $link)
00105 {
00106 $this->tpl->setCurrentBlock('radio_link');
00107 $this->tpl->setVariable('TXT_LINK',$this->lng->txt('link'));
00108 $this->tpl->setVariable('NAME_LINK','cp_options['.$a_ref_id.'][type]');
00109 $this->tpl->setVariable('VALUE_LINK',ilCopyWizardOptions::COPY_WIZARD_LINK);
00110 $this->tpl->setVariable('ID_LINK',$a_depth.'_'.$a_type.'_'.$a_ref_id.'_link');
00111 if(!$copy or !$perm_copy)
00112 {
00113 $this->tpl->setVariable('LINK_CHECKED','checked="checked"');
00114 }
00115 $this->tpl->parseCurrentBlock();
00116 }
00117 elseif($link)
00118 {
00119 $this->tpl->setCurrentBlock('missing_link_perm');
00120 $this->tpl->setVariable('TXT_MISSING_LINK_PERM',$this->lng->txt('missing_perm'));
00121 $this->tpl->parseCurrentBlock();
00122 }
00123
00124
00125 $this->tpl->setVariable('TXT_OMIT',$this->lng->txt('omit'));
00126 $this->tpl->setVariable('NAME_OMIT','cp_options['.$a_ref_id.'][type]');
00127 $this->tpl->setVariable('VALUE_OMIT',ilCopyWizardOptions::COPY_WIZARD_OMIT);
00128 $this->tpl->setVariable('ID_OMIT',$a_depth.'_'.$a_type.'_'.$a_ref_id.'_omit');
00129 if(((!$copy or !$perm_copy) and (!$link or !$perm_link)))
00130 {
00131 $this->tpl->setVariable('OMIT_CHECKED','checked="checked"');
00132 }
00133 }
00134
00135
00136
00143 public function getWizardPageBlockHTML()
00144 {
00145 $this->readItems();
00146
00147 if(!count($this->items))
00148 {
00149 return '';
00150 }
00151 }
00152
00158 protected function initTemplate()
00159 {
00160 $this->tpl = new ilTemplate('tpl.copy_wizard_block.html',true,true,'Services/CopyWizard');
00161 }
00162
00168 protected function fillMainBlock()
00169 {
00170
00171 if(count($this->items) > 1)
00172 {
00173 $this->tpl->setCurrentBlock('obj_options');
00174 $this->tpl->setVariable('NAME_OPTIONS',$this->lng->txt('omit_all'));
00175 $this->tpl->setVariable('JS_FIELD',$this->item_type.'_'.ilCopyWizardOptions::COPY_WIZARD_OMIT);
00176 $this->tpl->setVariable('JS_TYPE',$this->item_type.'_omit');
00177 $this->tpl->parseCurrentBlock();
00178
00179 $this->tpl->setCurrentBlock('obj_options');
00180 $this->tpl->setVariable('NAME_OPTIONS',$this->lng->txt('copy_all'));
00181 $this->tpl->setVariable('OBJ_CHECKED','checked="checked"');
00182 $this->tpl->setVariable('JS_FIELD',$this->item_type.'_'.ilCopyWizardOptions::COPY_WIZARD_COPY);
00183 $this->tpl->setVariable('JS_TYPE',$this->item_type.'_copy');
00184 $this->tpl->parseCurrentBlock();
00185
00186 if($this->objDefinition->allowLink($this->item_type))
00187 {
00188 $this->tpl->setCurrentBlock('obj_options');
00189 $this->tpl->setVariable('NAME_OPTIONS',$this->lng->txt('link_all'));
00190 $this->tpl->setVariable('JS_FIELD',$this->item_type.'_'.ilCopyWizardOptions::COPY_WIZARD_LINK);
00191 $this->tpl->setVariable('JS_TYPE',$this->item_type.'_link');
00192 $this->tpl->parseCurrentBlock();
00193
00194 }
00195 $this->tpl->setVariable('OPTION_CLASS','option_value');
00196 }
00197 else
00198 {
00199 $this->tpl->setVariable('OPTION_CLASS','option');
00200 }
00201 $this->tpl->setVariable('OBJ_IMG',ilUtil::getImagePath('icon_'.$this->item_type.'.gif'));
00202 $this->tpl->setVariable('OBJ_ALT',$this->lng->txt('objs_'.$this->item_type));
00203 $this->tpl->setVariable('ROWSPAN',count($this->items) + 1);
00204 }
00205
00211 protected function fillItemBlock()
00212 {
00213 foreach($this->items as $node)
00214 {
00215 $selected = $this->fetchSelected($node['child']);
00216
00217
00218 $this->tpl->setCurrentBlock('item_options');
00219 $this->tpl->setVariable('ITEM_CHECK_NAME','cp_options['.$node['child'].'][type]');
00220 $this->tpl->setVariable('ITEM_VALUE',ilCopyWizardOptions::COPY_WIZARD_OMIT);
00221 $this->tpl->setVariable('ITEM_NAME_OPTION',$this->lng->txt('omit'));
00222 if($selected == ilCopyWizardOptions::COPY_WIZARD_OMIT)
00223 {
00224 $this->tpl->setVariable('ITEM_CHECKED','checked="checked"');
00225 }
00226 $this->tpl->setVariable('ITEM_ID',$this->item_type.'_'.ilCopyWizardOptions::COPY_WIZARD_OMIT);
00227 $this->tpl->parseCurrentBlock();
00228
00229
00230 if($this->objDefinition->allowCopy($this->item_type))
00231 {
00232 $this->tpl->setCurrentBlock('item_options');
00233 if($selected == ilCopyWizardOptions::COPY_WIZARD_COPY)
00234 {
00235 $this->tpl->setVariable('ITEM_CHECKED','checked="checked"');
00236 }
00237 $this->tpl->setVariable('ITEM_CHECK_NAME','cp_options['.$node['child'].'][type]');
00238 $this->tpl->setVariable('ITEM_VALUE',ilCopyWizardOptions::COPY_WIZARD_COPY);
00239 $this->tpl->setVariable('ITEM_NAME_OPTION',$this->lng->txt('copy'));
00240 $this->tpl->setVariable('ITEM_ID',$this->item_type.'_'.ilCopyWizardOptions::COPY_WIZARD_COPY);
00241 $this->tpl->parseCurrentBlock();
00242 }
00243 if($this->objDefinition->allowLink($this->item_type))
00244 {
00245 $this->tpl->setCurrentBlock('item_options');
00246 if($selected ==ilCopyWizardOptions::COPY_WIZARD_LINK)
00247 {
00248 $this->tpl->setVariable('ITEM_CHECKED','checked="checked"');
00249 }
00250 $this->tpl->setVariable('ITEM_CHECK_NAME','cp_options['.$node['child'].'][type]');
00251 $this->tpl->setVariable('ITEM_VALUE',ilCopyWizardOptions::COPY_WIZARD_LINK);
00252 $this->tpl->setVariable('ITEM_NAME_OPTION',$this->lng->txt('link'));
00253 $this->tpl->setVariable('ITEM_ID',$this->item_type.'_'.ilCopyWizardOptions::COPY_WIZARD_LINK);
00254 $this->tpl->parseCurrentBlock();
00255 }
00256
00257
00258 $this->tpl->setCurrentBlock('item_row');
00259 $this->tpl->setVariable('ITEM_TITLE',$node['title']);
00260 $this->tpl->setVariable('DESCRIPTION',$node['description']);
00261 $this->tpl->parseCurrentBlock();
00262 }
00263 }
00264
00270 protected function fillAdditionalOptions()
00271 {
00272
00273 }
00274
00280 protected function readItems()
00281 {
00282 $nodes = $this->tree->getSubTree($this->tree->getNodeData($this->source_id),true,$this->item_type);
00283
00284 $this->items = array();
00285 switch($nodes[0]['type'])
00286 {
00287 case 'fold':
00288 case 'grp':
00289 case 'crs':
00290 case 'cat':
00291 foreach($nodes as $node)
00292 {
00293 if($node['child'] != $this->source_id)
00294 {
00295 $this->items[] = $node;
00296 }
00297 }
00298 break;
00299 default:
00300 $this->items = $nodes;
00301 break;
00302 }
00303 }
00304
00310 protected function fetchSelected($a_node_id)
00311 {
00312 return $_POST['cp_options'][$a_node_id]['type'] ?
00313 $_POST['cp_options'][$a_node_id]['type'] :
00314 ilCopyWizardOptions::COPY_WIZARD_COPY;
00315 }
00316 }
00317
00318
00319 ?>