• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

content/classes/class.ilInternalLinkGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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;                      // "text" | "link"
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                 // determine link type and target
00065                 $this->determineLinkType();
00066 
00067                 $def_type = ilObject::_lookupType($this->default_obj, true);
00068 
00069                 // determine content object id
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                 $target_str = ($link_target == "")
00098                         ? ""
00099                         : " target=\"".$link_target."\" ";*/
00100         }
00101 
00102         function determineLinkType()
00103         {
00104                 // determine link type and target
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         function showLinkHelp()
00177         {
00178                 global $ilUser;
00179                 
00180                 $target_str = ($this->link_target == "")
00181                         ? ""
00182                         : " target=\"".$this->link_target."\"";
00183 
00184                 if(($this->link_type == "GlossaryItem") &&
00185                         empty($_SESSION["il_link_glossary"]))
00186                 {
00187                         $this->changeTargetObject("glo");
00188                 }
00189                 if(($this->link_type == "PageObject" || $this->link_type == "StructureObject") &&
00190                         empty($_SESSION["il_link_cont_obj"]))
00191                 {
00192                         $this->changeTargetObject("cont_obj");
00193                 }
00194 
00195                 $tpl =& new ilTemplate("tpl.link_help.html", true, true, true);
00196                 $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00197 
00198                 switch($this->link_type)
00199                 {
00200                         case "GlossaryItem":
00201                                 $this->ctrl->setParameter($this, "target_type", "glo");
00202                                 break;
00203 
00204                         case "PageObject":
00205                         case "StructureObject":
00206                                 $this->ctrl->setParameter($this, "target_type", "cont_obj");
00207                                 break;
00208 
00209                         case "Media":
00210                                 $this->ctrl->setParameter($this, "target_type", "mep");
00211                                 break;
00212 
00213                         default:
00214                                 break;
00215                 }
00216 //echo "<br><br>:".$this->ctrl->getFormAction($this).":";
00217 //echo "<br>link_type:".$this->link_type;
00218 //echo "<br>cont_obj:".$_SESSION["il_link_cont_obj"];
00219 //echo "<br>link_mep".$_SESSION["il_link_mep"];
00220                 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00221                 $tpl->setVariable("FORMACTION2", $this->ctrl->getFormAction($this));
00222                 $tpl->setVariable("TXT_HELP_HEADER", $this->lng->txt("cont_link_select"));
00223                 $tpl->setVariable("TXT_TYPE", $this->lng->txt("cont_link_type"));
00224                 $ltypes = array("StructureObject" => $this->lng->txt("cont_lk_chapter"),
00225                         "StructureObject_New" => $this->lng->txt("cont_lk_chapter_new"),
00226                         "PageObject" => $this->lng->txt("cont_lk_page"),
00227                         "PageObject_FAQ" => $this->lng->txt("cont_lk_page_faq"),
00228                         "PageObject_New" => $this->lng->txt("cont_lk_page_new"),
00229                         "GlossaryItem" => $this->lng->txt("cont_lk_term"),
00230                         "GlossaryItem_New" => $this->lng->txt("cont_lk_term_new"),
00231                         "Media" => $this->lng->txt("cont_lk_media_inline"),
00232                         "Media_Media" => $this->lng->txt("cont_lk_media_media"),
00233                         "Media_FAQ" => $this->lng->txt("cont_lk_media_faq"),
00234                         "Media_New" => $this->lng->txt("cont_lk_media_new")
00235                         );
00236 
00237                 // filter link types
00238                 foreach($this->filter_link_types as $link_type)
00239                 {
00240                         unset($ltypes[$link_type]);
00241                 }
00242 
00243                 $ltype = ($this->link_target != "")
00244                         ? $this->link_type."_".$this->link_target
00245                         : $this->link_type;
00246 
00247 //echo "<br><br>".$ltype;
00248 
00249                 $select_ltype = ilUtil::formSelect ($ltype,
00250                         "ltype", $ltypes, false, true);
00251                 $tpl->setVariable("SELECT_TYPE", $select_ltype);
00252                 $tpl->setVariable("CMD_CHANGETYPE", "changeLinkType");
00253                 $tpl->setVariable("BTN_CHANGETYPE", $this->lng->txt("cont_change_type"));
00254                 
00255                 if ($this->isEnabledJavaScript())
00256                 {
00257                         $tpl->setVariable("BTN_CLOSE_JS", $this->lng->txt("close"));
00258                 }
00259                 else 
00260                 {
00261                         $tpl->setVariable("CMD_CLOSE", "closeLinkHelp");
00262                         $tpl->setVariable("BTN_CLOSE", $this->lng->txt("close"));
00263                 }
00264 
00265                 $chapterRowBlock = "chapter_row";
00266                 if ($this->isEnabledJavaScript())
00267                 {
00268                         $chapterRowBlock .= "_js";
00269                 }
00270                 
00271                 switch($this->link_type)
00272                 {
00273                         // page link
00274                         case "PageObject":
00275                                 require_once("./content/classes/class.ilObjContentObject.php");
00276                                 $cont_obj =& new ilObjContentObject($_SESSION["il_link_cont_obj"], true);
00277 
00278                                 // get all chapters
00279                                 $ctree =& $cont_obj->getLMTree();
00280                                 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
00281                                 $tpl->setCurrentBlock("chapter_list");
00282                                 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_content_obj"));
00283                                 $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
00284                                 $tpl->setCurrentBlock("change_cont_obj");
00285                                 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
00286                                 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
00287                                 $tpl->parseCurrentBlock();
00288 
00289                                 foreach($nodes as $node)
00290                                 {
00291                                         if($node["type"] == "st")
00292                                         {
00293                                                 $tpl->setCurrentBlock("chapter_row");
00294                                                 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00295                                                 $tpl->setVariable("ROWCLASS", "tblrow1");
00296                                                 //$tpl->setVariable("LINK_CHAPTER",
00297                                                 //      "[iln chap=\"".$node["obj_id"]."\"".$target_str."] [/iln]");
00298                                                 $tpl->parseCurrentBlock();
00299                                         }
00300                                         if($node["type"] == "pg")
00301                                         {
00302                                                 switch ($this->mode)
00303                                                 {
00304                                                         case "link":
00305                                                                 require_once("content/classes/Media/class.ilObjMediaObjectGUI.php");
00306                                                                 ilObjMediaObjectGUI::_recoverParameters();
00307                                                                 $tpl->setCurrentBlock("link_row");
00308                                                                 $tpl->setVariable("ROWCLASS", "tblrow2");
00309                                                                 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00310                                                                 $tpl->setVariable("LINK_TARGET", "content");
00311                                                                 $tpl->setVariable("LINK",
00312                                                                         ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00313                                                                         "linktype=PageObject".
00314                                                                         "&linktarget=il__pg_".$node["obj_id"].
00315                                                                         "&linktargetframe=".$this->link_target));
00316                                                                 $tpl->parseCurrentBlock();
00317                                                                 break;
00318 
00319                                                         default:
00320                                                                 $tpl->setCurrentBlock($chapterRowBlock);
00321                                                                 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00322                                                                 $tpl->setVariable("ROWCLASS", "tblrow2");
00323                                                                 $tpl->setVariable("LINK_CHAPTER",
00324                                                                         $this->prepareJavascriptOutput("[iln page=\"".$node["obj_id"]."\"".$target_str."] [/iln]"));
00325                                                                 $tpl->parseCurrentBlock();
00326                                                                 break;
00327                                                 }
00328                                         }
00329                                         $tpl->setCurrentBlock("row");
00330                                         $tpl->parseCurrentBlock();
00331                                 }
00332 
00333                                 // get all free pages
00334                                 $pages = ilLMPageObject::getPageList($cont_obj->getId());
00335                                 $free_pages = array();
00336                                 foreach ($pages as $page)
00337                                 {
00338                                         if (!$ctree->isInTree($page["obj_id"]))
00339                                         {
00340                                                 $free_pages[] = $page;
00341                                         }
00342                                 }
00343                                 if(count($free_pages) > 0)
00344                                 {
00345                                         $tpl->setCurrentBlock(str_replace("_js","",$chapterRowBlock));
00346                                         $tpl->setVariable("TXT_CHAPTER", $this->lng->txt("cont_free_pages"));
00347                                         $tpl->setVariable("ROWCLASS", "tblrow1");
00348                                         $tpl->parseCurrentBlock();
00349 
00350                                         foreach ($free_pages as $node)
00351                                         {
00352                                                 switch ($this->mode)
00353                                                 {
00354                                                         case "link":
00355                                                                 require_once("content/classes/Media/class.ilObjMediaObjectGUI.php");
00356                                                                 ilObjMediaObjectGUI::_recoverParameters();
00357                                                                 $tpl->setCurrentBlock("link_row");
00358                                                                 $tpl->setVariable("ROWCLASS", "tblrow2");
00359                                                                 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00360                                                                 $tpl->setVariable("LINK_TARGET", "content");
00361                                                                 $tpl->setVariable("LINK",
00362                                                                         ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00363                                                                         "linktype=PageObject".
00364                                                                         "&linktarget=il__pg_".$node["obj_id"].
00365                                                                         "&linktargetframe=".$this->link_target));
00366                                                                 $tpl->parseCurrentBlock();
00367                                                                 break;
00368 
00369                                                         default:
00370                                                                 $tpl->setCurrentBlock($chapterRowBlock);
00371                                                                 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00372                                                                 $tpl->setVariable("ROWCLASS", "tblrow2");
00373                                                                 $tpl->setVariable("LINK_CHAPTER",
00374                                                                         $this->prepareJavascriptOutput("[iln page=\"".$node["obj_id"]."\"".$target_str."] [/iln]"));
00375                                                                 $tpl->parseCurrentBlock();
00376                                                                 break;
00377                                                 }
00378                                         }
00379                                 }
00380 
00381                                 $tpl->setCurrentBlock("chapter_list");
00382                                 $tpl->parseCurrentBlock();
00383 
00384                                 break;
00385 
00386                         // chapter link
00387                         case "StructureObject":
00388                                 require_once("./content/classes/class.ilObjContentObject.php");
00389                                 $cont_obj =& new ilObjContentObject($_SESSION["il_link_cont_obj"], true);
00390 
00391                                 // get all chapters
00392                                 $ctree =& $cont_obj->getLMTree();
00393                                 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
00394                                 $tpl->setCurrentBlock("chapter_list");
00395                                 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_content_obj"));
00396                                 $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
00397                                 $tpl->setCurrentBlock("change_cont_obj");
00398                                 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
00399                                 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
00400                                 $tpl->parseCurrentBlock();
00401 
00402                                 foreach($nodes as $node)
00403                                 {
00404                                         if($node["type"] == "st")
00405                                         {
00406                                                 $css_row = ($css_row == "tblrow1")
00407                                                         ? "tblrow2"
00408                                                         : "tblrow1";
00409 
00410                                                 switch ($this->mode)
00411                                                 {
00412                                                         case "link":
00413                                                                 require_once("content/classes/Media/class.ilObjMediaObjectGUI.php");
00414                                                                 ilObjMediaObjectGUI::_recoverParameters();
00415                                                                 $tpl->setCurrentBlock("link_row");
00416                                                                 $tpl->setVariable("ROWCLASS", $css_row);
00417                                                                 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00418                                                                 $tpl->setVariable("LINK_TARGET", "content");
00419                                                                 $tpl->setVariable("LINK",
00420                                                                         ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00421                                                                         "linktype=StructureObject".
00422                                                                         "&linktarget=il__st_".$node["obj_id"].
00423                                                                         "&linktargetframe=".$this->link_target));
00424                                                                 $tpl->parseCurrentBlock();
00425                                                                 break;
00426 
00427                                                         default:
00428                                                                 $tpl->setCurrentBlock($chapterRowBlock);
00429                                                                 $tpl->setVariable("ROWCLASS", $css_row);
00430                                                                 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00431                                                                 $tpl->setVariable("LINK_CHAPTER",
00432                                                                         $this->prepareJavascriptOutput("[iln chap=\"".$node["obj_id"]."\"".$target_str."] [/iln]"));
00433                                                                 $tpl->parseCurrentBlock();
00434                                                                 break;
00435                                                 }
00436                                         }
00437                                         $tpl->setCurrentBlock("row");
00438                                         $tpl->parseCurrentBlock();
00439                                 }
00440                                 $tpl->setCurrentBlock("chapter_list");
00441                                 $tpl->parseCurrentBlock();
00442                                 break;
00443 
00444                         // glossary item link
00445                         case "GlossaryItem":
00446                                 require_once("./content/classes/class.ilObjGlossary.php");
00447                                 $glossary =& new ilObjGlossary($_SESSION["il_link_glossary"], true);
00448 
00449                                 // get all glossary items
00450                                 $terms = $glossary->getTermList();
00451                                 $tpl->setCurrentBlock("chapter_list");
00452                                 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("glossary"));
00453                                 $tpl->setVariable("TXT_CONT_TITLE", $glossary->getTitle());
00454                                 $tpl->setCurrentBlock("change_cont_obj");
00455                                 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
00456                                 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
00457                                 $tpl->parseCurrentBlock();
00458 
00459                                 foreach($terms as $term)
00460                                 {
00461                                         $css_row = ($css_row =="tblrow1")
00462                                                 ? "tblrow2"
00463                                                 : "tblrow1";
00464 
00465                                         switch ($this->mode)
00466                                         {
00467                                                 case "link":
00468                                                         require_once("content/classes/Media/class.ilObjMediaObjectGUI.php");
00469                                                         ilObjMediaObjectGUI::_recoverParameters();
00470                                                         $tpl->setCurrentBlock("link_row");
00471                                                         $tpl->setVariable("ROWCLASS", "tblrow2");
00472                                                         $tpl->setVariable("TXT_CHAPTER", $term["term"]);
00473                                                         $tpl->setVariable("LINK_TARGET", "content");
00474                                                         $tpl->setVariable("LINK",
00475                                                                 ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00476                                                                         "linktype=GlossaryItem".
00477                                                                         "&linktarget=il__git_".$term["id"].
00478                                                                         "&linktargetframe=".$this->link_target));
00479                                                         $tpl->parseCurrentBlock();
00480                                                         break;
00481 
00482                                                 default:
00483                                                         $tpl->setCurrentBlock($chapterRowBlock);
00484                                                         $tpl->setVariable("ROWCLASS", $css_row);
00485                                                         $tpl->setVariable("TXT_CHAPTER", $term["term"]);
00486                                                         $tpl->setVariable("LINK_CHAPTER",
00487                                                                 $this->prepareJavascriptOutput("[iln term=\"".$term["id"]."\"".$target_str."]".$term["term"]."[/iln]"));
00488                                                         $tpl->parseCurrentBlock();
00489                                                         $tpl->setCurrentBlock("row");
00490                                                         $tpl->parseCurrentBlock();
00491                                                         break;
00492                                         }
00493                                 }
00494 
00495                                 $tpl->setCurrentBlock("chapter_list");
00496                                 $tpl->parseCurrentBlock();
00497                                 break;
00498 
00499                         // media object
00500                         case "Media":
00501                                 //$tpl->setVariable("TARGET2", " target=\"content\" ");
00502                                 // content object id = 0 --> get clipboard objects
00503                                 if ($_SESSION["il_link_mep"] == 0)
00504                                 {
00505                                         $tpl->setCurrentBlock("change_cont_obj");
00506                                         $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
00507                                         $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
00508                                         $tpl->parseCurrentBlock();
00509                                         $objs = $this->ilias->account->getClipboardObjects("mob");
00510                                         $tpl->setCurrentBlock("chapter_list");
00511                                         $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_media_source"));
00512                                         $tpl->setVariable("TXT_CONT_TITLE", $this->lng->txt("cont_personal_clipboard"));
00513 
00514                                         foreach($objs as $obj)
00515                                         {
00516                                                 switch ($this->mode)
00517                                                 {
00518                                                         case "link":
00519                                                                 require_once("content/classes/Media/class.ilObjMediaObjectGUI.php");
00520                                                                 ilObjMediaObjectGUI::_recoverParameters();
00521                                                                 $tpl->setCurrentBlock("link_row");
00522                                                                 $tpl->setVariable("ROWCLASS", "tblrow2");
00523                                                                 $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
00524                                                                 $tpl->setVariable("LINK_TARGET", "content");
00525                                                                 $tpl->setVariable("LINK",
00526                                                                         ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00527                                                                         "linktype=MediaObject".
00528                                                                         "&linktarget=il__mob_".$obj["id"].
00529                                                                         "&linktargetframe=".$this->link_target));
00530                                                                 $tpl->parseCurrentBlock();
00531                                                                 break;
00532 
00533                                                         default:
00534                                                                 $tpl->setCurrentBlock($chapterRowBlock);
00535                                                                 $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
00536                                                                 $tpl->setVariable("ROWCLASS", "tblrow1");
00537                                                                 if (!empty($target_str))
00538                                                                 {
00539                                                                         $tpl->setVariable("LINK_CHAPTER",
00540                                                                                 $this->prepareJavascriptOutput("[iln media=\"".$obj["id"]."\"".$target_str."] [/iln]"));
00541                                                                 }
00542                                                                 else
00543                                                                 {
00544                                                                         $tpl->setVariable("LINK_CHAPTER",
00545                                                                                 $this->prepareJavascriptOutput("[iln media=\"".$obj["id"]."\"/]"));
00546                                                                 }
00547                                                                 $tpl->parseCurrentBlock();
00548                                                                 $tpl->setCurrentBlock("row");
00549                                                                 $tpl->parseCurrentBlock();
00550                                                                 break;
00551                                                 }
00552                                         }
00553                                         $tpl->setCurrentBlock("chapter_list");
00554                                         $tpl->parseCurrentBlock();
00555                                 }
00556                                 else
00557                                 {
00558                                         require_once("./content/classes/class.ilObjMediaPool.php");
00559                                         $med_pool =& new ilObjMediaPool($_SESSION["il_link_mep"], true);
00560 
00561                                         // get media objects
00562                                         $objs = $med_pool->getChilds($_SESSION["il_link_mep_obj"]);
00563                                         $tpl->setCurrentBlock("chapter_list");
00564                                         $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("mep"));
00565                                         $tpl->setVariable("TXT_CONT_TITLE", $med_pool->getTitle());
00566                                         $tpl->setCurrentBlock("change_cont_obj");
00567                                         $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
00568                                         $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
00569                                         $tpl->parseCurrentBlock();
00570 
00571                                         if ($parent_id = $med_pool->getParentId($_SESSION["il_link_mep_obj"]))
00572                                         {
00573                                                 $css_row = "tblrow1";
00574                                                 $tpl->setCurrentBlock("icon");
00575                                                 $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.gif"));
00576                                                 $tpl->parseCurrentBlock();
00577                                                 $tpl->setCurrentBlock("link_row");
00578                                                 $tpl->setVariable("ROWCLASS", $css_row);
00579                                                 $tpl->setVariable("TXT_CHAPTER", "..");
00580                                                 $this->ctrl->setParameter($this, "mep_fold", $parent_id);
00581                                                 $tpl->setVariable("LINK",
00582                                                         $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
00583                                                 $tpl->parseCurrentBlock();
00584                                         }
00585 
00586                                         foreach($objs as $obj)
00587                                         {
00588                                                 if($obj["type"] == "fold")
00589                                                 {
00590                                                         $css_row = ($css_row == "tblrow2")
00591                                                                 ? "tblrow1"
00592                                                                 : "tblrow2";
00593                                                         $tpl->setCurrentBlock("icon");
00594                                                         $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.gif"));
00595                                                         $tpl->parseCurrentBlock();
00596                                                         $tpl->setCurrentBlock("link_row");
00597                                                         $tpl->setVariable("ROWCLASS", $css_row);
00598                                                         $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
00599                                                         $this->ctrl->setParameter($this, "mep_fold", $obj["obj_id"]);
00600                                                         $tpl->setVariable("LINK",
00601                                                                 $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
00602                                                         $tpl->parseCurrentBlock();
00603                                                 }
00604                                                 else
00605                                                 {
00606                                                         $css_row = ($css_row == "tblrow2")
00607                                                                 ? "tblrow1"
00608                                                                 : "tblrow2";
00609                                                         switch ($this->mode)
00610                                                         {
00611                                                                 case "link":
00612                                                                         require_once("content/classes/Media/class.ilObjMediaObjectGUI.php");
00613                                                                         ilObjMediaObjectGUI::_recoverParameters();
00614                                                                         $tpl->setCurrentBlock("icon");
00615                                                                         $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_mob.gif"));
00616                                                                         $tpl->parseCurrentBlock();
00617                                                                         $tpl->setCurrentBlock("link_row");
00618                                                                         $tpl->setVariable("ROWCLASS", $css_row);
00619                                                                         $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
00620                                                                         $tpl->setVariable("LINK_TARGET", "content");
00621                                                                         $tpl->setVariable("LINK",
00622                                                                                 ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00623                                                                                 "linktype=MediaObject".
00624                                                                                 "&linktarget=il__mob_".$obj["obj_id"].
00625                                                                                 "&linktargetframe=".$this->link_target));
00626                                                                         $tpl->parseCurrentBlock();
00627                                                                         break;
00628 
00629                                                                 default:
00630                                                                         $tpl->setCurrentBlock($chapterRowBlock);
00631                                                                         $tpl->setVariable("ROWCLASS", $css_row);
00632                                                                         $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
00633                                                                         if ($target_str != "")
00634                                                                         {
00635                                                                                 $tpl->setVariable("LINK_CHAPTER",
00636                                                                                         $this->prepareJavascriptOutput("[iln media=\"".$obj["obj_id"]."\"".$target_str."] [/iln]"));
00637                                                                         }
00638                                                                         else
00639                                                                         {
00640                                                                                 $tpl->setVariable("LINK_CHAPTER",
00641                                                                                         $this->prepareJavascriptOutput("[iln media=\"".$obj["obj_id"]."\"/]"));
00642                                                                         }
00643                                                                         $tpl->parseCurrentBlock();
00644                                                                         break;
00645                                                         }
00646                                                 }
00647                                                 $tpl->setCurrentBlock("row");
00648                                                 $tpl->parseCurrentBlock();
00649                                         }
00650                                         $tpl->setCurrentBlock("chapter_list");
00651                                         $tpl->parseCurrentBlock();
00652                                 }
00653 
00654 
00655                                 break;
00656 
00657                 }
00658 
00659                 $tpl->show();
00660                 exit;
00661         }
00662 
00663         function changeLinkType()
00664         {
00665                 $_SESSION["il_link_type"] = $_POST["ltype"];
00666                 $this->determineLinkType();
00667                 $this->showLinkHelp();
00668         }
00669 
00670         function setMedPoolFolder()
00671         {
00672                 $_SESSION["il_link_mep_obj"] = $_GET["mep_fold"];
00673                 $this->showLinkHelp();
00674         }
00675 
00676         function changeTargetObject($a_type = "")
00677         {
00678                 $_SESSION["il_link_mep_obj"] = "";
00679 
00680                 if($_GET["do"] == "set")
00681                 {
00682                         switch ($_GET["target_type"])
00683                         {
00684                                 case "glo":
00685                                         $_SESSION["il_link_glossary"] = $_GET["sel_id"];
00686                                         break;
00687 
00688                                 case "mep":
00689                                         $_SESSION["il_link_mep"] = $_GET["sel_id"];
00690                                         break;
00691 
00692                                 default:
00693                                         $_SESSION["il_link_cont_obj"] = $_GET["sel_id"];
00694                                         break;
00695                         }
00696                         $this->showLinkHelp();
00697                         return;
00698                 }
00699 
00700                 if(empty($a_type))
00701                 {
00702                         $a_type = $_GET["target_type"];
00703                 }
00704 
00705                 $tpl =& new ilTemplate("tpl.link_help_explorer.html", true, true, true);
00706                 $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00707 
00708                 require_once "classes/class.ilExplorer.php";
00709                 //$tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
00710 
00711 
00712 //echo "<br><br>:".$this->ctrl->getLinkTarget($this).":<br>";
00713                 $exp = new ilExplorer(ilUtil::appendUrlParameterString(
00714                         $this->ctrl->getTargetScript(), "do=set"));
00715                 if ($_GET["expand"] == "")
00716                 {
00717                         $expanded = $this->tree->readRootId();
00718                 }
00719                 else
00720                 {
00721                         $expanded = $_GET["expand"];
00722                 }
00723                 $exp->setExpand($expanded);
00724 //echo "<br><br>exp:$expanded:<br>";
00725 
00726                 $exp->setTargetGet("sel_id");
00727                 $this->ctrl->setParameter($this, "target_type", $a_type);
00728                 $exp->setParamsGet($this->ctrl->getParameterArray($this, "changeTargetObject"));
00729 //echo "<br>"; var_dump($this->ctrl->getParameterArray($this, "changeTargetObject"));
00730                 /*$exp->setParamsGet(array("ref_id" => $_GET["ref_id"],
00731                         "cmd" => "changeTargetObject", "mode" => "page_edit", "obj_id" => $_GET["obj_id"],
00732                         "target_type" => $a_type, "linkmode" => $_GET["linkmode"]));*/
00733 
00734                 $exp->addFilter("root");
00735                 $exp->addFilter("cat");
00736                 $exp->addFilter("grp");
00737                 $exp->addFilter("fold");
00738                 $exp->addFilter("crs");
00739 
00740                 switch ($a_type)
00741                 {
00742                         case "glo":
00743                                 $exp->addFilter("glo");
00744                                 break;
00745 
00746                         case "mep":
00747                                 $exp->addFilter("mep");
00748                                 break;
00749 
00750                         default:
00751                                 $exp->addFilter("lm");
00752                                 $exp->addFilter("dbk");
00753                                 break;
00754                 }
00755                 $exp->setFiltered(true);
00756                 $exp->setFilterMode(IL_FM_POSITIVE);
00757 
00758                 $exp->setClickable("cat", false);
00759                 $exp->setClickable("grp", false);
00760                 $exp->setClickable("fold", false);
00761                 $exp->setClickable("crs", false);
00762 
00763                 $exp->setFrameTarget("");
00764                 $exp->setOutput(0);
00765 
00766                 $output = $exp->getOutput();
00767 //echo "<br><br><br>out:".$output.":<br>";
00768 
00769                 $tpl->setCurrentBlock("content");
00770                 if ($a_type == "glo")
00771                 {
00772                         $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_glossary"));
00773                 }
00774                 else if ($a_type == "mep")
00775                 {
00776                         $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_media_source"));
00777                 }
00778                 else
00779                 {
00780                         $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_cont_obj"));
00781                 }
00782                 $tpl->setVariable("EXPLORER",$output);
00783                 $tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
00784                 $tpl->setVariable("BTN_REFRESH", "changeTargetObject");
00785                 $tpl->setVariable("TXT_REFRESH", $this->lng->txt("refresh"));
00786                 $tpl->setVariable("BTN_RESET", "resetLinkList");
00787                 $tpl->setVariable("TXT_RESET", $this->lng->txt("reset"));
00788 
00789                 if ($a_type == "mep")
00790                 {
00791                         $tpl->setCurrentBlock("sel_clipboard");
00792                         $this->ctrl->setParameter($this, "do", "set");
00793                         //$this->ctrl->setParameter($this, "sel_id", 0);
00794                         //$this->ctrl->setParameter($this, "target_type", "mep");
00795                         //$this->ctrl->setParameter($this, "linkmode", "");
00796                         //$this->ctrl->setParameter($this, "obj_id", "");
00797                         $tpl->setVariable("LINK_CLIPBOARD", $this->ctrl->getLinkTarget($this, "changeTargetObject"));
00798                         $tpl->setVariable("TXT_PERS_CLIPBOARD", $this->lng->txt("clipboard"));
00799                         $tpl->parseCurrentBlock();
00800                 }
00801 
00802                 /*
00803                 $tpl->setVariable("BTN_STRUCTURE", "resetLinkList");
00804                 $tpl->setVariable("TXT_STRUCTURE", $this->lng->txt("reset"));*/
00805                 $tpl->parseCurrentBlock();
00806 
00807                 $tpl->show();
00808                 exit;
00809         }
00810 
00811 
00815         function isEnabledJavaScript()
00816         {
00817                 global $ilias;
00818                 
00819                 include_once("content/classes/Pages/class.ilPageEditorGUI.php");
00820                 if($ilias->getSetting("enable_js_edit"))
00821                 {
00822                         if (ilPageEditorGUI::_doJSEditing())
00823                         {
00824                                 return true;
00825                         }
00826                 }
00827                 return false;
00828         }
00829 
00830 
00831 }
00832 ?>

Generated on Fri Dec 13 2013 08:00:15 for ILIAS Release_3_3_x_branch .rev 46803 by  doxygen 1.7.1