ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 var $lng;
24 var $mode; // "text" | "link"
26 var $ctrl;
27 var $tree;
28 var $ltypes = array();
29
30 function __construct($a_default_type, $a_default_obj)
31 {
32 global $lng, $ilias, $ilCtrl, $tree;
33
34 $lng->loadLanguageModule("link");
35
36 $this->initLinkTypes();
37 if (($_SESSION["il_link_cont_obj"] != "" && !$tree->isInTree($_SESSION["il_link_cont_obj"])) ||
38 ($_SESSION["il_link_glossary"] != "" && !$tree->isInTree($_SESSION["il_link_glossary"])) ||
39 ($_SESSION["il_link_wiki"] != "" && !$tree->isInTree($_SESSION["il_link_wiki"])) ||
40 ($_SESSION["il_link_mep"] != "" && !$tree->isInTree($_SESSION["il_link_mep"])))
41 {
42 $this->resetSessionVars();
43 }
44
45 $this->lng = $lng;
46 $this->tree = $tree;
47 $this->ctrl = $ilCtrl;
48 $this->ctrl->saveParameter($this, array("linkmode", "target_type"));
49 $this->default_type = $a_default_type;
50 $this->default_obj = $a_default_obj;
51 $this->filter_link_types = array();
52 $this->mode = "text";
53
54 }
55
59 function initLinkTypes()
60 {
61 global $lng;
62
63 $this->ltypes = array(
64 "StructureObject" => $lng->txt("cont_lk_chapter"),
65 "StructureObject_New" => $lng->txt("cont_lk_chapter_new"),
66 "PageObject" => $lng->txt("cont_lk_page"),
67 "PageObject_FAQ" => $lng->txt("cont_lk_page_faq"),
68 "PageObject_New" => $lng->txt("cont_lk_page_new"),
69 "GlossaryItem" => $lng->txt("cont_lk_term"),
70 "GlossaryItem_New" => $lng->txt("cont_lk_term_new"),
71 "Media" => $lng->txt("cont_lk_media_inline"),
72 "Media_Media" => $lng->txt("cont_lk_media_media"),
73 "Media_FAQ" => $lng->txt("cont_lk_media_faq"),
74 "Media_New" => $lng->txt("cont_lk_media_new"),
75 "WikiPage" => $lng->txt("cont_wiki_page"),
76 "File" => $lng->txt("cont_lk_file"),
77 "RepositoryItem" => $lng->txt("cont_repository_item")
78 );
79 }
80
85 {
86 // determine link type and target
87 $ltype = ($_SESSION["il_link_type"] == "")
88 ? $this->default_type
89 : $_SESSION["il_link_type"];
90 $ltype_arr = explode("_", $ltype);
91
92 if (!isset($this->ltypes[$ltype_arr[0]]) &&
93 !isset($this->ltypes[$ltype]))
94 {
95 $this->link_type = $this->default_type;
96 }
97 else
98 {
99 $this->link_type = ($ltype_arr[0] == "")
100 ? $this->default_type
101 : $ltype_arr[0];
102 $this->link_target = $ltype_arr[1];
103 }
104 }
105
109 function setMode($a_mode = "text")
110 {
111 $this->mode = $a_mode;
112 }
113
114 function setSetLinkTargetScript($a_script)
115 {
116 $this->set_link_script = $a_script;
117 }
118
119 function setReturn($a_return)
120 {
121 $this->return = $a_return;
122 }
123
125 {
127 }
128
129 function filterLinkType($a_link_type)
130 {
131 $this->filter_link_types[] = $a_link_type;
132 }
133
139 function setFilterWhiteList($a_white_list)
140 {
141 $this->filter_white_list = $a_white_list;
142 }
143
144
145 function executeCommand()
146 {
147 $next_class = $this->ctrl->getNextClass($this);
148
149 $cmd = $this->ctrl->getCmd("showLinkHelp");
150 switch($next_class)
151 {
152 default:
153 $ret =& $this->$cmd();
154 break;
155 }
156
157 return $ret;
158 }
159
161 {
162 $_SESSION["il_link_mep"] = "";
163 $_SESSION["il_link_mep_obj"] = "";
164 $_SESSION["il_link_type"] = "";
165 }
166
167 function resetLinkList()
168 {
169 $this->resetSessionVars();
170 $this->determineLinkType();
171 $this->showLinkHelp();
172 }
173
174 function closeLinkHelp()
175 {
176 if ($this->return == "")
177 {
178 $this->ctrl->returnToParent($this);
179 }
180 else
181 {
182 ilUtil::redirect($this->return);
183 }
184 }
185
190 {
191 global $ilUser;
192
193 include_once("./Services/COPage/classes/class.ilPageEditorGUI.php");
194 if (self::_doJSEditing())
195 {
196 $str = htmlspecialchars($str, ENT_QUOTES);
197 }
198 return($str);
199 }
200
201
205 function showLinkHelp()
206 {
207 global $ilUser, $ilCtrl;
208
209 // filter link types
210 if (!$this->filter_white_list)
211 {
212 foreach($this->filter_link_types as $link_type)
213 {
214 unset($this->ltypes[$link_type]);
215 }
216 }
217 else
218 {
219 $ltypes = array();
220 foreach($this->ltypes as $k => $l)
221 {
222 if (in_array($k, $this->filter_link_types))
223 {
224 $ltypes[$k] = $l;
225 }
226 }
227 $this->ltypes = $ltypes;
228 }
229
230
231 // determine link type and target
232 $this->determineLinkType();
233
234 $ltype = ($this->link_target != "")
235 ? $this->link_type."_".$this->link_target
236 : $this->link_type;
237
238 $def_type = ilObject::_lookupType($this->default_obj, true);
239
240 // determine content object id
241 switch($this->link_type)
242 {
243 case "PageObject":
244 case "StructureObject":
245 if (empty($_SESSION["il_link_cont_obj"]) &&
246 ($def_type != "mep" && $def_type != "glo"))
247 {
248 $_SESSION["il_link_cont_obj"] = $this->default_obj;
249 }
250 break;
251
252 case "GlossaryItem":
253 if (empty($_SESSION["il_link_glossary"]) && $def_type == "glo")
254 {
255 $_SESSION["il_link_glossary"] = $this->default_obj;
256 }
257 break;
258
259 case "Media":
260 if (empty($_SESSION["il_link_mep"]) && $def_type == "mep")
261 {
262 $_SESSION["il_link_mep"] = $this->default_obj;
263 }
264 break;
265
266 case "WikiPage":
267 if (empty($_SESSION["il_link_wiki"]) && $def_type == "wiki")
268 {
269 $_SESSION["il_link_wiki"] = $this->default_obj;
270 }
271 break;
272 }
273
274 /*
275 $target_str = ($link_target == "")
276 ? ""
277 : " target=\"".$link_target."\" ";*/
278
279
280
281 $target_str = ($this->link_target == "")
282 ? ""
283 : " target=\"".$this->link_target."\"";
284//echo "-".$this->link_type."-";
285 if(($this->link_type == "GlossaryItem") &&
286 (empty($_SESSION["il_link_glossary"]) ||
287 !in_array(ilObject::_lookupType($_SESSION["il_link_glossary"], true),
288 array("glo"))))
289 {
290 $this->changeTargetObject("glo");
291 }
292 if(($this->link_type == "WikiPage") &&
293 (empty($_SESSION["il_link_wiki"]) ||
294 !in_array(ilObject::_lookupType($_SESSION["il_link_wiki"], true),
295 array("wiki"))))
296 {
297 $this->changeTargetObject("wiki");
298 }
299 if(($this->link_type == "PageObject" || $this->link_type == "StructureObject") &&
300 (empty($_SESSION["il_link_cont_obj"]) ||
301 !in_array(ilObject::_lookupType($_SESSION["il_link_cont_obj"], true),
302 array("lm"))))
303 {
304 $this->changeTargetObject("cont_obj");
305 }
306 if ($ilCtrl->isAsynch())
307 {
308 $tpl = new ilTemplate("tpl.link_help_asynch.html", true, true, "Services/Link");
309 }
310 else
311 {
312 $tpl = new ilTemplate("tpl.link_help.html", true, true, "Services/Link");
313 $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
314 }
315
316 switch($this->link_type)
317 {
318 case "GlossaryItem":
319 $this->ctrl->setParameter($this, "target_type", "glo");
320 break;
321
322 case "PageObject":
323 case "StructureObject":
324 $this->ctrl->setParameter($this, "target_type", "cont_obj");
325 break;
326
327 case "Media":
328 $this->ctrl->setParameter($this, "target_type", "mep");
329 break;
330
331 case "WikiPage":
332 $this->ctrl->setParameter($this, "target_type", "wiki");
333 break;
334
335 default:
336 break;
337 }
338//echo "<br><br>:".$this->ctrl->getFormAction($this).":";
339//echo "<br>link_type:".$this->link_type;
340//echo "<br>cont_obj:".$_SESSION["il_link_cont_obj"];
341//echo "<br>link_mep".$_SESSION["il_link_mep"];
342 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "changeLinkType", "", true));
343 $tpl->setVariable("FORMACTION2", $this->ctrl->getFormAction($this));
344 $tpl->setVariable("TXT_HELP_HEADER", $this->lng->txt("cont_link_select"));
345 $tpl->setVariable("TXT_TYPE", $this->lng->txt("cont_link_type"));
346
347
348//echo "<br><br>".$ltype;
349
350 $select_ltype = ilUtil::formSelect ($ltype,
351 "ltype", $this->ltypes, false, true, "0", "", array("id" => "ilIntLinkTypeSelector"));
352 $tpl->setVariable("SELECT_TYPE", $select_ltype);
353 $tpl->setVariable("CMD_CHANGETYPE", "changeLinkType");
354 $tpl->setVariable("BTN_CHANGETYPE", $this->lng->txt("cont_change_type"));
355
356/* if ($this->isEnabledJavaScript())
357 {
358 $tpl->setVariable("BTN_CLOSE_JS", $this->lng->txt("close"));
359 }
360 else
361 {*/
362 $tpl->setVariable("CMD_CLOSE", "closeLinkHelp");
363 $tpl->setVariable("BTN_CLOSE", $this->lng->txt("close"));
364// }
365
366 $chapterRowBlock = "chapter_row";
367 $anchor_row_block = "anchor_link";
368 if ($this->isEnabledJavaScript())
369 {
370 $chapterRowBlock .= "_js";
371 $anchor_row_block .= "_js";
372 }
373
374 $obj_id = ilObject::_lookupObjId($_SESSION["il_link_cont_obj"]);
375 $type = ilObject::_lookupType($obj_id);
376
377 // switch link type
378 switch($this->link_type)
379 {
380 // page link
381 case "PageObject":
382 require_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
383 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
384
385 $cont_obj = new ilObjLearningModule($_SESSION["il_link_cont_obj"], true);
386
387 // get all chapters
388 $ctree = $cont_obj->getLMTree();
389 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
390 $tpl->setCurrentBlock("chapter_list");
391 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("obj_lm"));
392 $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
393 $tpl->setVariable("THEAD", $this->lng->txt("pages"));
394
395
396 $tpl->setCurrentBlock("change_cont_obj");
397 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
398 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
399 $tpl->parseCurrentBlock();
400
401 foreach($nodes as $node)
402 {
403 if($node["type"] == "st")
404 {
405 $tpl->setCurrentBlock("chapter_row");
406 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
407 $tpl->setVariable("ROWCLASS", "tblrow1");
408 //$tpl->setVariable("LINK_CHAPTER",
409 // "[iln chap=\"".$node["obj_id"]."\"".$target_str."] [/iln]");
410 $tpl->parseCurrentBlock();
411 $tpl->setCurrentBlock("row");
412 $tpl->parseCurrentBlock();
413 }
414
415 if($node["type"] == "pg")
416 {
417 include_once("./Services/COPage/classes/class.ilPCParagraph.php");
418 $this->renderLink($tpl, $node["title"], $node["obj_id"],
419 "PageObject", "pg", "page",
420 ilPCParagraph::_readAnchors($type, $node["obj_id"], ""));
421 }
422 }
423
424 // get all free pages
425 $pages = ilLMPageObject::getPageList($cont_obj->getId());
426 $free_pages = array();
427 foreach ($pages as $page)
428 {
429 if (!$ctree->isInTree($page["obj_id"]))
430 {
431 $free_pages[] = $page;
432 }
433 }
434 if(count($free_pages) > 0)
435 {
436 $tpl->setCurrentBlock(str_replace("_js","",$chapterRowBlock));
437 $tpl->setVariable("TXT_CHAPTER", $this->lng->txt("cont_free_pages"));
438 $tpl->setVariable("ROWCLASS", "tblrow1");
439 $tpl->parseCurrentBlock();
440
441 foreach ($free_pages as $node)
442 {
443 include_once("./Services/COPage/classes/class.ilPCParagraph.php");
444 $this->renderLink($tpl, $node["title"], $node["obj_id"],
445 "PageObject", "pg", "page",
446 ilPCParagraph::_readAnchors($type, $node["obj_id"], ""));
447 }
448 }
449
450 $tpl->setCurrentBlock("chapter_list");
451 $tpl->parseCurrentBlock();
452
453 break;
454
455 // chapter link
456 case "StructureObject":
457
458 // check whether current object matchs to type
459 if (!in_array(ilObject::_lookupType($_SESSION["il_link_cont_obj"], true),
460 array("lm")))
461 {
462 $this->changeTargetObject("lm");
463 }
464
465 if ($type == "lm")
466 {
467 require_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
468 $cont_obj = new ilObjLearningModule($_SESSION["il_link_cont_obj"], true);
469 }
470
471 // get all chapters
472 $ctree =& $cont_obj->getLMTree();
473 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
474 $tpl->setCurrentBlock("chapter_list");
475 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("obj_lm"));
476 $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
477 $tpl->setVariable("THEAD", $this->lng->txt("link_chapters"));
478 $tpl->setCurrentBlock("change_cont_obj");
479 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
480 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
481 $tpl->parseCurrentBlock();
482
483 foreach($nodes as $node)
484 {
485 if($node["type"] == "st")
486 {
487 $this->renderLink($tpl, $node["title"], $node["obj_id"],
488 "StructureObject", "st", "chap");
489 }
490 }
491 $tpl->setCurrentBlock("chapter_list");
492 $tpl->parseCurrentBlock();
493 break;
494
495 // glossary item link
496 case "GlossaryItem":
497 require_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
498 $glossary = new ilObjGlossary($_SESSION["il_link_glossary"], true);
499
500 // get all glossary items
501 $terms = $glossary->getTermList();
502 $tpl->setCurrentBlock("chapter_list");
503 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("glossary"));
504 $tpl->setVariable("TXT_CONT_TITLE", $glossary->getTitle());
505 $tpl->setVariable("THEAD", $this->lng->txt("link_terms"));
506 $tpl->setCurrentBlock("change_cont_obj");
507 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
508 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
509 $tpl->parseCurrentBlock();
510
511 foreach($terms as $term)
512 {
513 $this->renderLink($tpl, $term["term"], $term["id"],
514 "GlossaryItem", "git", "term");
515 }
516
517 $tpl->setCurrentBlock("chapter_list");
518 $tpl->parseCurrentBlock();
519 break;
520
521 // media object
522 case "Media":
523 include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
524 //$tpl->setVariable("TARGET2", " target=\"content\" ");
525 // content object id = 0 --> get clipboard objects
526 if ($_SESSION["il_link_mep"] == 0)
527 {
528 $tpl->setCurrentBlock("change_cont_obj");
529 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
530 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
531 $tpl->parseCurrentBlock();
532 $mobjs = $ilUser->getClipboardObjects("mob");
533 // sort by name
534 $objs = array();
535 foreach ($mobjs as $obj)
536 {
537 $objs[$obj["title"].":".$obj["id"]] = $obj;
538 }
539 ksort($objs);
540 $tpl->setCurrentBlock("chapter_list");
541 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_media_source"));
542 $tpl->setVariable("TXT_CONT_TITLE", $this->lng->txt("cont_personal_clipboard"));
543 $tpl->setVariable("THEAD", $this->lng->txt("link_mobs"));
544 $tpl->setVariable("COLSPAN", "2");
545
546 foreach($objs as $obj)
547 {
548 $this->renderLink($tpl, $obj["title"], $obj["id"],
549 "MediaObject", "mob", "media");
550 }
551 $tpl->setCurrentBlock("chapter_list");
552 $tpl->parseCurrentBlock();
553 }
554 else
555 {
556 require_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
557 $med_pool = new ilObjMediaPool($_SESSION["il_link_mep"], true);
558 // get current folders
559 $fobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "fold");
560 $f2objs = array();
561 foreach ($fobjs as $obj)
562 {
563 $f2objs[$obj["title"].":".$obj["child"]] = $obj;
564 }
565 ksort($f2objs);
566 // get current media objects
567 $mobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "mob");
568 $m2objs = array();
569 foreach ($mobjs as $obj)
570 {
571 $m2objs[$obj["title"].":".$obj["child"]] = $obj;
572 }
573 ksort($m2objs);
574
575 // merge everything together
576 $objs = array_merge($f2objs, $m2objs);
577
578 $tpl->setCurrentBlock("chapter_list");
579 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("mep"));
580 $tpl->setVariable("TXT_CONT_TITLE", $med_pool->getTitle());
581 $tpl->setVariable("THEAD", $this->lng->txt("link_mobs"));
582 $tpl->setCurrentBlock("change_cont_obj");
583 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
584 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
585 $tpl->setVariable("COLSPAN", "2");
586 $tpl->parseCurrentBlock();
587 if ($parent_id = $med_pool->getParentId($_SESSION["il_link_mep_obj"]))
588 {
589 $css_row = "tblrow1";
590 $tpl->setCurrentBlock("icon");
591 $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.svg"));
592 $tpl->parseCurrentBlock();
593 $tpl->setCurrentBlock("link_row");
594 $tpl->setVariable("ROWCLASS", $css_row);
595 $tpl->setVariable("TXT_CHAPTER", "..");
596 $this->ctrl->setParameter($this, "mep_fold", $parent_id);
597 if ($ilCtrl->isAsynch())
598 {
599 $tpl->setVariable("LINK", "#");
600 $tpl->setVariable("LR_ONCLICK",
601 " onclick=\"return il.IntLink.setMepPoolFolder('".$parent_id."');\" ");
602
603 }
604 else
605 {
606 $tpl->setVariable("LINK",
607 $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
608 }
609 $tpl->parseCurrentBlock();
610 $tpl->setCurrentBlock("row");
611 $tpl->parseCurrentBlock();
612 }
613 foreach($objs as $obj)
614 {
615 if($obj["type"] == "fold")
616 {
617 $css_row = ($css_row == "tblrow2")
618 ? "tblrow1"
619 : "tblrow2";
620 $tpl->setCurrentBlock("icon");
621 $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.svg"));
622 $tpl->parseCurrentBlock();
623 $tpl->setCurrentBlock("link_row");
624 $tpl->setVariable("ROWCLASS", $css_row);
625 $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
626 $this->ctrl->setParameter($this, "mep_fold", $obj["child"]);
627 if ($ilCtrl->isAsynch())
628 {
629 $tpl->setVariable("LINK", "#");
630 $tpl->setVariable("LR_ONCLICK",
631 " onclick=\"return il.IntLink.setMepPoolFolder('".$obj["child"]."');\" ");
632
633 }
634 else
635 {
636 $tpl->setVariable("LINK",
637 $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
638 }
639 $tpl->parseCurrentBlock();
640 }
641 else
642 {
643 $fid = ilMediaPoolItem::lookupForeignId($obj["child"]);
644 if (ilObject::_lookupType($fid) == "mob")
645 {
646 $this->renderLink($tpl, $obj["title"], $fid,
647 "MediaObject", "mob", "media");
648 }
649 }
650 $tpl->setCurrentBlock("row");
651 $tpl->parseCurrentBlock();
652 }
653 $tpl->setCurrentBlock("chapter_list");
654 $tpl->parseCurrentBlock();
655 }
656 break;
657
658 // glossary item link
659 case "WikiPage":
660 $wiki_id = ilObject::_lookupObjId($_SESSION["il_link_wiki"]);
661 require_once("./Modules/Wiki/classes/class.ilWikiPage.php");
662 $wpages = ilWikiPage::getAllWikiPages($wiki_id);
663
664 // get all glossary items
665 $tpl->setCurrentBlock("chapter_list");
666 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("obj_wiki"));
667 $tpl->setVariable("TXT_CONT_TITLE", ilObject::_lookupTitle($wiki_id));
668 $tpl->setVariable("THEAD", $this->lng->txt("link_wpages"));
669 $tpl->setCurrentBlock("change_cont_obj");
670 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
671 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
672 $tpl->parseCurrentBlock();
673
674 foreach($wpages as $wpage)
675 {
676 $this->renderLink($tpl, $wpage["title"], $wpage["id"],
677 "WikiPage", "wpage", "wpage");
678 }
679
680 $tpl->setCurrentBlock("chapter_list");
681 $tpl->parseCurrentBlock();
682 break;
683
684 // repository item
685 case "RepositoryItem":
686 $tpl->setVariable("LINK_HELP_CONTENT", $this->selectRepositoryItem());
687 break;
688
689 // file download link
690 case "File":
691 if (!is_object($this->uploaded_file))
692 {
693 $tpl->setVariable("LINK_HELP_CONTENT", $this->getFileLinkHTML());
694 }
695 else
696 {
697 echo $this->getFileLinkHTML();
698 exit;
699 }
700 break;
701
702 }
703
704 if ($ilCtrl->isAsynch())
705 {
706 echo $tpl->get();
707 exit;
708 }
709
710 exit;
711 }
712
718 {
719 global $ilCtrl, $lng;
720
721 if (!is_object($this->uploaded_file))
722 {
723 $tpl = new ilTemplate("tpl.link_file.html", true, true, "Services/Link");
724 $tpl->setCurrentBlock("form");
725 $tpl->setVariable("FORM_ACTION",
726 $ilCtrl->getFormAction($this, "saveFileLink", "", true));
727 $tpl->setVariable("TXT_SELECT_FILE", $lng->txt("cont_select_file"));
728 $tpl->setVariable("TXT_SAVE_LINK", $lng->txt("cont_create_link"));
729 $tpl->setVariable("CMD_SAVE_LINK", "saveFileLink");
730 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
731 $fi = new ilFileInputGUI("", "link_file");
732 $fi->setSize(15);
733 $tpl->setVariable("INPUT", $fi->getToolbarHTML());
734 $tpl->parseCurrentBlock();
735 return $tpl->get();
736 }
737 else
738 {
739 $tpl = new ilTemplate("tpl.link_file.html", true, true, "Services/Link");
740 $tpl->setCurrentBlock("link_js");
741// $tpl->setVariable("LINK_FILE",
742// $this->prepareJavascriptOutput("[iln dfile=\"".$this->uploaded_file->getId()."\"] [/iln]")
743// );
744 $tpl->setVariable("TAG_B",
745 '[iln dfile=\x22'.$this->uploaded_file->getId().'\x22]');
746 $tpl->setVariable("TAG_E",
747 "[/iln]");
748 $tpl->setVariable("TXT_FILE",
749 $this->uploaded_file->getTitle());
750// $tpl->parseCurrentBlock();
751 return $tpl->get();
752 }
753 }
754
758 function saveFileLink()
759 {
760 if ($_FILES["link_file"]["name"] != "")
761 {
762 include_once("./Modules/File/classes/class.ilObjFile.php");
763 $fileObj = new ilObjFile();
764 $fileObj->setType("file");
765 $fileObj->setTitle($_FILES["link_file"]["name"]);
766 $fileObj->setDescription("");
767 $fileObj->setFileName($_FILES["link_file"]["name"]);
768 $fileObj->setFileType($_FILES["link_file"]["type"]);
769 $fileObj->setFileSize($_FILES["link_file"]["size"]);
770 $fileObj->setMode("filelist");
771 $fileObj->create();
772 // upload file to filesystem
773 $fileObj->createDirectory();
774 $fileObj->raiseUploadError(false);
775 $fileObj->getUploadFile($_FILES["link_file"]["tmp_name"],
776 $_FILES["link_file"]["name"]);
777 $this->uploaded_file = $fileObj;
778
779 }
780 $this->showLinkHelp();
781 }
782
786 function outputThumbnail(&$tpl, $a_id, $a_mode = "")
787 {
788 // output thumbnail
789 $mob = new ilObjMediaObject($a_id);
790 $med =& $mob->getMediaItem("Standard");
791 $target = $med->getThumbnailTarget("small");
792 $suff = "";
793 if ($this->getSetLinkTargetScript() != "")
794 {
795 $tpl->setCurrentBlock("thumbnail_link");
796 $suff = "_link";
797 }
798 else if ($this->isEnabledJavaScript())
799 {
800 $tpl->setCurrentBlock("thumbnail_js");
801 $suff = "_js";
802 }
803 else
804 {
805 $tpl->setCurrentBlock("thumbnail");
806 }
807
808 if ($target != "")
809 {
810 $tpl->setCurrentBlock("thumb".$suff);
811 $tpl->setVariable("SRC_THUMB", $target);
812 $tpl->parseCurrentBlock();
813 }
814 else
815 {
816 $tpl->setVariable("NO_THUMB", "&nbsp;");
817 }
818
819 if ($this->getSetLinkTargetScript() != "")
820 {
821 $tpl->setCurrentBlock("thumbnail_link");
822 }
823 else if ($this->isEnabledJavaScript())
824
825 {
826 $tpl->setCurrentBlock("thumbnail_js");
827 }
828 else
829 {
830 $tpl->setCurrentBlock("thumbnail");
831 }
832 $tpl->parseCurrentBlock();
833 }
834
835
839 function changeLinkType()
840 {
841 $_SESSION["il_link_type"] = $_POST["ltype"];
842 $this->determineLinkType();
843 $this->showLinkHelp();
844 }
845
850 {
851 $_SESSION["il_link_mep_obj"] = $_GET["mep_fold"];
852 $this->showLinkHelp();
853 }
854
859 {
860 global $ilCtrl;
861
862 $ilCtrl->setParameter($this, "target_type", $a_type);
863 include_once("./Services/Link/classes/class.ilLinkTargetObjectExplorerGUI.php");
864 $exp = new ilLinkTargetObjectExplorerGUI($this, "getTargetExplorer");
865
866 if ($a_type == "")
867 {
868 $a_type = $_GET["target_type"];
869 }
870
871 $white = array("root", "cat", "crs", "fold", "grp");
872
873 switch ($a_type)
874 {
875 case "glo":
876 $white[] = "glo";
877 $exp->setClickableType("glo");
878 break;
879
880 case "wiki":
881 $white[] = "wiki";
882 $exp->setClickableType("wiki");
883 break;
884
885 case "mep":
886 $white[] = "mep";
887 $exp->setClickableType("mep");
888 break;
889
890 default:
891 $white[] = "lm";
892 $exp->setClickableType("lm");
893 break;
894 }
895
896 $exp->setTypeWhiteList($white);
897
898
899 if (!$exp->handleCommand())
900 {
901 return $exp->getHTML();
902 }
903 }
904
909 {
910 global $ilCtrl;
911
912 $_SESSION["il_link_mep_obj"] = "";
913 if($_GET["do"] == "set")
914 {
915 switch ($_GET["target_type"])
916 {
917 case "glo":
918 $_SESSION["il_link_glossary"] = $_GET["sel_id"];
919 break;
920
921 case "mep":
922 $_SESSION["il_link_mep"] = $_GET["sel_id"];
923 break;
924
925 case "wiki":
926 $_SESSION["il_link_wiki"] = $_GET["sel_id"];
927 break;
928
929 default:
930 $_SESSION["il_link_cont_obj"] = $_GET["sel_id"];
931 break;
932 }
933 $this->showLinkHelp();
934 return;
935 }
936
937 if(empty($a_type))
938 {
939 if (!empty($_GET["target_type"]))
940 {
941 $a_type = $_GET["target_type"];
942 }
943 else
944 {
945 $this->determineLinkType();
946 $a_type = "lm";
947 if ($this->link_type == "GlossaryItem")
948 {
949 $a_type = "glo";
950 }
951 if ($this->link_type == "Media")
952 {
953 $a_type = "mep";
954 }
955 if ($this->link_type == "WikiPage")
956 {
957 $a_type = "wiki";
958 }
959 }
960 }
961
962 $tpl = new ilTemplate("tpl.link_help_explorer.html", true, true, "Services/Link");
963
965
966 if ($a_type == "glo")
967 {
968 $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_glossary"));
969 }
970 else if ($a_type == "wiki")
971 {
972 $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_wiki"));
973 }
974 else if ($a_type == "mep")
975 {
976 $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_media_source"));
977 }
978 else
979 {
980 $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_cont_obj"));
981 }
982 $tpl->setVariable("EXPLORER",$output);
983 $tpl->setVariable("ACTION", $this->ctrl->getFormAction($this, "resetLinkList", "", true));
984 $tpl->setVariable("BTN_RESET", "resetLinkList");
985 $tpl->setVariable("TXT_RESET", $this->lng->txt("back"));
986
987 if ($a_type == "mep")
988 {
989 $tpl->setCurrentBlock("sel_clipboard");
990 $this->ctrl->setParameter($this, "do", "set");
991 if ($ilCtrl->isAsynch())
992 {
993 $tpl->setVariable("LINK_CLIPBOARD", "#");
994 $tpl->setVariable("CLIPBOARD_ONCLICK",
995 " onclick=\"return il.IntLink.selectLinkTargetObject('mep', 0);\" ");
996
997 }
998 else
999 {
1000 $tpl->setVariable("LINK_CLIPBOARD", $this->ctrl->getLinkTarget($this, "changeTargetObject"));
1001 }
1002 $tpl->setVariable("TXT_PERS_CLIPBOARD", $this->lng->txt("clipboard"));
1003 $tpl->parseCurrentBlock();
1004 }
1005
1006 $tpl->parseCurrentBlock();
1007
1008 echo $tpl->get();
1009 exit;
1010 }
1011
1012
1017 {
1018 global $ilCtrl;
1019
1020 $_SESSION["il_link_mep_obj"] = "";
1021
1022 $ilCtrl->setParameter($this, "target_type", $a_type);
1023 include_once("./Services/Link/classes/class.ilIntLinkRepItemExplorerGUI.php");
1024 $exp = new ilIntLinkRepItemExplorerGUI($this, "selectRepositoryItem");
1025 $exp->setSetLinkTargetScript($this->getSetLinkTargetScript());
1026
1027 if (!$exp->handleCommand())
1028 {
1029 return $exp->getHTML();
1030 }
1031 }
1032
1037 {
1038 $output = $this->selectRepositoryItem();
1039 echo $output;
1040 exit;
1041 }
1042
1049 static function _doJSEditing()
1050 {
1051 return true;
1053 }
1054
1055
1060 {
1061 global $ilias;
1062
1063 include_once("./Services/COPage/classes/class.ilPageEditorGUI.php");
1064
1065 if (self::_doJSEditing())
1066 {
1067 return true;
1068 }
1069
1070 return false;
1071 }
1072
1073
1077 static function getInitHTML($a_url)
1078 {
1079 global $tpl, $lng;
1080
1081 $lng->loadLanguageModule("link");
1082
1083 $tpl->addJavaScript("./Services/UIComponent/Explorer/js/ilExplorer.js");
1084 include_once("./Services/UIComponent/Explorer2/classes/class.ilExplorerBaseGUI.php");
1086
1087 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1089
1090 $tpl->addJavascript("./Services/Link/js/ilIntLink.js");
1091
1092 // #18721
1093 $tpl->addJavaScript("Services/Form/js/Form.js");
1094
1095 include_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
1096 $modal = ilModalGUI::getInstance();
1097 $modal->setHeading($lng->txt("link_link"));
1098 $modal->setId("ilIntLinkModal");
1099 $modal->setBody("<div id='ilIntLinkModalContent'></div>");
1100
1101 $ltpl = new ilTemplate("tpl.int_link_panel.html", true, true, "Services/Link");
1102 $ltpl->setVariable("MODAL", $modal->getHTML());
1103
1104 $ltpl->setVariable("IL_INT_LINK_URL", $a_url);
1105
1106 return $ltpl->get();
1107 }
1108
1112 function renderLink($tpl, $a_title, $a_obj_id, $a_type, $a_type_short, $a_bb_type,
1113 $a_anchors = array())
1114 {
1115 $chapterRowBlock = "chapter_row";
1116 $anchor_row_block = "anchor_link";
1117 if ($this->isEnabledJavaScript())
1118 {
1119
1120 $chapterRowBlock .= "_js";
1121 $anchor_row_block .= "_js";
1122 }
1123
1124 $target_str = ($this->link_target == "")
1125 ? ""
1126 : " target=\"".$this->link_target."\"";
1127
1128 if (count($a_anchors) > 0)
1129 {
1130 foreach ($a_anchors as $anchor)
1131 {
1132 $tpl->setCurrentBlock($anchor_row_block);
1133 $tpl->setVariable("ALINK_BEGIN",
1134 $this->prepareJavascriptOutput("[iln ".$a_bb_type."=\"".$a_obj_id."\"".$target_str." anchor=\"$anchor\"]"));
1135 $tpl->setVariable("ALINK_END", "[/iln]");
1136 $tpl->setVariable("TXT_LINK", "#".$anchor);
1137 $tpl->parseCurrentBlock();
1138 }
1139 }
1140
1141 $this->css_row = ($this->css_row == "tblrow1")
1142 ? "tblrow2"
1143 : "tblrow1";
1144
1145 if ($this->getSetLinkTargetScript() != "")
1146 {
1147 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1148 require_once("./Services/MediaObjects/classes/class.ilImageMapEditorGUI.php");
1150 if ($a_type == "MediaObject")
1151 {
1152 $this->outputThumbnail($tpl, $a_obj_id);
1153 }
1154 $tpl->setCurrentBlock("link_row");
1155 $tpl->setVariable("ROWCLASS", $this->css_row);
1156 $tpl->setVariable("TXT_CHAPTER", $a_title);
1157 //$tpl->setVariable("LINK_TARGET", "content");
1158 $tpl->setVariable("LINK",
1160 "linktype=".$a_type.
1161 "&linktarget=il__".$a_type_short."_".$a_obj_id.
1162 "&linktargetframe=".$this->link_target));
1163 $tpl->parseCurrentBlock();
1164 }
1165 else
1166 {
1167 $tpl->setCurrentBlock($chapterRowBlock);
1168 if ($a_type == "MediaObject")
1169 {
1170 $this->outputThumbnail($tpl, $a_obj_id);
1171 $tpl->setCurrentBlock($chapterRowBlock);
1172 }
1173 $tpl->setVariable("ROWCLASS", $this->css_row);
1174 $tpl->setVariable("TXT_CHAPTER", $a_title);
1175 if ($this->isEnabledJavaScript())
1176 {
1177// $tpl->setVariable("TXT_CHAPTER_JS", htmlspecialchars(str_replace("'", "\'", $a_title)));
1178 }
1179 if ($a_type == "MediaObject" && empty($target_str))
1180 {
1181 $tpl->setVariable("LINK_BEGIN",
1182 $this->prepareJavascriptOutput("[iln ".$a_bb_type."=\"".$a_obj_id."\"/]"));
1183 $tpl->setVariable("LINK_END", "");
1184 }
1185 else
1186 {
1187 $tpl->setVariable("LINK_BEGIN",
1188 $this->prepareJavascriptOutput("[iln ".$a_bb_type."=\"".$a_obj_id."\"".$target_str."]"));
1189 $tpl->setVariable("LINK_END", "[/iln]");
1190 }
1191 $tpl->parseCurrentBlock();
1192 }
1193
1194 $tpl->setCurrentBlock("row");
1195 $tpl->parseCurrentBlock();
1196
1197 }
1198
1199}
1200?>
global $tpl
Definition: ilias.php:8
global $l
Definition: afr.php:30
PHPExcel root directory.
Definition: PHPExcel.php:30
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
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.
refreshRepositorySelector()
Refresh Repository Selector.
setMedPoolFolder()
select media pool folder
static getInitHTML($a_url)
Get initialisation HTML to use interna link editing.
saveFileLink()
Save file link.
isEnabledJavaScript()
determine, wether js is used
__construct($a_default_type, $a_default_obj)
renderLink($tpl, $a_title, $a_obj_id, $a_type, $a_type_short, $a_bb_type, $a_anchors=array())
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)
setMode($a_mode="text")
Set mode.
changeTargetObject($a_type="")
Cange target object.
determineLinkType()
Determine current link type.
getTargetExplorer($a_type="")
Cange target object.
initLinkTypes()
Initialize link types.
changeLinkType()
change link type
showLinkHelp()
Show link help list.
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 _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 _doJSEditing()
checks if current user has activated js editing and if browser is js capable
special template class to simplify handling of ITX/PEAR
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)
http redirect to other 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()
Init YUI Connection module.
$white
Definition: example_030.php:84
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
$cmd
Definition: sahs_server.php:35
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:93