ILIAS  release_4-4 Revision
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_wiki"] != "" && !$tree->isInTree($_SESSION["il_link_wiki"])) ||
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  }
54 
58  function initLinkTypes()
59  {
60  global $lng;
61 
62  $this->ltypes = array(
63  "StructureObject" => $lng->txt("cont_lk_chapter"),
64  "StructureObject_New" => $lng->txt("cont_lk_chapter_new"),
65  "PageObject" => $lng->txt("cont_lk_page"),
66  "PageObject_FAQ" => $lng->txt("cont_lk_page_faq"),
67  "PageObject_New" => $lng->txt("cont_lk_page_new"),
68  "GlossaryItem" => $lng->txt("cont_lk_term"),
69  "GlossaryItem_New" => $lng->txt("cont_lk_term_new"),
70  "Media" => $lng->txt("cont_lk_media_inline"),
71  "Media_Media" => $lng->txt("cont_lk_media_media"),
72  "Media_FAQ" => $lng->txt("cont_lk_media_faq"),
73  "Media_New" => $lng->txt("cont_lk_media_new"),
74  "WikiPage" => $lng->txt("cont_wiki_page"),
75  "File" => $lng->txt("cont_lk_file"),
76  "RepositoryItem" => $lng->txt("cont_repository_item")
77  );
78  }
79 
83  function determineLinkType()
84  {
85  // determine link type and target
86  $ltype = ($_SESSION["il_link_type"] == "")
87  ? $this->default_type
88  : $_SESSION["il_link_type"];
89  $ltype_arr = explode("_", $ltype);
90 
91  if (!isset($this->ltypes[$ltype_arr[0]]) &&
92  !isset($this->ltypes[$ltype]))
93  {
94  $this->link_type = $this->default_type;
95  }
96  else
97  {
98  $this->link_type = ($ltype_arr[0] == "")
99  ? $this->default_type
100  : $ltype_arr[0];
101  $this->link_target = $ltype_arr[1];
102  }
103  }
104 
108  function setMode($a_mode = "text")
109  {
110  $this->mode = $a_mode;
111  }
112 
113  function setSetLinkTargetScript($a_script)
114  {
115  $this->set_link_script = $a_script;
116  }
117 
118  function setReturn($a_return)
119  {
120  $this->return = $a_return;
121  }
122 
124  {
125  return $this->set_link_script;
126  }
127 
128  function filterLinkType($a_link_type)
129  {
130  $this->filter_link_types[] = $a_link_type;
131  }
132 
138  function setFilterWhiteList($a_white_list)
139  {
140  $this->filter_white_list = $a_white_list;
141  }
142 
143 
144  function &executeCommand()
145  {
146  $next_class = $this->ctrl->getNextClass($this);
147 
148  $cmd = $this->ctrl->getCmd("showLinkHelp");
149  switch($next_class)
150  {
151  default:
152  $ret =& $this->$cmd();
153  break;
154  }
155 
156  return $ret;
157  }
158 
159  function resetSessionVars()
160  {
161  $_SESSION["il_link_mep"] = "";
162  $_SESSION["il_link_mep_obj"] = "";
163  $_SESSION["il_link_type"] = "";
164  }
165 
166  function resetLinkList()
167  {
168  $this->resetSessionVars();
169  $this->determineLinkType();
170  $this->showLinkHelp();
171  }
172 
173  function closeLinkHelp()
174  {
175  if ($this->return == "")
176  {
177  $this->ctrl->returnToParent($this);
178  }
179  else
180  {
181  ilUtil::redirect($this->return);
182  }
183  }
184 
188  function prepareJavascriptOutput($str)
189  {
190  global $ilUser;
191 
192  include_once("./Services/COPage/classes/class.ilPageEditorGUI.php");
193  if (self::_doJSEditing())
194  {
195  $str = htmlspecialchars($str, ENT_QUOTES);
196  }
197  return($str);
198  }
199 
200 
204  function showLinkHelp()
205  {
206  global $ilUser, $ilCtrl;
207 
208  // filter link types
209  if (!$this->filter_white_list)
210  {
211  foreach($this->filter_link_types as $link_type)
212  {
213  unset($this->ltypes[$link_type]);
214  }
215  }
216  else
217  {
218  $ltypes = array();
219  foreach($this->ltypes as $k => $l)
220  {
221  if (in_array($k, $this->filter_link_types))
222  {
223  $ltypes[$k] = $l;
224  }
225  }
226  $this->ltypes = $ltypes;
227  }
228 
229 
230  // determine link type and target
231  $this->determineLinkType();
232 
233  $ltype = ($this->link_target != "")
234  ? $this->link_type."_".$this->link_target
235  : $this->link_type;
236 
237  $def_type = ilObject::_lookupType($this->default_obj, true);
238 
239  // determine content object id
240  switch($this->link_type)
241  {
242  case "PageObject":
243  case "StructureObject":
244  if (empty($_SESSION["il_link_cont_obj"]) &&
245  ($def_type != "mep" && $def_type != "glo"))
246  {
247  $_SESSION["il_link_cont_obj"] = $this->default_obj;
248  }
249  break;
250 
251  case "GlossaryItem":
252  if (empty($_SESSION["il_link_glossary"]) && $def_type == "glo")
253  {
254  $_SESSION["il_link_glossary"] = $this->default_obj;
255  }
256  break;
257 
258  case "Media":
259  if (empty($_SESSION["il_link_mep"]) && $def_type == "mep")
260  {
261  $_SESSION["il_link_mep"] = $this->default_obj;
262  }
263  break;
264 
265  case "WikiPage":
266  if (empty($_SESSION["il_link_wiki"]) && $def_type == "wiki")
267  {
268  $_SESSION["il_link_wiki"] = $this->default_obj;
269  }
270  break;
271  }
272 
273  /*
274  $target_str = ($link_target == "")
275  ? ""
276  : " target=\"".$link_target."\" ";*/
277 
278 
279 
280  $target_str = ($this->link_target == "")
281  ? ""
282  : " target=\"".$this->link_target."\"";
283 //echo "-".$this->link_type."-";
284  if(($this->link_type == "GlossaryItem") &&
285  (empty($_SESSION["il_link_glossary"]) ||
286  !in_array(ilObject::_lookupType($_SESSION["il_link_glossary"], true),
287  array("glo"))))
288  {
289  $this->changeTargetObject("glo");
290  }
291  if(($this->link_type == "WikiPage") &&
292  (empty($_SESSION["il_link_wiki"]) ||
293  !in_array(ilObject::_lookupType($_SESSION["il_link_wiki"], true),
294  array("wiki"))))
295  {
296  $this->changeTargetObject("wiki");
297  }
298  if(($this->link_type == "PageObject" || $this->link_type == "StructureObject") &&
299  (empty($_SESSION["il_link_cont_obj"]) ||
300  !in_array(ilObject::_lookupType($_SESSION["il_link_cont_obj"], true),
301  array("lm", "dbk"))))
302  {
303  $this->changeTargetObject("cont_obj");
304  }
305  if ($ilCtrl->isAsynch())
306  {
307  $tpl = new ilTemplate("tpl.link_help_asynch.html", true, true, "Modules/LearningModule");
308  }
309  else
310  {
311  $tpl =& new ilTemplate("tpl.link_help.html", true, true, "Modules/LearningModule");
312  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
313  }
314 
315  switch($this->link_type)
316  {
317  case "GlossaryItem":
318  $this->ctrl->setParameter($this, "target_type", "glo");
319  break;
320 
321  case "PageObject":
322  case "StructureObject":
323  $this->ctrl->setParameter($this, "target_type", "cont_obj");
324  break;
325 
326  case "Media":
327  $this->ctrl->setParameter($this, "target_type", "mep");
328  break;
329 
330  case "WikiPage":
331  $this->ctrl->setParameter($this, "target_type", "wiki");
332  break;
333 
334  default:
335  break;
336  }
337 //echo "<br><br>:".$this->ctrl->getFormAction($this).":";
338 //echo "<br>link_type:".$this->link_type;
339 //echo "<br>cont_obj:".$_SESSION["il_link_cont_obj"];
340 //echo "<br>link_mep".$_SESSION["il_link_mep"];
341 //echo $this->ctrl->getFormAction($this, "", "", true);
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("cont_content_obj"));
392  $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
393  $tpl->setCurrentBlock("change_cont_obj");
394  $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
395  $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
396  $tpl->parseCurrentBlock();
397 
398  foreach($nodes as $node)
399  {
400  if($node["type"] == "st")
401  {
402  $tpl->setCurrentBlock("chapter_row");
403  $tpl->setVariable("TXT_CHAPTER", $node["title"]);
404  $tpl->setVariable("ROWCLASS", "tblrow1");
405  //$tpl->setVariable("LINK_CHAPTER",
406  // "[iln chap=\"".$node["obj_id"]."\"".$target_str."] [/iln]");
407  $tpl->parseCurrentBlock();
408  $tpl->setCurrentBlock("row");
409  $tpl->parseCurrentBlock();
410  }
411 
412  if($node["type"] == "pg")
413  {
414  include_once("./Services/COPage/classes/class.ilPCParagraph.php");
415  $this->renderLink($tpl, $node["title"], $node["obj_id"],
416  "PageObject", "pg", "page",
417  ilPCParagraph::_readAnchors($type, $node["obj_id"], ""));
418  }
419  }
420 
421  // get all free pages
422  $pages = ilLMPageObject::getPageList($cont_obj->getId());
423  $free_pages = array();
424  foreach ($pages as $page)
425  {
426  if (!$ctree->isInTree($page["obj_id"]))
427  {
428  $free_pages[] = $page;
429  }
430  }
431  if(count($free_pages) > 0)
432  {
433  $tpl->setCurrentBlock(str_replace("_js","",$chapterRowBlock));
434  $tpl->setVariable("TXT_CHAPTER", $this->lng->txt("cont_free_pages"));
435  $tpl->setVariable("ROWCLASS", "tblrow1");
436  $tpl->parseCurrentBlock();
437 
438  foreach ($free_pages as $node)
439  {
440  include_once("./Services/COPage/classes/class.ilPCParagraph.php");
441  $this->renderLink($tpl, $node["title"], $node["obj_id"],
442  "PageObject", "pg", "page",
443  ilPCParagraph::_readAnchors($type, $node["obj_id"], ""));
444  }
445  }
446 
447  $tpl->setCurrentBlock("chapter_list");
448  $tpl->parseCurrentBlock();
449 
450  break;
451 
452  // chapter link
453  case "StructureObject":
454 
455  // check whether current object matchs to type
456  if (!in_array(ilObject::_lookupType($_SESSION["il_link_cont_obj"], true),
457  array("lm", "dbk")))
458  {
459  $this->changeTargetObject("lm");
460  }
461 
462  if ($type == "lm")
463  {
464  require_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
465  $cont_obj = new ilObjLearningModule($_SESSION["il_link_cont_obj"], true);
466  }
467  else if ($type == "dbk")
468  {
469  require_once("./Modules/LearningModule/classes/class.ilObjDlBook.php");
470  $cont_obj = new ilObjDlBook($_SESSION["il_link_cont_obj"], true);
471  }
472 
473  // get all chapters
474  $ctree =& $cont_obj->getLMTree();
475  $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
476  $tpl->setCurrentBlock("chapter_list");
477  $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_content_obj"));
478  $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
479  $tpl->setCurrentBlock("change_cont_obj");
480  $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
481  $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
482  $tpl->parseCurrentBlock();
483 
484  foreach($nodes as $node)
485  {
486  if($node["type"] == "st")
487  {
488  $this->renderLink($tpl, $node["title"], $node["obj_id"],
489  "StructureObject", "st", "chap");
490  }
491  }
492  $tpl->setCurrentBlock("chapter_list");
493  $tpl->parseCurrentBlock();
494  break;
495 
496  // glossary item link
497  case "GlossaryItem":
498  require_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
499  $glossary =& new ilObjGlossary($_SESSION["il_link_glossary"], true);
500 
501  // get all glossary items
502  $terms = $glossary->getTermList();
503  $tpl->setCurrentBlock("chapter_list");
504  $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("glossary"));
505  $tpl->setVariable("TXT_CONT_TITLE", $glossary->getTitle());
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 = $this->ilias->account->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("COLSPAN", "2");
544 
545  foreach($objs as $obj)
546  {
547  $this->renderLink($tpl, $obj["title"], $obj["id"],
548  "MediaObject", "mob", "media");
549  }
550  $tpl->setCurrentBlock("chapter_list");
551  $tpl->parseCurrentBlock();
552  }
553  else
554  {
555  require_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
556  $med_pool =& new ilObjMediaPool($_SESSION["il_link_mep"], true);
557  // get current folders
558  $fobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "fold");
559  $f2objs = array();
560  foreach ($fobjs as $obj)
561  {
562  $f2objs[$obj["title"].":".$obj["child"]] = $obj;
563  }
564  ksort($f2objs);
565  // get current media objects
566  $mobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "mob");
567  $m2objs = array();
568  foreach ($mobjs as $obj)
569  {
570  $m2objs[$obj["title"].":".$obj["child"]] = $obj;
571  }
572  ksort($m2objs);
573 
574  // merge everything together
575  $objs = array_merge($f2objs, $m2objs);
576 
577  $tpl->setCurrentBlock("chapter_list");
578  $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("mep"));
579  $tpl->setVariable("TXT_CONT_TITLE", $med_pool->getTitle());
580  $tpl->setCurrentBlock("change_cont_obj");
581  $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
582  $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
583  $tpl->setVariable("COLSPAN", "2");
584  $tpl->parseCurrentBlock();
585  if ($parent_id = $med_pool->getParentId($_SESSION["il_link_mep_obj"]))
586  {
587  $css_row = "tblrow1";
588  $tpl->setCurrentBlock("icon");
589  $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.png"));
590  $tpl->parseCurrentBlock();
591  $tpl->setCurrentBlock("link_row");
592  $tpl->setVariable("ROWCLASS", $css_row);
593  $tpl->setVariable("TXT_CHAPTER", "..");
594  $this->ctrl->setParameter($this, "mep_fold", $parent_id);
595  if ($ilCtrl->isAsynch())
596  {
597  $tpl->setVariable("LINK", "#");
598  $tpl->setVariable("LR_ONCLICK",
599  " onclick=\"return il.IntLink.setMepPoolFolder('".$parent_id."');\" ");
600 
601  }
602  else
603  {
604  $tpl->setVariable("LINK",
605  $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
606  }
607  $tpl->parseCurrentBlock();
608  $tpl->setCurrentBlock("row");
609  $tpl->parseCurrentBlock();
610  }
611  foreach($objs as $obj)
612  {
613  if($obj["type"] == "fold")
614  {
615  $css_row = ($css_row == "tblrow2")
616  ? "tblrow1"
617  : "tblrow2";
618  $tpl->setCurrentBlock("icon");
619  $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.png"));
620  $tpl->parseCurrentBlock();
621  $tpl->setCurrentBlock("link_row");
622  $tpl->setVariable("ROWCLASS", $css_row);
623  $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
624  $this->ctrl->setParameter($this, "mep_fold", $obj["child"]);
625  if ($ilCtrl->isAsynch())
626  {
627  $tpl->setVariable("LINK", "#");
628  $tpl->setVariable("LR_ONCLICK",
629  " onclick=\"return il.IntLink.setMepPoolFolder('".$obj["child"]."');\" ");
630 
631  }
632  else
633  {
634  $tpl->setVariable("LINK",
635  $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
636  }
637  $tpl->parseCurrentBlock();
638  }
639  else
640  {
641  $fid = ilMediaPoolItem::lookupForeignId($obj["child"]);
642  if (ilObject::_lookupType($fid) == "mob")
643  {
644  $this->renderLink($tpl, $obj["title"], $fid,
645  "MediaObject", "mob", "media");
646  }
647  }
648  $tpl->setCurrentBlock("row");
649  $tpl->parseCurrentBlock();
650  }
651  $tpl->setCurrentBlock("chapter_list");
652  $tpl->parseCurrentBlock();
653  }
654  break;
655 
656  // glossary item link
657  case "WikiPage":
658  $wiki_id = ilObject::_lookupObjId($_SESSION["il_link_wiki"]);
659  require_once("./Modules/Wiki/classes/class.ilWikiPage.php");
660  $wpages = ilWikiPage::getAllPages($wiki_id);
661 
662  // get all glossary items
663  $tpl->setCurrentBlock("chapter_list");
664  $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("obj_wiki"));
665  $tpl->setVariable("TXT_CONT_TITLE", ilObject::_lookupTitle($wiki_id));
666  $tpl->setCurrentBlock("change_cont_obj");
667  $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
668  $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
669  $tpl->parseCurrentBlock();
670 
671  foreach($wpages as $wpage)
672  {
673  $this->renderLink($tpl, $wpage["title"], $wpage["id"],
674  "WikiPage", "wpage", "wpage");
675  }
676 
677  $tpl->setCurrentBlock("chapter_list");
678  $tpl->parseCurrentBlock();
679  break;
680 
681  // repository item
682  case "RepositoryItem":
683  $tpl->setVariable("LINK_HELP_CONTENT", $this->selectRepositoryItem());
684  break;
685 
686  // file download link
687  case "File":
688  if (!is_object($this->uploaded_file))
689  {
690  $tpl->setVariable("LINK_HELP_CONTENT", $this->getFileLinkHTML());
691  }
692  else
693  {
694  echo $this->getFileLinkHTML();
695  exit;
696  }
697  break;
698 
699  }
700 
701  if ($ilCtrl->isAsynch())
702  {
703  echo $tpl->get();
704  exit;
705  }
706 
707  exit;
708  }
709 
714  function getFileLinkHTML()
715  {
716  global $ilCtrl, $lng;
717 
718  if (!is_object($this->uploaded_file))
719  {
720  $tpl = new ilTemplate("tpl.link_file.html", true, true, "Modules/LearningModule");
721  $tpl->setCurrentBlock("form");
722  $tpl->setVariable("FORM_ACTION",
723  $ilCtrl->getFormAction($this, "saveFileLink", "", true));
724  $tpl->setVariable("TXT_SELECT_FILE", $lng->txt("cont_select_file"));
725  $tpl->setVariable("TXT_SAVE_LINK", $lng->txt("cont_create_link"));
726  $tpl->setVariable("CMD_SAVE_LINK", "saveFileLink");
727  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
728  $fi = new ilFileInputGUI("", "link_file");
729  $fi->setSize(15);
730  $tpl->setVariable("INPUT", $fi->getToolbarHTML());
731  $tpl->parseCurrentBlock();
732  return $tpl->get();
733  }
734  else
735  {
736  $tpl = new ilTemplate("tpl.link_file.html", true, true, "Modules/LearningModule");
737  $tpl->setCurrentBlock("link_js");
738 // $tpl->setVariable("LINK_FILE",
739 // $this->prepareJavascriptOutput("[iln dfile=\"".$this->uploaded_file->getId()."\"] [/iln]")
740 // );
741  $tpl->setVariable("TAG_B",
742  '[iln dfile=\x22'.$this->uploaded_file->getId().'\x22]');
743  $tpl->setVariable("TAG_E",
744  "[/iln]");
745  $tpl->setVariable("TXT_FILE",
746  $this->uploaded_file->getTitle());
747 // $tpl->parseCurrentBlock();
748  return $tpl->get();
749  }
750  }
751 
755  function saveFileLink()
756  {
757  $mtpl =& new ilTemplate("tpl.link_help.html", true, true, "Modules/LearningModule");
758  $mtpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
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 
849  function setMedPoolFolder()
850  {
851  $_SESSION["il_link_mep_obj"] = $_GET["mep_fold"];
852  $this->showLinkHelp();
853  }
854 
858  function getTargetExplorer($a_type)
859  {
860  global $ilCtrl;
861 
862  include_once("./Services/Link/classes/class.ilLinkTargetObjectExplorer.php");
864  $ilCtrl->getTargetScript(), "do=set"));
865  if ($_GET["expand"] == "")
866  {
867  $expanded = $this->tree->readRootId();
868  }
869  else
870  {
871  $expanded = $_GET["expand"];
872  }
873  $exp->setExpand($expanded);
874  $exp ->setAsynchExpanding(true);
875 
876  $exp->setTargetGet("sel_id");
877  $ilCtrl->setParameter($this, "target_type", $a_type);
878  $exp->setParamsGet($this->ctrl->getParameterArray($this, "refreshTargetExplorer"));
879 
880  $exp->addFilter("root");
881  $exp->addFilter("cat");
882  $exp->addFilter("grp");
883  $exp->addFilter("fold");
884  $exp->addFilter("crs");
885 
886  switch ($a_type)
887  {
888  case "glo":
889  $exp->addFilter("glo");
890  break;
891 
892  case "wiki":
893  $exp->addFilter("wiki");
894  break;
895 
896  case "mep":
897  $exp->addFilter("mep");
898  break;
899 
900  default:
901  $exp->addFilter("lm");
902  $exp->addFilter("dbk");
903  break;
904  }
905  $exp->setFiltered(true);
906  $exp->setFilterMode(IL_FM_POSITIVE);
907 
908  $exp->setClickable("cat", false);
909  $exp->setClickable("grp", false);
910  $exp->setClickable("fold", false);
911  $exp->setClickable("crs", false);
912 
913  $exp->setFrameTarget("");
914  $exp->setOutput(0);
915 
916  return $exp->getOutput();
917  }
918 
922  function changeTargetObject($a_type = "")
923  {
924  global $ilCtrl;
925 
926  $_SESSION["il_link_mep_obj"] = "";
927  if($_GET["do"] == "set")
928  {
929  switch ($_GET["target_type"])
930  {
931  case "glo":
932  $_SESSION["il_link_glossary"] = $_GET["sel_id"];
933  break;
934 
935  case "mep":
936  $_SESSION["il_link_mep"] = $_GET["sel_id"];
937  break;
938 
939  case "wiki":
940  $_SESSION["il_link_wiki"] = $_GET["sel_id"];
941  break;
942 
943  default:
944  $_SESSION["il_link_cont_obj"] = $_GET["sel_id"];
945  break;
946  }
947  $this->showLinkHelp();
948  return;
949  }
950 
951  if(empty($a_type))
952  {
953  if (!empty($_GET["target_type"]))
954  {
955  $a_type = $_GET["target_type"];
956  }
957  else
958  {
959  $this->determineLinkType();
960  if ($this->link_type == "GlossaryItem")
961  {
962  $a_type = "glo";
963  }
964  if ($this->link_type == "Media")
965  {
966  $a_type = "mep";
967  }
968  if ($this->link_type == "WikiPage")
969  {
970  $a_type = "wiki";
971  }
972  }
973  }
974 
975  $tpl =& new ilTemplate("tpl.link_help_explorer.html", true, true, "Modules/LearningModule");
976 
977  $output = $this->getTargetExplorer($a_type);
978 
979  if ($a_type == "glo")
980  {
981  $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_glossary"));
982  }
983  if ($a_type == "wiki")
984  {
985  $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_wiki"));
986  }
987  else if ($a_type == "mep")
988  {
989  $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_media_source"));
990  }
991  else
992  {
993  $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_cont_obj"));
994  }
995  $tpl->setVariable("EXPLORER",$output);
996  $tpl->setVariable("ACTION", $this->ctrl->getFormAction($this, "resetLinkList", "", true));
997  $tpl->setVariable("BTN_RESET", "resetLinkList");
998  $tpl->setVariable("TXT_RESET", $this->lng->txt("back"));
999 
1000  if ($a_type == "mep")
1001  {
1002  $tpl->setCurrentBlock("sel_clipboard");
1003  $this->ctrl->setParameter($this, "do", "set");
1004  if ($ilCtrl->isAsynch())
1005  {
1006  $tpl->setVariable("LINK_CLIPBOARD", "#");
1007  $tpl->setVariable("CLIPBOARD_ONCLICK",
1008  " onclick=\"return il.IntLink.selectLinkTargetObject('mep', 0);\" ");
1009 
1010  }
1011  else
1012  {
1013  $tpl->setVariable("LINK_CLIPBOARD", $this->ctrl->getLinkTarget($this, "changeTargetObject"));
1014  }
1015  $tpl->setVariable("TXT_PERS_CLIPBOARD", $this->lng->txt("clipboard"));
1016  $tpl->parseCurrentBlock();
1017  }
1018 
1019  $tpl->parseCurrentBlock();
1020 
1021  echo $tpl->get();
1022  exit;
1023  }
1024 
1029  {
1030  $output = $this->getTargetExplorer($_GET["target_type"]);
1031  echo $output;
1032  exit;
1033  }
1034 
1035 
1040  {
1041  global $ilCtrl;
1042 
1043  $_SESSION["il_link_mep_obj"] = "";
1044 
1045  if(empty($a_type))
1046  {
1047  $a_type = $_GET["target_type"];
1048  }
1049 
1050  include_once "./Modules/LearningModule/classes/class.ilIntLinkRepItemExplorer.php";
1052  $this->ctrl->getTargetScript(), "do=set"));
1053  if ($_GET["expand"] == "")
1054  {
1055  if((int)$_GET["ref_id"])
1056  {
1057  // #12504
1058  $expanded = (int)$_GET["ref_id"];
1059  }
1060  else
1061  {
1062  $expanded = $this->tree->readRootId();
1063  }
1064  }
1065  else
1066  {
1067  $expanded = $_GET["expand"];
1068  }
1069  $exp->setMode($this->mode);
1070  $exp->setSetLinkTargetScript($this->getSetLinkTargetScript());
1071  $exp->setExpand($expanded);
1072 
1073  $exp->setTargetGet("sel_id");
1074  $this->ctrl->setParameter($this, "target_type", $a_type);
1075  $exp->setParamsGet($this->ctrl->getParameterArray($this, "refreshRepositorySelector"));
1076 
1077  // filter
1078  $exp->setFiltered(true);
1079  $exp->setFilterMode(IL_FM_POSITIVE);
1080 
1081  global $objDefinition;
1082 
1083  $rtypes = $objDefinition->getAllRepositoryTypes();
1084 
1085  $exp->addFilter("root");
1086  foreach ($rtypes as $t)
1087  {
1088  $exp->addFilter($t);
1089  }
1090 
1091  $sel_types = $rtypes;
1092  $exp->setSelectableTypes($sel_types);
1093 
1094 
1095  $exp->setFrameTarget("");
1096  $exp->setOutput(0);
1097  $output = $exp->getOutput();
1098 
1099  return $output;
1100  }
1101 
1106  {
1107  $output = $this->selectRepositoryItem();
1108  echo $output;
1109  exit;
1110  }
1111 
1118  static function _doJSEditing()
1119  {
1120  return true;
1122  }
1123 
1124 
1129  {
1130  global $ilias;
1131 
1132  include_once("./Services/COPage/classes/class.ilPageEditorGUI.php");
1133 
1134  if (self::_doJSEditing())
1135  {
1136  return true;
1137  }
1138 
1139  return false;
1140  }
1141 
1142 
1146  function getInitHTML($a_url, $a_move_to_body = false)
1147  {
1148  global $tpl;
1149 
1150  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1151  ilYuiUtil::initPanel(false);
1154  $tpl->addJavaScript("./Services/UIComponent/Explorer/js/ilExplorer.js");
1155  $tpl->addJavascript("./Services/Link/js/ilIntLink.js");
1156 
1157  $ltpl = new ilTemplate("tpl.int_link_panel.html", true, true, "Services/Link");
1158  if ($a_move_to_body)
1159  {
1160  $ltpl->touchBlock("move_to_body");
1161  }
1162  $ltpl->setVariable("IL_INT_LINK_URL", $a_url);
1163 
1164  return $ltpl->get();
1165  }
1166 
1170  function renderLink($tpl, $a_title, $a_obj_id, $a_type, $a_type_short, $a_bb_type,
1171  $a_anchors = array())
1172  {
1173  $chapterRowBlock = "chapter_row";
1174  $anchor_row_block = "anchor_link";
1175  if ($this->isEnabledJavaScript())
1176  {
1177 
1178  $chapterRowBlock .= "_js";
1179  $anchor_row_block .= "_js";
1180  }
1181 
1182  $target_str = ($this->link_target == "")
1183  ? ""
1184  : " target=\"".$this->link_target."\"";
1185 
1186  if (count($a_anchors) > 0)
1187  {
1188  foreach ($a_anchors as $anchor)
1189  {
1190  $tpl->setCurrentBlock($anchor_row_block);
1191  $tpl->setVariable("ALINK_BEGIN",
1192  $this->prepareJavascriptOutput("[iln ".$a_bb_type."=\"".$a_obj_id."\"".$target_str." anchor=\"$anchor\"]"));
1193  $tpl->setVariable("ALINK_END", "[/iln]");
1194  $tpl->setVariable("TXT_LINK", "#".$anchor);
1195  $tpl->parseCurrentBlock();
1196  }
1197  }
1198 
1199  $this->css_row = ($this->css_row == "tblrow1")
1200  ? "tblrow2"
1201  : "tblrow1";
1202 
1203  if ($this->getSetLinkTargetScript() != "")
1204  {
1205  require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1206  require_once("./Services/MediaObjects/classes/class.ilImageMapEditorGUI.php");
1208  if ($a_type == "MediaObject")
1209  {
1210  $this->outputThumbnail($tpl, $a_obj_id);
1211  }
1212  $tpl->setCurrentBlock("link_row");
1213  $tpl->setVariable("ROWCLASS", $this->css_row);
1214  $tpl->setVariable("TXT_CHAPTER", $a_title);
1215  //$tpl->setVariable("LINK_TARGET", "content");
1216  $tpl->setVariable("LINK",
1218  "linktype=".$a_type.
1219  "&linktarget=il__".$a_type_short."_".$a_obj_id.
1220  "&linktargetframe=".$this->link_target));
1221  $tpl->parseCurrentBlock();
1222  }
1223  else
1224  {
1225  $tpl->setCurrentBlock($chapterRowBlock);
1226  if ($a_type == "MediaObject")
1227  {
1228  $this->outputThumbnail($tpl, $a_obj_id);
1229  $tpl->setCurrentBlock($chapterRowBlock);
1230  }
1231  $tpl->setVariable("ROWCLASS", $this->css_row);
1232  $tpl->setVariable("TXT_CHAPTER", $a_title);
1233  if ($this->isEnabledJavaScript())
1234  {
1235 // $tpl->setVariable("TXT_CHAPTER_JS", htmlspecialchars(str_replace("'", "\'", $a_title)));
1236  }
1237  if ($a_type == "MediaObject" && empty($target_str))
1238  {
1239  $tpl->setVariable("LINK_BEGIN",
1240  $this->prepareJavascriptOutput("[iln ".$a_bb_type."=\"".$a_obj_id."\"/]"));
1241  $tpl->setVariable("LINK_END", "");
1242  }
1243  else
1244  {
1245  $tpl->setVariable("LINK_BEGIN",
1246  $this->prepareJavascriptOutput("[iln ".$a_bb_type."=\"".$a_obj_id."\"".$target_str."]"));
1247  $tpl->setVariable("LINK_END", "[/iln]");
1248  }
1249  $tpl->parseCurrentBlock();
1250  }
1251 
1252  $tpl->setCurrentBlock("row");
1253  $tpl->parseCurrentBlock();
1254 
1255  }
1256 
1257 }
1258 ?>
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
exit
Definition: login.php:54
getTargetExplorer($a_type)
Cange target object.
Class ilObjLearningModule.
$_POST['username']
Definition: cron.php:12
Internal Link: Repository Item Selector Explorer.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
This class represents a file property in a property form.
Class ilObjGlossary.
Class ilObjDlBook.
static initConnection()
Init YUI Connection module.
outputThumbnail(&$tpl, $a_id, $a_mode="")
output thumbnail
$cmd
Definition: sahs_server.php:35
const IL_FM_POSITIVE
setFilterWhiteList($a_white_list)
Set filter list as white list (per detault it is a black list)
static _lookupTitle($a_id)
lookup object title
getFileLinkHTML()
Get HTML for file link.
Class ilInternalLinkGUI.
showLinkHelp()
Show link help list.
setMode($a_mode="text")
Set mode.
determineLinkType()
Determine current link type.
global $ilCtrl
Definition: ilias.php:18
Internal Link: Repository Item Selector Explorer.
static lookupForeignId($a_id)
Lookup Foreign Id.
renderLink($tpl, $a_title, $a_obj_id, $a_type, $a_type_short, $a_bb_type, $a_anchors=array())
Render internal link item.
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
refreshTargetExplorer()
Refresh target explorer.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
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.
changeTargetObject($a_type="")
Cange target object.
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
Class ilObjFile.
getPageList($lm_id)
static
redirection script todo: (a better solution should control the processing via a xml file) ...
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
Class ilObjMediaObject.
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 initPanel($a_resize=false)
Init yui panel.
_doJSEditing()
checks if current user has activated js editing and if browser is js capable
prepareJavascriptOutput($str)
Prepare output for JS enabled editing.
initLinkTypes()
Initialize link types.
if(!file_exists(getcwd().'/ilias.ini.php')) if(isset( $_GET["client_id"]))
registration confirmation script for ilias
Definition: confirmReg.php:20
setMedPoolFolder()
select media pool folder
global $ilUser
Definition: imgupload.php:15
Media pool object.
ilInternalLinkGUI($a_default_type, $a_default_obj)
static initDragDrop()
Init YUI Drag and Drop.
isEnabledJavaScript()
determine, wether js is used
saveFileLink()
Save file link.
selectRepositoryItem()
select repository item explorer
_recoverParameters()
Recover parameters from session variables (static)
static redirect($a_script)
http redirect to other script
static getAllPages($a_wiki_id)
Get all pages of wiki.
getInitHTML($a_url, $a_move_to_body=false)
Get initialisation HTML to use interna link editing.
changeLinkType()
change link type
refreshRepositorySelector()
Refresh Repository Selector.