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

content/classes/class.ilObjContentObjectGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2005 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 
00037 include_once "classes/class.ilObjectGUI.php";
00038 include_once "content/classes/class.ilObjContentObject.php";
00039 include_once ("content/classes/class.ilLMPageObjectGUI.php");
00040 include_once ("content/classes/class.ilStructureObjectGUI.php");
00041 
00042 class ilObjContentObjectGUI extends ilObjectGUI
00043 {
00044         var $ctrl;
00045 
00051         function ilObjContentObjectGUI($a_data,$a_id = 0,$a_call_by_reference = true, $a_prepare_output = true)
00052         {
00053                 global $lng, $ilCtrl;
00054 
00055                 $this->ctrl =& $ilCtrl;
00056                 $lng->loadLanguageModule("content");
00057                 parent::ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
00058                 $this->actions = $this->objDefinition->getActions("lm");
00059 
00060         }
00061 
00065         function &executeCommand()
00066         {
00067                 if ($this->ctrl->getRedirectSource() == "ilinternallinkgui")
00068                 {
00069                         $this->explorer();
00070                         return;
00071                 }
00072 
00073                 if ($this->ctrl->getCmdClass() == "ilinternallinkgui")
00074                 {
00075                         $this->ctrl->setReturn($this, "explorer");
00076                 }
00077 
00078                 // get next class that processes or forwards current command
00079                 $next_class = $this->ctrl->getNextClass($this);
00080 
00081                 // get current command
00082                 $cmd = $this->ctrl->getCmd();
00083 
00084                 $this->addLocations();
00085                 switch($next_class)
00086                 {
00087                         case 'ilmdeditorgui':
00088 
00089                                 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00090                                 $this->setTabs();
00091                                 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00092                                 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00093 
00094                                 $this->ctrl->forwardCommand($md_gui);
00095                                 break;
00096 
00097                         case "ilobjstylesheetgui":
00098                                 include_once ("classes/class.ilObjStyleSheetGUI.php");
00099                                 $this->ctrl->setReturn($this, "properties");
00100                                 $style_gui =& new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
00101                                 $ret =& $this->ctrl->forwardCommand($style_gui);
00102                                 //$ret =& $style_gui->executeCommand();
00103 
00104                                 if ($cmd == "save")
00105                                 {
00106                                         $style_id = $ret;
00107                                         $this->object->setStyleSheetId($style_id);
00108                                         $this->object->update();
00109                                         $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
00110                                 }
00111                                 break;
00112 
00113                         case "illmpageobjectgui":
00114                                 $this->ctrl->setReturn($this, "properties");
00115 //echo "!";
00116                                 //$this->lm_obj =& $this->ilias->obj_factory->getInstanceByRefId($this->ref_id);
00117 
00118                                 $pg_gui =& new ilLMPageObjectGUI($this->object);
00119                                 if ($_GET["obj_id"] != "")
00120                                 {
00121                                         $obj =& ilLMObjectFactory::getInstance($this->object, $_GET["obj_id"]);
00122                                         $pg_gui->setLMPageObject($obj);
00123                                 }
00124                                 //$ret =& $pg_gui->executeCommand();
00125                                 $ret =& $this->ctrl->forwardCommand($pg_gui);
00126                                 if ($cmd == "save" || $cmd == "cancel")
00127                                 {
00128                                         $this->ctrl->redirect($this, "pages");
00129                                 }
00130                                 break;
00131 
00132                         case "ilstructureobjectgui":
00133                                 $this->ctrl->setReturn($this, "properties");
00134                                 $st_gui =& new ilStructureObjectGUI($this->object, $this->object->lm_tree);
00135                                 if ($_GET["obj_id"] != "")
00136                                 {
00137                                         $obj =& ilLMObjectFactory::getInstance($this->object, $_GET["obj_id"]);
00138                                         $st_gui->setStructureObject($obj);
00139                                 }
00140                                 //$ret =& $st_gui->executeCommand();
00141                                 $ret =& $this->ctrl->forwardCommand($st_gui);
00142                                 if ($cmd == "save" || $cmd == "cancel")
00143                                 {
00144                                         if ($_GET["obj_id"] == "")
00145                                         {
00146                                                 $this->ctrl->redirect($this, "chapters");
00147                                         }
00148                                         else
00149                                         {
00150                                                 $this->ctrl->setCmd("subchap");
00151                                                 $this->executeCommand();
00152                                         }
00153                                 }
00154                                 break;
00155 
00156                         default:
00157                                 if ($cmd == "create")
00158                                 {
00159                                         switch ($_POST["new_type"])
00160                                         {
00161                                                 case "pg":
00162                                                         $this->setTabs();
00163                                                         $this->ctrl->setCmdClass("ilLMPageObjectGUI");
00164                                                         $ret =& $this->executeCommand();
00165                                                         break;
00166 
00167                                                 case "st":
00168                                                         $this->setTabs();
00169                                                         $this->ctrl->setCmdClass("ilStructureObjectGUI");
00170                                                         $ret =& $this->executeCommand();
00171                                                         break;
00172                                         }
00173                                 }
00174                                 else
00175                                 {
00176                                         $ret =& $this->$cmd();
00177 
00178                                 }
00179                                 break;
00180                 }
00181                 return $ret;
00182         }
00183 
00184         function _forwards()
00185         {
00186                 return array("ilLMPageObjectGUI", "ilStructureObjectGUI","ilObjStyleSheetGUI");
00187         }
00188 
00192         function properties()
00193         {
00194                 $this->setTabs();
00195 
00196                 //add template for view button
00197                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00198 
00199                 // view button
00200                 $this->tpl->setCurrentBlock("btn_cell");
00201                 $this->tpl->setVariable("BTN_LINK",ILIAS_HTTP_PATH."/content/"."lm_presentation.php?ref_id=".$this->object->getRefID());
00202                 $this->tpl->setVariable("BTN_TARGET"," target=\"ilContObj".$this->object->getID()."\" ");
00203                 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
00204                 $this->tpl->parseCurrentBlock();
00205 
00206                 $this->tpl->setCurrentBlock("btn_cell");
00207                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "fixTreeConfirm"));
00208                 //$this->tpl->setVariable("BTN_TARGET"," target=\"_top\" ");
00209                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_fix_tree"));
00210                 $this->tpl->parseCurrentBlock();
00211 
00212                 //$this->tpl->touchBlock("btn_row");
00213 
00214                 // edit public section
00215                 if ($this->ilias->getSetting("pub_section"))
00216                 {
00217                         if ($this->object->getType() != "dbk")
00218                         {
00219                                 $this->tpl->setCurrentBlock("btn_cell");
00220                                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "editPublicSection"));
00221                                 //$this->tpl->setVariable("BTN_TARGET"," target=\"_top\" ");
00222                                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("public_section"));
00223                                 $this->tpl->parseCurrentBlock();
00224                         }
00225                 }
00226 
00227                 // lm properties
00228                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_properties.html", true);
00229                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00230                 $this->tpl->setVariable("TXT_PROPERTIES", $this->lng->txt("cont_lm_properties"));
00231 
00232                 // online
00233                 $this->tpl->setVariable("TXT_ONLINE", $this->lng->txt("cont_online"));
00234                 $this->tpl->setVariable("CBOX_ONLINE", "cobj_online");
00235                 $this->tpl->setVariable("VAL_ONLINE", "y");
00236                 if ($this->object->getOnline())
00237                 {
00238                         $this->tpl->setVariable("CHK_ONLINE", "checked");
00239                 }
00240 
00241                 // layout
00242                 $this->tpl->setVariable("TXT_LAYOUT", $this->lng->txt("cont_def_layout"));
00243                 $layouts = ilObjContentObject::getAvailableLayouts();
00244                 $select_layout = ilUtil::formSelect ($this->object->getLayout(), "lm_layout",
00245                         $layouts, false, true);
00246                 $this->tpl->setVariable("SELECT_LAYOUT", $select_layout);
00247 
00248                 // style
00249                 $this->tpl->setVariable("TXT_STYLE", $this->lng->txt("cont_style"));
00250                 $fixed_style = $this->ilias->getSetting("fixed_content_style_id");
00251                 if ($fixed_style > 0)
00252                 {
00253                         $this->tpl->setVariable("VAL_STYLE",
00254                                 ilObject::_lookupTitle($fixed_style)." (".
00255                                 $this->lng->txt("global_fixed").")");
00256                 }
00257                 else
00258                 {
00259                         $this->tpl->setCurrentBlock("style_edit");
00260                         if ($this->object->getStyleSheetId() > 0)
00261                         {
00262                                 $this->tpl->setVariable("VAL_STYLE",
00263                                         ilObject::_lookupTitle($this->object->getStyleSheetId()));
00264 
00265                                 // edit icon
00266                                 $this->tpl->setVariable("LINK_STYLE_EDIT",
00267                                         $this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
00268                                 $this->tpl->setVariable("TXT_STYLE_EDIT",
00269                                         $this->lng->txt("edit"));
00270                                 $this->tpl->setVariable("IMG_STYLE_EDIT",
00271                                         ilUtil::getImagePath("icon_pencil.gif"));
00272 
00273                                 // delete icon
00274                                 $this->tpl->setVariable("LINK_STYLE_DROP",
00275                                         $this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
00276                                 $this->tpl->setVariable("TXT_STYLE_DROP",
00277                                         $this->lng->txt("delete"));
00278                                 $this->tpl->setVariable("IMG_STYLE_DROP",
00279                                         ilUtil::getImagePath("delete.gif"));
00280                         }
00281                         else
00282                         {
00283                                 $this->tpl->setVariable("VAL_STYLE",
00284                                         $this->lng->txt("default"));
00285                                 $this->tpl->setVariable("LINK_STYLE_CREATE",
00286                                         $this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
00287                                 $this->tpl->setVariable("TXT_STYLE_CREATE",
00288                                         $this->lng->txt("create"));
00289                         }
00290                         $this->tpl->parseCurrentBlock();
00291                 }
00292 
00293                 // page header
00294                 $this->tpl->setVariable("TXT_PAGE_HEADER", $this->lng->txt("cont_page_header"));
00295                 $pg_header = array ("st_title" => $this->lng->txt("cont_st_title"),
00296                         "pg_title" => $this->lng->txt("cont_pg_title"),
00297                         "none" => $this->lng->txt("cont_none"));
00298                 $select_pg_head = ilUtil::formSelect ($this->object->getPageHeader(), "lm_pg_header",
00299                         $pg_header, false, true);
00300                 $this->tpl->setVariable("SELECT_PAGE_HEADER", $select_pg_head);
00301 
00302                 // chapter numbers
00303                 $this->tpl->setVariable("TXT_NUMBER", $this->lng->txt("cont_act_number"));
00304                 $this->tpl->setVariable("CBOX_NUMBER", "cobj_act_number");
00305                 $this->tpl->setVariable("VAL_NUMBER", "y");
00306                 if ($this->object->isActiveNumbering())
00307                 {
00308                         $this->tpl->setVariable("CHK_NUMBER", "checked");
00309                 }
00310 
00311                 // toc mode
00312                 $this->tpl->setVariable("TXT_TOC_MODE", $this->lng->txt("cont_toc_mode"));
00313                 $arr_toc_mode = array ("chapters" => $this->lng->txt("cont_chapters_only"),
00314                         "pages" => $this->lng->txt("cont_chapters_and_pages"));
00315                 $select_toc_mode = ilUtil::formSelect ($this->object->getTOCMode(), "toc_mode",
00316                         $arr_toc_mode, false, true);
00317                 $this->tpl->setVariable("SELECT_TOC_MODE", $select_toc_mode);
00318 
00319                 // clean frames
00320                 $this->tpl->setVariable("TXT_CLEAN_FRAMES", $this->lng->txt("cont_clean_frames"));
00321                 $this->tpl->setVariable("TXT_CLEAN_FRAMES_DESC", $this->lng->txt("cont_clean_frames_desc"));
00322                 $this->tpl->setVariable("CBOX_CLEAN_FRAMES", "cobj_clean_frames");
00323                 $this->tpl->setVariable("VAL_CLEAN_FRAMES", "y");
00324                 if ($this->object->cleanFrames())
00325                 {
00326                         $this->tpl->setVariable("CHK_CLEAN_FRAMES", "checked");
00327                 }
00328                 
00329                 // history user comments
00330                 $this->tpl->setVariable("TXT_HIST_USER_COMMENTS", $this->lng->txt("enable_hist_user_comments"));
00331                 $this->tpl->setVariable("TXT_HIST_USER_COMMENTS_DESC", $this->lng->txt("enable_hist_user_comments_desc"));
00332                 $this->tpl->setVariable("CBOX_HIST_USER_COMMENTS", "cobj_user_comments");
00333                 $this->tpl->setVariable("VAL_HIST_USER_COMMENTS", "y");
00334                 if ($this->object->isActiveHistoryUserComments())
00335                 {
00336                         $this->tpl->setVariable("CHK_HIST_USER_COMMENTS", "checked");
00337                 }
00338 
00339                 // lm menu
00340                 $this->tpl->setVariable("TXT_LM_MENU", $this->lng->txt("cont_lm_menu"));
00341                 $this->tpl->setVariable("TXT_ACT_MENU", $this->lng->txt("cont_active"));
00342                 $this->tpl->setVariable("CBOX_LM_MENU", "cobj_act_lm_menu");
00343                 $this->tpl->setVariable("VAL_LM_MENU", "y");
00344                 if ($this->object->isActiveLMMenu())
00345                 {
00346                         $this->tpl->setVariable("CHK_LM_MENU", "checked");
00347                 }
00348 
00349                 // toc
00350                 $this->tpl->setVariable("TXT_TOC", $this->lng->txt("cont_toc"));
00351                 $this->tpl->setVariable("CBOX_TOC", "cobj_act_toc");
00352                 $this->tpl->setVariable("VAL_TOC", "y");
00353                 if ($this->object->isActiveTOC())
00354                 {
00355                         $this->tpl->setVariable("CHK_TOC", "checked");
00356                 }
00357 
00358                 // print view
00359                 $this->tpl->setVariable("TXT_PRINT", $this->lng->txt("cont_print_view"));
00360                 $this->tpl->setVariable("CBOX_PRINT", "cobj_act_print");
00361                 $this->tpl->setVariable("VAL_PRINT", "y");
00362                 if ($this->object->isActivePrintView())
00363                 {
00364                         $this->tpl->setVariable("CHK_PRINT", "checked");
00365                 }
00366                 
00367                 // downloads
00368                 $this->tpl->setVariable("TXT_DOWNLOADS", $this->lng->txt("cont_downloads"));
00369                 $this->tpl->setVariable("TXT_DOWNLOADS_DESC", $this->lng->txt("cont_downloads_desc"));
00370                 $this->tpl->setVariable("CBOX_DOWNLOADS", "cobj_act_downloads");
00371                 $this->tpl->setVariable("VAL_DOWNLOADS", "y");
00372                 if ($this->object->isActiveDownloads())
00373                 {
00374                         $this->tpl->setVariable("CHK_DOWNLOADS", "checked");
00375                 }
00376                 
00377                 // get user defined menu entries
00378                 $this->__initLMMenuEditor();
00379                 $entries = $this->lmme_obj->getMenuEntries();
00380                 
00381                 if (count($entries) > 0)
00382                 {
00383                         foreach ($entries as $entry)
00384                         {
00385                                 $this->ctrl->setParameter($this, "menu_entry", $entry["id"]);
00386 
00387                                 $this->tpl->setCurrentBlock("menu_entries");
00388                                 
00389                                 if ($entry["type"] == "intern")
00390                                 {
00391                                         $entry["link"] = ILIAS_HTTP_PATH."/goto.php?target=".$entry["link"];
00392                                 }
00393 
00394                                 // add http:// prefix if not exist
00395                                 if (!strstr($entry["link"],'http://'))
00396                                 {
00397                                         $entry["link"] = "http://".$entry["link"];
00398                                 }
00399                                 
00400                                 $this->tpl->setVariable("ENTRY_LINK", $entry["link"]);
00401                                 $this->tpl->setVariable("ENTRY_TITLE", $entry["title"]);
00402 
00403                                 $this->tpl->setVariable("CBOX_ENTRY", "menu_entries[]");
00404                                 $this->tpl->setVariable("VAL_ENTRY", $entry["id"]);
00405 
00406                                 if (ilUtil::yn2tf($entry["active"]))
00407                                 {
00408                                         $this->tpl->setVariable("CHK_ENTRY", "checked=\"checked\"");
00409                                 }
00410 
00411 
00412                                 $this->tpl->setVariable("LINK_EDIT", $this->ctrl->getLinkTarget($this,"editMenuEntry"));
00413                                 $this->tpl->setVariable("TARGET_EDIT", "content");
00414                                 $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00415                                 $this->tpl->setVariable("IMG_EDIT", ilUtil::getImagePath("icon_pencil.gif"));
00416 
00417                                 $this->tpl->setVariable("LINK_DROP", $this->ctrl->getLinkTarget($this,"deleteMenuEntry"));
00418                                 $this->tpl->setVariable("TARGET_DROP", "content");
00419                                 $this->tpl->setVariable("TXT_DROP", $this->lng->txt("drop"));
00420                                 $this->tpl->setVariable("IMG_DROP", ilUtil::getImagePath("delete.gif"));
00421 
00422                                 $this->tpl->parseCurrentBlock();
00423                         }
00424                 }
00425                 
00426                 // add entry link
00427 
00428 
00429                 $this->tpl->setCurrentBlock("commands");
00430                 $this->tpl->setVariable("BTN_NAME", "saveProperties");
00431                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00432                 $this->tpl->setVariable("BTN_NAME2", "addMenuEntry");
00433                 $this->tpl->setVariable("BTN_TEXT2", $this->lng->txt("add_menu_entry"));
00434                 $this->tpl->parseCurrentBlock();
00435         }
00436 
00440         function explorer()
00441         {
00442                 global $ilUser, $ilias;
00443                 
00444                 switch ($this->object->getType())
00445                 {
00446                         case "lm":
00447                                 $gui_class = "ilobjlearningmodulegui";
00448                                 break;
00449 
00450                         case "dlb":
00451                                 $gui_class = "ilobjdlbookgui";
00452                                 break;
00453                 }
00454 
00455 
00456 
00457                 $this->tpl = new ilTemplate("tpl.main.html", true, true);
00458                 // get learning module object
00459                 //$this->lm_obj =& new ilObjLearningModule($this->ref_id, true);
00460 
00461                 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00462 
00463                 //$this->tpl = new ilTemplate("tpl.explorer.html", false, false);
00464                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
00465 
00466                 require_once ("content/classes/class.ilLMEditorExplorer.php");
00467                 $exp = new ilLMEditorExplorer($this->ctrl->getLinkTarget($this, "view"),
00468                         $this->object, $gui_class);
00469 
00470                 $exp->setTargetGet("obj_id");
00471                 $exp->setExpandTarget($this->ctrl->getLinkTarget($this, "explorer"));
00472 
00473                 if ($_GET["lmmovecopy"] == "1")
00474                 {
00475                         $this->proceedDragDrop();
00476                 }
00477         
00478 
00479                 if ($_GET["lmexpand"] == "")
00480                 {
00481                         $mtree = new ilTree($this->object->getId());
00482                         $mtree->setTableNames('lm_tree','lm_data');
00483                         $mtree->setTreeTablePK("lm_id");
00484                         $expanded = $mtree->readRootId();
00485                 }
00486                 else
00487                 {
00488                         $expanded = $_GET["lmexpand"];
00489                 }
00490 
00491                 $exp->setExpand($expanded);
00492 
00493                 // build html-output
00494                 $exp->setOutput(0);
00495                 $output = $exp->getOutput();
00496 
00497                 include_once("content/classes/Pages/class.ilPageEditorGUI.php");
00498                 if (ilPageEditorGUI::_doJSEditing()) 
00499                 {
00500                         //$this->tpl->touchBlock("includejavascript");
00501                         
00502                         $IDS = "";
00503                         for ($i=0;$i<count($exp->iconList);$i++) 
00504                         {
00505                                 if ($i>0) $IDS .= ",";
00506                                 $IDS .= "'".$exp->iconList[$i]."'";
00507                         }
00508                         $this->tpl->setVariable("ICONIDS",$IDS);
00509                         //$this->ctrl->setParameter($this, "lmovecopy", 1);
00510                         $this->tpl->setVariable("TESTPFAD",$this->ctrl->getLinkTarget($this, "explorer")."&lmmovecopy=1");
00511                         //$this->tpl->setVariable("POPUPLINK",$this->ctrl->getLinkTarget($this, "popup")."&ptype=movecopytreenode");
00512                         $this->tpl->setVariable("POPUPLINK",$this->ctrl->getLinkTarget($this, "popup")."&ptype=movecopytreenode");
00513                 }
00514                 
00515                 
00516                 $this->tpl->setCurrentBlock("content");
00517                 $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_chap_and_pages"));
00518                 $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
00519                 $this->tpl->setVariable("EXPLORER",$output);
00520                 $this->ctrl->setParameter($this, "lmexpand", $_GET["lmexpand"]);
00521                 //$this->tpl->setVariable("ACTION", "lm_edit.php?cmd=explorer&ref_id=".$this->ref_id."&lmexpand=".$_GET["lmexpand"]);
00522                 $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this, "explorer"));
00523                 $this->tpl->parseCurrentBlock();
00524                 //$this->tpl->show(false);
00525 
00526         }
00527         
00531         function popup()
00532         {
00533                 include_once "./content/classes/Pages/class.ilWysiwygUtil.php";
00534                 $popup = new ilWysiwygUtil();
00535                 $popup->show($_GET["ptype"]);
00536                 exit;
00537         }
00538 
00542         function proceedDragDrop()
00543         {
00544                 $lmtree = new ilTree($this->object->getId());
00545                 $lmtree->setTableNames('lm_tree','lm_data');
00546                 $lmtree->setTreeTablePK("lm_id");
00547 
00548 
00549                 // node-id of dragged object
00550                 $source_id = $_GET["dragdropSource"];
00551 
00552                 // node-id of object under dragged obj at drop
00553                 $target_id = $_GET["dragdropTarget"];
00554 
00555                 // "move" | "copy"
00556                 $movecopy = $_GET["dragdropCopymove"];
00557 
00558                 // "after" | "before" : copy or move the source-object before or after the selected target-object.
00559                 $position = $_GET["dragdropPosition"];
00560 
00561                 //echo "sourceId: $sourceId<br>";
00562                 //echo "targetId: $targetId<br>";
00563                 //echo "move or copy: $movecopy<br>";
00564                 //echo "position: $position<br>";
00565 
00566                 $source_obj = ilLMObjectFactory::getInstance($this->object, $source_id, true);
00567                 $source_obj->setLMId($this->object->getId());
00568                 $target_obj = ilLMObjectFactory::getInstance($this->object, $target_id, true);
00569                 $target_obj->setLMId($this->object->getId());
00570                 $target_parent = $lmtree->getParentId($target_id);
00571 
00572 
00573                 // handle pages
00574                 if ($source_obj->getType() == "pg")
00575                 {
00576                         if ($lmtree->isInTree($source_obj->getId()))
00577                         {
00578                                 $node_data = $lmtree->getNodeData($source_obj->getId());
00579 
00580                                 // cut on move
00581                                 if ($movecopy == "move")
00582                                 {
00583                                         $parent_id = $lmtree->getParentId($source_obj->getId());
00584                                         $lmtree->deleteTree($node_data);
00585 
00586                                         // write history entry
00587                                         require_once("classes/class.ilHistory.php");
00588                                         ilHistory::_createEntry($source_obj->getId(), "cut",
00589                                                 array(ilLMObject::_lookupTitle($parent_id), $parent_id),
00590                                                 $this->object->getType().":pg");
00591                                         ilHistory::_createEntry($parent_id, "cut_page",
00592                                                 array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()),
00593                                                 $this->object->getType().":st");
00594                                 }
00595                                 else
00596                                 {
00597                                         // copy page
00598                                         $new_page =& $source_obj->copy();
00599                                         $source_id = $new_page->getId();
00600                                         $source_obj =& $new_page;
00601                                 }
00602 
00603                                 // paste page
00604                                 if(!$lmtree->isInTree($source_obj->getId()))
00605                                 {
00606                                         // move page after/before other page
00607                                         if ($target_obj->getType() == "pg")
00608                                         {
00609                                                 $target_pos = $target_id;
00610                                                 if ($position == "before")
00611                                                 {
00612                                                         $target_pos = IL_FIRST_NODE;
00613                                                         if ($pred = $lmtree->fetchPredecessorNode($target_id))
00614                                                         {
00615                                                                 if ($lmtree->getParentId($pred["child"]) == $target_parent)
00616                                                                 {
00617                                                                         $target_pos = $pred["child"];
00618                                                                 }
00619                                                         }
00620                                                 }
00621                                                 $parent = $target_parent;
00622                                         }
00623                                         else // move page into chapter
00624                                         {
00625                                                 $target_pos = IL_FIRST_NODE;
00626                                                 $parent = $target_id;
00627                                         }
00628 
00629                                         // insert page into tree
00630                                         $lmtree->insertNode($source_obj->getId(),
00631                                                 $parent, $target_pos);
00632 
00633                                         // write hisroty entry
00634                                         if ($movecopy == "move")
00635                                         {
00636                                                 // write history comments
00637                                                 include_once("classes/class.ilHistory.php");
00638                                                 ilHistory::_createEntry($source_obj->getId(), "paste",
00639                                                         array(ilLMObject::_lookupTitle($parent), $parent),
00640                                                         $this->object->getType().":pg");
00641                                                 ilHistory::_createEntry($parent, "paste_page",
00642                                                         array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()),
00643                                                         $this->object->getType().":st");
00644                                         }
00645 
00646                                 }
00647                         }
00648                 }
00649 
00650                 // handle chapters
00651                 if ($source_obj->getType() == "st")
00652                 {
00653                         // check wether target is a chapter
00654                         if ($target_obj->getType() != "st")
00655                         {
00656                                 return;
00657                         }
00658                         $source_node = $lmtree->getNodeData($source_id);
00659                         $subnodes = $lmtree->getSubtree($source_node);
00660 
00661                         // check, if target is within subtree
00662                         foreach ($subnodes as $subnode)
00663                         {
00664                                 if($subnode["obj_id"] == $target_id)
00665                                 {
00666                                         return;
00667                                 }
00668                         }
00669 
00670                         $target_pos = $target_id;
00671 
00672                         // insert before
00673                         if ($position == "before")
00674                         {
00675                                 $target_pos = IL_FIRST_NODE;
00676 
00677                                 // look for predecessor chapter on same level
00678                                 $childs = $lmtree->getChildsByType($target_parent, "st");
00679                                 $found = false;
00680                                 foreach ($childs as $child)
00681                                 {
00682                                         if ($child["obj_id"] == $target_id)
00683                                         {
00684                                                 $found = true;
00685                                         }
00686                                         if (!$found)
00687                                         {
00688                                                 $target_pos = $child["obj_id"];
00689                                         }
00690                                 }
00691 
00692                                 // if target_pos is still first node we must skip all pages
00693                                 if ($target_pos == IL_FIRST_NODE)
00694                                 {
00695                                         $pg_childs =& $lmtree->getChildsByType($target_parent, "pg");
00696                                         if (count($pg_childs) != 0)
00697                                         {
00698                                                 $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
00699                                         }
00700                                 }
00701                         }
00702 
00703                         // insert into
00704                         if ($position == "into")
00705                         {
00706                                 $target_parent = $target_id;
00707                                 $target_pos = IL_FIRST_NODE;
00708 
00709                                 // if target_pos is still first node we must skip all pages
00710                                 if ($target_pos == IL_FIRST_NODE)
00711                                 {
00712                                         $pg_childs =& $lmtree->getChildsByType($target_parent, "pg");
00713                                         if (count($pg_childs) != 0)
00714                                         {
00715                                                 $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
00716                                         }
00717                                 }
00718                         }
00719 
00720 
00721                         // delete source tree
00722                         if ($movecopy == "move")
00723                         {
00724                                 $lmtree->deleteTree($source_node);
00725                         }
00726                         else
00727                         {
00728                                 // copy chapter (incl. subcontents)
00729                                 $new_chapter =& $source_obj->copy($lmtree, $target_parent, $target_pos);
00730                         }
00731 
00732                         if (!$lmtree->isInTree($source_id))
00733                         {
00734                                 $lmtree->insertNode($source_id, $target_parent, $target_pos);
00735 
00736                                 // insert moved tree
00737                                 if ($movecopy == "move")
00738                                 {
00739                                         foreach ($subnodes as $node)
00740                                         {
00741                                                 if($node["obj_id"] != $source_id)
00742                                                 {
00743                                                         $lmtree->insertNode($node["obj_id"], $node["parent"]);
00744                                                 }
00745                                         }
00746                                 }
00747                         }
00748 
00749                         // check the tree
00750                         $this->object->checkTree();
00751 
00752                 }
00753 
00754 
00755                 $this->object->checkTree();
00756         }
00757 
00758 
00759 
00763         function saveProperties()
00764         {
00765                 $this->object->setLayout($_POST["lm_layout"]);
00766                 $this->object->setPageHeader($_POST["lm_pg_header"]);
00767                 $this->object->setTOCMode($_POST["toc_mode"]);
00768                 $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
00769                 $this->object->setActiveLMMenu(ilUtil::yn2tf($_POST["cobj_act_lm_menu"]));
00770                 $this->object->setActiveNumbering(ilUtil::yn2tf($_POST["cobj_act_number"]));
00771                 $this->object->setActiveTOC(ilUtil::yn2tf($_POST["cobj_act_toc"]));
00772                 $this->object->setActivePrintView(ilUtil::yn2tf($_POST["cobj_act_print"]));
00773                 $this->object->setActiveDownloads(ilUtil::yn2tf($_POST["cobj_act_downloads"]));
00774                 $this->object->setCleanFrames(ilUtil::yn2tf($_POST["cobj_clean_frames"]));
00775                 $this->object->setHistoryUserComments(ilUtil::yn2tf($_POST["cobj_user_comments"]));
00776                 $this->object->updateProperties();
00777 
00778                 $this->__initLMMenuEditor();
00779                 $this->lmme_obj->updateActiveStatus($_POST["menu_entries"]);
00780 
00781                 sendInfo($this->lng->txt("msg_obj_modified"), true);
00782                 $this->ctrl->redirect($this, "properties");
00783         }
00784 
00788         function createObject()
00789         {
00790                 global $rbacsystem;
00791 
00792                 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
00793 
00794                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
00795                 {
00796                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00797                 }
00798                 else
00799                 {
00800                         // fill in saved values in case of error
00801                         $data = array();
00802                         $data["fields"] = array();
00803                         $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
00804                         $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
00805 
00806                         $this->getTemplateFile("create", $new_type);
00807 
00808                         foreach ($data["fields"] as $key => $val)
00809                         {
00810                                 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
00811                                 $this->tpl->setVariable(strtoupper($key), $val);
00812 
00813                                 if ($this->prepare_output)
00814                                 {
00815                                         $this->tpl->parseCurrentBlock();
00816                                 }
00817                         }
00818 
00819                         $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
00820                                 $_GET["ref_id"]."&new_type=".$new_type));
00821                         $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
00822                         $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00823                         $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
00824                         $this->tpl->setVariable("CMD_SUBMIT", "save");
00825                         $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
00826                         $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00827 
00828                         $this->tpl->setVariable("TXT_IMPORT_LM", $this->lng->txt("import_".$new_type));
00829                         $this->tpl->setVariable("TXT_LM_FILE", $this->lng->txt("file"));
00830                         $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
00831 
00832                         // get the value for the maximal uploadable filesize from the php.ini (if available)
00833                         $umf=get_cfg_var("upload_max_filesize");
00834                         // get the value for the maximal post data from the php.ini (if available)
00835                         $pms=get_cfg_var("post_max_size");
00836 
00837                         // use the smaller one as limit
00838                         $max_filesize=min($umf, $pms);
00839                         if (!$max_filesize) $max_filesize=max($umf, $pms);
00840                         
00841                         // gives out the limit as a littel notice :)
00842                         $this->tpl->setVariable("TXT_FILE_INFO", $this->lng->txt("file_notice")." $max_filesize.");
00843 
00844                 }
00845         }
00846 
00850         function saveObject()
00851         {
00852                 global $rbacadmin, $rbacsystem;
00853 
00854                 // always call parent method first to create an object_data entry & a reference
00855                 //$newObj = parent::saveObject();
00856                 // TODO: fix MetaDataGUI implementation to make it compatible to use parent call
00857                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $_GET["new_type"]))
00858                 {
00859                         $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
00860                 }
00861                 else
00862                 {
00863                         // check title
00864                         if ($_POST["Fobject"]["title"] == "")
00865                         {
00866                                 $this->ilias->raiseError($this->lng->txt("please_enter_title"), $this->ilias->error_obj->MESSAGE);
00867                                 return;
00868                         }
00869 
00870                         // create and insert object in objecttree
00871                         include_once("content/classes/class.ilObjContentObject.php");
00872                         $newObj = new ilObjContentObject();
00873                         $newObj->setType($this->type);
00874                         $newObj->setTitle($_POST["Fobject"]["title"]);#"content object ".$newObj->getId());             // set by meta_gui->save
00875                         $newObj->setDescription($_POST["Fobject"]["desc"]);     // set by meta_gui->save
00876                         $newObj->create();
00877                         $newObj->createReference();
00878                         $newObj->putInTree($_GET["ref_id"]);
00879                         $newObj->setPermissions($_GET["ref_id"]);
00880                         $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00881 
00882                         // setup rolefolder & default local roles (moderator)
00883                         //$roles = $newObj->initDefaultRoles();
00884                         // assign author role to creator of forum object
00885                         //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "n");
00886                         //ilObjUser::updateActiveRoles($newObj->getOwner());
00887                         // create content object tree
00888                         $newObj->createLMTree();
00889                         unset($newObj);
00890 
00891                         // always send a message
00892                         sendInfo($this->lng->txt($this->type."_added"), true);
00893                         ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
00894                 }
00895         }
00896 
00897         // called by administration
00898 /*
00899         function chooseMetaSectionObject($a_target = "")
00900         {
00901                 if ($a_target == "")
00902                 {
00903                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00904                 }
00905 
00906                 include_once "classes/class.ilMetaDataGUI.php";
00907                 $meta_gui =& new ilMetaDataGUI();
00908                 $meta_gui->setObject($this->object);
00909                 $meta_gui->edit("ADM_CONTENT", "adm_content",
00910                         $a_target, $_REQUEST["meta_section"]);
00911         }
00912 */
00913 
00914         // called by editor
00915 /*
00916         function chooseMetaSection()
00917         {
00918                 $this->setTabs();
00919 //echo "<br>target:".$this->ctrl->getLinkTarget($this).":";
00920                 $this->chooseMetaSectionObject($this->ctrl->getLinkTarget($this));
00921         }
00922 */
00923 
00924 /*
00925         function addMetaObject($a_target = "")
00926         {
00927                 if ($a_target == "")
00928                 {
00929                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00930                 }
00931 
00932                 include_once "classes/class.ilMetaDataGUI.php";
00933                 $meta_gui =& new ilMetaDataGUI();
00934                 $meta_gui->setObject($this->object);
00935                 $meta_name = $_POST["meta_name"] ? $_POST["meta_name"] : $_GET["meta_name"];
00936                 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
00937                 if ($meta_index == "")
00938                         $meta_index = 0;
00939                 $meta_path = $_POST["meta_path"] ? $_POST["meta_path"] : $_GET["meta_path"];
00940                 $meta_section = $_POST["meta_section"] ? $_POST["meta_section"] : $_GET["meta_section"];
00941                 if ($meta_name != "")
00942                 {
00943                         $meta_gui->meta_obj->add($meta_name, $meta_path, $meta_index);
00944                 }
00945                 else
00946                 {
00947                         sendInfo($this->lng->txt("meta_choose_element"), true);
00948                 }
00949                 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $meta_section);
00950         }
00951 */
00952 
00953 /*
00954         function addMeta()
00955         {
00956                 $this->setTabs();
00957                 $this->addMetaObject($this->ctrl->getLinkTarget($this));
00958         }
00959 */
00960 
00964         function addBibItemObject($a_target = "")
00965         {
00966                 include_once "content/classes/class.ilBibItemGUI.php";
00967                 $bib_gui =& new ilBibItemGUI();
00968                 $bib_gui->setObject($this->object);
00969                 $bibItemName = $_POST["bibItemName"] ? $_POST["bibItemName"] : $_GET["bibItemName"];
00970                 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
00971                 if ($bibItemIndex == "")
00972                         $bibItemIndex = 0;
00973                 $bibItemPath = $_POST["bibItemPath"] ? $_POST["bibItemPath"] : $_GET["bibItemPath"];
00974                 if ($bibItemName != "")
00975                 {
00976                         $bib_gui->bib_obj->add($bibItemName, $bibItemPath, $bibItemIndex);
00977                         $data = $bib_gui->bib_obj->getElement("BibItem");
00978                         $bibItemIndex = (count($data) - 1);
00979                 }
00980                 else
00981                 {
00982                         sendInfo($this->lng->txt("bibitem_choose_element"), true);
00983                 }
00984                 if ($a_target == "")
00985                 {
00986                         $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
00987                 }
00988 
00989                 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
00990         }
00991 
00995         function addBibItem()
00996         {
00997                 $this->setTabs();
00998                 $this->addBibItemObject($this->ctrl->getLinkTarget($this));
00999         }
01000 
01001 /*
01002         function deleteMetaObject($a_target = "")
01003         {
01004                 if ($a_target == "")
01005                 {
01006                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
01007                 }
01008 
01009                 include_once "classes/class.ilMetaDataGUI.php";
01010                 $meta_gui =& new ilMetaDataGUI();
01011                 $meta_gui->setObject($this->object);
01012                 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
01013                 $meta_gui->meta_obj->delete($_GET["meta_name"], $_GET["meta_path"], $meta_index);
01014                 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $_GET["meta_section"]);
01015         }
01016 */
01017 
01018 /*
01019         function deleteMeta()
01020         {
01021                 $this->setTabs();
01022                 $this->deleteMetaObject($this->ctrl->getLinkTarget($this));
01023         }
01024 */
01025 
01029         function deleteBibItemObject($a_target = "")
01030         {
01031                 include_once "content/classes/class.ilBibItemGUI.php";
01032                 $bib_gui =& new ilBibItemGUI();
01033                 $bib_gui->setObject($this->object);
01034                 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
01035                 $bib_gui->bib_obj->delete($_GET["bibItemName"], $_GET["bibItemPath"], $bibItemIndex);
01036                 if (strpos($bibItemIndex, ",") > 0)
01037                 {
01038                         $bibItemIndex = substr($bibItemIndex, 0, strpos($bibItemIndex, ","));
01039                 }
01040                 if ($a_target == "")
01041                 {
01042                         $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
01043                 }
01044 
01045                 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
01046         }
01047 
01051         function deleteBibItem()
01052         {
01053                 $this->setTabs();
01054                 $this->deleteBibItemObject($this->ctrl->getLinkTarget($this));
01055         }
01056 
01057 /*
01058         function editMetaObject($a_target = "")
01059         {
01060 
01061                 if ($a_target == "")
01062                 {
01063                         $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
01064                 }
01065 
01066                 include_once "classes/class.ilMetaDataGUI.php";
01067                 $meta_gui =& new ilMetaDataGUI();
01068                 $meta_gui->setObject($this->object);
01069 //echo "target:$a_target:";
01070                 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $_GET["meta_section"]);
01071         }
01072 
01073         function editMeta()
01074         {
01075                 $this->setTabs();
01076                 $this->editMetaObject($this->ctrl->getLinkTarget($this));
01077         }
01078 */
01079 
01083         function editBibItemObject($a_target = "")
01084         {
01085                 include_once "content/classes/class.ilBibItemGUI.php";
01086                 $bib_gui =& new ilBibItemGUI();
01087                 $bib_gui->setObject($this->object);
01088                 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
01089                 $bibItemIndex *= 1;
01090                 if ($bibItemIndex < 0)
01091                 {
01092                         $bibItemIndex = 0;
01093                 }
01094                 if ($a_target == "")
01095                 {
01096                         $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
01097                 }
01098 
01099                 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
01100         }
01101 
01105         function editBibItem()
01106         {
01107                 $this->setTabs();
01108                 $this->editBibItemObject($this->ctrl->getLinkTarget($this));
01109         }
01110 
01111 /*
01112         function saveMetaObject($a_target = "adm_object.php")
01113         {
01114                 include_once "classes/class.ilMetaDataGUI.php";
01115                 $meta_gui =& new ilMetaDataGUI();
01116                 $meta_gui->setObject($this->object);
01117 //echo "title_value:".htmlentities($_POST["meta"]["Title"]["Value"]); exit;
01118                 $meta_gui->save($_POST["meta_section"]);
01119                 ilUtil::redirect($a_target . "?cmd=editMeta&ref_id=" . $this->object->getRefId() . "&meta_section=" . $_POST["meta_section"]);
01120         }
01121 
01122         function saveMeta()
01123         {
01124 //              $this->saveMetaObject("lm_edit.php");
01125         }
01126 */
01127 
01131         function saveBibItemObject($a_target = "")
01132         {
01133                 include_once "content/classes/class.ilBibItemGUI.php";
01134                 $bib_gui =& new ilBibItemGUI();
01135                 $bib_gui->setObject($this->object);
01136                 $bibItemIndex = $_POST["bibItemIndex"] ? $_POST["bibItemIndex"] : $_GET["bibItemIndex"];
01137                 $bibItemIndex *= 1;
01138                 if ($bibItemIndex < 0)
01139                 {
01140                         $bibItemIndex = 0;
01141                 }
01142                 $bibItemIndex = $bib_gui->save($bibItemIndex);
01143 
01144                 if ($a_target == "")
01145                 {
01146                         $a_target = "adm_object.php?ref_id=" . $this->object->getRefId();
01147                 }
01148 
01149                 $bib_gui->edit("ADM_CONTENT", "adm_content", $a_target, $bibItemIndex);
01150         }
01151 
01155         function saveBibItem()
01156         {
01157                 $this->setTabs();
01158                 $this->saveBibItemObject($this->ctrl->getLinkTarget($this));
01159         }
01160 
01166         function exportObject()
01167         {
01168                 return;
01169         }
01170 
01176         function importObject()
01177         {
01178                 $this->createObject();
01179                 return;
01180         }
01181 
01182 
01189         function importFileObject()
01190         {
01191                 global $_FILES, $rbacsystem, $ilDB;
01192 
01193                 include_once "content/classes/class.ilObjLearningModule.php";
01194 
01195                 // check if file was uploaded
01196                 $source = $_FILES["xmldoc"]["tmp_name"];
01197                 if (($source == 'none') || (!$source))
01198                 {
01199                         $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
01200                 }
01201                 // check create permission
01202                 /*
01203                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $_GET["new_type"]))
01204                 {
01205                         $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
01206                 }*/
01207 
01208                 // check correct file type
01209                 $info = pathinfo($_FILES["xmldoc"]["name"]);
01210                 if (strtolower($info["extension"]) != "zip")
01211                 {
01212                         $this->ilias->raiseError("File must be a zip file!",$this->ilias->error_obj->MESSAGE);
01213                 }
01214 
01215                 // create and insert object in objecttree
01216                 include_once("content/classes/class.ilObjContentObject.php");
01217                 $newObj = new ilObjContentObject();
01218                 $newObj->setType($_GET["new_type"]);
01219                 $newObj->setTitle($_FILES["xmldoc"]["name"]);
01220                 $newObj->setDescription("");
01221                 $newObj->create(true);
01222                 $newObj->createReference();
01223                 $newObj->putInTree($_GET["ref_id"]);
01224                 $newObj->setPermissions($_GET["ref_id"]);
01225                 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
01226 
01227                 // create learning module tree
01228                 $newObj->createLMTree();
01229 
01230                 // create import directory
01231                 $newObj->createImportDirectory();
01232 
01233                 // copy uploaded file to import directory
01234                 $file = pathinfo($_FILES["xmldoc"]["name"]);
01235                 $full_path = $newObj->getImportDirectory()."/".$_FILES["xmldoc"]["name"];
01236 
01237                 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"],
01238                         $_FILES["xmldoc"]["name"], $full_path);
01239 
01240                 //move_uploaded_file($_FILES["xmldoc"]["tmp_name"], $full_path);
01241 
01242                 // unzip file
01243                 ilUtil::unzip($full_path);
01244 
01245                 // determine filename of xml file
01246                 $subdir = basename($file["basename"],".".$file["extension"]);
01247                 $xml_file = $newObj->getImportDirectory()."/".$subdir."/".$subdir.".xml";
01248 
01249                 // check whether subdirectory exists within zip file
01250                 if (!is_dir($newObj->getImportDirectory()."/".$subdir))
01251                 {
01252                         $this->ilias->raiseError(sprintf($this->lng->txt("cont_no_subdir_in_zip"), $subdir),
01253                                 $this->ilias->error_obj->MESSAGE);
01254                 }
01255 
01256                 // check whether xml file exists within zip file
01257                 if (!is_file($xml_file))
01258                 {
01259                         $this->ilias->raiseError(sprintf($this->lng->txt("cont_zip_file_invalid"), $subdir."/".$subdir.".xml"),
01260                                 $this->ilias->error_obj->MESSAGE);
01261                 }
01262 
01263                 include_once ("content/classes/class.ilContObjParser.php");
01264                 $contParser = new ilContObjParser($newObj, $xml_file, $subdir);
01265                 $contParser->startParsing();
01266                 ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
01267                 $newObj->MDUpdateListener('General');
01268 
01269                 // import style
01270                 $style_file = $newObj->getImportDirectory()."/".$subdir."/style.xml";
01271                 if (is_file($style_file))
01272                 {
01273                         require_once("classes/class.ilObjStyleSheet.php");
01274                         $style = new ilObjStyleSheet();
01275                         $style->createFromXMLFile($style_file);
01276                         $newObj->writeStyleSheetId($style->getId());
01277                 }
01278                 
01279                 // delete import directory
01280                 ilUtil::delDir($newObj->getImportDirectory());
01281 
01282                 sendInfo($this->lng->txt($this->type."_added"),true);
01283                 ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
01284 
01285         }
01286 
01290         function chapters()
01291         {
01292                 global $tree;
01293 
01294                 $this->setTabs();
01295 
01296                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.structure_edit.html", true);
01297                 $num = 0;
01298 
01299                 $this->ctrl->setParameter($this, "backcmd", "chapters");
01300                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01301                 $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_chapters"));
01302                 $this->tpl->setVariable("CHECKBOX_TOP", IL_FIRST_NODE);
01303 
01304 
01305                 $cnt = 0;
01306                 $childs = $this->lm_tree->getChilds($this->lm_tree->getRootId());
01307                 foreach ($childs as $child)
01308                 {
01309                         if($child["type"] != "st")
01310                         {
01311                                 continue;
01312                         }
01313 
01314                         $this->tpl->setCurrentBlock("table_row");
01315                         // color changing
01316                         $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
01317 
01318                         // checkbox
01319                         $this->tpl->setVariable("CHECKBOX_ID", $child["obj_id"]);
01320                         $this->tpl->setVariable("CSS_ROW", $css_row);
01321                         $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_st.gif"));
01322 
01323                         // link
01324                         $this->ctrl->setParameter($this, "backcmd", "");
01325                         $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $child["obj_id"]);
01326                         $this->tpl->setVariable("LINK_TARGET",
01327                                 $this->ctrl->getLinkTargetByClass("ilStructureObjectGUI", "view"));
01328 
01329                         // title
01330                         $this->tpl->setVariable("TEXT_CONTENT", $child["title"]);
01331 
01332                         $this->tpl->parseCurrentBlock();
01333                 }
01334                 
01335                 $paste_active = false;
01336                 if (ilEditClipboard::getContentObjectType() == "st")
01337                 {
01338                         if ($this->lm_tree->isInTree(ilEditClipboard::getContentObjectId())
01339                                 || ilEditClipboard::getAction() == "copy")
01340                         {
01341                                 $paste_active = true;
01342                         }
01343                 }
01344 
01345                 if($cnt == 0 && !$paste_active)
01346                 {
01347                         $this->tpl->setCurrentBlock("notfound");
01348                         $this->tpl->setVariable("NUM_COLS", 3);
01349                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
01350                         $this->tpl->parseCurrentBlock();
01351                 }
01352                 else
01353                 {
01354                         // SHOW VALID ACTIONS
01355                         $this->tpl->setVariable("NUM_COLS", 3);
01356                         if ($cnt > 0)
01357                         {
01358                                 $acts = array("delete" => "delete", "move" => "moveChapter",
01359                                         "copy" => "copyChapter");
01360                         }
01361                         if ($paste_active)
01362                         {
01363                                 $acts["pasteChapter"] =  "pasteChapter";
01364                         }
01365                         $this->setActions($acts);
01366                         $this->showActions();
01367                 }
01368 
01369                 // SHOW POSSIBLE SUB OBJECTS
01370                 $this->tpl->setVariable("NUM_COLS", 3);
01371                 $subobj = array("st");
01372                 $opts = ilUtil::formSelect(12,"new_type",$subobj);
01373                 $this->tpl->setCurrentBlock("add_object");
01374                 $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
01375                 $this->tpl->setVariable("BTN_NAME", "create");
01376                 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("insert"));
01377                 $this->tpl->parseCurrentBlock();
01378 
01379                 $this->tpl->setCurrentBlock("form");
01380                 $this->tpl->parseCurrentBlock();
01381 
01382         }
01383 
01384 
01385         /*
01386         * list all pages of learning module
01387         */
01388         function pages()
01389         {
01390                 global $tree;
01391 
01392                 $this->setTabs();
01393 
01394                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.all_pages.html", true);
01395                 $num = 0;
01396 
01397                 $this->tpl->setCurrentBlock("form");
01398                 $this->ctrl->setParameter($this, "backcmd", "pages");
01399                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01400                 $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_pages"));
01401                 $this->tpl->setVariable("CONTEXT", $this->lng->txt("context"));
01402                 $this->tpl->setVariable("CHECKBOX_TOP", IL_FIRST_NODE);
01403 
01404                 $cnt = 0;
01405                 $pages = ilLMPageObject::getPageList($this->object->getId());
01406                 foreach ($pages as $page)
01407                 {
01408                         $this->tpl->setCurrentBlock("table_row");
01409                         // color changing
01410                         $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
01411 
01412                         // checkbox
01413                         $this->tpl->setVariable("CHECKBOX_ID", $page["obj_id"]);
01414                         $this->tpl->setVariable("CSS_ROW", $css_row);
01415                         $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_le.gif"));
01416 
01417                         // link
01418                         $this->ctrl->setParameter($this, "backcmd", "");
01419                         $this->ctrl->setParameterByClass("ilLMPageObjectGUI", "obj_id", $page["obj_id"]);
01420 //echo "<br>:".$this->ctrl->getLinkTargetByClass("ilLMPageObjectGUI", "view").":";
01421                         $this->tpl->setVariable("LINK_TARGET",
01422                                 $this->ctrl->getLinkTargetByClass("ilLMPageObjectGUI", "view"));
01423 
01424                         // title
01425                         $this->tpl->setVariable("TEXT_CONTENT", $page["title"]);
01426 
01427                         // context
01428                         if ($this->lm_tree->isInTree($page["obj_id"]))
01429                         {
01430                                 $path_str = $this->getContextPath($page["obj_id"]);
01431                         }
01432                         else
01433                         {
01434                                 $path_str = "---";
01435                         }
01436                         $this->tpl->setVariable("TEXT_CONTEXT", $path_str);
01437 
01438                         $this->tpl->parseCurrentBlock();
01439                 }
01440                 if($cnt == 0)
01441                 {
01442                         $this->tpl->setCurrentBlock("notfound");
01443                         $this->tpl->setVariable("NUM_COLS", 4);
01444                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
01445                         $this->tpl->parseCurrentBlock();
01446                 }
01447                 else
01448                 {
01449                         $acts = array("delete" => "delete", "movePage" => "movePage", "copyPage" => "copyPage");
01450                         if(ilEditClipboard::getContentObjectType() == "pg" &&
01451                                 ilEditClipboard::getAction() == "copy")
01452                         {
01453                                 $acts["pastePage"] = "pastePage";
01454                         }
01455 
01456                         /*
01457                         if (ilEditClipboard::getContentObjectType() == "st")
01458                         {
01459                                 $acts["pasteChapter"] =  "pasteChapter";
01460                         }*/
01461                         $this->setActions($acts);
01462                         $this->tpl->setVariable("NUM_COLS", 4);
01463                         $this->showActions();
01464 
01465                         // SHOW VALID ACTIONS
01466                         /*
01467                         $this->tpl->setCurrentBlock("operation_btn");
01468                         $this->tpl->setVariable("BTN_NAME", "delete");
01469                         $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
01470                         $this->tpl->parseCurrentBlock();*/
01471 
01472                 }
01473 
01474                 // SHOW POSSIBLE SUB OBJECTS
01475                 $this->tpl->setVariable("NUM_COLS", 4);
01476                 //$this->showPossibleSubObjects("st");
01477                 $subobj = array("pg");
01478                 $opts = ilUtil::formSelect(12,"new_type",$subobj);
01479                 $this->tpl->setCurrentBlock("add_object");
01480                 $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
01481                 $this->tpl->setVariable("BTN_NAME", "create");
01482                 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("create"));
01483                 $this->tpl->parseCurrentBlock();
01484 
01485 
01486                 $this->tpl->setCurrentBlock("form");
01487                 $this->tpl->parseCurrentBlock();
01488 
01489         }
01490 
01494         function pastePage()
01495         {
01496                 if(ilEditClipboard::getContentObjectType() != "pg")
01497                 {
01498                         $this->ilias->raiseError($this->lng->txt("no_page_in_clipboard"),$this->ilias->error_obj->MESSAGE);
01499                 }
01500 
01501                 // paste selected object
01502                 $id = ilEditClipboard::getContentObjectId();
01503 
01504                 // copy page, if action is copy
01505                 if (ilEditClipboard::getAction() == "copy")
01506                 {
01507                         // check wether page belongs to lm
01508                         if (ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId())
01509                                 == $this->object->getID())
01510                         {
01511                                 $lm_page = new ilLMPageObject($this->object, $id);
01512                                 $new_page =& $lm_page->copy();
01513                                 $id = $new_page->getId();
01514                         }
01515                         else
01516                         {
01517                                 // get page from other content object into current content object
01518                                 $lm_id = ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId());
01519                                 $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
01520                                 $lm_page = new ilLMPageObject($lm_obj, $id);
01521                                 $new_page =& $lm_page->copyToOtherContObject($this->object);
01522                                 $id = $new_page->getId();
01523                         }
01524                 }
01525                 
01526                 // cut is not be possible in "all pages" form yet
01527                 if (ilEditClipboard::getAction() == "cut")
01528                 {
01529                         // check wether page belongs not to lm
01530                         if (ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId())
01531                                 != $this->object->getID())
01532                         {
01533                                 $lm_id = ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId());
01534                                 $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
01535                                 $lm_page = new ilLMPageObject($lm_obj, $id);
01536                                 $lm_page->setLMId($this->object->getID());
01537                                 $lm_page->update();
01538                                 $page =& $lm_page->getPageObject();
01539                                 $page->buildDom();
01540                                 $page->setParentId($this->object->getID());
01541                                 $page->update();
01542                         }
01543                 }
01544 
01545 
01546                 ilEditClipboard::clear();
01547                 $this->ctrl->redirect($this, "pages");
01548         }
01549 
01553         function copyPage()
01554         {
01555                 if(!isset($_POST["id"]))
01556                 {
01557                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01558                 }
01559                 if(count($_POST["id"]) > 1)
01560                 {
01561                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
01562                 }
01563 
01564                 // SAVE POST VALUES
01565                 ilEditClipboard::storeContentObject("pg",$_POST["id"][0],"copy");
01566 
01567                 sendInfo($this->lng->txt("msg_copy_clipboard"), true);
01568 
01569                 $this->ctrl->redirect($this, "pages");
01570         }
01571 
01579         function delete($a_parent_subobj_id = 0)
01580         {
01581                 if(!isset($_POST["id"]))
01582                 {
01583                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01584                 }
01585 
01586                 if(count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE)
01587                 {
01588                         $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
01589                 }
01590 
01591                 if ($a_parent_subobj_id == 0)
01592                 {
01593                         $this->setTabs();
01594                 }
01595 
01596                 // SAVE POST VALUES
01597                 $_SESSION["saved_post"] = $_POST["id"];
01598 
01599                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
01600 
01601                 sendInfo($this->lng->txt("info_delete_sure"));
01602 
01603                 if ($a_parent_subobj_id != 0)
01604                 {
01605                         $this->ctrl->setParameterByClass("ilStructureObjectGUI", "backcmd", $_GET["backcmd"]);
01606                         $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $a_parent_subobj_id);
01607                         $this->tpl->setVariable("FORMACTION",
01608                                 $this->ctrl->getFormActionByClass("ilStructureObjectGUI"));
01609                 }
01610                 else
01611                 {
01612                         $this->ctrl->setParameter($this, "backcmd", $_GET["backcmd"]);
01613                         $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01614                 }
01615                 // BEGIN TABLE HEADER
01616                 $this->tpl->setCurrentBlock("table_header");
01617                 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
01618                 $this->tpl->parseCurrentBlock();
01619 
01620                 // END TABLE HEADER
01621 
01622                 // BEGIN TABLE DATA
01623                 $counter = 0;
01624                 foreach($_POST["id"] as $id)
01625                 {
01626                         if ($id != IL_FIRST_NODE)
01627                         {
01628                                 $obj =& new ilLMObject($this->object, $id);
01629                                 switch($obj->getType())         // ok that's not so nice, could be done better
01630                                 {
01631                                         case "pg":
01632                                                 $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_pg.gif"));
01633                                                 break;
01634                                         case "st":
01635                                                 $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_st.gif"));
01636                                                 break;
01637                                 }
01638                                 $this->tpl->setCurrentBlock("table_row");
01639                                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01640                                 $this->tpl->setVariable("TEXT_CONTENT", $obj->getTitle());
01641                                 $this->tpl->parseCurrentBlock();
01642                         }
01643                 }
01644 
01645                 // cancel/confirm button
01646                 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01647                 $buttons = array( "cancelDelete"  => $this->lng->txt("cancel"),
01648                                                                   "confirmedDelete"  => $this->lng->txt("confirm"));
01649                 foreach ($buttons as $name => $value)
01650                 {
01651                         $this->tpl->setCurrentBlock("operation_btn");
01652                         $this->tpl->setVariable("BTN_NAME",$name);
01653                         $this->tpl->setVariable("BTN_VALUE",$value);
01654                         $this->tpl->parseCurrentBlock();
01655                 }
01656         }
01657 
01661         function cancelDelete()
01662         {
01663                 session_unregister("saved_post");
01664 
01665                 $this->ctrl->redirect($this, $_GET["backcmd"]);
01666 
01667         }
01668 
01676         function confirmedDelete($a_parent_subobj_id = 0)
01677         {
01678                 $tree = new ilTree($this->object->getId());
01679                 $tree->setTableNames('lm_tree','lm_data');
01680                 $tree->setTreeTablePK("lm_id");
01681 
01682                 // check number of objects
01683                 if (!isset($_SESSION["saved_post"]))
01684                 {
01685                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01686                 }
01687 
01688                 // delete all selected objects
01689                 foreach ($_SESSION["saved_post"] as $id)
01690                 {
01691                         if ($id != IL_FIRST_NODE)
01692                         {
01693                                 $obj =& ilLMObjectFactory::getInstance($this->object, $id, false);
01694                                 $node_data = $tree->getNodeData($id);
01695                                 if (is_object($obj))
01696                                 {
01697                                         $obj->setLMId($this->object->getId());
01698                                         $obj->delete();
01699                                 }
01700                                 if($tree->isInTree($id))
01701                                 {
01702                                         $tree->deleteTree($node_data);
01703                                 }
01704                         }
01705                 }
01706 
01707                 // check the tree
01708                 $this->object->checkTree();
01709 
01710                 // feedback
01711                 sendInfo($this->lng->txt("info_deleted"),true);
01712 
01713                 if ($a_parent_subobj_id == 0)
01714                 {
01715                         $this->ctrl->redirect($this, $_GET["backcmd"]);
01716                 }
01717         }
01718 
01719 
01720 
01727         function getContextPath($a_endnode_id, $a_startnode_id = 1)
01728         {
01729                 $path = "";
01730 
01731                 $tmpPath = $this->lm_tree->getPathFull($a_endnode_id, $a_startnode_id);
01732 
01733                 // count -1, to exclude the learning module itself
01734                 for ($i = 1; $i < (count($tmpPath) - 1); $i++)
01735                 {
01736                         if ($path != "")
01737                         {
01738                                 $path .= " > ";
01739                         }
01740 
01741                         $path .= $tmpPath[$i]["title"];
01742                 }
01743 
01744                 return $path;
01745         }
01746 
01747 
01748 
01754         function showActions()
01755         {
01756                 $notoperations = array();
01757 
01758                 $operations = array();
01759 
01760                 $d = $this->actions;
01761 
01762                 foreach ($d as $row)
01763                 {
01764                         if (!in_array($row["name"], $notoperations))
01765                         {
01766                                 $operations[] = $row;
01767                         }
01768                 }
01769 
01770                 if (count($operations)>0)
01771                 {
01772                         foreach ($operations as $val)
01773                         {
01774                                 $this->tpl->setCurrentBlock("operation_btn");
01775                                 $this->tpl->setVariable("BTN_NAME", $val["lng"]);
01776                                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
01777                                 $this->tpl->parseCurrentBlock();
01778                         }
01779 
01780                         $this->tpl->setCurrentBlock("operation");
01781                         $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01782                         $this->tpl->parseCurrentBlock();
01783                 }
01784         }
01785 
01789         function perm()
01790         {
01791                 $this->setTabs();
01792 
01793                 $this->setFormAction("addRole", $this->ctrl->getLinkTarget($this, "addRole"));
01794                 $this->setFormAction("permSave", $this->ctrl->getLinkTarget($this, "permSave"));
01795                 $this->permObject();
01796         }
01797 
01798 
01802         function permSave()
01803         {
01804                 $this->setReturnLocation("permSave", $this->ctrl->getLinkTarget($this, "perm"));
01805                 $this->permSaveObject();
01806         }
01807         
01811         function info()
01812         {
01813                 $this->setTabs();
01814                 $this->infoObject();
01815         }
01816 
01817 
01821         function addRole()
01822         {
01823                 $this->setReturnLocation("addRole", $this->ctrl->getLinkTarget($this, "perm"));
01824                 $this->addRoleObject();
01825         }
01826 
01827 
01831         function owner()
01832         {
01833                 $this->setTabs();
01834                 $this->ownerObject();
01835         }
01836 
01837 
01841         function view()
01842         {
01843                 $this->viewObject();
01844         }
01845 
01846 
01850         function moveChapter($a_parent_subobj_id = 0)
01851         {
01852                 if(!isset($_POST["id"]))
01853                 {
01854                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01855                 }
01856 //echo "Hallo::"; exit;
01857                 if(count($_POST["id"]) > 1)
01858                 {
01859                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
01860                 }
01861 
01862                 if(count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE)
01863                 {
01864                         $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
01865                 }
01866 
01867                 // SAVE POST VALUES
01868                 ilEditClipboard::storeContentObject("st", $_POST["id"][0], "move");
01869 
01870                 sendInfo($this->lng->txt("cont_chap_select_target_now"), true);
01871 
01872                 if ($a_parent_subobj_id == 0)
01873                 {
01874                         $this->ctrl->redirect($this, "chapters");
01875                 }
01876         }
01877 
01878 
01882         function copyChapter($a_parent_subobj_id = 0)
01883         {
01884                 if(!isset($_POST["id"]))
01885                 {
01886                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01887                 }
01888 
01889                 if(count($_POST["id"]) > 1)
01890                 {
01891                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
01892                 }
01893 
01894                 if(count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE)
01895                 {
01896                         $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
01897                 }
01898 
01899                 // SAVE POST VALUES
01900                 ilEditClipboard::storeContentObject("st", $_POST["id"][0], "copy");
01901 
01902                 sendInfo($this->lng->txt("cont_chap_copy_select_target_now"), true);
01903 
01904                 if ($a_parent_subobj_id == 0)
01905                 {
01906                         $this->ctrl->redirect($this, "chapters");
01907                 }
01908         }
01909 
01913         function pasteChapter($a_parent_subobj_id = 0)
01914         {
01915                 if (ilEditClipboard::getContentObjectType() != "st")
01916                 {
01917                         $this->ilias->raiseError($this->lng->txt("no_chapter_in_clipboard"),$this->ilias->error_obj->MESSAGE);
01918                 }
01919 
01920                 $target_tree = new ilTree($this->object->getId());
01921                 $target_tree->setTableNames('lm_tree','lm_data');
01922                 $target_tree->setTreeTablePK("lm_id");
01923 
01924                 // check wether page belongs to lm
01925                 if (ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId())
01926                         != $this->object->getID())
01927                 {
01928                         $source_tree = new ilTree(ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId()));
01929                         $source_tree->setTableNames('lm_tree','lm_data');
01930                         $source_tree->setTreeTablePK("lm_id");
01931                 }
01932                 else
01933                 {
01934                         $source_tree =& $target_tree;
01935                 }
01936 
01937                 // check, if target is within subtree
01938                 $id = ilEditClipboard::getContentObjectId();
01939                 $node = $source_tree->getNodeData($id);
01940                 $subnodes = $source_tree->getSubtree($node);
01941                 foreach ($subnodes as $subnode)
01942                 {
01943                         if($subnode["obj_id"] == $a_parent_subobj_id)
01944                         {
01945                                 $this->ilias->raiseError($this->lng->txt("cont_target_within_source"),$this->ilias->error_obj->MESSAGE);
01946                         }
01947                 }
01948                 if($_POST["id"][0] == $id)
01949                 {
01950                         ilEditClipboard::clear();
01951                         $this->ctrl->redirect($this, "chapters");
01952                 }
01953 
01954                 // determin parent
01955                 $parent = ($a_parent_subobj_id == 0)
01956                         ? $target_tree->getRootId()
01957                         : $a_parent_subobj_id;
01958 
01959                 // determine target position
01960                 if(!isset($_POST["id"]))
01961                 {
01962                         $target = IL_LAST_NODE;
01963                 }
01964                 else
01965                 {
01966                         $target = $_POST["id"][0];
01967                 }
01968                 if($target == IL_FIRST_NODE) // do not move a chapter in front of a page
01969                 {
01970                         $childs =& $target_tree->getChildsByType($parent, "pg");
01971                         if (count($childs) != 0)
01972                         {
01973                                 $target = $childs[count($childs) - 1]["obj_id"];
01974                         }
01975                 }
01976 
01977                 //echo ":".$id.":";
01978                 // delete old tree entries
01979 //echo "-".ilEditClipboard::getAction()."-";
01980                 if (ilEditClipboard::getAction() == "move")
01981                 {
01982                         if (ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId())
01983                                 != $this->object->getID())
01984                         {
01985                                 // we should never reach these lines, moving chapters from on
01986                                 // lm to another is not supported
01987                                 ilEditClipboard::clear();
01988                                 if ($a_parent_subobj_id == 0)
01989                                 {
01990                                         $this->ctrl->redirect($this, "chapters");
01991                                 }
01992                                 return;
01993                         }
01994 
01995                         $target_tree->deleteTree($node);
01996 
01997                         if (!$target_tree->isInTree($id))
01998                         {
01999                                 $target_tree->insertNode($id, $parent, $target);
02000 
02001                                 foreach ($subnodes as $node)
02002                                 {
02003                                         //$obj_data =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
02004                                         //$obj_data->putInTree($node["parent"]);
02005                                         if($node["obj_id"] != $id)
02006                                         {
02007                                                 $target_tree->insertNode($node["obj_id"], $node["parent"]);
02008                                         }
02009                                 }
02010                         }
02011                 }
02012                 else    // copy
02013                 {
02014                         $id = ilEditClipboard::getContentObjectId();
02015 
02016                         if (ilLMObject::_lookupContObjID($id)
02017                                 == $this->object->getID())
02018                         {
02019                                 $source_obj = ilLMObjectFactory::getInstance($this->object, $id, true);
02020                                 $source_obj->setLMId($this->object->getId());
02021                                 $source_obj->copy($target_tree, $parent, $target);
02022                         }
02023                         else
02024                         {
02025                                 $lm_id = ilLMObject::_lookupContObjID($id);
02026 
02027                                 $source_lm =& ilObjectFactory::getInstanceByObjId($lm_id);
02028                                 $source_obj = ilLMObjectFactory::getInstance($source_lm, $id, true);
02029                                 $source_obj->setLMId($lm_id);
02030                                 $source_obj->copy($target_tree, $parent, $target);
02031                         }
02032                 }
02033 
02034                 ilEditClipboard::clear();
02035 
02036                 // check the tree
02037                 $this->object->checkTree();
02038 
02039                 if ($a_parent_subobj_id == 0)
02040                 {
02041                         $this->ctrl->redirect($this, "chapters");
02042                 }
02043         }
02044 
02048         function movePage()
02049         {
02050                 if(!isset($_POST["id"]))
02051                 {
02052                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
02053                 }
02054                 if(count($_POST["id"]) > 1)
02055                 {
02056                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
02057                 }
02058 
02059                 // SAVE POST VALUES
02060                 ilEditClipboard::storeContentObject("pg", $_POST["id"][0]);
02061 
02062                 sendInfo($this->lng->txt("cont_page_select_target_now"), true);
02063                 $this->ctrl->redirect($this, "pages");
02064         }
02065 
02069         function cancel()
02070         {
02071                 if ($_GET["new_type"] == "pg")
02072                 {
02073                         $this->ctrl->redirect($this, "pages");
02074                 }
02075                 else
02076                 {
02077                         $this->ctrl->redirect($this, "chapters");
02078                 }
02079         }
02080 
02081 
02085         function export()
02086         {
02087                 require_once("content/classes/class.ilContObjectExport.php");
02088                 $cont_exp = new ilContObjectExport($this->object);
02089                 $cont_exp->buildExportFile();
02090                 $this->ctrl->redirect($this, "exportList");
02091         }
02092 
02096         function exportMenu()
02097         {
02098                 // create xml export file button
02099                 $this->tpl->setCurrentBlock("btn_cell");
02100                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "export"));
02101                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file_xml"));
02102                 $this->tpl->parseCurrentBlock();
02103                 
02104                 // create html export file button
02105                 $this->tpl->setCurrentBlock("btn_cell");
02106                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportHTML"));
02107                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file_html"));
02108                 $this->tpl->parseCurrentBlock();
02109 
02110                 // create scorm export file button
02111                 $this->tpl->setCurrentBlock("btn_cell");
02112                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportSCORM"));
02113                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file_scorm"));
02114                 $this->tpl->parseCurrentBlock();
02115 
02116                 // view last export log button
02117                 if (is_file($this->object->getExportDirectory()."/export.log"))
02118                 {
02119                         $this->tpl->setCurrentBlock("btn_cell");
02120                         $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "viewExportLog"));
02121                         $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_view_last_export_log"));
02122                         $this->tpl->parseCurrentBlock();
02123                 }
02124 
02125         }
02126                 
02127         /*
02128         * list all export files
02129         */
02130         function exportList()
02131         {
02132                 global $tree;
02133 
02134                 $this->setTabs();
02135 
02136                 //add template for view button
02137                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
02138 
02139                 $this->exportMenu();
02140                 
02141                 $export_files = $this->object->getExportFiles();
02142 
02143                 // create table
02144                 require_once("classes/class.ilTableGUI.php");
02145                 $tbl = new ilTableGUI();
02146 
02147                 // load files templates
02148                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
02149 
02150                 // load template for table content data
02151                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", true);
02152 
02153                 $num = 0;
02154 
02155                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
02156 
02157                 $tbl->setTitle($this->lng->txt("cont_export_files"));
02158 
02159                 $tbl->setHeaderNames(array("", $this->lng->txt("type"),
02160                         $this->lng->txt("cont_file"),
02161                         $this->lng->txt("cont_size"), $this->lng->txt("date") ));
02162 
02163                 $cols = array("", "type", "file", "size", "date");
02164                 $header_params = array("ref_id" => $_GET["ref_id"],
02165                         "cmd" => "exportList", "cmdClass" => strtolower(get_class($this)));
02166                 $tbl->setHeaderVars($cols, $header_params);
02167                 $tbl->setColumnWidth(array("1%", "9%", "40%", "25%", "25%"));
02168 
02169                 // control
02170                 $tbl->setOrderColumn($_GET["sort_by"]);
02171                 $tbl->setOrderDirection($_GET["sort_order"]);
02172                 $tbl->setLimit($_GET["limit"]);
02173                 $tbl->setOffset($_GET["offset"]);
02174                 $tbl->setMaxCount($this->maxcount);             // ???
02175                 $tbl->disable("sort");
02176 
02177 
02178                 $this->tpl->setVariable("COLUMN_COUNTS", 5);
02179 
02180                 // delete button
02181                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
02182                 $this->tpl->setCurrentBlock("tbl_action_btn");
02183                 $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
02184                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
02185                 $this->tpl->parseCurrentBlock();
02186 
02187                 $this->tpl->setCurrentBlock("tbl_action_btn");
02188                 $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
02189                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
02190                 $this->tpl->parseCurrentBlock();
02191 
02192                 $this->tpl->setCurrentBlock("tbl_action_btn");
02193                 $this->tpl->setVariable("BTN_NAME", "publishExportFile");
02194                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("cont_public_access"));
02195                 $this->tpl->parseCurrentBlock();
02196 
02197                 // footer
02198                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
02199                 //$tbl->disable("footer");
02200 
02201                 $tbl->setMaxCount(count($export_files));
02202                 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
02203                 $tbl->render();
02204                 if(count($export_files) > 0)
02205                 {
02206                         $i=0;
02207                         foreach($export_files as $exp_file)
02208                         {
02209                                 $this->tpl->setCurrentBlock("tbl_content");
02210                                 $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
02211 
02212                                 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
02213                                 $this->tpl->setVariable("CSS_ROW", $css_row);
02214 
02215                                 $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
02216                                 $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($exp_file["type"]))
02217                                         ? " <b>(".$this->lng->txt("public").")<b>"
02218                                         : "";
02219                                 $this->tpl->setVariable("TXT_TYPE", $exp_file["type"].$public_str);
02220                                 $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"].":".$exp_file["file"]);
02221 
02222                                 $file_arr = explode("__", $exp_file["file"]);
02223                                 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
02224 
02225                                 $this->tpl->parseCurrentBlock();
02226                         }
02227                 } //if is_array
02228                 else
02229                 {
02230                         $this->tpl->setCurrentBlock("notfound");
02231                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
02232                         $this->tpl->setVariable("NUM_COLS", 4);
02233                         $this->tpl->parseCurrentBlock();
02234                 }
02235 
02236                 $this->tpl->parseCurrentBlock();
02237         }
02238 
02239         /*
02240         * view last export log
02241         */
02242         function viewExportLog()
02243         {
02244                 global $tree;
02245 
02246                 $this->setTabs();
02247 
02248                 //add template for view button
02249                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
02250                 
02251                 $this->exportMenu();
02252 
02253                 // load files templates
02254                 $this->tpl->setVariable("ADM_CONTENT",
02255                         nl2br(file_get_contents($this->object->getExportDirectory()."/export.log")));
02256 
02257                 $this->tpl->parseCurrentBlock();
02258         }
02259 
02263         function downloadExportFile()
02264         {
02265                 if(!isset($_POST["file"]))
02266                 {
02267                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
02268                 }
02269 
02270                 if (count($_POST["file"]) > 1)
02271                 {
02272                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
02273                 }
02274 
02275                 $file = explode(":", $_POST["file"][0]);
02276                 $export_dir = $this->object->getExportDirectory($file[0]);
02277                 ilUtil::deliverFile($export_dir."/".$file[1],
02278                         $file[1]);
02279         }
02280 
02284         function publishExportFile()
02285         {
02286                 if(!isset($_POST["file"]))
02287                 {
02288                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
02289                 }
02290                 if (count($_POST["file"]) > 1)
02291                 {
02292                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
02293                 }
02294                 
02295                 $file = explode(":", $_POST["file"][0]);
02296                 $export_dir = $this->object->getExportDirectory($file[0]);
02297                 
02298                 if ($this->object->getPublicExportFile($file[0]) ==
02299                         $file[1])
02300                 {
02301                         $this->object->setPublicExportFile($file[0], "");
02302                 }
02303                 else
02304                 {
02305                         $this->object->setPublicExportFile($file[0], $file[1]);
02306                 }
02307                 $this->object->update();
02308                 $this->ctrl->redirect($this, "exportList");
02309         }
02310 
02314         function downloadPDFFile()
02315         {
02316                 if(!isset($_POST["file"]))
02317                 {
02318                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
02319                 }
02320 
02321                 if (count($_POST["file"]) > 1)
02322                 {
02323                         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
02324                 }
02325 
02326 
02327                 $export_dir = $this->object->getOfflineDirectory();
02328                 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
02329                         $_POST["file"][0]);
02330         }
02331 
02335         function confirmDeleteExportFile()
02336         {
02337                 if(!isset($_POST["file"]))
02338                 {
02339                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
02340                 }
02341 
02342                 $this->setTabs();
02343 
02344                 // SAVE POST VALUES
02345                 $_SESSION["ilExportFiles"] = $_POST["file"];
02346 
02347                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
02348 
02349                 sendInfo($this->lng->txt("info_delete_sure"));
02350 
02351                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
02352 
02353                 // BEGIN TABLE HEADER
02354                 $this->tpl->setCurrentBlock("table_header");
02355                 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
02356                 $this->tpl->parseCurrentBlock();
02357 
02358                 // BEGIN TABLE DATA
02359                 $counter = 0;
02360                 foreach($_POST["file"] as $file)
02361                 {
02362                                 $file = explode(":", $file);
02363                                 $this->tpl->setCurrentBlock("table_row");
02364                                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
02365                                 $this->tpl->setVariable("TEXT_CONTENT", $file[1]." (".$file[0].")");
02366                                 $this->tpl->parseCurrentBlock();
02367                 }
02368 
02369                 // cancel/confirm button
02370                 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
02371                 $buttons = array( "cancelDeleteExportFile"  => $this->lng->txt("cancel"),
02372                         "deleteExportFile"  => $this->lng->txt("confirm"));
02373                 foreach ($buttons as $name => $value)
02374                 {
02375                         $this->tpl->setCurrentBlock("operation_btn");
02376                         $this->tpl->setVariable("BTN_NAME",$name);
02377                         $this->tpl->setVariable("BTN_VALUE",$value);
02378                         $this->tpl->parseCurrentBlock();
02379                 }
02380         }
02381 
02382 
02386         function cancelDeleteExportFile()
02387         {
02388                 session_unregister("ilExportFiles");
02389                 $this->ctrl->redirect($this, "exportList");
02390         }
02391 
02392 
02396         function deleteExportFile()
02397         {
02398                 foreach($_SESSION["ilExportFiles"] as $file)
02399                 {
02400                         $file = explode(":", $file);
02401                         $export_dir = $this->object->getExportDirectory($file[0]);
02402                         
02403                         $exp_file = $export_dir."/".$file[1];
02404                         $exp_dir = $export_dir."/".substr($file[1], 0, strlen($file[1]) - 4);
02405                         if (@is_file($exp_file))
02406                         {
02407                                 unlink($exp_file);
02408                         }
02409                         if (@is_dir($exp_dir))
02410                         {
02411                                 ilUtil::delDir($exp_dir);
02412                         }
02413                 }
02414                 $this->ctrl->redirect($this, "exportList");
02415         }
02416 
02421         function fixTreeConfirm()
02422         {
02423                 $this->setTabs();
02424 
02425                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm.html");
02426 
02427                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
02428 
02429                 //
02430                 $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("confirmation"));
02431                 $this->tpl->setVariable("TXT_CONTENT", $this->lng->txt("cont_fix_tree_confirm"));
02432                 $this->tpl->setVariable("CMD_CANCEL", "cancelFixTree");
02433                 $this->tpl->setVariable("CMD_OK", "fixTree");
02434                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
02435                 $this->tpl->setVariable("TXT_OK", $this->lng->txt("cont_fix_tree"));
02436         }
02437 
02441         function cancelFixTree()
02442         {
02443                 $this->ctrl->redirect($this, "properties");
02444         }
02445 
02449         function fixTree()
02450         {
02451                 $this->object->fixTree();
02452                 sendInfo($this->lng->txt("cont_tree_fixed"), true);
02453                 $this->ctrl->redirect($this, "properties");
02454         }
02455 
02459         function setilLMMenu($a_offline = false, $a_export_format = "")
02460         {
02461                 if (!$this->object->isActiveLMMenu())
02462                 {
02463                         return "";
02464                 }
02465 
02466                 include_once("./classes/class.ilTemplate.php");
02467 
02468                 $tpl_menu =& new ilTemplate("tpl.lm_menu.html", true, true, true);
02469                 $tpl_menu->setCurrentBlock("lm_menu_btn");
02470 
02471                 // Determine whether the view of a learning resource should
02472                 // be shown in the frameset of ilias, or in a separate window.
02473                 $showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
02474 
02475                 if ($showViewInFrameset)
02476                 {
02477                         $buttonTarget = "bottom";
02478                 }
02479                 else
02480                 {
02481                         $buttonTarget = "_top";
02482                 }
02483 
02484                 if ($a_export_format == "scorm")
02485                 {
02486                         $buttonTarget = "";
02487                 }
02488 
02489                 if ($this->object->isActiveTOC())
02490                 {
02491                         if (!$a_offline)
02492                         {
02493                                 $tpl_menu->setVariable("BTN_LINK", ILIAS_HTTP_PATH."/content/lm_presentation.php?cmd=showTableOfContents&ref_id="
02494                                                                            .$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]);
02495                         }
02496                         else
02497                         {
02498                                 $tpl_menu->setVariable("BTN_LINK", "./table_of_contents.html");
02499                         }
02500                         $tpl_menu->setVariable("BTN_TXT", $this->lng->txt("cont_contents"));
02501                         $tpl_menu->setVariable("BTN_TARGET", $buttonTarget);
02502                         $tpl_menu->parseCurrentBlock();
02503                 }
02504 
02505                 // print view
02506                 if ($this->object->isActivePrintView())
02507                 {
02508                         if (!$a_offline)                // has to be implemented for offline mode
02509                         {
02510                                 $tpl_menu->setVariable("BTN_LINK", ILIAS_HTTP_PATH."/content/lm_presentation.php?cmd=showPrintViewSelection&ref_id="
02511                                                                            .$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]);
02512                                 $tpl_menu->setVariable("BTN_TXT", $this->lng->txt("cont_print_view"));
02513                                 $tpl_menu->setVariable("BTN_TARGET", $buttonTarget);
02514                                 $tpl_menu->parseCurrentBlock();
02515                         }
02516                 }
02517 
02518                 // download
02519                 if ($this->object->isActiveDownloads() && !$a_offline)
02520                 {
02521                         $tpl_menu->setVariable("BTN_LINK", ILIAS_HTTP_PATH."/content/lm_presentation.php?cmd=showDownloadList&ref_id="
02522                                                                    .$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]);
02523                         $tpl_menu->setVariable("BTN_TXT", $this->lng->txt("download"));
02524                                                 $tpl_menu->setVariable("BTN_TARGET", $buttonTarget);
02525                         $tpl_menu->parseCurrentBlock();
02526                 }
02527 
02528                 // get user defined menu entries
02529                 $this->__initLMMenuEditor();
02530                 $entries = $this->lmme_obj->getMenuEntries(true);
02531 
02532                 if (count($entries) > 0)
02533                 {
02534                         foreach ($entries as $entry)
02535                         {
02536                                 // build goto-link for internal resources
02537                                 if ($entry["type"] == "intern")
02538                                 {
02539                                         $entry["link"] = ILIAS_HTTP_PATH."/goto.php?target=".$entry["link"];
02540                                 }
02541 
02542                                 // add http:// prefix if not exist
02543                                 if (!strstr($entry["link"],'http://'))
02544                                 {
02545                                         $entry["link"] = "http://".$entry["link"];
02546                                 }
02547 
02548                                 $tpl_menu->setVariable("BTN_LINK", $entry["link"]);
02549                                 $tpl_menu->setVariable("BTN_TXT", $entry["title"]);
02550                                 //$tpl_menu->setVariable("BTN_TARGET", $buttonTarget);
02551                                 $tpl_menu->setVariable("BTN_TARGET", "_blank");
02552                                 $tpl_menu->parseCurrentBlock();
02553                         }
02554                 }
02555 
02556                 // close button
02557                 if(!$showViewInFrameset and
02558                    $this->object->isActiveLMMenu())
02559                 {
02560                         $tpl_menu->setCurrentBlock("js_close");
02561                         $tpl_menu->setVariable("JS_BTN_TXT",$this->lng->txt('close'));
02562                         $tpl_menu->parseCurrentBlock();
02563                 }
02564 
02565                 // Jump to...
02566                 /*
02567                 $tpl_menu->setCurrentBlock("jump");
02568                 $tpl_menu->setVariable("JUMP_TXT", $this->lng->txt("jump_to"));
02569                 $tpl_menu->parseCurrentBlock();
02570                 */
02571 
02572                 return $tpl_menu->get();
02573         }
02574 
02578         function createPDF()
02579         {
02580                 require_once("content/classes/class.ilContObjectExport.php");
02581                 $cont_exp = new ilContObjectExport($this->object, "pdf");
02582                 $cont_exp->buildExportFile();
02583                 $this->offlineList();
02584         }
02585 
02589         function exportHTML()
02590         {
02591                 require_once("content/classes/class.ilContObjectExport.php");
02592                 $cont_exp = new ilContObjectExport($this->object, "html");
02593                 $cont_exp->buildExportFile();
02594 //echo $this->tpl->get();
02595                 $this->ctrl->redirect($this, "exportList");
02596         }
02597 
02601         function exportSCORM()
02602         {
02603                 require_once("content/classes/class.ilContObjectExport.php");
02604                 $cont_exp = new ilContObjectExport($this->object, "scorm");
02605                 $cont_exp->buildExportFile();
02606 //echo $this->tpl->get();
02607                 $this->ctrl->redirect($this, "exportList");
02608         }
02609 
02613         function addLocations()
02614         {
02615                 global $lng;
02616 
02617                 $obj_id = $_GET["obj_id"];
02618                 $tree =& $this->object->getTree();
02619 
02620                 if (($obj_id != 0) && $tree->isInTree($obj_id))
02621                 {
02622                         $path = $tree->getPathFull($obj_id);
02623                 }
02624                 else
02625                 {
02626                         $path = $tree->getPathFull($tree->getRootId());
02627                         if ($obj_id != 0)
02628                         {
02629                                 $path[] = array("type" => "pg", "child" => $this->obj_id,
02630                                         "title" => ilLMPageObject::_getPresentationTitle($this->obj_id));
02631                         }
02632                 }
02633 
02634                 $modifier = 1;
02635 
02636                 foreach ($path as $key => $row)
02637                 {
02638                         if ($row["child"] == 1)
02639                         {
02640                                 $this->ctrl->setParameter($this, "obj_id", "");
02641                                 $this->ctrl->addLocation(
02642                                         $this->object->getTitle(),
02643                                         $this->ctrl->getLinkTarget($this, "properties"));
02644                         }
02645                         else
02646                         {
02647                                 $title = $row["title"];
02648                                 switch($row["type"])
02649                                 {
02650                                         case "st":
02651                                                 $this->ctrl->setParameterByClass("ilstructureobjectgui", "obj_id", $row["child"]);
02652                                                 $this->ctrl->addLocation(
02653                                                         $title,
02654                                                         $this->ctrl->getLinkTargetByClass("ilstructureobjectgui", "view"));
02655                                                 break;
02656 
02657                                         case "pg":
02658                                                 $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $row["child"]);
02659                                                 $this->ctrl->addLocation(
02660                                                         $title,
02661                                                         $this->ctrl->getLinkTargetByClass("illmpageobjectgui", "view"));
02662                                                 break;
02663                                 }
02664                         }
02665                 }
02666                 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
02667         }
02668 
02669 
02673         function setTabs()
02674         {
02675                 // catch feedback message
02676                 include_once("classes/class.ilTabsGUI.php");
02677                 $tabs_gui =& new ilTabsGUI();
02678                 $this->getTabs($tabs_gui);
02679                 $this->tpl->setCurrentBlock("header_image");
02680                 $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_lm_b.gif"));
02681                 $this->tpl->parseCurrentBlock();
02682                 $this->tpl->setCurrentBlock("content");
02683                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
02684                 $this->tpl->setVariable("HEADER", $this->object->getTitle());
02685         }
02686 
02692         function getTabs(&$tabs_gui)
02693         {
02694                 global $rbacsystem;
02695                 
02696                 // back to upper context
02697                 //$tabs_gui->getTargetsByObjectType($this, $this->object->getType());
02698 
02699                 // properties
02700                 $tabs_gui->addTarget("properties",
02701                         $this->ctrl->getLinkTarget($this,'properties'),
02702                         "properties", get_class($this));
02703 
02704                 // meta data
02705                 $tabs_gui->addTarget("meta_data",
02706                         $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
02707                         "meta_data", "ilmdeditorgui");
02708 
02709                 // chapters
02710                 $tabs_gui->addTarget("cont_chapters",
02711                         $this->ctrl->getLinkTarget($this, "chapters"),
02712                         "chapters", get_class($this));
02713 
02714                 // pages
02715                 $tabs_gui->addTarget("cont_all_pages",
02716                         $this->ctrl->getLinkTarget($this, "pages"),
02717                         "pages", get_class($this));
02718 
02719                 if ($this->object->getType() == "lm")
02720                 {
02721                         // export
02722                         $tabs_gui->addTarget("export",
02723                                 $this->ctrl->getLinkTarget($this, "exportList"),
02724                                 "exportList", get_class($this));
02725         
02726                         // link checker
02727                         $tabs_gui->addTarget("link_check",
02728                                 $this->ctrl->getLinkTarget($this, "linkChecker"),
02729                                 "linkChecker", get_class($this));
02730                 }
02731                 else
02732                 {
02733                         // bibliographical data
02734                         $tabs_gui->addTarget("bib_data",
02735                                 $this->ctrl->getLinkTarget($this, "editBibItem"),
02736                                 "editBibItem", get_class($this));
02737                 }
02738 
02739                 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
02740                 {
02741                         // permissions
02742                         $tabs_gui->addTarget("perm_settings",
02743                                 $this->ctrl->getLinkTarget($this, "perm"),
02744                                 "perm", get_class($this));
02745                 }
02746 
02747         }
02748 
02749         function editPublicSection()
02750         {
02751                 $this->setTabs();
02752 
02753                 switch ($this->object->getType())
02754                 {
02755                         case "lm":
02756                                 $gui_class = "ilobjlearningmodulegui";
02757                                 break;
02758 
02759                         case "dlb":
02760                                 $gui_class = "ilobjdlbookgui";
02761                                 break;
02762                 }
02763 
02764                 // get learning module object
02765                 $this->lm_obj =& new ilObjLearningModule($this->ref_id, true);
02766 
02767                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_public_selector.html");
02768 
02769                 require_once ("content/classes/class.ilPublicSectionSelector.php");
02770                 $exp = new ilPublicSectionSelector($this->ctrl->getLinkTarget($this, "view"),
02771                         $this->object, $gui_class);
02772 
02773                 $exp->setTargetGet("obj_id");
02774 
02775                 // build html-output
02776                 $exp->setOutput(0);
02777                 $output = $exp->getOutput();
02778                 
02779                 // get page ids
02780                 foreach ($exp->format_options as $node)
02781                 {
02782                         if (!$node["container"])
02783                         {
02784                                 $pages[] = $node["child"];
02785                         }
02786                 }
02787                 
02788                 $js_pages = ilUtil::array_php2js($pages);
02789 
02790                 //$this->tpl->setCurrentBlock("content");
02791                 //var_dump($this->object->getPublicAccessMode());
02792                 // access mode selector
02793                 $this->tpl->setVariable("TXT_SET_PUBLIC_MODE", $this->lng->txt("set_public_mode"));
02794                 $this->tpl->setVariable("TXT_CHOOSE_PUBLIC_MODE", $this->lng->txt("choose_public_mode"));
02795                 $modes = array("complete" => $this->lng->txt("all_pages"), "selected" => $this->lng->txt("selected_pages_only"));
02796                 $select_public_mode = ilUtil::formSelect ($this->object->getPublicAccessMode(),"lm_public_mode",$modes, false, true);
02797                 $this->tpl->setVariable("SELECT_PUBLIC_MODE", $select_public_mode);
02798 
02799                 $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("choose_public_pages"));
02800                 $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
02801                 $this->tpl->setVariable("EXPLORER",$output);
02802                 $this->tpl->setVariable("ONCLICK",$js_pages);
02803                 $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
02804                 $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
02805                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
02806                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getLinkTarget($this, "savePublicSection"));
02807                 $this->tpl->parseCurrentBlock();
02808         }
02809         
02810         function savePublicSection()
02811         {
02812                 //var_dump($_POST["lm_public_mode"]);exit;
02813                 $this->object->setPublicAccessMode($_POST["lm_public_mode"]);
02814                 $this->object->updateProperties();
02815                 ilLMObject::_writePublicAccessStatus($_POST["pages"],$this->object->getId());
02816                 sendInfo($this->lng->txt("msg_obj_modified"), true);
02817                 $this->ctrl->redirect($this, "editPublicSection");
02818         }
02819 
02820         function linkChecker()
02821         {
02822                 global $ilias,$ilUser;
02823 
02824                 $this->__initLinkChecker();
02825 
02826                 $invalid_links = $this->link_checker_obj->getInvalidLinksFromDB();
02827 
02828 
02829                 $this->setTabs();
02830 
02831                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.link_check.html", true);
02832 
02833                 if($last_access = $this->link_checker_obj->getLastCheckTimestamp())
02834                 {
02835                         $this->tpl->setCurrentBlock("LAST_MODIFIED");
02836                         $this->tpl->setVariable("AS_OF",$this->lng->txt('last_change').": ");
02837                         $this->tpl->setVariable("LAST_CHECK",date('Y-m-d H:i:s',$last_access));
02838                         $this->tpl->parseCurrentBlock();
02839                 }
02840 
02841 
02842                 $this->tpl->setVariable("F_ACTION",$this->ctrl->getFormAction($this));
02843 
02844                 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_lm.gif'));
02845                 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('learning_module'));
02846                 $this->tpl->setVariable("TITLE",$this->object->getTitle().' ('.$this->lng->txt('link_check').')');
02847                 $this->tpl->setVariable("PAGE_TITLE",$this->lng->txt('cont_pg_title'));
02848                 $this->tpl->setVariable("URL",$this->lng->txt('url'));
02849                 $this->tpl->setVariable("OPTIONS",$this->lng->txt('edit'));
02850 
02851                 if(!count($invalid_links))
02852                 {
02853                         $this->tpl->setCurrentBlock("no_invalid");
02854                         $this->tpl->setVariable("TXT_NO_INVALID",$this->lng->txt('no_invalid_links'));
02855                         $this->tpl->parseCurrentBlock();
02856                 }
02857                 else
02858                 {
02859                         $counter = 0;
02860                         foreach($invalid_links as $invalid)
02861                         {
02862                                 $this->tpl->setCurrentBlock("invalid_row");
02863                                 $this->tpl->setVariable("ROW_COLOR",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
02864                                 $this->tpl->setVariable("ROW_PAGE_TITLE",
02865                                                                                 ilLMPageObject::_getPresentationTitle($invalid['page_id'],$this->object->getPageHeader()));
02866                                 $this->tpl->setVariable("ROW_URL",$invalid['url']);
02867 
02868 
02869                                 // EDIT IMAGE
02870                                 $this->ctrl->setParameterByClass('ilLMPageObjectGUI','obj_id',$invalid['page_id']);
02871                                 $this->tpl->setVariable("ROW_EDIT_LINK",$this->ctrl->getLinkTargetByClass('ilLMPageObjectGUI','view'));
02872 
02873                                 $this->tpl->setVariable("ROW_IMG",ilUtil::getImagePath('edit.gif'));
02874                                 $this->tpl->setVariable("ROW_ALT_IMG",$this->lng->txt('edit'));
02875                                 $this->tpl->parseCurrentBlock();
02876                         }
02877                 }
02878                 if((bool) $ilias->getSetting('cron_link_check'))
02879                 {
02880                         include_once './classes/class.ilLinkCheckNotify.php';
02881 
02882                         // Show message block
02883                         $this->tpl->setCurrentBlock("MESSAGE_BLOCK");
02884                         $this->tpl->setVariable("INFO_MESSAGE",$this->lng->txt('link_check_message_a'));
02885                         $this->tpl->setVariable("CHECK_MESSAGE",ilUtil::formCheckbox(
02886                                                                                 ilLinkCheckNotify::_getNotifyStatus($ilUser->getId(),$this->object->getId()),
02887                                                                                 'link_check_message',
02888                                                                                 1));
02889                         $this->tpl->setVariable("INFO_MESSAGE_LONG",$this->lng->txt('link_check_message_b'));
02890                         $this->tpl->parseCurrentBlock();
02891 
02892                         // Show save button
02893                         $this->tpl->setCurrentBlock("CRON_ENABLED");
02894                         $this->tpl->setVariable("DOWNRIGHT_IMG",ilUtil::getImagePath('arrow_downright.gif'));
02895                         $this->tpl->setVariable("BTN_SUBMIT_LINK_CHECK",$this->lng->txt('save'));
02896                         $this->tpl->parseCurrentBlock();
02897                 }
02898                 $this->tpl->setVariable("BTN_REFRESH",$this->lng->txt('refresh'));
02899 
02900                 return true;
02901 
02902         }
02903         function saveLinkCheck()
02904         {
02905                 global $ilDB,$ilUser;
02906 
02907                 include_once './classes/class.ilLinkCheckNotify.php';
02908 
02909                 $link_check_notify =& new ilLinkCheckNotify($ilDB);
02910                 $link_check_notify->setUserId($ilUser->getId());
02911                 $link_check_notify->setObjId($this->object->getId());
02912 
02913                 if($_POST['link_check_message'])
02914                 {
02915                         sendInfo($this->lng->txt('link_check_message_enabled'));
02916                         $link_check_notify->addNotifier();
02917                 }
02918                 else
02919                 {
02920                         sendInfo($this->lng->txt('link_check_message_disabled'));
02921                         $link_check_notify->deleteNotifier();
02922                 }
02923                 $this->linkChecker();
02924 
02925                 return true;
02926         }
02927                 
02928 
02929 
02930         function refreshLinkCheck()
02931         {
02932                 $this->__initLinkChecker();
02933 
02934                 if(!$this->link_checker_obj->checkPear())
02935                 {
02936                         sendInfo($this->lng->txt('missing_pear_library'));
02937                         $this->linkChecker();
02938 
02939                         return false;
02940                 }
02941 
02942                 $this->link_checker_obj->checkLinks();
02943                 sendInfo($this->lng->txt('link_checker_refreshed'));
02944 
02945                 $this->linkChecker();
02946 
02947                 return true;
02948         }
02949 
02950         function __initLinkChecker()
02951         {
02952                 global $ilDB;
02953 
02954                 include_once './classes/class.ilLinkChecker.php';
02955 
02956                 $this->link_checker_obj =& new ilLinkChecker($ilDB,false);
02957                 $this->link_checker_obj->setObjId($this->object->getId());
02958 
02959                 return true;
02960         }
02961         
02962         function __initLMMenuEditor()
02963         {
02964                 include_once './content/classes/class.ilLMMenuEditor.php';
02965 
02966                 $this->lmme_obj =& new ilLMMenuEditor();
02967                 $this->lmme_obj->setObjId($this->object->getId());
02968 
02969                 return true;
02970         }
02971 
02975         function addMenuEntry()
02976         {
02977                 $this->setTabs();
02978 
02979                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_menu_entry_form.html",true);
02980                 
02981                 if (isset($_GET["link_ref_id"]))
02982                 {
02983                         $obj_type = ilObject::_lookupType($_GET["link_ref_id"],true);
02984                         $obj_id = ilObject::_lookupObjectId($_GET["link_ref_id"]);
02985                         $title = ilObject::_lookupTitle($obj_id);
02986                         
02987                         $target_link = $obj_type."_".$_GET["link_ref_id"];
02988                         $this->tpl->setVariable("TITLE", $title);
02989                         $this->tpl->setVariable("TARGET", $target_link);
02990                         $this->tpl->setVariable("LINK_REF_ID", $_GET["link_ref_id"]);
02991                 }
02992 
02993                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
02994                 $this->tpl->setVariable("TXT_NEW_ENTRY", $this->lng->txt("lm_menu_new_entry"));
02995                 $this->tpl->setVariable("TXT_TARGET", $this->lng->txt("lm_menu_entry_target"));
02996                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("lm_menu_entry_title"));
02997                 $this->tpl->setVariable("BTN_NAME", "saveMenuEntry");
02998                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
02999                 $this->tpl->setVariable("BTN_NAME2", "showEntrySelector");
03000                 $this->tpl->setVariable("BTN_TEXT2", $this->lng->txt("lm_menu_select_internal_object"));
03001                 $this->tpl->parseCurrentBlock();
03002         }
03003 
03007         function saveMenuEntry()
03008         {
03009                 // check title and target
03010                 if (empty($_POST["title"]))
03011                 {
03012                         $this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
03013                 }
03014                 if (empty($_POST["target"]))
03015                 {
03016                         $this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
03017                 }
03018                 
03019                 $this->__initLMMenuEditor();
03020                 $this->lmme_obj->setTitle($_POST["title"]);
03021                 $this->lmme_obj->setTarget($_POST["target"]);
03022                 $this->lmme_obj->setLinkRefId($_POST["link_ref_id"]);
03023                 
03024                 if ($_POST["link_ref_id"])
03025                 {
03026                         $this->lmme_obj->setLinkType("intern");
03027                 }
03028                 
03029                 $this->lmme_obj->create();
03030 
03031                 sendInfo($this->lng->txt("msg_entry_added"), true);
03032                 $this->ctrl->redirect($this, "properties");
03033         }
03034         
03038         function deleteMenuEntry()
03039         {
03040                 if (empty($_GET["menu_entry"]))
03041                 {
03042                         $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
03043                 }
03044                 
03045                 $this->__initLMMenuEditor();
03046                 $this->lmme_obj->delete($_GET["menu_entry"]);
03047 
03048                 sendInfo($this->lng->txt("msg_entry_removed"), true);
03049                 $this->ctrl->redirect($this, "properties");
03050         }
03051         
03055         function editMenuEntry()
03056         {
03057                 if (empty($_GET["menu_entry"]))
03058                 {
03059                         $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
03060                 }
03061                 
03062                 $this->__initLMMenuEditor();
03063                 $this->lmme_obj->readEntry($_GET["menu_entry"]);
03064 
03065                 $this->setTabs();
03066 
03067                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_menu_entry_form.html",true);
03068 
03069                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
03070                 $this->tpl->setVariable("TXT_NEW_ENTRY", $this->lng->txt("lm_menu_edit_entry"));
03071                 $this->tpl->setVariable("TXT_TARGET", $this->lng->txt("lm_menu_entry_target"));
03072                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("lm_menu_entry_title"));
03073                 $this->tpl->setVariable("TITLE", $this->lmme_obj->getTitle());
03074                 $this->tpl->setVariable("TARGET", $this->lmme_obj->getTarget());
03075                 $this->tpl->setVariable("ENTRY_ID", $this->lmme_obj->getEntryId());
03076                 $this->tpl->setVariable("BTN_NAME", "updateMenuEntry");
03077                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
03078                 $this->tpl->setVariable("BTN_NAME2", "showEntrySelector");
03079                 $this->tpl->setVariable("BTN_TEXT2", $this->lng->txt("lm_menu_select_internal_object"));
03080                 $this->tpl->parseCurrentBlock();
03081         }
03082         
03086         function updateMenuEntry()
03087         {
03088                 if (empty($_POST["menu_entry"]))
03089                 {
03090                         $this->ilias->raiseError($this->lng->txt("no_menu_entry_id"),$this->ilias->error_obj->MESSAGE);
03091                 }
03092                 
03093                 // check title and target
03094                 if (empty($_POST["title"]))
03095                 {
03096                         $this->ilias->raiseError($this->lng->txt("please_enter_title"),$this->ilias->error_obj->MESSAGE);
03097                 }
03098                 if (empty($_POST["target"]))
03099                 {
03100                         $this->ilias->raiseError($this->lng->txt("please_enter_target"),$this->ilias->error_obj->MESSAGE);
03101                 }
03102                 
03103                 $this->__initLMMenuEditor();
03104                 $this->lmme_obj->readEntry($_POST["menu_entry"]);
03105                 $this->lmme_obj->setTitle($_POST["title"]);
03106                 $this->lmme_obj->setTarget($_POST["target"]);
03107                 $this->lmme_obj->update();
03108 
03109                 sendInfo($this->lng->txt("msg_entry_updated"), true);
03110                 $this->ctrl->redirect($this, "properties");
03111         }
03112         
03113         function showEntrySelector()
03114         {
03115                 $this->setTabs();
03116                 
03117                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_menu_object_selector.html",true);
03118 
03119                 sendInfo($this->lng->txt("lm_menu_select_object_to_add"));
03120                 
03121                 require_once ("content/classes/class.ilLMMenuObjectSelector.php");
03122                 $exp = new ilLMMenuObjectSelector($this->ctrl->getLinkTarget($this,'test'),$this);
03123 
03124                 $exp->setExpand($_GET["lm_menu_expand"] ? $_GET["lm_menu_expand"] : $this->tree->readRootId());
03125                 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'showEntrySelector'));
03126                 $exp->setTargetGet("ref_id");
03127                 $exp->setRefId($this->cur_ref_id);
03128                 
03129                 $sel_types = array('lm','dbk','glo','frm','exc','tst','svy');
03130                 $exp->setSelectableTypes($sel_types);
03131 
03132                 //$exp->setTargetGet("obj_id");
03133 
03134                 // build html-output
03135                 $exp->setOutput(0);
03136                 $output = $exp->getOutput();
03137                 
03138                 // get page ids
03139                 foreach ($exp->format_options as $node)
03140                 {
03141                         if (!$node["container"])
03142                         {
03143                                 $pages[] = $node["child"];
03144                         }
03145                 }
03146                 
03147                 //$this->tpl->setCurrentBlock("content");
03148                 //var_dump($this->object->getPublicAccessMode());
03149                 // access mode selector
03150                 $this->tpl->setVariable("TXT_SET_PUBLIC_MODE", $this->lng->txt("set_public_mode"));
03151                 $this->tpl->setVariable("TXT_CHOOSE_PUBLIC_MODE", $this->lng->txt("choose_public_mode"));
03152                 $modes = array("complete" => $this->lng->txt("all_pages"), "selected" => $this->lng->txt("selected_pages_only"));
03153                 $select_public_mode = ilUtil::formSelect ($this->object->getPublicAccessMode(),"lm_public_mode",$modes, false, true);
03154                 $this->tpl->setVariable("SELECT_PUBLIC_MODE", $select_public_mode);
03155 
03156                 $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("choose_public_pages"));
03157                 $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
03158                 $this->tpl->setVariable("EXPLORER",$output);
03159                 $this->tpl->setVariable("ONCLICK",$js_pages);
03160                 $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
03161                 $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
03162                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
03163                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getLinkTarget($this, "savePublicSection"));
03164                 $this->tpl->parseCurrentBlock();
03165         }
03166 } // END class.ilObjContentObjectGUI
03167 ?>

Generated on Fri Dec 13 2013 10:18:29 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1