ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjLinkResourceGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once "./Services/Object/classes/class.ilObject2GUI.php";
6 include_once('./Modules/WebResource/classes/class.ilParameterAppender.php');
7 require_once 'Services/LinkChecker/interfaces/interface.ilLinkCheckerGUIRowHandling.php';
8 
23 {
24  const VIEW_MODE_VIEW = 1;
25  const VIEW_MODE_MANAGE = 2;
26  const VIEW_MODE_SORT = 3;
27 
28  const LINK_MOD_CREATE = 1;
29  const LINK_MOD_EDIT = 2;
30  const LINK_MOD_ADD = 3;
31 
32  function getType()
33  {
34  return "webr";
35  }
36 
37  public function executeCommand()
38  {
39  global $ilCtrl, $ilTabs, $ilErr, $ilAccess;
40 
41 
42  //if($this->ctrl->getTargetScript() == 'link_resources.php')
43  if($_GET["baseClass"] == 'ilLinkResourceHandlerGUI')
44  {
45  $_GET['view_mode'] = isset($_GET['switch_mode']) ? $_GET['switch_mode'] : $_GET['view_mode'];
46  $ilCtrl->saveParameter($this, 'view_mode');
47  $this->__prepareOutput();
48  }
49 
50  $this->lng->loadLanguageModule("webr");
51 
52  $next_class = $this->ctrl->getNextClass($this);
53  $cmd = $this->ctrl->getCmd();
54 
55  switch($next_class)
56  {
57  case "ilinfoscreengui":
58  $this->infoScreenForward(); // forwards command
59  break;
60 
61  case 'ilmdeditorgui':
62  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
63  {
64  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
65  }
66 
67  $this->prepareOutput();
68  $ilTabs->activateTab('id_meta_data');
69  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
70  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
71  $md_gui->addObserver($this->object,'MDUpdateListener','General');
72  $this->ctrl->forwardCommand($md_gui);
73  break;
74 
75  case 'ilpermissiongui':
76  $this->prepareOutput();
77  $ilTabs->activateTab('id_permissions');
78  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
79  $perm_gui =& new ilPermissionGUI($this);
80  $ret =& $this->ctrl->forwardCommand($perm_gui);
81  break;
82 
83  case 'ilobjectcopygui':
84  $this->prepareOutput();
85  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
86  $cp = new ilObjectCopyGUI($this);
87  $cp->setType('webr');
88  $this->ctrl->forwardCommand($cp);
89  break;
90 
91  case 'ilexportgui':
92  $this->prepareOutput();
93  $this->tabs_gui->setTabActive('export');
94  include_once './Services/Export/classes/class.ilExportGUI.php';
95  $exp = new ilExportGUI($this);
96  $exp->addFormat('xml');
97  $this->ctrl->forwardCommand($exp);
98  break;
99 
100  case "ilcommonactiondispatchergui":
101  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
103  $this->ctrl->forwardCommand($gui);
104  break;
105 
106  case "ilpropertyformgui":
107  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
108  $this->initFormLink(self::LINK_MOD_EDIT);
109  $this->ctrl->forwardCommand($this->form);
110  break;
111 
112  case "ilinternallinkgui":
113  $this->lng->loadLanguageModule("content");
114  require_once("./Modules/LearningModule/classes/class.ilInternalLinkGUI.php");
115  $link_gui = new ilInternalLinkGUI("RepositoryItem", 0);
116  $link_gui->filterLinkType("PageObject");
117  $link_gui->filterLinkType("GlossaryItem");
118  $link_gui->filterLinkType("RepositoryItem");
119  $link_gui->setFilterWhiteList(true);
120  $link_gui->setMode("asynch");
121  $ilCtrl->forwardCommand($link_gui);
122  break;
123 
124  default:
125  if(!$cmd)
126  {
127  $this->ctrl->setCmd("view");
128  }
130  }
131 
132  if(!$this->getCreationMode())
133  {
134  // Fill meta header tags
135  include_once('Services/MetaData/classes/class.ilMDUtils.php');
136  ilMDUtils::_fillHTMLMetaTags($this->object->getId(),$this->object->getId(),'webr');
137 
138  $this->addHeaderAction();
139  }
140  return true;
141  }
142 
143  protected function initCreateForm($a_new_type)
144  {
145  $this->initFormLink(self::LINK_MOD_CREATE);
146  return $this->form;
147  }
148 
153  public function save()
154  {
155  global $ilCtrl;
156 
157  $this->initFormLink(self::LINK_MOD_CREATE);
158  if($this->checkLinkInput(self::LINK_MOD_CREATE,0,0))
159  {
160  // Save new object
161  $_POST['title'] = $_POST['tit'];
162  $_POST['desc'] = $_POST['des'];
163  parent::save();
164  }
165  else
166  {
167  // Data incomplete or invalid
168  ilUtil::sendFailure($this->lng->txt('err_check_input'));
169  $this->form->setValuesByPost();
170  $this->tpl->setContent($this->form->getHTML());
171  }
172  }
173 
174  protected function afterSave(ilObject $a_new_object)
175  {
176  // Save link
177  $this->link->setLinkResourceId($a_new_object->getId());
178  $link_id = $this->link->add();
179  $this->link->updateValid(true);
180 
181  ilUtil::sendSuccess($this->lng->txt('webr_link_added'));
182 
183  // personal workspace
184  if($this->id_type == self::WORKSPACE_NODE_ID)
185  {
186  $this->ctrl->redirect($this, "editLinks");
187  }
188  // repository
189  else
190  {
191  ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=".
192  $a_new_object->getRefId()."&cmd=switchViewMode&switch_mode=2");
193  }
194  }
195 
201  protected function settings()
202  {
203  global $ilTabs;
204 
205  $this->checkPermission('write');
206  $ilTabs->activateTab('id_settings');
207 
208  $this->initFormSettings();
209  $this->tpl->setContent($this->form->getHTML());
210  }
211 
216  protected function saveSettings()
217  {
218  global $ilTabs;
219 
220  $this->checkPermission('write');
221  $ilTabs->activateTab('id_settings');
222 
223  $this->initFormSettings();
224  if($this->form->checkInput())
225  {
226  $this->object->setTitle($this->form->getInput('tit'));
227  $this->object->setDescription($this->form->getInput('des'));
228  $this->object->update();
229 
230  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
231  $sort = new ilContainerSortingSettings($this->object->getId());
232  $sort->setSortMode($this->form->getInput('sor'));
233  $sort->update();
234 
235  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
236  $this->ctrl->redirect($this,'settings');
237  }
238 
239  $this->form->setValuesByPost();
240  ilUtil::sendFailure($this->lng->txt('err_check_input'));
241  $this->tpl->setContent($this->form->getHTML());
242  }
243 
244 
249  protected function initFormSettings()
250  {
251  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
252  $this->form = new ilPropertyFormGUI();
253  $this->form->setFormAction($this->ctrl->getFormAction($this,'saveSettings'));
254  $this->form->setTitle($this->lng->txt('webr_edit_settings'));
255 
256  // Title
257  $tit = new ilTextInputGUI($this->lng->txt('webr_list_title'),'tit');
258  $tit->setValue($this->object->getTitle());
259  $tit->setRequired(true);
260  $tit->setSize(40);
261  $tit->setMaxLength(127);
262  $this->form->addItem($tit);
263 
264  // Description
265  $des = new ilTextAreaInputGUI($this->lng->txt('webr_list_desc'),'des');
266  $des->setValue($this->object->getDescription());
267  $des->setCols(40);
268  $des->setRows(3);
269  $this->form->addItem($des);
270 
271  // Sorting
272  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
273  include_once './Services/Container/classes/class.ilContainer.php';
274 
275  $sor = new ilRadioGroupInputGUI($this->lng->txt('webr_sorting'),'sor');
276  $sor->setRequired(true);
277  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
278  $sor->setValue(ilContainerSortingSettings::_lookupSortMode($this->object->getId()));
279 
280  $opt = new ilRadioOption(
281  $this->lng->txt('webr_sort_title'),
283  );
284  $sor->addOption($opt);
285 
286  $opm = new ilRadioOption(
287  $this->lng->txt('webr_sort_manual'),
289  );
290  $sor->addOption($opm);
291  $this->form->addItem($sor);
292 
293  $this->form->addCommandButton('saveSettings', $this->lng->txt('save'));
294  $this->form->addCommandButton('view', $this->lng->txt('cancel'));
295  }
296 
297 
302  public function editLink()
303  {
304  global $ilCtrl;
305 
306  $this->checkPermission('write');
307  $this->activateTabs('content','id_content_view');
308 
309  if(!(int) $_GET['link_id'])
310  {
311  ilUtil::sendFailure($this->lng->txt('select_one'),true);
312  $ilCtrl->redirect($this,'view');
313  }
314 
315  $this->initFormLink(self::LINK_MOD_EDIT);
316  $this->setValuesFromLink((int) $_GET['link_id']);
317  $this->tpl->setContent($this->form->getHTML());
318  }
319 
324  public function updateLink()
325  {
326  global $ilCtrl;
327 
328  $this->initFormLink(self::LINK_MOD_EDIT);
329  if($this->checkLinkInput(self::LINK_MOD_EDIT,$this->object->getId(),(int) $_REQUEST['link_id']))
330  {
331  $this->link->setLinkId((int) $_REQUEST['link_id']);
332  $this->link->update();
333  if(ilParameterAppender::_isEnabled() and is_object($this->dynamic))
334  {
335  $this->dynamic->add((int) $_REQUEST['link_id']);
336  }
337 
338  if($this->isContainerMetaDataRequired())
339  {
340  $this->object->setTitle($this->form->getInput('tit'));
341  $this->object->setDescription($this->form->getInput('des'));
342  $this->object->update();
343  }
344 
345  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
346  $ilCtrl->redirect($this,'view');
347  }
348  ilUtil::sendFailure($this->lng->txt('err_check_input'));
349  $this->form->setValuesByPost();
350  $this->tpl->setContent($this->form->getHTML());
351  }
352 
357  public function addLink()
358  {
359  $this->checkPermission('write');
360  $this->activateTabs('content','id_content_view');
361 
362  $this->initFormLink(self::LINK_MOD_ADD);
363  $this->tpl->setContent($this->form->getHTML());
364  }
365 
370  public function saveAddLink()
371  {
372  global $ilCtrl;
373 
374  $this->checkPermission('write');
375 
376  $this->initFormLink(self::LINK_MOD_ADD);
377  if($this->checkLinkInput(self::LINK_MOD_ADD,$this->object->getId(),0))
378  {
379  if($this->isContainerMetaDataRequired())
380  {
381  // Save list data
382  $this->object->setTitle($this->form->getInput('lti'));
383  $this->object->setDescription($this->form->getInput('tde'));
384  $this->object->update();
385  }
386 
387  // Save Link
388  $link_id = $this->link->add();
389  $this->link->updateValid(true);
390 
391  // Dynamic parameters
392  if(ilParameterAppender::_isEnabled() and is_object($this->dynamic))
393  {
394  $this->dynamic->add($link_id);
395  }
396  ilUtil::sendSuccess($this->lng->txt('webr_link_added'),true);
397  $ilCtrl->redirect($this,'view');
398  }
399  // Error handling
400  ilUtil::sendFailure($this->lng->txt('err_check_input'));
401  $this->form->setValuesByPost();
402 
403  $this->activateTabs('content','id_content_view');
404  $this->tpl->setContent($this->form->getHTML());
405  }
406 
411  protected function deleteParameter()
412  {
413  global $ilCtrl;
414 
415  $this->checkPermission('write');
416 
417  $this->ctrl->setParameter($this,'link_id',(int) $_GET['link_id']);
418 
419  if(!isset($_GET['param_id']))
420  {
421  ilUtil::sendFailure($this->lng->txt('select_one'),TRUE);
422  $ilCtrl->redirect($this,'view');
423  }
424 
425  include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
426  $param = new ilParameterAppender($this->object->getId());
427  $param->delete((int) $_GET['param_id']);
428 
429  ilUtil::sendSuccess($this->lng->txt('links_parameter_deleted'),true);
430  $ilCtrl->redirect($this,'editLinks');
431  }
432 
433  protected function deleteParameterForm()
434  {
435  global $ilCtrl;
436 
437  $this->checkPermission('write');
438 
439  if(!isset($_GET['param_id']))
440  {
441  ilUtil::sendFailure($this->lng->txt('select_one'),TRUE);
442  $ilCtrl->redirect($this,'view');
443  }
444 
445  include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
446  $param = new ilParameterAppender($this->object->getId());
447  $param->delete((int) $_GET['param_id']);
448 
449  ilUtil::sendSuccess($this->lng->txt('links_parameter_deleted'),true);
450  $ilCtrl->redirect($this,'view');
451 
452  }
453 
454 
459  protected function updateLinks()
460  {
461  global $ilCtrl;
462 
463  $this->checkPermission('write');
464  $this->activateTabs('content','');
465 
466  if(!is_array($_POST['ids']))
467  {
468  ilUtil::sendFailure($this->lng->txt('select_one'),TRUE);
469  $ilCtrl->redirect($this,'view');
470  }
471 
472  // Validate
473  $invalid = array();
474  foreach($_POST['ids'] as $link_id)
475  {
476  $data = $_POST['links'][$link_id];
477 
478  // handle internal links
479  if($_POST['tar_'.$link_id.'_ajax_type'] &&
480  $_POST['tar_'.$link_id.'_ajax_id'])
481  {
482  $data['tar'] = $_POST['links'][$link_id]['tar'] =
483  $_POST['tar_'.$link_id.'_ajax_type'].'|'.
484  $_POST['tar_'.$link_id.'_ajax_id'];
485  }
486 
487 
488  if(!strlen($data['tit']))
489  {
490  $invalid[] = $link_id;
491  continue;
492  }
493  if(!strlen($data['tar']))
494  {
495  $invalid[] = $link_id;
496  continue;
497  }
498  if($data['nam'] and !$data['val'])
499  {
500  $invalid[] = $link_id;
501  continue;
502  }
503  if(!$data['nam'] and $data['val'])
504  {
505  $invalid[] = $link_id;
506  continue;
507  }
508  }
509 
510  if(count($invalid))
511  {
512  ilUtil::sendFailure($this->lng->txt('err_check_input'));
513  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.webr_manage.html','Modules/WebResource');
514 
515  include_once './Modules/WebResource/classes/class.ilWebResourceEditableLinkTableGUI.php';
516  $table = new ilWebResourceEditableLinkTableGUI($this,'view');
517  $table->setInvalidLinks($invalid);
518  $table->parseSelectedLinks($_POST['ids']);
519  $table->updateFromPost();
520  $this->tpl->setVariable('TABLE_LINKS',$table->getHTML());
521  return false;
522  }
523 
524  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
525  $links = new ilLinkResourceItems($this->object->getId());
526 
527  // Save Settings
528  foreach($_POST['ids'] as $link_id)
529  {
530  $data = $_POST['links'][$link_id];
531 
532  $links->setLinkId($link_id);
533  $links->setTitle(ilUtil::stripSlashes($data['tit']));
534  $links->setDescription(ilUtil::stripSlashes($data['des']));
535  $links->setTarget(str_replace('"', '', ilUtil::stripSlashes($data['tar'])));
536  $links->setActiveStatus((int) $data['act']);
537  $links->setDisableCheckStatus((int) $data['che']);
538  $links->setValidStatus((int) $data['vali']);
539  $links->update();
540 
541  if(strlen($data['nam']) and $data['val'])
542  {
543  $param = new ilParameterAppender($this->object->getId());
544  $param->setName(ilUtil::stripSlashes($data['nam']));
545  $param->setValue((int) $data['val']);
546  $param->add($link_id);
547  }
548 
549  if($this->isContainerMetaDataRequired())
550  {
551  $this->object->setTitle(ilUtil::stripSlashes($data['tit']));
552  $this->object->setDescription(ilUtil::stripSlashes($data['des']));
553  $this->object->update();
554  }
555 
556  // TODO: Dynamic parameters
557  }
558 
559  ilUtil::sendSuccess($this->lng->txt('settings_saved'),TRUE);
560  $ilCtrl->redirect($this,'view');
561  }
562 
568  protected function setValuesFromLink($a_link_id)
569  {
570  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
571  $link = new ilLinkResourceItems($this->object->getId());
572 
573  $values = $link->getItem($a_link_id);
574 
576  {
577  }
578 
579  $this->form->setValuesByArray(
580  array(
581  'tit' => $values['title'],
582  'tar' => $values['target'],
583  'des' => $values['description'],
584  'act' => (int) $values['active'],
585  'che' => (int) $values['disable_check'],
586  'vali' => (int) $values['valid']
587  )
588  );
589  }
590 
591 
599  protected function checkLinkInput($a_mode,$a_webr_id = 0,$a_link_id = 0)
600  {
601  $valid = $this->form->checkInput();
602 
603  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
604  $this->link = new ilLinkResourceItems($a_webr_id);
605  $this->link->setTarget(str_replace('"', '', ilUtil::stripSlashes($this->form->getInput('tar'))));
606  $this->link->setTitle($this->form->getInput('tit'));
607  $this->link->setDescription($this->form->getInput('des'));
608  $this->link->setDisableCheckStatus($this->form->getInput('che'));
609 
610  if($a_mode == self::LINK_MOD_CREATE)
611  {
612  $this->link->setActiveStatus(true);
613  }
614  else
615  {
616  $this->link->setActiveStatus($this->form->getInput('act'));
617  }
618 
619  if($a_mode == self::LINK_MOD_EDIT)
620  {
621  $this->link->setValidStatus($this->form->getInput('vali'));
622  }
623  else
624  {
625  $this->link->setValidStatus(true);
626  }
627 
629  {
630  return $valid;
631  }
632 
633  $this->dynamic = new ilParameterAppender($a_webr_id);
634  $this->dynamic->setName($this->form->getInput('nam'));
635  $this->dynamic->setValue($this->form->getInput('val'));
636  if(!$this->dynamic->validate())
637  {
638  switch($this->dynamic->getErrorCode())
639  {
640  case LINKS_ERR_NO_NAME:
641  $this->form->getItemByPostVar('nam')->setAlert($this->lng->txt('links_no_name_given'));
642  return false;
643 
644  case LINKS_ERR_NO_VALUE:
645  $this->form->getItemByPostVar('val')->setAlert($this->lng->txt('links_no_value_given'));
646  return false;
647 
649  // Nothing entered => no error
650  return $valid;
651  }
652  $this->dynamic = null;
653  }
654  return $valid;
655  }
656 
657 
663  protected function initFormLink($a_mode)
664  {
665  global $ilTabs;
666 
667  $ilTabs->activateTab("id_content");
668 
669  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
670  $this->form = new ilPropertyFormGUI();
671 
672  switch($a_mode)
673  {
674  case self::LINK_MOD_CREATE:
675  // Header
676  $this->ctrl->setParameter($this,'new_type','webr');
677  $this->form->setTitle($this->lng->txt('webr_new_link'));
678  $this->form->setTableWidth('600px');
679 
680  // Buttons
681  $this->form->addCommandButton('save', $this->lng->txt('webr_add'));
682  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
683  break;
684 
685  case self::LINK_MOD_ADD:
686  // Header
687  $this->form->setTitle($this->lng->txt('webr_new_link'));
688 
689  // Buttons
690  $this->form->addCommandButton('saveAddLink', $this->lng->txt('webr_add'));
691  $this->form->addCommandButton('view', $this->lng->txt('cancel'));
692  break;
693 
694  case self::LINK_MOD_EDIT:
695  // Header
696  $this->ctrl->setParameter($this,'link_id',(int) $_REQUEST['link_id']);
697  $this->form->setTitle($this->lng->txt('webr_edit'));
698 
699  // Buttons
700  $this->form->addCommandButton('updateLink', $this->lng->txt('save'));
701  $this->form->addCommandButton('view', $this->lng->txt('cancel'));
702  break;
703  }
704 
705 
706  $this->form->setFormAction($this->ctrl->getFormAction($this));
707 
708  if($a_mode == self::LINK_MOD_ADD and $this->isContainerMetaDataRequired())
709  {
710  ilUtil::sendInfo($this->lng->txt('webr_container_info'));
711 
712 
713  $this->form->setTitle($this->lng->txt('webr_edit_list'));
714 
715  // List Title
716  $title = new ilTextInputGUI($this->lng->txt('webr_list_title'),'lti');
717  $title->setRequired(true);
718  $title->setSize(40);
719  $title->setMaxLength(127);
720  $this->form->addItem($title);
721 
722  // List Description
723  $desc = new ilTextAreaInputGUI($this->lng->txt('webr_list_desc'),'tde');
724  $desc->setRows(3);
725  $desc->setCols(40);
726  $this->form->addItem($desc);
727 
728  // Addtional section
729  $sect = new ilFormSectionHeaderGUI();
730  $sect->setTitle($this->lng->txt('webr_add'));
731  $this->form->addItem($sect);
732  }
733 
734  // Target
735  /*
736  $tar = new ilTextInputGUI($this->lng->txt('webr_link_target'),'tar');
737  $tar->setValue("http://");
738 
739  $tar->setSize(40);
740  $tar->setMaxLength(500);
741  */
742  include_once 'Services/Form/classes/class.ilLinkInputGUI.php';
743  $tar = new ilLinkInputGUI($this->lng->txt('webr_link_target'),'tar');
744  $tar->setInternalLinkFilterTypes(array("PageObject", "GlossaryItem", "RepositoryItem"));
745 
746  $tar->setRequired(true);
747  $this->form->addItem($tar);
748 
749  // Title
750  $tit = new ilTextInputGUI($this->lng->txt('webr_link_title'),'tit');
751  $tit->setRequired(true);
752  $tit->setSize(40);
753  $tit->setMaxLength(127);
754  $this->form->addItem($tit);
755 
756  // Description
757  $des = new ilTextAreaInputGUI($this->lng->txt('description'),'des');
758  $des->setRows(3);
759  $des->setCols(40);
760  $this->form->addItem($des);
761 
762 
763  if($a_mode != self::LINK_MOD_CREATE)
764  {
765  // Active
766  $act = new ilCheckboxInputGUI($this->lng->txt('active'),'act');
767  $act->setChecked(true);
768  $act->setValue(1);
769  $this->form->addItem($act);
770 
771  // Check
772  $che = new ilCheckboxInputGUI($this->lng->txt('webr_disable_check'),'che');
773  $che->setValue(1);
774  $this->form->addItem($che);
775  }
776 
777  // Valid
778  if($a_mode == self::LINK_MOD_EDIT)
779  {
780  $val = new ilCheckboxInputGUI($this->lng->txt('valid'),'vali');
781  $this->form->addItem($val);
782  }
783 
784  if(ilParameterAppender::_isEnabled() && $a_mode != self::LINK_MOD_CREATE)
785  {
786  $dyn = new ilNonEditableValueGUI($this->lng->txt('links_dyn_parameter'));
787  $dyn->setInfo($this->lng->txt('links_dynamic_info'));
788 
789 
790  if(count($links = ilParameterAppender::_getParams((int) $_GET['link_id'])))
791  {
792  $ex = new ilCustomInputGUI($this->lng->txt('links_existing_params'),'ex');
793  $dyn->addSubItem($ex);
794 
795  foreach($links as $id => $link)
796  {
797  $p = new ilCustomInputGUI();
798 
799  $ptpl = new ilTemplate('tpl.link_dyn_param_edit.html',true,true,'Modules/WebResource');
800  $ptpl->setVariable('INFO_TXT',ilParameterAppender::parameterToInfo($link['name'], $link['value']));
801  $this->ctrl->setParameter($this,'param_id',$id);
802  $ptpl->setVariable('LINK_DEL',$this->ctrl->getLinkTarget($this,'deleteParameterForm'));
803  $ptpl->setVariable('LINK_TXT',$this->lng->txt('delete'));
804  $p->setHtml($ptpl->get());
805  $dyn->addSubItem($p);
806  }
807  }
808 
809  // Existing parameters
810 
811  // New parameter
812  if($a_mode != self::LINK_MOD_CREATE)
813  {
814  #$new = new ilCustomInputGUI($this->lng->txt('links_add_param'),'');
815  #$dyn->addSubItem($new);
816  }
817 
818  // Dynyamic name
819  $nam = new ilTextInputGUI($this->lng->txt('links_name'),'nam');
820  $nam->setSize(12);
821  $nam->setMaxLength(128);
822  $dyn->addSubItem($nam);
823 
824  // Dynamic value
825  $val = new ilSelectInputGUI($this->lng->txt('links_value'),'val');
827  $val->setValue(0);
828  $dyn->addSubItem($val);
829 
830  $this->form->addItem($dyn);
831  }
832  }
833 
839  protected function isContainerMetaDataRequired()
840  {
841  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
842  return ilLinkResourceItems::lookupNumberOfLinks($this->object->getId()) == 1;
843  }
844 
849  protected function switchViewMode()
850  {
851  global $ilCtrl;
852 
853  $_REQUEST['view_mode'] = $_GET['view_mode'] = (int) $_GET['switch_mode'];
854  $this->view();
855  }
856 
861  protected function editLinks()
862  {
863  $_GET['switch_mode'] = self::VIEW_MODE_MANAGE;
864  $this->switchViewMode();
865  }
866 
867 
872  public function view()
873  {
874  global $ilErr, $ilTabs;
875 
876  $ilTabs->activateTab("id_content");
877 
878  $this->checkPermission('read');
879 
880  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
881  {
882  parent::view();
883  return true;
884  }
885  else
886  {
887  switch((int) $_REQUEST['view_mode'])
888  {
889  case self::VIEW_MODE_MANAGE:
890  $this->manage();
891  break;
892 
893  case self::VIEW_MODE_SORT:
894  $this->sort();
895  break;
896 
897  default:
898  $this->showLinks();
899  break;
900  }
901  }
902  return true;
903  }
904 
909  protected function manage()
910  {
911  $this->checkPermission('write');
912  $this->activateTabs('content','id_content_manage');
913 
914  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.webr_manage.html','Modules/WebResource');
915  $this->showToolbar('ACTION_BUTTONS');
916 
917  include_once './Modules/WebResource/classes/class.ilWebResourceEditableLinkTableGUI.php';
918  $table = new ilWebResourceEditableLinkTableGUI($this,'view');
919  $table->parse();
920 
921  include_once './Modules/LearningModule/classes/class.ilInternalLinkGUI.php';
923 
924  $this->tpl->addJavaScript("Modules/WebResource/js/intLink.js");
925  $this->tpl->addJavascript("Services/Form/js/Form.js");
926 
927  $this->tpl->setVariable('TABLE_LINKS',$table->getHTML().$js);
928  }
929 
934  protected function showLinks()
935  {
936  $this->checkPermission('read');
937  $this->activateTabs('content','id_content_view');
938 
939  include_once './Modules/WebResource/classes/class.ilWebResourceLinkTableGUI.php';
940  $table = new ilWebResourceLinkTableGUI($this,'showLinks');
941  $table->parse();
942 
943  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.webr_view.html','Modules/WebResource');
944  $this->showToolbar('ACTION_BUTTONS');
945  $this->tpl->setVariable('LINK_TABLE',$table->getHTML());
946  }
947 
952  protected function sort()
953  {
954  $this->checkPermission('write');
955  $this->activateTabs('content','id_content_ordering');
956 
957  include_once './Modules/WebResource/classes/class.ilWebResourceLinkTableGUI.php';
958  $table = new ilWebResourceLinkTableGUI($this,'sort',true);
959  $table->parse();
960 
961  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.webr_view.html','Modules/WebResource');
962  $this->showToolbar('ACTION_BUTTONS');
963  $this->tpl->setVariable('LINK_TABLE',$table->getHTML());
964  }
965 
970  protected function saveSorting()
971  {
972  $this->checkPermission('write');
973 
974  include_once './Services/Container/classes/class.ilContainerSorting.php';
975  $sort = ilContainerSorting::_getInstance($this->object->getId());
976  $sort->savePost((array) $_POST['position']);
977 
978  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
979  $this->view();
980  }
981 
982 
988  protected function showToolbar($a_tpl_var)
989  {
990  if(!$this->checkPermissionBool('write'))
991  {
992  return;
993  }
994 
995  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
996  $tool = new ilToolbarGUI();
997  $tool->setFormAction($this->ctrl->getFormAction($this));
998  $tool->addButton(
999  $this->lng->txt('webr_add'),
1000  $this->ctrl->getLinkTarget($this,'addLink')
1001  );
1002 
1003  $this->tpl->setVariable($a_tpl_var,$tool->getHTML());
1004  return;
1005  }
1006 
1011  protected function confirmDeleteLink()
1012  {
1013  $this->checkPermission('write');
1014  $this->activateTabs('content','id_content_view');
1015 
1016  $link_ids = array();
1017 
1018  if(is_array($_POST['link_ids']))
1019  {
1020  $link_ids =$_POST['link_ids'];
1021  }
1022  elseif(isset($_GET['link_id']))
1023  {
1024  $link_ids = array($_GET['link_id']);
1025  }
1026 
1027  if(!count($link_ids) > 0)
1028  {
1029  ilUtil::sendFailure($this->lng->txt('select_one'));
1030  $this->view();
1031  return false;
1032  }
1033 
1034  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1035  $links = new ilLinkResourceItems($this->object->getId());
1036 
1037  include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1038  $confirm = new ilConfirmationGUI();
1039  $confirm->setFormAction($this->ctrl->getFormAction($this,'view'));
1040  $confirm->setHeaderText($this->lng->txt('webr_sure_delete_items'));
1041  $confirm->setConfirm($this->lng->txt('delete'), 'deleteLinks');
1042  $confirm->setCancel($this->lng->txt('cancel'), 'view');
1043 
1044  foreach($link_ids as $link_id)
1045  {
1046  $link = $links->getItem($link_id);
1047  $confirm->addItem('link_ids[]', $link_id,$link['title']);
1048  }
1049  $this->tpl->setContent($confirm->getHTML());
1050  }
1051 
1056  protected function deleteLinks()
1057  {
1058  global $ilCtrl;
1059 
1060  $this->checkPermission('write');
1061 
1062  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1063  $links = new ilLinkResourceItems($this->object->getId());
1064 
1065  foreach($_POST['link_ids'] as $link_id)
1066  {
1067  $links->delete($link_id);
1068  }
1069  ilUtil::sendSuccess($this->lng->txt('webr_deleted_items'),true);
1070  $ilCtrl->redirect($this,'view');
1071  }
1072 
1077  protected function deactivateLink()
1078  {
1079  global $ilCtrl;
1080 
1081  $this->checkPermission('write');
1082 
1083  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1084  $links = new ilLinkResourceItems($this->object->getId());
1085 
1086  if(!$_GET['link_id'])
1087  {
1088  ilUtil::sendFailure($this->lng->txt('select_one'),true);
1089  $ilCtrl->redirect($this,'view');
1090  }
1091 
1092  $links->setLinkId((int) $_GET['link_id']);
1093  $links->updateActive(false);
1094 
1095  ilUtil::sendSuccess($this->lng->txt('webr_inactive_success'),true);
1096  $ilCtrl->redirect($this,'view');
1097  }
1098 
1099 
1105  function infoScreen()
1106  {
1107  $this->ctrl->setCmd("showSummary");
1108  $this->ctrl->setCmdClass("ilinfoscreengui");
1109  $this->infoScreenForward();
1110  }
1111 
1116  {
1117  global $ilTabs;
1118 
1119  $this->checkPermission('visible');
1120  $ilTabs->activateTab('id_info');
1121 
1122  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1123  $info = new ilInfoScreenGUI($this);
1124 
1125  $info->enablePrivateNotes();
1126 
1127  // standard meta data
1128  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
1129 
1130  if($this->id_type == self::WORKSPACE_NODE_ID)
1131  {
1132  $info->addProperty($this->lng->txt("perma_link"), $this->getPermanentLinkWidget());
1133  }
1134 
1135  // forward the command
1136  $this->ctrl->forwardCommand($info);
1137  }
1138 
1139 
1140  function history()
1141  {
1142  global $ilTabs;
1143 
1144  $this->checkPermission('write');
1145  $ilTabs->activateTab('id_history');
1146 
1147  include_once("./Services/History/classes/class.ilHistoryGUI.php");
1148 
1149  $hist_gui =& new ilHistoryGUI($this->object->getId());
1150 
1151  $hist_html = $hist_gui->getHistoryTable(array("ref_id" => $_GET["ref_id"],
1152  "cmd" => "history",
1153  "cmdClass" =>$_GET["cmdClass"],
1154  "cmdNode" =>$_GET["cmdNode"]));
1155 
1156  $this->tpl->setVariable("ADM_CONTENT", $hist_html);
1157  }
1158 
1167  public function formatInvalidLinkArray(Array $row)
1168  {
1169  $this->object->items_obj->readItem($row['page_id']);
1170  $row['title'] = $this->object->items_obj->getTitle();
1171 
1172  require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
1174  $actions->setSelectionHeaderClass('small');
1175  $actions->setItemLinkClass('xsmall');
1176  $actions->setListTitle($this->lng->txt('actions'));
1177  $actions->setId($row['page_id']);
1178  $this->ctrl->setParameter($this, 'link_id', $row['page_id']);
1179  $actions->addItem(
1180  $this->lng->txt('edit'),
1181  '',
1182  $this->ctrl->getLinkTarget($this, 'editLink')
1183  );
1184  $this->ctrl->clearParameters($this);
1185  $row['action_html'] = $actions->getHTML();
1186 
1187  return $row;
1188  }
1189 
1194  protected function linkChecker()
1195  {
1196  global $ilias, $ilUser, $tpl, $ilTabs;
1197 
1198  $this->checkPermission('write');
1199  $ilTabs->activateTab('id_link_check');
1200 
1201  $this->__initLinkChecker();
1202  $this->object->initLinkResourceItemsObject();
1203 
1204  require_once './Services/LinkChecker/classes/class.ilLinkCheckerTableGUI.php';
1205 
1206  $toolbar = new ilToolbarGUI();
1207 
1208  if((bool)$ilias->getSetting('cron_web_resource_check'))
1209  {
1210  include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
1211  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
1212 
1213  $chb = new ilCheckboxInputGUI($this->lng->txt('link_check_message_a'), 'link_check_message');
1214  $chb->setValue(1);
1215  $chb->setChecked((bool)ilLinkCheckNotify::_getNotifyStatus($ilUser->getId(), $this->object->getId()));
1216  $chb->setOptionTitle($this->lng->txt('link_check_message_b'));
1217 
1218  $toolbar->addInputItem($chb);
1219  $toolbar->addFormButton($this->lng->txt('save'), 'saveLinkCheck');
1220  $toolbar->setFormAction($this->ctrl->getLinkTarget($this, 'saveLinkCheck'));
1221  }
1222 
1223  $tgui = new ilLinkCheckerTableGUI($this, 'linkChecker');
1224  $tgui->setLinkChecker($this->link_checker_obj)
1225  ->setRowHandler($this)
1226  ->setRefreshButton($this->lng->txt('refresh'), 'refreshLinkCheck');
1227 
1228  return $tpl->setContent($tgui->prepareHTML()->getHTML().$toolbar->getHTML());
1229  }
1230 
1231  function saveLinkCheck()
1232  {
1233  global $ilDB,$ilUser;
1234 
1235  include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
1236 
1237  $link_check_notify =& new ilLinkCheckNotify($ilDB);
1238  $link_check_notify->setUserId($ilUser->getId());
1239  $link_check_notify->setObjId($this->object->getId());
1240 
1241  if($_POST['link_check_message'])
1242  {
1243  ilUtil::sendSuccess($this->lng->txt('link_check_message_enabled'));
1244  $link_check_notify->addNotifier();
1245  }
1246  else
1247  {
1248  ilUtil::sendSuccess($this->lng->txt('link_check_message_disabled'));
1249  $link_check_notify->deleteNotifier();
1250  }
1251  $this->linkChecker();
1252 
1253  return true;
1254  }
1255 
1256 
1257 
1258  function refreshLinkCheck()
1259  {
1260  $this->__initLinkChecker();
1261 
1262  if(!$this->link_checker_obj->checkPear())
1263  {
1264  ilUtil::sendFailure($this->lng->txt('missing_pear_library'));
1265  $this->linkChecker();
1266 
1267  return false;
1268  }
1269 
1270 
1271  $this->object->initLinkResourceItemsObject();
1272 
1273  // Set all link to valid. After check invalid links will be set to invalid
1274  $this->object->items_obj->updateValidByCheck();
1275 
1276  foreach($this->link_checker_obj->checkWebResourceLinks() as $invalid)
1277  {
1278  $this->object->items_obj->readItem($invalid['page_id']);
1279  $this->object->items_obj->setActiveStatus(false);
1280  $this->object->items_obj->setValidStatus(false);
1281  $this->object->items_obj->update(false);
1282  }
1283 
1284  $this->object->items_obj->updateLastCheck();
1285  ilUtil::sendSuccess($this->lng->txt('link_checker_refreshed'));
1286 
1287  $this->linkChecker();
1288 
1289  return true;
1290  }
1291 
1293  {
1294  global $ilDB;
1295 
1296  include_once './Services/LinkChecker/classes/class.ilLinkChecker.php';
1297 
1298  $this->link_checker_obj =& new ilLinkChecker($ilDB,false);
1299  $this->link_checker_obj->setObjId($this->object->getId());
1300 
1301  return true;
1302  }
1303 
1304 
1311  protected function activateTabs($a_active_tab,$a_active_subtab = '')
1312  {
1313  global $ilCtrl, $ilTabs, $lng;
1314 
1315  switch($a_active_tab)
1316  {
1317  case 'content':
1318  if($this->checkPermissionBool('write'))
1319  {
1320  $this->lng->loadLanguageModule('cntr');
1321 
1322  $this->ctrl->setParameter($this,'switch_mode',self::VIEW_MODE_VIEW);
1323  $ilTabs->addSubTab('id_content_view',
1324  $lng->txt('view'),
1325  $this->ctrl->getLinkTarget($this,'switchViewMode')
1326  );
1327  $this->ctrl->setParameter($this,'switch_mode',self::VIEW_MODE_MANAGE);
1328  $ilTabs->addSubTab('id_content_manage',
1329  $lng->txt('cntr_manage'),
1330  $this->ctrl->getLinkTarget($this,'switchViewMode')
1331  );
1332  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1333  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
1334  include_once './Services/Container/classes/class.ilContainer.php';
1335  if((ilLinkResourceItems::lookupNumberOfLinks($this->object->getId()) > 1)
1337  {
1338  $this->ctrl->setParameter($this,'switch_mode',self::VIEW_MODE_SORT);
1339  $ilTabs->addSubTab('id_content_ordering',
1340  $this->lng->txt('cntr_ordering'),
1341  $this->ctrl->getLinkTarget($this,'switchViewMode')
1342  );
1343  }
1344 
1345  $ilCtrl->clearParameters($this);
1346  $ilTabs->activateSubTab($a_active_subtab);
1347  }
1348  }
1349 
1350  $ilTabs->activateTab('id_content');
1351  }
1352 
1353 
1358  function setTabs()
1359  {
1360  global $ilTabs, $lng, $ilHelp;
1361 
1362  $ilHelp->setScreenIdComponent("webr");
1363 
1364  if ($this->checkPermissionBool('read'))
1365  {
1366  $ilTabs->addTab("id_content",
1367  $lng->txt("content"),
1368  $this->ctrl->getLinkTarget($this, "view"));
1369  }
1370 
1371  if ($this->checkPermissionBool('visible'))
1372  {
1373  $ilTabs->addTab("id_info",
1374  $lng->txt("info_short"),
1375  $this->ctrl->getLinkTarget($this, "infoScreen"));
1376  }
1377 
1378  if($this->checkPermissionBool('write') and !$this->getCreationMode())
1379  {
1380  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1381  if(ilLinkResourceItems::lookupNumberOfLinks($this->object->getId()) > 1)
1382  {
1383  $ilTabs->addTab("id_settings",
1384  $lng->txt("settings"),
1385  $this->ctrl->getLinkTarget($this, "settings"));
1386  }
1387 
1388  }
1389 
1390  if ($this->checkPermissionBool('write'))
1391  {
1392  $ilTabs->addTab("id_history",
1393  $lng->txt("history"),
1394  $this->ctrl->getLinkTarget($this, "history"));
1395  }
1396 
1397  if ($this->checkPermissionBool('write'))
1398  {
1399  // Check if pear library is available
1400  if(@include_once('HTTP/Request.php'))
1401  {
1402  $ilTabs->addTab("id_link_check",
1403  $lng->txt("link_check"),
1404  $this->ctrl->getLinkTarget($this, "linkChecker"));
1405  }
1406  }
1407 
1408  if ($this->checkPermissionBool('write'))
1409  {
1410  $ilTabs->addTab("id_meta_data",
1411  $lng->txt("meta_data"),
1412  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'));
1413  }
1414 
1415  if($this->checkPermissionBool('write'))
1416  {
1417  $ilTabs->addTab(
1418  'export',
1419  $this->lng->txt('export'),
1420  $this->ctrl->getLinkTargetByClass('ilexportgui','')
1421  );
1422  }
1423 
1424  // will add permission tab if needed
1425  parent::setTabs();
1426  }
1427 
1428  // PRIVATE
1429  function __prepareOutput()
1430  {
1431  // output objects
1432  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
1433  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
1434 
1435  // output locator
1436  $this->__setLocator();
1437 
1438  // output message
1439  if ($this->message)
1440  {
1441  ilUtil::sendInfo($this->message);
1442  }
1443 
1444  // display infopanel if something happened
1445  ilUtil::infoPanel();;
1446  }
1447 
1448  function __setLocator()
1449  {
1450  global $tree;
1451  global $lng, $ilCtrl;
1452 
1453  $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html", "Services/Locator");
1454 
1455  $counter = 0;
1456 
1457  //$this->tpl->touchBlock('locator_separator');
1458  //$this->tpl->touchBlock('locator_item');
1459 
1460  foreach ($tree->getPathFull($this->object->getRefId()) as $key => $row)
1461  {
1462 
1463  //if ($row["child"] == $tree->getRootId())
1464  //{
1465  // continue;
1466  //}
1467 
1468  if($counter++)
1469  {
1470  $this->tpl->touchBlock('locator_separator_prefix');
1471  }
1472 
1473  if ($row["child"] > 0)
1474  {
1475  $this->tpl->setCurrentBlock("locator_img");
1476  $this->tpl->setVariable("IMG_SRC",
1477  ilUtil::getImagePath("icon_".$row["type"]."_s.png"));
1478  $this->tpl->setVariable("IMG_ALT",
1479  $lng->txt("obj_".$type));
1480  $this->tpl->parseCurrentBlock();
1481  }
1482 
1483  $this->tpl->setCurrentBlock("locator_item");
1484 
1485  if($row["type"] == 'webr')
1486  {
1487  $this->tpl->setVariable("ITEM",$this->object->getTitle());
1488  $this->tpl->setVariable("LINK_ITEM",$this->ctrl->getLinkTarget($this));
1489  }
1490  elseif ($row["child"] != $tree->getRootId())
1491  {
1492  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $row["child"]);
1493  $this->tpl->setVariable("ITEM", $row["title"]);
1494  $this->tpl->setVariable("LINK_ITEM",
1495  $ilCtrl->getLinkTargetByClass("ilrepositorygui", ""));
1496  }
1497  else
1498  {
1499  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $row["child"]);
1500  $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
1501  $this->tpl->setVariable("LINK_ITEM",
1502  $ilCtrl->getLinkTargetByClass("ilrepositorygui", ""));
1503  }
1504  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
1505 
1506  $this->tpl->parseCurrentBlock();
1507  }
1508 
1509  $this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
1510  $this->tpl->parseCurrentBlock();
1511  }
1512 
1513  function callDirectLink()
1514  {
1515  $obj_id = $this->object->getId();
1516 
1517 
1518  include_once("./Services/Link/classes/class.ilLink.php");
1519  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1521  {
1523 
1524  // #15647 - handle internal links
1525  include_once "Services/Form/classes/class.ilFormPropertyGUI.php";
1526  include_once "Services/Form/classes/class.ilLinkInputGUI.php";
1527  if(ilLinkInputGUI::isInternalLink($url["target"]))
1528  {
1529  // #10612
1530  $parts = explode("|", $url["target"]);
1531  if ($parts[0] == "page")
1532  {
1533  $parts[0] = "pg";
1534  }
1535  if ($parts[0] == "term")
1536  {
1537  $parts[0] = "git";
1538  }
1539  $url["target"] = ilLink::_getStaticLink($parts[1], $parts[0]);
1540  }
1541 
1542  include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
1544  {
1545  $url = ilParameterAppender::_append($url);
1546  }
1547 
1548  $this->redirectToLink($this->ref_id, $obj_id, $url["target"]);
1549  }
1550  }
1551 
1552  function callLink()
1553  {
1554  if($_REQUEST["link_id"])
1555  {
1556  $obj_id = $this->object->getId();
1557 
1558  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1559  $items = new ilLinkResourceItems($obj_id);
1560  $item = $items->getItem($_REQUEST["link_id"]);
1561  if($item["target"])
1562  {
1563  // #15647 - handle internal links
1564  include_once "Services/Form/classes/class.ilFormPropertyGUI.php";
1565  include_once "Services/Form/classes/class.ilLinkInputGUI.php";
1566  if(ilLinkInputGUI::isInternalLink($item["target"]))
1567  {
1568  $parts = explode("|", $item["target"]);
1569  if ($parts[0] == "page")
1570  {
1571  $parts[0] = "pg";
1572  }
1573  include_once("./Services/Link/classes/class.ilLink.php");
1574  $item["target"] = ilLink::_getStaticLink($parts[1], $parts[0]);
1575  if ($parts[0] == "term")
1576  {
1577  $parts[0] = "git";
1578  $item["target"] =
1580  $parts[0],
1581  true,
1582  "&target=git_".$parts[1]);
1583  }
1584  }
1585  include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
1587  {
1588  $item = ilParameterAppender::_append($item);
1589  }
1590 //var_dump($item); exit;
1591  $this->redirectToLink($this->ref_id, $obj_id, $item["target"]);
1592  }
1593  }
1594  }
1595 
1596  protected function redirectToLink($a_ref_id, $a_obj_id, $a_url)
1597  {
1598  global $ilUser;
1599 
1600  if($a_url)
1601  {
1602  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1603  ilChangeEvent::_recordReadEvent("webr", $a_ref_id, $a_obj_id,
1604  $ilUser->getId());
1605 
1606  ilUtil::redirect($a_url);
1607  }
1608  }
1609 
1610  function _goto($a_target, $a_additional = null)
1611  {
1612  global $ilAccess, $ilErr, $lng;
1613 
1614  if($a_additional && substr($a_additional, -3) == "wsp")
1615  {
1616  $_GET["baseClass"] = "ilsharedresourceGUI";
1617  $_GET["wsp_id"] = $a_target;
1618  include("ilias.php");
1619  exit;
1620  }
1621 
1622  // Will be replaced in future releases by ilAccess::checkAccess()
1623  if ($ilAccess->checkAccess("read", "", $a_target))
1624  {
1625  ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=$a_target");
1626  }
1627  else
1628  {
1629  // to do: force flat view
1630  if ($ilAccess->checkAccess("visible", "", $a_target))
1631  {
1632  ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=".$a_target."&cmd=infoScreen");
1633  }
1634  else
1635  {
1636  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1637  {
1638  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
1639  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1641  }
1642  }
1643  }
1644 
1645  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1646  }
1647 } // END class.ilObjLinkResource
1648 ?>