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