ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilInternalLinkGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
25 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
26 
38 {
43  var $lng;
44  var $mode; // "text" | "link"
46  var $ctrl;
47  var $tree;
48 
49  function ilInternalLinkGUI($a_default_type, $a_default_obj)
50  {
51  global $lng, $ilias, $ilCtrl, $tree;
52 
53  if (($_SESSION["il_link_cont_obj"] != "" && !$tree->isInTree($_SESSION["il_link_cont_obj"])) ||
54  ($_SESSION["il_link_glossary"] != "" && !$tree->isInTree($_SESSION["il_link_glossary"])) ||
55  ($_SESSION["il_link_mep"] != "" && !$tree->isInTree($_SESSION["il_link_mep"])))
56  {
57  $this->resetSessionVars();
58  }
59 
60  $this->lng =& $lng;
61  $this->tree =& $tree;
62  $this->ilias =& $ilias;
63  $this->ctrl =& $ilCtrl;
64  $this->ctrl->saveParameter($this, array("linkmode", "target_type"));
65  $this->default_type = $a_default_type;
66  $this->default_obj = $a_default_obj;
67  $this->filter_link_types = array();
68  $this->mode = "text";
69 
70  // determine link type and target
71  $this->determineLinkType();
72 
73  $def_type = ilObject::_lookupType($this->default_obj, true);
74 
75  // determine content object id
76  switch($this->link_type)
77  {
78  case "PageObject":
79  case "StructureObject":
80  if (empty($_SESSION["il_link_cont_obj"]) &&
81  ($def_type != "mep" && $def_type != "glo"))
82  {
83  $_SESSION["il_link_cont_obj"] = $this->default_obj;
84  }
85  break;
86 
87  case "GlossaryItem":
88  if (empty($_SESSION["il_link_glossary"]) && $def_type == "glo")
89  {
90  $_SESSION["il_link_glossary"] = $this->default_obj;
91  }
92  break;
93 
94  case "Media":
95  if (empty($_SESSION["il_link_mep"]) && $def_type == "mep")
96  {
97  $_SESSION["il_link_mep"] = $this->default_obj;
98  }
99  break;
100  }
101 
102  /*
103  $target_str = ($link_target == "")
104  ? ""
105  : " target=\"".$link_target."\" ";*/
106  }
107 
108  function determineLinkType()
109  {
110  // determine link type and target
111  $ltype = ($_SESSION["il_link_type"] == "")
112  ? $this->default_type
113  : $_SESSION["il_link_type"];
114  $ltype_arr = explode("_", $ltype);
115  $this->link_type = ($ltype_arr[0] == "")
116  ? $this->default_type
117  : $ltype_arr[0];
118  $this->link_target = $ltype_arr[1];
119  }
120 
121  function setMode($a_mode = "text")
122  {
123  $this->mode = $a_mode;
124  }
125 
126  function setSetLinkTargetScript($a_script)
127  {
128  $this->set_link_script = $a_script;
129  }
130 
131  function setReturn($a_return)
132  {
133  $this->return = $a_return;
134  }
135 
137  {
138  return $this->set_link_script;
139  }
140 
141  function filterLinkType($a_link_type)
142  {
143  $this->filter_link_types[] = $a_link_type;
144  }
145 
146  function &executeCommand()
147  {
148  $next_class = $this->ctrl->getNextClass($this);
149 
150  $cmd = $this->ctrl->getCmd("showLinkHelp");
151  switch($next_class)
152  {
153  default:
154  $ret =& $this->$cmd();
155  break;
156  }
157 
158  return $ret;
159  }
160 
161  function resetSessionVars()
162  {
163  $_SESSION["il_link_mep"] = "";
164  $_SESSION["il_link_mep_obj"] = "";
165  $_SESSION["il_link_type"] = "";
166  }
167 
168  function resetLinkList()
169  {
170  $this->resetSessionVars();
171  $this->determineLinkType();
172  $this->showLinkHelp();
173  }
174 
175  function closeLinkHelp()
176  {
177  if ($this->return == "")
178  {
179  $this->ctrl->returnToParent($this);
180  }
181  else
182  {
183  ilUtil::redirect($this->return);
184  }
185  }
186 
187 
188  function prepareJavascriptOutput($str)
189  {
190  global $ilUser;
191 
192  include_once("./Services/COPage/classes/class.ilPageEditorGUI.php");
194  {
195  $str = htmlspecialchars($str);
196  }
197  return($str);
198  }
199 
200 
204  function showLinkHelp()
205  {
206  global $ilUser;
207 
208  $target_str = ($this->link_target == "")
209  ? ""
210  : " target=\"".$this->link_target."\"";
211 
212  if(($this->link_type == "GlossaryItem") &&
213  empty($_SESSION["il_link_glossary"]))
214  {
215  $this->changeTargetObject("glo");
216  }
217  if(($this->link_type == "PageObject" || $this->link_type == "StructureObject") &&
218  empty($_SESSION["il_link_cont_obj"]))
219  {
220  $this->changeTargetObject("cont_obj");
221  }
222 
223  $tpl =& new ilTemplate("tpl.link_help.html", true, true, "Modules/LearningModule");
224  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
225 
226  switch($this->link_type)
227  {
228  case "GlossaryItem":
229  $this->ctrl->setParameter($this, "target_type", "glo");
230  break;
231 
232  case "PageObject":
233  case "StructureObject":
234  $this->ctrl->setParameter($this, "target_type", "cont_obj");
235  break;
236 
237  case "Media":
238  $this->ctrl->setParameter($this, "target_type", "mep");
239  break;
240 
241  default:
242  break;
243  }
244 //echo "<br><br>:".$this->ctrl->getFormAction($this).":";
245 //echo "<br>link_type:".$this->link_type;
246 //echo "<br>cont_obj:".$_SESSION["il_link_cont_obj"];
247 //echo "<br>link_mep".$_SESSION["il_link_mep"];
248  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
249  $tpl->setVariable("FORMACTION2", $this->ctrl->getFormAction($this));
250  $tpl->setVariable("TXT_HELP_HEADER", $this->lng->txt("cont_link_select"));
251  $tpl->setVariable("TXT_TYPE", $this->lng->txt("cont_link_type"));
252  $ltypes = array("StructureObject" => $this->lng->txt("cont_lk_chapter"),
253  "StructureObject_New" => $this->lng->txt("cont_lk_chapter_new"),
254  "PageObject" => $this->lng->txt("cont_lk_page"),
255  "PageObject_FAQ" => $this->lng->txt("cont_lk_page_faq"),
256  "PageObject_New" => $this->lng->txt("cont_lk_page_new"),
257  "GlossaryItem" => $this->lng->txt("cont_lk_term"),
258  "GlossaryItem_New" => $this->lng->txt("cont_lk_term_new"),
259  "Media" => $this->lng->txt("cont_lk_media_inline"),
260  "Media_Media" => $this->lng->txt("cont_lk_media_media"),
261  "Media_FAQ" => $this->lng->txt("cont_lk_media_faq"),
262  "Media_New" => $this->lng->txt("cont_lk_media_new"),
263  "RepositoryItem" => $this->lng->txt("cont_repository_item")
264  );
265 
266  // filter link types
267  foreach($this->filter_link_types as $link_type)
268  {
269  unset($ltypes[$link_type]);
270  }
271 
272  $ltype = ($this->link_target != "")
273  ? $this->link_type."_".$this->link_target
274  : $this->link_type;
275 
276 //echo "<br><br>".$ltype;
277 
278  $select_ltype = ilUtil::formSelect ($ltype,
279  "ltype", $ltypes, false, true);
280  $tpl->setVariable("SELECT_TYPE", $select_ltype);
281  $tpl->setVariable("CMD_CHANGETYPE", "changeLinkType");
282  $tpl->setVariable("BTN_CHANGETYPE", $this->lng->txt("cont_change_type"));
283 
284 /* if ($this->isEnabledJavaScript())
285  {
286  $tpl->setVariable("BTN_CLOSE_JS", $this->lng->txt("close"));
287  }
288  else
289  {*/
290  $tpl->setVariable("CMD_CLOSE", "closeLinkHelp");
291  $tpl->setVariable("BTN_CLOSE", $this->lng->txt("close"));
292 // }
293 
294  $chapterRowBlock = "chapter_row";
295  if ($this->isEnabledJavaScript())
296  {
297  $chapterRowBlock .= "_js";
298  }
299 
300  $obj_id = ilObject::_lookupObjId($_SESSION["il_link_cont_obj"]);
301  $type = ilObject::_lookupType($obj_id);
302 
303  switch($this->link_type)
304  {
305  // page link
306  case "PageObject":
307  if ($type == "lm")
308  {
309  require_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
310  $cont_obj =& new ilObjLearningModule($_SESSION["il_link_cont_obj"], true);
311  }
312  else if ($type == "dbk")
313  {
314  require_once("./Modules/LearningModule/classes/class.ilObjDlBook.php");
315  $cont_obj =& new ilObjDlBook($_SESSION["il_link_cont_obj"], true);
316  }
317 
318  // get all chapters
319  $ctree =& $cont_obj->getLMTree();
320  $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
321  $tpl->setCurrentBlock("chapter_list");
322  $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_content_obj"));
323  $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
324  $tpl->setCurrentBlock("change_cont_obj");
325  $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
326  $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
327  $tpl->parseCurrentBlock();
328 
329  foreach($nodes as $node)
330  {
331  if($node["type"] == "st")
332  {
333  $tpl->setCurrentBlock("chapter_row");
334  $tpl->setVariable("TXT_CHAPTER", $node["title"]);
335  $tpl->setVariable("ROWCLASS", "tblrow1");
336  //$tpl->setVariable("LINK_CHAPTER",
337  // "[iln chap=\"".$node["obj_id"]."\"".$target_str."] [/iln]");
338  $tpl->parseCurrentBlock();
339  }
340  if($node["type"] == "pg")
341  {
342  switch ($this->mode)
343  {
344  case "link":
345  require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
346  require_once("./Services/MediaObjects/classes/class.ilImageMapEditorGUI.php");
348  $tpl->setCurrentBlock("link_row");
349  $tpl->setVariable("ROWCLASS", "tblrow2");
350  $tpl->setVariable("TXT_CHAPTER", $node["title"]);
351  $tpl->setVariable("LINK_TARGET", "content");
352  $tpl->setVariable("LINK",
354  "linktype=PageObject".
355  "&linktarget=il__pg_".$node["obj_id"].
356  "&linktargetframe=".$this->link_target));
357  $tpl->parseCurrentBlock();
358  break;
359 
360  default:
361  $tpl->setCurrentBlock($chapterRowBlock);
362  $tpl->setVariable("TXT_CHAPTER", $node["title"]);
363  $tpl->setVariable("ROWCLASS", "tblrow2");
364  $tpl->setVariable("LINK_CHAPTER",
365  $this->prepareJavascriptOutput("[iln page=\"".$node["obj_id"]."\"".$target_str."] [/iln]"));
366  $tpl->parseCurrentBlock();
367  break;
368  }
369  }
370  $tpl->setCurrentBlock("row");
371  $tpl->parseCurrentBlock();
372  }
373 
374  // get all free pages
375  $pages = ilLMPageObject::getPageList($cont_obj->getId());
376  $free_pages = array();
377  foreach ($pages as $page)
378  {
379  if (!$ctree->isInTree($page["obj_id"]))
380  {
381  $free_pages[] = $page;
382  }
383  }
384  if(count($free_pages) > 0)
385  {
386  $tpl->setCurrentBlock(str_replace("_js","",$chapterRowBlock));
387  $tpl->setVariable("TXT_CHAPTER", $this->lng->txt("cont_free_pages"));
388  $tpl->setVariable("ROWCLASS", "tblrow1");
389  $tpl->parseCurrentBlock();
390 
391  foreach ($free_pages as $node)
392  {
393  switch ($this->mode)
394  {
395  case "link":
396  require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
397  require_once("./Services/MediaObjects/classes/class.ilImageMapEditorGUI.php");
399  $tpl->setCurrentBlock("link_row");
400  $tpl->setVariable("ROWCLASS", "tblrow2");
401  $tpl->setVariable("TXT_CHAPTER", $node["title"]);
402  $tpl->setVariable("LINK_TARGET", "content");
403  $tpl->setVariable("LINK",
405  "linktype=PageObject".
406  "&linktarget=il__pg_".$node["obj_id"].
407  "&linktargetframe=".$this->link_target));
408  $tpl->parseCurrentBlock();
409  break;
410 
411  default:
412  $tpl->setCurrentBlock($chapterRowBlock);
413  $tpl->setVariable("TXT_CHAPTER", $node["title"]);
414  $tpl->setVariable("ROWCLASS", "tblrow2");
415  $tpl->setVariable("LINK_CHAPTER",
416  $this->prepareJavascriptOutput("[iln page=\"".$node["obj_id"]."\"".$target_str."] [/iln]"));
417  $tpl->parseCurrentBlock();
418  break;
419  }
420  }
421  }
422 
423  $tpl->setCurrentBlock("chapter_list");
424  $tpl->parseCurrentBlock();
425 
426  break;
427 
428  // chapter link
429  case "StructureObject":
430 
431  //echo "-$type-".$_SESSION["il_link_cont_obj"]."-";
432  if ($type == "lm")
433  {
434  require_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
435  $cont_obj =& new ilObjLearningModule($_SESSION["il_link_cont_obj"], true);
436  }
437  else if ($type == "dbk")
438  {
439  require_once("./Modules/LearningModule/classes/class.ilObjDlBook.php");
440  $cont_obj =& new ilObjDlBook($_SESSION["il_link_cont_obj"], true);
441  }
442 
443  // get all chapters
444  $ctree =& $cont_obj->getLMTree();
445  $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
446  $tpl->setCurrentBlock("chapter_list");
447  $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_content_obj"));
448  $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
449  $tpl->setCurrentBlock("change_cont_obj");
450  $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
451  $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
452  $tpl->parseCurrentBlock();
453 
454  foreach($nodes as $node)
455  {
456  if($node["type"] == "st")
457  {
458  $css_row = ($css_row == "tblrow1")
459  ? "tblrow2"
460  : "tblrow1";
461 
462  switch ($this->mode)
463  {
464  case "link":
465  require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
466  require_once("./Services/MediaObjects/classes/class.ilImageMapEditorGUI.php");
468  $tpl->setCurrentBlock("link_row");
469  $tpl->setVariable("ROWCLASS", $css_row);
470  $tpl->setVariable("TXT_CHAPTER", $node["title"]);
471  $tpl->setVariable("LINK_TARGET", "content");
472  $tpl->setVariable("LINK",
474  "linktype=StructureObject".
475  "&linktarget=il__st_".$node["obj_id"].
476  "&linktargetframe=".$this->link_target));
477  $tpl->parseCurrentBlock();
478  break;
479 
480  default:
481  $tpl->setCurrentBlock($chapterRowBlock);
482  $tpl->setVariable("ROWCLASS", $css_row);
483  $tpl->setVariable("TXT_CHAPTER", $node["title"]);
484  $tpl->setVariable("LINK_CHAPTER",
485  $this->prepareJavascriptOutput("[iln chap=\"".$node["obj_id"]."\"".$target_str."] [/iln]"));
486  $tpl->parseCurrentBlock();
487  break;
488  }
489  }
490  $tpl->setCurrentBlock("row");
491  $tpl->parseCurrentBlock();
492  }
493  $tpl->setCurrentBlock("chapter_list");
494  $tpl->parseCurrentBlock();
495  break;
496 
497  // glossary item link
498  case "GlossaryItem":
499  require_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
500  $glossary =& new ilObjGlossary($_SESSION["il_link_glossary"], true);
501 
502  // get all glossary items
503  $terms = $glossary->getTermList();
504  $tpl->setCurrentBlock("chapter_list");
505  $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("glossary"));
506  $tpl->setVariable("TXT_CONT_TITLE", $glossary->getTitle());
507  $tpl->setCurrentBlock("change_cont_obj");
508  $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
509  $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
510  $tpl->parseCurrentBlock();
511 
512  foreach($terms as $term)
513  {
514  $css_row = ($css_row =="tblrow1")
515  ? "tblrow2"
516  : "tblrow1";
517 
518  switch ($this->mode)
519  {
520  case "link":
521  require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
522  require_once("./Services/MediaObjects/classes/class.ilImageMapEditorGUI.php");
524  $tpl->setCurrentBlock("link_row");
525  $tpl->setVariable("ROWCLASS", "tblrow2");
526  $tpl->setVariable("TXT_CHAPTER", $term["term"]);
527  $tpl->setVariable("LINK_TARGET", "content");
528  $tpl->setVariable("LINK",
530  "linktype=GlossaryItem".
531  "&linktarget=il__git_".$term["id"].
532  "&linktargetframe=".$this->link_target));
533  $tpl->parseCurrentBlock();
534  break;
535 
536  default:
537  $tpl->setCurrentBlock($chapterRowBlock);
538  $tpl->setVariable("ROWCLASS", $css_row);
539  $tpl->setVariable("TXT_CHAPTER", $term["term"]);
540  $tpl->setVariable("LINK_CHAPTER",
541  $this->prepareJavascriptOutput("[iln term=\"".$term["id"]."\"".$target_str."]"." "."[/iln]"));
542  $tpl->parseCurrentBlock();
543  $tpl->setCurrentBlock("row");
544  $tpl->parseCurrentBlock();
545  break;
546  }
547  }
548 
549  $tpl->setCurrentBlock("chapter_list");
550  $tpl->parseCurrentBlock();
551  break;
552 
553  // media object
554  case "Media":
555  //$tpl->setVariable("TARGET2", " target=\"content\" ");
556  // content object id = 0 --> get clipboard objects
557  if ($_SESSION["il_link_mep"] == 0)
558  {
559  $tpl->setCurrentBlock("change_cont_obj");
560  $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
561  $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
562  $tpl->parseCurrentBlock();
563  $mobjs = $this->ilias->account->getClipboardObjects("mob");
564  // sort by name
565  $objs = array();
566  foreach ($mobjs as $obj)
567  {
568  $objs[$obj["title"].":".$obj["id"]] = $obj;
569  }
570  ksort($objs);
571  $tpl->setCurrentBlock("chapter_list");
572  $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_media_source"));
573  $tpl->setVariable("TXT_CONT_TITLE", $this->lng->txt("cont_personal_clipboard"));
574  $tpl->setVariable("COLSPAN", "2");
575 
576  foreach($objs as $obj)
577  {
578  switch ($this->mode)
579  {
580  case "link":
581  require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
582  require_once("./Services/MediaObjects/classes/class.ilImageMapEditorGUI.php");
584  $tpl->setCurrentBlock("link_row");
585  $this->outputThumbnail($tpl, $obj["id"], "link");
586  $tpl->setCurrentBlock("link_row");
587 
588  $tpl->setCurrentBlock("link_row");
589  $tpl->setVariable("ROWCLASS", "tblrow2");
590  $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
591  $tpl->setVariable("LINK_TARGET", "content");
592  $tpl->setVariable("LINK",
594  "linktype=MediaObject".
595  "&linktarget=il__mob_".$obj["id"].
596  "&linktargetframe=".$this->link_target));
597  $tpl->parseCurrentBlock();
598  break;
599 
600  default:
601  $tpl->setCurrentBlock($chapterRowBlock);
602  $this->outputThumbnail($tpl, $obj["id"]);
603  $tpl->setCurrentBlock($chapterRowBlock);
604  $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
605  $tpl->setVariable("ROWCLASS", "tblrow1");
606  if (!empty($target_str))
607  {
608  $tpl->setVariable("LINK_CHAPTER",
609  $this->prepareJavascriptOutput("[iln media=\"".$obj["id"]."\"".$target_str."] [/iln]"));
610  }
611  else
612  {
613  $tpl->setVariable("LINK_CHAPTER",
614  $this->prepareJavascriptOutput("[iln media=\"".$obj["id"]."\"/]"));
615  }
616  $tpl->parseCurrentBlock();
617  $tpl->setCurrentBlock("row");
618  $tpl->parseCurrentBlock();
619  break;
620  }
621  }
622  $tpl->setCurrentBlock("chapter_list");
623  $tpl->parseCurrentBlock();
624  }
625  else
626  {
627  require_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
628  $med_pool =& new ilObjMediaPool($_SESSION["il_link_mep"], true);
629 
630  // get current folders
631  $fobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "fold");
632  $f2objs = array();
633  foreach ($fobjs as $obj)
634  {
635  $f2objs[$obj["title"].":".$obj["id"]] = $obj;
636  }
637  ksort($f2objs);
638 
639  // get current media objects
640  $mobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "mob");
641  $m2objs = array();
642  foreach ($mobjs as $obj)
643  {
644  $m2objs[$obj["title"].":".$obj["id"]] = $obj;
645  }
646  ksort($m2objs);
647 
648  // merge everything together
649  $objs = array_merge($f2objs, $m2objs);
650 
651  $tpl->setCurrentBlock("chapter_list");
652  $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("mep"));
653  $tpl->setVariable("TXT_CONT_TITLE", $med_pool->getTitle());
654  $tpl->setCurrentBlock("change_cont_obj");
655  $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
656  $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
657  $tpl->setVariable("COLSPAN", "2");
658  $tpl->parseCurrentBlock();
659 
660  if ($parent_id = $med_pool->getParentId($_SESSION["il_link_mep_obj"]))
661  {
662  $css_row = "tblrow1";
663  $tpl->setCurrentBlock("icon");
664  $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.gif"));
665  $tpl->parseCurrentBlock();
666  $tpl->setCurrentBlock("link_row");
667  $tpl->setVariable("ROWCLASS", $css_row);
668  $tpl->setVariable("TXT_CHAPTER", "..");
669  $this->ctrl->setParameter($this, "mep_fold", $parent_id);
670  $tpl->setVariable("LINK",
671  $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
672  $tpl->parseCurrentBlock();
673  $tpl->setCurrentBlock("row");
674  $tpl->parseCurrentBlock();
675  }
676 
677  foreach($objs as $obj)
678  {
679  if($obj["type"] == "fold")
680  {
681  $css_row = ($css_row == "tblrow2")
682  ? "tblrow1"
683  : "tblrow2";
684  $tpl->setCurrentBlock("icon");
685  $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.gif"));
686  $tpl->parseCurrentBlock();
687  $tpl->setCurrentBlock("link_row");
688  $tpl->setVariable("ROWCLASS", $css_row);
689  $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
690  $this->ctrl->setParameter($this, "mep_fold", $obj["obj_id"]);
691  $tpl->setVariable("LINK",
692  $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
693  $tpl->parseCurrentBlock();
694  }
695  else
696  {
697  $css_row = ($css_row == "tblrow2")
698  ? "tblrow1"
699  : "tblrow2";
700  switch ($this->mode)
701  {
702  case "link":
703  require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
704  require_once("./Services/MediaObjects/classes/class.ilImageMapEditorGUI.php");
706  $tpl->setCurrentBlock("link_row");
707  $this->outputThumbnail($tpl, $obj["obj_id"], "link");
708  $tpl->setCurrentBlock("link_row");
709  $tpl->setVariable("ROWCLASS", $css_row);
710  $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
711  $tpl->setVariable("LINK_TARGET", "content");
712  $tpl->setVariable("LINK",
714  "linktype=MediaObject".
715  "&linktarget=il__mob_".$obj["obj_id"].
716  "&linktargetframe=".$this->link_target));
717  $tpl->parseCurrentBlock();
718  break;
719 
720  default:
721  $tpl->setCurrentBlock($chapterRowBlock);
722  $this->outputThumbnail($tpl, $obj["obj_id"]);
723  $tpl->setCurrentBlock($chapterRowBlock);
724  $tpl->setVariable("ROWCLASS", $css_row);
725  $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
726  if ($target_str != "")
727  {
728  $tpl->setVariable("LINK_CHAPTER",
729  $this->prepareJavascriptOutput("[iln media=\"".$obj["obj_id"]."\"".$target_str."] [/iln]"));
730  }
731  else
732  {
733  $tpl->setVariable("LINK_CHAPTER",
734  $this->prepareJavascriptOutput("[iln media=\"".$obj["obj_id"]."\"/]"));
735  }
736  $tpl->parseCurrentBlock();
737  break;
738  }
739  }
740  $tpl->setCurrentBlock("row");
741  $tpl->parseCurrentBlock();
742  }
743  $tpl->setCurrentBlock("chapter_list");
744  $tpl->parseCurrentBlock();
745  }
746  break;
747 
748  // repository item
749  case "RepositoryItem":
750  $tpl->setVariable("LINK_HELP_CONTENT", $this->selectRepositoryItem());
751  break;
752 
753  }
754 
755 
756  $tpl->show();
757  exit;
758  }
759 
760 
764  function outputThumbnail(&$tpl, $a_id, $a_mode = "")
765  {
766  // output thumbnail
767  $mob =& new ilObjMediaObject($a_id);
768  $med =& $mob->getMediaItem("Standard");
769  $target = $med->getThumbnailTarget("small");
770  if ($a_mode == "link")
771  {
772  $tpl->setCurrentBlock("thumbnail_link");
773  }
774  else if ($this->isEnabledJavaScript())
775  {
776  $tpl->setCurrentBlock("thumbnail_js");
777  }
778  else
779  {
780  $tpl->setCurrentBlock("thumbnail");
781  }
782  if ($target != "")
783  {
784  $tpl->setCurrentBlock("thumb");
785  $tpl->setVariable("SRC_THUMB", $target);
786  $tpl->parseCurrentBlock();
787  }
788  else
789  {
790  $tpl->setVariable("NO_THUMB", "&nbsp;");
791  }
792 
793  if ($a_mode == "link")
794  {
795  $tpl->setCurrentBlock("thumbnail_link");
796  }
797  else if ($this->isEnabledJavaScript())
798 
799  {
800  $tpl->setCurrentBlock("thumbnail_js");
801  }
802  else
803  {
804  $tpl->setCurrentBlock("thumbnail");
805  }
806  $tpl->parseCurrentBlock();
807  }
808 
809 
813  function changeLinkType()
814  {
815  $_SESSION["il_link_type"] = $_POST["ltype"];
816  $this->determineLinkType();
817  $this->showLinkHelp();
818  }
819 
823  function setMedPoolFolder()
824  {
825  $_SESSION["il_link_mep_obj"] = $_GET["mep_fold"];
826  $this->showLinkHelp();
827  }
828 
832  function changeTargetObject($a_type = "")
833  {
834  $_SESSION["il_link_mep_obj"] = "";
835 
836  if($_GET["do"] == "set")
837  {
838  switch ($_GET["target_type"])
839  {
840  case "glo":
841  $_SESSION["il_link_glossary"] = $_GET["sel_id"];
842  break;
843 
844  case "mep":
845  $_SESSION["il_link_mep"] = $_GET["sel_id"];
846  break;
847 
848  default:
849  $_SESSION["il_link_cont_obj"] = $_GET["sel_id"];
850  break;
851  }
852  $this->showLinkHelp();
853  return;
854  }
855 
856  if(empty($a_type))
857  {
858  $a_type = $_GET["target_type"];
859  }
860 
861  $tpl =& new ilTemplate("tpl.link_help_explorer.html", true, true, "Modules/LearningModule");
862  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
863 
864  require_once "classes/class.ilExplorer.php";
865  //$tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
866 
867 
868 //echo "<br><br>:".$this->ctrl->getLinkTarget($this).":<br>";
870  $this->ctrl->getTargetScript(), "do=set"));
871  if ($_GET["expand"] == "")
872  {
873  $expanded = $this->tree->readRootId();
874  }
875  else
876  {
877  $expanded = $_GET["expand"];
878  }
879  $exp->setExpand($expanded);
880 //echo "<br><br>exp:$expanded:<br>";
881 
882  $exp->setTargetGet("sel_id");
883  $this->ctrl->setParameter($this, "target_type", $a_type);
884  $exp->setParamsGet($this->ctrl->getParameterArray($this, "changeTargetObject"));
885 //echo "<br>"; var_dump($this->ctrl->getParameterArray($this, "changeTargetObject"));
886  /*$exp->setParamsGet(array("ref_id" => $_GET["ref_id"],
887  "cmd" => "changeTargetObject", "mode" => "page_edit", "obj_id" => $_GET["obj_id"],
888  "target_type" => $a_type, "linkmode" => $_GET["linkmode"]));*/
889 
890  $exp->addFilter("root");
891  $exp->addFilter("cat");
892  $exp->addFilter("grp");
893  $exp->addFilter("fold");
894  $exp->addFilter("crs");
895 
896  switch ($a_type)
897  {
898  case "glo":
899  $exp->addFilter("glo");
900  break;
901 
902  case "mep":
903  $exp->addFilter("mep");
904  break;
905 
906  default:
907  $exp->addFilter("lm");
908  $exp->addFilter("dbk");
909  break;
910  }
911  $exp->setFiltered(true);
912  $exp->setFilterMode(IL_FM_POSITIVE);
913 
914  $exp->setClickable("cat", false);
915  $exp->setClickable("grp", false);
916  $exp->setClickable("fold", false);
917  $exp->setClickable("crs", false);
918 
919  $exp->setFrameTarget("");
920  $exp->setOutput(0);
921 
922  $output = $exp->getOutput();
923 //echo "<br><br><br>out:".$output.":<br>";
924 
925  $tpl->setCurrentBlock("content");
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));
940  $tpl->setVariable("BTN_REFRESH", "changeTargetObject");
941  $tpl->setVariable("TXT_REFRESH", $this->lng->txt("refresh"));
942  $tpl->setVariable("BTN_RESET", "resetLinkList");
943  $tpl->setVariable("TXT_RESET", $this->lng->txt("reset"));
944 
945  if ($a_type == "mep")
946  {
947  $tpl->setCurrentBlock("sel_clipboard");
948  $this->ctrl->setParameter($this, "do", "set");
949  //$this->ctrl->setParameter($this, "sel_id", 0);
950  //$this->ctrl->setParameter($this, "target_type", "mep");
951  //$this->ctrl->setParameter($this, "linkmode", "");
952  //$this->ctrl->setParameter($this, "obj_id", "");
953  $tpl->setVariable("LINK_CLIPBOARD", $this->ctrl->getLinkTarget($this, "changeTargetObject"));
954  $tpl->setVariable("TXT_PERS_CLIPBOARD", $this->lng->txt("clipboard"));
955  $tpl->parseCurrentBlock();
956  }
957 
958  /*
959  $tpl->setVariable("BTN_STRUCTURE", "resetLinkList");
960  $tpl->setVariable("TXT_STRUCTURE", $this->lng->txt("reset"));*/
961  $tpl->parseCurrentBlock();
962 
963  $tpl->show();
964  exit;
965  }
966 
971  {
972  $_SESSION["il_link_mep_obj"] = "";
973 
974  if(empty($a_type))
975  {
976  $a_type = $_GET["target_type"];
977  }
978 
979  $tpl =& new ilTemplate("tpl.link_help_explorer.html", true, true, "Modules/LearningModule");
980  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
981 
982  include_once "./Modules/LearningModule/classes/class.ilIntLinkRepItemExplorer.php";
984  $this->ctrl->getTargetScript(), "do=set"));
985  if ($_GET["expand"] == "")
986  {
987  $expanded = $this->tree->readRootId();
988  }
989  else
990  {
991  $expanded = $_GET["expand"];
992  }
993  $exp->setMode($this->mode);
994  $exp->setSetLinkTargetScript($this->getSetLinkTargetScript());
995  $exp->setExpand($expanded);
996 
997  $exp->setTargetGet("sel_id");
998  $this->ctrl->setParameter($this, "target_type", $a_type);
999  $exp->setParamsGet($this->ctrl->getParameterArray($this, "showLinkHelp"));
1000 
1001  // filter
1002  $exp->setFiltered(true);
1003  $exp->setFilterMode(IL_FM_POSITIVE);
1004  $exp->addFilter("root");
1005  $exp->addFilter("cat");
1006  $exp->addFilter("grp");
1007  $exp->addFilter("fold");
1008  $exp->addFilter("crs");
1009  $exp->addFilter("lm");
1010  $exp->addFilter("htlm");
1011  $exp->addFilter("dbk");
1012  $exp->addFilter("glo");
1013  $exp->addFilter("frm");
1014  $exp->addFilter("exc");
1015  $exp->addFilter("tst");
1016  $exp->addFilter("svy");
1017  $exp->addFilter("webr");
1018  $exp->addFilter("file");
1019  $exp->addFilter("chat");
1020  $exp->addFilter("sahs");
1021  $exp->addFilter("mcst");
1022 
1023  $sel_types = array('lm','dbk','htlm','glo','frm','exc','tst','svy','webr','chat',
1024  'cat','crs','grp','file','fold','sahs','mcst');
1025  $exp->setSelectableTypes($sel_types);
1026 
1027  /*
1028  $exp->setClickable("cat", false);
1029  $exp->setClickable("grp", false);
1030  $exp->setClickable("fold", false);
1031  $exp->setClickable("crs", false);*/
1032 
1033  $exp->setFrameTarget("");
1034  $exp->setOutput(0);
1035 
1036  $output = $exp->getOutput();
1037 //echo "<br><br><br>out:".$output.":<br>";
1038 
1039  $tpl->setCurrentBlock("content");
1040  $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_repository_item_links"));
1041  $tpl->setVariable("EXPLORER",$output);
1042  $tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
1043  $tpl->setVariable("BTN_REFRESH", "showLinkHelp");
1044  $tpl->setVariable("TXT_REFRESH", $this->lng->txt("refresh"));
1045  $tpl->setVariable("BTN_RESET", "resetLinkList");
1046  $tpl->setVariable("TXT_RESET", $this->lng->txt("reset"));
1047 
1048  /*
1049  $tpl->setVariable("BTN_STRUCTURE", "resetLinkList");
1050  $tpl->setVariable("TXT_STRUCTURE", $this->lng->txt("reset"));*/
1051  $tpl->parseCurrentBlock();
1052 
1053  return $tpl->get();
1054  //$tpl->show();
1055  //exit;
1056  }
1057 
1058 
1059 
1064  {
1065  global $ilias;
1066 
1067  include_once("./Services/COPage/classes/class.ilPageEditorGUI.php");
1068  if($ilias->getSetting("enable_js_edit"))
1069  {
1071  {
1072  return true;
1073  }
1074  }
1075  return false;
1076  }
1077 
1078 
1079 }
1080 ?>