ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilInternalLinkGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
5require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
6
18{
23
28
33
37 protected $parent_ref_id;
38
42 protected $parent_obj_id;
43
44 protected $link_type; // "PageObject_New"
45 protected $link_target; // "New"
46 protected $base_link_type; // "PageObject"
47
48
50
54 protected $ltypes = array();
55
59 protected $parent_type = array();
60
64 public $ctrl;
65
69 protected $filter_white_list = false;
70
74 protected $filter_link_types = array();
75
79 protected $tree;
80
84 protected $lng;
85
89 protected $user;
90
91 public function __construct($a_default_link_type, $a_default_parent_id, $a_is_ref = true)
92 {
93 global $DIC;
94 $this->tree = $DIC->repositoryTree();
95 $this->lng = $DIC->language();
96 $this->ctrl = $DIC->ctrl();
97 $this->user = $DIC->user();
98
99 $this->lng->loadLanguageModule("link");
100 $this->lng->loadLanguageModule("content");
101 //$this->ctrl->saveParameter($this, array("linkmode", "target_type", "link_par_ref_id", "link_par_obj_id",
102 // "link_par_fold_id", "link_type"));
103 $this->ctrl->saveParameter($this, array("linkmode", "link_par_ref_id", "link_par_obj_id",
104 "link_par_fold_id", "link_type"));
105
106 // default type and parent
107 $this->default_link_type = $a_default_link_type;
108 if ($a_is_ref) {
109 $this->default_parent_ref_id = $a_default_parent_id;
110 $this->default_parent_obj_id = ilObject::_lookupObjId($a_default_parent_id);
111 } else {
112 $this->default_parent_ref_id = 0;
113 $this->default_parent_obj_id = $a_default_parent_id;
114 }
115 $this->default_parent_obj_type = ($this->default_parent_obj_id > 0)
116 ? ilObject::_lookupType($this->default_parent_obj_id)
117 : "";
118
119 // current parent object
120 $this->parent_ref_id = (int) $_GET["link_par_ref_id"];
121 $this->parent_fold_id = (int) $_GET["link_par_fold_id"]; // e.g. media pool folder
122 if ($this->parent_ref_id > 0) {
123 $this->parent_obj_id = ilObject::_lookupObjId($this->parent_ref_id);
124 } else {
125 $this->parent_obj_id = (int) $_GET["link_par_obj_id"];
126 }
127 }
128
132 public function init()
133 {
137
138 if ($this->parent_ref_id > 0 && !$tree->isInTree($this->parent_ref_id)) {
139 $this->resetLinkList();
140 }
141
142 $this->parent_type = array(
143 "StructureObject" => "lm",
144 "PageObject" => "lm",
145 "GlossaryItem" => "glo",
146 "Media" => "mep",
147 "WikiPage" => "wiki",
148 "PortfolioPage" => "prtf",
149 "PortfolioTemplatePage" => "prtt",
150 "File" => "",
151 "RepositoryItem" => "",
152 "User" => ""
153 );
154
155 // filter link types
156 $this->ltypes = array(
157 "StructureObject" => $lng->txt("cont_lk_chapter"),
158 "StructureObject_New" => $lng->txt("cont_lk_chapter_new"),
159 "PageObject" => $lng->txt("cont_lk_page"),
160 "PageObject_FAQ" => $lng->txt("cont_lk_page_faq"),
161 "PageObject_New" => $lng->txt("cont_lk_page_new"),
162 "GlossaryItem" => $lng->txt("cont_lk_term"),
163 "GlossaryItem_New" => $lng->txt("cont_lk_term_new"),
164 "Media" => $lng->txt("cont_lk_media_inline"),
165 "Media_Media" => $lng->txt("cont_lk_media_media"),
166 "Media_FAQ" => $lng->txt("cont_lk_media_faq"),
167 "Media_New" => $lng->txt("cont_lk_media_new"),
168 "WikiPage" => $lng->txt("cont_wiki_page"),
169 "PortfolioPage" => $lng->txt("cont_prtf_page"),
170 "PortfolioTemplatePage" => $lng->txt("cont_prtt_page"),
171 "File" => $lng->txt("cont_lk_file"),
172 "RepositoryItem" => $lng->txt("cont_repository_item"),
173 "User" => $lng->txt("cont_user")
174 );
175 if (!$this->filter_white_list) {
176 foreach ($this->filter_link_types as $link_type) {
177 unset($this->ltypes[$link_type]);
178 }
179 } else {
180 $ltypes = array();
181 foreach ($this->ltypes as $k => $l) {
182 if (in_array($k, $this->filter_link_types)) {
183 $ltypes[$k] = $l;
184 }
185 }
186 $this->ltypes = $ltypes;
187 }
188 // determine link type and target
189 $this->link_type = ($_GET["link_type"] == "")
190 ? $this->default_link_type
191 : $_GET["link_type"];
192 $ltype_arr = explode("_", $this->link_type);
193 $this->base_link_type = $ltype_arr[0];
194 $this->link_target = $ltype_arr[1];
195
196
197 $def_type = ilObject::_lookupType($this->default_parent_obj_id);
198
199 // determine content object id
200 switch ($this->base_link_type) {
201 case "PageObject":
202 case "StructureObject":
203 case "GlossaryItem":
204 case "Media":
205 case "WikiPage":
206 case "PortfolioPage":
207 case "PortfolioTemplatePage":
208 if ($this->parent_ref_id == 0 && $this->parent_obj_id == 0
209 && $def_type == $this->parent_type[$this->base_link_type]) {
210 $this->parent_ref_id = $this->default_parent_ref_id;
211 $this->parent_obj_id = $this->default_parent_obj_id;
212 $ctrl->setParameter($this, "link_par_obj_id", $this->parent_obj_id);
213 $ctrl->setParameter($this, "link_par_ref_id", $this->parent_ref_id);
214 }
215 break;
216 }
217 }
218
219
224 public function setMode($a_mode = "text")
225 {
226 }
227
228 public function setSetLinkTargetScript($a_script)
229 {
230 $this->set_link_script = $a_script;
231 }
232
233 public function setReturn($a_return)
234 {
235 $this->return = $a_return;
236 }
237
238 public function getSetLinkTargetScript()
239 {
241 }
242
243 public function filterLinkType($a_link_type)
244 {
245 $this->filter_link_types[] = $a_link_type;
246 }
247
253 public function setFilterWhiteList($a_white_list)
254 {
255 $this->filter_white_list = $a_white_list;
256 }
257
258
259 public function executeCommand()
260 {
261 $this->init();
262 $next_class = $this->ctrl->getNextClass($this);
263
264 $cmd = $this->ctrl->getCmd("showLinkHelp");
265 switch ($next_class) {
266 default:
267 $ret = $this->$cmd();
268 break;
269 }
270
271 return $ret;
272 }
273
274 public function resetLinkList()
275 {
277
278 $ctrl->setParameter($this, "link_par_ref_id", "");
279 $ctrl->setParameter($this, "link_par_obj_id", "");
280 $ctrl->setParameter($this, "link_par_fold_id", "");
281 $ctrl->setParameter($this, "link_type", "");
282
283 $ctrl->redirect($this, "showLinkHelp", "", true);
284 }
285
286 public function closeLinkHelp()
287 {
288 if ($this->return == "") {
289 $this->ctrl->returnToParent($this);
290 } else {
291 ilUtil::redirect($this->return);
292 }
293 }
294
298 public function prepareJavascriptOutput($str)
299 {
300 return htmlspecialchars($str, ENT_QUOTES);
301 }
302
303
307 public function showLinkHelp()
308 {
311
312
313 $parent_type = $this->parent_type[$this->base_link_type];
314 if ((in_array($this->base_link_type, array("GlossaryItem", "WikiPage", "PageObject", "StructureObject")) &&
315 ($this->parent_ref_id == 0))
316 ||
317 (($this->parent_ref_id > 0) &&
318 !in_array(ilObject::_lookupType($this->parent_ref_id, true), array($parent_type)))) {
319 if ($parent_type != "") {
321 }
322 }
323 if ($ilCtrl->isAsynch()) {
324 $tpl = new ilTemplate("tpl.link_help_asynch.html", true, true, "Services/Link");
325 $tpl->setVariable("NEW_LINK_URL", $this->ctrl->getLinkTarget(
326 $this,
327 "",
328 false,
329 true,
330 false
331 ));
332 } else {
333 $tpl = new ilTemplate("tpl.link_help.html", true, true, "Services/Link");
334 $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
335 }
336
337 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "changeLinkType", "", true));
338 $tpl->setVariable("FORMACTION2", $this->ctrl->getFormAction($this));
339 $tpl->setVariable("TXT_HELP_HEADER", $this->lng->txt("cont_link_select"));
340 $tpl->setVariable("TXT_TYPE", $this->lng->txt("cont_link_type"));
341
342
343 $select_ltype = ilUtil::formSelect(
344 $this->link_type,
345 "ltype",
346 $this->ltypes,
347 false,
348 true,
349 "0",
350 "",
351 array("id" => "ilIntLinkTypeSelector")
352 );
353 $tpl->setVariable("SELECT_TYPE", $select_ltype);
354 $tpl->setVariable("CMD_CHANGETYPE", "changeLinkType");
355 $tpl->setVariable("BTN_CHANGETYPE", $this->lng->txt("cont_change_type"));
356
357 $tpl->setVariable("CMD_CLOSE", "closeLinkHelp");
358 $tpl->setVariable("BTN_CLOSE", $this->lng->txt("close"));
359
360 $chapterRowBlock = "chapter_row_js";
361
362 // switch link type
363 switch ($this->base_link_type) {
364 // page link
365 case "PageObject":
366 require_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
367 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
368
369 $cont_obj = new ilObjLearningModule($this->parent_ref_id, true);
370
371 // get all chapters
372 $ctree = $cont_obj->getLMTree();
373 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
374 $tpl->setCurrentBlock("chapter_list");
375 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("obj_lm"));
376 $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
377 $tpl->setVariable("THEAD", $this->lng->txt("pages"));
378
379
380 $tpl->setCurrentBlock("change_cont_obj");
381 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
382 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
383 $tpl->parseCurrentBlock();
384
385 foreach ($nodes as $node) {
386 if ($node["type"] == "st") {
387 $tpl->setCurrentBlock("header_row");
388 $tpl->setVariable("TXT_HEADER", $node["title"]);
389 $tpl->parseCurrentBlock();
390 $tpl->setCurrentBlock("row");
391 $tpl->parseCurrentBlock();
392 }
393
394 if ($node["type"] == "pg") {
395 include_once("./Services/COPage/classes/class.ilPCParagraph.php");
396 $this->renderLink(
397 $tpl,
398 $node["title"],
399 $node["obj_id"],
400 "PageObject",
401 "pg",
402 "page",
403 ilPCParagraph::_readAnchors("lm", $node["obj_id"], "")
404 );
405 }
406 }
407
408 // get all free pages
409 $pages = ilLMPageObject::getPageList($cont_obj->getId());
410 $free_pages = array();
411 foreach ($pages as $page) {
412 if (!$ctree->isInTree($page["obj_id"])) {
413 $free_pages[] = $page;
414 }
415 }
416 if (count($free_pages) > 0) {
417 $tpl->setCurrentBlock("header_row");
418 $tpl->setVariable("TXT_HEADER", $this->lng->txt("cont_free_pages"));
419 $tpl->parseCurrentBlock();
420
421 foreach ($free_pages as $node) {
422 include_once("./Services/COPage/classes/class.ilPCParagraph.php");
423 $this->renderLink(
424 $tpl,
425 $node["title"],
426 $node["obj_id"],
427 "PageObject",
428 "pg",
429 "page",
430 ilPCParagraph::_readAnchors("lm", $node["obj_id"], "")
431 );
432 }
433 }
434
435 $tpl->setCurrentBlock("chapter_list");
436 $tpl->parseCurrentBlock();
437
438 break;
439
440 // chapter link
441 case "StructureObject":
442
443 // check whether current object matchs to type
444 if (!in_array(
445 ilObject::_lookupType($this->parent_ref_id, true),
446 array("lm")
447 )) {
448 $this->changeTargetObject("lm");
449 }
450
451 require_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
452 $cont_obj = new ilObjLearningModule($this->parent_ref_id, true);
453
454 // get all chapters
455 $ctree = &$cont_obj->getLMTree();
456 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
457 $tpl->setCurrentBlock("chapter_list");
458 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("obj_lm"));
459 $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
460 $tpl->setVariable("THEAD", $this->lng->txt("link_chapters"));
461 $tpl->setCurrentBlock("change_cont_obj");
462 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
463 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
464 $tpl->parseCurrentBlock();
465
466 foreach ($nodes as $node) {
467 if ($node["type"] == "st") {
468 $this->renderLink(
469 $tpl,
470 $node["title"],
471 $node["obj_id"],
472 "StructureObject",
473 "st",
474 "chap"
475 );
476 }
477 }
478 $tpl->setCurrentBlock("chapter_list");
479 $tpl->parseCurrentBlock();
480 break;
481
482 // glossary item link
483 case "GlossaryItem":
484 require_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
485 $glossary = new ilObjGlossary($this->parent_ref_id, true);
486
487 // get all glossary items
488 $terms = $glossary->getTermList();
489 $tpl->setCurrentBlock("chapter_list");
490 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("glossary"));
491 $tpl->setVariable("TXT_CONT_TITLE", $glossary->getTitle());
492 $tpl->setVariable("THEAD", $this->lng->txt("link_terms"));
493 $tpl->setCurrentBlock("change_cont_obj");
494 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
495 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
496 $tpl->parseCurrentBlock();
497
498 foreach ($terms as $term) {
499 $this->renderLink(
500 $tpl,
501 $term["term"],
502 $term["id"],
503 "GlossaryItem",
504 "git",
505 "term"
506 );
507 }
508
509 $tpl->setCurrentBlock("chapter_list");
510 $tpl->parseCurrentBlock();
511 break;
512
513 // media object
514 case "Media":
515 include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
516 //$tpl->setVariable("TARGET2", " target=\"content\" ");
517 // content object id = 0 --> get clipboard objects
518 if ($this->parent_ref_id == 0) {
519 $tpl->setCurrentBlock("change_cont_obj");
520 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
521 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
522 $tpl->parseCurrentBlock();
523 $mobjs = $ilUser->getClipboardObjects("mob");
524 // sort by name
525 $objs = array();
526 foreach ($mobjs as $obj) {
527 $objs[$obj["title"] . ":" . $obj["id"]] = $obj;
528 }
529 ksort($objs);
530 $tpl->setCurrentBlock("chapter_list");
531 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_media_source"));
532 $tpl->setVariable("TXT_CONT_TITLE", $this->lng->txt("cont_personal_clipboard"));
533 $tpl->setVariable("THEAD", $this->lng->txt("link_mobs"));
534 $tpl->setVariable("COLSPAN", "2");
535
536 foreach ($objs as $obj) {
537 $this->renderLink(
538 $tpl,
539 $obj["title"],
540 $obj["id"],
541 "MediaObject",
542 "mob",
543 "media"
544 );
545 }
546 $tpl->setCurrentBlock("chapter_list");
547 $tpl->parseCurrentBlock();
548 } else {
549 require_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
550 $med_pool = new ilObjMediaPool($this->parent_ref_id, true);
551 // get current folders
552 $fobjs = $med_pool->getChilds($this->parent_fold_id, "fold");
553 $f2objs = array();
554 foreach ($fobjs as $obj) {
555 $f2objs[$obj["title"] . ":" . $obj["child"]] = $obj;
556 }
557 ksort($f2objs);
558 // get current media objects
559 $mobjs = $med_pool->getChilds($this->parent_fold_id, "mob");
560 $m2objs = array();
561 foreach ($mobjs as $obj) {
562 $m2objs[$obj["title"] . ":" . $obj["child"]] = $obj;
563 }
564 ksort($m2objs);
565
566 // merge everything together
567 $objs = array_merge($f2objs, $m2objs);
568
569 $tpl->setCurrentBlock("chapter_list");
570 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("mep"));
571 $tpl->setVariable("TXT_CONT_TITLE", $med_pool->getTitle());
572 $tpl->setVariable("THEAD", $this->lng->txt("link_mobs"));
573 $tpl->setCurrentBlock("change_cont_obj");
574 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
575 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
576 $tpl->setVariable("COLSPAN", "2");
577 $tpl->parseCurrentBlock();
578 if ($parent_id = $med_pool->getParentId($this->parent_fold_id)) {
579 $css_row = "tblrow1";
580 $tpl->setCurrentBlock("icon");
581 $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.svg"));
582 $tpl->parseCurrentBlock();
583 $tpl->setCurrentBlock("link_row");
584 $tpl->setVariable("ROWCLASS", $css_row);
585 $tpl->setVariable("TXT_CHAPTER", "..");
586 $this->ctrl->setParameter($this, "mep_fold", $parent_id);
587 if ($ilCtrl->isAsynch()) {
588 $tpl->setVariable("LINK", "#");
589 $tpl->setVariable(
590 "LR_ONCLICK",
591 " onclick=\"return il.IntLink.setMepPoolFolder('" . $parent_id . "');\" "
592 );
593 } else {
594 $tpl->setVariable(
595 "LINK",
596 $this->ctrl->getLinkTarget($this, "setMedPoolFolder")
597 );
598 }
599 $tpl->parseCurrentBlock();
600 $tpl->setCurrentBlock("row");
601 $tpl->parseCurrentBlock();
602 }
603 foreach ($objs as $obj) {
604 if ($obj["type"] == "fold") {
605 $css_row = ($css_row == "tblrow2")
606 ? "tblrow1"
607 : "tblrow2";
608 $tpl->setCurrentBlock("icon");
609 $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.svg"));
610 $tpl->parseCurrentBlock();
611 $tpl->setCurrentBlock("link_row");
612 $tpl->setVariable("ROWCLASS", $css_row);
613 $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
614 $this->ctrl->setParameter($this, "mep_fold", $obj["child"]);
615 if ($ilCtrl->isAsynch()) {
616 $tpl->setVariable("LINK", "#");
617 $tpl->setVariable(
618 "LR_ONCLICK",
619 " onclick=\"return il.IntLink.setMepPoolFolder('" . $obj["child"] . "');\" "
620 );
621 } else {
622 $tpl->setVariable(
623 "LINK",
624 $this->ctrl->getLinkTarget($this, "setMedPoolFolder")
625 );
626 }
627 $tpl->parseCurrentBlock();
628 } else {
629 $fid = ilMediaPoolItem::lookupForeignId($obj["child"]);
630 if (ilObject::_lookupType($fid) == "mob") {
631 $this->renderLink(
632 $tpl,
633 $obj["title"],
634 $fid,
635 "MediaObject",
636 "mob",
637 "media"
638 );
639 }
640 }
641 $tpl->setCurrentBlock("row");
642 $tpl->parseCurrentBlock();
643 }
644 $tpl->setCurrentBlock("chapter_list");
645 $tpl->parseCurrentBlock();
646 }
647 break;
648
649 // wiki page link
650 case "WikiPage":
651 $wiki_id = ilObject::_lookupObjId($this->parent_ref_id);
652 require_once("./Modules/Wiki/classes/class.ilWikiPage.php");
653 $wpages = ilWikiPage::getAllWikiPages($wiki_id);
654
655 // get all glossary items
656 $tpl->setCurrentBlock("chapter_list");
657 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("obj_wiki"));
658 $tpl->setVariable("TXT_CONT_TITLE", ilObject::_lookupTitle($wiki_id));
659 $tpl->setVariable("THEAD", $this->lng->txt("link_wpages"));
660 $tpl->setCurrentBlock("change_cont_obj");
661 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
662 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
663 $tpl->parseCurrentBlock();
664
665 foreach ($wpages as $wpage) {
666 $this->renderLink(
667 $tpl,
668 $wpage["title"],
669 $wpage["id"],
670 "WikiPage",
671 "wpage",
672 "wpage"
673 );
674 }
675
676 $tpl->setCurrentBlock("chapter_list");
677 $tpl->parseCurrentBlock();
678 break;
679
680 // Portfolio page link
681 case "PortfolioPage":
682 case "PortfolioTemplatePage":
683 $prtf_id = $this->parent_obj_id;
684 require_once("./Modules/Portfolio/classes/class.ilPortfolioPage.php");
685 $ppages = ilPortfolioPage::getAllPortfolioPages($prtf_id);
686
687 // get all glossary items
688 $tpl->setCurrentBlock("chapter_list");
689 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("obj_" . ilObject::_lookupType($prtf_id)));
690 $tpl->setVariable("TXT_CONT_TITLE", ilObject::_lookupTitle($prtf_id));
691 $tpl->setVariable("THEAD", $this->lng->txt("pages"));
692
693 foreach ($ppages as $ppage) {
694 $this->renderLink(
695 $tpl,
696 $ppage["title"],
697 $ppage["id"],
698 "PortfolioPage",
699 "ppage",
700 "ppage",
701 array(),
702 $ppage["title"]
703 );
704 }
705
706 $tpl->setCurrentBlock("chapter_list");
707 $tpl->parseCurrentBlock();
708 break;
709
710 // repository item
711 case "RepositoryItem":
712 $tpl->setVariable("LINK_HELP_CONTENT", $this->selectRepositoryItem());
713 break;
714
715 // file download link
716 case "File":
717 if (!is_object($this->uploaded_file)) {
718 $tpl->setVariable("LINK_HELP_CONTENT", $this->getFileLinkHTML());
719 } else {
720 echo $this->getFileLinkHTML();
721 exit;
722 }
723 break;
724
725 // file download link
726 case "User":
727 $tpl->setVariable("LINK_HELP_CONTENT", $this->addUser());
728 break;
729
730 }
731
732 if ($ilCtrl->isAsynch()) {
733 echo $tpl->get();
734 exit;
735 }
736
737 exit;
738 }
739
744 public function getFileLinkHTML()
745 {
748
749 if (!is_object($this->uploaded_file)) {
750 $tpl = new ilTemplate("tpl.link_file.html", true, true, "Services/Link");
751 $tpl->setCurrentBlock("form");
752 $tpl->setVariable(
753 "FORM_ACTION",
754 $ilCtrl->getFormAction($this, "saveFileLink", "", true)
755 );
756 $tpl->setVariable("TXT_SELECT_FILE", $lng->txt("cont_select_file"));
757 $tpl->setVariable("TXT_SAVE_LINK", $lng->txt("cont_create_link"));
758 $tpl->setVariable("CMD_SAVE_LINK", "saveFileLink");
759 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
760 $fi = new ilFileInputGUI("", "link_file");
761 $fi->setSize(15);
762 $tpl->setVariable("INPUT", $fi->getToolbarHTML());
763 $tpl->parseCurrentBlock();
764 return $tpl->get();
765 } else {
766 $tpl = new ilTemplate("tpl.link_file.html", true, true, "Services/Link");
767 $tpl->setCurrentBlock("link_js");
768 // $tpl->setVariable("LINK_FILE",
769 // $this->prepareJavascriptOutput("[iln dfile=\"".$this->uploaded_file->getId()."\"] [/iln]")
770 // );
771 $tpl->setVariable(
772 "TAG_B",
773 '[iln dfile=\x22' . $this->uploaded_file->getId() . '\x22]'
774 );
775 $tpl->setVariable(
776 "TAG_E",
777 "[/iln]"
778 );
779 $tpl->setVariable(
780 "TXT_FILE",
781 $this->uploaded_file->getTitle()
782 );
783 // $tpl->parseCurrentBlock();
784 return $tpl->get();
785 }
786 }
787
791 public function saveFileLink()
792 {
793 if ($_FILES["link_file"]["name"] != "") {
794 include_once("./Modules/File/classes/class.ilObjFile.php");
795 $fileObj = new ilObjFile();
796 $fileObj->setType("file");
797 $fileObj->setTitle($_FILES["link_file"]["name"]);
798 $fileObj->setDescription("");
799 $fileObj->setFileName($_FILES["link_file"]["name"]);
800 $fileObj->setFileType($_FILES["link_file"]["type"]);
801 $fileObj->setFileSize($_FILES["link_file"]["size"]);
802 $fileObj->setMode("filelist");
803 $fileObj->create();
804 // upload file to filesystem
805 $fileObj->createDirectory();
806 $fileObj->raiseUploadError(false);
807 $fileObj->getUploadFile(
808 $_FILES["link_file"]["tmp_name"],
809 $_FILES["link_file"]["name"]
810 );
811 $this->uploaded_file = $fileObj;
812 }
813 $this->showLinkHelp();
814 }
815
819 public function outputThumbnail(&$tpl, $a_id, $a_mode = "")
820 {
821 // output thumbnail
822 $mob = new ilObjMediaObject($a_id);
823 $med = &$mob->getMediaItem("Standard");
824 $target = $med->getThumbnailTarget("small");
825 $suff = "";
826 if ($this->getSetLinkTargetScript() != "") {
827 $tpl->setCurrentBlock("thumbnail_link");
828 $suff = "_link";
829 } else {
830 $tpl->setCurrentBlock("thumbnail_js");
831 $suff = "_js";
832 }
833
834 if ($target != "") {
835 $tpl->setCurrentBlock("thumb" . $suff);
836 $tpl->setVariable("SRC_THUMB", $target);
837 $tpl->parseCurrentBlock();
838 } else {
839 $tpl->setVariable("NO_THUMB", "&nbsp;");
840 }
841
842 if ($this->getSetLinkTargetScript() != "") {
843 $tpl->setCurrentBlock("thumbnail_link");
844 } else {
845 $tpl->setCurrentBlock("thumbnail_js");
846 }
847 $tpl->parseCurrentBlock();
848 }
849
850
854 public function changeLinkType()
855 {
857
858 $ctrl->setParameter($this, "link_type", $_GET["link_type"]);
859 $base_type = explode("_", $_GET["link_type"])[0];
860 if ($this->parent_type[$base_type] != ilObject::_lookupType($this->parent_ref_id, true)) {
861 $ctrl->setParameter($this, "link_par_ref_id", 0);
862 $ctrl->setParameter($this, "link_par_obj_id", 0);
863 }
864
865 $ctrl->redirect($this, "showLinkHelp", "", true);
866 }
867
871 public function setMedPoolFolder()
872 {
874 $ctrl->setParameter($this, "link_par_fold_id", $_GET["mep_fold"]);
875 $ctrl->redirect($this, "showLinkHelp", "", true);
876 }
877
881 public function getTargetExplorer()
882 {
883 //$ilCtrl->setParameter($this, "target_type", $a_type);
884 include_once("./Services/Link/classes/class.ilLinkTargetObjectExplorerGUI.php");
885 $exp = new ilLinkTargetObjectExplorerGUI($this, "getTargetExplorer", $this->link_type);
886
887 $a_type = $this->parent_type[$this->base_link_type];
888
889 $white = array("root", "cat", "crs", "fold", "grp");
890
891 $white[] = $a_type;
892 $exp->setClickableType($a_type);
893 if ($a_type == "prtf") {
894 $white[] = "prtt";
895 $exp->setClickableType("prtt");
896 }
897
898 $exp->setTypeWhiteList($white);
899
900
901 if (!$exp->handleCommand()) {
902 return $exp->getHTML();
903 }
904 }
905
909 public function changeTargetObject($a_type = "")
910 {
912
913 $ilCtrl->setParameter($this, "link_par_fold_id", "");
914 if ($_GET["do"] == "set") {
915 $ilCtrl->setParameter($this, "link_par_ref_id", $_GET["sel_id"]);
916 $ilCtrl->redirect($this, "showLinkHelp", "", true);
917 return;
918 }
919
920 $ilCtrl->setParameter($this, "link_type", $this->link_type);
921
922 $tpl = new ilTemplate("tpl.link_help_explorer.html", true, true, "Services/Link");
923
924 $output = $this->getTargetExplorer();
925
926 $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_" . $this->parent_type[$this->base_link_type]));
927
928 $tpl->setVariable("EXPLORER", $output);
929 $tpl->setVariable("ACTION", $this->ctrl->getFormAction($this, "resetLinkList", "", true));
930 $tpl->setVariable("BTN_RESET", "resetLinkList");
931 $tpl->setVariable("TXT_RESET", $this->lng->txt("back"));
932
933 if ($this->parent_type[$this->base_link_type] == "mep") {
934 $tpl->setCurrentBlock("sel_clipboard");
935 $this->ctrl->setParameter($this, "do", "set");
936 if ($ilCtrl->isAsynch()) {
937 $tpl->setVariable("LINK_CLIPBOARD", "#");
938 $tpl->setVariable(
939 "CLIPBOARD_ONCLICK",
940 " onclick=\"return il.IntLink.selectLinkTargetObject('mep', 0, '" . $this->link_type . "');\" "
941 );
942 } else {
943 $tpl->setVariable("LINK_CLIPBOARD", $this->ctrl->getLinkTarget($this, "changeTargetObject"));
944 }
945 $tpl->setVariable("TXT_PERS_CLIPBOARD", $this->lng->txt("clipboard"));
946 $tpl->parseCurrentBlock();
947 }
948
949 $tpl->parseCurrentBlock();
950
951 echo $tpl->get();
952 exit;
953 }
954
955
959 public function selectRepositoryItem()
960 {
962
963 $ilCtrl->setParameter($this, "link_par_fold_id", "");
964
965 //$ilCtrl->setParameter($this, "target_type", $a_type);
966 include_once("./Services/Link/classes/class.ilIntLinkRepItemExplorerGUI.php");
967 $exp = new ilIntLinkRepItemExplorerGUI($this, "selectRepositoryItem");
968 $exp->setSetLinkTargetScript($this->getSetLinkTargetScript());
969
970 if (!$exp->handleCommand()) {
971 return $exp->getHTML();
972 }
973 }
974
979 {
980 $output = $this->selectRepositoryItem();
981 echo $output;
982 exit;
983 }
984
985
989 public static function getInitHTML($a_url)
990 {
991 global $DIC;
992
993 $lng = $DIC->language();
994 $tpl = $DIC["tpl"];
995
996 $lng->loadLanguageModule("link");
997
998 $tpl->addJavaScript("./Services/UIComponent/Explorer/js/ilExplorer.js");
999 include_once("./Services/UIComponent/Explorer2/classes/class.ilExplorerBaseGUI.php");
1001
1002 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1004
1005 $tpl->addJavascript("./Services/Link/js/ilIntLink.js");
1006
1007 // #18721
1008 $tpl->addJavaScript("Services/Form/js/Form.js");
1009
1010 include_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
1011 $modal = ilModalGUI::getInstance();
1012 $modal->setHeading($lng->txt("link_link"));
1013 $modal->setId("ilIntLinkModal");
1014 $modal->setBody("<div id='ilIntLinkModalContent'></div>");
1015
1016 $ltpl = new ilTemplate("tpl.int_link_panel.html", true, true, "Services/Link");
1017 $ltpl->setVariable("MODAL", $modal->getHTML());
1018
1019 $ltpl->setVariable("IL_INT_LINK_URL", $a_url);
1020
1021 return $ltpl->get();
1022 }
1023
1027 public function renderLink(
1028 $tpl,
1029 $a_title,
1030 $a_obj_id,
1031 $a_type,
1032 $a_type_short,
1033 $a_bb_type,
1034 $a_anchors = array(),
1035 $a_link_content = ""
1036 ) {
1037 $chapterRowBlock = "chapter_row_js";
1038 $anchor_row_block = "anchor_link_js";
1039
1040 $target_str = ($this->link_target == "")
1041 ? ""
1042 : " target=\"" . $this->link_target . "\"";
1043
1044 if (count($a_anchors) > 0) {
1045 foreach ($a_anchors as $anchor) {
1046 if ($this->getSetLinkTargetScript() != "") {
1047 // not implemented yet (anchors that work with map areas)
1048
1049 /*$tpl->setCurrentBlock("anchor_link");
1050 $tpl->setVariable("ALINK",
1051 ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
1052 "linktype=".$a_type.
1053 "&linktarget=il__".$a_type_short."_".$a_obj_id.
1054 "&linktargetframe=".$this->link_target).
1055 "&linkanchor=".$anchor);
1056 $tpl->setVariable("TXT_ALINK", "#" . $anchor);
1057 $tpl->parseCurrentBlock();*/
1058 } else {
1059 $tpl->setCurrentBlock($anchor_row_block);
1060 $tpl->setVariable(
1061 "ALINK_BEGIN",
1062 $this->prepareJavascriptOutput("[iln " . $a_bb_type . "=\"" . $a_obj_id . "\"" . $target_str . " anchor=\"$anchor\"]")
1063 );
1064 $tpl->setVariable("ALINK_END", "[/iln]");
1065 $tpl->setVariable("TXT_LINK", "#" . $anchor);
1066 $tpl->parseCurrentBlock();
1067 }
1068 }
1069 }
1070
1071 $this->css_row = ($this->css_row == "tblrow1")
1072 ? "tblrow2"
1073 : "tblrow1";
1074
1075 if ($this->getSetLinkTargetScript() != "") {
1076 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1077 require_once("./Services/MediaObjects/classes/class.ilImageMapEditorGUI.php");
1079 if ($a_type == "MediaObject") {
1080 $this->outputThumbnail($tpl, $a_obj_id);
1081 }
1082 $tpl->setCurrentBlock("link_row");
1083 $tpl->setVariable("ROWCLASS", $this->css_row);
1084 $tpl->setVariable("TXT_CHAPTER", $a_title);
1085 $tpl->setVariable(
1086 "LINK",
1088 $this->getSetLinkTargetScript(),
1089 "linktype=" . $a_type .
1090 "&linktarget=il__" . $a_type_short . "_" . $a_obj_id .
1091 "&linktargetframe=" . $this->link_target
1092 )
1093 );
1094 $tpl->parseCurrentBlock();
1095 } else {
1096 $tpl->setCurrentBlock($chapterRowBlock);
1097 if ($a_type == "MediaObject") {
1098 $this->outputThumbnail($tpl, $a_obj_id);
1099 $tpl->setCurrentBlock($chapterRowBlock);
1100 }
1101 $tpl->setVariable("ROWCLASS", $this->css_row);
1102 $tpl->setVariable("TXT_CHAPTER", $a_title);
1103 if ($a_type == "MediaObject" && empty($target_str)) {
1104 $tpl->setVariable(
1105 "LINK_BEGIN",
1106 $this->prepareJavascriptOutput("[iln " . $a_bb_type . "=\"" . $a_obj_id . "\"/]")
1107 );
1108 $tpl->setVariable("LINK_END", "");
1109 } else {
1110 $tpl->setVariable(
1111 "LINK_BEGIN",
1112 $this->prepareJavascriptOutput("[iln " . $a_bb_type . "=\"" . $a_obj_id . "\"" . $target_str . "]")
1113 );
1114 $tpl->setVariable("LINK_CONTENT", $a_link_content);
1115 $tpl->setVariable("LINK_END", "[/iln]");
1116 }
1117 $tpl->parseCurrentBlock();
1118 }
1119
1120 $tpl->setCurrentBlock("row");
1121 $tpl->parseCurrentBlock();
1122 }
1123
1130 public function addUser()
1131 {
1132 $form = $this->initUserSearchForm();
1133 return $form->getHTML() . $this->getUserSearchResult();
1134 }
1135
1139 public function initUserSearchForm()
1140 {
1141 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1142 $form = new ilPropertyFormGUI();
1143 $form->setId("link_user_search_form");
1144
1145 // user search
1146 $ti = new ilTextInputGUI($this->lng->txt("obj_user"), "usr_search_str");
1147 $ti->setValue($_POST["usr_search_str"]);
1148 $form->addItem($ti);
1149
1150 $form->addCommandButton("searchUser", $this->lng->txt("search"));
1151
1152 return $form;
1153 }
1154
1161 public function getUserSearchResult()
1162 {
1163 global $DIC;
1164
1165 $tpl = $DIC["tpl"];
1166 $lng = $DIC->language();
1167
1168 if (strlen($_POST["usr_search_str"]) < 3) {
1169 if (strlen($_POST["usr_search_str"]) > 0) {
1170 $lng->loadLanguageModule("search");
1171 return $tpl->getMessageHTML($lng->txt("search_minimum_three"), "info");
1172 }
1173
1174 return "";
1175 }
1176
1177 $form = $this->initUserSearchForm();
1178 $form->checkInput();
1179
1180 $users = ilInternalLink::searchUsers($form->getInput("usr_search_str"));
1181 if (count($users) == 0) {
1182 return $tpl->getMessageHTML($lng->txt("cont_user_search_did_not_match"), "info");
1183 }
1184
1185 $f = $DIC->ui()->factory();
1186 $r = $DIC->ui()->renderer();
1187 $lng = $DIC->language();
1188 $cards = array();
1189 foreach ($users as $user) {
1190 $b = $f->button()->standard($lng->txt("insert"), "#")
1191 ->withOnLoadCode(function ($id) use ($user) {
1192 return
1193 '$("#' . $id . "\").click(function(ev) { il.IntLink.addInternalLink('[iln user=\"" .
1194 ilObjUser::_lookupLogin($user) . "\"/]', '', ev); return false;});";
1195 });
1197 $cards[] = $f->card()->standard($name, $f->image()->responsive(ilObjUser::_getPersonalPicturePath($user, "small"), $name))
1198 ->withSections(array($b));
1199 }
1200 $deck = $f->deck($cards)->withLargeCardsSize();
1201
1202 return $r->renderAsync($deck);
1203 }
1204}
user()
Definition: user.php:4
$tpl
Definition: ilias.php:10
global $l
Definition: afr.php:30
$users
Definition: authpage.php:44
exit
Definition: backend.php:16
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static init($a_main_tpl=null)
Init JS.
This class represents a file property in a property form.
static _recoverParameters()
Recover parameters from session variables (static)
Internal Link: Repository Item Selector Explorer.
Class ilInternalLinkGUI.
__construct($a_default_link_type, $a_default_parent_id, $a_is_ref=true)
refreshRepositorySelector()
Refresh Repository Selector.
setMedPoolFolder()
select media pool folder
getTargetExplorer()
Cange target object.
static getInitHTML($a_url)
Get initialisation HTML to use interna link editing.
saveFileLink()
Save file link.
renderLink( $tpl, $a_title, $a_obj_id, $a_type, $a_type_short, $a_bb_type, $a_anchors=array(), $a_link_content="")
Render internal link item.
selectRepositoryItem()
select repository item explorer
getFileLinkHTML()
Get HTML for file link.
setFilterWhiteList($a_white_list)
Set filter list as white list (per detault it is a black list)
initUserSearchForm()
Init user search form.
setMode($a_mode="text")
Set mode.
changeTargetObject($a_type="")
Cange target object.
changeLinkType()
change link type
showLinkHelp()
Show link help list.
init()
Init (first in execute command)
outputThumbnail(&$tpl, $a_id, $a_mode="")
output thumbnail
prepareJavascriptOutput($str)
Prepare output for JS enabled editing.
static getPageList($lm_id)
static
Internal Link: Repository Item Selector Explorer.
static lookupForeignId($a_id)
Lookup Foreign Id.
static getInstance()
Get instance.
Class ilObjFile.
Class ilObjGlossary.
Class ilObjLearningModule.
Class ilObjMediaObject.
Media pool object.
static _lookupLogin($a_user_id)
lookup login
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
static _readAnchors($a_parent_type, $a_page_id, $a_page_lang="-")
Read anchors of a page.
static getAllPortfolioPages($a_portfolio_id)
Get pages of portfolio.
This class represents a property form user interface.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static redirect($a_script)
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static getAllWikiPages($a_wiki_id)
Get all pages of wiki.
static initConnection(ilTemplate $a_main_tpl=null)
Init YUI Connection module.
$white
Definition: example_030.php:84
$r
Definition: example_031.php:79
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
$target
Definition: test.php:19
$ret
Definition: parser.php:6
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92