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

Generated on Fri Dec 13 2013 13:52:09 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1