00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00036 require_once "class.ilContainerGUI.php";
00037 require_once "./Modules/Category/classes/class.ilObjCategoryGUI.php";
00038
00039 class ilObjRootFolderGUI extends ilContainerGUI
00040 {
00045 function ilObjRootFolderGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
00046 {
00047 $this->type = "root";
00048 $this->ilContainerGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
00049 }
00050
00054 function importCategoriesFormObject ()
00055 {
00056 ilObjCategoryGUI::_importCategoriesForm($this->ref_id, $this->tpl);
00057 }
00058
00064 function importCancelledObject()
00065 {
00066 ilUtil::sendInfo($this->lng->txt("action_aborted"),true);
00067 $this->ctrl->returnToParent($this);
00068 }
00069
00073 function importCategoriesObject()
00074 {
00075 ilObjCategoryGUI::_importCategories($this->ref_id,0);
00076 }
00077
00078
00082 function importCategoriesWithRolObject()
00083 {
00084 ilObjCategoryGUI::_importCategories($this->ref_id,1);
00085 }
00086
00087
00088 function getTabs(&$tabs_gui)
00089 {
00090 global $rbacsystem;
00091
00092 $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
00093
00094 if ($rbacsystem->checkAccess('read',$this->ref_id))
00095 {
00096 $tabs_gui->addTarget("view_content",
00097 $this->ctrl->getLinkTarget($this, ""),
00098 array("", "view", "render"));
00099 }
00100
00101 if ($rbacsystem->checkAccess('write',$this->ref_id))
00102 {
00103 $force_active = ($_GET["cmd"] == "edit")
00104 ? true
00105 : false;
00106 $tabs_gui->addTarget("edit_properties",
00107 $this->ctrl->getLinkTarget($this, "edit"), "edit", get_class($this)
00108 , "", $force_active);
00109 }
00110
00111
00112 parent::getTabs($tabs_gui);
00113
00114 }
00115
00116 function &executeCommand()
00117 {
00118 global $rbacsystem;
00119
00120 $next_class = $this->ctrl->getNextClass($this);
00121 $cmd = $this->ctrl->getCmd();
00122
00123 switch($next_class)
00124 {
00125 case 'ilcontainerlinklistgui':
00126 include_once("./classes/class.ilContainerLinkListGUI.php");
00127 $link_list_gui =& new ilContainerLinkListGUI();
00128 $ret =& $this->ctrl->forwardCommand($link_list_gui);
00129 break;
00130
00131
00132 case "ilpageobjectgui":
00133 $this->tpl->getStandardTemplate();
00134 $this->setLocator();
00135 ilUtil::sendInfo();
00136 ilUtil::infoPanel();
00137
00138 $ret = $this->forwardToPageObject();
00139 $this->setTitleAndDescription();
00140 $this->setPageEditorTabs();
00141 return $ret;
00142 break;
00143
00144 case 'ilpermissiongui':
00145 $this->prepareOutput();
00146 include_once("./classes/class.ilPermissionGUI.php");
00147 $perm_gui =& new ilPermissionGUI($this);
00148 $ret =& $this->ctrl->forwardCommand($perm_gui);
00149 break;
00150
00151 default:
00152 $this->prepareOutput();
00153 include_once("classes/class.ilObjStyleSheet.php");
00154 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00155 ilObjStyleSheet::getContentStylePath(0));
00156
00157 if(!$cmd)
00158 {
00159 $cmd = "render";
00160 }
00161
00162 $cmd .= "Object";
00163 $this->$cmd();
00164
00165 break;
00166 }
00167 return true;
00168 }
00169
00175 function editObject()
00176 {
00177 global $rbacsystem, $lng;
00178
00179 if (!$rbacsystem->checkAccess("write", $this->ref_id))
00180 {
00181 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00182 }
00183
00184 $this->ctrl->setParameter($this,"mode","edit");
00185
00186
00187 include_once "./Services/MetaData/classes/class.ilMDLanguageItem.php";
00188
00189 $this->getTemplateFile("edit",'');
00190 $this->showSortingSettings();
00191
00192 $array_push = true;
00193
00194 if ($_SESSION["error_post_vars"])
00195 {
00196 $_SESSION["translation_post"] = $_SESSION["error_post_vars"];
00197 $_GET["mode"] = "session";
00198 $array_push = false;
00199 }
00200
00201
00202 if (($_GET["mode"] != "session"))
00203 {
00204 $data = $this->object->getTranslations();
00205 $_SESSION["translation_post"] = $data;
00206 $array_push = false;
00207 }
00208 elseif ($_GET["entry"] != 0)
00209 {
00210 array_splice($_SESSION["translation_post"]["Fobject"],$_GET["entry"],1,array());
00211
00212 if ($_GET["entry"] == $_SESSION["translation_post"]["default_language"])
00213 {
00214 $_SESSION["translation_post"]["default_language"] = "";
00215 }
00216 }
00217
00218 $data = $_SESSION["translation_post"];
00219
00220
00221 if (!$_GET["entry"] and $array_push)
00222 {
00223 $count = array_push($data["Fobject"],array("title" => "","desc" => ""));
00224 }
00225 else
00226 {
00227 $count = count($data["Fobject"]);
00228 }
00229
00230
00231 $strip = isset($_SESSION["translation_post"]) ? true : false;
00232
00233
00234 if (count($data["Fobject"]) == 0)
00235 {
00236 $data["Fobject"][0] =
00237 array("title" => "",
00238 "desc" => "",
00239 "lang" => $lng->getDefaultLanguage()
00240 );
00241 }
00242
00243 foreach ($data["Fobject"] as $key => $val)
00244 {
00245
00246 if ($key == $count -1)
00247 {
00248 $this->tpl->setCurrentBlock("addTranslation");
00249 $this->tpl->setVariable("TXT_ADD_TRANSLATION",$this->lng->txt("add_translation")." >>");
00250 $this->tpl->parseCurrentBlock();
00251 }
00252
00253
00254 if ($key != 0)
00255 {
00256 $this->tpl->setCurrentBlock("removeTranslation");
00257 $this->tpl->setVariable("TXT_REMOVE_TRANSLATION",$this->lng->txt("remove_translation"));
00258 $this->ctrl->setParameter($this, "entry", $key);
00259 $this->ctrl->setParameter($this, "mode", "edit");
00260 $this->tpl->setVariable("LINK_REMOVE_TRANSLATION", $this->ctrl->getLinkTarget($this, "removeTranslation"));
00261 $this->tpl->parseCurrentBlock();
00262 }
00263
00264
00265 $this->tpl->addBlockFile("SEL_LANGUAGE", "sel_language", "tpl.lang_selection.html", false);
00266 $this->tpl->setVariable("SEL_NAME", "Fobject[".$key."][lang]");
00267
00268 $languages = ilMDLanguageItem::_getLanguages();
00269
00270 foreach ($languages as $code => $language)
00271 {
00272 $this->tpl->setCurrentBlock("lg_option");
00273 $this->tpl->setVariable("VAL_LG", $code);
00274 $this->tpl->setVariable("TXT_LG", $language);
00275
00276 if ($code == $val["lang"])
00277 {
00278 $this->tpl->setVariable("SELECTED", "selected=\"selected\"");
00279 }
00280
00281 $this->tpl->parseCurrentBlock();
00282 }
00283
00284
00285 $this->tpl->setCurrentBlock("obj_form");
00286
00287 if ($key == 0)
00288 {
00289 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("repository"));
00290 }
00291 else
00292 {
00293 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("translation")." ".$key);
00294 }
00295
00296 if ($key == $data["default_language"])
00297 {
00298 $this->tpl->setVariable("CHECKED", "checked=\"checked\"");
00299 }
00300
00301 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00302 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("title_long"));
00303 $this->tpl->setVariable("TXT_DEFAULT", $this->lng->txt("default"));
00304 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00305 $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($val["title"],$strip));
00306 $this->tpl->setVariable("DESC", ilUtil::stripSlashes($val["desc"]));
00307 $this->tpl->setVariable("NUM", $key);
00308 $this->tpl->parseCurrentBlock();
00309 }
00310
00311 $this->showCustomIconsEditing();
00312
00313
00314 $this->tpl->setCurrentBlock("adm_content");
00315 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00316 $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
00317 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00318 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00319 $this->tpl->setVariable("CMD_SUBMIT", "update");
00320 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00321 }
00322
00326 function setTitleAndDescription()
00327 {
00328 global $lng;
00329
00330 parent::setTitleAndDescription();
00331 $this->tpl->setDescription("");
00332 if ($this->object->getTitle() == "ILIAS")
00333 {
00334 $this->tpl->setTitle($lng->txt("repository"));
00335 }
00336 else
00337 {
00338 if ($this->object->getDescription() != "")
00339 {
00340 $this->tpl->setTitle($this->object->getDescription());
00341 }
00342 }
00343 }
00344
00350 function updateObject()
00351 {
00352 global $rbacsystem;
00353 if (!$rbacsystem->checkAccess("write", $this->object->getRefId()))
00354 {
00355 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
00356 }
00357 else
00358 {
00359 $data = $_POST;
00360
00361
00362 if (!isset($data["default_language"]))
00363 {
00364 $this->ilias->raiseError($this->lng->txt("msg_no_default_language"),$this->ilias->error_obj->MESSAGE);
00365 }
00366
00367
00368 foreach ($data["Fobject"] as $key => $val)
00369 {
00370 $langs[$key] = $val["lang"];
00371 }
00372
00373 $langs = array_count_values($langs);
00374
00375
00376 if (array_key_exists("",$langs) &&
00377 (count($data["Fobject"]) > 1 || $data["Fobject"][0]["title"] != ""))
00378 {
00379 $this->ilias->raiseError($this->lng->txt("msg_no_language_selected"),$this->ilias->error_obj->MESSAGE);
00380 }
00381
00382
00383 if (array_sum($langs) > count($langs))
00384 {
00385 $this->ilias->raiseError($this->lng->txt("msg_multi_language_selected"),$this->ilias->error_obj->MESSAGE);
00386 }
00387
00388
00389 $_POST["Fobject"]["title"] = $_POST["Fobject"][$_POST["default_language"]]["title"];
00390 $_POST["Fobject"]["desc"] = $_POST["Fobject"][$_POST["default_language"]]["desc"];
00391
00392
00393 $this->object->removeTranslations();
00394
00395
00396 foreach ($data["Fobject"] as $key => $val)
00397 {
00398 if ($key == $data["default_language"])
00399 {
00400 $default = 1;
00401 }
00402 else
00403 {
00404 $default = 0;
00405 }
00406
00407 if (trim($val["title"]) != "")
00408 {
00409 $this->object->addTranslation(ilUtil::stripSlashes($val["title"]),ilUtil::stripSlashes($val["desc"]),$val["lang"],$default);
00410 }
00411 }
00412
00413
00414 if (trim($_POST["Fobject"]["title"]) == "")
00415 {
00416 $_POST["Fobject"]["title"] = "ILIAS";
00417 }
00418
00419
00420 $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
00421 $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00422
00423
00424 if ($this->ilias->getSetting("custom_icons"))
00425 {
00426 $this->object->saveIcons($_FILES["cont_big_icon"],
00427 $_FILES["cont_small_icon"], $_FILES["cont_tiny_icon"]);
00428 }
00429
00430 $this->update = $this->object->update();
00431 }
00432
00433 include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
00434 $settings = new ilContainerSortingSettings($this->object->getId());
00435 $settings->setSortMode((int) $_POST['sorting']);
00436 $settings->update();
00437
00438 ilUtil::sendInfo($this->lng->txt("msg_obj_modified"),true);
00439 ilUtil::redirect($this->getReturnLocation("update",$this->ctrl->getTargetScript()."?".$this->link_params));
00440 }
00441
00447 function addTranslationObject()
00448 {
00449 if (!($_GET["mode"] != "create" or $_GET["mode"] != "edit"))
00450 {
00451 $message = get_class($this)."::addTranslationObject(): Missing or wrong parameter! mode: ".$_GET["mode"];
00452 $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
00453 }
00454
00455 $_SESSION["translation_post"] = $_POST;
00456 $this->ctrl->setParameter($this, "entry", 0);
00457 $this->ctrl->setParameter($this, "mode", "session");
00458 $this->ctrl->setParameter($this, "new_type", $_GET["new_type"]);
00459 ilUtil::redirect($this->ctrl->getLinkTarget($this, $_GET["mode"]));
00460 }
00461
00467 function removeTranslationObject()
00468 {
00469 if (!($_GET["mode"] != "create" or $_GET["mode"] != "edit"))
00470 {
00471 $message = get_class($this)."::removeTranslationObject(): Missing or wrong parameter! mode: ".$_GET["mode"];
00472 $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
00473 }
00474
00475 $this->ctrl->setParameter($this, "entry", $_GET["entry"]);
00476 $this->ctrl->setParameter($this, "mode", "session");
00477 $this->ctrl->setParameter($this, "new_type", $_GET["new_type"]);
00478 ilUtil::redirect($this->ctrl->getLinkTarget($this, $_GET["mode"]));
00479
00480 }
00481
00487 function removeBigIconObject()
00488 {
00489 $_SESSION["translation_post"] = $_POST;
00490 $this->object->removeBigIcon();
00491 ilUtil::redirect($this->ctrl->getLinkTarget($this, $_GET["mode"]));
00492 }
00493
00499 function removeSmallIconObject()
00500 {
00501
00502 $_SESSION["translation_post"] = $_POST;
00503 $this->object->removeSmallIcon();
00504 ilUtil::redirect($this->ctrl->getLinkTarget($this, $_GET["mode"]));
00505 }
00506
00512 function removeTinyIconObject()
00513 {
00514
00515 $_SESSION["translation_post"] = $_POST;
00516 $this->object->removeTinyIcon();
00517 ilUtil::redirect($this->ctrl->getLinkTarget($this, $_GET["mode"]));
00518 }
00519
00523 function _goto($a_target)
00524 {
00525 global $ilAccess, $ilErr, $lng;
00526
00527 if ($ilAccess->checkAccess("read", "",1))
00528 {
00529 $_GET["cmd"] = "frameset";
00530 $_GET["ref_id"] = 1;
00531 include("repository.php");
00532 exit;
00533 }
00534 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
00535 }
00536
00542 protected function showSortingSettings()
00543 {
00544 $this->tpl->setVariable('TXT_SORTING',$this->lng->txt('sorting_header'));
00545 $this->tpl->setVariable('TXT_SORT_TITLE',$this->lng->txt('sorting_title_header'));
00546 $this->tpl->setVariable('INFO_SORT_TITLE',$this->lng->txt('sorting_info_title'));
00547 $this->tpl->setVariable('TXT_SORT_MANUAL',$this->lng->txt('sorting_manual_header'));
00548 $this->tpl->setVariable('INFO_SORT_MANUAL',$this->lng->txt('sorting_info_manual'));
00549
00550 include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
00551 if($this->getCreationMode())
00552 {
00553 $settings = new ilContainerSortingSettings(0);
00554 }
00555 else
00556 {
00557 $settings = new ilContainerSortingSettings($this->object->getId());
00558 }
00559
00560
00561 $this->tpl->setVariable('RADIO_SORT_TITLE',ilUtil::formRadioButton(
00562 $settings->getSortMode() == ilContainerSortingSettings::MODE_TITLE,
00563 'sorting',
00564 ilContainerSortingSettings::MODE_TITLE));
00565 $this->tpl->setVariable('RADIO_SORT_MANUAL',ilUtil::formRadioButton(
00566 $settings->getSortMode() == ilContainerSortingSettings::MODE_MANUAL,
00567 'sorting',
00568 ilContainerSortingSettings::MODE_MANUAL));
00569 }
00570
00571 }
00572 ?>