ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 ilGlobalTemplate("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 ilGlobalTemplate("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 $glossary = new ilObjGlossary($this->parent_ref_id, true);
485
486 // get all glossary items
487 $terms = $glossary->getTermList();
488 $tpl->setCurrentBlock("chapter_list");
489 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("glossary"));
490 $tpl->setVariable("TXT_CONT_TITLE", $glossary->getTitle());
491 $tpl->setVariable("THEAD", $this->lng->txt("link_terms"));
492 $tpl->setCurrentBlock("change_cont_obj");
493 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
494 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
495 $tpl->parseCurrentBlock();
496
497 foreach ($terms as $term) {
498 $this->renderLink(
499 $tpl,
500 $term["term"],
501 $term["id"],
502 "GlossaryItem",
503 "git",
504 "term"
505 );
506 }
507
508 $tpl->setCurrentBlock("chapter_list");
509 $tpl->parseCurrentBlock();
510 break;
511
512 // media object
513 case "Media":
514 include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
515 //$tpl->setVariable("TARGET2", " target=\"content\" ");
516 // content object id = 0 --> get clipboard objects
517 if ($this->parent_ref_id == 0) {
518 $tpl->setCurrentBlock("change_cont_obj");
519 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
520 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
521 $tpl->parseCurrentBlock();
522 $mobjs = $ilUser->getClipboardObjects("mob");
523 // sort by name
524 $objs = array();
525 foreach ($mobjs as $obj) {
526 $objs[$obj["title"] . ":" . $obj["id"]] = $obj;
527 }
528 ksort($objs);
529 $tpl->setCurrentBlock("chapter_list");
530 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_media_source"));
531 $tpl->setVariable("TXT_CONT_TITLE", $this->lng->txt("cont_personal_clipboard"));
532 $tpl->setVariable("THEAD", $this->lng->txt("link_mobs"));
533 $tpl->setVariable("COLSPAN", "2");
534
535 foreach ($objs as $obj) {
536 $this->renderLink(
537 $tpl,
538 $obj["title"],
539 $obj["id"],
540 "MediaObject",
541 "mob",
542 "media"
543 );
544 }
545 $tpl->setCurrentBlock("chapter_list");
546 $tpl->parseCurrentBlock();
547 } else {
548 require_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
549 $med_pool = new ilObjMediaPool($this->parent_ref_id, true);
550 // get current folders
551 $fobjs = $med_pool->getChilds($this->parent_fold_id, "fold");
552 $f2objs = array();
553 foreach ($fobjs as $obj) {
554 $f2objs[$obj["title"] . ":" . $obj["child"]] = $obj;
555 }
556 ksort($f2objs);
557 // get current media objects
558 $mobjs = $med_pool->getChilds($this->parent_fold_id, "mob");
559 $m2objs = array();
560 foreach ($mobjs as $obj) {
561 $m2objs[$obj["title"] . ":" . $obj["child"]] = $obj;
562 }
563 ksort($m2objs);
564
565 // merge everything together
566 $objs = array_merge($f2objs, $m2objs);
567
568 $tpl->setCurrentBlock("chapter_list");
569 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("mep"));
570 $tpl->setVariable("TXT_CONT_TITLE", $med_pool->getTitle());
571 $tpl->setVariable("THEAD", $this->lng->txt("link_mobs"));
572 $tpl->setCurrentBlock("change_cont_obj");
573 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
574 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
575 $tpl->setVariable("COLSPAN", "2");
576 $tpl->parseCurrentBlock();
577 if ($parent_id = $med_pool->getParentId($this->parent_fold_id)) {
578 $css_row = "tblrow1";
579 $tpl->setCurrentBlock("icon");
580 $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.svg"));
581 $tpl->parseCurrentBlock();
582 $tpl->setCurrentBlock("link_row");
583 $tpl->setVariable("ROWCLASS", $css_row);
584 $tpl->setVariable("TXT_CHAPTER", "..");
585 $this->ctrl->setParameter($this, "mep_fold", $parent_id);
586 if ($ilCtrl->isAsynch()) {
587 $tpl->setVariable("LINK", "#");
588 $tpl->setVariable(
589 "LR_ONCLICK",
590 " onclick=\"return il.IntLink.setMepPoolFolder('" . $parent_id . "');\" "
591 );
592 } else {
593 $tpl->setVariable(
594 "LINK",
595 $this->ctrl->getLinkTarget($this, "setMedPoolFolder")
596 );
597 }
598 $tpl->parseCurrentBlock();
599 $tpl->setCurrentBlock("row");
600 $tpl->parseCurrentBlock();
601 }
602 foreach ($objs as $obj) {
603 if ($obj["type"] == "fold") {
604 $css_row = ($css_row == "tblrow2")
605 ? "tblrow1"
606 : "tblrow2";
607 $tpl->setCurrentBlock("icon");
608 $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.svg"));
609 $tpl->parseCurrentBlock();
610 $tpl->setCurrentBlock("link_row");
611 $tpl->setVariable("ROWCLASS", $css_row);
612 $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
613 $this->ctrl->setParameter($this, "mep_fold", $obj["child"]);
614 if ($ilCtrl->isAsynch()) {
615 $tpl->setVariable("LINK", "#");
616 $tpl->setVariable(
617 "LR_ONCLICK",
618 " onclick=\"return il.IntLink.setMepPoolFolder('" . $obj["child"] . "');\" "
619 );
620 } else {
621 $tpl->setVariable(
622 "LINK",
623 $this->ctrl->getLinkTarget($this, "setMedPoolFolder")
624 );
625 }
626 $tpl->parseCurrentBlock();
627 } else {
628 $fid = ilMediaPoolItem::lookupForeignId($obj["child"]);
629 if (ilObject::_lookupType($fid) == "mob") {
630 $this->renderLink(
631 $tpl,
632 $obj["title"],
633 $fid,
634 "MediaObject",
635 "mob",
636 "media"
637 );
638 }
639 }
640 $tpl->setCurrentBlock("row");
641 $tpl->parseCurrentBlock();
642 }
643 $tpl->setCurrentBlock("chapter_list");
644 $tpl->parseCurrentBlock();
645 }
646 break;
647
648 // wiki page link
649 case "WikiPage":
650 $wiki_id = ilObject::_lookupObjId($this->parent_ref_id);
651 require_once("./Modules/Wiki/classes/class.ilWikiPage.php");
652 $wpages = ilWikiPage::getAllWikiPages($wiki_id);
653
654 // get all glossary items
655 $tpl->setCurrentBlock("chapter_list");
656 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("obj_wiki"));
657 $tpl->setVariable("TXT_CONT_TITLE", ilObject::_lookupTitle($wiki_id));
658 $tpl->setVariable("THEAD", $this->lng->txt("link_wpages"));
659 $tpl->setCurrentBlock("change_cont_obj");
660 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
661 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
662 $tpl->parseCurrentBlock();
663
664 foreach ($wpages as $wpage) {
665 $this->renderLink(
666 $tpl,
667 $wpage["title"],
668 $wpage["id"],
669 "WikiPage",
670 "wpage",
671 "wpage"
672 );
673 }
674
675 $tpl->setCurrentBlock("chapter_list");
676 $tpl->parseCurrentBlock();
677 break;
678
679 // Portfolio page link
680 case "PortfolioPage":
681 case "PortfolioTemplatePage":
682 $prtf_id = $this->parent_obj_id;
683 require_once("./Modules/Portfolio/classes/class.ilPortfolioPage.php");
684 $ppages = ilPortfolioPage::getAllPortfolioPages($prtf_id);
685
686 // get all glossary items
687 $tpl->setCurrentBlock("chapter_list");
688 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("obj_" . ilObject::_lookupType($prtf_id)));
689 $tpl->setVariable("TXT_CONT_TITLE", ilObject::_lookupTitle($prtf_id));
690 $tpl->setVariable("THEAD", $this->lng->txt("pages"));
691
692 foreach ($ppages as $ppage) {
693 $this->renderLink(
694 $tpl,
695 $ppage["title"],
696 $ppage["id"],
697 "PortfolioPage",
698 "ppage",
699 "ppage",
700 array(),
701 $ppage["title"]
702 );
703 }
704
705 $tpl->setCurrentBlock("chapter_list");
706 $tpl->parseCurrentBlock();
707 break;
708
709 // repository item
710 case "RepositoryItem":
711 $tpl->setVariable("LINK_HELP_CONTENT", $this->selectRepositoryItem());
712 break;
713
714 // file download link
715 case "File":
716 if (!is_object($this->uploaded_file)) {
717 $tpl->setVariable("LINK_HELP_CONTENT", $this->getFileLinkHTML());
718 } else {
719 echo $this->getFileLinkHTML();
720 exit;
721 }
722 break;
723
724 // file download link
725 case "User":
726 $tpl->setVariable("LINK_HELP_CONTENT", $this->addUser());
727 break;
728
729 }
730
731 if ($ilCtrl->isAsynch()) {
732 echo $tpl->get();
733 exit;
734 }
735
736 exit;
737 }
738
743 public function getFileLinkHTML()
744 {
747
748 if (!is_object($this->uploaded_file)) {
749 $tpl = new ilTemplate("tpl.link_file.html", true, true, "Services/Link");
750 $tpl->setCurrentBlock("form");
751 $tpl->setVariable(
752 "FORM_ACTION",
753 $ilCtrl->getFormAction($this, "saveFileLink", "", true)
754 );
755 $tpl->setVariable("TXT_SELECT_FILE", $lng->txt("cont_select_file"));
756 $tpl->setVariable("TXT_SAVE_LINK", $lng->txt("cont_create_link"));
757 $tpl->setVariable("CMD_SAVE_LINK", "saveFileLink");
758 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
759 $fi = new ilFileInputGUI("", "link_file");
760 $fi->setSize(15);
761 $tpl->setVariable("INPUT", $fi->getToolbarHTML());
762 $tpl->parseCurrentBlock();
763 return $tpl->get();
764 } else {
765 $tpl = new ilTemplate("tpl.link_file.html", true, true, "Services/Link");
766 $tpl->setCurrentBlock("link_js");
767 // $tpl->setVariable("LINK_FILE",
768 // $this->prepareJavascriptOutput("[iln dfile=\"".$this->uploaded_file->getId()."\"] [/iln]")
769 // );
770 $tpl->setVariable(
771 "TAG_B",
772 '[iln dfile=\x22' . $this->uploaded_file->getId() . '\x22]'
773 );
774 $tpl->setVariable(
775 "TAG_E",
776 "[/iln]"
777 );
778 $tpl->setVariable(
779 "TXT_FILE",
780 $this->uploaded_file->getTitle()
781 );
782 // $tpl->parseCurrentBlock();
783 return $tpl->get();
784 }
785 }
786
790 public function saveFileLink()
791 {
792 if ($_FILES["link_file"]["name"] != "") {
793 include_once("./Modules/File/classes/class.ilObjFile.php");
794 $fileObj = new ilObjFile();
795 $fileObj->setType("file");
796 $fileObj->setTitle($_FILES["link_file"]["name"]);
797 $fileObj->setDescription("");
798 $fileObj->setFileName($_FILES["link_file"]["name"]);
799 $fileObj->setFileType($_FILES["link_file"]["type"]);
800 $fileObj->setFileSize($_FILES["link_file"]["size"]);
801 $fileObj->setMode("filelist");
802 $fileObj->create();
803 // upload file to filesystem
804 $fileObj->createDirectory();
805 $fileObj->raiseUploadError(false);
806 $fileObj->getUploadFile(
807 $_FILES["link_file"]["tmp_name"],
808 $_FILES["link_file"]["name"]
809 );
810 $this->uploaded_file = $fileObj;
811 }
812 $this->showLinkHelp();
813 }
814
818 public function outputThumbnail(&$tpl, $a_id, $a_mode = "")
819 {
820 // output thumbnail
821 $mob = new ilObjMediaObject($a_id);
822 $med = &$mob->getMediaItem("Standard");
823 $target = $med->getThumbnailTarget("small");
824 $suff = "";
825 if ($this->getSetLinkTargetScript() != "") {
826 $tpl->setCurrentBlock("thumbnail_link");
827 $suff = "_link";
828 } else {
829 $tpl->setCurrentBlock("thumbnail_js");
830 $suff = "_js";
831 }
832
833 if ($target != "") {
834 $tpl->setCurrentBlock("thumb" . $suff);
835 $tpl->setVariable("SRC_THUMB", $target);
836 $tpl->parseCurrentBlock();
837 } else {
838 $tpl->setVariable("NO_THUMB", "&nbsp;");
839 }
840
841 if ($this->getSetLinkTargetScript() != "") {
842 $tpl->setCurrentBlock("thumbnail_link");
843 } else {
844 $tpl->setCurrentBlock("thumbnail_js");
845 }
846 $tpl->parseCurrentBlock();
847 }
848
849
853 public function changeLinkType()
854 {
856
857 $ctrl->setParameter($this, "link_type", $_GET["link_type"]);
858 $base_type = explode("_", $_GET["link_type"])[0];
859 if ($this->parent_type[$base_type] != ilObject::_lookupType($this->parent_ref_id, true)) {
860 $ctrl->setParameter($this, "link_par_ref_id", 0);
861 $ctrl->setParameter($this, "link_par_obj_id", 0);
862 }
863
864 $ctrl->redirect($this, "showLinkHelp", "", true);
865 }
866
870 public function setMedPoolFolder()
871 {
873 $ctrl->setParameter($this, "link_par_fold_id", $_GET["mep_fold"]);
874 $ctrl->redirect($this, "showLinkHelp", "", true);
875 }
876
880 public function getTargetExplorer()
881 {
882 //$ilCtrl->setParameter($this, "target_type", $a_type);
883 include_once("./Services/Link/classes/class.ilLinkTargetObjectExplorerGUI.php");
884 $exp = new ilLinkTargetObjectExplorerGUI($this, "getTargetExplorer", $this->link_type);
885
886 $a_type = $this->parent_type[$this->base_link_type];
887
888 $white = array("root", "cat", "crs", "fold", "grp");
889
890 $white[] = $a_type;
891 $exp->setClickableType($a_type);
892 if ($a_type == "prtf") {
893 $white[] = "prtt";
894 $exp->setClickableType("prtt");
895 }
896
897 $exp->setTypeWhiteList($white);
898
899
900 if (!$exp->handleCommand()) {
901 return $exp->getHTML();
902 }
903 }
904
908 public function changeTargetObject($a_type = "")
909 {
911
912 $ilCtrl->setParameter($this, "link_par_fold_id", "");
913 if ($_GET["do"] == "set") {
914 $ilCtrl->setParameter($this, "link_par_ref_id", $_GET["sel_id"]);
915 $ilCtrl->redirect($this, "showLinkHelp", "", true);
916 return;
917 }
918
919 $ilCtrl->setParameter($this, "link_type", $this->link_type);
920
921 $tpl = new ilTemplate("tpl.link_help_explorer.html", true, true, "Services/Link");
922
923 $output = $this->getTargetExplorer();
924
925 $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_" . $this->parent_type[$this->base_link_type]));
926
927 $tpl->setVariable("EXPLORER", $output);
928 $tpl->setVariable("ACTION", $this->ctrl->getFormAction($this, "resetLinkList", "", true));
929 $tpl->setVariable("BTN_RESET", "resetLinkList");
930 $tpl->setVariable("TXT_RESET", $this->lng->txt("back"));
931
932 if ($this->parent_type[$this->base_link_type] == "mep") {
933 $tpl->setCurrentBlock("sel_clipboard");
934 $this->ctrl->setParameter($this, "do", "set");
935 if ($ilCtrl->isAsynch()) {
936 $tpl->setVariable("LINK_CLIPBOARD", "#");
937 $tpl->setVariable(
938 "CLIPBOARD_ONCLICK",
939 " onclick=\"return il.IntLink.selectLinkTargetObject('mep', 0, '" . $this->link_type . "');\" "
940 );
941 } else {
942 $tpl->setVariable("LINK_CLIPBOARD", $this->ctrl->getLinkTarget($this, "changeTargetObject"));
943 }
944 $tpl->setVariable("TXT_PERS_CLIPBOARD", $this->lng->txt("clipboard"));
945 $tpl->parseCurrentBlock();
946 }
947
948 $tpl->parseCurrentBlock();
949
950 echo $tpl->get();
951 exit;
952 }
953
954
958 public function selectRepositoryItem()
959 {
961
962 $ilCtrl->setParameter($this, "link_par_fold_id", "");
963
964 //$ilCtrl->setParameter($this, "target_type", $a_type);
965 include_once("./Services/Link/classes/class.ilIntLinkRepItemExplorerGUI.php");
966 $exp = new ilIntLinkRepItemExplorerGUI($this, "selectRepositoryItem");
967 $exp->setSetLinkTargetScript($this->getSetLinkTargetScript());
968
969 if (!$exp->handleCommand()) {
970 return $exp->getHTML();
971 }
972 }
973
978 {
979 $output = $this->selectRepositoryItem();
980 echo $output;
981 exit;
982 }
983
984
988 public static function getInitHTML($a_url)
989 {
990 global $DIC;
991
992 $lng = $DIC->language();
993 $tpl = $DIC["tpl"];
994
995 $lng->loadLanguageModule("link");
996
997 $tpl->addJavaScript("./Services/UIComponent/Explorer/js/ilExplorer.js");
998 include_once("./Services/UIComponent/Explorer2/classes/class.ilExplorerBaseGUI.php");
1000
1001 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1003
1004 $tpl->addJavascript("./Services/Link/js/ilIntLink.js");
1005
1006 // #18721
1007 $tpl->addJavaScript("Services/Form/js/Form.js");
1008
1009 include_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
1010 $modal = ilModalGUI::getInstance();
1011 $modal->setHeading($lng->txt("link_link"));
1012 $modal->setId("ilIntLinkModal");
1013 $modal->setBody("<div id='ilIntLinkModalContent'></div>");
1014
1015 $ltpl = new ilTemplate("tpl.int_link_panel.html", true, true, "Services/Link");
1016 $ltpl->setVariable("MODAL", $modal->getHTML());
1017
1018 $ltpl->setVariable("IL_INT_LINK_URL", $a_url);
1019
1020 return $ltpl->get();
1021 }
1022
1026 public function renderLink(
1027 $tpl,
1028 $a_title,
1029 $a_obj_id,
1030 $a_type,
1031 $a_type_short,
1032 $a_bb_type,
1033 $a_anchors = array(),
1034 $a_link_content = ""
1035 ) {
1036 $chapterRowBlock = "chapter_row_js";
1037 $anchor_row_block = "anchor_link_js";
1038
1039 $target_str = ($this->link_target == "")
1040 ? ""
1041 : " target=\"" . $this->link_target . "\"";
1042
1043 if (count($a_anchors) > 0) {
1044 foreach ($a_anchors as $anchor) {
1045 if ($this->getSetLinkTargetScript() != "") {
1046 // not implemented yet (anchors that work with map areas)
1047
1048 /*$tpl->setCurrentBlock("anchor_link");
1049 $tpl->setVariable("ALINK",
1050 ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
1051 "linktype=".$a_type.
1052 "&linktarget=il__".$a_type_short."_".$a_obj_id.
1053 "&linktargetframe=".$this->link_target).
1054 "&linkanchor=".$anchor);
1055 $tpl->setVariable("TXT_ALINK", "#" . $anchor);
1056 $tpl->parseCurrentBlock();*/
1057 } else {
1058 $tpl->setCurrentBlock($anchor_row_block);
1059 $tpl->setVariable(
1060 "ALINK_BEGIN",
1061 $this->prepareJavascriptOutput("[iln " . $a_bb_type . "=\"" . $a_obj_id . "\"" . $target_str . " anchor=\"$anchor\"]")
1062 );
1063 $tpl->setVariable("ALINK_END", "[/iln]");
1064 $tpl->setVariable("TXT_LINK", "#" . $anchor);
1065 $tpl->parseCurrentBlock();
1066 }
1067 }
1068 }
1069
1070 $this->css_row = ($this->css_row == "tblrow1")
1071 ? "tblrow2"
1072 : "tblrow1";
1073
1074 if ($this->getSetLinkTargetScript() != "") {
1075 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1076 require_once("./Services/MediaObjects/classes/class.ilImageMapEditorGUI.php");
1078 if ($a_type == "MediaObject") {
1079 $this->outputThumbnail($tpl, $a_obj_id);
1080 }
1081 $tpl->setCurrentBlock("link_row");
1082 $tpl->setVariable("ROWCLASS", $this->css_row);
1083 $tpl->setVariable("TXT_CHAPTER", $a_title);
1084 $tpl->setVariable(
1085 "LINK",
1087 $this->getSetLinkTargetScript(),
1088 "linktype=" . $a_type .
1089 "&linktarget=il__" . $a_type_short . "_" . $a_obj_id .
1090 "&linktargetframe=" . $this->link_target
1091 )
1092 );
1093 $tpl->parseCurrentBlock();
1094 } else {
1095 $tpl->setCurrentBlock($chapterRowBlock);
1096 if ($a_type == "MediaObject") {
1097 $this->outputThumbnail($tpl, $a_obj_id);
1098 $tpl->setCurrentBlock($chapterRowBlock);
1099 }
1100 $tpl->setVariable("ROWCLASS", $this->css_row);
1101 $tpl->setVariable("TXT_CHAPTER", $a_title);
1102 if ($a_type == "MediaObject" && empty($target_str)) {
1103 $tpl->setVariable(
1104 "LINK_BEGIN",
1105 $this->prepareJavascriptOutput("[iln " . $a_bb_type . "=\"" . $a_obj_id . "\"/]")
1106 );
1107 $tpl->setVariable("LINK_END", "");
1108 } else {
1109 $tpl->setVariable(
1110 "LINK_BEGIN",
1111 $this->prepareJavascriptOutput("[iln " . $a_bb_type . "=\"" . $a_obj_id . "\"" . $target_str . "]")
1112 );
1113 $tpl->setVariable("LINK_CONTENT", $a_link_content);
1114 $tpl->setVariable("LINK_END", "[/iln]");
1115 }
1116 $tpl->parseCurrentBlock();
1117 }
1118
1119 $tpl->setCurrentBlock("row");
1120 $tpl->parseCurrentBlock();
1121 }
1122
1129 public function addUser()
1130 {
1131 $form = $this->initUserSearchForm();
1132 return $form->getHTML() . $this->getUserSearchResult();
1133 }
1134
1138 public function initUserSearchForm()
1139 {
1140 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1141 $form = new ilPropertyFormGUI();
1142 $form->setId("link_user_search_form");
1143
1144 // user search
1145 $ti = new ilTextInputGUI($this->lng->txt("obj_user"), "usr_search_str");
1146 $ti->setValue($_POST["usr_search_str"]);
1147 $form->addItem($ti);
1148
1149 $form->addCommandButton("searchUser", $this->lng->txt("search"));
1150
1151 return $form;
1152 }
1153
1160 public function getUserSearchResult()
1161 {
1162 global $DIC;
1163
1164 $tpl = $DIC["tpl"];
1165 $lng = $DIC->language();
1166
1167 if (strlen($_POST["usr_search_str"]) < 3) {
1168 if (strlen($_POST["usr_search_str"]) > 0) {
1169 $lng->loadLanguageModule("search");
1170 return ilUtil::getSystemMessageHTML($lng->txt("search_minimum_three"), "info");
1171 }
1172
1173 return "";
1174 }
1175
1176 $form = $this->initUserSearchForm();
1177 $form->checkInput();
1178
1179 $users = ilInternalLink::searchUsers($form->getInput("usr_search_str"));
1180 if (count($users) == 0) {
1181 return ilUtil::getSystemMessageHTML($lng->txt("cont_user_search_did_not_match"), "info");
1182 }
1183
1184 $f = $DIC->ui()->factory();
1185 $r = $DIC->ui()->renderer();
1186 $lng = $DIC->language();
1187 $cards = array();
1188 foreach ($users as $user) {
1189 $b = $f->button()->standard($lng->txt("insert"), "#")
1190 ->withOnLoadCode(function ($id) use ($user) {
1191 return
1192 '$("#' . $id . "\").click(function(ev) { il.IntLink.addInternalLink('[iln user=\"" .
1193 ilObjUser::_lookupLogin($user) . "\"/]', '', ev); return false;});";
1194 });
1196 $cards[] = $f->card()->standard($name, $f->image()->responsive(ilObjUser::_getPersonalPicturePath($user, "small"), $name))
1197 ->withSections(array($b));
1198 }
1199 $deck = $f->deck($cards)->withLargeCardsSize();
1200
1201 return $r->renderAsync($deck);
1202 }
1203}
user()
Definition: user.php:4
$_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.
special template class to simplify handling of ITX/PEAR
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 _getPersonalPicturePath( $a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false)
Get path to personal picture.
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 getSystemMessageHTML($a_txt, $a_type="info")
Get HTML for a system message.
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(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:29
if($format !==null) $name
Definition: metadata.php:230
$ret
Definition: parser.php:6
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46