ILIAS  release_7 Revision v7.30-3-g800a261c036
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
5require_once "./Services/Object/classes/class.ilObject2GUI.php";
6include_once('./Modules/WebResource/classes/class.ilParameterAppender.php');
7require_once 'Services/LinkChecker/interfaces/interface.ilLinkCheckerGUIRowHandling.php';
8
23{
24 const VIEW_MODE_VIEW = 1;
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;
33
34 public function getType()
35 {
36 return "webr";
37 }
38
39 public function executeCommand()
40 {
41 global $DIC;
42
43 $ilCtrl = $DIC['ilCtrl'];
44 $ilTabs = $DIC['ilTabs'];
45 $ilErr = $DIC['ilErr'];
46 $ilAccess = $DIC['ilAccess'];
47
48
49 //if($this->ctrl->getTargetScript() == 'link_resources.php')
50 if ($_GET["baseClass"] == 'ilLinkResourceHandlerGUI') {
51 $_GET['view_mode'] = isset($_GET['switch_mode']) ? $_GET['switch_mode'] : $_GET['view_mode'];
52 $ilCtrl->saveParameter($this, 'view_mode');
53 $this->__prepareOutput();
54 }
55
56 $this->lng->loadLanguageModule("webr");
57
58 $next_class = $this->ctrl->getNextClass($this);
59 $cmd = $this->ctrl->getCmd();
60
61 switch ($next_class) {
62 case "ilinfoscreengui":
63 $this->prepareOutput();
64 $this->infoScreenForward(); // forwards command
65 break;
66
67 case 'ilobjectmetadatagui':
68 $this->checkPermission('write'); // #18563
69 $this->prepareOutput();
70 $ilTabs->activateTab('id_meta_data');
71 include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
72 $md_gui = new ilObjectMetaDataGUI($this->object);
73 $this->ctrl->forwardCommand($md_gui);
74 break;
75
76 case 'ilpermissiongui':
77 $this->prepareOutput();
78 $ilTabs->activateTab('id_permissions');
79 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
80 $perm_gui = new ilPermissionGUI($this);
81 $ret = &$this->ctrl->forwardCommand($perm_gui);
82 break;
83
84 case 'ilobjectcopygui':
85 $this->prepareOutput();
86 include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
87 $cp = new ilObjectCopyGUI($this);
88 $cp->setType('webr');
89 $this->ctrl->forwardCommand($cp);
90 break;
91
92 case 'ilexportgui':
93 $this->prepareOutput();
94 $this->tabs_gui->setTabActive('export');
95 include_once './Services/Export/classes/class.ilExportGUI.php';
96 $exp = new ilExportGUI($this);
97 $exp->addFormat('xml');
98 $this->ctrl->forwardCommand($exp);
99 break;
100
101 case "ilcommonactiondispatchergui":
102 $this->prepareOutput();
104 $this->ctrl->forwardCommand($gui);
105 break;
106
107 case "ilpropertyformgui":
108 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
109 $this->initFormLink(self::LINK_MOD_EDIT);
110 $this->ctrl->forwardCommand($this->form);
111 break;
112
113 case "ilinternallinkgui":
114 $this->lng->loadLanguageModule("content");
115 require_once("./Services/Link/classes/class.ilInternalLinkGUI.php");
116 $link_gui = new ilInternalLinkGUI("RepositoryItem", 0);
117 $link_gui->filterLinkType("PageObject");
118 $link_gui->filterLinkType("GlossaryItem");
119 $link_gui->filterLinkType("RepositoryItem");
120 $link_gui->setFilterWhiteList(true);
121 $ilCtrl->forwardCommand($link_gui);
122 break;
123
124 default:
125 if (!$cmd) {
126 $this->ctrl->setCmd("view");
127 }
128 parent::executeCommand();
129 }
130
131 if (!$this->getCreationMode()) {
132 // Fill meta header tags
133 include_once('Services/MetaData/classes/class.ilMDUtils.php');
134 ilMDUtils::_fillHTMLMetaTags($this->object->getId(), $this->object->getId(), 'webr');
135
136 $this->addHeaderAction();
137 }
138 return true;
139 }
140
141 protected function initCreateForm($a_new_type)
142 {
143 $this->initFormLink(self::LINK_MOD_CREATE);
144 return $this->form;
145 }
146
151 public function save()
152 {
153 global $DIC;
154
155 $ilCtrl = $DIC['ilCtrl'];
156
157 $this->initFormLink(self::LINK_MOD_CREATE);
158 $valid = $this->form->checkInput();
159 if ($this->checkLinkInput(self::LINK_MOD_CREATE, $valid, 0, 0)
160 && $this->form->getInput('tar_mode_type') == 'single') {
161 // Save new object
162 parent::save();
163 } elseif ($valid && $this->form->getInput('tar_mode_type') == 'list') {
164 $this->initList(self::LINK_MOD_CREATE, 0);
165 parent::save();
166 } else {
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 if ($this->form->getInput('tar_mode_type') == 'single') {
177 // Save link
178 $this->link->setLinkResourceId($a_new_object->getId());
179 $link_id = $this->link->add();
180 $this->link->updateValid(true);
181
182 ilUtil::sendSuccess($this->lng->txt('webr_link_added'));
183 }
184
185 if ($this->form->getInput('tar_mode_type') == 'list') {
186 // Save list
187 $this->list->setListResourceId($a_new_object->getId());
188 $this->list->add();
189
190 ilUtil::sendSuccess($this->lng->txt('webr_list_added'));
191 }
192
193 // personal workspace
194 if ($this->id_type == self::WORKSPACE_NODE_ID) {
195 $this->ctrl->redirect($this, "editLinks");
196 }
197 // repository
198 else {
199 ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=" .
200 $a_new_object->getRefId() . "&cmd=switchViewMode&switch_mode=2");
201 }
202 }
203
209 protected function settings()
210 {
211 global $DIC;
212
213 $ilTabs = $DIC['ilTabs'];
214
215 $this->checkPermission('write');
216 $ilTabs->activateTab('id_settings');
217
218 $this->initFormSettings();
219 $this->tpl->setContent($this->form->getHTML());
220 }
221
226 protected function saveSettings()
227 {
228 global $DIC;
229
230 $obj_service = $this->object_service;
231 $ilTabs = $DIC['ilTabs'];
232
233 $this->checkPermission('write');
234 $ilTabs->activateTab('id_settings');
235
236 $this->initFormSettings();
237 $valid = $this->form->checkInput();
238 if ($valid) {
239 // update list
240 $this->initList(self::LINK_MOD_EDIT_LIST, $this->object->getId());
241 $this->list->update();
242
243 // update object
244 $this->object->setTitle($this->form->getInput('title'));
245 $this->object->setDescription($this->form->getInput('desc'));
246 $this->object->update();
247
248 // update sorting
249 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
250 $sort = new ilContainerSortingSettings($this->object->getId());
251 $sort->setSortMode($this->form->getInput('sor'));
252 $sort->update();
253
254 // tile image
255 $obj_service->commonSettings()->legacyForm($this->form, $this->object)->saveTileImage();
256
257
258 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
259 $this->ctrl->redirect($this, 'settings');
260 }
261
262 $this->form->setValuesByPost();
263 ilUtil::sendFailure($this->lng->txt('err_check_input'));
264 $this->tpl->setContent($this->form->getHTML());
265 }
266
267
272 protected function initFormSettings()
273 {
274 $obj_service = $this->object_service;
275
276 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
277 $this->form = new ilPropertyFormGUI();
278 $this->form->setFormAction($this->ctrl->getFormAction($this, 'saveSettings'));
279
280 if (ilLinkResourceList::checkListStatus($this->object->getId())) {
281 $this->form->setTitle($this->lng->txt('webr_edit_settings'));
282
283 // Title
284 $tit = new ilTextInputGUI($this->lng->txt('webr_list_title'), 'title');
285 $tit->setValue($this->object->getTitle());
286 $tit->setRequired(true);
287 $tit->setSize(40);
288 $tit->setMaxLength(127);
289 $this->form->addItem($tit);
290
291 // Description
292 $des = new ilTextAreaInputGUI($this->lng->txt('webr_list_desc'), 'desc');
293 $des->setValue($this->object->getDescription());
294 $des->setCols(40);
295 $des->setRows(3);
296 $this->form->addItem($des);
297
299 $section->setTitle($this->lng->txt('obj_presentation'));
300 $this->form->addItem($section);
301
302 // tile image
303 $obj_service->commonSettings()->legacyForm($this->form, $this->object)->addTileImage();
304
305 // Sorting
306 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
307 include_once './Services/Container/classes/class.ilContainer.php';
308
309 $sor = new ilRadioGroupInputGUI($this->lng->txt('webr_sorting'), 'sor');
310 $sor->setRequired(true);
311 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
312 $sor->setValue(ilContainerSortingSettings::_lookupSortMode($this->object->getId()));
313
314 $opt = new ilRadioOption(
315 $this->lng->txt('webr_sort_title'),
317 );
318 $sor->addOption($opt);
319
320 $opm = new ilRadioOption(
321 $this->lng->txt('webr_sort_manual'),
323 );
324 $sor->addOption($opm);
325 $this->form->addItem($sor);
326 } else {
327 $this->form->setTitle($this->lng->txt('obj_presentation'));
328
329 // hidden title
330 $tit = new ilHiddenInputGUI('title');
331 $tit->setValue($this->object->getTitle());
332 $this->form->addItem($tit);
333
334 // hidden description
335 $des = new ilHiddenInputGUI('desc');
336 $des->setValue($this->object->getDescription());
337 $this->form->addItem($des);
338
339 // tile image
340 $obj_service->commonSettings()->legacyForm($this->form, $this->object)->addTileImage();
341 }
342
343 $this->form->addCommandButton('saveSettings', $this->lng->txt('save'));
344 $this->form->addCommandButton('view', $this->lng->txt('cancel'));
345 }
346
347
352 public function editLink()
353 {
354 global $DIC;
355
356 $ilCtrl = $DIC['ilCtrl'];
357
358 $this->checkPermission('write');
359 $this->activateTabs('content', 'id_content_view');
360
361 if (!(int) $_GET['link_id']) {
362 ilUtil::sendFailure($this->lng->txt('select_one'), true);
363 $ilCtrl->redirect($this, 'view');
364 }
365
366 $this->initFormLink(self::LINK_MOD_EDIT);
367 $this->setValuesFromLink((int) $_GET['link_id']);
368 $this->tpl->setContent($this->form->getHTML());
369 }
370
375 public function updateLink()
376 {
377 global $DIC;
378
379 $ilCtrl = $DIC['ilCtrl'];
380
381 $this->initFormLink(self::LINK_MOD_EDIT);
382 $valid = $this->form->checkInput();
383 if ($this->checkLinkInput(self::LINK_MOD_EDIT, $valid, $this->object->getId(), (int) $_REQUEST['link_id'])) {
384 $this->link->setLinkId((int) $_REQUEST['link_id']);
385 $this->link->update();
386 if (ilParameterAppender::_isEnabled() and is_object($this->dynamic)) {
387 $this->dynamic->add((int) $_REQUEST['link_id']);
388 }
389
390 if (!ilLinkResourceList::checkListStatus($this->object->getId())) {
391 $this->object->setTitle($this->form->getInput('title'));
392 $this->object->setDescription($this->form->getInput('desc'));
393 $this->object->update();
394 }
395
396 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
397 $ilCtrl->redirect($this, 'view');
398 }
399 ilUtil::sendFailure($this->lng->txt('err_check_input'));
400 $this->form->setValuesByPost();
401 $this->tpl->setContent($this->form->getHTML());
402 }
403
407 public function getLinkToListModal()
408 {
409 global $DIC;
410
411 $f = $DIC->ui()->factory();
412 $r = $DIC->ui()->renderer();
413
414 // check if form was already set
415 if ($this->form == null) {
416 $this->initFormLink(self::LINK_MOD_SET_LIST);
417 }
418
419 $form_id = 'form_' . $this->form->getId();
420
421 $submit = $f->button()->primary($this->lng->txt('save'), '#')
422 ->withOnLoadCode(function ($id) use ($form_id) {
423 return "$('#{$id}').click(function() { $('#{$form_id}').submit(); return false; });";
424 });
425 $info = $f->messageBox()->info($this->lng->txt('webr_new_list_info'));
426
427 $modal = $f->modal()->roundtrip(
428 $this->lng->txt('webr_new_list'),
429 $f->legacy($r->render($info) . $this->form->getHTML())
430 )
431 ->withActionButtons([$submit]);
432
433 // modal triggers its show signal on load if form validation failed
434 if (isset($_POST['sbmt']) && $_POST['sbmt'] == 'submit') {
435 $modal = $modal->withOnLoad($modal->getShowSignal());
436 }
437
438 return $modal;
439 }
440
444 public function saveLinkList()
445 {
446 global $DIC;
447
448 $ilCtrl = $DIC['ilCtrl'];
449
450 $this->checkPermission('write');
451
452 $this->initFormLink(self::LINK_MOD_SET_LIST);
453 $valid = $this->form->checkInput();
454 if ($valid) {
455 // Save list data
456 $this->object->setTitle($this->form->getInput('lti'));
457 $this->object->setDescription($this->form->getInput('tde'));
458 $this->object->update();
459
460 // Save Link List
461 $this->initList(self::LINK_MOD_SET_LIST, $this->object->getId());
462 $this->list->add();
463 ilUtil::sendSuccess($this->lng->txt('webr_list_set'), true);
464 $ilCtrl->redirect($this, 'view');
465 }
466
467 // Error handling
468 ilUtil::sendFailure($this->lng->txt('err_check_input'), true);
469 $this->form->setValuesByPost();
470 $this->view();
471 }
472
477 public function addLink()
478 {
479 $this->checkPermission('write');
480 $this->activateTabs('content', 'id_content_view');
481
482 $this->initFormLink(self::LINK_MOD_ADD);
483 $this->tpl->setContent($this->form->getHTML());
484 }
485
490 public function saveAddLink()
491 {
492 global $DIC;
493
494 $ilCtrl = $DIC['ilCtrl'];
495
496 $this->checkPermission('write');
497
498 $this->initFormLink(self::LINK_MOD_ADD);
499 $valid = $this->form->checkInput();
500 if ($this->checkLinkInput(self::LINK_MOD_ADD, $valid, $this->object->getId(), 0)) {
501 // Save Link
502 $link_id = $this->link->add();
503 $this->link->updateValid(true);
504
505 // Dynamic parameters
506 if (ilParameterAppender::_isEnabled() and is_object($this->dynamic)) {
507 $this->dynamic->add($link_id);
508 }
509 ilUtil::sendSuccess($this->lng->txt('webr_link_added'), true);
510 $ilCtrl->redirect($this, 'view');
511 }
512 // Error handling
513 ilUtil::sendFailure($this->lng->txt('err_check_input'));
514 $this->form->setValuesByPost();
515
516 $this->activateTabs('content', 'id_content_view');
517 $this->tpl->setContent($this->form->getHTML());
518 }
519
524 protected function deleteParameter()
525 {
526 global $DIC;
527
528 $ilCtrl = $DIC['ilCtrl'];
529
530 $this->checkPermission('write');
531
532 $this->ctrl->setParameter($this, 'link_id', (int) $_GET['link_id']);
533
534 if (!isset($_GET['param_id'])) {
535 ilUtil::sendFailure($this->lng->txt('select_one'), true);
536 $ilCtrl->redirect($this, 'view');
537 }
538
539 include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
540 $param = new ilParameterAppender($this->object->getId());
541 $param->delete((int) $_GET['param_id']);
542
543 ilUtil::sendSuccess($this->lng->txt('links_parameter_deleted'), true);
544 $ilCtrl->redirect($this, 'editLinks');
545 }
546
547 protected function deleteParameterForm()
548 {
549 global $DIC;
550
551 $ilCtrl = $DIC['ilCtrl'];
552
553 $this->checkPermission('write');
554
555 if (!isset($_GET['param_id'])) {
556 ilUtil::sendFailure($this->lng->txt('select_one'), true);
557 $ilCtrl->redirect($this, 'view');
558 }
559
560 include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
561 $param = new ilParameterAppender($this->object->getId());
562 $param->delete((int) $_GET['param_id']);
563
564 ilUtil::sendSuccess($this->lng->txt('links_parameter_deleted'), true);
565 $ilCtrl->redirect($this, 'view');
566 }
567
568
573 protected function updateLinks()
574 {
575 global $DIC;
576
577 $ilCtrl = $DIC['ilCtrl'];
578
579 $this->checkPermission('write');
580 $this->activateTabs('content', '');
581
582 if (!is_array($_POST['ids'])) {
583 ilUtil::sendFailure($this->lng->txt('select_one'), true);
584 $ilCtrl->redirect($this, 'view');
585 }
586
587 // Validate
588 $invalid = array();
589 foreach ($_POST['ids'] as $link_id) {
590 $data = $_POST['links'][$link_id];
591
592 // handle internal links
593 if ($_POST['tar_' . $link_id . '_ajax_type'] &&
594 $_POST['tar_' . $link_id . '_ajax_id']) {
595 $data['tar'] = $_POST['links'][$link_id]['tar'] =
596 $_POST['tar_' . $link_id . '_ajax_type'] . '|' .
597 $_POST['tar_' . $link_id . '_ajax_id'];
598 }
599
600
601 if (!strlen($data['title'])) {
602 $invalid[] = $link_id;
603 continue;
604 }
605 if (!strlen($data['tar'])) {
606 $invalid[] = $link_id;
607 continue;
608 }
609 if ($data['nam'] and !$data['val']) {
610 $invalid[] = $link_id;
611 continue;
612 }
613 if (!$data['nam'] and $data['val']) {
614 $invalid[] = $link_id;
615 continue;
616 }
617 }
618
619 if (count($invalid)) {
620 ilUtil::sendFailure($this->lng->txt('err_check_input'));
621 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.webr_manage.html', 'Modules/WebResource');
622
623 include_once './Modules/WebResource/classes/class.ilWebResourceEditableLinkTableGUI.php';
624 $table = new ilWebResourceEditableLinkTableGUI($this, 'view');
625 $table->setInvalidLinks($invalid);
626 $table->parseSelectedLinks($_POST['ids']);
627 $table->updateFromPost();
628 $this->tpl->setVariable('TABLE_LINKS', $table->getHTML());
629 return false;
630 }
631
632 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
633 $links = new ilLinkResourceItems($this->object->getId());
634
635 // Save Settings
636 include_once './Services/Form/classes/class.ilFormPropertyGUI.php';
637 include_once './Services/Form/classes/class.ilLinkInputGUI.php';
638 foreach ($_POST['ids'] as $link_id) {
639 $data = $_POST['links'][$link_id];
640
641 $orig = ilLinkResourceItems::lookupItem($this->object->getId(), $link_id);
642
643 $links->setLinkId($link_id);
644 $links->setTitle(ilUtil::stripSlashes($data['title']));
645 $links->setDescription(ilUtil::stripSlashes($data['desc']));
646 $links->setTarget(str_replace('"', '', ilUtil::stripSlashes($data['tar'])));
647 $links->setActiveStatus((int) $data['act']);
648 $links->setDisableCheckStatus((int) $data['che']);
649 $links->setLastCheckDate($orig['last_check']);
650 $links->setValidStatus((int) $data['vali']);
651 $links->setInternal(ilLinkInputGUI::isInternalLink($data['tar']));
652 $links->update();
653
654 if (strlen($data['nam']) and $data['val']) {
655 $param = new ilParameterAppender($this->object->getId());
656 $param->setName(ilUtil::stripSlashes($data['nam']));
657 $param->setValue((int) $data['val']);
658 $param->add($link_id);
659 }
660
661 if (!ilLinkResourceList::checkListStatus($this->object->getId())) {
662 $this->object->setTitle(ilUtil::stripSlashes($data['title']));
663 $this->object->setDescription(ilUtil::stripSlashes($data['desc']));
664 $this->object->update();
665 }
666
667 // TODO: Dynamic parameters
668 }
669
670 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
671 $ilCtrl->redirect($this, 'view');
672 }
673
679 protected function setValuesFromLink($a_link_id)
680 {
681 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
682 $link = new ilLinkResourceItems($this->object->getId());
683
684 $values = $link->getItem($a_link_id);
685
687 }
688
689 $this->form->setValuesByArray(
690 array(
691 'title' => $values['title'],
692 'tar' => $values['target'],
693 'desc' => $values['description'],
694 'act' => (int) $values['active'],
695 'che' => (int) $values['disable_check'],
696 'vali' => (int) $values['valid']
697 )
698 );
699 }
700
707 protected function initList(int $a_mode, int $a_webr_id = 0)
708 {
709 if ($a_mode == self::LINK_MOD_CREATE || $a_mode == self::LINK_MOD_EDIT_LIST) {
710 $this->list = new ilLinkResourceList($a_webr_id);
711 $this->list->setTitle($this->form->getInput('title'));
712 $this->list->setDescription($this->form->getInput('desc'));
713 }
714
715 if ($a_mode == self::LINK_MOD_SET_LIST) {
716 $this->list = new ilLinkResourceList($a_webr_id);
717 $this->list->setTitle($this->form->getInput('lti'));
718 $this->list->setDescription($this->form->getInput('tde'));
719 }
720 }
721
722
731 protected function checkLinkInput($a_mode, $a_valid, $a_webr_id = 0, $a_link_id = 0)
732 {
733 $valid = $a_valid;
734
735 $link_input = $this->form->getInput('tar');
736
737 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
738 $this->link = new ilLinkResourceItems($a_webr_id);
739 $this->link->setTarget(str_replace('"', '', ilUtil::stripSlashes($link_input)));
740 $this->link->setTitle($this->form->getInput('title'));
741 $this->link->setDescription($this->form->getInput('desc'));
742 $this->link->setDisableCheckStatus($this->form->getInput('che'));
743 $this->link->setInternal(ilLinkInputGUI::isInternalLink($link_input));
744
745 if ($a_mode == self::LINK_MOD_CREATE) {
746 $this->link->setActiveStatus(true);
747 } else {
748 $this->link->setActiveStatus($this->form->getInput('act'));
749 }
750
751 if ($a_mode == self::LINK_MOD_EDIT) {
752 $this->link->setValidStatus($this->form->getInput('vali'));
753 } else {
754 $this->link->setValidStatus(true);
755 }
756
758 return $valid;
759 }
760
761 $this->dynamic = new ilParameterAppender($a_webr_id);
762 $this->dynamic->setName($this->form->getInput('nam'));
763 $this->dynamic->setValue($this->form->getInput('val'));
764 if (!$this->dynamic->validate()) {
765 switch ($this->dynamic->getErrorCode()) {
767 $this->form->getItemByPostVar('nam')->setAlert($this->lng->txt('links_no_name_given'));
768 return false;
769
771 $this->form->getItemByPostVar('val')->setAlert($this->lng->txt('links_no_value_given'));
772 return false;
773
775 // Nothing entered => no error
776 return $valid;
777 }
778 $this->dynamic = null;
779 }
780 return $valid;
781 }
782
783
789 protected function initFormLink($a_mode)
790 {
791 global $DIC;
792
793 $ilTabs = $DIC['ilTabs'];
794
795 $ilTabs->activateTab("id_content");
796
797 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
798 $this->form = new ilPropertyFormGUI();
799
800 switch ($a_mode) {
802 // Header
803 $this->ctrl->setParameter($this, 'new_type', 'webr');
804 $this->form->setTitle($this->lng->txt('webr_new_link'));
805 $this->form->setTableWidth('600px');
806
807 // Buttons
808 $this->form->addCommandButton('save', $this->lng->txt('webr_add'));
809 $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
810 break;
811
813 // Header
814 $this->form->setTitle($this->lng->txt('webr_new_link'));
815
816 // Buttons
817 $this->form->addCommandButton('saveAddLink', $this->lng->txt('webr_add'));
818 $this->form->addCommandButton('view', $this->lng->txt('cancel'));
819 break;
820
822 // Header
823 $this->ctrl->setParameter($this, 'link_id', (int) $_REQUEST['link_id']);
824 $this->form->setTitle($this->lng->txt('webr_edit'));
825
826 // Buttons
827 $this->form->addCommandButton('updateLink', $this->lng->txt('save'));
828 $this->form->addCommandButton('view', $this->lng->txt('cancel'));
829 break;
830 }
831
832 if ($a_mode == self::LINK_MOD_SET_LIST) {
833 $this->form->setValuesByPost();
834 $this->form->setFormAction($this->ctrl->getFormAction($this, 'saveLinkList'));
835 $this->form->setId(uniqid('form'));
836
837 // List Title
838 $title = new ilTextInputGUI($this->lng->txt('webr_list_title'), 'lti');
839 $title->setRequired(true);
840 $title->setSize(40);
841 $title->setMaxLength(127);
842 $this->form->addItem($title);
843
844 // List Description
845 $desc = new ilTextAreaInputGUI($this->lng->txt('webr_list_desc'), 'tde');
846 $desc->setRows(3);
847 $desc->setCols(40);
848 $this->form->addItem($desc);
849
850 $item = new ilHiddenInputGUI('sbmt');
851 $item->setValue('submit');
852 $this->form->addItem($item);
853 }
854
855
856 else {
857 $this->form->setFormAction($this->ctrl->getFormAction($this));
858
859 // Target
860 /*
861 $tar = new ilTextInputGUI($this->lng->txt('webr_link_target'),'tar');
862 $tar->setValue("http://");
863
864 $tar->setSize(40);
865 $tar->setMaxLength(500);
866 */
867 include_once 'Services/Form/classes/class.ilLinkInputGUI.php';
868 $tar = new ilLinkInputGUI($this->lng->txt('type'), 'tar'); // lng var
869 if ($a_mode == self::LINK_MOD_CREATE) {
870 $tar->setAllowedLinkTypes(ilLinkInputGUI::LIST);
871 }
872 $tar->setInternalLinkFilterTypes(
873 array(
874 "PageObject",
875 "GlossaryItem",
876 "RepositoryItem",
877 'WikiPage'
878 )
879 );
880 $tar->setExternalLinkMaxLength(1000);
881 $tar->setInternalLinkFilterTypes(array("PageObject", "GlossaryItem", "RepositoryItem"));
882 $tar->setRequired(true);
883 $this->form->addItem($tar);
884
885 // Title
886 $tit = new ilTextInputGUI($this->lng->txt('webr_link_title'), 'title');
887 $tit->setRequired(true);
888 $tit->setSize(40);
889 $tit->setMaxLength(127);
890 $this->form->addItem($tit);
891
892 // Description
893 $des = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
894 $des->setRows(3);
895 $des->setCols(40);
896 $this->form->addItem($des);
897
898
899 if ($a_mode != self::LINK_MOD_CREATE) {
900 // Active
901 $act = new ilCheckboxInputGUI($this->lng->txt('active'), 'act');
902 $act->setChecked(true);
903 $act->setValue(1);
904 $this->form->addItem($act);
905
906 // Check
907 $che = new ilCheckboxInputGUI($this->lng->txt('webr_disable_check'), 'che');
908 $che->setValue(1);
909 $this->form->addItem($che);
910 }
911
912 // Valid
913 if ($a_mode == self::LINK_MOD_EDIT) {
914 $val = new ilCheckboxInputGUI($this->lng->txt('valid'), 'vali');
915 $this->form->addItem($val);
916 }
917
918 if (ilParameterAppender::_isEnabled() && $a_mode != self::LINK_MOD_CREATE) {
919 $dyn = new ilNonEditableValueGUI($this->lng->txt('links_dyn_parameter'));
920 $dyn->setInfo($this->lng->txt('links_dynamic_info'));
921
922
923 if (count($links = ilParameterAppender::_getParams((int)$_GET['link_id']))) {
924 $ex = new ilCustomInputGUI($this->lng->txt('links_existing_params'), 'ex');
925 $dyn->addSubItem($ex);
926
927 foreach ($links as $id => $link) {
928 $p = new ilCustomInputGUI();
929
930 $ptpl = new ilTemplate('tpl.link_dyn_param_edit.html', true, true, 'Modules/WebResource');
931 $ptpl->setVariable('INFO_TXT', ilParameterAppender::parameterToInfo($link['name'], $link['value']));
932 $this->ctrl->setParameter($this, 'param_id', $id);
933 $ptpl->setVariable('LINK_DEL', $this->ctrl->getLinkTarget($this, 'deleteParameterForm'));
934 $ptpl->setVariable('LINK_TXT', $this->lng->txt('delete'));
935 $p->setHtml($ptpl->get());
936 $dyn->addSubItem($p);
937 }
938 }
939
940 // Existing parameters
941
942 // New parameter
943 if ($a_mode != self::LINK_MOD_CREATE) {
944 #$new = new ilCustomInputGUI($this->lng->txt('links_add_param'),'');
945 #$dyn->addSubItem($new);
946 }
947
948 // Dynyamic name
949 $nam = new ilTextInputGUI($this->lng->txt('links_name'), 'nam');
950 $nam->setSize(12);
951 $nam->setMaxLength(128);
952 $dyn->addSubItem($nam);
953
954 // Dynamic value
955 $val = new ilSelectInputGUI($this->lng->txt('links_value'), 'val');
956 $val->setOptions(ilParameterAppender::_getOptionSelect());
957 $val->setValue(0);
958 $dyn->addSubItem($val);
959
960 $this->form->addItem($dyn);
961 }
962 }
963 }
964
969 protected function switchViewMode()
970 {
971 global $DIC;
972
973 $ilCtrl = $DIC['ilCtrl'];
974
975 $_REQUEST['view_mode'] = $_GET['view_mode'] = (int) $_GET['switch_mode'];
976 $this->view();
977 }
978
983 protected function editLinks()
984 {
985 $_GET['switch_mode'] = self::VIEW_MODE_MANAGE;
986 $this->switchViewMode();
987 }
988
989
994 public function view()
995 {
996 global $DIC;
997
998 $ilErr = $DIC['ilErr'];
999 $ilTabs = $DIC['ilTabs'];
1000
1001 $ilTabs->activateTab("id_content");
1002
1003 $this->checkPermission('read');
1004
1005 if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
1006 parent::view();
1007 return true;
1008 } else {
1009 switch ((int) $_REQUEST['view_mode']) {
1011 $this->manage();
1012 break;
1013
1015 // #14638
1016 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
1018 $this->sort();
1019 break;
1020 }
1021 // fallthrough
1022
1023 // no break
1024 default:
1025 $this->showLinks();
1026 break;
1027 }
1028 }
1029 $GLOBALS['DIC']['tpl']->setPermanentLink($this->object->getType(), $this->object->getRefId());
1030 return true;
1031 }
1032
1037 protected function manage()
1038 {
1039 $this->checkPermission('write');
1040 $this->activateTabs('content', 'id_content_manage');
1041
1042 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.webr_manage.html', 'Modules/WebResource');
1043 $this->showToolbar('ACTION_BUTTONS');
1044
1045 include_once './Modules/WebResource/classes/class.ilWebResourceEditableLinkTableGUI.php';
1046 $table = new ilWebResourceEditableLinkTableGUI($this, 'view');
1047 $table->parse();
1048
1049 include_once './Services/Link/classes/class.ilInternalLinkGUI.php';
1051
1052 $this->tpl->addJavaScript("Modules/WebResource/js/intLink.js");
1053 $this->tpl->addJavascript("Services/Form/js/Form.js");
1054
1055 $this->tpl->setVariable('TABLE_LINKS', $table->getHTML() . $js);
1056 }
1057
1062 protected function showLinks()
1063 {
1064 $this->checkPermission('read');
1065 $this->activateTabs('content', 'id_content_view');
1066
1067 include_once './Modules/WebResource/classes/class.ilWebResourceLinkTableGUI.php';
1068 $table = new ilWebResourceLinkTableGUI($this, 'showLinks');
1069 $table->parse();
1070
1071 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.webr_view.html', 'Modules/WebResource');
1072 $this->showToolbar('ACTION_BUTTONS');
1073 $this->tpl->setVariable('LINK_TABLE', $table->getHTML());
1074 }
1075
1080 protected function sort()
1081 {
1082 $this->checkPermission('write');
1083 $this->activateTabs('content', 'id_content_ordering');
1084
1085 include_once './Modules/WebResource/classes/class.ilWebResourceLinkTableGUI.php';
1086 $table = new ilWebResourceLinkTableGUI($this, 'sort', true);
1087 $table->parse();
1088
1089 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.webr_view.html', 'Modules/WebResource');
1090 $this->showToolbar('ACTION_BUTTONS');
1091 $this->tpl->setVariable('LINK_TABLE', $table->getHTML());
1092 }
1093
1098 protected function saveSorting()
1099 {
1100 $this->checkPermission('write');
1101
1102 include_once './Services/Container/classes/class.ilContainerSorting.php';
1103 $sort = ilContainerSorting::_getInstance($this->object->getId());
1104 $sort->savePost((array) $_POST['position']);
1105
1106 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1107 $this->view();
1108 }
1109
1110
1116 protected function showToolbar($a_tpl_var)
1117 {
1118 global $DIC;
1119
1120 include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
1121 $tool = new ilToolbarGUI();
1122 $tool->setFormAction($this->ctrl->getFormAction($this));
1123
1124 $f = $DIC->ui()->factory();
1125 $r = $DIC->ui()->renderer();
1126
1127 if (
1128 ilLinkResourceList::checkListStatus($this->object->getId()) &&
1129 $this->checkPermissionBool('write')
1130 ) {
1131 $tool->addButton(
1132 $this->lng->txt('webr_add'),
1133 $this->ctrl->getLinkTarget($this, 'addLink')
1134 );
1135 }
1136 elseif ($this->checkPermissionBool('write')) {
1137 $modal = $this->getLinkToListModal();
1138 $button = $f->button()->standard($this->lng->txt('webr_set_to_list'), '#')
1139 ->withOnClick($modal->getShowSignal());
1140
1141 $this->tpl->setVariable("MODAL", $r->render([$modal]));
1142 $tool->addComponent($button);
1143 }
1144
1145 $download_button = $f->button()->standard(
1146 $this->lng->txt('export_html'),
1147 $this->ctrl->getLinkTarget($this, 'exportHTML')
1148 );
1149 $tool->addComponent($download_button);
1150 $this->tpl->setVariable($a_tpl_var, $tool->getHTML());
1151 return;
1152 }
1153
1158 protected function confirmDeleteLink()
1159 {
1160 $this->checkPermission('write');
1161 $this->activateTabs('content', 'id_content_view');
1162
1163 $link_ids = array();
1164
1165 if (is_array($_POST['link_ids'])) {
1166 $link_ids = $_POST['link_ids'];
1167 } elseif (isset($_GET['link_id'])) {
1168 $link_ids = array($_GET['link_id']);
1169 }
1170
1171 if (!count($link_ids) > 0) {
1172 ilUtil::sendFailure($this->lng->txt('select_one'));
1173 $this->view();
1174 return false;
1175 }
1176
1177 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1178 $links = new ilLinkResourceItems($this->object->getId());
1179
1180 include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1181 $confirm = new ilConfirmationGUI();
1182 $confirm->setFormAction($this->ctrl->getFormAction($this, 'view'));
1183 $confirm->setHeaderText($this->lng->txt('webr_sure_delete_items'));
1184 $confirm->setConfirm($this->lng->txt('delete'), 'deleteLinks');
1185 $confirm->setCancel($this->lng->txt('cancel'), 'view');
1186
1187 foreach ($link_ids as $link_id) {
1188 $link = $links->getItem($link_id);
1189 $confirm->addItem('link_ids[]', $link_id, $link['title']);
1190 }
1191 $this->tpl->setContent($confirm->getHTML());
1192 }
1193
1198 protected function deleteLinks()
1199 {
1200 global $DIC;
1201
1202 $ilCtrl = $DIC['ilCtrl'];
1203
1204 $this->checkPermission('write');
1205
1206 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1207 $links = new ilLinkResourceItems($this->object->getId());
1208
1209 foreach ($_POST['link_ids'] as $link_id) {
1210 $links->delete($link_id);
1211 }
1212 ilUtil::sendSuccess($this->lng->txt('webr_deleted_items'), true);
1213 $ilCtrl->redirect($this, 'view');
1214 }
1215
1220 protected function deactivateLink()
1221 {
1222 global $DIC;
1223
1224 $ilCtrl = $DIC['ilCtrl'];
1225
1226 $this->checkPermission('write');
1227
1228 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1229 $links = new ilLinkResourceItems($this->object->getId());
1230
1231 if (!$_GET['link_id']) {
1232 ilUtil::sendFailure($this->lng->txt('select_one'), true);
1233 $ilCtrl->redirect($this, 'view');
1234 }
1235
1236 $links->setLinkId((int) $_GET['link_id']);
1237 $links->updateActive(false);
1238
1239 ilUtil::sendSuccess($this->lng->txt('webr_inactive_success'), true);
1240 $ilCtrl->redirect($this, 'view');
1241 }
1242
1243
1249 public function infoScreen()
1250 {
1251 $this->ctrl->setCmd("showSummary");
1252 $this->ctrl->setCmdClass("ilinfoscreengui");
1253 $this->infoScreenForward();
1254 }
1255
1259 public function infoScreenForward()
1260 {
1261 global $DIC;
1262
1263 $ilTabs = $DIC['ilTabs'];
1264
1265 if (!$this->checkPermissionBool('visible')) {
1266 $this->checkPermission('read');
1267 }
1268 $ilTabs->activateTab('id_info');
1269
1270 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1271 $info = new ilInfoScreenGUI($this);
1272
1273 $info->enablePrivateNotes();
1274
1275 // standard meta data
1276 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
1277
1278 if ($this->id_type == self::WORKSPACE_NODE_ID) {
1279 $info->addProperty($this->lng->txt("perma_link"), $this->getPermanentLinkWidget());
1280 }
1281
1282 // forward the command
1283 $this->ctrl->forwardCommand($info);
1284 }
1285
1286
1287 public function history()
1288 {
1289 global $DIC;
1290
1291 $ilTabs = $DIC['ilTabs'];
1292
1293 $this->checkPermission('write');
1294 $ilTabs->activateTab('id_history');
1295
1296 include_once("./Services/History/classes/class.ilHistoryTableGUI.php");
1297 $hist_gui = new ilHistoryTableGUI($this, "history", $this->object->getId(), $this->object->getType);
1298 $hist_gui->initTable();
1299 $this->tpl->setContent($hist_gui->getHTML());
1300 }
1301
1310 public function formatInvalidLinkArray(array $row)
1311 {
1312 $this->object->items_obj->readItem($row['page_id']);
1313 $row['title'] = $this->object->items_obj->getTitle();
1314
1315 require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
1317 $actions->setSelectionHeaderClass('small');
1318 $actions->setItemLinkClass('xsmall');
1319 $actions->setListTitle($this->lng->txt('actions'));
1320 $actions->setId($row['page_id']);
1321 $this->ctrl->setParameter($this, 'link_id', $row['page_id']);
1322 $actions->addItem(
1323 $this->lng->txt('edit'),
1324 '',
1325 $this->ctrl->getLinkTarget($this, 'editLink')
1326 );
1327 $this->ctrl->clearParameters($this);
1328 $row['action_html'] = $actions->getHTML();
1329
1330 return $row;
1331 }
1332
1337 protected function linkChecker()
1338 {
1339 global $DIC;
1340
1341 $ilias = $DIC['ilias'];
1342 $ilUser = $DIC['ilUser'];
1343 $tpl = $DIC['tpl'];
1344 $ilTabs = $DIC['ilTabs'];
1345
1346 $this->checkPermission('write');
1347 $ilTabs->activateTab('id_link_check');
1348
1349 $this->__initLinkChecker();
1350 $this->object->initLinkResourceItemsObject();
1351
1352 require_once './Services/LinkChecker/classes/class.ilLinkCheckerTableGUI.php';
1353
1354 $toolbar = new ilToolbarGUI();
1355
1356 if ((bool) $ilias->getSetting('cron_web_resource_check')) {
1357 include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
1358 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
1359
1360 $chb = new ilCheckboxInputGUI($this->lng->txt('link_check_message_a'), 'link_check_message');
1361 $chb->setValue(1);
1362 $chb->setChecked((bool) ilLinkCheckNotify::_getNotifyStatus($ilUser->getId(), $this->object->getId()));
1363 $chb->setOptionTitle($this->lng->txt('link_check_message_b'));
1364
1365 $toolbar->addInputItem($chb);
1366 $toolbar->addFormButton($this->lng->txt('save'), 'saveLinkCheck');
1367 $toolbar->setFormAction($this->ctrl->getLinkTarget($this, 'saveLinkCheck'));
1368 }
1369
1370 $tgui = new ilLinkCheckerTableGUI($this, 'linkChecker');
1371 $tgui->setLinkChecker($this->link_checker_obj)
1372 ->setRowHandler($this)
1373 ->setRefreshButton($this->lng->txt('refresh'), 'refreshLinkCheck');
1374
1375 return $tpl->setContent($tgui->prepareHTML()->getHTML() . $toolbar->getHTML());
1376 }
1377
1378 public function saveLinkCheck()
1379 {
1380 global $DIC;
1381
1382 $ilDB = $DIC['ilDB'];
1383 $ilUser = $DIC['ilUser'];
1384
1385 include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
1386
1387 $link_check_notify = new ilLinkCheckNotify($ilDB);
1388 $link_check_notify->setUserId($ilUser->getId());
1389 $link_check_notify->setObjId($this->object->getId());
1390
1391 if ($_POST['link_check_message']) {
1392 ilUtil::sendSuccess($this->lng->txt('link_check_message_enabled'));
1393 $link_check_notify->addNotifier();
1394 } else {
1395 ilUtil::sendSuccess($this->lng->txt('link_check_message_disabled'));
1396 $link_check_notify->deleteNotifier();
1397 }
1398 $this->linkChecker();
1399
1400 return true;
1401 }
1402
1403
1404
1405 public function refreshLinkCheck()
1406 {
1407 $this->__initLinkChecker();
1408 $this->object->initLinkResourceItemsObject();
1409
1410 // Set all link to valid. After check invalid links will be set to invalid
1411 $this->object->items_obj->updateValidByCheck();
1412
1413 foreach ($this->link_checker_obj->checkWebResourceLinks() as $invalid) {
1414 $this->object->items_obj->readItem($invalid['page_id']);
1415 $this->object->items_obj->setActiveStatus(false);
1416 $this->object->items_obj->setValidStatus(false);
1417 $this->object->items_obj->update(false);
1418 }
1419
1420 $this->object->items_obj->updateLastCheck();
1421 ilUtil::sendSuccess($this->lng->txt('link_checker_refreshed'));
1422
1423 $this->linkChecker();
1424
1425 return true;
1426 }
1427
1428 public function __initLinkChecker()
1429 {
1430 global $DIC;
1431
1432 $ilDB = $DIC['ilDB'];
1433
1434 include_once './Services/LinkChecker/classes/class.ilLinkChecker.php';
1435
1436 $this->link_checker_obj = new ilLinkChecker($ilDB, false);
1437 $this->link_checker_obj->setObjId($this->object->getId());
1438
1439 return true;
1440 }
1441
1442
1449 protected function activateTabs($a_active_tab, $a_active_subtab = '')
1450 {
1451 global $DIC;
1452
1453 $ilCtrl = $DIC['ilCtrl'];
1454 $ilTabs = $DIC['ilTabs'];
1455 $lng = $DIC['lng'];
1456
1457 switch ($a_active_tab) {
1458 case 'content':
1459 if ($this->checkPermissionBool('write')) {
1460 $this->lng->loadLanguageModule('cntr');
1461
1462 $this->ctrl->setParameter($this, 'switch_mode', self::VIEW_MODE_VIEW);
1463 $ilTabs->addSubTab(
1464 'id_content_view',
1465 $lng->txt('view'),
1466 $this->ctrl->getLinkTarget($this, 'switchViewMode')
1467 );
1468 $this->ctrl->setParameter($this, 'switch_mode', self::VIEW_MODE_MANAGE);
1469 $ilTabs->addSubTab(
1470 'id_content_manage',
1471 $lng->txt('cntr_manage'),
1472 $this->ctrl->getLinkTarget($this, 'switchViewMode')
1473 );
1474 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1475 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
1476 include_once './Services/Container/classes/class.ilContainer.php';
1477 if ((ilLinkResourceItems::lookupNumberOfLinks($this->object->getId()) > 1)
1479 $this->ctrl->setParameter($this, 'switch_mode', self::VIEW_MODE_SORT);
1480 $ilTabs->addSubTab(
1481 'id_content_ordering',
1482 $this->lng->txt('cntr_ordering'),
1483 $this->ctrl->getLinkTarget($this, 'switchViewMode')
1484 );
1485 }
1486
1487 $ilCtrl->clearParameters($this);
1488 $ilTabs->activateSubTab($a_active_subtab);
1489 }
1490 }
1491
1492 $ilTabs->activateTab('id_content');
1493 }
1494
1495
1500 public function setTabs()
1501 {
1502 global $DIC;
1503
1504 $ilTabs = $DIC['ilTabs'];
1505 $lng = $DIC['lng'];
1506 $ilHelp = $DIC['ilHelp'];
1507
1508 $ilHelp->setScreenIdComponent("webr");
1509
1510 if ($this->checkPermissionBool('read')) {
1511 $ilTabs->addTab(
1512 "id_content",
1513 $lng->txt("content"),
1514 $this->ctrl->getLinkTarget($this, "view")
1515 );
1516 }
1517
1518 if (
1519 $this->checkPermissionBool('visible') ||
1520 $this->checkPermissionBool('read')
1521 ) {
1522 $ilTabs->addTab(
1523 "id_info",
1524 $lng->txt("info_short"),
1525 $this->ctrl->getLinkTarget($this, "infoScreen")
1526 );
1527 }
1528
1529 if ($this->checkPermissionBool('write') and !$this->getCreationMode()) {
1530 $ilTabs->addTab(
1531 "id_settings",
1532 $lng->txt("settings"),
1533 $this->ctrl->getLinkTarget($this, "settings")
1534 );
1535 }
1536
1537 if ($this->checkPermissionBool('write')) {
1538 $ilTabs->addTab(
1539 "id_history",
1540 $lng->txt("history"),
1541 $this->ctrl->getLinkTarget($this, "history")
1542 );
1543 }
1544
1545 if ($this->checkPermissionBool('write')) {
1546 // Check if pear library is available
1547 $ilTabs->addTab(
1548 "id_link_check",
1549 $lng->txt("link_check"),
1550 $this->ctrl->getLinkTarget($this, "linkChecker")
1551 );
1552 }
1553
1554 if ($this->checkPermissionBool('write')) {
1555 include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
1556 $mdgui = new ilObjectMetaDataGUI($this->object);
1557 $mdtab = $mdgui->getTab();
1558 if ($mdtab) {
1559 $ilTabs->addTab(
1560 "id_meta_data",
1561 $lng->txt("meta_data"),
1562 $mdtab
1563 );
1564 }
1565 }
1566
1567 if ($this->checkPermissionBool('write')) {
1568 $ilTabs->addTab(
1569 'export',
1570 $this->lng->txt('export'),
1571 $this->ctrl->getLinkTargetByClass('ilexportgui', '')
1572 );
1573 }
1574
1575 // will add permission tab if needed
1576 parent::setTabs();
1577 }
1578
1579 // PRIVATE
1580 public function __prepareOutput()
1581 {
1582 // output objects
1583 // $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
1584 // $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
1585
1586 $this->tpl->setLocator();
1587
1588 // output message
1589 if ($this->message) {
1590 ilUtil::sendInfo($this->message);
1591 }
1592
1593 // display infopanel if something happened
1595 ;
1596 }
1597
1598 public function addLocatorItems()
1599 {
1600 global $DIC;
1601
1602 $ilLocator = $DIC['ilLocator'];
1603
1604 if (is_object($this->object)) {
1605 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this), "", $this->object->getRefId(), "webr");
1606 }
1607 }
1608
1609 protected function handleSubItemLinks($a_target)
1610 {
1611 // #15647 - handle internal links
1612 include_once "Services/Form/classes/class.ilFormPropertyGUI.php";
1613 include_once "Services/Form/classes/class.ilLinkInputGUI.php";
1614
1615 if (ilLinkInputGUI::isInternalLink($a_target)) {
1616 include_once("./Services/Link/classes/class.ilLink.php");
1617
1618 // #10612
1619 $parts = explode("|", $a_target);
1620
1621 if ($parts[0] == 'wpage') {
1623 0,
1624 'wiki',
1625 true,
1626 '&target=wiki_wpage_' . $parts[1]
1627 );
1628 }
1629
1630 if ($parts[0] == "term") {
1631 // #16894
1633 0,
1634 "git",
1635 true,
1636 "&target=git_" . $parts[1]
1637 );
1638 }
1639
1640 if ($parts[0] == "page") {
1641 $parts[0] = "pg";
1642 }
1643
1644 $a_target = ilLink::_getStaticLink($parts[1], $parts[0]);
1645 }
1646
1647 return $a_target;
1648 }
1649
1650 public function callDirectLink()
1651 {
1652 $obj_id = $this->object->getId();
1653
1654 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1657 if ($url["target"]) {
1658 $url["target"] = $this->handleSubItemLinks($url["target"]);
1659
1660 include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
1663 }
1664
1665 $this->redirectToLink($this->ref_id, $obj_id, $url["target"]);
1666 }
1667 }
1668 }
1669
1670 public function callLink()
1671 {
1672 if ($_REQUEST["link_id"]) {
1673 $obj_id = $this->object->getId();
1674
1675 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1676 $items = new ilLinkResourceItems($obj_id);
1677 $item = $items->getItem($_REQUEST["link_id"]);
1678 if ($item["target"]) {
1679 $item["target"] = $this->handleSubItemLinks($item["target"]);
1680
1681 include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
1683 $item = ilParameterAppender::_append($item);
1684 }
1685 ilLoggerFactory::getLogger('webr')->debug('Redirecting to: ' . $item['target']);
1686 $this->redirectToLink($this->ref_id, $obj_id, $item["target"]);
1687 }
1688 }
1689 }
1690
1691 protected function redirectToLink($a_ref_id, $a_obj_id, $a_url)
1692 {
1693 global $DIC;
1694
1695 $ilUser = $DIC['ilUser'];
1696
1697 if ($a_url) {
1698 require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1700 "webr",
1701 $a_ref_id,
1702 $a_obj_id,
1703 $ilUser->getId()
1704 );
1705
1706 ilUtil::redirect($a_url);
1707 }
1708 }
1709
1710 public function exportHTML()
1711 {
1712 global $DIC;
1713
1714 $ilSetting = $DIC['ilSetting'];
1715
1716 $tpl = new ilTemplate("tpl.export_html.html", true, true, "Modules/WebResource");
1717
1718 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
1719 $items = new ilLinkResourceItems($this->object->getId());
1720 foreach ($items->getAllItems() as $item) {
1721 if (!$item["active"]) {
1722 continue;
1723 }
1724
1725 $target = $this->handleSubItemLinks($item["target"]);
1726
1727 $tpl->setCurrentBlock("link_bl");
1728 $tpl->setVariable("LINK_URL", $target);
1729 $tpl->setVariable("LINK_TITLE", $item["title"]);
1730 $tpl->setVariable("LINK_DESC", $item["description"]);
1731 $tpl->setVariable("LINK_CREATE", $item["create_date"]);
1732 $tpl->setVariable("LINK_UPDATE", $item["last_update"]);
1733 $tpl->parseCurrentBlock();
1734 }
1735
1736 $tpl->setVariable("CREATE_DATE", $this->object->getCreateDate());
1737 $tpl->setVariable("LAST_UPDATE", $this->object->getLastUpdateDate());
1738 $tpl->setVariable("TXT_TITLE", $this->object->getTitle());
1739 $tpl->setVariable("TXT_DESC", $this->object->getLongDescription());
1740
1741 $tpl->setVariable("INST_ID", ($ilSetting->get('short_inst_name') != "")
1742 ? $ilSetting->get('short_inst_name')
1743 : "ILIAS");
1744
1745 ilUtil::deliverData($tpl->get(), "bookmarks.html");
1746 }
1747
1748 public static function _goto($a_target, $a_additional = null)
1749 {
1750 global $DIC;
1751
1752 $ilAccess = $DIC['ilAccess'];
1753 $ilErr = $DIC['ilErr'];
1754 $lng = $DIC['lng'];
1755
1756 if ($a_additional && substr($a_additional, -3) == "wsp") {
1757 $_GET["baseClass"] = "ilsharedresourceGUI";
1758 $_GET["wsp_id"] = $a_target;
1759 include("ilias.php");
1760 exit;
1761 }
1762
1763 // Will be replaced in future releases by ilAccess::checkAccess()
1764 if ($ilAccess->checkAccess("read", "", $a_target)) {
1765 ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=$a_target");
1766 } else {
1767 // to do: force flat view
1768 if ($ilAccess->checkAccess("visible", "", $a_target)) {
1769 ilUtil::redirect("ilias.php?baseClass=ilLinkResourceHandlerGUI&ref_id=" . $a_target . "&cmd=infoScreen");
1770 } else {
1771 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1772 ilUtil::sendFailure(sprintf(
1773 $lng->txt("msg_no_perm_read_item"),
1775 ), true);
1777 }
1778 }
1779 }
1780
1781 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1782 }
1783} // END class.ilObjLinkResource
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$section
Definition: Utf8Test.php:83
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const LINKS_ERR_NO_NAME
const LINKS_ERR_NO_VALUE
const LINKS_ERR_NO_NAME_VALUE
User interface class for advanced drop-down selection lists.
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 a checkbox property in a property form.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Confirmation screen class.
static _lookupSortMode($a_obj_id)
lookup sort mode
static _getInstance($a_obj_id)
get instance by obj_id
This class represents a custom property in a property form.
Export User Interface Class.
This class represents a section header in a property form.
This class represents a hidden form property in a property form.
Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE Date: 24....
Class ilInfoScreenGUI.
Class ilInternalLinkGUI.
static getInitHTML($a_url)
Get initialisation HTML to use interna link editing.
class for checking external links in page objects.
static _getNotifyStatus($a_usr_id, $a_obj_id)
class ilLinkCheckerTableGUI
class for checking external links in page objects Normally used in Cron jobs, but should be extensibl...
This class represents a external and/or internal link in a property form.
static isInternalLink($a_value)
Class ilLinkResourceItems.
static lookupItem($a_webr_id, $a_link_id)
static _getFirstLink($a_webr_id)
Get first link item Check before with _isSingular() if there is more or less than one.
static _isSingular($a_webr_id)
Check whether there is only one active link in the web resource.
static lookupNumberOfLinks($a_webr_id)
Get number of assigned links.
Class ilLinkResourceList.
static checkListStatus(int $a_webr_id)
Check if a weblink list was already created or transformed from a single weblink.
static getLogger($a_component_id)
Get component logger.
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.
Class ilObjLinkResourceGUI.
confirmDeleteLink()
Show delete confirmation screen.
addLocatorItems()
Functions to be overwritten.
deleteParameter()
Delete a dynamic parameter.
redirectToLink($a_ref_id, $a_obj_id, $a_url)
showLinks()
Show all active links.
infoScreen()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
activateTabs($a_active_tab, $a_active_subtab='')
Activate tab and subtabs.
getLinkToListModal()
Get form to transform a single weblink to a weblink list.
switchViewMode()
Switch between "View" "Manage" and "Sort".
showToolbar($a_tpl_var)
Show toolbar.
saveSorting()
Save nmanual sorting.
initCreateForm($a_new_type)
Init object creation form.
initFormLink($a_mode)
Show create/edit single link.
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
updateLinks()
Update all visible links.
setTabs()
get tabs @access public
saveSettings()
Save container settings.
getType()
Functions that must be overwritten.
checkLinkInput($a_mode, $a_valid, $a_webr_id=0, $a_link_id=0)
Check input after creating a new link.
initList(int $a_mode, int $a_webr_id=0)
Init a new link list.
linkChecker()
Show link validation.
settings()
Edit settings Title, Description, Sorting.
editLinks()
Start with manage mode.
static _goto($a_target, $a_additional=null)
addLink()
Add an additional link.
setValuesFromLink($a_link_id)
Set form values from link.
save()
Save new object @access public.
infoScreenForward()
show information screen
initFormSettings()
Show settings form.
New implementation of ilObjectGUI.
prepareOutput($a_show_subobjects=true)
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
getCreationMode()
get creation mode
GUI class for the workflow of copying objects.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
addHeaderAction()
Add header action menu.
Class ilObjectMetaDataGUI.
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
getRefId()
get reference id @access public
getId()
get object id @access public
Class ilParameterAppender.
static parameterToInfo($a_name, $a_value)
Get info text describing an existing dynamic link.
static _append($a_link_data)
static _getOptionSelect()
Get options as array.
static _getParams($a_link_id)
Get dynamic parameter definitions.
static _isEnabled()
Check if dynamic parameters are enabled.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
This class represents a text property in a property form.
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static infoPanel($a_keep=true)
TableGUI class for search results.
const ROOT_FOLDER_ID
Definition: constants.php:30
$valid
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
interface ilLinkCheckerGUIRowHandling
exit
Definition: login.php:29
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
$url
global $ilDB
$param
Definition: xapitoken.php:29