ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  public function getType()
33  {
34  return "webr";
35  }
36 
37  public function executeCommand()
38  {
39  global $DIC;
40 
41  $ilCtrl = $DIC['ilCtrl'];
42  $ilTabs = $DIC['ilTabs'];
43  $ilErr = $DIC['ilErr'];
44  $ilAccess = $DIC['ilAccess'];
45 
46 
47  //if($this->ctrl->getTargetScript() == 'link_resources.php')
48  if ($_GET["baseClass"] == 'ilLinkResourceHandlerGUI') {
49  $_GET['view_mode'] = isset($_GET['switch_mode']) ? $_GET['switch_mode'] : $_GET['view_mode'];
50  $ilCtrl->saveParameter($this, 'view_mode');
51  $this->__prepareOutput();
52  }
53 
54  $this->lng->loadLanguageModule("webr");
55 
56  $next_class = $this->ctrl->getNextClass($this);
57  $cmd = $this->ctrl->getCmd();
58 
59  switch ($next_class) {
60  case "ilinfoscreengui":
61  $this->prepareOutput();
62  $this->infoScreenForward(); // forwards command
63  break;
64 
65  case 'ilobjectmetadatagui':
66  $this->checkPermission('write'); // #18563
67  $this->prepareOutput();
68  $ilTabs->activateTab('id_meta_data');
69  include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
70  $md_gui = new ilObjectMetaDataGUI($this->object);
71  $this->ctrl->forwardCommand($md_gui);
72  break;
73 
74  case 'ilpermissiongui':
75  $this->prepareOutput();
76  $ilTabs->activateTab('id_permissions');
77  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
78  $perm_gui = new ilPermissionGUI($this);
79  $ret = &$this->ctrl->forwardCommand($perm_gui);
80  break;
81 
82  case 'ilobjectcopygui':
83  $this->prepareOutput();
84  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
85  $cp = new ilObjectCopyGUI($this);
86  $cp->setType('webr');
87  $this->ctrl->forwardCommand($cp);
88  break;
89 
90  case 'ilexportgui':
91  $this->prepareOutput();
92  $this->tabs_gui->setTabActive('export');
93  include_once './Services/Export/classes/class.ilExportGUI.php';
94  $exp = new ilExportGUI($this);
95  $exp->addFormat('xml');
96  $this->ctrl->forwardCommand($exp);
97  break;
98 
99  case "ilcommonactiondispatchergui":
100  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
102  $this->ctrl->forwardCommand($gui);
103  break;
104 
105  case "ilpropertyformgui":
106  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
107  $this->initFormLink(self::LINK_MOD_EDIT);
108  $this->ctrl->forwardCommand($this->form);
109  break;
110 
111  case "ilinternallinkgui":
112  $this->lng->loadLanguageModule("content");
113  require_once("./Services/Link/classes/class.ilInternalLinkGUI.php");
114  $link_gui = new ilInternalLinkGUI("RepositoryItem", 0);
115  $link_gui->filterLinkType("PageObject");
116  $link_gui->filterLinkType("GlossaryItem");
117  $link_gui->filterLinkType("RepositoryItem");
118  $link_gui->setFilterWhiteList(true);
119  $ilCtrl->forwardCommand($link_gui);
120  break;
121 
122  default:
123  if (!$cmd) {
124  $this->ctrl->setCmd("view");
125  }
126  parent::executeCommand();
127  }
128 
129  if (!$this->getCreationMode()) {
130  // Fill meta header tags
131  include_once('Services/MetaData/classes/class.ilMDUtils.php');
132  ilMDUtils::_fillHTMLMetaTags($this->object->getId(), $this->object->getId(), 'webr');
133 
134  $this->addHeaderAction();
135  }
136  return true;
137  }
138 
139  protected function initCreateForm($a_new_type)
140  {
141  $this->initFormLink(self::LINK_MOD_CREATE);
142  return $this->form;
143  }
144 
149  public function save()
150  {
151  global $DIC;
152 
153  $ilCtrl = $DIC['ilCtrl'];
154 
155  $this->initFormLink(self::LINK_MOD_CREATE);
156  if ($this->checkLinkInput(self::LINK_MOD_CREATE, 0, 0)) {
157  // Save new object
158  $_POST['title'] = $_POST['tit'];
159  $_POST['desc'] = $_POST['des'];
160  parent::save();
161  } else {
162  // Data incomplete or invalid
163  ilUtil::sendFailure($this->lng->txt('err_check_input'));
164  $this->form->setValuesByPost();
165  $this->tpl->setContent($this->form->getHTML());
166  }
167  }
168 
169  protected function afterSave(ilObject $a_new_object)
170  {
171  // Save link
172  $this->link->setLinkResourceId($a_new_object->getId());
173  $link_id = $this->link->add();
174  $this->link->updateValid(true);
175 
176  ilUtil::sendSuccess($this->lng->txt('webr_link_added'));
177 
178  // personal workspace
179  if ($this->id_type == self::WORKSPACE_NODE_ID) {
180  $this->ctrl->redirect($this, "editLinks");
181  }
182  // repository
183  else {
184  ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=" .
185  $a_new_object->getRefId() . "&cmd=switchViewMode&switch_mode=2");
186  }
187  }
188 
194  protected function settings()
195  {
196  global $DIC;
197 
198  $ilTabs = $DIC['ilTabs'];
199 
200  $this->checkPermission('write');
201  $ilTabs->activateTab('id_settings');
202 
203  $this->initFormSettings();
204  $this->tpl->setContent($this->form->getHTML());
205  }
206 
211  protected function saveSettings()
212  {
213  global $DIC;
214 
215  $obj_service = $this->object_service;
216  $ilTabs = $DIC['ilTabs'];
217 
218  $this->checkPermission('write');
219  $ilTabs->activateTab('id_settings');
220 
221  $this->initFormSettings();
222  if ($this->form->checkInput()) {
223  $this->object->setTitle($this->form->getInput('tit'));
224  $this->object->setDescription($this->form->getInput('des'));
225  $this->object->update();
226 
227  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
228  $sort = new ilContainerSortingSettings($this->object->getId());
229  $sort->setSortMode($this->form->getInput('sor'));
230  $sort->update();
231 
232  // tile image
233  $obj_service->commonSettings()->legacyForm($this->form, $this->object)->saveTileImage();
234 
235 
236  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
237  $this->ctrl->redirect($this, 'settings');
238  }
239 
240  $this->form->setValuesByPost();
241  ilUtil::sendFailure($this->lng->txt('err_check_input'));
242  $this->tpl->setContent($this->form->getHTML());
243  }
244 
245 
250  protected function initFormSettings()
251  {
252  $obj_service = $this->object_service;
253 
254  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
255  $this->form = new ilPropertyFormGUI();
256  $this->form->setFormAction($this->ctrl->getFormAction($this, 'saveSettings'));
257  $this->form->setTitle($this->lng->txt('webr_edit_settings'));
258 
259  // Title
260  $tit = new ilTextInputGUI($this->lng->txt('webr_list_title'), 'tit');
261  $tit->setValue($this->object->getTitle());
262  $tit->setRequired(true);
263  $tit->setSize(40);
264  $tit->setMaxLength(127);
265  $this->form->addItem($tit);
266 
267  // Description
268  $des = new ilTextAreaInputGUI($this->lng->txt('webr_list_desc'), 'des');
269  $des->setValue($this->object->getDescription());
270  $des->setCols(40);
271  $des->setRows(3);
272  $this->form->addItem($des);
273 
275  $section->setTitle($this->lng->txt('obj_presentation'));
276  $this->form->addItem($section);
277 
278  // tile image
279  $obj_service->commonSettings()->legacyForm($this->form, $this->object)->addTileImage();
280 
281  // Sorting
282  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
283  include_once './Services/Container/classes/class.ilContainer.php';
284 
285  $sor = new ilRadioGroupInputGUI($this->lng->txt('webr_sorting'), 'sor');
286  $sor->setRequired(true);
287  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
288  $sor->setValue(ilContainerSortingSettings::_lookupSortMode($this->object->getId()));
289 
290  $opt = new ilRadioOption(
291  $this->lng->txt('webr_sort_title'),
293  );
294  $sor->addOption($opt);
295 
296  $opm = new ilRadioOption(
297  $this->lng->txt('webr_sort_manual'),
299  );
300  $sor->addOption($opm);
301  $this->form->addItem($sor);
302 
303  $this->form->addCommandButton('saveSettings', $this->lng->txt('save'));
304  $this->form->addCommandButton('view', $this->lng->txt('cancel'));
305  }
306 
307 
312  public function editLink()
313  {
314  global $DIC;
315 
316  $ilCtrl = $DIC['ilCtrl'];
317 
318  $this->checkPermission('write');
319  $this->activateTabs('content', 'id_content_view');
320 
321  if (!(int) $_GET['link_id']) {
322  ilUtil::sendFailure($this->lng->txt('select_one'), true);
323  $ilCtrl->redirect($this, 'view');
324  }
325 
326  $this->initFormLink(self::LINK_MOD_EDIT);
327  $this->setValuesFromLink((int) $_GET['link_id']);
328  $this->tpl->setContent($this->form->getHTML());
329  }
330 
335  public function updateLink()
336  {
337  global $DIC;
338 
339  $ilCtrl = $DIC['ilCtrl'];
340 
341  $this->initFormLink(self::LINK_MOD_EDIT);
342  if ($this->checkLinkInput(self::LINK_MOD_EDIT, $this->object->getId(), (int) $_REQUEST['link_id'])) {
343  $this->link->setLinkId((int) $_REQUEST['link_id']);
344  $this->link->update();
345  if (ilParameterAppender::_isEnabled() and is_object($this->dynamic)) {
346  $this->dynamic->add((int) $_REQUEST['link_id']);
347  }
348 
349  if ($this->isContainerMetaDataRequired()) {
350  $this->object->setTitle($this->form->getInput('tit'));
351  $this->object->setDescription($this->form->getInput('des'));
352  $this->object->update();
353  }
354 
355  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
356  $ilCtrl->redirect($this, 'view');
357  }
358  ilUtil::sendFailure($this->lng->txt('err_check_input'));
359  $this->form->setValuesByPost();
360  $this->tpl->setContent($this->form->getHTML());
361  }
362 
367  public function addLink()
368  {
369  $this->checkPermission('write');
370  $this->activateTabs('content', 'id_content_view');
371 
372  $this->initFormLink(self::LINK_MOD_ADD);
373  $this->tpl->setContent($this->form->getHTML());
374  }
375 
380  public function saveAddLink()
381  {
382  global $DIC;
383 
384  $ilCtrl = $DIC['ilCtrl'];
385 
386  $this->checkPermission('write');
387 
388  $this->initFormLink(self::LINK_MOD_ADD);
389  if ($this->checkLinkInput(self::LINK_MOD_ADD, $this->object->getId(), 0)) {
390  if ($this->isContainerMetaDataRequired()) {
391  // Save list data
392  $this->object->setTitle($this->form->getInput('lti'));
393  $this->object->setDescription($this->form->getInput('tde'));
394  $this->object->update();
395  }
396 
397  // Save Link
398  $link_id = $this->link->add();
399  $this->link->updateValid(true);
400 
401  // Dynamic parameters
402  if (ilParameterAppender::_isEnabled() and is_object($this->dynamic)) {
403  $this->dynamic->add($link_id);
404  }
405  ilUtil::sendSuccess($this->lng->txt('webr_link_added'), true);
406  $ilCtrl->redirect($this, 'view');
407  }
408  // Error handling
409  ilUtil::sendFailure($this->lng->txt('err_check_input'));
410  $this->form->setValuesByPost();
411 
412  $this->activateTabs('content', 'id_content_view');
413  $this->tpl->setContent($this->form->getHTML());
414  }
415 
420  protected function deleteParameter()
421  {
422  global $DIC;
423 
424  $ilCtrl = $DIC['ilCtrl'];
425 
426  $this->checkPermission('write');
427 
428  $this->ctrl->setParameter($this, 'link_id', (int) $_GET['link_id']);
429 
430  if (!isset($_GET['param_id'])) {
431  ilUtil::sendFailure($this->lng->txt('select_one'), true);
432  $ilCtrl->redirect($this, 'view');
433  }
434 
435  include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
436  $param = new ilParameterAppender($this->object->getId());
437  $param->delete((int) $_GET['param_id']);
438 
439  ilUtil::sendSuccess($this->lng->txt('links_parameter_deleted'), true);
440  $ilCtrl->redirect($this, 'editLinks');
441  }
442 
443  protected function deleteParameterForm()
444  {
445  global $DIC;
446 
447  $ilCtrl = $DIC['ilCtrl'];
448 
449  $this->checkPermission('write');
450 
451  if (!isset($_GET['param_id'])) {
452  ilUtil::sendFailure($this->lng->txt('select_one'), true);
453  $ilCtrl->redirect($this, 'view');
454  }
455 
456  include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
457  $param = new ilParameterAppender($this->object->getId());
458  $param->delete((int) $_GET['param_id']);
459 
460  ilUtil::sendSuccess($this->lng->txt('links_parameter_deleted'), true);
461  $ilCtrl->redirect($this, 'view');
462  }
463 
464 
469  protected function updateLinks()
470  {
471  global $DIC;
472 
473  $ilCtrl = $DIC['ilCtrl'];
474 
475  $this->checkPermission('write');
476  $this->activateTabs('content', '');
477 
478  if (!is_array($_POST['ids'])) {
479  ilUtil::sendFailure($this->lng->txt('select_one'), true);
480  $ilCtrl->redirect($this, 'view');
481  }
482 
483  // Validate
484  $invalid = array();
485  foreach ($_POST['ids'] as $link_id) {
486  $data = $_POST['links'][$link_id];
487 
488  // handle internal links
489  if ($_POST['tar_' . $link_id . '_ajax_type'] &&
490  $_POST['tar_' . $link_id . '_ajax_id']) {
491  $data['tar'] = $_POST['links'][$link_id]['tar'] =
492  $_POST['tar_' . $link_id . '_ajax_type'] . '|' .
493  $_POST['tar_' . $link_id . '_ajax_id'];
494  }
495 
496 
497  if (!strlen($data['tit'])) {
498  $invalid[] = $link_id;
499  continue;
500  }
501  if (!strlen($data['tar'])) {
502  $invalid[] = $link_id;
503  continue;
504  }
505  if ($data['nam'] and !$data['val']) {
506  $invalid[] = $link_id;
507  continue;
508  }
509  if (!$data['nam'] and $data['val']) {
510  $invalid[] = $link_id;
511  continue;
512  }
513  }
514 
515  if (count($invalid)) {
516  ilUtil::sendFailure($this->lng->txt('err_check_input'));
517  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.webr_manage.html', 'Modules/WebResource');
518 
519  include_once './Modules/WebResource/classes/class.ilWebResourceEditableLinkTableGUI.php';
520  $table = new ilWebResourceEditableLinkTableGUI($this, 'view');
521  $table->setInvalidLinks($invalid);
522  $table->parseSelectedLinks($_POST['ids']);
523  $table->updateFromPost();
524  $this->tpl->setVariable('TABLE_LINKS', $table->getHTML());
525  return false;
526  }
527 
528  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
529  $links = new ilLinkResourceItems($this->object->getId());
530 
531  // Save Settings
532  include_once './Services/Form/classes/class.ilFormPropertyGUI.php';
533  include_once './Services/Form/classes/class.ilLinkInputGUI.php';
534  foreach ($_POST['ids'] as $link_id) {
535  $data = $_POST['links'][$link_id];
536 
537  $orig = ilLinkResourceItems::lookupItem($this->object->getId(), $link_id);
538 
539  $links->setLinkId($link_id);
540  $links->setTitle(ilUtil::stripSlashes($data['tit']));
541  $links->setDescription(ilUtil::stripSlashes($data['des']));
542  $links->setTarget(str_replace('"', '', ilUtil::stripSlashes($data['tar'])));
543  $links->setActiveStatus((int) $data['act']);
544  $links->setDisableCheckStatus((int) $data['che']);
545  $links->setLastCheckDate($orig['last_check']);
546  $links->setValidStatus((int) $data['vali']);
547  $links->setInternal(ilLinkInputGUI::isInternalLink($data['tar']));
548  $links->update();
549 
550  if (strlen($data['nam']) and $data['val']) {
551  $param = new ilParameterAppender($this->object->getId());
552  $param->setName(ilUtil::stripSlashes($data['nam']));
553  $param->setValue((int) $data['val']);
554  $param->add($link_id);
555  }
556 
557  if ($this->isContainerMetaDataRequired()) {
558  $this->object->setTitle(ilUtil::stripSlashes($data['tit']));
559  $this->object->setDescription(ilUtil::stripSlashes($data['des']));
560  $this->object->update();
561  }
562 
563  // TODO: Dynamic parameters
564  }
565 
566  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
567  $ilCtrl->redirect($this, 'view');
568  }
569 
575  protected function setValuesFromLink($a_link_id)
576  {
577  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
578  $link = new ilLinkResourceItems($this->object->getId());
579 
580  $values = $link->getItem($a_link_id);
581 
583  }
584 
585  $this->form->setValuesByArray(
586  array(
587  'tit' => $values['title'],
588  'tar' => $values['target'],
589  'des' => $values['description'],
590  'act' => (int) $values['active'],
591  'che' => (int) $values['disable_check'],
592  'vali' => (int) $values['valid']
593  )
594  );
595  }
596 
597 
605  protected function checkLinkInput($a_mode, $a_webr_id = 0, $a_link_id = 0)
606  {
607  $valid = $this->form->checkInput();
608 
609  $link_input = $this->form->getInput('tar');
610 
611  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
612  $this->link = new ilLinkResourceItems($a_webr_id);
613  $this->link->setTarget(str_replace('"', '', ilUtil::stripSlashes($link_input)));
614  $this->link->setTitle($this->form->getInput('tit'));
615  $this->link->setDescription($this->form->getInput('des'));
616  $this->link->setDisableCheckStatus($this->form->getInput('che'));
617  $this->link->setInternal(ilLinkInputGUI::isInternalLink($link_input));
618 
619  if ($a_mode == self::LINK_MOD_CREATE) {
620  $this->link->setActiveStatus(true);
621  } else {
622  $this->link->setActiveStatus($this->form->getInput('act'));
623  }
624 
625  if ($a_mode == self::LINK_MOD_EDIT) {
626  $this->link->setValidStatus($this->form->getInput('vali'));
627  } else {
628  $this->link->setValidStatus(true);
629  }
630 
632  return $valid;
633  }
634 
635  $this->dynamic = new ilParameterAppender($a_webr_id);
636  $this->dynamic->setName($this->form->getInput('nam'));
637  $this->dynamic->setValue($this->form->getInput('val'));
638  if (!$this->dynamic->validate()) {
639  switch ($this->dynamic->getErrorCode()) {
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 $DIC;
666 
667  $ilTabs = $DIC['ilTabs'];
668 
669  $ilTabs->activateTab("id_content");
670 
671  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
672  $this->form = new ilPropertyFormGUI();
673 
674  switch ($a_mode) {
675  case self::LINK_MOD_CREATE:
676  // Header
677  $this->ctrl->setParameter($this, 'new_type', 'webr');
678  $this->form->setTitle($this->lng->txt('webr_new_link'));
679  $this->form->setTableWidth('600px');
680 
681  // Buttons
682  $this->form->addCommandButton('save', $this->lng->txt('webr_add'));
683  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
684  break;
685 
686  case self::LINK_MOD_ADD:
687  // Header
688  $this->form->setTitle($this->lng->txt('webr_new_link'));
689 
690  // Buttons
691  $this->form->addCommandButton('saveAddLink', $this->lng->txt('webr_add'));
692  $this->form->addCommandButton('view', $this->lng->txt('cancel'));
693  break;
694 
695  case self::LINK_MOD_EDIT:
696  // Header
697  $this->ctrl->setParameter($this, 'link_id', (int) $_REQUEST['link_id']);
698  $this->form->setTitle($this->lng->txt('webr_edit'));
699 
700  // Buttons
701  $this->form->addCommandButton('updateLink', $this->lng->txt('save'));
702  $this->form->addCommandButton('view', $this->lng->txt('cancel'));
703  break;
704  }
705 
706 
707  $this->form->setFormAction($this->ctrl->getFormAction($this));
708 
709  if ($a_mode == self::LINK_MOD_ADD and $this->isContainerMetaDataRequired()) {
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');
745  array(
746  "PageObject",
747  "GlossaryItem",
748  "RepositoryItem",
749  'WikiPage'
750  )
751  );
752  $tar->setExternalLinkMaxLength(1000);
753  $tar->setInternalLinkFilterTypes(array("PageObject", "GlossaryItem", "RepositoryItem"));
754  $tar->setRequired(true);
755  $this->form->addItem($tar);
756 
757  // Title
758  $tit = new ilTextInputGUI($this->lng->txt('webr_link_title'), 'tit');
759  $tit->setRequired(true);
760  $tit->setSize(40);
761  $tit->setMaxLength(127);
762  $this->form->addItem($tit);
763 
764  // Description
765  $des = new ilTextAreaInputGUI($this->lng->txt('description'), 'des');
766  $des->setRows(3);
767  $des->setCols(40);
768  $this->form->addItem($des);
769 
770 
771  if ($a_mode != self::LINK_MOD_CREATE) {
772  // Active
773  $act = new ilCheckboxInputGUI($this->lng->txt('active'), 'act');
774  $act->setChecked(true);
775  $act->setValue(1);
776  $this->form->addItem($act);
777 
778  // Check
779  $che = new ilCheckboxInputGUI($this->lng->txt('webr_disable_check'), 'che');
780  $che->setValue(1);
781  $this->form->addItem($che);
782  }
783 
784  // Valid
785  if ($a_mode == self::LINK_MOD_EDIT) {
786  $val = new ilCheckboxInputGUI($this->lng->txt('valid'), 'vali');
787  $this->form->addItem($val);
788  }
789 
790  if (ilParameterAppender::_isEnabled() && $a_mode != self::LINK_MOD_CREATE) {
791  $dyn = new ilNonEditableValueGUI($this->lng->txt('links_dyn_parameter'));
792  $dyn->setInfo($this->lng->txt('links_dynamic_info'));
793 
794 
795  if (count($links = ilParameterAppender::_getParams((int) $_GET['link_id']))) {
796  $ex = new ilCustomInputGUI($this->lng->txt('links_existing_params'), 'ex');
797  $dyn->addSubItem($ex);
798 
799  foreach ($links as $id => $link) {
800  $p = new ilCustomInputGUI();
801 
802  $ptpl = new ilTemplate('tpl.link_dyn_param_edit.html', true, true, 'Modules/WebResource');
803  $ptpl->setVariable('INFO_TXT', ilParameterAppender::parameterToInfo($link['name'], $link['value']));
804  $this->ctrl->setParameter($this, 'param_id', $id);
805  $ptpl->setVariable('LINK_DEL', $this->ctrl->getLinkTarget($this, 'deleteParameterForm'));
806  $ptpl->setVariable('LINK_TXT', $this->lng->txt('delete'));
807  $p->setHtml($ptpl->get());
808  $dyn->addSubItem($p);
809  }
810  }
811 
812  // Existing parameters
813 
814  // New parameter
815  if ($a_mode != self::LINK_MOD_CREATE) {
816  #$new = new ilCustomInputGUI($this->lng->txt('links_add_param'),'');
817  #$dyn->addSubItem($new);
818  }
819 
820  // Dynyamic name
821  $nam = new ilTextInputGUI($this->lng->txt('links_name'), 'nam');
822  $nam->setSize(12);
823  $nam->setMaxLength(128);
824  $dyn->addSubItem($nam);
825 
826  // Dynamic value
827  $val = new ilSelectInputGUI($this->lng->txt('links_value'), 'val');
829  $val->setValue(0);
830  $dyn->addSubItem($val);
831 
832  $this->form->addItem($dyn);
833  }
834  }
835 
841  protected function isContainerMetaDataRequired()
842  {
843  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
844  return ilLinkResourceItems::lookupNumberOfLinks($this->object->getId()) == 1;
845  }
846 
851  protected function switchViewMode()
852  {
853  global $DIC;
854 
855  $ilCtrl = $DIC['ilCtrl'];
856 
857  $_REQUEST['view_mode'] = $_GET['view_mode'] = (int) $_GET['switch_mode'];
858  $this->view();
859  }
860 
865  protected function editLinks()
866  {
867  $_GET['switch_mode'] = self::VIEW_MODE_MANAGE;
868  $this->switchViewMode();
869  }
870 
871 
876  public function view()
877  {
878  global $DIC;
879 
880  $ilErr = $DIC['ilErr'];
881  $ilTabs = $DIC['ilTabs'];
882 
883  $ilTabs->activateTab("id_content");
884 
885  $this->checkPermission('read');
886 
887  if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
888  parent::view();
889  return true;
890  } else {
891  switch ((int) $_REQUEST['view_mode']) {
892  case self::VIEW_MODE_MANAGE:
893  $this->manage();
894  break;
895 
896  case self::VIEW_MODE_SORT:
897  // #14638
898  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
900  $this->sort();
901  break;
902  }
903  // fallthrough
904 
905  // no break
906  default:
907  $this->showLinks();
908  break;
909  }
910  }
911  $GLOBALS['DIC']['tpl']->setPermanentLink($this->object->getType(), $this->object->getRefId());
912  return true;
913  }
914 
919  protected function manage()
920  {
921  $this->checkPermission('write');
922  $this->activateTabs('content', 'id_content_manage');
923 
924  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.webr_manage.html', 'Modules/WebResource');
925  $this->showToolbar('ACTION_BUTTONS');
926 
927  include_once './Modules/WebResource/classes/class.ilWebResourceEditableLinkTableGUI.php';
928  $table = new ilWebResourceEditableLinkTableGUI($this, 'view');
929  $table->parse();
930 
931  include_once './Services/Link/classes/class.ilInternalLinkGUI.php';
933 
934  $this->tpl->addJavaScript("Modules/WebResource/js/intLink.js");
935  $this->tpl->addJavascript("Services/Form/js/Form.js");
936 
937  $this->tpl->setVariable('TABLE_LINKS', $table->getHTML() . $js);
938  }
939 
944  protected function showLinks()
945  {
946  $this->checkPermission('read');
947  $this->activateTabs('content', 'id_content_view');
948 
949  include_once './Modules/WebResource/classes/class.ilWebResourceLinkTableGUI.php';
950  $table = new ilWebResourceLinkTableGUI($this, 'showLinks');
951  $table->parse();
952 
953  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.webr_view.html', 'Modules/WebResource');
954  $this->showToolbar('ACTION_BUTTONS');
955  $this->tpl->setVariable('LINK_TABLE', $table->getHTML());
956  }
957 
962  protected function sort()
963  {
964  $this->checkPermission('write');
965  $this->activateTabs('content', 'id_content_ordering');
966 
967  include_once './Modules/WebResource/classes/class.ilWebResourceLinkTableGUI.php';
968  $table = new ilWebResourceLinkTableGUI($this, 'sort', true);
969  $table->parse();
970 
971  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.webr_view.html', 'Modules/WebResource');
972  $this->showToolbar('ACTION_BUTTONS');
973  $this->tpl->setVariable('LINK_TABLE', $table->getHTML());
974  }
975 
980  protected function saveSorting()
981  {
982  $this->checkPermission('write');
983 
984  include_once './Services/Container/classes/class.ilContainerSorting.php';
985  $sort = ilContainerSorting::_getInstance($this->object->getId());
986  $sort->savePost((array) $_POST['position']);
987 
988  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
989  $this->view();
990  }
991 
992 
998  protected function showToolbar($a_tpl_var)
999  {
1000  if (!$this->checkPermissionBool('write')) {
1001  return;
1002  }
1003 
1004  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
1005  $tool = new ilToolbarGUI();
1006  $tool->setFormAction($this->ctrl->getFormAction($this));
1007  $tool->addButton(
1008  $this->lng->txt('webr_add'),
1009  $this->ctrl->getLinkTarget($this, 'addLink')
1010  );
1011 
1012  $this->tpl->setVariable($a_tpl_var, $tool->getHTML());
1013  return;
1014  }
1015 
1020  protected function confirmDeleteLink()
1021  {
1022  $this->checkPermission('write');
1023  $this->activateTabs('content', 'id_content_view');
1024 
1025  $link_ids = array();
1026 
1027  if (is_array($_POST['link_ids'])) {
1028  $link_ids = $_POST['link_ids'];
1029  } elseif (isset($_GET['link_id'])) {
1030  $link_ids = array($_GET['link_id']);
1031  }
1032 
1033  if (!count($link_ids) > 0) {
1034  ilUtil::sendFailure($this->lng->txt('select_one'));
1035  $this->view();
1036  return false;
1037  }
1038 
1039  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1040  $links = new ilLinkResourceItems($this->object->getId());
1041 
1042  include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1043  $confirm = new ilConfirmationGUI();
1044  $confirm->setFormAction($this->ctrl->getFormAction($this, 'view'));
1045  $confirm->setHeaderText($this->lng->txt('webr_sure_delete_items'));
1046  $confirm->setConfirm($this->lng->txt('delete'), 'deleteLinks');
1047  $confirm->setCancel($this->lng->txt('cancel'), 'view');
1048 
1049  foreach ($link_ids as $link_id) {
1050  $link = $links->getItem($link_id);
1051  $confirm->addItem('link_ids[]', $link_id, $link['title']);
1052  }
1053  $this->tpl->setContent($confirm->getHTML());
1054  }
1055 
1060  protected function deleteLinks()
1061  {
1062  global $DIC;
1063 
1064  $ilCtrl = $DIC['ilCtrl'];
1065 
1066  $this->checkPermission('write');
1067 
1068  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1069  $links = new ilLinkResourceItems($this->object->getId());
1070 
1071  foreach ($_POST['link_ids'] as $link_id) {
1072  $links->delete($link_id);
1073  }
1074  ilUtil::sendSuccess($this->lng->txt('webr_deleted_items'), true);
1075  $ilCtrl->redirect($this, 'view');
1076  }
1077 
1082  protected function deactivateLink()
1083  {
1084  global $DIC;
1085 
1086  $ilCtrl = $DIC['ilCtrl'];
1087 
1088  $this->checkPermission('write');
1089 
1090  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1091  $links = new ilLinkResourceItems($this->object->getId());
1092 
1093  if (!$_GET['link_id']) {
1094  ilUtil::sendFailure($this->lng->txt('select_one'), true);
1095  $ilCtrl->redirect($this, 'view');
1096  }
1097 
1098  $links->setLinkId((int) $_GET['link_id']);
1099  $links->updateActive(false);
1100 
1101  ilUtil::sendSuccess($this->lng->txt('webr_inactive_success'), true);
1102  $ilCtrl->redirect($this, 'view');
1103  }
1104 
1105 
1111  public function infoScreen()
1112  {
1113  $this->ctrl->setCmd("showSummary");
1114  $this->ctrl->setCmdClass("ilinfoscreengui");
1115  $this->infoScreenForward();
1116  }
1117 
1121  public function infoScreenForward()
1122  {
1123  global $DIC;
1124 
1125  $ilTabs = $DIC['ilTabs'];
1126 
1127  if (!$this->checkPermissionBool('visible')) {
1128  $this->checkPermission('read');
1129  }
1130  $ilTabs->activateTab('id_info');
1131 
1132  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1133  $info = new ilInfoScreenGUI($this);
1134 
1135  $info->enablePrivateNotes();
1136 
1137  // standard meta data
1138  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
1139 
1140  if ($this->id_type == self::WORKSPACE_NODE_ID) {
1141  $info->addProperty($this->lng->txt("perma_link"), $this->getPermanentLinkWidget());
1142  }
1143 
1144  // forward the command
1145  $this->ctrl->forwardCommand($info);
1146  }
1147 
1148 
1149  public function history()
1150  {
1151  global $DIC;
1152 
1153  $ilTabs = $DIC['ilTabs'];
1154 
1155  $this->checkPermission('write');
1156  $ilTabs->activateTab('id_history');
1157 
1158  include_once("./Services/History/classes/class.ilHistoryTableGUI.php");
1159  $hist_gui = new ilHistoryTableGUI($this, "history", $this->object->getId(), $this->object->getType);
1160  $hist_gui->initTable();
1161  $this->tpl->setContent($hist_gui->getHTML());
1162  }
1163 
1172  public function formatInvalidLinkArray(array $row)
1173  {
1174  $this->object->items_obj->readItem($row['page_id']);
1175  $row['title'] = $this->object->items_obj->getTitle();
1176 
1177  require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
1179  $actions->setSelectionHeaderClass('small');
1180  $actions->setItemLinkClass('xsmall');
1181  $actions->setListTitle($this->lng->txt('actions'));
1182  $actions->setId($row['page_id']);
1183  $this->ctrl->setParameter($this, 'link_id', $row['page_id']);
1184  $actions->addItem(
1185  $this->lng->txt('edit'),
1186  '',
1187  $this->ctrl->getLinkTarget($this, 'editLink')
1188  );
1189  $this->ctrl->clearParameters($this);
1190  $row['action_html'] = $actions->getHTML();
1191 
1192  return $row;
1193  }
1194 
1199  protected function linkChecker()
1200  {
1201  global $DIC;
1202 
1203  $ilias = $DIC['ilias'];
1204  $ilUser = $DIC['ilUser'];
1205  $tpl = $DIC['tpl'];
1206  $ilTabs = $DIC['ilTabs'];
1207 
1208  $this->checkPermission('write');
1209  $ilTabs->activateTab('id_link_check');
1210 
1211  $this->__initLinkChecker();
1212  $this->object->initLinkResourceItemsObject();
1213 
1214  require_once './Services/LinkChecker/classes/class.ilLinkCheckerTableGUI.php';
1215 
1216  $toolbar = new ilToolbarGUI();
1217 
1218  if ((bool) $ilias->getSetting('cron_web_resource_check')) {
1219  include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
1220  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
1221 
1222  $chb = new ilCheckboxInputGUI($this->lng->txt('link_check_message_a'), 'link_check_message');
1223  $chb->setValue(1);
1224  $chb->setChecked((bool) ilLinkCheckNotify::_getNotifyStatus($ilUser->getId(), $this->object->getId()));
1225  $chb->setOptionTitle($this->lng->txt('link_check_message_b'));
1226 
1227  $toolbar->addInputItem($chb);
1228  $toolbar->addFormButton($this->lng->txt('save'), 'saveLinkCheck');
1229  $toolbar->setFormAction($this->ctrl->getLinkTarget($this, 'saveLinkCheck'));
1230  }
1231 
1232  $tgui = new ilLinkCheckerTableGUI($this, 'linkChecker');
1233  $tgui->setLinkChecker($this->link_checker_obj)
1234  ->setRowHandler($this)
1235  ->setRefreshButton($this->lng->txt('refresh'), 'refreshLinkCheck');
1236 
1237  return $tpl->setContent($tgui->prepareHTML()->getHTML() . $toolbar->getHTML());
1238  }
1239 
1240  public function saveLinkCheck()
1241  {
1242  global $DIC;
1243 
1244  $ilDB = $DIC['ilDB'];
1245  $ilUser = $DIC['ilUser'];
1246 
1247  include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
1248 
1249  $link_check_notify = new ilLinkCheckNotify($ilDB);
1250  $link_check_notify->setUserId($ilUser->getId());
1251  $link_check_notify->setObjId($this->object->getId());
1252 
1253  if ($_POST['link_check_message']) {
1254  ilUtil::sendSuccess($this->lng->txt('link_check_message_enabled'));
1255  $link_check_notify->addNotifier();
1256  } else {
1257  ilUtil::sendSuccess($this->lng->txt('link_check_message_disabled'));
1258  $link_check_notify->deleteNotifier();
1259  }
1260  $this->linkChecker();
1261 
1262  return true;
1263  }
1264 
1265 
1266 
1267  public function refreshLinkCheck()
1268  {
1269  $this->__initLinkChecker();
1270  $this->object->initLinkResourceItemsObject();
1271 
1272  // Set all link to valid. After check invalid links will be set to invalid
1273  $this->object->items_obj->updateValidByCheck();
1274 
1275  foreach ($this->link_checker_obj->checkWebResourceLinks() as $invalid) {
1276  $this->object->items_obj->readItem($invalid['page_id']);
1277  $this->object->items_obj->setActiveStatus(false);
1278  $this->object->items_obj->setValidStatus(false);
1279  $this->object->items_obj->update(false);
1280  }
1281 
1282  $this->object->items_obj->updateLastCheck();
1283  ilUtil::sendSuccess($this->lng->txt('link_checker_refreshed'));
1284 
1285  $this->linkChecker();
1286 
1287  return true;
1288  }
1289 
1290  public function __initLinkChecker()
1291  {
1292  global $DIC;
1293 
1294  $ilDB = $DIC['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 $DIC;
1314 
1315  $ilCtrl = $DIC['ilCtrl'];
1316  $ilTabs = $DIC['ilTabs'];
1317  $lng = $DIC['lng'];
1318 
1319  switch ($a_active_tab) {
1320  case 'content':
1321  if ($this->checkPermissionBool('write')) {
1322  $this->lng->loadLanguageModule('cntr');
1323 
1324  $this->ctrl->setParameter($this, 'switch_mode', self::VIEW_MODE_VIEW);
1325  $ilTabs->addSubTab(
1326  'id_content_view',
1327  $lng->txt('view'),
1328  $this->ctrl->getLinkTarget($this, 'switchViewMode')
1329  );
1330  $this->ctrl->setParameter($this, 'switch_mode', self::VIEW_MODE_MANAGE);
1331  $ilTabs->addSubTab(
1332  'id_content_manage',
1333  $lng->txt('cntr_manage'),
1334  $this->ctrl->getLinkTarget($this, 'switchViewMode')
1335  );
1336  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1337  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
1338  include_once './Services/Container/classes/class.ilContainer.php';
1339  if ((ilLinkResourceItems::lookupNumberOfLinks($this->object->getId()) > 1)
1341  $this->ctrl->setParameter($this, 'switch_mode', self::VIEW_MODE_SORT);
1342  $ilTabs->addSubTab(
1343  'id_content_ordering',
1344  $this->lng->txt('cntr_ordering'),
1345  $this->ctrl->getLinkTarget($this, 'switchViewMode')
1346  );
1347  }
1348 
1349  $ilCtrl->clearParameters($this);
1350  $ilTabs->activateSubTab($a_active_subtab);
1351  }
1352  }
1353 
1354  $ilTabs->activateTab('id_content');
1355  }
1356 
1357 
1362  public function setTabs()
1363  {
1364  global $DIC;
1365 
1366  $ilTabs = $DIC['ilTabs'];
1367  $lng = $DIC['lng'];
1368  $ilHelp = $DIC['ilHelp'];
1369 
1370  $ilHelp->setScreenIdComponent("webr");
1371 
1372  if ($this->checkPermissionBool('read')) {
1373  $ilTabs->addTab(
1374  "id_content",
1375  $lng->txt("content"),
1376  $this->ctrl->getLinkTarget($this, "view")
1377  );
1378  }
1379 
1380  if (
1381  $this->checkPermissionBool('visible') ||
1382  $this->checkPermissionBool('read')
1383  ) {
1384  $ilTabs->addTab(
1385  "id_info",
1386  $lng->txt("info_short"),
1387  $this->ctrl->getLinkTarget($this, "infoScreen")
1388  );
1389  }
1390 
1391  if ($this->checkPermissionBool('write') and !$this->getCreationMode()) {
1392  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1393  if (ilLinkResourceItems::lookupNumberOfLinks($this->object->getId()) > 1) {
1394  $ilTabs->addTab(
1395  "id_settings",
1396  $lng->txt("settings"),
1397  $this->ctrl->getLinkTarget($this, "settings")
1398  );
1399  }
1400  }
1401 
1402  if ($this->checkPermissionBool('write')) {
1403  $ilTabs->addTab(
1404  "id_history",
1405  $lng->txt("history"),
1406  $this->ctrl->getLinkTarget($this, "history")
1407  );
1408  }
1409 
1410  if ($this->checkPermissionBool('write')) {
1411  // Check if pear library is available
1412  $ilTabs->addTab(
1413  "id_link_check",
1414  $lng->txt("link_check"),
1415  $this->ctrl->getLinkTarget($this, "linkChecker")
1416  );
1417  }
1418 
1419  if ($this->checkPermissionBool('write')) {
1420  include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
1421  $mdgui = new ilObjectMetaDataGUI($this->object);
1422  $mdtab = $mdgui->getTab();
1423  if ($mdtab) {
1424  $ilTabs->addTab(
1425  "id_meta_data",
1426  $lng->txt("meta_data"),
1427  $mdtab
1428  );
1429  }
1430  }
1431 
1432  if ($this->checkPermissionBool('write')) {
1433  $ilTabs->addTab(
1434  'export',
1435  $this->lng->txt('export'),
1436  $this->ctrl->getLinkTargetByClass('ilexportgui', '')
1437  );
1438  }
1439 
1440  // will add permission tab if needed
1441  parent::setTabs();
1442  }
1443 
1444  // PRIVATE
1445  public function __prepareOutput()
1446  {
1447  // output objects
1448  // $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
1449  // $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
1450 
1451  $this->tpl->setLocator();
1452 
1453  // output message
1454  if ($this->message) {
1455  ilUtil::sendInfo($this->message);
1456  }
1457 
1458  // display infopanel if something happened
1460  ;
1461  }
1462 
1463  public function addLocatorItems()
1464  {
1465  global $DIC;
1466 
1467  $ilLocator = $DIC['ilLocator'];
1468 
1469  if (is_object($this->object)) {
1470  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this), "", $this->object->getRefId(), "webr");
1471  }
1472  }
1473 
1474  protected function handleSubItemLinks($a_target)
1475  {
1476  // #15647 - handle internal links
1477  include_once "Services/Form/classes/class.ilFormPropertyGUI.php";
1478  include_once "Services/Form/classes/class.ilLinkInputGUI.php";
1479 
1480  if (ilLinkInputGUI::isInternalLink($a_target)) {
1481  include_once("./Services/Link/classes/class.ilLink.php");
1482 
1483  // #10612
1484  $parts = explode("|", $a_target);
1485 
1486  if ($parts[0] == 'wpage') {
1487  return ilLink::_getStaticLink(
1488  0,
1489  'wiki',
1490  true,
1491  '&target=wiki_wpage_' . $parts[1]
1492  );
1493  }
1494 
1495  if ($parts[0] == "term") {
1496  // #16894
1497  return ilLink::_getStaticLink(
1498  0,
1499  "git",
1500  true,
1501  "&target=git_" . $parts[1]
1502  );
1503  }
1504 
1505  if ($parts[0] == "page") {
1506  $parts[0] = "pg";
1507  }
1508 
1509  $a_target = ilLink::_getStaticLink($parts[1], $parts[0]);
1510  }
1511 
1512  return $a_target;
1513  }
1514 
1515  public function callDirectLink()
1516  {
1517  $obj_id = $this->object->getId();
1518 
1519  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1522  if ($url["target"]) {
1523  $url["target"] = $this->handleSubItemLinks($url["target"]);
1524 
1525  include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
1528  }
1529 
1530  $this->redirectToLink($this->ref_id, $obj_id, $url["target"]);
1531  }
1532  }
1533  }
1534 
1535  public function callLink()
1536  {
1537  if ($_REQUEST["link_id"]) {
1538  $obj_id = $this->object->getId();
1539 
1540  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1541  $items = new ilLinkResourceItems($obj_id);
1542  $item = $items->getItem($_REQUEST["link_id"]);
1543  if ($item["target"]) {
1544  $item["target"] = $this->handleSubItemLinks($item["target"]);
1545 
1546  include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
1548  $item = ilParameterAppender::_append($item);
1549  }
1550  ilLoggerFactory::getLogger('webr')->debug('Redirecting to: ' . $item['target']);
1551  $this->redirectToLink($this->ref_id, $obj_id, $item["target"]);
1552  }
1553  }
1554  }
1555 
1556  protected function redirectToLink($a_ref_id, $a_obj_id, $a_url)
1557  {
1558  global $DIC;
1559 
1560  $ilUser = $DIC['ilUser'];
1561 
1562  if ($a_url) {
1563  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1565  "webr",
1566  $a_ref_id,
1567  $a_obj_id,
1568  $ilUser->getId()
1569  );
1570 
1571  ilUtil::redirect($a_url);
1572  }
1573  }
1574 
1575  public function exportHTML()
1576  {
1577  global $DIC;
1578 
1579  $ilSetting = $DIC['ilSetting'];
1580 
1581  $tpl = new ilTemplate("tpl.export_html.html", true, true, "Modules/WebResource");
1582 
1583  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1584  $items = new ilLinkResourceItems($this->object->getId());
1585  foreach ($items->getAllItems() as $item) {
1586  if (!$item["active"]) {
1587  continue;
1588  }
1589 
1590  $target = $this->handleSubItemLinks($item["target"]);
1591 
1592  $tpl->setCurrentBlock("link_bl");
1593  $tpl->setVariable("LINK_URL", $target);
1594  $tpl->setVariable("LINK_TITLE", $item["title"]);
1595  $tpl->setVariable("LINK_DESC", $item["description"]);
1596  $tpl->setVariable("LINK_CREATE", $item["create_date"]);
1597  $tpl->setVariable("LINK_UPDATE", $item["last_update"]);
1598  $tpl->parseCurrentBlock();
1599  }
1600 
1601  $tpl->setVariable("CREATE_DATE", $this->object->getCreateDate());
1602  $tpl->setVariable("LAST_UPDATE", $this->object->getLastUpdateDate());
1603  $tpl->setVariable("TXT_TITLE", $this->object->getTitle());
1604  $tpl->setVariable("TXT_DESC", $this->object->getLongDescription());
1605 
1606  $tpl->setVariable("INST_ID", ($ilSetting->get('short_inst_name') != "")
1607  ? $ilSetting->get('short_inst_name')
1608  : "ILIAS");
1609 
1610  ilUtil::deliverData($tpl->get(), "bookmarks.html");
1611  }
1612 
1613  public static function _goto($a_target, $a_additional = null)
1614  {
1615  global $DIC;
1616 
1617  $ilAccess = $DIC['ilAccess'];
1618  $ilErr = $DIC['ilErr'];
1619  $lng = $DIC['lng'];
1620 
1621  if ($a_additional && substr($a_additional, -3) == "wsp") {
1622  $_GET["baseClass"] = "ilsharedresourceGUI";
1623  $_GET["wsp_id"] = $a_target;
1624  include("ilias.php");
1625  exit;
1626  }
1627 
1628  // Will be replaced in future releases by ilAccess::checkAccess()
1629  if ($ilAccess->checkAccess("read", "", $a_target)) {
1630  ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=$a_target");
1631  } else {
1632  // to do: force flat view
1633  if ($ilAccess->checkAccess("visible", "", $a_target)) {
1634  ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=" . $a_target . "&cmd=infoScreen");
1635  } else {
1636  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1637  ilUtil::sendFailure(sprintf(
1638  $lng->txt("msg_no_perm_read_item"),
1640  ), true);
1642  }
1643  }
1644  }
1645 
1646  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1647  }
1648 } // END class.ilObjLinkResource
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
This class represents an option in a radio group.
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
infoScreen()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
static _isSingular($a_webr_id)
Check whether there is only one active link in the web resource.
Class ilObjectMetaDataGUI.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
static getInitHTML($a_url)
Get initialisation HTML to use interna link editing.
TableGUI class for search results.
Class ilInfoScreenGUI.
settings()
Edit settings Title, Description, Sorting.
updateLink()
Save after editing.
$js
This class represents a selection list property in a property form.
This class represents a property form user interface.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
New implementation of ilObjectGUI.
GUI class for the workflow of copying objects.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
saveSorting()
Save nmanual sorting.
This class represents a section header in a property form.
static _getOptionSelect()
Get options as array.
setInfo($a_info)
Set Information Text.
checkLinkInput($a_mode, $a_webr_id=0, $a_link_id=0)
Check input after creating a new link.
$valid
static lookupNumberOfLinks($a_webr_id)
Get number of assigned links.
getPermanentLinkWidget($a_append=null, $a_center=false)
if(!array_key_exists('StateId', $_REQUEST)) $id
setValue($a_value)
Set Value.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
Class ilObjLinkResourceGUI.
setInternalLinkFilterTypes(array $a_val)
Set internal link filter types.
This class represents a checkbox property in a property form.
addLink()
Add an additional link.
static _lookupTitle($a_id)
lookup object title
class for checking external links in page objects Normally used in Cron jobs, but should be extensibl...
Class ilInternalLinkGUI.
infoScreenForward()
show information screen
class for checking external links in page objects.
initFormSettings()
Show settings form.
linkChecker()
Show link validation.
afterSave(ilObject $a_new_object)
showLinks()
Show all active links.
global $ilCtrl
Definition: ilias.php:18
class ilLinkCheckerTableGUI
static _append($a_link_data)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$section
Definition: Utf8Test.php:83
setChecked($a_checked)
Set Checked.
Export User Interface Class.
This class represents a property in a property form.
static parameterToInfo($a_name, $a_value)
Get info text describing an existing dynamic link.
if(isset($_POST['submit'])) $form
getId()
get object id public
switchViewMode()
Switch between "View" "Manage" and "Sort".
$values
editLinks()
Start with manage mode.
static _lookupObjId($a_id)
setValue($a_value)
Set Value.
special template class to simplify handling of ITX/PEAR
static isInternalLink($a_value)
setSize($a_size)
Set Size.
This class represents a text property in a property form.
static lookupItem($a_webr_id, $a_link_id)
static infoPanel($a_keep=true)
$ilUser
Definition: imgupload.php:18
const LINKS_ERR_NO_VALUE
editLink()
Edit a single link.
interface ilLinkCheckerGUIRowHandling
deleteParameter()
Delete a dynamic parameter.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
isContainerMetaDataRequired()
Check if a new container title is required Necessary if there is more than one link.
setOptions($a_options)
Set Options.
const LINKS_ERR_NO_NAME
setValuesFromLink($a_link_id)
Set form values from link.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
saveSettings()
Save container settings.
$row
static _getFirstLink($a_webr_id)
Get first link item Check before with _isSingular() if there is more or less than one...
User interface class for advanced drop-down selection lists.
Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE Date: 24.10.14 Time: 10:35.
exit
Definition: backend.php:16
This class represents a custom property in a property form.
static _getNotifyStatus($a_usr_id, $a_obj_id)
static _fillHTMLMetaTags($a_rbac_id, $a_obj_id, $a_type)
Fill html meta tags.
This class represents a non editable value in a property form.
global $ilSetting
Definition: privfeed.php:17
This class represents a text area property in a property form.
global $ilDB
$ret
Definition: parser.php:6
Class ilObjLinkResourceGUI.
getRefId()
get reference id public
prepareOutput($a_show_subobjects=true)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
Class ilParameterAppender.
const LINKS_ERR_NO_NAME_VALUE
static _goto($a_target, $a_additional=null)
static getLogger($a_component_id)
Get component logger.
$url
static _lookupSortMode($a_obj_id)
lookup sort mode
redirectToLink($a_ref_id, $a_obj_id, $a_url)
static _getInstance($a_obj_id)
get instance by obj_id
$links
if(empty($password)) $table
Definition: pwgen.php:24
initFormLink($a_mode)
Show create/edit single link.
activateTabs($a_active_tab, $a_active_subtab='')
Activate tab and subtabs.
$info
Definition: index.php:5
setValue($a_value)
Set Value.
static redirect($a_script)
updateLinks()
Update all visible links.
save()
Save new object public.
static _getParams($a_link_id)
Get dynamic parameter definitions.
static _isEnabled()
Check if dynamic parameters are enabled.
$target
Definition: test.php:19
addHeaderAction()
Add header action menu.
$_POST["username"]
setRequired($a_required)
Set Required.
This class represents a external and/or internal link in a property form.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
showToolbar($a_tpl_var)
Show toolbar.
Confirmation screen class.
confirmDeleteLink()
Show delete confirmation screen.