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