00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 require_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
00025 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
00026
00037 class ilInternalLinkGUI
00038 {
00039 var $default_type;
00040 var $default_obj;
00041 var $link_type;
00042 var $link_target;
00043 var $lng;
00044 var $mode;
00045 var $set_link_script;
00046 var $ctrl;
00047 var $tree;
00048
00049 function ilInternalLinkGUI($a_default_type, $a_default_obj)
00050 {
00051 global $lng, $ilias, $ilCtrl, $tree;
00052
00053 if (($_SESSION["il_link_cont_obj"] != "" && !$tree->isInTree($_SESSION["il_link_cont_obj"])) ||
00054 ($_SESSION["il_link_glossary"] != "" && !$tree->isInTree($_SESSION["il_link_glossary"])) ||
00055 ($_SESSION["il_link_mep"] != "" && !$tree->isInTree($_SESSION["il_link_mep"])))
00056 {
00057 $this->resetSessionVars();
00058 }
00059
00060 $this->lng =& $lng;
00061 $this->tree =& $tree;
00062 $this->ilias =& $ilias;
00063 $this->ctrl =& $ilCtrl;
00064 $this->ctrl->saveParameter($this, array("linkmode", "target_type"));
00065 $this->default_type = $a_default_type;
00066 $this->default_obj = $a_default_obj;
00067 $this->filter_link_types = array();
00068 $this->mode = "text";
00069
00070
00071 $this->determineLinkType();
00072
00073 $def_type = ilObject::_lookupType($this->default_obj, true);
00074
00075
00076 switch($this->link_type)
00077 {
00078 case "PageObject":
00079 case "StructureObject":
00080 if (empty($_SESSION["il_link_cont_obj"]) &&
00081 ($def_type != "mep" && $def_type != "glo"))
00082 {
00083 $_SESSION["il_link_cont_obj"] = $this->default_obj;
00084 }
00085 break;
00086
00087 case "GlossaryItem":
00088 if (empty($_SESSION["il_link_glossary"]) && $def_type == "glo")
00089 {
00090 $_SESSION["il_link_glossary"] = $this->default_obj;
00091 }
00092 break;
00093
00094 case "Media":
00095 if (empty($_SESSION["il_link_mep"]) && $def_type == "mep")
00096 {
00097 $_SESSION["il_link_mep"] = $this->default_obj;
00098 }
00099 break;
00100 }
00101
00102
00103
00104
00105
00106 }
00107
00108 function determineLinkType()
00109 {
00110
00111 $ltype = ($_SESSION["il_link_type"] == "")
00112 ? $this->default_type
00113 : $_SESSION["il_link_type"];
00114 $ltype_arr = explode("_", $ltype);
00115 $this->link_type = ($ltype_arr[0] == "")
00116 ? $this->default_type
00117 : $ltype_arr[0];
00118 $this->link_target = $ltype_arr[1];
00119 }
00120
00121 function setMode($a_mode = "text")
00122 {
00123 $this->mode = $a_mode;
00124 }
00125
00126 function setSetLinkTargetScript($a_script)
00127 {
00128 $this->set_link_script = $a_script;
00129 }
00130
00131 function setReturn($a_return)
00132 {
00133 $this->return = $a_return;
00134 }
00135
00136 function getSetLinkTargetScript()
00137 {
00138 return $this->set_link_script;
00139 }
00140
00141 function filterLinkType($a_link_type)
00142 {
00143 $this->filter_link_types[] = $a_link_type;
00144 }
00145
00146 function &executeCommand()
00147 {
00148 $next_class = $this->ctrl->getNextClass($this);
00149
00150 $cmd = $this->ctrl->getCmd("showLinkHelp");
00151 switch($next_class)
00152 {
00153 default:
00154 $ret =& $this->$cmd();
00155 break;
00156 }
00157
00158 return $ret;
00159 }
00160
00161 function resetSessionVars()
00162 {
00163 $_SESSION["il_link_mep"] = "";
00164 $_SESSION["il_link_mep_obj"] = "";
00165 $_SESSION["il_link_type"] = "";
00166 }
00167
00168 function resetLinkList()
00169 {
00170 $this->resetSessionVars();
00171 $this->determineLinkType();
00172 $this->showLinkHelp();
00173 }
00174
00175 function closeLinkHelp()
00176 {
00177 if ($this->return == "")
00178 {
00179 $this->ctrl->returnToParent($this);
00180 }
00181 else
00182 {
00183 ilUtil::redirect($this->return);
00184 }
00185 }
00186
00187
00188 function prepareJavascriptOutput($str)
00189 {
00190 global $ilUser;
00191
00192 include_once("./Services/COPage/classes/class.ilPageEditorGUI.php");
00193 if (ilPageEditorGUI::_doJSEditing())
00194 {
00195 $str = htmlspecialchars($str);
00196 }
00197 return($str);
00198 }
00199
00200
00204 function showLinkHelp()
00205 {
00206 global $ilUser;
00207
00208 $target_str = ($this->link_target == "")
00209 ? ""
00210 : " target=\"".$this->link_target."\"";
00211
00212 if(($this->link_type == "GlossaryItem") &&
00213 empty($_SESSION["il_link_glossary"]))
00214 {
00215 $this->changeTargetObject("glo");
00216 }
00217 if(($this->link_type == "PageObject" || $this->link_type == "StructureObject") &&
00218 empty($_SESSION["il_link_cont_obj"]))
00219 {
00220 $this->changeTargetObject("cont_obj");
00221 }
00222
00223 $tpl =& new ilTemplate("tpl.link_help.html", true, true, "Modules/LearningModule");
00224 $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00225
00226 switch($this->link_type)
00227 {
00228 case "GlossaryItem":
00229 $this->ctrl->setParameter($this, "target_type", "glo");
00230 break;
00231
00232 case "PageObject":
00233 case "StructureObject":
00234 $this->ctrl->setParameter($this, "target_type", "cont_obj");
00235 break;
00236
00237 case "Media":
00238 $this->ctrl->setParameter($this, "target_type", "mep");
00239 break;
00240
00241 default:
00242 break;
00243 }
00244
00245
00246
00247
00248 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00249 $tpl->setVariable("FORMACTION2", $this->ctrl->getFormAction($this));
00250 $tpl->setVariable("TXT_HELP_HEADER", $this->lng->txt("cont_link_select"));
00251 $tpl->setVariable("TXT_TYPE", $this->lng->txt("cont_link_type"));
00252 $ltypes = array("StructureObject" => $this->lng->txt("cont_lk_chapter"),
00253 "StructureObject_New" => $this->lng->txt("cont_lk_chapter_new"),
00254 "PageObject" => $this->lng->txt("cont_lk_page"),
00255 "PageObject_FAQ" => $this->lng->txt("cont_lk_page_faq"),
00256 "PageObject_New" => $this->lng->txt("cont_lk_page_new"),
00257 "GlossaryItem" => $this->lng->txt("cont_lk_term"),
00258 "GlossaryItem_New" => $this->lng->txt("cont_lk_term_new"),
00259 "Media" => $this->lng->txt("cont_lk_media_inline"),
00260 "Media_Media" => $this->lng->txt("cont_lk_media_media"),
00261 "Media_FAQ" => $this->lng->txt("cont_lk_media_faq"),
00262 "Media_New" => $this->lng->txt("cont_lk_media_new"),
00263 "RepositoryItem" => $this->lng->txt("cont_repository_item")
00264 );
00265
00266
00267 foreach($this->filter_link_types as $link_type)
00268 {
00269 unset($ltypes[$link_type]);
00270 }
00271
00272 $ltype = ($this->link_target != "")
00273 ? $this->link_type."_".$this->link_target
00274 : $this->link_type;
00275
00276
00277
00278 $select_ltype = ilUtil::formSelect ($ltype,
00279 "ltype", $ltypes, false, true);
00280 $tpl->setVariable("SELECT_TYPE", $select_ltype);
00281 $tpl->setVariable("CMD_CHANGETYPE", "changeLinkType");
00282 $tpl->setVariable("BTN_CHANGETYPE", $this->lng->txt("cont_change_type"));
00283
00284 if ($this->isEnabledJavaScript())
00285 {
00286 $tpl->setVariable("BTN_CLOSE_JS", $this->lng->txt("close"));
00287 }
00288 else
00289 {
00290 $tpl->setVariable("CMD_CLOSE", "closeLinkHelp");
00291 $tpl->setVariable("BTN_CLOSE", $this->lng->txt("close"));
00292 }
00293
00294 $chapterRowBlock = "chapter_row";
00295 if ($this->isEnabledJavaScript())
00296 {
00297 $chapterRowBlock .= "_js";
00298 }
00299
00300 $obj_id = ilObject::_lookupObjId($_SESSION["il_link_cont_obj"]);
00301 $type = ilObject::_lookupType($obj_id);
00302
00303 switch($this->link_type)
00304 {
00305
00306 case "PageObject":
00307 if ($type == "lm")
00308 {
00309 require_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
00310 $cont_obj =& new ilObjLearningModule($_SESSION["il_link_cont_obj"], true);
00311 }
00312 else if ($type == "dbk")
00313 {
00314 require_once("./Modules/LearningModule/classes/class.ilObjDlBook.php");
00315 $cont_obj =& new ilObjDlBook($_SESSION["il_link_cont_obj"], true);
00316 }
00317
00318
00319 $ctree =& $cont_obj->getLMTree();
00320 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
00321 $tpl->setCurrentBlock("chapter_list");
00322 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_content_obj"));
00323 $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
00324 $tpl->setCurrentBlock("change_cont_obj");
00325 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
00326 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
00327 $tpl->parseCurrentBlock();
00328
00329 foreach($nodes as $node)
00330 {
00331 if($node["type"] == "st")
00332 {
00333 $tpl->setCurrentBlock("chapter_row");
00334 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00335 $tpl->setVariable("ROWCLASS", "tblrow1");
00336
00337
00338 $tpl->parseCurrentBlock();
00339 }
00340 if($node["type"] == "pg")
00341 {
00342 switch ($this->mode)
00343 {
00344 case "link":
00345 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
00346 ilObjMediaObjectGUI::_recoverParameters();
00347 $tpl->setCurrentBlock("link_row");
00348 $tpl->setVariable("ROWCLASS", "tblrow2");
00349 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00350 $tpl->setVariable("LINK_TARGET", "content");
00351 $tpl->setVariable("LINK",
00352 ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00353 "linktype=PageObject".
00354 "&linktarget=il__pg_".$node["obj_id"].
00355 "&linktargetframe=".$this->link_target));
00356 $tpl->parseCurrentBlock();
00357 break;
00358
00359 default:
00360 $tpl->setCurrentBlock($chapterRowBlock);
00361 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00362 $tpl->setVariable("ROWCLASS", "tblrow2");
00363 $tpl->setVariable("LINK_CHAPTER",
00364 $this->prepareJavascriptOutput("[iln page=\"".$node["obj_id"]."\"".$target_str."] [/iln]"));
00365 $tpl->parseCurrentBlock();
00366 break;
00367 }
00368 }
00369 $tpl->setCurrentBlock("row");
00370 $tpl->parseCurrentBlock();
00371 }
00372
00373
00374 $pages = ilLMPageObject::getPageList($cont_obj->getId());
00375 $free_pages = array();
00376 foreach ($pages as $page)
00377 {
00378 if (!$ctree->isInTree($page["obj_id"]))
00379 {
00380 $free_pages[] = $page;
00381 }
00382 }
00383 if(count($free_pages) > 0)
00384 {
00385 $tpl->setCurrentBlock(str_replace("_js","",$chapterRowBlock));
00386 $tpl->setVariable("TXT_CHAPTER", $this->lng->txt("cont_free_pages"));
00387 $tpl->setVariable("ROWCLASS", "tblrow1");
00388 $tpl->parseCurrentBlock();
00389
00390 foreach ($free_pages as $node)
00391 {
00392 switch ($this->mode)
00393 {
00394 case "link":
00395 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
00396 ilObjMediaObjectGUI::_recoverParameters();
00397 $tpl->setCurrentBlock("link_row");
00398 $tpl->setVariable("ROWCLASS", "tblrow2");
00399 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00400 $tpl->setVariable("LINK_TARGET", "content");
00401 $tpl->setVariable("LINK",
00402 ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00403 "linktype=PageObject".
00404 "&linktarget=il__pg_".$node["obj_id"].
00405 "&linktargetframe=".$this->link_target));
00406 $tpl->parseCurrentBlock();
00407 break;
00408
00409 default:
00410 $tpl->setCurrentBlock($chapterRowBlock);
00411 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00412 $tpl->setVariable("ROWCLASS", "tblrow2");
00413 $tpl->setVariable("LINK_CHAPTER",
00414 $this->prepareJavascriptOutput("[iln page=\"".$node["obj_id"]."\"".$target_str."] [/iln]"));
00415 $tpl->parseCurrentBlock();
00416 break;
00417 }
00418 }
00419 }
00420
00421 $tpl->setCurrentBlock("chapter_list");
00422 $tpl->parseCurrentBlock();
00423
00424 break;
00425
00426
00427 case "StructureObject":
00428
00429
00430 if ($type == "lm")
00431 {
00432 require_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
00433 $cont_obj =& new ilObjLearningModule($_SESSION["il_link_cont_obj"], true);
00434 }
00435 else if ($type == "dbk")
00436 {
00437 require_once("./Modules/LearningModule/classes/class.ilObjDlBook.php");
00438 $cont_obj =& new ilObjDlBook($_SESSION["il_link_cont_obj"], true);
00439 }
00440
00441
00442 $ctree =& $cont_obj->getLMTree();
00443 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
00444 $tpl->setCurrentBlock("chapter_list");
00445 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_content_obj"));
00446 $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
00447 $tpl->setCurrentBlock("change_cont_obj");
00448 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
00449 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
00450 $tpl->parseCurrentBlock();
00451
00452 foreach($nodes as $node)
00453 {
00454 if($node["type"] == "st")
00455 {
00456 $css_row = ($css_row == "tblrow1")
00457 ? "tblrow2"
00458 : "tblrow1";
00459
00460 switch ($this->mode)
00461 {
00462 case "link":
00463 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
00464 ilObjMediaObjectGUI::_recoverParameters();
00465 $tpl->setCurrentBlock("link_row");
00466 $tpl->setVariable("ROWCLASS", $css_row);
00467 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00468 $tpl->setVariable("LINK_TARGET", "content");
00469 $tpl->setVariable("LINK",
00470 ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00471 "linktype=StructureObject".
00472 "&linktarget=il__st_".$node["obj_id"].
00473 "&linktargetframe=".$this->link_target));
00474 $tpl->parseCurrentBlock();
00475 break;
00476
00477 default:
00478 $tpl->setCurrentBlock($chapterRowBlock);
00479 $tpl->setVariable("ROWCLASS", $css_row);
00480 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00481 $tpl->setVariable("LINK_CHAPTER",
00482 $this->prepareJavascriptOutput("[iln chap=\"".$node["obj_id"]."\"".$target_str."] [/iln]"));
00483 $tpl->parseCurrentBlock();
00484 break;
00485 }
00486 }
00487 $tpl->setCurrentBlock("row");
00488 $tpl->parseCurrentBlock();
00489 }
00490 $tpl->setCurrentBlock("chapter_list");
00491 $tpl->parseCurrentBlock();
00492 break;
00493
00494
00495 case "GlossaryItem":
00496 require_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
00497 $glossary =& new ilObjGlossary($_SESSION["il_link_glossary"], true);
00498
00499
00500 $terms = $glossary->getTermList();
00501 $tpl->setCurrentBlock("chapter_list");
00502 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("glossary"));
00503 $tpl->setVariable("TXT_CONT_TITLE", $glossary->getTitle());
00504 $tpl->setCurrentBlock("change_cont_obj");
00505 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
00506 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
00507 $tpl->parseCurrentBlock();
00508
00509 foreach($terms as $term)
00510 {
00511 $css_row = ($css_row =="tblrow1")
00512 ? "tblrow2"
00513 : "tblrow1";
00514
00515 switch ($this->mode)
00516 {
00517 case "link":
00518 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
00519 ilObjMediaObjectGUI::_recoverParameters();
00520 $tpl->setCurrentBlock("link_row");
00521 $tpl->setVariable("ROWCLASS", "tblrow2");
00522 $tpl->setVariable("TXT_CHAPTER", $term["term"]);
00523 $tpl->setVariable("LINK_TARGET", "content");
00524 $tpl->setVariable("LINK",
00525 ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00526 "linktype=GlossaryItem".
00527 "&linktarget=il__git_".$term["id"].
00528 "&linktargetframe=".$this->link_target));
00529 $tpl->parseCurrentBlock();
00530 break;
00531
00532 default:
00533 $tpl->setCurrentBlock($chapterRowBlock);
00534 $tpl->setVariable("ROWCLASS", $css_row);
00535 $tpl->setVariable("TXT_CHAPTER", $term["term"]);
00536 $tpl->setVariable("LINK_CHAPTER",
00537 $this->prepareJavascriptOutput("[iln term=\"".$term["id"]."\"".$target_str."]"." "."[/iln]"));
00538 $tpl->parseCurrentBlock();
00539 $tpl->setCurrentBlock("row");
00540 $tpl->parseCurrentBlock();
00541 break;
00542 }
00543 }
00544
00545 $tpl->setCurrentBlock("chapter_list");
00546 $tpl->parseCurrentBlock();
00547 break;
00548
00549
00550 case "Media":
00551
00552
00553 if ($_SESSION["il_link_mep"] == 0)
00554 {
00555 $tpl->setCurrentBlock("change_cont_obj");
00556 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
00557 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
00558 $tpl->parseCurrentBlock();
00559 $mobjs = $this->ilias->account->getClipboardObjects("mob");
00560
00561 $objs = array();
00562 foreach ($mobjs as $obj)
00563 {
00564 $objs[$obj["title"].":".$obj["id"]] = $obj;
00565 }
00566 ksort($objs);
00567 $tpl->setCurrentBlock("chapter_list");
00568 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_media_source"));
00569 $tpl->setVariable("TXT_CONT_TITLE", $this->lng->txt("cont_personal_clipboard"));
00570 $tpl->setVariable("COLSPAN", "2");
00571
00572 foreach($objs as $obj)
00573 {
00574 switch ($this->mode)
00575 {
00576 case "link":
00577 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
00578 ilObjMediaObjectGUI::_recoverParameters();
00579 $tpl->setCurrentBlock("link_row");
00580 $this->outputThumbnail($tpl, $obj["id"], "link");
00581 $tpl->setCurrentBlock("link_row");
00582
00583 $tpl->setCurrentBlock("link_row");
00584 $tpl->setVariable("ROWCLASS", "tblrow2");
00585 $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
00586 $tpl->setVariable("LINK_TARGET", "content");
00587 $tpl->setVariable("LINK",
00588 ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00589 "linktype=MediaObject".
00590 "&linktarget=il__mob_".$obj["id"].
00591 "&linktargetframe=".$this->link_target));
00592 $tpl->parseCurrentBlock();
00593 break;
00594
00595 default:
00596 $tpl->setCurrentBlock($chapterRowBlock);
00597 $this->outputThumbnail($tpl, $obj["id"]);
00598 $tpl->setCurrentBlock($chapterRowBlock);
00599 $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
00600 $tpl->setVariable("ROWCLASS", "tblrow1");
00601 if (!empty($target_str))
00602 {
00603 $tpl->setVariable("LINK_CHAPTER",
00604 $this->prepareJavascriptOutput("[iln media=\"".$obj["id"]."\"".$target_str."] [/iln]"));
00605 }
00606 else
00607 {
00608 $tpl->setVariable("LINK_CHAPTER",
00609 $this->prepareJavascriptOutput("[iln media=\"".$obj["id"]."\"/]"));
00610 }
00611 $tpl->parseCurrentBlock();
00612 $tpl->setCurrentBlock("row");
00613 $tpl->parseCurrentBlock();
00614 break;
00615 }
00616 }
00617 $tpl->setCurrentBlock("chapter_list");
00618 $tpl->parseCurrentBlock();
00619 }
00620 else
00621 {
00622 require_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
00623 $med_pool =& new ilObjMediaPool($_SESSION["il_link_mep"], true);
00624
00625
00626 $fobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "fold");
00627 $f2objs = array();
00628 foreach ($fobjs as $obj)
00629 {
00630 $f2objs[$obj["title"].":".$obj["id"]] = $obj;
00631 }
00632 ksort($f2objs);
00633
00634
00635 $mobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "mob");
00636 $m2objs = array();
00637 foreach ($mobjs as $obj)
00638 {
00639 $m2objs[$obj["title"].":".$obj["id"]] = $obj;
00640 }
00641 ksort($m2objs);
00642
00643
00644 $objs = array_merge($f2objs, $m2objs);
00645
00646 $tpl->setCurrentBlock("chapter_list");
00647 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("mep"));
00648 $tpl->setVariable("TXT_CONT_TITLE", $med_pool->getTitle());
00649 $tpl->setCurrentBlock("change_cont_obj");
00650 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
00651 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
00652 $tpl->setVariable("COLSPAN", "2");
00653 $tpl->parseCurrentBlock();
00654
00655 if ($parent_id = $med_pool->getParentId($_SESSION["il_link_mep_obj"]))
00656 {
00657 $css_row = "tblrow1";
00658 $tpl->setCurrentBlock("icon");
00659 $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.gif"));
00660 $tpl->parseCurrentBlock();
00661 $tpl->setCurrentBlock("link_row");
00662 $tpl->setVariable("ROWCLASS", $css_row);
00663 $tpl->setVariable("TXT_CHAPTER", "..");
00664 $this->ctrl->setParameter($this, "mep_fold", $parent_id);
00665 $tpl->setVariable("LINK",
00666 $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
00667 $tpl->parseCurrentBlock();
00668 $tpl->setCurrentBlock("row");
00669 $tpl->parseCurrentBlock();
00670 }
00671
00672 foreach($objs as $obj)
00673 {
00674 if($obj["type"] == "fold")
00675 {
00676 $css_row = ($css_row == "tblrow2")
00677 ? "tblrow1"
00678 : "tblrow2";
00679 $tpl->setCurrentBlock("icon");
00680 $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.gif"));
00681 $tpl->parseCurrentBlock();
00682 $tpl->setCurrentBlock("link_row");
00683 $tpl->setVariable("ROWCLASS", $css_row);
00684 $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
00685 $this->ctrl->setParameter($this, "mep_fold", $obj["obj_id"]);
00686 $tpl->setVariable("LINK",
00687 $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
00688 $tpl->parseCurrentBlock();
00689 }
00690 else
00691 {
00692 $css_row = ($css_row == "tblrow2")
00693 ? "tblrow1"
00694 : "tblrow2";
00695 switch ($this->mode)
00696 {
00697 case "link":
00698 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
00699 ilObjMediaObjectGUI::_recoverParameters();
00700 $tpl->setCurrentBlock("link_row");
00701 $this->outputThumbnail($tpl, $obj["obj_id"], "link");
00702 $tpl->setCurrentBlock("link_row");
00703 $tpl->setVariable("ROWCLASS", $css_row);
00704 $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
00705 $tpl->setVariable("LINK_TARGET", "content");
00706 $tpl->setVariable("LINK",
00707 ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00708 "linktype=MediaObject".
00709 "&linktarget=il__mob_".$obj["obj_id"].
00710 "&linktargetframe=".$this->link_target));
00711 $tpl->parseCurrentBlock();
00712 break;
00713
00714 default:
00715 $tpl->setCurrentBlock($chapterRowBlock);
00716 $this->outputThumbnail($tpl, $obj["obj_id"]);
00717 $tpl->setCurrentBlock($chapterRowBlock);
00718 $tpl->setVariable("ROWCLASS", $css_row);
00719 $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
00720 if ($target_str != "")
00721 {
00722 $tpl->setVariable("LINK_CHAPTER",
00723 $this->prepareJavascriptOutput("[iln media=\"".$obj["obj_id"]."\"".$target_str."] [/iln]"));
00724 }
00725 else
00726 {
00727 $tpl->setVariable("LINK_CHAPTER",
00728 $this->prepareJavascriptOutput("[iln media=\"".$obj["obj_id"]."\"/]"));
00729 }
00730 $tpl->parseCurrentBlock();
00731 break;
00732 }
00733 }
00734 $tpl->setCurrentBlock("row");
00735 $tpl->parseCurrentBlock();
00736 }
00737 $tpl->setCurrentBlock("chapter_list");
00738 $tpl->parseCurrentBlock();
00739 }
00740 break;
00741
00742
00743 case "RepositoryItem":
00744 $tpl->setVariable("LINK_HELP_CONTENT", $this->selectRepositoryItem());
00745 break;
00746
00747 }
00748
00749
00750 $tpl->show();
00751 exit;
00752 }
00753
00754
00758 function outputThumbnail(&$tpl, $a_id, $a_mode = "")
00759 {
00760
00761 $mob =& new ilObjMediaObject($a_id);
00762 $med =& $mob->getMediaItem("Standard");
00763 $target = $med->getThumbnailTarget("small");
00764 if ($a_mode == "link")
00765 {
00766 $tpl->setCurrentBlock("thumbnail_link");
00767 }
00768 else if ($this->isEnabledJavaScript())
00769 {
00770 $tpl->setCurrentBlock("thumbnail_js");
00771 }
00772 else
00773 {
00774 $tpl->setCurrentBlock("thumbnail");
00775 }
00776 if ($target != "")
00777 {
00778 $tpl->setCurrentBlock("thumb");
00779 $tpl->setVariable("SRC_THUMB", $target);
00780 $tpl->parseCurrentBlock();
00781 }
00782 else
00783 {
00784 $tpl->setVariable("NO_THUMB", " ");
00785 }
00786
00787 if ($a_mode == "link")
00788 {
00789 $tpl->setCurrentBlock("thumbnail_link");
00790 }
00791 else if ($this->isEnabledJavaScript())
00792
00793 {
00794 $tpl->setCurrentBlock("thumbnail_js");
00795 }
00796 else
00797 {
00798 $tpl->setCurrentBlock("thumbnail");
00799 }
00800 $tpl->parseCurrentBlock();
00801 }
00802
00803
00807 function changeLinkType()
00808 {
00809 $_SESSION["il_link_type"] = $_POST["ltype"];
00810 $this->determineLinkType();
00811 $this->showLinkHelp();
00812 }
00813
00817 function setMedPoolFolder()
00818 {
00819 $_SESSION["il_link_mep_obj"] = $_GET["mep_fold"];
00820 $this->showLinkHelp();
00821 }
00822
00826 function changeTargetObject($a_type = "")
00827 {
00828 $_SESSION["il_link_mep_obj"] = "";
00829
00830 if($_GET["do"] == "set")
00831 {
00832 switch ($_GET["target_type"])
00833 {
00834 case "glo":
00835 $_SESSION["il_link_glossary"] = $_GET["sel_id"];
00836 break;
00837
00838 case "mep":
00839 $_SESSION["il_link_mep"] = $_GET["sel_id"];
00840 break;
00841
00842 default:
00843 $_SESSION["il_link_cont_obj"] = $_GET["sel_id"];
00844 break;
00845 }
00846 $this->showLinkHelp();
00847 return;
00848 }
00849
00850 if(empty($a_type))
00851 {
00852 $a_type = $_GET["target_type"];
00853 }
00854
00855 $tpl =& new ilTemplate("tpl.link_help_explorer.html", true, true, "Modules/LearningModule");
00856 $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00857
00858 require_once "classes/class.ilExplorer.php";
00859
00860
00861
00862
00863 $exp = new ilExplorer(ilUtil::appendUrlParameterString(
00864 $this->ctrl->getTargetScript(), "do=set"));
00865 if ($_GET["expand"] == "")
00866 {
00867 $expanded = $this->tree->readRootId();
00868 }
00869 else
00870 {
00871 $expanded = $_GET["expand"];
00872 }
00873 $exp->setExpand($expanded);
00874
00875
00876 $exp->setTargetGet("sel_id");
00877 $this->ctrl->setParameter($this, "target_type", $a_type);
00878 $exp->setParamsGet($this->ctrl->getParameterArray($this, "changeTargetObject"));
00879
00880
00881
00882
00883
00884 $exp->addFilter("root");
00885 $exp->addFilter("cat");
00886 $exp->addFilter("grp");
00887 $exp->addFilter("fold");
00888 $exp->addFilter("crs");
00889
00890 switch ($a_type)
00891 {
00892 case "glo":
00893 $exp->addFilter("glo");
00894 break;
00895
00896 case "mep":
00897 $exp->addFilter("mep");
00898 break;
00899
00900 default:
00901 $exp->addFilter("lm");
00902 $exp->addFilter("dbk");
00903 break;
00904 }
00905 $exp->setFiltered(true);
00906 $exp->setFilterMode(IL_FM_POSITIVE);
00907
00908 $exp->setClickable("cat", false);
00909 $exp->setClickable("grp", false);
00910 $exp->setClickable("fold", false);
00911 $exp->setClickable("crs", false);
00912
00913 $exp->setFrameTarget("");
00914 $exp->setOutput(0);
00915
00916 $output = $exp->getOutput();
00917
00918
00919 $tpl->setCurrentBlock("content");
00920 if ($a_type == "glo")
00921 {
00922 $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_glossary"));
00923 }
00924 else if ($a_type == "mep")
00925 {
00926 $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_media_source"));
00927 }
00928 else
00929 {
00930 $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_cont_obj"));
00931 }
00932 $tpl->setVariable("EXPLORER",$output);
00933 $tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
00934 $tpl->setVariable("BTN_REFRESH", "changeTargetObject");
00935 $tpl->setVariable("TXT_REFRESH", $this->lng->txt("refresh"));
00936 $tpl->setVariable("BTN_RESET", "resetLinkList");
00937 $tpl->setVariable("TXT_RESET", $this->lng->txt("reset"));
00938
00939 if ($a_type == "mep")
00940 {
00941 $tpl->setCurrentBlock("sel_clipboard");
00942 $this->ctrl->setParameter($this, "do", "set");
00943
00944
00945
00946
00947 $tpl->setVariable("LINK_CLIPBOARD", $this->ctrl->getLinkTarget($this, "changeTargetObject"));
00948 $tpl->setVariable("TXT_PERS_CLIPBOARD", $this->lng->txt("clipboard"));
00949 $tpl->parseCurrentBlock();
00950 }
00951
00952
00953
00954
00955 $tpl->parseCurrentBlock();
00956
00957 $tpl->show();
00958 exit;
00959 }
00960
00964 function selectRepositoryItem()
00965 {
00966 $_SESSION["il_link_mep_obj"] = "";
00967
00968 if(empty($a_type))
00969 {
00970 $a_type = $_GET["target_type"];
00971 }
00972
00973 $tpl =& new ilTemplate("tpl.link_help_explorer.html", true, true, "Modules/LearningModule");
00974 $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00975
00976 include_once "./Modules/LearningModule/classes/class.ilIntLinkRepItemExplorer.php";
00977 $exp = new ilIntLinkRepItemExplorer(ilUtil::appendUrlParameterString(
00978 $this->ctrl->getTargetScript(), "do=set"));
00979 if ($_GET["expand"] == "")
00980 {
00981 $expanded = $this->tree->readRootId();
00982 }
00983 else
00984 {
00985 $expanded = $_GET["expand"];
00986 }
00987 $exp->setMode($this->mode);
00988 $exp->setSetLinkTargetScript($this->getSetLinkTargetScript());
00989 $exp->setExpand($expanded);
00990
00991 $exp->setTargetGet("sel_id");
00992 $this->ctrl->setParameter($this, "target_type", $a_type);
00993 $exp->setParamsGet($this->ctrl->getParameterArray($this, "showLinkHelp"));
00994
00995
00996 $exp->setFiltered(true);
00997 $exp->setFilterMode(IL_FM_POSITIVE);
00998 $exp->addFilter("root");
00999 $exp->addFilter("cat");
01000 $exp->addFilter("grp");
01001 $exp->addFilter("fold");
01002 $exp->addFilter("crs");
01003 $exp->addFilter("lm");
01004 $exp->addFilter("htlm");
01005 $exp->addFilter("dbk");
01006 $exp->addFilter("glo");
01007 $exp->addFilter("frm");
01008 $exp->addFilter("exc");
01009 $exp->addFilter("tst");
01010 $exp->addFilter("svy");
01011 $exp->addFilter("webr");
01012 $exp->addFilter("file");
01013 $exp->addFilter("chat");
01014 $exp->addFilter("sahs");
01015 $exp->addFilter("mcst");
01016
01017 $sel_types = array('lm','dbk','htlm','glo','frm','exc','tst','svy','webr','chat',
01018 'cat','crs','grp','file','fold','sahs','mcst');
01019 $exp->setSelectableTypes($sel_types);
01020
01021
01022
01023
01024
01025
01026
01027 $exp->setFrameTarget("");
01028 $exp->setOutput(0);
01029
01030 $output = $exp->getOutput();
01031
01032
01033 $tpl->setCurrentBlock("content");
01034 $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_repository_item_links"));
01035 $tpl->setVariable("EXPLORER",$output);
01036 $tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
01037 $tpl->setVariable("BTN_REFRESH", "showLinkHelp");
01038 $tpl->setVariable("TXT_REFRESH", $this->lng->txt("refresh"));
01039 $tpl->setVariable("BTN_RESET", "resetLinkList");
01040 $tpl->setVariable("TXT_RESET", $this->lng->txt("reset"));
01041
01042
01043
01044
01045 $tpl->parseCurrentBlock();
01046
01047 return $tpl->get();
01048
01049
01050 }
01051
01052
01053
01057 function isEnabledJavaScript()
01058 {
01059 global $ilias;
01060
01061 include_once("./Services/COPage/classes/class.ilPageEditorGUI.php");
01062 if($ilias->getSetting("enable_js_edit"))
01063 {
01064 if (ilPageEditorGUI::_doJSEditing())
01065 {
01066 return true;
01067 }
01068 }
01069 return false;
01070 }
01071
01072
01073 }
01074 ?>