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

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