• 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 
00038 require_once "class.ilObjectGUI.php";
00039 require_once "class.ilContainer.php";
00040 
00041 class ilContainerGUI extends ilObjectGUI
00042 {
00047         function ilContainerGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
00048         {
00049                 global $rbacsystem;
00050 
00051                 $this->rbacsystem =& $rbacsystem;
00052 
00053                 //$this->ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
00054                 
00055                 // prepare output things should generally be made in executeCommand
00056                 // method (maybe dependent on current class/command
00057                 $this->ilObjectGUI($a_data, $a_id, $a_call_by_reference, false);
00058         }
00059 
00064         function &executeCommand()
00065         {
00066                 $next_class = $this->ctrl->getNextClass();
00067                 $cmd = $this->ctrl->getCmd("render");
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 
00080                                 break;
00081                 }
00082                 return true;
00083         }
00084 
00088         function &forwardToPageObject()
00089         {
00090                 global $lng;
00091 
00092                 // page object
00093                 include_once("./content/classes/Pages/class.ilPageObject.php");
00094                 include_once("./content/classes/Pages/class.ilPageObjectGUI.php");
00095 
00096                 $lng->loadLanguageModule("content");
00097                 
00098                 include_once("./classes/class.ilObjStyleSheet.php");
00099                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00100                         ilObjStyleSheet::getContentStylePath(0));
00101 
00102                 if (!ilPageObject::_exists($this->object->getType(),
00103                         $this->object->getId()))
00104                 {
00105                         // doesn't exist -> create new one
00106                         $new_page_object = new ilPageObject($this->object->getType());
00107                         $new_page_object->setParentId($this->object->getId());
00108                         $new_page_object->setId($this->object->getId());
00109                         $new_page_object->createFromXML();
00110                 }
00111                 
00112                 // get page object
00113                 $page_object = new ilPageObject($this->object->getType(),
00114                         $this->object->getId(), true);
00115 
00116                 $this->ctrl->setReturnByClass("ilpageobjectgui", "view");
00117                 //$page_object =& $this->obj->getPageObject();
00118                 $page_object->buildDom();
00119                 //$page_object->addUpdateListener($this, "updateHistory");
00120                 $int_links = $page_object->getInternalLinks();
00121                 //$link_xml = $this->getLinkXML($int_links);
00122                 $page_gui =& new ilPageObjectGUI($page_object);
00123 
00124                 // $view_frame = ilFrameTargetInfo::_getFrame("MainContent");
00125                 //$page_gui->setViewPageLink(ILIAS_HTTP_PATH."/goto.php?target=pg_".$this->obj->getId(),
00126                 //      $view_frame);
00127 
00128                 $page_gui->setIntLinkHelpDefault("StructureObject", $_GET["ref_id"]);
00129                 $page_gui->setTemplateTargetVar("ADM_CONTENT");
00130                 $page_gui->setLinkXML($link_xml);
00131                 //$page_gui->enableChangeComments($this->content_object->isActiveHistoryUserComments());
00132                 $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
00133                 $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
00134                 //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
00135                 $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this, ""));
00136                 $page_gui->setPresentationTitle("");
00137                 //$page_gui->setLocator($contObjLocator);
00138                 $page_gui->setHeader("");
00139                 $ret =& $this->ctrl->forwardCommand($page_gui);
00140                 
00141                 //$ret =& $page_gui->executeCommand();
00142                 return $ret;
00143         }
00144         
00148         function prepareOutput($a_show_subobjects = true)
00149         {
00150                 if (parent::prepareOutput())    // return false in admin mode
00151                 {
00152                         if ($this->getCreationMode() != true && $a_show_subobjects)
00153                         {
00154                                 // This method is called directly from ilContainerGUI::renderObject
00155                                 #$this->showPossibleSubObjects();
00156                                 $this->showTreeFlatIcon();
00157                         }
00158                 }
00159         }
00160         
00161         function showTreeFlatIcon()
00162         {
00163                 global $tpl;
00164                 
00165                 // dont show icon, if role (permission gui->rolegui) is edited
00166                 if ($_GET["obj_id"] != "")
00167                 {
00168                         return;
00169                 }
00170                 
00171                 $mode = ($_SESSION["il_rep_mode"] == "flat")
00172                         ? "tree"
00173                         : "flat";
00174                 $link = "repository.php?cmd=frameset&set_mode=".$mode."&ref_id=".$this->object->getRefId();
00175                 $tpl->setTreeFlatIcon($link, $mode);
00176         }
00177         
00181         function setTitleAndDescription()
00182         {
00183                 global $ilias;
00184 //echo "1-".get_class($this)."-".$this->object->getTitle()."-";
00185                 $this->tpl->setTitle($this->object->getTitle());
00186                 $this->tpl->setDescription($this->object->getLongDescription());
00187 
00188                 // set tile icon
00189                 $icon = ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif");
00190                 if ($ilias->getSetting("custom_icons") &&
00191                         in_array($this->object->getType(), array("cat","grp","crs")))
00192                 {
00193                         require_once("classes/class.ilContainer.php");
00194                         if (($path = ilContainer::_lookupIconPath($this->object->getId(), "big")) != "")
00195                         {
00196                                 $icon = $path;
00197                         }
00198                 }
00199                 $this->tpl->setTitleIcon($icon, $this->lng->txt("obj_".$this->object->getType()));
00200         }
00201 
00202 
00206         function showPossibleSubObjects()
00207         {
00208                 global $ilAccess;
00209 
00210                 $found = false;
00211                 $cmd = ($this->cmd != "")
00212                         ? $this->cmd
00213                         : $this->ctrl->getCmd();
00214 
00215                 #if ($cmd != "" && $cmd != "showList" && $cmd != "render"
00216                 #       && $cmd != "view")
00217                 #{
00218                 #       return;
00219                 #}
00220                 
00221                 $type = $this->object->getType();
00222 
00223                 $d = $this->objDefinition->getCreatableSubObjects($type);
00224 
00225                 if (count($d) > 0)
00226                 {
00227                         foreach ($d as $row)
00228                         {
00229                             $count = 0;
00230                                 if ($row["max"] > 0)
00231                                 {
00232                                         //how many elements are present?
00233                                         //var_dump($this->data);
00234                                         // this is broken
00235                                         /*
00236                                         for ($i=0; $i<count($this->data["ctrl"]); $i++)
00237                                         {
00238                                                 if ($this->data["ctrl"][$i]["type"] == $row["name"])
00239                                                 {
00240                                                     $count++;
00241                                                 }
00242                                         }*/
00243                                 }
00244 
00245                                 if ($row["max"] == "" || $count < $row["max"])
00246                                 {
00247                                         if (in_array($row["name"], array("sahs", "alm", "hlm", "lm", "grp", "frm", "mep","crs",
00248                                                                                                          "cat", "glo", "dbk","exc", "qpl", "tst", "svy", "spl", "chat", 
00249                                                                                                          "htlm","fold","linkr","file","icrs","icla","crsg",'webr')))
00250                                         {
00251                                                 if ($this->rbacsystem->checkAccess("create", $this->object->getRefId(), $row["name"]))
00252                                                 {
00253                                                         $subobj[] = $row["name"];
00254                                                 }
00255                                         }
00256                                 }
00257                         }
00258                 }
00259                 if (is_array($subobj))
00260                 {
00261                         // show addEvent button
00262                         if($this->object->getType() == 'crs')
00263                         {
00264                                 if($ilAccess->checkAccess('write','',$this->object->getRefId()))
00265                                 {
00266                                         $this->tpl->setCurrentBlock("event_button");
00267                                         $this->tpl->setVariable("E_FORMACTION",$this->ctrl->getFormActionByClass('ileventadministrationgui'));
00268                                         $this->tpl->setVariable("BTN_NAME_EVENT",'addEvent');
00269                                         $this->tpl->setVariable("TXT_ADD_EVENT",$this->lng->txt('add_event'));
00270                                         $this->tpl->parseCurrentBlock();
00271                                 }
00272                         }
00273                         $this->tpl->setCurrentBlock("add_commands");
00274                         // convert form to inline element, to show them in one row
00275                         if($this->object->getType() == 'crs')
00276                         {
00277                                 $this->tpl->setVariable("FORMSTYLE",'display:inline');
00278                         }
00279                         $this->tpl->setVariable("H_FORMACTION",  "repository.php?ref_id=".$this->object->getRefId().
00280                                 "&cmd=post");
00281                         // possible subobjects
00282                         $opts = ilUtil::formSelect("", "new_type", $subobj);
00283                         $this->tpl->setVariable("SELECT_OBJTYPE_REPOS", $opts);
00284                         $this->tpl->setVariable("BTN_NAME_REPOS", "create");
00285                         $this->tpl->setVariable("TXT_ADD_REPOS", $this->lng->txt("add"));
00286                         $this->tpl->parseCurrentBlock();
00287                 }
00288         }
00289 
00290 
00294 /*      This is currently implemented in ilRepositoryGUI for all containers
00295         and a conceptional issue whether it should be moved to this class.
00296         function showTreeObject()
00297         {
00298                 $this->tpl = new ilTemplate("tpl.main.html", true, true);
00299                 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00300 
00301                 //$this->tpl = new ilTemplate("tpl.explorer.html", false, false);
00302                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
00303                 $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
00304 
00305                 include_once ("classes/class.ilRepositoryExplorer.php");
00306                 $exp = new ilRepositoryExplorer("repository.php?cmd=goto");
00307                 $exp->setExpandTarget("repository.php?cmd=showTree&ref_id=".$this->object->getRefId());
00308                 $exp->setTargetGet("ref_id");
00309 
00310                 if ($_GET["repexpand"] == "")
00311                 {
00312                         $expanded = $this->tree->readRootId();
00313                 }
00314                 else
00315                 {
00316                         $expanded = $_GET["repexpand"];
00317                 }
00318 
00319                 $exp->setExpand($expanded);
00320 
00321                 // build html-output
00322                 $exp->setOutput(0);
00323                 $output = $exp->getOutput();
00324 
00325                 $this->tpl->setCurrentBlock("content");
00326                 $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("repository"));
00327                 $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
00328                 $this->tpl->setVariable("EXPLORER", $output);
00329                 //$this->tpl->setVariable("ACTION", "repository.php?repexpand=".$_GET["repexpand"]);
00330                 $this->tpl->parseCurrentBlock();
00331                 $this->tpl->show(false);
00332                 exit;
00333         }
00334 */
00335 
00341         function renderObject()
00342         {
00343                 global $ilBench, $tree;
00344                 
00345                 // course content interface methods could probably
00346                 // move to this class
00347                 if($this->type != 'icrs' and $tree->checkForParentType($this->ref_id,'crs'))
00348                 {
00349                         include_once './course/classes/class.ilCourseContentGUI.php';
00350                         $course_content_obj = new ilCourseContentGUI($this);
00351                         
00352                         $this->ctrl->setCmd('view');
00353                         $this->ctrl->setCmdClass(get_class($course_content_obj));
00354                         $this->ctrl->forwardCommand($course_content_obj);
00355 
00356                         return;
00357                 }
00358 
00359                 // 'add object'
00360                 $this->showPossibleSubObjects();
00361 
00362                 $ilBench->start("ilContainerGUI", "0000__renderObject");
00363 
00364                 $tpl = new ilTemplate ("tpl.container_page.html", true, true);
00365                 
00366                 // get all sub items
00367                 $ilBench->start("ilContainerGUI", "0100_getSubItems");
00368                 $this->getSubItems();
00369                 $ilBench->stop("ilContainerGUI", "0100_getSubItems");
00370 
00371                 $ilBench->start("ilContainerGUI", "0200_renderItemList");
00372                 $html = $this->renderItemList();
00373                 $tpl->setVariable("CONTAINER_PAGE_CONTENT", $html);
00374                 $ilBench->stop("ilContainerGUI", "0200_renderItemList");
00375                 
00376                 $this->showAdministrationPanel($tpl);
00377                 $this->showPermanentLink($tpl);
00378                 
00379                 $this->html = $tpl->get();
00380                 
00381                 $ilBench->stop("ilContainerGUI", "0000__renderObject");
00382         }
00383 
00387         function showAdministrationPanel(&$tpl)
00388         {
00389                 global $ilAccess, $ilSetting;
00390                 
00391                 if ($this->isActiveAdministrationPanel())
00392                 {
00393                         $tpl->setCurrentBlock("admin_button_off");
00394                         $tpl->setVariable("ADMIN_MODE_LINK",
00395                                 $this->ctrl->getLinkTarget($this, "disableAdministrationPanel"));
00396                         $tpl->setVariable("TXT_ADMIN_MODE",
00397                                 $this->lng->txt("admin_panel_disable"));
00398                         $tpl->parseCurrentBlock();
00399                         
00400                         // administration panel
00401                         if ($ilAccess->checkAccess("write", "", $this->object->getRefId())
00402                                 && in_array($this->object->getType(), array("cat", "root")))
00403                         {
00404                                 if ($ilSetting->get("enable_cat_page_edit"))
00405                                 {
00406                                         $tpl->setCurrentBlock("edit_cmd");
00407                                         $tpl->setVariable("TXT_EDIT_PAGE", $this->lng->txt("edit_page"));
00408                                         $tpl->setVariable("LINK_EDIT_PAGE", $this->ctrl->getLinkTarget($this, "editPageFrame"));
00409                                         $tpl->setVariable("FRAME_EDIT_PAGE", ilFrameTargetInfo::_getFrame("MainContent"));
00410                                         $tpl->parseCurrentBlock();
00411                                 }
00412                         }
00413                         
00414                         $tpl->setCurrentBlock("admin_panel_cmd");
00415                         $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("delete_selected_items"));
00416                         $tpl->setVariable("PANEL_CMD", "delete");
00417                         $tpl->parseCurrentBlock();
00418                         if (!$_SESSION["clipboard"])
00419                         {
00420                                 $tpl->setCurrentBlock("admin_panel_cmd");
00421                                 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("move_selected_items"));
00422                                 $tpl->setVariable("PANEL_CMD", "cut");
00423                                 $tpl->parseCurrentBlock();
00424                                 $tpl->setCurrentBlock("admin_panel_cmd");
00425                                 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("link_selected_items"));
00426                                 $tpl->setVariable("PANEL_CMD", "link");
00427                                 $tpl->parseCurrentBlock();
00428                         }
00429                         else
00430                         {
00431                                 $tpl->setCurrentBlock("admin_panel_cmd");
00432                                 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("paste_clipboard_items"));
00433                                 $tpl->setVariable("PANEL_CMD", "paste");
00434                                 $tpl->parseCurrentBlock();
00435                                 $tpl->setCurrentBlock("admin_panel_cmd");
00436                                 $tpl->setVariable("TXT_PANEL_CMD", $this->lng->txt("clear_clipboard"));
00437                                 $tpl->setVariable("PANEL_CMD", "clear");
00438                                 $tpl->parseCurrentBlock();
00439                         }
00440                         $tpl->setCurrentBlock("admin_panel");
00441                         $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00442                         $tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
00443                         $tpl->setVariable("TXT_ADMIN_PANEL", $this->lng->txt("admin_panel"));
00444                         $tpl->parseCurrentBlock();
00445                         $this->ctrl->setParameter($this, "type", "");
00446                         $this->ctrl->setParameter($this, "item_ref_id", "");
00447                         $tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00448                 }
00449                 else if ($this->adminCommands)
00450                 {
00451                         #$this->__showTimingsButton($tpl);
00452 
00453                         $tpl->setCurrentBlock("admin_button");
00454                         $tpl->setVariable("ADMIN_MODE_LINK",
00455                                 $this->ctrl->getLinkTarget($this, "enableAdministrationPanel"));
00456                         $tpl->setVariable("TXT_ADMIN_MODE",
00457                                 $this->lng->txt("admin_panel_enable"));
00458                         $tpl->parseCurrentBlock();
00459                 }
00460         }
00461 
00462         function __showTimingsButton(&$tpl)
00463         {
00464                 global $tree;
00465 
00466                 if(!$tree->checkForParentType($this->object->getRefId(),'crs'))
00467                 {
00468                         return false;
00469                 }
00470                 $tpl->setCurrentBlock("custom_button");
00471                 $tpl->setVariable("ADMIN_MODE_LINK",$this->ctrl->getLinkTargetByClass('ilcoursecontentgui','editTimings'));
00472                 $tpl->setVariable("TXT_ADMIN_MODE",$this->lng->txt('timings_edit'));
00473                 $tpl->parseCurrentBlock();
00474                 return true;
00475         }
00479         function showPermanentLink(&$tpl)
00480         {
00481                 if ($this->object->getType() == "root")
00482                 {
00483                         return;
00484                 }
00485                 $tpl->setCurrentBlock("perma_link");
00486                 $tpl->setVariable("PERMA_LINK", ILIAS_HTTP_PATH.
00487                         "/goto.php?target=".
00488                         $this->object->getType().
00489                         "_".$this->object->getRefId()."&client_id=".CLIENT_ID);
00490                 $tpl->setVariable("TXT_PERMA_LINK", $this->lng->txt("perma_link"));
00491                 $tpl->setVariable("PERMA_TARGET", "_top");
00492                 $tpl->parseCurrentBlock();
00493         }
00494 
00498         function editPageFrameObject()
00499         {
00500                 include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
00501                 $fs_gui = new ilFramesetGUI();
00502                 
00503                 $fs_gui->setFramesetTitle($this->object->getTitle());
00504                 $fs_gui->setMainFrameName("content");
00505                 $fs_gui->setSideFrameName("link_list");
00506                 
00507                 $fs_gui->setSideFrameSource(
00508                         $this->ctrl->getLinkTargetByClass("ilcontainerlinklistgui", "show"));
00509 
00510                 $fs_gui->setMainFrameSource(
00511                         $this->ctrl->getLinkTarget(
00512                                 $this, "editPageContent"));
00513                         
00514                 /* old xml page handling
00515                 $fs_gui->setMainFrameSource(
00516                         $this->ctrl->getLinkTargetByClass(
00517                                 array("ilpageobjectgui"), "view"));*/
00518                                 
00519                 $fs_gui->show();
00520                 exit;
00521         }
00522 
00528         function editPageContentObject()
00529         {
00530                 global $rbacsystem, $tpl;
00531 
00532                 if (!$rbacsystem->checkAccess("write", $this->ref_id))
00533                 {
00534                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00535                 }
00536                 
00537                 $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
00538                         "xhtml_page");
00539                 if ($xpage_id > 0)
00540                 {
00541                         include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
00542                         $xpage = new ilXHTMLPage($xpage_id);
00543                         $content = $xpage->getContent();
00544                 }
00545                 
00546                 // get template
00547                 $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.container_edit_page_content.html");
00548                 $tpl->setVariable("VAL_CONTENT", ilUtil::prepareFormOutput($content));
00549                 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00550                 $tpl->setVariable("TXT_EDIT_PAGE_CONTENT",
00551                         $this->lng->txt("edit_page_content"));
00552                 $tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
00553                 $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00554                 
00555                 // add rte support
00556                 include_once "./Services/RTE/classes/class.ilRTE.php";
00557                 $rtestring = ilRTE::_getRTEClassname();
00558 //echo "+".$rtestring."+";
00559                 include_once "./Services/RTE/classes/class.$rtestring.php";
00560                 $rte = new $rtestring();
00561                 //$rte->addPlugin("latex");
00562                 include_once "./classes/class.ilObject.php";
00563                 $obj_id = ilObject::_lookupObjectId($_GET["ref_id"]);
00564                 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
00565                 $rte->addRTESupport($obj_id, $obj_type);
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                 $text = ilUtil::stripSlashes($_POST["page_content"],
00576                                 true,
00577                                 ilObjAdvancedEditing::_getUsedHTMLTagsAsString());
00578                 if ($xpage_id > 0)
00579                 {
00580                         $xpage = new ilXHTMLPage($xpage_id);
00581                         $xpage->setContent($text);
00582                         $xpage->save();
00583                 }
00584                 else
00585                 {
00586                         $xpage = new ilXHTMLPage();
00587                         $xpage->setContent($text);
00588                         $xpage->save();
00589                         ilContainer::_writeContainerSetting($this->object->getId(),
00590                                 "xhtml_page", $xpage->getId());
00591                 }
00592                 
00593                 include_once("Services/RTE/classes/class.ilRTE.php");
00594                 ilRTE::_cleanupMediaObjectUsage($text, $this->object->getType().":html",
00595                         $this->object->getId());
00596 
00597                 sendInfo($this->lng->txt("msg_obj_modified"), true);
00598                 $this->ctrl->redirect($this, "");
00599         }
00600         
00601         function cancelPageContentObject()
00602         {
00603                 sendInfo($this->lng->txt("action_aborted"), true);
00604                 $this->ctrl->redirect($this, "");
00605         }
00606 
00610         function getSubItems()
00611         {
00612                 global $objDefinition, $ilBench;
00613 
00614                 $objects = $this->tree->getChilds($this->object->getRefId(), "title");
00615 
00616                 $found = false;
00617 
00618                 foreach ($objects as $key => $object)
00619                 {
00620 
00621                         // hide object types in devmode
00622                         if ($objDefinition->getDevMode($object["type"]))
00623                         {
00624                                 continue;
00625                         }
00626 
00627                         // group together types (e.g. ILIAS learning modules
00628                         // and SCORM learning modules to learning materials)
00629                         switch ($object["type"])
00630                         {
00631                                 // learning material
00632                                 case "sahs":
00633                                 case "lm":
00634                                 case "dbk":
00635                                 case "htlm":
00636                                         $type = "lres";
00637                                         break;
00638 
00639                                 default:
00640                                         $type = $object["type"];
00641                                         break;
00642                         }
00643 
00644                         $this->items[$type][$key] = $object;
00645                 }
00646         }
00647 
00648         function renderItemList($a_type = "all")
00649         {
00650                 global $objDefinition, $ilBench, $ilSetting;
00651                 
00652                 include_once("classes/class.ilObjectListGUIFactory.php");
00653 
00654                 $output_html = "";
00655                 $this->clearAdminCommandsDetermination();
00656                 
00657                 switch ($a_type)
00658                 {
00659                         // render all items list
00660                         case "all":
00661                         
00662                                 /*
00663                                 // get container page
00664                                 include_once("./content/classes/Pages/class.ilPageObjectGUI.php");
00665                                 include_once("./content/classes/Pages/class.ilPageObject.php");
00666                                 if (ilPageObject::_exists($this->object->getType(),
00667                                         $this->object->getId()))
00668                                 {
00669                                         $page =& new ilPageObject($this->object->getType(), $this->object->getId());
00670                                         $page_gui =& new ilPageObjectGUI($page);
00671                                         //$page_gui->setSourcecodeDownloadScript("glossary_presentation.php?ref_id=".$_GET["ref_id"]);
00672                                         //$page_gui->setFullscreenLink("glossary_presentation.php?cmd=fullscreen&amp;ref_id=".$_GET["ref_id"]);
00673                                         //$page_gui->setFileDownloadLink("glossary_presentation.php?cmd=downloadFile".
00674                                         //      "&amp;ref_id=".$_GET["ref_id"]);
00675                                                 
00676                                         $page_gui->setOutputMode("presentation");
00677                                         //$page_gui->setLinkXML($this->getLinkXML());
00678                                         $page_gui->setTemplateOutput(false);
00679                                         $output_html.= $page_gui->presentation($page_gui->getOutputMode());
00680                                 }*/
00681                                 
00682                                 $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(),
00683                                         "xhtml_page");
00684                                 if ($xpage_id > 0 && $ilSetting->get("enable_cat_page_edit"))
00685                                 {
00686                                         include_once("Services/XHTMLPage/classes/class.ilXHTMLPage.php");
00687                                         $xpage = new ilXHTMLPage($xpage_id);
00688                                         $output_html.= $xpage->getContent();
00689                                 }
00690 
00691 
00692                                 // all item types
00693                                 $type_ordering = array(
00694                                         "cat", "fold", "crs", "icrs", "icla", "grp", "chat", "frm", "lres",
00695                                         "glo", "webr", "file", "exc",
00696                                         "tst", "svy", "mep", "qpl", "spl");
00697 
00698                                 $cur_obj_type = "";
00699                                 $overall_tpl =& $this->newBlockTemplate();
00700                                 $this->type_template = array();
00701                                 $first = true;
00702                                 
00703                                 // iterate all types
00704                                 foreach ($type_ordering as $type)
00705                                 {
00706                                         // set template (overall or type specific)
00707                                         if (is_int(strpos($output_html, "[list-".$type."]")))
00708                                         {
00709                                                 $tpl =& $this->newBlockTemplate();
00710                                                 $overall = false;                       // individual
00711                                         }
00712                                         else
00713                                         {
00714                                                 $tpl =& $overall_tpl;
00715                                                 $overall = true;                        // put to the rest
00716                                         }
00717                                                 
00718                                         if (is_array($this->items[$type]))
00719                                         {
00720                                                 
00721                                                 $item_html = array();
00722 
00723                                                 foreach($this->items[$type] as $key => $item)
00724                                                 {
00725                                                         // get list gui class for each object type
00726                                                         if ($cur_obj_type != $item["type"])
00727                                                         {
00728                                                                 $item_list_gui =& ilObjectListGUIFactory::_getListGUIByType($item["type"]);
00729                                                                 $item_list_gui->setContainerObject($this);
00730                                                         }
00731                                                         // render item row
00732                                                         $ilBench->start("ilContainerGUI", "0210_getListHTML");
00733                                                         
00734                                                         // show administration command buttons (or not)
00735                                                         if (!$this->isActiveAdministrationPanel())
00736                                                         {
00737                                                                 $item_list_gui->enableDelete(false);
00738                                                                 $item_list_gui->enableLink(false);
00739                                                                 $item_list_gui->enableCut(false);
00740                                                         }
00741                                                         
00742                                                         $html = $item_list_gui->getListItemHTML($item["ref_id"],
00743                                                                 $item["obj_id"], $item["title"], $item["description"]);
00744                                                                 
00745                                                         // check whether any admin command is allowed for
00746                                                         // the items
00747                                                         $this->determineAdminCommands($item["ref_id"],
00748                                                                 $item_list_gui->adminCommandsIncluded());
00749                                                         $ilBench->stop("ilContainerGUI", "0210_getListHTML");
00750                                                         if ($html != "")
00751                                                         {
00752                                                                 $item_html[] = array("html" => $html, "item_ref_id" => $item["ref_id"]
00753                                                                         , "item_obj_id" => $item["obj_id"]);
00754                                                         }
00755                                                 }
00756 
00757                                                 // output block for resource type
00758                                                 if (count($item_html) > 0)
00759                                                 {
00760                                                         // separator row
00761                                                         if (!$first && $overall)
00762                                                         {
00763                                                                 $this->addSeparatorRow($tpl);
00764                                                         }
00765                                                         
00766                                                         if ($overall)
00767                                                         {
00768                                                                 $first = false;
00769                                                         }
00770 
00771                                                         // add a header for each resource type
00772                                                         if ($this->ilias->getSetting("icon_position_in_lists") == "item_rows")
00773                                                         {
00774                                                                 $this->addHeaderRow($tpl, $type, false);
00775                                                         }
00776                                                         else
00777                                                         {
00778                                                                 $this->addHeaderRow($tpl, $type);
00779                                                         }
00780                                                         $this->resetRowType();
00781 
00782                                                         // content row
00783                                                         foreach($item_html as $item)
00784                                                         {
00785                                                                 if ($this->ilias->getSetting("icon_position_in_lists") == "item_rows")
00786                                                                 {
00787                                                                         $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], $type);
00788                                                                 }
00789                                                                 else
00790                                                                 {
00791                                                                         $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"]);
00792                                                                 }
00793                                                         }
00794 
00795                                                         // store type specific templates in array
00796                                                         if (is_int(strpos($output_html, "[list-".$type."]")))
00797                                                         {
00798                                                                 $this->type_template[$type] = $tpl;
00799                                                         }
00800                                                 }
00801                                                 else
00802                                                 {
00803                                                         // [list-...] tag available, but no item of type accessible
00804                                                         if (!$overall)
00805                                                         {
00806                                                                 $this->addHeaderRow($tpl, $type);
00807                                                                 $this->resetRowType();
00808                                                                 $this->addMessageRow($tpl, 
00809                                                                         $this->lng->txt("msg_no_type_accessible"), $type);
00810                                                                 $this->type_template[$type] = $tpl;
00811                                                         }
00812                                                 }
00813                                         }
00814                                         else
00815                                         {
00816                                                 // [list-...] tag available, but no item of type exists
00817                                                 if (!$overall)
00818                                                 {
00819                                                         $this->addHeaderRow($tpl, $type);
00820                                                         $this->resetRowType();
00821                                                         $this->addMessageRow($tpl,
00822                                                                 $this->lng->txt("msg_no_type_available"), $type);
00823                                                         $this->type_template[$type] = $tpl;
00824                                                 }
00825                                         }
00826 
00827                                 }
00828 
00829 
00830                                 // I don't know why but executing this
00831                                 // line before the following foreach loop seems to be crucial
00832                                 if ($output_html != "")
00833                                 {
00834                                         //$output_html.= "<br /><br />";
00835                                 }
00836                                 $output_html.= $overall_tpl->get();
00837                                 //$output_html = str_replace("<br>++", "++", $output_html);
00838                                 //$output_html = str_replace("<br>++", "++", $output_html);
00839                                 //$output_html = str_replace("++<br>", "++", $output_html);
00840                                 //$output_html = str_replace("++<br>", "++", $output_html);
00841                                 foreach ($this->type_template as $type => $tpl)
00842                                 {
00843                                         $output_html = eregi_replace("\[list-".$type."\]",
00844                                                 "</p>".$tpl->get()."<p class=\"ilc_Standard\">",
00845                                                 $output_html);
00846                                 }
00847 
00848                                 //if (ilPageObject::_exists($this->object->getType(),
00849                                 //      $this->object->getId()))
00850                                 if ($xpage_id > 0)
00851                                 {                               
00852                                         $page_block = new ilTemplate("tpl.container_page_block.html", false, false);
00853                                         $page_block->setVariable("CONTAINER_PAGE_CONTENT", $output_html);
00854                                         $output_html = $page_block->get();
00855                                 }
00856 
00857                                 break;
00858 
00859                         default:
00860                                 // to do:
00861                                 break;
00862                 }
00863 
00864                 return $output_html;
00865         }
00866 
00870         function clearAdminCommandsDetermination()
00871         {
00872                 $this->adminCommands = false;
00873         }
00874         
00878         function determineAdminCommands($a_ref_id, $a_admin_com_included_in_list = false)
00879         {
00880                 if (!$this->adminCommands)
00881                 {
00882                         if (!$this->isActiveAdministrationPanel())
00883                         {
00884                                 if ($this->rbacsystem->checkAccess("delete", $a_ref_id))
00885                                 {
00886                                         $this->adminCommands = true;
00887                                 }
00888                         }
00889                         else
00890                         {
00891                                 $this->adminCommands = $a_admin_com_included_in_list;
00892                         }
00893                 }
00894         }
00895 
00902         function &newBlockTemplate()
00903         {
00904                 $tpl = new ilTemplate ("tpl.container_list_block.html", true, true);
00905                 $this->cur_row_type = "row_type_1";
00906                 return $tpl;
00907         }
00908 
00916         function addHeaderRow(&$a_tpl, $a_type, $a_show_image = true)
00917         {
00918                 if ($a_type != "lres")
00919                 {
00920                         $icon = ilUtil::getImagePath("icon_".$a_type.".gif");
00921                         $title = $this->lng->txt("objs_".$a_type);
00922                 }
00923                 else
00924                 {
00925                         $icon = ilUtil::getImagePath("icon_lm.gif");
00926                         $title = $this->lng->txt("learning_resources");
00927                 }
00928                 
00929                 if ($a_show_image)
00930                 {
00931                         $a_tpl->setCurrentBlock("container_header_row_image");
00932                         $a_tpl->setVariable("HEADER_IMG", $icon);
00933                         $a_tpl->setVariable("HEADER_ALT", $title);
00934                 }
00935                 else
00936                 {
00937                         $a_tpl->setCurrentBlock("container_header_row");
00938                 }
00939                 
00940                 $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
00941                 $a_tpl->parseCurrentBlock();
00942                 $a_tpl->touchBlock("container_row");
00943         }
00944 
00952         function addStandardRow(&$a_tpl, $a_html, $a_item_ref_id = "", $a_item_obj_id = "",
00953                 $a_image_type = "")
00954         {
00955                 $this->cur_row_type = ($this->cur_row_type == "row_type_1")
00956                         ? "row_type_2"
00957                         : "row_type_1";
00958 
00959                 $a_tpl->touchBlock($this->cur_row_type);
00960                 
00961                 $nbsp = true;
00962                 if ($a_image_type != "")
00963                 {
00964                         if ($a_image_type != "lres")
00965                         {
00966                                 $icon = ilUtil::getImagePath("icon_".$a_image_type.".gif");
00967                                 $alt = $this->lng->txt("obj_".$a_image_type);
00968                         }
00969                         else
00970                         {
00971                                 $icon = ilUtil::getImagePath("icon_lm.gif");
00972                                 $alt = $this->lng->txt("learning_resource");
00973                         }
00974                         
00975                         // custom icon
00976                         if ($this->ilias->getSetting("custom_icons") &&
00977                                 in_array($a_image_type, array("cat","grp","crs")))
00978                         {
00979                                 require_once("classes/class.ilContainer.php");
00980                                 if (($path = ilContainer::_lookupIconPath($a_item_obj_id, "small")) != "")
00981                                 {
00982                                         $icon = $path;
00983                                 }
00984                         }
00985 
00986                         $a_tpl->setCurrentBlock("block_row_image");
00987                         $a_tpl->setVariable("ROW_IMG", $icon);
00988                         $a_tpl->setVariable("ROW_ALT", $alt);
00989                         $a_tpl->parseCurrentBlock();
00990                         $nbsp = false;
00991                 }
00992 
00993                 if ($this->isActiveAdministrationPanel())
00994                 {
00995                         $a_tpl->setCurrentBlock("block_row_check");
00996                         $a_tpl->setVariable("ITEM_ID", $a_item_ref_id);
00997                         $a_tpl->parseCurrentBlock();
00998                         $nbsp = false;
00999                 }
01000                 if ($nbsp)
01001                 {
01002                         $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
01003                 }
01004                 $a_tpl->setCurrentBlock("container_standard_row");
01005                 $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
01006                 $a_tpl->parseCurrentBlock();
01007                 $a_tpl->touchBlock("container_row");
01008         }
01009 
01013         function addMessageRow(&$a_tpl, $a_message, $a_type)
01014         {
01015                 $this->cur_row_type = ($this->cur_row_type == "row_type_1")
01016                         ? "row_type_2"
01017                         : "row_type_1";
01018 
01019                 $a_tpl->touchBlock($this->cur_row_type);
01020                 
01021                 if ($a_type != "lres")
01022                 {
01023                         $type = $this->lng->txt("obj_".$a_type);
01024                 }
01025                 else
01026                 {
01027                         $type = $this->lng->txt("learning_resource");
01028                 }
01029                 $a_message = str_replace("[type]", $type, $a_message);
01030                 
01031                 $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
01032 
01033                 $a_tpl->setCurrentBlock("container_standard_row");
01034                 $a_tpl->setVariable("BLOCK_ROW_CONTENT",
01035                         $a_message);
01036                 $a_tpl->parseCurrentBlock();
01037                 $a_tpl->touchBlock("container_row");
01038         }
01039 
01040         function resetRowType()
01041         {
01042                 $this->cur_row_type = "";
01043         }
01044 
01045         function addSeparatorRow(&$a_tpl)
01046         {
01047                 $a_tpl->touchBlock("separator_row");
01048                 $a_tpl->touchBlock("container_row");
01049         }
01050         
01051         function setPageEditorTabs()
01052         {
01053                 global $lng;
01054                 
01055                 if (!$this->isActiveAdministrationPanel()
01056                         || strtolower($this->ctrl->getCmdClass()) != "ilpageobjectgui")
01057                 {
01058                         return;
01059                 }
01060 
01061                 $lng->loadLanguageModule("content");
01062                 //$tabs_gui = new ilTabsGUI();
01063                 //$tabs_gui->setSubTabs();
01064                 
01065                 // back to upper context
01066                 $this->tabs_gui->setBackTarget($this->lng->txt("obj_cat"),
01067                         $this->ctrl->getLinkTarget($this, "frameset"),
01068                         ilFrameTargetInfo::_getFrame("MainContent"));
01069 
01070                 $this->tabs_gui->addTarget("edit", $this->ctrl->getLinkTargetByClass("ilpageobjectgui", "view")
01071                         , array("", "view"), "ilpageobjectgui");
01072 
01073                 //$this->tpl->setTabs($tabs_gui->getHTML());
01074         }
01075 
01076 
01081         function getTabs(&$tabs_gui)
01082         {
01083                 global $rbacsystem;
01084 
01085                 // edit permissions
01086                 if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
01087                 {
01088                         $tabs_gui->addTarget("perm_settings",
01089                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
01090                 }
01091 
01092                 // show clipboard
01093                 if ($this->ctrl->getTargetScript() == "repository.php" and !empty($_SESSION["clipboard"]))
01094                 {
01095                         $tabs_gui->addTarget("clipboard",
01096                                  $this->ctrl->getLinkTarget($this, "clipboard"), "clipboard", get_class($this));
01097                 }
01098 
01099         }
01100 
01101         //*****************
01102         // COMMON METHODS (may be overwritten in derived classes
01103         // if special handling is necessary)
01104         //*****************
01105 
01109         function enableAdministrationPanelObject()
01110         {
01111                 $_SESSION["il_cont_admin_panel"] = true;
01112                 $this->ctrl->redirect($this, "render");
01113         }
01114 
01118         function disableAdministrationPanelObject()
01119         {
01120                 $_SESSION["il_cont_admin_panel"] = false;
01121                 $this->ctrl->redirect($this, "render");
01122         }
01123         
01127         function addToDeskObject()
01128         {
01129                 if ($_GET["item_ref_id"] and $_GET["type"])
01130                 {
01131                         $this->ilias->account->addDesktopItem($_GET["item_ref_id"], $_GET["type"]);
01132                 }
01133                 else
01134                 {
01135                         if ($_POST["items"])
01136                         {
01137                                 foreach ($_POST["items"] as $item)
01138                                 {
01139                                         $type = ilObject::_lookupType($item, true);
01140                                         $this->ilias->account->addDesktopItem($item, $type);
01141                                         unset($tmp_obj);
01142                                 }
01143                         }
01144                 }
01145                 $this->renderObject();
01146         }
01147 
01151         function removeFromDeskObject()
01152         {
01153                 if ($_GET["item_ref_id"] and $_GET["type"])
01154                 {
01155                         $this->ilias->account->dropDesktopItem($_GET["item_ref_id"], $_GET["type"]);
01156                 }
01157                 else
01158                 {
01159                         if ($_POST["items"])
01160                         {
01161                                 foreach ($_POST["items"] as $item)
01162                                 {
01163                                         $type = ilObject::_lookupType($item, true);
01164                                         $this->ilias->account->dropDesktopItem($item, $type);
01165                                         unset($tmp_obj);
01166                                 }
01167                         }
01168                 }
01169                 $this->renderObject();
01170         }
01171 
01172 
01179         function cutObject()
01180         {
01181                 global $rbacsystem;
01182                 
01183                 if ($_GET["item_ref_id"] != "")
01184                 {
01185                         $_POST["id"] = array($_GET["item_ref_id"]);
01186                 }
01187 
01188                 //$this->ilias->raiseError("move operation does not work at the moment and is disabled",$this->ilias->error_obj->MESSAGE);
01189 
01190 //echo "CUT";
01191 //echo $_SESSION["referer"];
01192                 if (!isset($_POST["id"]))
01193                 {
01194                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01195                 }
01196 
01197                 // FOR ALL OBJECTS THAT SHOULD BE COPIED
01198                 foreach ($_POST["id"] as $ref_id)
01199                 {
01200                         // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
01201                         $node_data = $this->tree->getNodeData($ref_id);
01202                         $subtree_nodes = $this->tree->getSubTree($node_data);
01203 
01204                         $all_node_data[] = $node_data;
01205                         $all_subtree_nodes[] = $subtree_nodes;
01206 
01207                         // CHECK DELETE PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
01208                         foreach ($subtree_nodes as $node)
01209                         {
01210                                 if (!$rbacsystem->checkAccess('delete',$node["ref_id"]))
01211                                 {
01212                                         $no_cut[] = $node["ref_id"];
01213                                 }
01214                         }
01215                 }
01216                 // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'delete'
01217                 if (count($no_cut))
01218                 {
01219                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_cut")." ".implode(',',$this->getTitlesByRefId($no_cut)),
01220                                                                          $this->ilias->error_obj->MESSAGE);
01221                 }
01222                 //echo "GET";var_dump($_GET);echo "POST";var_dump($_POST);
01223                 $_SESSION["clipboard"]["parent"] = $_GET["ref_id"];
01224                 $_SESSION["clipboard"]["cmd"] = ($_GET["cmd"] != "" && $_GET["cmd"] != "post")
01225                         ? $_GET["cmd"]
01226                         : key($_POST["cmd"]);
01227 //echo "-".$clipboard["cmd"]."-";
01228                 $_SESSION["clipboard"]["ref_ids"] = $_POST["id"];
01229 //echo "-".$_SESSION["clipboard"]["cmd"]."-";
01230 
01231                 sendinfo($this->lng->txt("msg_cut_clipboard"),true);
01232 
01233                 $this->ctrl->returnToParent($this);
01234 
01235         } // END CUT
01236 
01237 
01244         function linkObject()
01245         {
01246                 global $clipboard, $rbacsystem, $rbacadmin;
01247                 
01248                 if ($_GET["item_ref_id"] != "")
01249                 {
01250                         $_POST["id"] = array($_GET["item_ref_id"]);
01251                 }
01252 
01253                 if (!isset($_POST["id"]))
01254                 {
01255                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01256                 }
01257 
01258                 // CHECK ACCESS
01259                 foreach ($_POST["id"] as $ref_id)
01260                 {
01261                         if (!$rbacsystem->checkAccess('delete',$ref_id))
01262                         {
01263                                 $no_cut[] = $ref_id;
01264                         }
01265 
01266                         $object =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
01267 
01268                         if (!$this->objDefinition->allowLink($object->getType()))
01269                         {
01270                                 $no_link[] = $object->getType();
01271                         }
01272                 }
01273 
01274                 // NO ACCESS
01275                 if (count($no_cut))
01276                 {
01277                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_link")." ".
01278                                                                          implode(',',$no_cut),$this->ilias->error_obj->MESSAGE);
01279                 }
01280 
01281                 if (count($no_link))
01282                 {
01283                         $no_link = array_unique($no_link);
01284 
01285                         foreach ($no_link as $type)
01286                         {
01287                                 $txt_objs[] = $this->lng->txt("objs_".$type);
01288                         }
01289 
01290                         $this->ilias->raiseError(implode(', ',$txt_objs)." ".$this->lng->txt("msg_obj_no_link"),$this->ilias->error_obj->MESSAGE);
01291 
01292                         //$this->ilias->raiseError($this->lng->txt("msg_not_possible_link")." ".
01293                         //                                               implode(',',$no_link),$this->ilias->error_obj->MESSAGE);
01294                 }
01295 
01296                 // WRITE TO CLIPBOARD
01297                 $clipboard["parent"] = $_GET["ref_id"];
01298                 $clipboard["cmd"] = ($_GET["cmd"] != "" && $_GET["cmd"] != "post")
01299                         ? $_GET["cmd"]
01300                         : key($_POST["cmd"]);
01301 
01302                 foreach ($_POST["id"] as $ref_id)
01303                 {
01304                         $clipboard["ref_ids"][] = $ref_id;
01305                 }
01306 
01307                 $_SESSION["clipboard"] = $clipboard;
01308 
01309                 sendinfo($this->lng->txt("msg_link_clipboard"),true);
01310 
01311                 $this->ctrl->returnToParent($this);
01312 
01313         } // END LINK
01314 
01315 
01321         function clearObject()
01322         {
01323                 unset($_SESSION["clipboard"]);
01324                 unset($_SESSION["il_rep_clipboard"]);
01325                 //var_dump($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
01326 
01327                 // only redirect if clipboard was cleared
01328                 if (isset($_POST["cmd"]["clear"]))
01329                 {
01330                         sendinfo($this->lng->txt("msg_clear_clipboard"),true);
01331 
01332                         $this->ctrl->returnToParent($this);
01333                         //ilUtil::redirect($this->getReturnLocation("clear",$this->ctrl->getLinkTarget($this)),get_class($this));
01334                 }
01335         }
01336 
01343         function pasteObject()
01344         {
01345                 global $rbacsystem, $rbacadmin, $rbacreview, $log;
01346 
01347 //var_dump($_SESSION["clipboard"]);exit;
01348                 if (!in_array($_SESSION["clipboard"]["cmd"],array("cut","link","copy")))
01349                 {
01350                         $message = get_class($this)."::pasteObject(): cmd was neither 'cut','link' or 'copy'; may be a hack attempt!";
01351                         $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
01352                 }
01353 
01354                 // this loop does all checks
01355                 foreach ($_SESSION["clipboard"]["ref_ids"] as $ref_id)
01356                 {
01357                         $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($ref_id);
01358 
01359                         // CHECK ACCESS
01360                         if (!$rbacsystem->checkAccess('create',$this->object->getRefId(), $obj_data->getType()))
01361                         {
01362                                 $no_paste[] = $ref_id;
01363                         }
01364 
01365                         // CHECK IF REFERENCE ALREADY EXISTS
01366                         if ($this->object->getRefId() == $this->tree->getParentId($obj_data->getRefId()))
01367                         {
01368                                 $exists[] = $ref_id;
01369                                 break;
01370                         }
01371 
01372                         // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
01373                         if ($this->tree->isGrandChild($ref_id,$this->object->getRefId()))
01374                         {
01375                                 $is_child[] = $ref_id;
01376                         }
01377 
01378                         // CHECK IF OBJECT IS ALLOWED TO CONTAIN PASTED OBJECT AS SUBOBJECT
01379                         $obj_type = $obj_data->getType();
01380 
01381                         if (!in_array($obj_type, array_keys($this->objDefinition->getSubObjects($this->object->getType()))))
01382                         {
01383                                 $not_allowed_subobject[] = $obj_data->getType();
01384                         }
01385                 }
01386 
01388                 // process checking results
01389                 if (count($exists))
01390                 {
01391                         $this->ilias->raiseError($this->lng->txt("msg_obj_exists"),$this->ilias->error_obj->MESSAGE);
01392                 }
01393 
01394                 if (count($is_child))
01395                 {
01396                         $this->ilias->raiseError($this->lng->txt("msg_not_in_itself")." ".implode(',',$is_child),
01397                                                                          $this->ilias->error_obj->MESSAGE);
01398                 }
01399 
01400                 if (count($not_allowed_subobject))
01401                 {
01402                         $this->ilias->raiseError($this->lng->txt("msg_may_not_contain")." ".implode(',',$not_allowed_subobject),
01403                                                                          $this->ilias->error_obj->MESSAGE);
01404                 }
01405 
01406                 if (count($no_paste))
01407                 {
01408                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_paste")." ".
01409                                                                          implode(',',$no_paste),$this->ilias->error_obj->MESSAGE);
01410                 }
01411 
01412                 // log pasteObject call
01413                 $log->write("ilObjectGUI::pasteObject(), cmd: ".$_SESSION["clipboard"]["cmd"]);
01414 
01416                 // everything ok: now paste the objects to new location
01417 
01418                 // to prevent multiple actions via back/reload button
01419                 $ref_ids = $_SESSION["clipboard"]["ref_ids"];
01420                 unset($_SESSION["clipboard"]["ref_ids"]);
01421 
01422                 // process COPY command
01423                 if ($_SESSION["clipboard"]["cmd"] == "copy")
01424                 {
01425                         // CALL PRIVATE CLONE METHOD
01426                         $this->cloneObject($ref_ids);
01427                 }
01428 
01429                 // process CUT command
01430                 if ($_SESSION["clipboard"]["cmd"] == "cut")
01431                 {
01432                         // get subtrees
01433                         foreach($ref_ids as $ref_id)
01434                         {
01435                                 // get node data
01436                                 $top_node = $this->tree->getNodeData($ref_id);
01437 
01438                                 // get subnodes of top nodes
01439                                 $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
01440                         }
01441 
01442                         // STEP 1: Move all subtrees to trash
01443                         $log->write("ilObjectGUI::pasteObject(), (1/3) move subtrees to trash");
01444 
01445                         foreach($ref_ids as $ref_id)
01446                         {
01447                                 $tnodes = $this->tree->getSubtree($this->tree->getNodeData($ref_id));
01448 
01449                                 foreach ($tnodes as $tnode)
01450                                 {
01451                                         $rbacadmin->revokePermission($tnode["child"],0,false);
01452                                         
01453                                         // we don't remove the item from the personal desktop,
01454                                         // just due to moving it
01455                                         //$affected_users = ilUtil::removeItemFromDesktops($tnode["child"]);
01456                                 }
01457 
01458                                 $this->tree->saveSubTree($ref_id);
01459                                 $this->tree->deleteTree($this->tree->getNodeData($ref_id));
01460                         }
01461 
01462                         // STEP 2: Move all subtrees to new location
01463                         $log->write("ilObjectGUI::pasteObject(), (2/3) move subtrees to new location");
01464 
01465                         // TODO: this whole put in place again stuff needs revision. Permission settings get lost.
01466                         foreach ($subnodes as $key => $subnode)
01467                         {
01468 $log->write("ilObjectGUI::pasteObject(), 0");
01469                                 // first paste top_node ...
01470                                 $rbacadmin->revokePermission($key,0,false);
01471 $log->write("ilObjectGUI::pasteObject(), 1");
01472                                 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
01473 $log->write("ilObjectGUI::pasteObject(), 2");
01474                                 $obj_data->putInTree($this->object->getRefId());
01475 $log->write("ilObjectGUI::pasteObject(), 3");
01476                                 $obj_data->setPermissions($key);
01477 $log->write("ilObjectGUI::pasteObject(), 4");
01478                                 // log entry
01479                                 $log->write("ilObjectGUI::pasteObject(), inserted top node. ref_id: $key,".
01480                                         " rgt: ".$subnode[0]["rgt"].", lft: ".$subnode[0]["lft"].", parent: ".$subnode[0]["parent"].",".
01481                                         " obj_id: ".$obj_data->getId().", type: ".$obj_data->getType().
01482                                         ", title: ".$obj_data->getTitle());
01483 
01484                                 // ... remove top_node from list ...
01485                                 array_shift($subnode);
01486 
01487                                 // ... insert subtree of top_node if any subnodes exist
01488                                 if (count($subnode) > 0)
01489                                 {
01490                                         foreach ($subnode as $node)
01491                                         {
01492                                                 $rbacadmin->revokePermission($node["child"],0,false);
01493                                                 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
01494                                                 $obj_data->putInTree($node["parent"]);
01495                                                 $obj_data->setPermissions($node["parent"]);
01496 
01497                                                 // log entry
01498                                                 $log->write("ilObjectGUI::pasteObject(), inserted subnode. ref_id: ".$node["child"].",".
01499                                                         " rgt: ".$node["rgt"].", lft: ".$node["lft"].", parent: ".$node["parent"].",".
01500                                                         " obj_id: ".$obj_data->getId().", type: ".$obj_data->getType().
01501                                                         ", title: ".$obj_data->getTitle());
01502                                         }
01503                                 }
01504                         }
01505 
01506                         // STEP 3: Remove trashed objects from system
01507                         $log->write("ilObjectGUI::pasteObject(), (3/3) remove trashed subtrees from system");
01508 
01509                         foreach ($ref_ids as $ref_id)
01510                         {
01511                                 // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
01512                                 $saved_tree = new ilTree(-(int)$ref_id);
01513                                 $node_data = $saved_tree->getNodeData($ref_id);
01514                                 $subtree_nodes = $saved_tree->getSubTree($node_data);
01515 
01516                                 // remember already checked deleted node_ids
01517                                 $checked[] = -(int) $ref_id;
01518 
01519                                 // dive in recursive manner in each already deleted subtrees and remove these objects too
01520                                 $this->removeDeletedNodes($ref_id, $checked, false);
01521 
01522                                 // delete save tree
01523                                 $this->tree->deleteTree($node_data);
01524 
01525                                 // write log entry
01526                                 $log->write("ilObjectGUI::pasteObject(), deleted tree, tree_id: ".$node_data["tree"].
01527                                         ", child: ".$node_data["child"]);
01528                         }
01529 
01530 
01531                         $log->write("ilObjectGUI::pasteObject(), cut finished");
01532 
01533                         // inform other objects in hierarchy about paste operation
01534                         //$this->object->notify("paste",$this->object->getRefId(),$_SESSION["clipboard"]["parent_non_rbac_id"],$this->object->getRefId(),$subnodes);
01535 
01536                         // inform other objects in hierarchy about cut operation
01537                         // the parent object where cut occured
01538                         $tmp_object = $this->ilias->obj_factory->getInstanceByRefId($_SESSION["clipboard"]["parent"]);
01539                         //$tmp_object->notify("cut", $tmp_object->getRefId(),$_SESSION["clipboard"]["parent_non_rbac_id"],$tmp_object->getRefId(),$ref_ids);
01540                         unset($tmp_object);
01541                 } // END CUT
01542 
01543                 // process LINK command
01544                 if ($_SESSION["clipboard"]["cmd"] == "link")
01545                 {
01546                         foreach ($ref_ids as $ref_id)
01547                         {
01548                                 // get node data
01549                                 $top_node = $this->tree->getNodeData($ref_id);
01550 
01551                                 // get subnodes of top nodes
01552                                 $subnodes[$ref_id] = $this->tree->getSubtree($top_node);
01553                         }
01554 
01555                         // now move all subtrees to new location
01556                         foreach ($subnodes as $key => $subnode)
01557                         {
01558                                 // first paste top_node....
01559                                 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($key);
01560                                 $new_ref_id = $obj_data->createReference();
01561                                 $obj_data->putInTree($_GET["ref_id"]);
01562                                 $obj_data->setPermissions($_GET["ref_id"]);
01563 
01564                                 // ... remove top_node from list ...
01565                                 array_shift($subnode);
01566 
01567                                 // ... store mapping of old ref_id => new_ref_id in hash array ...
01568                                 $mapping[$new_ref_id] = $key;
01569 
01570                                 // save old ref_id & create rolefolder if applicable
01571                                 $old_ref_id = $obj_data->getRefId();
01572                                 $obj_data->setRefId($new_ref_id);
01573                                 $obj_data->initDefaultRoles();
01574                                 $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
01575 
01576                                 if (isset($rolf_data["child"]))
01577                                 {
01578                                         // a role folder was created, so map it to old role folder
01579                                         $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
01580 
01581                                         // ... use mapping array to find out the correct new parent node where to put in the node...
01582                                         //$new_parent = array_search($node["parent"],$mapping);
01583                                         // ... append node to mapping for further possible subnodes ...
01584                                         $mapping[$rolf_data["child"]] = (int) $rolf_data_old["child"];
01585 
01586                                         // log creation of role folder
01587                                         $log->write("ilObjectGUI::pasteObject(), created role folder (ref_id): ".$rolf_data["child"].
01588                                                 ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
01589                                                 ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
01590 
01591                                 }
01592 
01593                                 // ... insert subtree of top_node if any subnodes exist ...
01594                                 if (count($subnode) > 0)
01595                                 {
01596                                         foreach ($subnode as $node)
01597                                         {
01598                                                 if ($node["type"] != 'rolf')
01599                                                 {
01600                                                         $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($node["child"]);
01601                                                         $new_ref_id = $obj_data->createReference();
01602 
01603                                                         // ... use mapping array to find out the correct new parent node where to put in the node...
01604                                                         $new_parent = array_search($node["parent"],$mapping);
01605                                                         // ... append node to mapping for further possible subnodes ...
01606                                                         $mapping[$new_ref_id] = (int) $node["child"];
01607 
01608                                                         $obj_data->putInTree($new_parent);
01609                                                         $obj_data->setPermissions($new_parent);
01610 
01611                                                         // save old ref_id & create rolefolder if applicable
01612                                                         $old_ref_id = $obj_data->getRefId();
01613                                                         $obj_data->setRefId($new_ref_id);
01614                                                         $obj_data->initDefaultRoles();
01615                                                         $rolf_data = $rbacreview->getRoleFolderOfObject($obj_data->getRefId());
01616 
01617                                                         if (isset($rolf_data["child"]))
01618                                                         {
01619                                                                 // a role folder was created, so map it to old role folder
01620                                                                 $rolf_data_old = $rbacreview->getRoleFolderOfObject($old_ref_id);
01621 
01622                                                                 // ... use mapping array to find out the correct new parent node where to put in the node...
01623                                                                 //$new_parent = array_search($node["parent"],$mapping);
01624                                                                 // ... append node to mapping for further possible subnodes ...
01625                                                                 $mapping[$rolf_data["child"]] = (int) $rolf_data_old["child"];
01626 
01627                                                                 // log creation of role folder
01628                                                                 $log->write("ilObjectGUI::pasteObject(), created role folder (ref_id): ".$rolf_data["child"].
01629                                                                         ", for object ref_id:".$obj_data->getRefId().", obj_id: ".$obj_data->getId().
01630                                                                         ", type: ".$obj_data->getType().", title: ".$obj_data->getTitle());
01631 
01632                                                         }
01633                                                 }
01634 
01635                                                 // re-map $subnodes
01636                                                 foreach ($subnodes as $old_ref => $subnode)
01637                                                 {
01638                                                         $new_ref = array_search($old_ref,$mapping);
01639 
01640                                                         foreach ($subnode as $node)
01641                                                         {
01642                                                                 $node["child"] = array_search($node["child"],$mapping);
01643                                                                 $node["parent"] = array_search($node["parent"],$mapping);
01644                                                                 $new_subnodes[$ref_id][] = $node;
01645                                                         }
01646                                                 }
01647 
01648                                         }
01649                                 }
01650                         }
01651 
01652                         $log->write("ilObjectGUI::pasteObject(), link finished");
01653 
01654                         // inform other objects in hierarchy about link operation
01655                         //$this->object->notify("link",$this->object->getRefId(),$_SESSION["clipboard"]["parent_non_rbac_id"],$this->object->getRefId(),$subnodes);
01656                 } // END LINK
01657 
01658                 // save cmd for correct message output after clearing the clipboard
01659                 $last_cmd = $_SESSION["clipboard"]["cmd"];
01660 
01661 
01662                 // clear clipboard
01663                 $this->clearObject();
01664 
01665                 if ($last_cmd == "cut")
01666                 {
01667                         sendInfo($this->lng->txt("msg_cut_copied"),true);
01668                 }
01669                 else
01670                 {
01671                         sendInfo($this->lng->txt("msg_linked"),true);
01672                 }
01673 
01674                 $this->ctrl->returnToParent($this);
01675 
01676         } // END PASTE
01677 
01678 
01679 
01683         function clipboardObject()
01684         {
01685                 global $ilErr,$ilLog;
01686 
01687                 // function should not be called if clipboard is empty
01688                 if (empty($_SESSION['clipboard']) or !is_array($_SESSION['clipboard']))
01689                 {
01690                         $message = sprintf('%s::clipboardObject(): Illegal access. Clipboard variable is empty!', get_class($this));
01691                         $ilLog->write($message,$ilLog->FATAL);
01692                         $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->WARNING);
01693                 }
01694 
01695                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.rep_clipboard.html");
01696 
01697                 // FORMAT DATA
01698                 $counter = 0;
01699                 $f_result = array();
01700 
01701                 foreach($_SESSION["clipboard"]["ref_ids"] as $ref_id)
01702                 {
01703                         if(!$tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id,false))
01704                         {
01705                                 continue;
01706                         }
01707 
01708                         //$f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user);
01709                         $f_result[$counter][] = $this->lng->txt("obj_".$tmp_obj->getType());
01710                         $f_result[$counter][] = $tmp_obj->getTitle();
01711                         //$f_result[$counter][] = $tmp_obj->getDescription();
01712                         $f_result[$counter][] = ($_SESSION["clipboard"]["cmd"] == "cut") ? $this->lng->txt("move") :$this->lng->txt($_SESSION["clipboard"]["cmd"]);
01713 
01714                         unset($tmp_obj);
01715                         ++$counter;
01716                 }
01717 
01718                 $this->__showClipboardTable($f_result, "clipboardObject");
01719 
01720                 return true;
01721         }
01722 
01723         
01728         function showCustomIconsEditing($a_input_colspan = 1)
01729         {
01730                 if ($this->ilias->getSetting("custom_icons"))
01731                 {
01732                         $this->tpl->addBlockFile("CONTAINER_ICONS", "container_icon_settings",
01733                                 "tpl.container_icon_settings.html");
01734 
01735                         if (($big_icon = $this->object->getBigIconPath()) != "")
01736                         {
01737                                 $this->tpl->setCurrentBlock("big_icon");
01738                                 $this->tpl->setVariable("SRC_BIG_ICON", $big_icon);
01739                                 $this->tpl->parseCurrentBlock();
01740                         }
01741                         if (($small_icon = $this->object->getSmallIconPath()) != "")
01742                         {
01743                                 $this->tpl->setCurrentBlock("small_icon");
01744                                 $this->tpl->setVariable("SRC_SMALL_ICON", $small_icon);
01745                                 $this->tpl->parseCurrentBlock();
01746                         }
01747                         $this->tpl->setCurrentBlock("container_icon_settings");
01748                         $this->tpl->setVariable("SPAN_TITLE", $a_input_colspan + 1);
01749                         $this->tpl->setVariable("SPAN_INPUT", $a_input_colspan);
01750                         $this->tpl->setVariable("ICON_SETTINGS", $this->lng->txt("icon_settings"));
01751                         $this->tpl->setVariable("BIG_ICON", $this->lng->txt("big_icon"));
01752                         $this->tpl->setVariable("SMALL_ICON", $this->lng->txt("small_icon"));
01753                         $this->tpl->setVariable("BIG_SIZE", "(".
01754                                 $this->ilias->getSetting("custom_icon_big_width")."x".
01755                                 $this->ilias->getSetting("custom_icon_big_height").")");
01756                         $this->tpl->setVariable("SMALL_SIZE", "(".
01757                                 $this->ilias->getSetting("custom_icon_small_width")."x".
01758                                 $this->ilias->getSetting("custom_icon_small_height").")");
01759                         $this->tpl->setVariable("TXT_REMOVE", $this->lng->txt("remove"));
01760                         $this->tpl->parseCurrentBlock();
01761                 }
01762         }
01763 
01764         function isActiveAdministrationPanel()
01765         {
01766                 return $_SESSION["il_cont_admin_panel"];
01767         }
01768 
01769 }
01770 ?>

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