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