• 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-2006 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                 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                 // determine link type and target
00071                 $this->determineLinkType();
00072 
00073                 $def_type = ilObject::_lookupType($this->default_obj, true);
00074 
00075                 // determine content object id
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                 $target_str = ($link_target == "")
00104                         ? ""
00105                         : " target=\"".$link_target."\" ";*/
00106         }
00107 
00108         function determineLinkType()
00109         {
00110                 // determine link type and target
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("content/classes/Pages/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, true);
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 //echo "<br><br>:".$this->ctrl->getFormAction($this).":";
00245 //echo "<br>link_type:".$this->link_type;
00246 //echo "<br>cont_obj:".$_SESSION["il_link_cont_obj"];
00247 //echo "<br>link_mep".$_SESSION["il_link_mep"];
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                 // filter link types
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 //echo "<br><br>".$ltype;
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                 switch($this->link_type)
00301                 {
00302                         // page link
00303                         case "PageObject":
00304                                 require_once("./content/classes/class.ilObjContentObject.php");
00305                                 $cont_obj =& new ilObjContentObject($_SESSION["il_link_cont_obj"], true);
00306 
00307                                 // get all chapters
00308                                 $ctree =& $cont_obj->getLMTree();
00309                                 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
00310                                 $tpl->setCurrentBlock("chapter_list");
00311                                 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_content_obj"));
00312                                 $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
00313                                 $tpl->setCurrentBlock("change_cont_obj");
00314                                 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
00315                                 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
00316                                 $tpl->parseCurrentBlock();
00317 
00318                                 foreach($nodes as $node)
00319                                 {
00320                                         if($node["type"] == "st")
00321                                         {
00322                                                 $tpl->setCurrentBlock("chapter_row");
00323                                                 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00324                                                 $tpl->setVariable("ROWCLASS", "tblrow1");
00325                                                 //$tpl->setVariable("LINK_CHAPTER",
00326                                                 //      "[iln chap=\"".$node["obj_id"]."\"".$target_str."] [/iln]");
00327                                                 $tpl->parseCurrentBlock();
00328                                         }
00329                                         if($node["type"] == "pg")
00330                                         {
00331                                                 switch ($this->mode)
00332                                                 {
00333                                                         case "link":
00334                                                                 require_once("content/classes/Media/class.ilObjMediaObjectGUI.php");
00335                                                                 ilObjMediaObjectGUI::_recoverParameters();
00336                                                                 $tpl->setCurrentBlock("link_row");
00337                                                                 $tpl->setVariable("ROWCLASS", "tblrow2");
00338                                                                 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00339                                                                 $tpl->setVariable("LINK_TARGET", "content");
00340                                                                 $tpl->setVariable("LINK",
00341                                                                         ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00342                                                                         "linktype=PageObject".
00343                                                                         "&linktarget=il__pg_".$node["obj_id"].
00344                                                                         "&linktargetframe=".$this->link_target));
00345                                                                 $tpl->parseCurrentBlock();
00346                                                                 break;
00347 
00348                                                         default:
00349                                                                 $tpl->setCurrentBlock($chapterRowBlock);
00350                                                                 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00351                                                                 $tpl->setVariable("ROWCLASS", "tblrow2");
00352                                                                 $tpl->setVariable("LINK_CHAPTER",
00353                                                                         $this->prepareJavascriptOutput("[iln page=\"".$node["obj_id"]."\"".$target_str."] [/iln]"));
00354                                                                 $tpl->parseCurrentBlock();
00355                                                                 break;
00356                                                 }
00357                                         }
00358                                         $tpl->setCurrentBlock("row");
00359                                         $tpl->parseCurrentBlock();
00360                                 }
00361 
00362                                 // get all free pages
00363                                 $pages = ilLMPageObject::getPageList($cont_obj->getId());
00364                                 $free_pages = array();
00365                                 foreach ($pages as $page)
00366                                 {
00367                                         if (!$ctree->isInTree($page["obj_id"]))
00368                                         {
00369                                                 $free_pages[] = $page;
00370                                         }
00371                                 }
00372                                 if(count($free_pages) > 0)
00373                                 {
00374                                         $tpl->setCurrentBlock(str_replace("_js","",$chapterRowBlock));
00375                                         $tpl->setVariable("TXT_CHAPTER", $this->lng->txt("cont_free_pages"));
00376                                         $tpl->setVariable("ROWCLASS", "tblrow1");
00377                                         $tpl->parseCurrentBlock();
00378 
00379                                         foreach ($free_pages as $node)
00380                                         {
00381                                                 switch ($this->mode)
00382                                                 {
00383                                                         case "link":
00384                                                                 require_once("content/classes/Media/class.ilObjMediaObjectGUI.php");
00385                                                                 ilObjMediaObjectGUI::_recoverParameters();
00386                                                                 $tpl->setCurrentBlock("link_row");
00387                                                                 $tpl->setVariable("ROWCLASS", "tblrow2");
00388                                                                 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00389                                                                 $tpl->setVariable("LINK_TARGET", "content");
00390                                                                 $tpl->setVariable("LINK",
00391                                                                         ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00392                                                                         "linktype=PageObject".
00393                                                                         "&linktarget=il__pg_".$node["obj_id"].
00394                                                                         "&linktargetframe=".$this->link_target));
00395                                                                 $tpl->parseCurrentBlock();
00396                                                                 break;
00397 
00398                                                         default:
00399                                                                 $tpl->setCurrentBlock($chapterRowBlock);
00400                                                                 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00401                                                                 $tpl->setVariable("ROWCLASS", "tblrow2");
00402                                                                 $tpl->setVariable("LINK_CHAPTER",
00403                                                                         $this->prepareJavascriptOutput("[iln page=\"".$node["obj_id"]."\"".$target_str."] [/iln]"));
00404                                                                 $tpl->parseCurrentBlock();
00405                                                                 break;
00406                                                 }
00407                                         }
00408                                 }
00409 
00410                                 $tpl->setCurrentBlock("chapter_list");
00411                                 $tpl->parseCurrentBlock();
00412 
00413                                 break;
00414 
00415                         // chapter link
00416                         case "StructureObject":
00417                                 require_once("./content/classes/class.ilObjContentObject.php");
00418                                 $cont_obj =& new ilObjContentObject($_SESSION["il_link_cont_obj"], true);
00419 
00420                                 // get all chapters
00421                                 $ctree =& $cont_obj->getLMTree();
00422                                 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
00423                                 $tpl->setCurrentBlock("chapter_list");
00424                                 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_content_obj"));
00425                                 $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
00426                                 $tpl->setCurrentBlock("change_cont_obj");
00427                                 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
00428                                 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
00429                                 $tpl->parseCurrentBlock();
00430 
00431                                 foreach($nodes as $node)
00432                                 {
00433                                         if($node["type"] == "st")
00434                                         {
00435                                                 $css_row = ($css_row == "tblrow1")
00436                                                         ? "tblrow2"
00437                                                         : "tblrow1";
00438 
00439                                                 switch ($this->mode)
00440                                                 {
00441                                                         case "link":
00442                                                                 require_once("content/classes/Media/class.ilObjMediaObjectGUI.php");
00443                                                                 ilObjMediaObjectGUI::_recoverParameters();
00444                                                                 $tpl->setCurrentBlock("link_row");
00445                                                                 $tpl->setVariable("ROWCLASS", $css_row);
00446                                                                 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00447                                                                 $tpl->setVariable("LINK_TARGET", "content");
00448                                                                 $tpl->setVariable("LINK",
00449                                                                         ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00450                                                                         "linktype=StructureObject".
00451                                                                         "&linktarget=il__st_".$node["obj_id"].
00452                                                                         "&linktargetframe=".$this->link_target));
00453                                                                 $tpl->parseCurrentBlock();
00454                                                                 break;
00455 
00456                                                         default:
00457                                                                 $tpl->setCurrentBlock($chapterRowBlock);
00458                                                                 $tpl->setVariable("ROWCLASS", $css_row);
00459                                                                 $tpl->setVariable("TXT_CHAPTER", $node["title"]);
00460                                                                 $tpl->setVariable("LINK_CHAPTER",
00461                                                                         $this->prepareJavascriptOutput("[iln chap=\"".$node["obj_id"]."\"".$target_str."] [/iln]"));
00462                                                                 $tpl->parseCurrentBlock();
00463                                                                 break;
00464                                                 }
00465                                         }
00466                                         $tpl->setCurrentBlock("row");
00467                                         $tpl->parseCurrentBlock();
00468                                 }
00469                                 $tpl->setCurrentBlock("chapter_list");
00470                                 $tpl->parseCurrentBlock();
00471                                 break;
00472 
00473                         // glossary item link
00474                         case "GlossaryItem":
00475                                 require_once("./content/classes/class.ilObjGlossary.php");
00476                                 $glossary =& new ilObjGlossary($_SESSION["il_link_glossary"], true);
00477 
00478                                 // get all glossary items
00479                                 $terms = $glossary->getTermList();
00480                                 $tpl->setCurrentBlock("chapter_list");
00481                                 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("glossary"));
00482                                 $tpl->setVariable("TXT_CONT_TITLE", $glossary->getTitle());
00483                                 $tpl->setCurrentBlock("change_cont_obj");
00484                                 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
00485                                 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
00486                                 $tpl->parseCurrentBlock();
00487 
00488                                 foreach($terms as $term)
00489                                 {
00490                                         $css_row = ($css_row =="tblrow1")
00491                                                 ? "tblrow2"
00492                                                 : "tblrow1";
00493 
00494                                         switch ($this->mode)
00495                                         {
00496                                                 case "link":
00497                                                         require_once("content/classes/Media/class.ilObjMediaObjectGUI.php");
00498                                                         ilObjMediaObjectGUI::_recoverParameters();
00499                                                         $tpl->setCurrentBlock("link_row");
00500                                                         $tpl->setVariable("ROWCLASS", "tblrow2");
00501                                                         $tpl->setVariable("TXT_CHAPTER", $term["term"]);
00502                                                         $tpl->setVariable("LINK_TARGET", "content");
00503                                                         $tpl->setVariable("LINK",
00504                                                                 ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00505                                                                         "linktype=GlossaryItem".
00506                                                                         "&linktarget=il__git_".$term["id"].
00507                                                                         "&linktargetframe=".$this->link_target));
00508                                                         $tpl->parseCurrentBlock();
00509                                                         break;
00510 
00511                                                 default:
00512                                                         $tpl->setCurrentBlock($chapterRowBlock);
00513                                                         $tpl->setVariable("ROWCLASS", $css_row);
00514                                                         $tpl->setVariable("TXT_CHAPTER", $term["term"]);
00515                                                         $tpl->setVariable("LINK_CHAPTER",
00516                                                                                           $this->prepareJavascriptOutput("[iln term=\"".$term["id"]."\"".$target_str."]"." "."[/iln]"));
00517                                                         $tpl->parseCurrentBlock();
00518                                                         $tpl->setCurrentBlock("row");
00519                                                         $tpl->parseCurrentBlock();
00520                                                         break;
00521                                         }
00522                                 }
00523 
00524                                 $tpl->setCurrentBlock("chapter_list");
00525                                 $tpl->parseCurrentBlock();
00526                                 break;
00527 
00528                         // media object
00529                         case "Media":
00530                                 //$tpl->setVariable("TARGET2", " target=\"content\" ");
00531                                 // content object id = 0 --> get clipboard objects
00532                                 if ($_SESSION["il_link_mep"] == 0)
00533                                 {
00534                                         $tpl->setCurrentBlock("change_cont_obj");
00535                                         $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
00536                                         $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
00537                                         $tpl->parseCurrentBlock();
00538                                         $mobjs = $this->ilias->account->getClipboardObjects("mob");
00539                                         // sort by name
00540                                         $objs = array();
00541                                         foreach ($mobjs as $obj)
00542                                         {
00543                                                 $objs[$obj["title"].":".$obj["id"]] = $obj;
00544                                         }
00545                                         ksort($objs);
00546                                         $tpl->setCurrentBlock("chapter_list");
00547                                         $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_media_source"));
00548                                         $tpl->setVariable("TXT_CONT_TITLE", $this->lng->txt("cont_personal_clipboard"));
00549                                         $tpl->setVariable("COLSPAN", "2");
00550 
00551                                         foreach($objs as $obj)
00552                                         {
00553                                                 switch ($this->mode)
00554                                                 {
00555                                                         case "link":
00556                                                                 require_once("content/classes/Media/class.ilObjMediaObjectGUI.php");
00557                                                                 ilObjMediaObjectGUI::_recoverParameters();
00558                                                                 $tpl->setCurrentBlock("link_row");
00559                                                                 $this->outputThumbnail($tpl, $obj["id"], "link");
00560                                                                 $tpl->setCurrentBlock("link_row");
00561 
00562                                                                 $tpl->setCurrentBlock("link_row");
00563                                                                 $tpl->setVariable("ROWCLASS", "tblrow2");
00564                                                                 $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
00565                                                                 $tpl->setVariable("LINK_TARGET", "content");
00566                                                                 $tpl->setVariable("LINK",
00567                                                                         ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00568                                                                         "linktype=MediaObject".
00569                                                                         "&linktarget=il__mob_".$obj["id"].
00570                                                                         "&linktargetframe=".$this->link_target));
00571                                                                 $tpl->parseCurrentBlock();
00572                                                                 break;
00573 
00574                                                         default:
00575                                                                 $tpl->setCurrentBlock($chapterRowBlock);
00576                                                                 $this->outputThumbnail($tpl, $obj["id"]);
00577                                                                 $tpl->setCurrentBlock($chapterRowBlock);
00578                                                                 $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
00579                                                                 $tpl->setVariable("ROWCLASS", "tblrow1");
00580                                                                 if (!empty($target_str))
00581                                                                 {
00582                                                                         $tpl->setVariable("LINK_CHAPTER",
00583                                                                                 $this->prepareJavascriptOutput("[iln media=\"".$obj["id"]."\"".$target_str."] [/iln]"));
00584                                                                 }
00585                                                                 else
00586                                                                 {
00587                                                                         $tpl->setVariable("LINK_CHAPTER",
00588                                                                                 $this->prepareJavascriptOutput("[iln media=\"".$obj["id"]."\"/]"));
00589                                                                 }
00590                                                                 $tpl->parseCurrentBlock();
00591                                                                 $tpl->setCurrentBlock("row");
00592                                                                 $tpl->parseCurrentBlock();
00593                                                                 break;
00594                                                 }
00595                                         }
00596                                         $tpl->setCurrentBlock("chapter_list");
00597                                         $tpl->parseCurrentBlock();
00598                                 }
00599                                 else
00600                                 {
00601                                         require_once("./content/classes/class.ilObjMediaPool.php");
00602                                         $med_pool =& new ilObjMediaPool($_SESSION["il_link_mep"], true);
00603 
00604                                         // get current folders
00605                                         $fobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "fold");
00606                                         $f2objs = array();
00607                                         foreach ($fobjs as $obj)
00608                                         {
00609                                                 $f2objs[$obj["title"].":".$obj["id"]] = $obj;
00610                                         }
00611                                         ksort($f2objs);
00612 
00613                                         // get current media objects
00614                                         $mobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "mob");
00615                                         $m2objs = array();
00616                                         foreach ($mobjs as $obj)
00617                                         {
00618                                                 $m2objs[$obj["title"].":".$obj["id"]] = $obj;
00619                                         }
00620                                         ksort($m2objs);
00621                                         
00622                                         // merge everything together
00623                                         $objs = array_merge($f2objs, $m2objs);
00624                                         
00625                                         $tpl->setCurrentBlock("chapter_list");
00626                                         $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("mep"));
00627                                         $tpl->setVariable("TXT_CONT_TITLE", $med_pool->getTitle());
00628                                         $tpl->setCurrentBlock("change_cont_obj");
00629                                         $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
00630                                         $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
00631                                         $tpl->setVariable("COLSPAN", "2");
00632                                         $tpl->parseCurrentBlock();
00633 
00634                                         if ($parent_id = $med_pool->getParentId($_SESSION["il_link_mep_obj"]))
00635                                         {
00636                                                 $css_row = "tblrow1";
00637                                                 $tpl->setCurrentBlock("icon");
00638                                                 $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.gif"));
00639                                                 $tpl->parseCurrentBlock();
00640                                                 $tpl->setCurrentBlock("link_row");
00641                                                 $tpl->setVariable("ROWCLASS", $css_row);
00642                                                 $tpl->setVariable("TXT_CHAPTER", "..");
00643                                                 $this->ctrl->setParameter($this, "mep_fold", $parent_id);
00644                                                 $tpl->setVariable("LINK",
00645                                                         $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
00646                                                 $tpl->parseCurrentBlock();
00647                                                 $tpl->setCurrentBlock("row");
00648                                                 $tpl->parseCurrentBlock();
00649                                         }
00650 
00651                                         foreach($objs as $obj)
00652                                         {
00653                                                 if($obj["type"] == "fold")
00654                                                 {
00655                                                         $css_row = ($css_row == "tblrow2")
00656                                                                 ? "tblrow1"
00657                                                                 : "tblrow2";
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", $obj["title"]);
00664                                                         $this->ctrl->setParameter($this, "mep_fold", $obj["obj_id"]);
00665                                                         $tpl->setVariable("LINK",
00666                                                                 $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
00667                                                         $tpl->parseCurrentBlock();
00668                                                 }
00669                                                 else
00670                                                 {
00671                                                         $css_row = ($css_row == "tblrow2")
00672                                                                 ? "tblrow1"
00673                                                                 : "tblrow2";
00674                                                         switch ($this->mode)
00675                                                         {
00676                                                                 case "link":
00677                                                                         require_once("content/classes/Media/class.ilObjMediaObjectGUI.php");
00678                                                                         ilObjMediaObjectGUI::_recoverParameters();
00679                                                                         $tpl->setCurrentBlock("link_row");
00680                                                                         $this->outputThumbnail($tpl, $obj["obj_id"], "link");
00681                                                                         $tpl->setCurrentBlock("link_row");
00682                                                                         $tpl->setVariable("ROWCLASS", $css_row);
00683                                                                         $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
00684                                                                         $tpl->setVariable("LINK_TARGET", "content");
00685                                                                         $tpl->setVariable("LINK",
00686                                                                                 ilUtil::appendUrlParameterString($this->getSetLinkTargetScript(),
00687                                                                                 "linktype=MediaObject".
00688                                                                                 "&linktarget=il__mob_".$obj["obj_id"].
00689                                                                                 "&linktargetframe=".$this->link_target));
00690                                                                         $tpl->parseCurrentBlock();
00691                                                                         break;
00692 
00693                                                                 default:
00694                                                                         $tpl->setCurrentBlock($chapterRowBlock);
00695                                                                         $this->outputThumbnail($tpl, $obj["obj_id"]);
00696                                                                         $tpl->setCurrentBlock($chapterRowBlock);
00697                                                                         $tpl->setVariable("ROWCLASS", $css_row);
00698                                                                         $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
00699                                                                         if ($target_str != "")
00700                                                                         {
00701                                                                                 $tpl->setVariable("LINK_CHAPTER",
00702                                                                                         $this->prepareJavascriptOutput("[iln media=\"".$obj["obj_id"]."\"".$target_str."] [/iln]"));
00703                                                                         }
00704                                                                         else
00705                                                                         {
00706                                                                                 $tpl->setVariable("LINK_CHAPTER",
00707                                                                                         $this->prepareJavascriptOutput("[iln media=\"".$obj["obj_id"]."\"/]"));
00708                                                                         }
00709                                                                         $tpl->parseCurrentBlock();
00710                                                                         break;
00711                                                         }
00712                                                 }
00713                                                 $tpl->setCurrentBlock("row");
00714                                                 $tpl->parseCurrentBlock();
00715                                         }
00716                                         $tpl->setCurrentBlock("chapter_list");
00717                                         $tpl->parseCurrentBlock();
00718                                 }
00719                                 break;
00720                                 
00721                         // repository item
00722                         case "RepositoryItem":
00723                                 $tpl->setVariable("LINK_HELP_CONTENT", $this->selectRepositoryItem());
00724                                 break;
00725 
00726                 }
00727 
00728                 
00729                 $tpl->show();
00730                 exit;
00731         }
00732         
00733         
00737         function outputThumbnail(&$tpl, $a_id, $a_mode = "")
00738         {
00739                 // output thumbnail
00740                 $mob =& new ilObjMediaObject($a_id);
00741                 $med =& $mob->getMediaItem("Standard");
00742                 $target = $med->getThumbnailTarget("small");
00743                 if ($a_mode == "link")
00744                 {
00745                         $tpl->setCurrentBlock("thumbnail_link");
00746                 }
00747                 else if ($this->isEnabledJavaScript())
00748                 {
00749                         $tpl->setCurrentBlock("thumbnail_js");
00750                 }
00751                 else
00752                 {
00753                         $tpl->setCurrentBlock("thumbnail");
00754                 }
00755                 if ($target != "")
00756                 {
00757                         $tpl->setCurrentBlock("thumb");
00758                         $tpl->setVariable("SRC_THUMB", $target);
00759                         $tpl->parseCurrentBlock();
00760                 }
00761                 else
00762                 {
00763                         $tpl->setVariable("NO_THUMB", "&nbsp;");
00764                 }
00765                 
00766                 if ($a_mode == "link")
00767                 {
00768                         $tpl->setCurrentBlock("thumbnail_link");
00769                 }
00770                 else if ($this->isEnabledJavaScript())
00771 
00772                 {
00773                         $tpl->setCurrentBlock("thumbnail_js");
00774                 }
00775                 else
00776                 {
00777                         $tpl->setCurrentBlock("thumbnail");
00778                 }
00779                 $tpl->parseCurrentBlock();
00780         }
00781 
00782 
00786         function changeLinkType()
00787         {
00788                 $_SESSION["il_link_type"] = $_POST["ltype"];
00789                 $this->determineLinkType();
00790                 $this->showLinkHelp();
00791         }
00792 
00796         function setMedPoolFolder()
00797         {
00798                 $_SESSION["il_link_mep_obj"] = $_GET["mep_fold"];
00799                 $this->showLinkHelp();
00800         }
00801 
00805         function changeTargetObject($a_type = "")
00806         {
00807                 $_SESSION["il_link_mep_obj"] = "";
00808 
00809                 if($_GET["do"] == "set")
00810                 {
00811                         switch ($_GET["target_type"])
00812                         {
00813                                 case "glo":
00814                                         $_SESSION["il_link_glossary"] = $_GET["sel_id"];
00815                                         break;
00816 
00817                                 case "mep":
00818                                         $_SESSION["il_link_mep"] = $_GET["sel_id"];
00819                                         break;
00820 
00821                                 default:
00822                                         $_SESSION["il_link_cont_obj"] = $_GET["sel_id"];
00823                                         break;
00824                         }
00825                         $this->showLinkHelp();
00826                         return;
00827                 }
00828 
00829                 if(empty($a_type))
00830                 {
00831                         $a_type = $_GET["target_type"];
00832                 }
00833 
00834                 $tpl =& new ilTemplate("tpl.link_help_explorer.html", true, true, true);
00835                 $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00836 
00837                 require_once "classes/class.ilExplorer.php";
00838                 //$tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
00839 
00840 
00841 //echo "<br><br>:".$this->ctrl->getLinkTarget($this).":<br>";
00842                 $exp = new ilExplorer(ilUtil::appendUrlParameterString(
00843                         $this->ctrl->getTargetScript(), "do=set"));
00844                 if ($_GET["expand"] == "")
00845                 {
00846                         $expanded = $this->tree->readRootId();
00847                 }
00848                 else
00849                 {
00850                         $expanded = $_GET["expand"];
00851                 }
00852                 $exp->setExpand($expanded);
00853 //echo "<br><br>exp:$expanded:<br>";
00854 
00855                 $exp->setTargetGet("sel_id");
00856                 $this->ctrl->setParameter($this, "target_type", $a_type);
00857                 $exp->setParamsGet($this->ctrl->getParameterArray($this, "changeTargetObject"));
00858 //echo "<br>"; var_dump($this->ctrl->getParameterArray($this, "changeTargetObject"));
00859                 /*$exp->setParamsGet(array("ref_id" => $_GET["ref_id"],
00860                         "cmd" => "changeTargetObject", "mode" => "page_edit", "obj_id" => $_GET["obj_id"],
00861                         "target_type" => $a_type, "linkmode" => $_GET["linkmode"]));*/
00862 
00863                 $exp->addFilter("root");
00864                 $exp->addFilter("cat");
00865                 $exp->addFilter("grp");
00866                 $exp->addFilter("fold");
00867                 $exp->addFilter("crs");
00868 
00869                 switch ($a_type)
00870                 {
00871                         case "glo":
00872                                 $exp->addFilter("glo");
00873                                 break;
00874 
00875                         case "mep":
00876                                 $exp->addFilter("mep");
00877                                 break;
00878 
00879                         default:
00880                                 $exp->addFilter("lm");
00881                                 $exp->addFilter("dbk");
00882                                 break;
00883                 }
00884                 $exp->setFiltered(true);
00885                 $exp->setFilterMode(IL_FM_POSITIVE);
00886 
00887                 $exp->setClickable("cat", false);
00888                 $exp->setClickable("grp", false);
00889                 $exp->setClickable("fold", false);
00890                 $exp->setClickable("crs", false);
00891 
00892                 $exp->setFrameTarget("");
00893                 $exp->setOutput(0);
00894 
00895                 $output = $exp->getOutput();
00896 //echo "<br><br><br>out:".$output.":<br>";
00897 
00898                 $tpl->setCurrentBlock("content");
00899                 if ($a_type == "glo")
00900                 {
00901                         $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_glossary"));
00902                 }
00903                 else if ($a_type == "mep")
00904                 {
00905                         $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_media_source"));
00906                 }
00907                 else
00908                 {
00909                         $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_choose_cont_obj"));
00910                 }
00911                 $tpl->setVariable("EXPLORER",$output);
00912                 $tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
00913                 $tpl->setVariable("BTN_REFRESH", "changeTargetObject");
00914                 $tpl->setVariable("TXT_REFRESH", $this->lng->txt("refresh"));
00915                 $tpl->setVariable("BTN_RESET", "resetLinkList");
00916                 $tpl->setVariable("TXT_RESET", $this->lng->txt("reset"));
00917 
00918                 if ($a_type == "mep")
00919                 {
00920                         $tpl->setCurrentBlock("sel_clipboard");
00921                         $this->ctrl->setParameter($this, "do", "set");
00922                         //$this->ctrl->setParameter($this, "sel_id", 0);
00923                         //$this->ctrl->setParameter($this, "target_type", "mep");
00924                         //$this->ctrl->setParameter($this, "linkmode", "");
00925                         //$this->ctrl->setParameter($this, "obj_id", "");
00926                         $tpl->setVariable("LINK_CLIPBOARD", $this->ctrl->getLinkTarget($this, "changeTargetObject"));
00927                         $tpl->setVariable("TXT_PERS_CLIPBOARD", $this->lng->txt("clipboard"));
00928                         $tpl->parseCurrentBlock();
00929                 }
00930 
00931                 /*
00932                 $tpl->setVariable("BTN_STRUCTURE", "resetLinkList");
00933                 $tpl->setVariable("TXT_STRUCTURE", $this->lng->txt("reset"));*/
00934                 $tpl->parseCurrentBlock();
00935 
00936                 $tpl->show();
00937                 exit;
00938         }
00939         
00943         function selectRepositoryItem()
00944         {
00945                 $_SESSION["il_link_mep_obj"] = "";
00946 
00947                 if(empty($a_type))
00948                 {
00949                         $a_type = $_GET["target_type"];
00950                 }
00951 
00952                 $tpl =& new ilTemplate("tpl.link_help_explorer.html", true, true, true);
00953                 $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00954 
00955                 include_once "content/classes/class.ilIntLinkRepItemExplorer.php";
00956                 $exp = new ilIntLinkRepItemExplorer(ilUtil::appendUrlParameterString(
00957                         $this->ctrl->getTargetScript(), "do=set"));
00958                 if ($_GET["expand"] == "")
00959                 {
00960                         $expanded = $this->tree->readRootId();
00961                 }
00962                 else
00963                 {
00964                         $expanded = $_GET["expand"];
00965                 }
00966                 $exp->setMode($this->mode);
00967                 $exp->setSetLinkTargetScript($this->getSetLinkTargetScript());
00968                 $exp->setExpand($expanded);
00969 
00970                 $exp->setTargetGet("sel_id");
00971                 $this->ctrl->setParameter($this, "target_type", $a_type);
00972                 $exp->setParamsGet($this->ctrl->getParameterArray($this, "showLinkHelp"));
00973                 
00974                 // filter
00975                 $exp->setFiltered(true);
00976                 $exp->setFilterMode(IL_FM_POSITIVE);
00977                 $exp->addFilter("root");
00978                 $exp->addFilter("cat");
00979                 $exp->addFilter("grp");
00980                 $exp->addFilter("fold");
00981                 $exp->addFilter("crs");
00982                 $exp->addFilter("lm");
00983                 $exp->addFilter("htlm");
00984                 $exp->addFilter("dbk");
00985                 $exp->addFilter("glo");
00986                 $exp->addFilter("frm");
00987                 $exp->addFilter("exc");
00988                 $exp->addFilter("tst");
00989                 $exp->addFilter("svy");
00990                 $exp->addFilter("webr");
00991                 $exp->addFilter("file");
00992                 $exp->addFilter("chat");
00993 
00994                 $sel_types = array('lm','dbk','htlm','glo','frm','exc','tst','svy','webr','chat',
00995                         'cat','crs','grp','file');
00996                 $exp->setSelectableTypes($sel_types);
00997 
00998                 /*
00999                 $exp->setClickable("cat", false);
01000                 $exp->setClickable("grp", false);
01001                 $exp->setClickable("fold", false);
01002                 $exp->setClickable("crs", false);*/
01003 
01004                 $exp->setFrameTarget("");
01005                 $exp->setOutput(0);
01006 
01007                 $output = $exp->getOutput();
01008 //echo "<br><br><br>out:".$output.":<br>";
01009 
01010                 $tpl->setCurrentBlock("content");
01011                 $tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_repository_item_links"));
01012                 $tpl->setVariable("EXPLORER",$output);
01013                 $tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
01014                 $tpl->setVariable("BTN_REFRESH", "showLinkHelp");
01015                 $tpl->setVariable("TXT_REFRESH", $this->lng->txt("refresh"));
01016                 $tpl->setVariable("BTN_RESET", "resetLinkList");
01017                 $tpl->setVariable("TXT_RESET", $this->lng->txt("reset"));
01018 
01019                 /*
01020                 $tpl->setVariable("BTN_STRUCTURE", "resetLinkList");
01021                 $tpl->setVariable("TXT_STRUCTURE", $this->lng->txt("reset"));*/
01022                 $tpl->parseCurrentBlock();
01023 
01024                 return $tpl->get();
01025                 //$tpl->show();
01026                 //exit;
01027         }
01028 
01029 
01030 
01034         function isEnabledJavaScript()
01035         {
01036                 global $ilias;
01037                 
01038                 include_once("content/classes/Pages/class.ilPageEditorGUI.php");
01039                 if($ilias->getSetting("enable_js_edit"))
01040                 {
01041                         if (ilPageEditorGUI::_doJSEditing())
01042                         {
01043                                 return true;
01044                         }
01045                 }
01046                 return false;
01047         }
01048 
01049 
01050 }
01051 ?>

Generated on Fri Dec 13 2013 11:57:56 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1