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

classes/class.ilContainerGUI.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 
00037 require_once "class.ilObjectGUI.php";
00038 require_once "class.ilContainer.php";
00039 
00040 class ilContainerGUI extends ilObjectGUI
00041 {
00046         function ilContainerGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
00047         {
00048                 global $rbacsystem;
00049 
00050                 $this->rbacsystem =& $rbacsystem;
00051 
00052                 //$this->ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
00053                 
00054                 // prepare output things should generally be made in executeCommand
00055                 // method (maybe dependent on current class/command
00056                 $this->ilObjectGUI($a_data, $a_id, $a_call_by_reference, false);
00057         }
00058 
00063         function &executeCommand()
00064         {
00065                 $next_class = $this->ctrl->getNextClass();
00066                 $cmd = $this->ctrl->getCmd("render");
00067 
00068                 switch($next_class)
00069                 {
00070                         // page editing
00071                         case "ilpageobjectgui":
00072                                 return $this->forwardToPageObject();
00073                                 break;
00074                         
00075                         default:
00076                                 $this->prepareOutput();
00077                                 $cmd .= "Object";
00078                                 $this->$cmd();
00079                                 break;
00080                 }
00081                 return true;
00082         }
00083 
00087         function &forwardToPageObject()
00088         {
00089                 global $lng;
00090 
00091                 // page object
00092                 include_once("./Services/COPage/classes/class.ilPageObject.php");
00093                 include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
00094 
00095                 $lng->loadLanguageModule("content");
00096                 
00097                 include_once("./classes/class.ilObjStyleSheet.php");
00098                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00099                         ilObjStyleSheet::getContentStylePath(0));
00100 
00101                 if (!ilPageObject::_exists($this->object->getType(),
00102                         $this->object->getId()))
00103                 {
00104                         // doesn't exist -> create new one
00105                         $new_page_object = new ilPageObject($this->object->getType());
00106                         $new_page_object->setParentId($this->object->getId());
00107                         $new_page_object->setId($this->object->getId());
00108                         $new_page_object->createFromXML();
00109                 }
00110                 
00111                 // get page object
00112                 $page_object = new ilPageObject($this->object->getType(),
00113                         $this->object->getId(), true);
00114 
00115                 $this->ctrl->setReturnByClass("ilpageobjectgui", "view");
00116                 //$page_object =& $this->obj->getPageObject();
00117                 $page_object->buildDom();
00118                 //$page_object->addUpdateListener($this, "updateHistory");
00119                 $int_links = $page_object->getInternalLinks();
00120                 //$link_xml = $this->getLinkXML($int_links);
00121                 $page_gui =& new ilPageObjectGUI($page_object);
00122 
00123                 // $view_frame = ilFrameTargetInfo::_getFrame("MainContent");
00124                 //$page_gui->setViewPageLink(ILIAS_HTTP_PATH."/goto.php?target=pg_".$this->obj->getId(),
00125                 //      $view_frame);
00126 
00127                 $page_gui->setIntLinkHelpDefault("StructureObject", $_GET["ref_id"]);
00128                 $page_gui->setTemplateTargetVar("ADM_CONTENT");
00129                 $page_gui->setLinkXML($link_xml);
00130                 //$page_gui->enableChangeComments($this->content_object->isActiveHistoryUserComments());
00131                 $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
00132                 $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
00133                 //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
00134                 $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this, ""));
00135                 $page_gui->setPresentationTitle("");
00136                 //$page_gui->setLocator($contObjLocator);
00137                 $page_gui->setHeader("");
00138                 $ret =& $this->ctrl->forwardCommand($page_gui);
00139                 
00140                 //$ret =& $page_gui->executeCommand();
00141                 return $ret;
00142         }
00143         
00147         function prepareOutput($a_show_subobjects = true)
00148         {
00149                 if (parent::prepareOutput())    // return false in admin mode
00150                 {
00151                         if ($this->getCreationMode() != true && $a_show_subobjects)
00152                         {
00153                                 // This method is called directly from ilContainerGUI::renderObject
00154                                 #$this->showPossibleSubObjects();
00155                                 $this->showTreeFlatIcon();
00156                         }
00157                 }
00158         }
00159         
00160         function showTreeFlatIcon()
00161         {
00162                 global $tpl;
00163                 
00164                 // dont show icon, if role (permission gui->rolegui) is edited
00165                 if ($_GET["obj_id"] != "")
00166                 {
00167                         return;
00168                 }
00169                 
00170                 $mode = ($_SESSION["il_rep_mode"] == "flat")
00171                         ? "tree"
00172                         : "flat";
00173                 $link = "repository.php?cmd=frameset&set_mode=".$mode."&ref_id=".$this->object->getRefId();
00174                 $tpl->setTreeFlatIcon($link, $mode);
00175         }
00176         
00180         function setTitleAndDescription()
00181         {
00182                 global $ilias;
00183 //echo "1-".get_class($this)."-".$this->object->getTitle()."-";
00184                 $this->tpl->setTitle($this->object->getTitle());
00185                 $this->tpl->setDescription($this->object->getLongDescription());
00186 
00187                 // set tile icon
00188                 $icon = ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif");
00189                 if ($ilias->getSetting("custom_icons") &&
00190                         in_array($this->object->getType(), array("cat","grp","crs", "root")))
00191                 {
00192                         require_once("classes/class.ilContainer.php");
00193                         if (($path = ilContainer::_lookupIconPath($this->object->getId(), "big")) != "")
00194                         {
00195                                 $icon = $path;
00196                         }
00197                 }
00198                 $this->tpl->setTitleIcon($icon, $this->lng->txt("obj_".$this->object->getType()));
00199         }
00200 
00201 
00205         function showPossibleSubObjects()
00206         {
00207                 global $ilAccess;
00208 
00209                 $found = false;
00210                 $cmd = ($this->cmd != "")
00211                         ? $this->cmd
00212                         : $this->ctrl->getCmd();
00213 
00214                 #if ($cmd != "" && $cmd != "showList" && $cmd != "render"
00215                 #       && $cmd != "view")
00216                 #{
00217                 #       return;
00218                 #}
00219                 
00220                 $type = $this->object->getType();
00221 
00222                 $d = $this->objDefinition->getCreatableSubObjects($type);
00223 
00224                 if (count($d) > 0)
00225                 {
00226                         foreach ($d as $row)
00227                         {
00228                             $count = 0;
00229                                 if ($row["max"] > 0)
00230                                 {
00231                                         //how many elements are present?
00232                                         //var_dump($this->data);
00233                                         // this is broken
00234                                         /*
00235                                         for ($i=0; $i<count($this->data["ctrl"]); $i++)
00236                                         {
00237                                                 if ($this->data["ctrl"][$i]["type"] == $row["name"])
00238                                                 {
00239                                                     $count++;
00240                                                 }
00241                                         }*/
00242                                 }
00243 
00244                                 if ($row["max"] == "" || $count < $row["max"])
00245                                 {
00246                                         if (in_array($row["name"], array("sahs", "alm", "hlm", "lm", "grp", "frm", "mep","crs", "mcst",
00247                                                                                                          "cat", "glo", "dbk","exc", "qpl", "tst", "svy", "spl", "chat", 
00248                                                                                                          "htlm","fold","linkr","file","icrs","icla","crsg",'webr',"feed",'rcrs')))
00249                                         {
00250                                                 if ($this->rbacsystem->checkAccess("create", $this->object->getRefId(), $row["name"]))
00251                                                 {
00252                                                         $subobj[] = $row["name"];
00253                                                 }
00254                                         }
00255                                 }
00256                         }
00257                 }
00258                 if (is_array($subobj))
00259                 {
00260                         // show addEvent button
00261                         if($this->object->getType() == 'crs')
00262                         {
00263                                 if($ilAccess->checkAccess('write','',$this->object->getRefId()))
00264                                 {
00265                                         $this->tpl->setCurrentBlock("event_button");
00266                                         $this->tpl->setVariable("E_FORMACTION",$this->ctrl->getFormActionByClass('ileventadministrationgui'));
00267                                         $this->tpl->setVariable("BTN_NAME_EVENT",'addEvent');
00268                                         $this->tpl->setVariable("TXT_ADD_EVENT",$this->lng->txt('add_event'));
00269                                         $this->tpl->parseCurrentBlock();
00270                                 }
00271                         }
00272                         $this->tpl->setCurrentBlock("add_commands");
00273                         // convert form to inline element, to show them in one row
00274                         if($this->object->getType() == 'crs')
00275                         {
00276                                 $this->tpl->setVariable("FORMSTYLE",'display:inline');
00277                         }
00278                         $this->tpl->setVariable("H_FORMACTION",  "repository.php?ref_id=".$this->object->getRefId().
00279                                 "&cmd=post");
00280                         // possible subobjects
00281                         $opts = ilUtil::formSelect("", "new_type", $subobj);
00282                         $this->tpl->setVariable("SELECT_OBJTYPE_REPOS", $opts);
00283                         $this->tpl->setVariable("BTN_NAME_REPOS", "create");
00284                         $this->tpl->setVariable("TXT_ADD_REPOS", $this->lng->txt("add"));
00285                         $this->tpl->parseCurrentBlock();
00286                 }
00287         }
00288 
00292         function renderObject()
00293         {
00294                 $this->getCenterColumnHTML(true);
00295                 if ($this->type == 'cat' || $this->type == 'grp')
00296                 {
00297                         $this->tpl->setRightContent($this->getRightColumnHTML());
00298                 }
00299         }
00300 
00306         function getContent()
00307         {
00308                 global $ilBench, $tree;
00309 
00310                 // course content interface methods could probably
00311                 // move to this class
00312                 if($this->type != 'icrs' and $tree->checkForParentType($this->ref_id,'crs'))
00313                 {
00314                         include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
00315                         $course_content_obj = new ilCourseContentGUI($this);
00316                         
00317                         $this->ctrl->setCmd('view');
00318                         $this->ctrl->setCmdClass(get_class($course_content_obj));
00319                         $this->ctrl->forwardCommand($course_content_obj);
00320 
00321                         return;
00322                 }
00323 
00324                 // 'add object'
00325                 $this->showPossibleSubObjects();
00326 
00327                 $ilBench->start("ilContainerGUI", "0000__renderObject");
00328 
00329                 $tpl = new ilTemplate ("tpl.container_page.html", true, true);
00330                 
00331                 // get all sub items
00332                 $ilBench->start("ilContainerGUI", "0100_getSubItems");
00333                 $this->getSubItems();
00334                 $ilBench->stop("ilContainerGUI", "0100_getSubItems");
00335 
00336                 // Show introduction, if repository is empty
00337                 if (count($this->items) == 1 && is_array($this->items["adm"]) && $this->object->getRefId() == ROOT_FOLDER_ID)
00338                 {
00339                         $html = $this->getIntroduction();
00340                         $tpl->setVariable("CONTAINER_PAGE_CONTENT", $html);
00341                 }
00342                 else    // show item list otherwise
00343                 {
00344                         $ilBench->start("ilContainerGUI", "0200_renderItemList");
00345                         $html = $this->renderItemList();
00346                         $tpl->setVariable("CONTAINER_PAGE_CONTENT", $html);
00347                         $ilBench->stop("ilContainerGUI", "0200_renderItemList");
00348                 }
00349                 
00350                 $this->showAdministrationPanel($tpl);
00351                 $this->showPermanentLink($tpl);
00352                 
00353                 $this->html = $tpl->get();
00354                 
00355                 $ilBench->stop("ilContainerGUI", "0000__renderObject");
00356         }
00357 
00361         function showAdministrationPanel(&$tpl)
00362         {
00363                 global $ilAccess, $ilSetting;
00364                 
00365                 if ($this->isActiveAdministrationPanel())
00366                 {
00367                         $tpl->setCurrentBlock("admin_button_off");
00368                         $tpl->setVariable("ADMIN_MODE_LINK",
00369                                 $this->ctrl->getLinkTarget($this, "disableAdministrationPanel"));
00370                         $tpl->setVariable("TXT_ADMIN_MODE",
00371                                 $this->lng->txt("admin_panel_disable"));
00372                         $tpl->parseCurrentBlock();
00373                         
00374                         // administration panel
00375                         if ($ilAccess->checkAccess("write", "", $this->object->getRefId())
00376                                 && in_array($this->object->getType(), array("cat", "root")))
00377                         {
00378                                 if ($ilSetting->get("enable_cat_page_edit"))
00379                                 {
00380                                         $tpl->setCurrentBlock("edit_cmd");
00381                                         $tpl->setVariable("TXT_EDIT_PAGE", $this->lng->txt("edit_page"));
00382                                         $tpl->setVariable("LINK_EDIT_PAGE", $this->ctrl->getLinkTarget($this, "editPageFrame"));
00383                                         $tpl->setVariable("FRAME_EDIT_PAGE", ilFrameTargetInfo::_getFrame("MainContent"));
00384                                         $tpl->parseCurrentBlock();
00385                                 }
00386                         }
00387                         
00388                         $tpl->setCurrentBlock("admin_panel_cmd");
00389                         $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("delete_selected_items"));
00390                         $tpl->setVariable("PANEL_CMD", "delete");
00391                         $tpl->parseCurrentBlock();
00392                         if (!$_SESSION["clipboard"])
00393                         {
00394                                 $tpl->setCurrentBlock("admin_panel_cmd");
00395                                 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("move_selected_items"));
00396                                 $tpl->setVariable("PANEL_CMD", "cut");
00397                                 $tpl->parseCurrentBlock();
00398                                 $tpl->setCurrentBlock("admin_panel_cmd");
00399                                 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("link_selected_items"));
00400                                 $tpl->setVariable("PANEL_CMD", "link");
00401                                 $tpl->parseCurrentBlock();
00402                         }
00403                         else
00404                         {
00405                                 $tpl->setCurrentBlock("admin_panel_cmd");
00406                                 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("paste_clipboard_items"));
00407                                 $tpl->setVariable("PANEL_CMD", "paste");
00408                                 $tpl->parseCurrentBlock();
00409                                 $tpl->setCurrentBlock("admin_panel_cmd");
00410                                 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("clear_clipboard"));
00411                                 $tpl->setVariable("PANEL_CMD", "clear");
00412                                 $tpl->parseCurrentBlock();
00413                                 
00414                         }
00415                         if ($ilAccess->checkAccess("write", "", $this->object->getRefId())
00416                                 && in_array($this->object->getType(), array("cat", "root")))
00417                         {
00418                                 include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
00419                                 if(ilContainerSortingSettings::_lookupSortMode($this->object->getId()) == ilContainerSortingSettings::MODE_MANUAL)
00420                                 {
00421                                         $tpl->setCurrentBlock('admin_panel_cmd');
00422                                         $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt('sorting_save'));
00423                                         $tpl->setVariable("PANEL_CMD", "saveSorting");
00424                                         $tpl->parseCurrentBlock();
00425                                 }
00426                         }
00427 
00428                         $tpl->setCurrentBlock("admin_panel");
00429                         $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00430                         $tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
00431                         $tpl->setVariable("TXT_ADMIN_PANEL", $this->lng->txt("admin_panel"));
00432                         $tpl->parseCurrentBlock();
00433                         $this->ctrl->setParameter($this, "type", "");
00434                         $this->ctrl->setParameter($this, "item_ref_id", "");
00435                         $GLOBALS["tpl"]->setPageFormAction($this->ctrl->getFormAction($this));
00436                 }
00437                 else if ($this->adminCommands || (is_object($this->object) && 
00438                         $ilAccess->checkAccess("write", "", $this->object->getRefId())))
00439                 {
00440                         #$this->__showTimingsButton($tpl);
00441 
00442                         $tpl->setCurrentBlock("admin_button");
00443                         $tpl->setVariable("ADMIN_MODE_LINK",
00444                                 $this->ctrl->getLinkTarget($this, "enableAdministrationPanel"));
00445                         $tpl->setVariable("TXT_ADMIN_MODE",
00446                                 $this->lng->txt("admin_panel_enable"));
00447                         $tpl->parseCurrentBlock();
00448                 }
00449         }
00450 
00451         function __showTimingsButton(&$tpl)
00452         {
00453                 global $tree;
00454 
00455                 if(!$tree->checkForParentType($this->object->getRefId(),'crs'))
00456                 {
00457                         return false;
00458                 }
00459                 $tpl->setCurrentBlock("custom_button");
00460                 $tpl->setVariable("ADMIN_MODE_LINK",$this->ctrl->getLinkTargetByClass('ilcoursecontentgui','editTimings'));
00461                 $tpl->setVariable("TXT_ADMIN_MODE",$this->lng->txt('timings_edit'));
00462                 $tpl->parseCurrentBlock();
00463                 return true;
00464         }
00468         function showPermanentLink(&$tpl)
00469         {
00470                 include_once('classes/class.ilLink.php');
00471                 $tpl->setCurrentBlock('perma_link');
00472                 $tpl->setVariable('PERMA_LINK',ilLink::_getStaticLink($this->object->getRefId(),$this->object->getType()));
00473                 $tpl->setVariable("TXT_PERMA_LINK", $this->lng->txt("perma_link"));
00474                 $tpl->setVariable("PERMA_TARGET", "_top");
00475                 $tpl->parseCurrentBlock();
00476 
00477                 /*              
00478                 $tpl->setCurrentBlock("perma_link");
00479                 $tpl->setVariable("PERMA_LINK", ILIAS_HTTP_PATH.
00480                         "/goto.php?target=".
00481                         $this->object->getType().
00482                         "_".$this->object->getRefId()."&client_id=".CLIENT_ID);
00483                 $tpl->setVariable("TXT_PERMA_LINK", $this->lng->txt("perma_link"));
00484                 $tpl->setVariable("PERMA_TARGET", "_top");
00485                 $tpl->parseCurrentBlock();
00486                 */
00487         }
00488 
00492         function editPageFrameObject()
00493         {
00494                 include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
00495                 $fs_gui = new ilFramesetGUI();
00496                 
00497                 $fs_gui->setFramesetTitle($this->object->getTitle());
00498                 $fs_gui->setMainFrameName("content");
00499                 $fs_gui->setSideFrameName("link_list");
00500                 
00501                 $fs_gui->setSideFrameSource(
00502                         $this->ctrl->getLinkTargetByClass("ilcontainerlinklistgui", "show"));
00503 
00504                 $fs_gui->setMainFrameSource(
00505                         $this->ctrl->getLinkTarget(
00506                                 $this, "editPageContent"));
00507                         
00508                 /* old xml page handling
00509                 $fs_gui->setMainFrameSource(
00510                         $this->ctrl->getLinkTargetByClass(
00511                                 array("ilpageobjectgui"), "view"));*/
00512                                 
00513                 $fs_gui->show();
00514                 exit;
00515         }
00516 
00522         function editPageContentObject()
00523         {
00524                 global $rbacsystem, $tpl;
00525 
00526                 if (!$rbacsystem->checkAccess("write", $this->ref_id))
00527                 {
00528                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00529                 }
00530                 
00531                 $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
00532                         "xhtml_page");
00533                 if ($xpage_id > 0)
00534                 {
00535                         include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
00536                         $xpage = new ilXHTMLPage($xpage_id);
00537                         $content = $xpage->getContent();
00538                 }
00539                 
00540                 // get template
00541                 $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.container_edit_page_content.html");
00542                 $tpl->setVariable("VAL_CONTENT", ilUtil::prepareFormOutput($content));
00543                 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00544                 $tpl->setVariable("TXT_EDIT_PAGE_CONTENT",
00545                         $this->lng->txt("edit_page_content"));
00546                 $tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
00547                 $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00548                 
00549                 include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
00550                 include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
00551                 //$ta = new ilTextAreaInputGUI();
00552                 //$tags = $ta->getRteTagSet("extended_table_img");
00553                 
00554                 // add rte support
00555                 include_once "./Services/RTE/classes/class.ilRTE.php";
00556                 $rtestring = ilRTE::_getRTEClassname();
00557                 include_once "./Services/RTE/classes/class.$rtestring.php";
00558                 $rte = new $rtestring();
00559                 //$rte->addPlugin("latex");
00560                 include_once "./classes/class.ilObject.php";
00561                 $obj_id = ilObject::_lookupObjectId($_GET["ref_id"]);
00562                 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
00563                 $rte->addRTESupport($obj_id, $obj_type);
00564                 //$rte->setStyleSelect(true);
00565                 //$rte->addCustomRTESupport($obj_id, $obj_type, $tags);
00566         }
00567         
00568         function savePageContentObject()
00569         {
00570                 include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
00571                 include_once "./classes/class.ilObjAdvancedEditing.php";
00572                 $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
00573                         "xhtml_page");
00574                 
00575                 /*include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
00576                 include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
00577                 $ta = new ilTextAreaInputGUI();
00578                 $ta->setRteTagSet("extended_table_img");
00579                 $tags = $ta->getRteTagString();*/
00580 
00581                 //$text = ilUtil::stripSlashes($_POST["page_content"],
00582                 //              true,
00583                 //              $tags);
00584                                 
00585                 $text = ilUtil::stripSlashes($_POST["page_content"],
00586                                 true,
00587                                 ilObjAdvancedEditing::_getUsedHTMLTagsAsString());
00588                 if ($xpage_id > 0)
00589                 {
00590                         $xpage = new ilXHTMLPage($xpage_id);
00591                         $xpage->setContent($text);
00592                         $xpage->save();
00593                 }
00594                 else
00595                 {
00596                         $xpage = new ilXHTMLPage();
00597                         $xpage->setContent($text);
00598                         $xpage->save();
00599                         ilContainer::_writeContainerSetting($this->object->getId(),
00600                                 "xhtml_page", $xpage->getId());
00601                 }
00602                 
00603                 include_once("Services/RTE/classes/class.ilRTE.php");
00604                 ilRTE::_cleanupMediaObjectUsage($text, $this->object->getType().":html",
00605                         $this->object->getId());
00606 
00607                 ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
00608                 $this->ctrl->redirect($this, "");
00609         }
00610         
00611         function cancelPageContentObject()
00612         {
00613                 ilUtil::sendInfo($this->lng->txt("action_aborted"), true);
00614                 $this->ctrl->redirect($this, "");
00615         }
00616 
00620         function getSubItems()
00621         {
00622                 global $objDefinition, $ilBench;
00623 
00624                 $objects = $this->tree->getChilds($this->object->getRefId(), "title");
00625 
00626                 $found = false;
00627 
00628                 include_once('Services/Container/classes/class.ilContainerSorting.php');
00629                 $sort = new ilContainerSorting($this->object->getId());
00630 
00631                 foreach ($objects as $key => $object)
00632                 {
00633 
00634                         // hide object types in devmode
00635                         if ($objDefinition->getDevMode($object["type"]))
00636                         {
00637                                 continue;
00638                         }
00639 
00640                         // group together types (e.g. ILIAS learning modules
00641                         // and SCORM learning modules to learning materials)
00642                         switch ($object["type"])
00643                         {
00644                                 // learning material
00645                                 case "sahs":
00646                                 case "lm":
00647                                 case "dbk":
00648                                 case "htlm":
00649                                         $type = "lres";
00650                                         break;
00651 
00652                                 default:
00653                                         $type = $object["type"];
00654                                         break;
00655                         }
00656                         
00657                         $this->items[$type][$key] = $object;
00658                 }
00659                 $this->items = $sort->sortTreeDataByType($this->items);
00660         }
00661 
00662         function renderItemList($a_type = "all")
00663         {
00664                 global $objDefinition, $ilBench, $ilSetting;
00665                 
00666                 include_once("classes/class.ilObjectListGUIFactory.php");
00667 
00668                 $output_html = "";
00669                 $this->clearAdminCommandsDetermination();
00670                 
00671                 switch ($a_type)
00672                 {
00673                         // render all items list
00674                         case "all":
00675                                                         
00676                                 $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
00677                                         "xhtml_page");
00678                                 if ($xpage_id > 0 && $ilSetting->get("enable_cat_page_edit"))
00679                                 {
00680                                         include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
00681                                         $xpage = new ilXHTMLPage($xpage_id);
00682                                         $output_html.= $xpage->getContent();
00683                                 }
00684 
00685 
00686                                 // all item types
00687                                 $type_ordering = array(
00688                                         "cat", "fold", "crs","rcrs", "icrs", "icla", "grp", "chat", "frm", "lres",
00689                                         "glo", "webr", "mcst", "file", "exc",
00690                                         "tst", "svy", "mep", "qpl", "spl");
00691 
00692                                 $cur_obj_type = "";
00693                                 $overall_tpl =& $this->newBlockTemplate();
00694                                 $this->type_template = array();
00695                                 $first = true;
00696                                 
00697                                 // iterate all types
00698                                 foreach ($type_ordering as $type)
00699                                 {
00700                                         // set template (overall or type specific)
00701                                         if (is_int(strpos($output_html, "[list-".$type."]")))
00702                                         {
00703                                                 $tpl =& $this->newBlockTemplate();
00704                                                 $overall = false;                       // individual
00705                                         }
00706                                         else
00707                                         {
00708                                                 $tpl =& $overall_tpl;
00709                                                 $overall = true;                        // put to the rest
00710                                         }
00711                                                 
00712                                         if (is_array($this->items[$type]))
00713                                         {
00714                                                 
00715                                                 $item_html = array();
00716 
00717                                                 foreach($this->items[$type] as $key => $item)
00718                                                 {
00719                                                         // get list gui class for each object type
00720                                                         if ($cur_obj_type != $item["type"])
00721                                                         {
00722                                                                 $item_list_gui =& ilObjectListGUIFactory::_getListGUIByType($item["type"]);
00723                                                                 $item_list_gui->setContainerObject($this);
00724                                                         }
00725                                                         // render item row
00726                                                         $ilBench->start("ilContainerGUI", "0210_getListHTML");
00727                                                         
00728                                                         // show administration command buttons (or not)
00729                                                         if (!$this->isActiveAdministrationPanel())
00730                                                         {
00731                                                                 $item_list_gui->enableDelete(false);
00732                                                                 $item_list_gui->enableLink(false);
00733                                                                 $item_list_gui->enableCut(false);
00734                                                         }
00735                                                         
00736                                                         $html = $item_list_gui->getListItemHTML($item["ref_id"],
00737                                                                 $item["obj_id"], $item["title"], $item["description"]);
00738                                                                 
00739                                                         // check whether any admin command is allowed for
00740                                                         // the items
00741                                                         $this->determineAdminCommands($item["ref_id"],
00742                                                                 $item_list_gui->adminCommandsIncluded());
00743                                                         $ilBench->stop("ilContainerGUI", "0210_getListHTML");
00744                                                         if ($html != "")
00745                                                         {
00746                                                                 $item_html[] = array("html" => $html, "item_ref_id" => $item["ref_id"]
00747                                                                         , "item_obj_id" => $item["obj_id"]);
00748                                                         }
00749                                                 }
00750 
00751                                                 // output block for resource type
00752                                                 if (count($item_html) > 0)
00753                                                 {
00754                                                         // separator row
00755                                                         if (!$first && $overall)
00756                                                         {
00757                                                                 $this->addSeparatorRow($tpl);
00758                                                         }
00759                                                         
00760                                                         if ($overall)
00761                                                         {
00762                                                                 $first = false;
00763                                                         }
00764 
00765                                                         // add a header for each resource type
00766                                                         if ($this->ilias->getSetting("icon_position_in_lists") == "item_rows")
00767                                                         {
00768                                                                 $this->addHeaderRow($tpl, $type, false);
00769                                                         }
00770                                                         else
00771                                                         {
00772                                                                 $this->addHeaderRow($tpl, $type);
00773                                                         }
00774                                                         $this->resetRowType();
00775 
00776                                                         // content row
00777                                                         $this->current_position = 1;
00778                                                         foreach($item_html as $item)
00779                                                         {
00780                                                                 $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],$type);
00781                                                         }
00782 
00783                                                         // store type specific templates in array
00784                                                         if (is_int(strpos($output_html, "[list-".$type."]")))
00785                                                         {
00786                                                                 $this->type_template[$type] = $tpl;
00787                                                         }
00788                                                 }
00789                                                 else
00790                                                 {
00791                                                         // [list-...] tag available, but no item of type accessible
00792                                                         if (!$overall)
00793                                                         {
00794                                                                 $this->addHeaderRow($tpl, $type);
00795                                                                 $this->resetRowType();
00796                                                                 $this->addMessageRow($tpl, 
00797                                                                         $this->lng->txt("msg_no_type_accessible"), $type);
00798                                                                 $this->type_template[$type] = $tpl;
00799                                                         }
00800                                                 }
00801                                         }
00802                                         else
00803                                         {
00804                                                 // [list-...] tag available, but no item of type exists
00805                                                 if (!$overall)
00806                                                 {
00807                                                         $this->addHeaderRow($tpl, $type);
00808                                                         $this->resetRowType();
00809                                                         $this->addMessageRow($tpl,
00810                                                                 $this->lng->txt("msg_no_type_available"), $type);
00811                                                         $this->type_template[$type] = $tpl;
00812                                                 }
00813                                         }
00814 
00815                                 }
00816 
00817 
00818                                 // I don't know why but executing this
00819                                 // line before the following foreach loop seems to be crucial
00820                                 if ($output_html != "")
00821                                 {
00822                                         //$output_html.= "<br /><br />";
00823                                 }
00824                                 $output_html.= $overall_tpl->get();
00825                                 //$output_html = str_replace("<br>++", "++", $output_html);
00826                                 //$output_html = str_replace("<br>++", "++", $output_html);
00827                                 //$output_html = str_replace("++<br>", "++", $output_html);
00828                                 //$output_html = str_replace("++<br>", "++", $output_html);
00829                                 foreach ($this->type_template as $type => $tpl)
00830                                 {
00831                                         $output_html = eregi_replace("\[list-".$type."\]",
00832                                                 "</p>".$tpl->get()."<p class=\"ilc_Standard\">",
00833                                                 $output_html);
00834                                 }
00835 
00836                                 //if (ilPageObject::_exists($this->object->getType(),
00837                                 //      $this->object->getId()))
00838                                 if ($xpage_id > 0)
00839                                 {                               
00840                                         $page_block = new ilTemplate("tpl.container_page_block.html", false, false);
00841                                         $page_block->setVariable("CONTAINER_PAGE_CONTENT", $output_html);
00842                                         $output_html = $page_block->get();
00843                                 }
00844 
00845                                 break;
00846 
00847                         default:
00848                                 // to do:
00849                                 break;
00850                 }
00851                 return $output_html;
00852         }
00853 
00857         function clearAdminCommandsDetermination()
00858         {
00859                 $this->adminCommands = false;
00860         }
00861         
00865         function determineAdminCommands($a_ref_id, $a_admin_com_included_in_list = false)
00866         {
00867                 if (!$this->adminCommands)
00868                 {
00869                         if (!$this->isActiveAdministrationPanel())
00870                         {
00871                                 if ($this->rbacsystem->checkAccess("delete", $a_ref_id))
00872                                 {
00873                                         $this->adminCommands = true;
00874                                 }
00875                         }
00876                         else
00877                         {
00878                                 $this->adminCommands = $a_admin_com_included_in_list;
00879                         }
00880                 }
00881         }
00882 
00889         function &newBlockTemplate()
00890         {
00891                 $tpl = new ilTemplate ("tpl.container_list_block.html", true, true);
00892                 $this->cur_row_type = "row_type_1";
00893                 return $tpl;
00894         }
00895 
00903         function addHeaderRow(&$a_tpl, $a_type, $a_show_image = true)
00904         {
00905                 if ($a_type != "lres")
00906                 {
00907                         $icon = ilUtil::getImagePath("icon_".$a_type.".gif");
00908                         $title = $this->lng->txt("objs_".$a_type);
00909                 }
00910                 else
00911                 {
00912                         $icon = ilUtil::getImagePath("icon_lm.gif");
00913                         $title = $this->lng->txt("learning_resources");
00914                 }
00915                 
00916                 if ($a_show_image)
00917                 {
00918                         $a_tpl->setCurrentBlock("container_header_row_image");
00919                         $a_tpl->setVariable("HEADER_IMG", $icon);
00920                         $a_tpl->setVariable("HEADER_ALT", $title);
00921                 }
00922                 else
00923                 {
00924                         $a_tpl->setCurrentBlock("container_header_row");
00925                 }
00926                 
00927                 $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
00928                 $a_tpl->parseCurrentBlock();
00929                 $a_tpl->touchBlock("container_row");
00930         }
00931 
00939         function addStandardRow(&$a_tpl, $a_html, $a_item_ref_id = "", $a_item_obj_id = "",
00940                 $a_image_type = "")
00941         {
00942                 $this->cur_row_type = ($this->cur_row_type == "row_type_1")
00943                         ? "row_type_2"
00944                         : "row_type_1";
00945 
00946                 $a_tpl->touchBlock($this->cur_row_type);
00947                 
00948                 $nbsp = true;
00949                 if ($this->ilias->getSetting("icon_position_in_lists") == "item_rows")
00950                 {
00951                         if ($a_image_type != "lres")
00952                         {
00953                                 $icon = ilUtil::getImagePath("icon_".$a_image_type.".gif");
00954                                 $alt = $this->lng->txt("obj_".$a_image_type);
00955                         }
00956                         else
00957                         {
00958                                 $icon = ilUtil::getImagePath("icon_lm.gif");
00959                                 $alt = $this->lng->txt("learning_resource");
00960                         }
00961                         
00962                         // custom icon
00963                         if ($this->ilias->getSetting("custom_icons") &&
00964                                 in_array($a_image_type, array("cat","grp","crs")))
00965                         {
00966                                 require_once("classes/class.ilContainer.php");
00967                                 if (($path = ilContainer::_lookupIconPath($a_item_obj_id, "small")) != "")
00968                                 {
00969                                         $icon = $path;
00970                                 }
00971                         }
00972 
00973                         $a_tpl->setCurrentBlock("block_row_image");
00974                         $a_tpl->setVariable("ROW_IMG", $icon);
00975                         $a_tpl->setVariable("ROW_ALT", $alt);
00976                         $a_tpl->parseCurrentBlock();
00977                         $nbsp = false;
00978                 }
00979 
00980                 if ($this->isActiveAdministrationPanel())
00981                 {
00982                         $a_tpl->setCurrentBlock("block_row_check");
00983                         $a_tpl->setVariable("ITEM_ID", $a_item_ref_id);
00984                         $a_tpl->parseCurrentBlock();
00985                         $nbsp = false;
00986                 }
00987                 include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
00988                 if($this->isActiveAdministrationPanel() && 
00989                         ilContainerSortingSettings::_lookupSortMode($this->object->getId()) == ilContainerSortingSettings::MODE_MANUAL)
00990                 {
00991                         $a_tpl->setCurrentBlock('block_position');
00992                         $a_tpl->setVariable('POS_TYPE',$a_image_type);
00993                         $a_tpl->setVariable('POS_ID',$a_item_ref_id);
00994                         $a_tpl->setVariable('POSITION',sprintf('%.1f',$this->current_position++));
00995                         $a_tpl->parseCurrentBlock();
00996                 }
00997                 if ($nbsp)
00998                 {
00999                         $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
01000                 }
01001                 $a_tpl->setCurrentBlock("container_standard_row");
01002                 $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
01003                 $a_tpl->parseCurrentBlock();
01004                 $a_tpl->touchBlock("container_row");
01005         }
01006 
01010         function addMessageRow(&$a_tpl, $a_message, $a_type)
01011         {
01012                 $this->cur_row_type = ($this->cur_row_type == "row_type_1")
01013                         ? "row_type_2"
01014                         : "row_type_1";
01015 
01016                 $a_tpl->touchBlock($this->cur_row_type);
01017                 
01018                 if ($a_type != "lres")
01019                 {
01020                         $type = $this->lng->txt("obj_".$a_type);
01021                 }
01022                 else
01023                 {
01024                         $type = $this->lng->txt("learning_resource");
01025                 }
01026                 $a_message = str_replace("[type]", $type, $a_message);
01027                 
01028                 $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
01029 
01030                 $a_tpl->setCurrentBlock("container_standard_row");
01031                 $a_tpl->setVariable("BLOCK_ROW_CONTENT",
01032                         $a_message);
01033                 $a_tpl->parseCurrentBlock();
01034                 $a_tpl->touchBlock("container_row");
01035         }
01036 
01037         function resetRowType()
01038         {
01039                 $this->cur_row_type = "";
01040         }
01041 
01042         function addSeparatorRow(&$a_tpl)
01043         {
01044                 $a_tpl->touchBlock("separator_row");
01045                 $a_tpl->touchBlock("container_row");
01046         }
01047         
01048         function setPageEditorTabs()
01049         {
01050                 global $lng;
01051                 
01052                 if (!$this->isActiveAdministrationPanel()
01053                         || strtolower($this->ctrl->getCmdClass()) != "ilpageobjectgui")
01054                 {
01055                         return;
01056                 }
01057 
01058                 $lng->loadLanguageModule("content");
01059                 //$tabs_gui = new ilTabsGUI();
01060                 //$tabs_gui->setSubTabs();
01061                 
01062                 // back to upper context
01063                 $this->tabs_gui->setBackTarget($this->lng->txt("obj_cat"),
01064                         $this->ctrl->getLinkTarget($this, "frameset"),
01065                         ilFrameTargetInfo::_getFrame("MainContent"));
01066 
01067                 $this->tabs_gui->addTarget("edit", $this->ctrl->getLinkTargetByClass("ilpageobjectgui", "view")
01068                         , array("", "view"), "ilpageobjectgui");
01069 
01070                 //$this->tpl->setTabs($tabs_gui->getHTML());
01071         }
01072 
01073 
01078         function getTabs(&$tabs_gui)
01079         {
01080                 global $rbacsystem;
01081 
01082                 // edit permissions
01083                 if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
01084                 {
01085                         $tabs_gui->addTarget("perm_settings",
01086                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
01087                 }
01088 
01089                 // show clipboard
01090                 if ($this->ctrl->getTargetScript() == "repository.php" and !empty($_SESSION["clipboard"]))
01091                 {
01092                         $tabs_gui->addTarget("clipboard",
01093                                  $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
01094                 }
01095 
01096         }
01097 
01098         //*****************
01099         // COMMON METHODS (may be overwritten in derived classes
01100         // if special handling is necessary)
01101         //*****************
01102 
01106         function enableAdministrationPanelObject()
01107         {
01108                 $_SESSION["il_cont_admin_panel"] = true;
01109                 $this->ctrl->redirect($this, "render");
01110         }
01111 
01115         function disableAdministrationPanelObject()
01116         {
01117                 $_SESSION["il_cont_admin_panel"] = false;
01118                 $this->ctrl->redirect($this, "render");
01119         }
01120         
01124         function addToDeskObject()
01125         {
01126                 if ($_GET["item_ref_id"] and $_GET["type"])
01127                 {
01128                         $this->ilias->account->addDesktopItem($_GET["item_ref_id"], $_GET["type"]);
01129                 }
01130                 else
01131                 {
01132                         if ($_POST["items"])
01133                         {
01134                                 foreach ($_POST["items"] as $item)
01135                                 {
01136                                         $type = ilObject::_lookupType($item, true);
01137                                         $this->ilias->account->addDesktopItem($item, $type);
01138                                 }
01139                         }
01140                 }
01141                 $this->renderObject();
01142         }
01143 
01147         function removeFromDeskObject()
01148         {
01149                 if ($_GET["item_ref_id"] and $_GET["type"])
01150                 {
01151                         $this->ilias->account->dropDesktopItem($_GET["item_ref_id"], $_GET["type"]);
01152                 }
01153                 else
01154                 {
01155                         if ($_POST["items"])
01156                         {
01157                                 foreach ($_POST["items"] as $item)
01158                                 {
01159                                         $type = ilObject::_lookupType($item, true);
01160                                         $this->ilias->account->dropDesktopItem($item, $type);
01161                                         unset($tmp_obj);
01162                                 }
01163                         }
01164                 }
01165                 $this->renderObject();
01166         }
01167 
01168 
01175         function cutObject()
01176         {
01177                 global $rbacsystem;
01178                 
01179                 if ($_GET["item_ref_id"] != "")
01180                 {
01181                         $_POST["id"] = array($_GET["item_ref_id"]);
01182                 }
01183 
01184                 //$this->ilias->raiseError("move operation does not work at the moment and is disabled",$this->ilias->error_obj->MESSAGE);
01185 
01186 //echo "CUT";
01187 //echo $_SESSION["referer"];
01188                 if (!isset($_POST["id"]))
01189                 {
01190                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01191                 }
01192 
01193                 // FOR ALL OBJECTS THAT SHOULD BE COPIED
01194                 foreach ($_POST["id"] as $ref_id)
01195                 {
01196                         // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
01197                         $node_data = $this->tree->getNodeData($ref_id);
01198                         $subtree_nodes = $this->tree->getSubTree($node_data);
01199 
01200                         $all_node_data[] = $node_data;
01201                         $all_subtree_nodes[] = $subtree_nodes;
01202 
01203                         // CHECK DELETE PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
01204                         foreach ($subtree_nodes as $node)
01205                         {
01206                                 if($node['type'] == 'rolf')
01207                                 {
01208                                         continue;
01209                                 }
01210                                 
01211                                 if (!$rbacsystem->checkAccess('delete',$node["ref_id"]))
01212                                 {
01213                                         $no_cut[] = $node["ref_id"];
01214                                 }
01215                         }
01216                 }
01217                 // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'delete'
01218                 if (count($no_cut))
01219                 {
01220                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_cut")." ".implode(',',$this->getTitlesByRefId($no_cut)),
01221                                                                          $this->ilias->error_obj->MESSAGE);
01222                 }
01223                 //echo "GET";var_dump($_GET);echo "POST";var_dump($_POST);
01224                 $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
01225                 $_SESSION["clipboard"]["cmd"] = ($_GET["cmd"] != "" && $_GET["cmd"] != "post")
01226                         ? $_GET["cmd"]
01227                         : key($_POST["cmd"]);
01228 //echo "-".$clipboard["cmd"]."-";
01229                 $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
01230 //echo "-".$_SESSION["clipboard"]["cmd"]."-";
01231 
01232                 ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"),true);
01233 
01234                 $this->ctrl->returnToParent($this);
01235 
01236         } // END CUT
01237 
01238 
01245         function linkObject()
01246         {
01247                 global $clipboard, $rbacsystem, $rbacadmin;
01248                 
01249                 if ($_GET["item_ref_id"] != "")
01250                 {
01251                         $_POST["id"] = array($_GET["item_ref_id"]);
01252                 }
01253 
01254                 if (!isset($_POST["id"]))
01255                 {
01256                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01257                 }
01258 
01259                 // CHECK ACCESS
01260                 foreach ($_POST["id"] as $ref_id)
01261                 {
01262                         if (!$rbacsystem->checkAccess('delete',$ref_id))
01263                         {
01264                                 $no_cut[] = $ref_id;
01265                         }
01266 
01267                         $object =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
01268 
01269                         if (!$this->objDefinition->allowLink($object->getType()))
01270                         {
01271                                 $no_link[] = $object->getType();
01272                         }
01273                 }
01274 
01275                 // NO ACCESS
01276                 if (count($no_cut))
01277                 {
01278                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_link")." ".
01279                                                                          implode(',',$no_cut),$this->ilias->error_obj->MESSAGE);
01280                 }
01281 
01282                 if (count($no_link))
01283                 {
01284                         $no_link = array_unique($no_link);
01285 
01286                         foreach ($no_link as $type)
01287                         {
01288                                 $txt_objs[] = $this->lng->txt("objs_".$type);
01289                         }
01290 
01291                         $this->ilias->raiseError(implode(', ',$txt_objs)." ".$this->lng->txt("msg_obj_no_link"),$this->ilias->error_obj->MESSAGE);
01292 
01293                         //$this->ilias->raiseError($this->lng->txt("msg_not_possible_link")." ".
01294                         //                                               implode(',',$no_link),$this->ilias->error_obj->MESSAGE);
01295                 }
01296 
01297                 // WRITE TO CLIPBOARD
01298                 $clipboard["parent"] = $_GET["ref_id"];
01299                 $clipboard["cmd"] = ($_GET["cmd"] != "" && $_GET["cmd"] != "post")
01300                         ? $_GET["cmd"]
01301                         : key($_POST["cmd"]);
01302 
01303                 foreach ($_POST["id"] as $ref_id)
01304                 {
01305                         $clipboard["ref_ids"][] = $ref_id;
01306                 }
01307 
01308                 $_SESSION["clipboard"] = $clipboard;
01309 
01310                 ilUtil::sendInfo($this->lng->txt("msg_link_clipboard"),true);
01311 
01312                 $this->ctrl->returnToParent($this);
01313 
01314         } // END LINK
01315 
01316 
01322         function clearObject()
01323         {
01324                 unset($_SESSION["clipboard"]);
01325                 unset($_SESSION["il_rep_clipboard"]);
01326                 //var_dump($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
01327 
01328                 // only redirect if clipboard was cleared
01329                 if (isset($_POST["cmd"]["clear"]))
01330                 {
01331                         ilUtil::sendInfo($this->lng->txt("msg_clear_clipboard"),true);
01332 
01333                         $this->ctrl->returnToParent($this);
01334                         //ilUtil::redirect($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
01335                 }
01336         }
01337 
01344         function pasteObject()
01345         {
01346                 global $rbacsystem, $rbacadmin, $rbacreview, $log,$tree;
01347 
01348 //var_dump($_SESSION["clipboard"]);exit;
01349                 if (!in_array($_SESSION["clipboard"]["cmd"],array("cut","link","copy")))
01350                 {
01351                         $message = get_class($this)."::pasteObject(): cmd was neither 'cut','link' or 'copy'; may be a hack attempt!";
01352                         $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
01353                 }
01354 
01355                 // this loop does all checks
01356                 foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id)
01357                 {
01358                         $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
01359 
01360                         // CHECK ACCESS
01361                         if (!$rbacsystem->checkAccess('create',$this->object->getRefId(), $obj_data->getType()))
01362                         {
01363                                 $no_paste[] = $ref_id;
01364                         }
01365 
01366                         // CHECK IF REFERENCE ALREADY EXISTS
01367                         if ($this->object->getRefId() == $this->tree->getParentId($obj_data->getRefId()))
01368                         {
01369                                 $exists[] = $ref_id;
01370                                 break;
01371                         }
01372 
01373                         // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
01374                         if ($this->tree->isGrandChild($ref_id,$this->object->getRefId()))
01375                         {
01376                                 $is_child[] = $ref_id;
01377                         }
01378 
01379                         // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
01380                         $obj_type = $obj_data->getType();
01381 
01382                         if (!in_array($obj_type, array_keys($this->objDefinition->getSubObjects($this->object->getType()))))
01383                         {
01384                                 $not_allowed_subobject[] = $obj_data->getType();
01385                         }
01386                 }
01387 
01389                 // process checking results
01390                 if (count($exists))
01391                 {
01392                         $this->ilias->raiseError($this->lng->txt("msg_obj_exists"),$this->ilias->error_obj->MESSAGE);
01393                 }
01394 
01395                 if (count($is_child))
01396                 {
01397                         $this->ilias->raiseError($this->lng->txt("msg_not_in_itself")." ".implode(',',$is_child),
01398                                                                          $this->ilias->error_obj->MESSAGE);
01399                 }
01400 
01401                 if (count($not_allowed_subobject))
01402                 {
01403                         $this->ilias->raiseError($this->lng->txt("msg_may_not_contain")." ".implode(',',$not_allowed_subobject),
01404                                                                          $this->ilias->error_obj->MESSAGE);
01405                 }
01406 
01407                 if (count($no_paste))
01408                 {
01409                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste")." ".
01410                                                                          implode(',',$no_paste),$this->ilias->error_obj->MESSAGE);
01411                 }
01412 
01413                 // log pasteObject call
01414                 $log->write("ilObjectGUI::pasteObject(), cmd: ".$_SESSION["clipboard"]["cmd"]);
01415 
01417                 // everything ok: now paste the objects to new location
01418 
01419                 // to prevent multiple actions via back/reload button
01420                 $ref_ids = $_SESSION["clipboard"]["ref_ids"];
01421                 unset($_SESSION["clipboard"]["ref_ids"]);
01422 
01423 
01424                 // process CUT command
01425                 if ($_SESSION["clipboard"]["cmd"] == "cut")
01426                 {
01427                         
01428                         foreach($ref_ids as $ref_id)
01429                         {
01430                                 // Store old parent
01431                                 $old_parent = $tree->getParentId($ref_id);
01432                                 $this->tree->moveTree($ref_id,$this->object->getRefId());
01433                                 $rbacadmin->adjustMovedObjectPermissions($ref_id,$old_parent);
01434                                 
01435                                 include_once('classes/class.ilConditionHandler.php');
01436                                 ilConditionHandler::_adjustMovedObjectConditions($ref_id);
01437                         }
01438                         
01439                         /*
01440                         // get subtrees
01441                         foreach($ref_ids as $ref_id)
01442                         {
01443                                 // get node data
01444                                 $top_node = $this->tree->getNodeData($ref_id);
01445 
01446                                 // get subnodes of top nodes
01447                                 $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
01448                         }
01449 
01450                         // STEP 1: Move all subtrees to trash
01451                         $log->write("ilObjectGUI::pasteObject(), (1/3) move subtrees to trash");
01452 
01453                         foreach($ref_ids as $ref_id)
01454                         {
01455                                 $tnodes = $this->tree->getSubtree($this->tree->getNodeData($ref_id));
01456 
01457                                 foreach ($tnodes as $tnode)
01458                                 {
01459                                         $rbacadmin->revokePermission($tnode["child"],0,false);
01460                                         
01461                                         // we don't remove the item from the personal desktop,
01462                                         // just due to moving it
01463                                         //$affected_users = ilUtil::removeItemFromDesktops($tnode["child"]);
01464                                 }
01465 
01466                                 $this->tree->saveSubTree($ref_id);
01467                                 $this->tree->deleteTree($this->tree->getNodeData($ref_id));
01468                         }
01469 
01470                         // STEP 2: Move all subtrees to new location
01471                         $log->write("ilObjectGUI::pasteObject(), (2/3) move subtrees to new location");
01472 
01473                         // TODO: this whole put in place again stuff needs revision. Permission settings get lost.
01474                         foreach ($subnodes as $key => $subnode)
01475                         {
01476 $log->write("ilObjectGUI::pasteObject(), 0");
01477                                 // first paste top_node ...
01478                                 $rbacadmin->revokePermission($key,0,false);
01479 $log->write("ilObjectGUI::pasteObject(), 1");
01480                                 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
01481 $log->write("ilObjectGUI::pasteObject(), 2");
01482                                 $obj_data->putInTree($this->object->getRefId());
01483 $log->write("ilObjectGUI::pasteObject(), 3");
01484                                 $obj_data->setPermissions($key);
01485 $log->write("ilObjectGUI::pasteObject(), 4");
01486                                 // log entry
01487                                 $log->write("ilObjectGUI::pasteObject(), inserted top node. ref_id: $key,".
01488                                         " rgt: ".$subnode[0]["rgt"].", lft: ".$subnode[0]["lft"].", parent: ".$subnode[0]["parent"].",".
01489                                         " obj_id: ".$obj_data->getId().", type: ".$obj_data->getType().
01490                                         ", title: ".$obj_data->getTitle());
01491 
01492                                 // ... remove top_node from list ...
01493                                 array_shift($subnode);
01494 
01495                                 // ... insert subtree of top_node if any subnodes exist
01496                                 if (count($subnode) > 0)
01497                                 {
01498                                         foreach ($subnode as $node)
01499                                         {
01500                                                 $rbacadmin->revokePermission($node["child"],0,false);
01501                                                 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
01502                                                 $obj_data->putInTree($node["parent"]);
01503                                                 $obj_data->setPermissions($node["parent"]);
01504 
01505                                                 // log entry
01506                                                 $log->write("ilObjectGUI::pasteObject(), inserted subnode. ref_id: ".$node["child"].",".
01507                                                         " rgt: ".$node["rgt"].", lft: ".$node["lft"].", parent: ".$node["parent"].",".
01508                                                         " obj_id: ".$obj_data->getId().", type: ".$obj_data->getType().
01509                                                         ", title: ".$obj_data->getTitle());
01510                                         }
01511                                 }
01512                         }
01513 
01514                         // STEP 3: Remove trashed objects from system
01515                         $log->write("ilObjectGUI::pasteObject(), (3/3) remove trashed subtrees from system");
01516 
01517                         foreach ($ref_ids as $ref_id)
01518                         {
01519                                 // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
01520                                 $saved_tree = new ilTree(-(int)$ref_id);
01521                                 $node_data = $saved_tree->getNodeData($ref_id);
01522                                 $subtree_nodes = $saved_tree->getSubTree($node_data);
01523 
01524                                 // remember already checked deleted node_ids
01525                                 $checked[] = -(int) $ref_id;
01526 
01527                                 // dive in recursive manner in each already deleted subtrees and remove these objects too
01528                                 $this->removeDeletedNodes($ref_id, $checked, false);
01529 
01530                                 // delete save tree
01531                                 $this->tree->deleteTree($node_data);
01532 
01533                                 // write log entry
01534                                 $log->write("ilObjectGUI::pasteObject(), deleted tree, tree_id: ".$node_data["tree"].
01535                                         ", child: ".$node_data["child"]);
01536                         }
01537 
01538 
01539                         $log->write("ilObjectGUI::pasteObject(), cut finished");
01540 
01541                         // inform other objects in hierarchy about paste operation
01542                         //$this->object->notify("paste",$this->object->getRefId(),$_SESSION["clipboard"]["parent_non_rbac_id"],$this->object->getRefId(),$subnodes);
01543 
01544                         // inform other objects in hierarchy about cut operation
01545                         // the parent object where cut occured
01546                         $tmp_object = $this->ilias->obj_factory->getInstanceByRefId($_SESSION["clipboard"]["parent"]);
01547                         //$tmp_object->notify("cut", $tmp_object->getRefId(),$_SESSION["clipboard"]["parent_non_rbac_id"],$tmp_object->getRefId(),$ref_ids);
01548                         unset($tmp_object);
01549                         
01550                         */
01551                         
01552                 } // END CUT
01553 
01554                 // process LINK command
01555                 if ($_SESSION["clipboard"]["cmd"] == "link")
01556                 {
01557                         foreach ($ref_ids as $ref_id)
01558                         {
01559                                 // get node data
01560                                 $top_node = $this->tree->getNodeData($ref_id);
01561 
01562                                 // get subnodes of top nodes
01563                                 $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
01564                         }
01565 
01566                         // now move all subtrees to new location
01567                         foreach ($subnodes as $key => $subnode)
01568                         {
01569                                 // first paste top_node....
01570                                 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
01571                                 $new_ref_id = $obj_data->createReference();
01572                                 $obj_data->putInTree($_GET["ref_id"]);
01573                                 $obj_data->setPermissions($_GET["ref_id"]);
01574 
01575                                 // ... remove top_node from list ...
01576                                 array_shift($subnode);
01577 
01578                                 // ... store mapping of old ref_id => new_ref_id in hash array ...
01579                                 $mapping[$new_ref_id] = $key;
01580 
01581                                 // save old ref_id & create rolefolder if applicable
01582                                 $old_ref_id = $obj_data->getRefId();
01583                                 $obj_data->setRefId($new_ref_id);
01584                                 $obj_data->initDefaultRoles();
01585                                 $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
01586 
01587                                 if (isset($rolf_data["child"]))
01588                                 {
01589                                         // a role folder was created, so map it to old role folder
01590                                         $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
01591 
01592                                         // ... use mapping array to find out the correct new parent node where to put in the node...
01593                                         //$new_parent = array_search($node["parent"],$mapping);
01594                                         // ... append node to mapping for further possible subnodes ...
01595                                         $mapping[$rolf_data["child"]] = (int) $rolf_data_old["child"];
01596 
01597                                         // log creation of role folder
01598                                         $log->write("ilObjectGUI::pasteObject(), created role folder (ref_id): ".$rolf_data["child"].
01599                                                 ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
01600                                                 ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
01601 
01602                                 }
01603 
01604                                 // ... insert subtree of top_node if any subnodes exist ...
01605                                 if (count($subnode) > 0)
01606                                 {
01607                                         foreach ($subnode as $node)
01608                                         {
01609                                                 if ($node["type"] != 'rolf')
01610                                                 {
01611                                                         $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
01612                                                         $new_ref_id = $obj_data->createReference();
01613 
01614                                                         // ... use mapping array to find out the correct new parent node where to put in the node...
01615                                                         $new_parent = array_search($node["parent"],$mapping);
01616                                                         // ... append node to mapping for further possible subnodes ...
01617                                                         $mapping[$new_ref_id] = (int) $node["child"];
01618 
01619                                                         $obj_data->putInTree($new_parent);
01620                                                         $obj_data->setPermissions($new_parent);
01621 
01622                                                         // save old ref_id & create rolefolder if applicable
01623                                                         $old_ref_id = $obj_data->getRefId();
01624                                                         $obj_data->setRefId($new_ref_id);
01625                                                         $obj_data->initDefaultRoles();
01626                                                         $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
01627 
01628                                                         if (isset($rolf_data["child"]))
01629                                                         {
01630                                                                 // a role folder was created, so map it to old role folder
01631                                                                 $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
01632 
01633                                                                 // ... use mapping array to find out the correct new parent node where to put in the node...
01634                                                                 //$new_parent = array_search($node["parent"],$mapping);
01635                                                                 // ... append node to mapping for further possible subnodes ...
01636                                                                 $mapping[$rolf_data["child"]] = (int) $rolf_data_old["child"];
01637 
01638                                                                 // log creation of role folder
01639                                                                 $log->write("ilObjectGUI::pasteObject(), created role folder (ref_id): ".$rolf_data["child"].
01640                                                                         ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
01641                                                                         ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
01642 
01643                                                         }
01644                                                 }
01645 
01646                                                 // re-map $subnodes
01647                                                 foreach ($subnodes as $old_ref => $subnode)
01648                                                 {
01649                                                         $new_ref = array_search($old_ref,$mapping);
01650 
01651                                                         foreach ($subnode as $node)
01652                                                         {
01653                                                                 $node["child"] = array_search($node["child"],$mapping);
01654                                                                 $node["parent"] = array_search($node["parent"],$mapping);
01655                                                                 $new_subnodes[$ref_id][] = $node;
01656                                                         }
01657                                                 }
01658 
01659                                         }
01660                                 }
01661                         }
01662 
01663                         $log->write("ilObjectGUI::pasteObject(), link finished");
01664 
01665                         // inform other objects in hierarchy about link operation
01666                         //$this->object->notify("link",$this->object->getRefId(),$_SESSION["clipboard"]["parent_non_rbac_id"],$this->object->getRefId(),$subnodes);
01667                 } // END LINK
01668 
01669                 // save cmd for correct message output after clearing the clipboard
01670                 $last_cmd = $_SESSION["clipboard"]["cmd"];
01671 
01672 
01673                 // clear clipboard
01674                 $this->clearObject();
01675 
01676                 if ($last_cmd == "cut")
01677                 {
01678                         ilUtil::sendInfo($this->lng->txt("msg_cut_copied"),true);
01679                 }
01680                 else
01681                 {
01682                         ilUtil::sendInfo($this->lng->txt("msg_linked"),true);
01683                 }
01684 
01685                 $this->ctrl->returnToParent($this);
01686 
01687         } // END PASTE
01688 
01689 
01690 
01694         function clipboardObject()
01695         {
01696                 global $ilErr,$ilLog;
01697 
01698                 // function should not be called if clipboard is empty
01699                 if (empty($_SESSION['clipboard']) or !is_array($_SESSION['clipboard']))
01700                 {
01701                         $message = sprintf('%s::clipboardObject(): Illegal access. Clipboard variable is empty!', get_class($this));
01702                         $ilLog->write($message,$ilLog->FATAL);
01703                         $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->WARNING);
01704                 }
01705 
01706                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.rep_clipboard.html");
01707 
01708                 // FORMAT DATA
01709                 $counter = 0;
01710                 $f_result = array();
01711 
01712                 foreach($_SESSION["clipboard"]["ref_ids"] as $ref_id)
01713                 {
01714                         if(!$tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id,false))
01715                         {
01716                                 continue;
01717                         }
01718 
01719                         //$f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user);
01720                         $f_result[$counter][] = $this->lng->txt("obj_".$tmp_obj->getType());
01721                         $f_result[$counter][] = $tmp_obj->getTitle();
01722                         //$f_result[$counter][] = $tmp_obj->getDescription();
01723                         $f_result[$counter][] = ($_SESSION["clipboard"]["cmd"] == "cut") ? $this->lng->txt("move") :$this->lng->txt($_SESSION["clipboard"]["cmd"]);
01724 
01725                         unset($tmp_obj);
01726                         ++$counter;
01727                 }
01728 
01729                 $this->__showClipboardTable($f_result, "clipboardObject");
01730 
01731                 return true;
01732         }
01733 
01734         
01739         function showCustomIconsEditing($a_input_colspan = 1)
01740         {
01741                 if ($this->ilias->getSetting("custom_icons"))
01742                 {
01743                         $this->tpl->addBlockFile("CONTAINER_ICONS", "container_icon_settings",
01744                                 "tpl.container_icon_settings.html");
01745 
01746                         if (($big_icon = $this->object->getBigIconPath()) != "")
01747                         {
01748                                 $this->tpl->setCurrentBlock("big_icon");
01749                                 $this->tpl->setVariable("SRC_BIG_ICON", $big_icon);
01750                                 $this->tpl->parseCurrentBlock();
01751                         }
01752                         if (($small_icon = $this->object->getSmallIconPath()) != "")
01753                         {
01754                                 $this->tpl->setCurrentBlock("small_icon");
01755                                 $this->tpl->setVariable("SRC_SMALL_ICON", $small_icon);
01756                                 $this->tpl->parseCurrentBlock();
01757                         }
01758                         if (($tiny_icon = $this->object->getTinyIconPath()) != "")
01759                         {
01760                                 $this->tpl->setCurrentBlock("tiny_icon");
01761                                 $this->tpl->setVariable("SRC_TINY_ICON", $tiny_icon);
01762                                 $this->tpl->parseCurrentBlock();
01763                         }
01764                         $this->tpl->setCurrentBlock("container_icon_settings");
01765                         $this->tpl->setVariable("SPAN_TITLE", $a_input_colspan + 1);
01766                         $this->tpl->setVariable("SPAN_INPUT", $a_input_colspan);
01767                         $this->tpl->setVariable("ICON_SETTINGS", $this->lng->txt("icon_settings"));
01768                         $this->tpl->setVariable("BIG_ICON", $this->lng->txt("big_icon"));
01769                         $this->tpl->setVariable("SMALL_ICON", $this->lng->txt("standard_icon"));
01770                         $this->tpl->setVariable("TINY_ICON", $this->lng->txt("tiny_icon"));
01771                         $this->tpl->setVariable("BIG_SIZE", "(".
01772                                 $this->ilias->getSetting("custom_icon_big_width")."x".
01773                                 $this->ilias->getSetting("custom_icon_big_height").")");
01774                         $this->tpl->setVariable("SMALL_SIZE", "(".
01775                                 $this->ilias->getSetting("custom_icon_small_width")."x".
01776                                 $this->ilias->getSetting("custom_icon_small_height").")");
01777                         $this->tpl->setVariable("TINY_SIZE", "(".
01778                                 $this->ilias->getSetting("custom_icon_tiny_width")."x".
01779                                 $this->ilias->getSetting("custom_icon_tiny_height").")");
01780                         $this->tpl->setVariable("TXT_REMOVE", $this->lng->txt("remove"));
01781                         $this->tpl->parseCurrentBlock();
01782                 }
01783         }
01784 
01785         function isActiveAdministrationPanel()
01786         {
01787                 return $_SESSION["il_cont_admin_panel"];
01788         }
01789 
01793         function getIntroduction()
01794         {
01795                 global $ilUser, $lng, $ilCtrl;
01796                 
01797                 $lng->loadLanguageModule("rep");
01798                 
01799                 $tpl = new ilTemplate("tpl.rep_intro.html", true, true, "Services/Repository");
01800                 $tpl->setVariable("IMG_REP_LARGE", ilUtil::getImagePath("icon_root_xxl.gif"));
01801                 $tpl->setVariable("TXT_WELCOME", $lng->txt("rep_intro"));
01802                 $tpl->setVariable("TXT_INTRO_1", $lng->txt("rep_intro1"));
01803                 $tpl->setVariable("TXT_INTRO_2", $lng->txt("rep_intro2"));
01804                 $tpl->setVariable("TXT_INTRO_3", sprintf($lng->txt("rep_intro3"), $lng->txt("add")));
01805                 $tpl->setVariable("TXT_INTRO_4", sprintf($lng->txt("rep_intro4"), $lng->txt("cat_add")));
01806                 $tpl->setVariable("TXT_INTRO_5", $lng->txt("rep_intro5"));
01807                 $tpl->setVariable("TXT_INTRO_6", $lng->txt("rep_intro6"));
01808                 
01809                 return $tpl->get();
01810         }
01811         
01815         function setColumnSettings($column_gui)
01816         {
01817                 global $ilAccess;
01818                 parent::setColumnSettings($column_gui);
01819 
01820                 if ($ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
01821                         $this->isActiveAdministrationPanel())
01822                 {
01823                         $column_gui->setEnableMovement(true);
01824                 }
01825                 
01826                 $column_gui->setRepositoryItems($this->items);
01827                 if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
01828                 {
01829                         $column_gui->setBlockProperty("news", "settings", true);
01830                         //$column_gui->setBlockProperty("news", "public_notifications_option", true);
01831                         $column_gui->setBlockProperty("news", "default_visibility_option", true);
01832                         $column_gui->setBlockProperty("news", "hide_news_block_option", true);
01833                 }
01834                 
01835                 if ($this->isActiveAdministrationPanel())
01836                 {
01837                         $column_gui->setAdminCommands(true);
01838                 }
01839         }
01840         
01841         
01849         public function cloneWizardPageTreeObject()
01850         {
01851                 $this->cloneWizardPageObject(true);
01852         }
01853         
01861         public function cloneWizardPageListObject()
01862         {
01863                 $this->cloneWizardPageObject(false);
01864         }
01865         
01872         public function cloneWizardPageObject($a_tree_view = true)
01873         {
01874                 include_once('Services/CopyWizard/classes/class.ilCopyWizardPageFactory.php');
01875                 
01876                 global $ilObjDataCache,$tree;
01877                 
01878                 if(!$_REQUEST['clone_source'])
01879                 {
01880                         ilUtil::sendInfo($this->lng->txt('select_one'));
01881                         if(isset($_SESSION['wizard_search_title']))
01882                         {
01883                                 $this->searchCloneSourceObject();
01884                         }
01885                         else
01886                         {
01887                                 $this->createObject();
01888                         }
01889                         return false;
01890                 }
01891                 $source_id = $_REQUEST['clone_source'];
01892                 $new_type = $_REQUEST['new_type'];
01893                 $this->ctrl->setParameter($this,'clone_source',(int) $_REQUEST['clone_source']);
01894                 $this->ctrl->setParameter($this,'new_type',$new_type);
01895                 
01896 
01897                 // Generell JavaScript
01898                 $this->tpl->addJavaScript('./Services/CopyWizard/js/ilContainer.js');
01899                 $this->tpl->setVariable('BODY_ATTRIBUTES','onload="ilDisableChilds(\'cmd\');"');
01900 
01901                 
01902                 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.container_wizard_page.html');
01903                 $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
01904                 $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_'.$new_type.'.gif'));
01905                 $this->tpl->setVariable('ALT_IMG',$this->lng->txt('obj_'.$new_type));
01906                 $this->tpl->setVariable('TXT_DUPLICATE',$this->lng->txt($new_type.'_wizard_page'));
01907                 $this->tpl->setVariable('INFO_DUPLICATE',$this->lng->txt($new_type.'_copy_threads_info'));
01908                 $this->tpl->setVariable('BTN_COPY',$this->lng->txt('obj_'.$new_type.'_duplicate'));
01909                 $this->tpl->setVariable('BTN_BACK',$this->lng->txt('btn_back'));
01910                 if(isset($_SESSION['wizard_search_title']))
01911                 {
01912                         $this->tpl->setVariable('CMD_BACK','searchCloneSource');
01913                 }
01914                 else
01915                 {
01916                         $this->tpl->setVariable('CMD_BACK','create');
01917                 }
01918                 
01919                 $this->tpl->setVariable('BTN_TREE',$this->lng->txt('treeview'));
01920                 $this->tpl->setVariable('BTN_LIST',$this->lng->txt('flatview'));
01921 
01922                 // Fill item rows
01923                 // tree view
01924                 if($a_tree_view)
01925                 {
01926                         $first = true;
01927                         $has_items = false; 
01928                         foreach($subnodes = $tree->getSubtree($source_node = $tree->getNodeData($source_id),true) as $node)
01929                         {
01930                                 if($first == true)
01931                                 {
01932                                         $first = false;
01933                                         continue;
01934                                 }
01935                                 
01936                                 if($node['type'] == 'rolf')
01937                                 {
01938                                         continue;
01939                                 }
01940                                 
01941                                 $has_items = true;
01942 
01943                                 for($i = $source_node['depth'];$i < $node['depth']; $i++)
01944                                 {
01945                                         $this->tpl->touchBlock('padding');
01946                                         $this->tpl->touchBlock('end_padding');
01947                                 }
01948                                 // fill options
01949                                 $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id,$node['type']);
01950                                 $copy_wizard_page->fillTreeSelection($node['ref_id'],$node['type'],$node['depth']);
01951                                 
01952                                 $this->tpl->setCurrentBlock('tree_row');
01953                                 $this->tpl->setVariable('TREE_IMG',ilUtil::getImagePath('icon_'.$node['type'].'_s.gif'));
01954                                 $this->tpl->setVariable('TREE_ALT_IMG',$this->lng->txt('obj_'.$node['type']));
01955                                 $this->tpl->setVariable('TREE_TITLE',$node['title']);
01956                                 $this->tpl->parseCurrentBlock();
01957                         }
01958                         if(!$has_items)
01959                         {
01960                                 $this->tpl->setCurrentBlock('no_content');
01961                                 $this->tpl->setVariable('TXT_NO_CONTENT',$this->lng->txt('container_no_items'));
01962                                 $this->tpl->parseCurrentBlock();
01963                         }
01964                         else
01965                         {
01966                                 $this->tpl->setCurrentBlock('tree_footer');
01967                                 $this->tpl->setVariable('TXT_COPY_ALL',$this->lng->txt('copy_all'));
01968                                 $this->tpl->setVariable('TXT_LINK_ALL',$this->lng->txt('link_all'));
01969                                 $this->tpl->setVariable('TXT_OMIT_ALL',$this->lng->txt('omit_all'));
01970                                 $this->tpl->parseCurrentBlock();
01971                                 
01972                         }
01973                 }
01974                 else
01975                 {
01976                         foreach($tree->getSubTreeTypes($source_id,array('rolf','crs')) as $type)
01977                         {
01978                                 $copy_wizard_page = ilCopyWizardPageFactory::_getInstanceByType($source_id,$type);
01979                                 if(strlen($html = $copy_wizard_page->getWizardPageBlockHTML()))
01980                                 {
01981                                         $this->tpl->setCurrentBlock('obj_row');
01982                                         $this->tpl->setVariable('ITEM_BLOCK',$html);
01983                                         $this->tpl->parseCurrentBlock();
01984                                 }
01985                         }
01986                 }
01987         }
01988         
01996         public function cloneAllObject()
01997         {
01998                 global $ilLog;
01999                 
02000                 include_once('classes/class.ilLink.php');
02001                 include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
02002                 
02003                 global $ilAccess,$ilErr,$rbacsystem,$tree,$ilUser;
02004                 
02005                 $new_type = $_REQUEST['new_type'];
02006                 $ref_id = (int) $_GET['ref_id'];
02007                 $clone_source = (int) $_REQUEST['clone_source'];
02008                 
02009                 if(!$rbacsystem->checkAccess('create', $ref_id,$new_type))
02010                 {
02011                         $ilErr->raiseError($this->lng->txt('permission_denied'));
02012                 }
02013                 if(!$clone_source)
02014                 {
02015                         ilUtil::sendInfo($this->lng->txt('select_one'));
02016                         $this->createObject();
02017                         return false;
02018                 }
02019                 if(!$ilAccess->checkAccess('write','', $clone_source,$new_type))
02020                 {
02021                         $ilErr->raiseError($this->lng->txt('permission_denied'));
02022                 }
02023 
02024                 $options = $_POST['cp_options'] ? $_POST['cp_options'] : array();
02025                 $orig = ilObjectFactory::getInstanceByRefId($clone_source);
02026                 $result = $orig->cloneAllObject($_COOKIE['PHPSESSID'], $_COOKIE['ilClientId'], $new_type, $ref_id, $clone_source, $options);
02027                 
02028                 // Check if copy is in progress
02029                 if ($result == $ref_id)
02030                 {
02031                         ilUtil::sendInfo($this->lng->txt("object_copy_in_progress"),true);
02032                         ilUtil::redirect('repository.php?ref_id='.$ref_id);
02033                 } 
02034                 else 
02035                 {
02036                         ilUtil::sendInfo($this->lng->txt("object_duplicated"),true);
02037                         ilUtil::redirect('repository.php?ref_id='.$result);                     
02038                 }       
02039         }
02040 
02048         public function copyWizardHasOptions($a_mode)
02049         {
02050                 switch($a_mode)
02051                 {
02052                         case self::COPY_WIZARD_NEEDS_PAGE:
02053                                 return true;
02054                         
02055                         default:
02056                                 return false;
02057                 }
02058         }
02059         
02067         public function saveSortingObject()
02068         {
02069                 include_once('Services/Container/classes/class.ilContainerSorting.php');
02070                 $sorting = new ilContainerSorting($this->object->getId());
02071                 $sorting->savePost($_POST['position']);
02072                 ilUtil::sendInfo($this->lng->txt('sorting_saved',true));
02073                 $this->ctrl->returnToParent($this);
02074         }
02075         
02076 
02077 }
02078 ?>

Generated on Fri Dec 13 2013 17:56:47 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1