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
00037 require_once "./Services/Language/classes/class.ilObjLanguage.php";
00038 require_once "./classes/class.ilObjectGUI.php";
00039
00040 class ilObjLanguageFolderGUI extends ilObjectGUI
00041 {
00047 function ilObjLanguageFolderGUI($a_data,$a_id,$a_call_by_reference)
00048 {
00049 $this->type = "lngf";
00050 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00051 $_GET["sort_by"] = "language";
00052 }
00053
00059 function viewObject()
00060 {
00061 global $rbacsystem, $ilSetting;
00062
00063 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00064 {
00065 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00066 }
00067
00068
00069 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00070
00071 if ($ilSetting->get("lang_ext_maintenance") == "1")
00072 {
00073 $this->tpl->setCurrentBlock("btn_cell");
00074 $this->tpl->setVariable("BTN_LINK",
00075 $this->ctrl->getLinkTarget($this, "confirmRefresh"));
00076 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("refresh_languages"));
00077 $this->tpl->parseCurrentBlock();
00078 }
00079 else
00080 {
00081 $this->tpl->setCurrentBlock("btn_cell");
00082 $this->tpl->setVariable("BTN_LINK",
00083 $this->ctrl->getLinkTarget($this, "refresh"));
00084 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("refresh_languages"));
00085 $this->tpl->parseCurrentBlock();
00086 }
00087
00088 $this->tpl->setCurrentBlock("btn_cell");
00089 $this->tpl->setVariable("BTN_LINK",
00090 $this->ctrl->getLinkTarget($this, "checkLanguage"));
00091 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("check_languages"));
00092 $this->tpl->parseCurrentBlock();
00093
00094
00095 if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
00096 {
00097 if ($ilSetting->get("lang_ext_maintenance") == "1")
00098 {
00099 $this->tpl->setCurrentBlock("btn_cell");
00100 $this->tpl->setVariable("BTN_LINK",
00101 $this->ctrl->getLinkTarget($this, "disableExtendedLanguageMaintenance"));
00102 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("disable_ext_lang_maint"));
00103 $this->tpl->parseCurrentBlock();
00104 }
00105 else
00106 {
00107 $this->tpl->setCurrentBlock("btn_cell");
00108 $this->tpl->setVariable("BTN_LINK",
00109 $this->ctrl->getLinkTarget($this, "enableExtendedLanguageMaintenance"));
00110 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("enable_ext_lang_maint"));
00111 $this->tpl->parseCurrentBlock();
00112 }
00113 }
00114
00115
00116 $this->data = array();
00117 $this->data["data"] = array();
00118 $this->data["ctrl"] = array();
00119 $this->data["cols"] = array("","language","status","last_change", "usr_agreement");
00120
00121 $languages = $this->object->getLanguages();
00122
00123 foreach ($languages as $lang_key => $lang_data)
00124 {
00125 $status = "";
00126
00127
00128 if ($lang_data["status"])
00129 {
00130 $status = "<span class=\"small\"> (".$this->lng->txt($lang_data["status"]).")</span>";
00131 }
00132
00133
00134 switch ($lang_data["info"])
00135 {
00136 case "file_not_found":
00137 $remark = "<span class=\"smallred\"> ".$this->lng->txt($lang_data["info"])."</span>";
00138 break;
00139 case "new_language":
00140 $remark = "<span class=\"smallgreen\"> ".$this->lng->txt($lang_data["info"])."</span>";
00141 break;
00142 default:
00143 $remark = "";
00144 break;
00145 }
00146
00147 if (file_exists("./Customizing/clients/".CLIENT_ID."/agreement/".
00148 "agreement_".$lang_key.".html"))
00149 {
00150 $agreement_exists_str = $this->lng->txt("available")." (".$this->lng->txt("client").")";
00151 }
00152 else if (file_exists("./Customizing/global/agreement/".
00153 "agreement_".$lang_key.".html"))
00154 {
00155 $agreement_exists_str = $this->lng->txt("available");
00156 }
00157 else
00158 {
00159 if ($lang_data["status"] == "system_language")
00160 {
00161 $agreement_exists_str = "<b>".$this->lng->txt("missing")."</b>";
00162 }
00163 else
00164 {
00165 $agreement_exists_str = $this->lng->txt("missing");
00166 }
00167 }
00168
00169
00170 if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
00171 {
00172 if ($ilSetting->get("lang_ext_maintenance") == "1")
00173 {
00174 if (substr($lang_data["description"],0,9) == "installed")
00175 {
00176 $this->ctrl->setParameterByClass("ilobjlanguageextgui","obj_id",$lang_data["obj_id"]);
00177 $url = $this->ctrl->getLinkTargetByClass("ilobjlanguageextgui","");
00178 $lang_data["name"] = '<a href="'.$url.'">'.$lang_data["name"].'</a>';
00179 }
00180 }
00181 }
00182
00183
00184 $this->data["data"][] = array(
00185 "language" => $lang_data["name"].$status,
00186 "status" => $this->lng->txt($lang_data["desc"])."<br/>".$remark,
00187 "last_change" => $lang_data["last_update"],
00188 "obj_id" => $lang_data["obj_id"],
00189 "agreement" => $agreement_exists_str
00190 );
00191
00192 }
00193
00194 $this->maxcount = count($this->data["data"]);
00195
00196
00197 $this->data["data"] = ilUtil::sortArray($this->data["data"],$_GET["sort_by"],$_GET["sort_order"]);
00198
00199
00200 foreach ($this->data["data"] as $key => $val)
00201 {
00202 $this->data["ctrl"][$key] = array(
00203 "obj_id" => $val["obj_id"],
00204 "type" => $val["type"]
00205 );
00206
00207 unset($this->data["data"][$key]["obj_id"]);
00208 $this->data["data"][$key]["last_change"] = ilFormat::formatDate($this->data["data"][$key]["last_change"]);
00209 }
00210
00211 $this->displayList();
00212 }
00213
00219 function displayList()
00220 {
00221 global $tree, $rbacsystem;
00222
00223 require_once "./Services/Table/classes/class.ilTableGUI.php";
00224
00225
00226 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00227
00228 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
00229
00230 $num = 0;
00231
00232 $this->tpl->setVariable("FORMACTION",
00233 $this->ctrl->getFormAction($this));
00234
00235
00236 $tbl = new ilTableGUI();
00237
00238
00239
00240
00241
00242 $tbl->disable("title");
00243
00244 foreach ($this->data["cols"] as $val)
00245 {
00246 $header_names[] = $this->lng->txt($val);
00247 }
00248
00249 $tbl->setHeaderNames($header_names);
00250
00251 $header_params = array("ref_id" => $this->ref_id);
00252 $tbl->setHeaderVars($this->data["cols"],$header_params);
00253
00254
00255 $tbl->setOrderColumn($_GET["sort_by"]);
00256 $tbl->setOrderDirection($_GET["sort_order"]);
00257 $tbl->setLimit(0);
00258 $tbl->setOffset(0);
00259 $tbl->setMaxCount($this->maxcount);
00260 $tbl->disable("sort");
00261
00262
00263 $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
00264 $this->showActions();
00265
00266
00267 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00268
00269
00270
00271 $tbl->render();
00272
00273 if (is_array($this->data["data"][0]))
00274 {
00275
00276 for ($i=0; $i < count($this->data["data"]); $i++)
00277 {
00278 $data = $this->data["data"][$i];
00279 $ctrl = $this->data["ctrl"][$i];
00280
00281
00282 $css_row = ilUtil::switchColor($i+1,"tblrow1","tblrow2");
00283
00284 $this->tpl->setCurrentBlock("checkbox");
00285 $this->tpl->setVariable("CHECKBOX_ID",$ctrl["obj_id"]);
00286 $this->tpl->setVariable("CSS_ROW",$css_row);
00287 $this->tpl->parseCurrentBlock();
00288
00289 $this->tpl->setCurrentBlock("table_cell");
00290 $this->tpl->setVariable("CELLSTYLE", "tblrow1");
00291 $this->tpl->parseCurrentBlock();
00292
00293 foreach ($data as $key => $val)
00294 {
00295
00296 $this->tpl->setCurrentBlock("text");
00297
00298 $this->tpl->setVariable("TEXT_CONTENT", $val);
00299 $this->tpl->parseCurrentBlock();
00300
00301 $this->tpl->setCurrentBlock("table_cell");
00302 $this->tpl->parseCurrentBlock();
00303
00304 }
00305
00306 $this->tpl->setCurrentBlock("tbl_content");
00307 $this->tpl->setVariable("CSS_ROW", $css_row);
00308 $this->tpl->parseCurrentBlock();
00309 }
00310 }
00311 }
00312
00316 function installObject()
00317 {
00318 if (!isset($_POST["id"]))
00319 {
00320 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00321 }
00322
00323 foreach ($_POST["id"] as $obj_id)
00324 {
00325 $langObj = new ilObjLanguage($obj_id);
00326 $key = $langObj->install();
00327
00328 if ($key != "")
00329 {
00330 $lang_installed[] = $key;
00331 }
00332
00333 unset($langObj);
00334 }
00335
00336 if (isset($lang_installed))
00337 {
00338 if (count($lang_installed) == 1)
00339 {
00340 $this->data = $this->lng->txt("lang_" . $lang_installed[0]) . " " . strtolower($this->lng->txt("installed")) . ".";
00341 }
00342 else
00343 {
00344 foreach ($lang_installed as $lang_key)
00345 {
00346 $langnames[] = $this->lng->txt("lang_" . $lang_key);
00347 }
00348 $this->data = implode(", ",$langnames) . " " . strtolower($this->lng->txt("installed")) . ".";
00349 }
00350 }
00351 else
00352 {
00353 $this->data = $this->lng->txt("languages_already_installed");
00354 }
00355
00356 $this->out();
00357 }
00358
00359
00363 function installLocalObject()
00364 {
00365 if (!isset($_POST["id"]))
00366 {
00367 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00368 }
00369
00370 foreach ($_POST["id"] as $obj_id)
00371 {
00372 $langObj = new ilObjLanguage($obj_id);
00373 $key = $langObj->install();
00374
00375 if ($key != "")
00376 {
00377 $lang_installed[] = $key;
00378 }
00379
00380 unset($langObj);
00381
00382 $langObj = new ilObjLanguage($obj_id);
00383 $key = $langObj->install('local');
00384
00385 if ($key != "")
00386 {
00387 $local_installed[] = $key;
00388 }
00389
00390 unset($langObj);
00391 }
00392
00393 if (isset($lang_installed))
00394 {
00395 if (count($lang_installed) == 1)
00396 {
00397 $this->data = $this->lng->txt("lang_" . $lang_installed[0]) . " " . strtolower($this->lng->txt("installed")) . ".";
00398 }
00399 else
00400 {
00401 foreach ($lang_installed as $lang_key)
00402 {
00403 $langnames[] = $this->lng->txt("lang_" . $lang_key);
00404 }
00405 $this->data = implode(", ",$langnames) . " " . strtolower($this->lng->txt("installed")) . ".";
00406 }
00407 }
00408
00409 if (isset($local_installed))
00410 {
00411 if (count($local_installed) == 1)
00412 {
00413 $this->data .= " " . $this->lng->txt("lang_" . $local_installed[0]) . " " . $this->lng->txt("local_language_file") . " " . strtolower($this->lng->txt("installed")) . ".";
00414 }
00415 else
00416 {
00417 foreach ($local_installed as $lang_key)
00418 {
00419 $langnames[] = $this->lng->txt("lang_" . $lang_key);
00420 }
00421 $this->data .= " " . implode(", ",$langnames) . " " . $this->lng->txt("local_language_files") . " " . strtolower($this->lng->txt("installed")) . ".";
00422 }
00423 }
00424 else
00425 {
00426 $this->data .= " " . $this->lng->txt("local_languages_already_installed");
00427 }
00428
00429 $this->out();
00430 }
00431
00432
00436 function uninstallObject()
00437 {
00438 if (!isset($_POST["id"]))
00439 {
00440 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00441 }
00442
00443
00444 foreach ($_POST["id"] as $obj_id)
00445 {
00446 $langObj = new ilObjLanguage($obj_id);
00447 if (!($sys_lang = $langObj->isSystemLanguage()))
00448 if (!($usr_lang = $langObj->isUserLanguage()))
00449 {
00450 $key = $langObj->uninstall();
00451 if ($key != "")
00452 $lang_uninstalled[] = $key;
00453 }
00454 unset($langObj);
00455 }
00456
00457
00458 if (isset($lang_uninstalled))
00459 {
00460 if (count($lang_uninstalled) == 1)
00461 {
00462 $this->data = $this->lng->txt("lang_".$lang_uninstalled[0])." ".$this->lng->txt("uninstalled");
00463 }
00464 else
00465 {
00466 foreach ($lang_uninstalled as $lang_key)
00467 {
00468 $langnames[] = $this->lng->txt("lang_".$lang_key);
00469 }
00470
00471 $this->data = implode(", ",$langnames)." ".$this->lng->txt("uninstalled");
00472 }
00473 }
00474 elseif ($sys_lang)
00475 {
00476 $this->data = $this->lng->txt("cannot_uninstall_systemlanguage");
00477 }
00478 elseif ($usr_lang)
00479 {
00480 $this->data = $this->lng->txt("cannot_uninstall_language_in_use");
00481 }
00482 else
00483 {
00484 $this->data = $this->lng->txt("languages_already_uninstalled");
00485 }
00486
00487 $this->out();
00488 }
00489
00493 function refreshObject()
00494 {
00495 $languages = ilObject::_getObjectsByType("lng");
00496
00497 foreach ($languages as $lang)
00498 {
00499 $langObj = new ilObjLanguage($lang["obj_id"],false);
00500
00501 if ($langObj->isInstalled() == true)
00502 {
00503 if ($langObj->check())
00504 {
00505 $langObj->flush();
00506 $langObj->insert();
00507 $langObj->setTitle($langObj->getKey());
00508 $langObj->setDescription($langObj->getStatus());
00509 $langObj->update();
00510 $langObj->optimizeData();
00511
00512 if ($langObj->isLocal() == true)
00513 {
00514 if ($langObj->check('local'))
00515 {
00516 $langObj->insert('local');
00517 $langObj->setTitle($langObj->getKey());
00518 $langObj->setDescription($langObj->getStatus());
00519 $langObj->update();
00520 $langObj->optimizeData();
00521 }
00522 }
00523 }
00524 }
00525
00526 unset($langObj);
00527 }
00528
00529 $this->data = $this->lng->txt("languages_updated");
00530
00531 $this->out();
00532 }
00533
00534
00538 function setUserLanguageObject()
00539 {
00540 require_once './Services/User/classes/class.ilObjUser.php';
00541
00542 if (!isset($_POST["id"]))
00543 {
00544 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00545 }
00546
00547 if (count($_POST["id"]) != 1)
00548 {
00549 $this->ilias->raiseError($this->lng->txt("choose_only_one_language")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
00550 }
00551
00552 $obj_id = $_POST["id"][0];
00553
00554 $newUserLangObj = new ilObjLanguage($obj_id);
00555
00556 if ($newUserLangObj->isUserLanguage())
00557 {
00558 $this->ilias->raiseError($this->lng->txt("lang_".$newUserLangObj->getKey())." ".$this->lng->txt("is_already_your")." ".$this->lng->txt("user_language")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
00559 }
00560
00561 if ($newUserLangObj->isInstalled() == false)
00562 {
00563 $this->ilias->raiseError($this->lng->txt("lang_".$newUserLangObj->getKey())." ".$this->lng->txt("language_not_installed")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
00564 }
00565
00566 $curUser = new ilObjUser($_SESSION["AccountId"]);
00567 $curUser->setLanguage($newUserLangObj->getKey());
00568 $curUser->update();
00569
00570
00571 $this->data = $this->lng->txt("user_language")." ".$this->lng->txt("changed_to")." ".$this->lng->txt("lang_".$newUserLangObj->getKey()).".";
00572
00573 $this->out();
00574 }
00575
00576
00580 function setSystemLanguageObject()
00581 {
00582 if (!isset($_POST["id"]))
00583 {
00584 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00585 }
00586
00587 if (count($_POST["id"]) != 1)
00588 {
00589 $this->ilias->raiseError($this->lng->txt("choose_only_one_language")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
00590 }
00591
00592 $obj_id = $_POST["id"][0];
00593
00594 $newSysLangObj = new ilObjLanguage($obj_id);
00595
00596 if ($newSysLangObj->isSystemLanguage())
00597 {
00598 $this->ilias->raiseError($this->lng->txt("lang_".$newSysLangObj->getKey())." is already the system language!<br>Action aborted!",$this->ilias->error_obj->MESSAGE);
00599 }
00600
00601 if ($newSysLangObj->isInstalled() == false)
00602 {
00603 $this->ilias->raiseError($this->lng->txt("lang_".$newSysLangObj->getKey())." is not installed. Please install that language first.<br>Action aborted!",$this->ilias->error_obj->MESSAGE);
00604 }
00605
00606 $this->ilias->setSetting("language", $newSysLangObj->getKey());
00607
00608
00609 $this->ilias->ini->setVariable("language","default",$newSysLangObj->getKey());
00610 $this->ilias->ini->write();
00611
00612 $this->data = $this->lng->txt("system_language")." ".$this->lng->txt("changed_to")." ".$this->lng->txt("lang_".$newSysLangObj->getKey()).".";
00613
00614 $this->out();
00615 }
00616
00617
00621 function checkLanguageObject()
00622 {
00623
00624
00625 $this->data = $this->object->checkAllLanguages();
00626 $this->out();
00627 }
00628
00629
00630 function out()
00631 {
00632 ilUtil::sendInfo($this->data,true);
00633 $this->ctrl->redirect($this, "view");
00634 }
00635
00636 function getAdminTabs(&$tabs_gui)
00637 {
00638 $this->getTabs($tabs_gui);
00639 }
00640
00646 function getTabs(&$tabs_gui)
00647 {
00648 global $rbacsystem;
00649
00650 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00651 {
00652 $tabs_gui->addTarget("settings",
00653 $this->ctrl->getLinkTarget($this, "view"), array("view",""), "", "");
00654 }
00655
00656 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00657 {
00658 $tabs_gui->addTarget("perm_settings",
00659 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00660 }
00661 }
00662
00663 function &executeCommand()
00664 {
00665 $next_class = $this->ctrl->getNextClass($this);
00666 $cmd = $this->ctrl->getCmd();
00667 $this->prepareOutput();
00668
00669 switch($next_class)
00670 {
00671 case 'ilpermissiongui':
00672 include_once("./classes/class.ilPermissionGUI.php");
00673 $perm_gui =& new ilPermissionGUI($this);
00674 $ret =& $this->ctrl->forwardCommand($perm_gui);
00675 break;
00676
00677 default:
00678 if(!$cmd)
00679 {
00680 $cmd = "view";
00681 }
00682 $cmd .= "Object";
00683 $this->$cmd();
00684
00685 break;
00686 }
00687 return true;
00688 }
00689
00693 function enableExtendedLanguageMaintenanceObject()
00694 {
00695 global $ilSetting, $ilCtrl;
00696
00697 $ilSetting->set("lang_ext_maintenance", 1);
00698 $ilCtrl->redirect($this, "view");
00699 }
00700
00704 function disableExtendedLanguageMaintenanceObject()
00705 {
00706 global $ilSetting, $ilCtrl;
00707
00708 $ilSetting->set("lang_ext_maintenance", 0);
00709 $ilCtrl->redirect($this, "view");
00710 }
00711
00712 function confirmRefreshObject()
00713 {
00714 global $ilCtrl, $lng;
00715
00716 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
00717 $conf_screen = new ilConfirmationGUI();
00718 $conf_screen->setFormAction($ilCtrl->getFormAction($this));
00719 $conf_screen->setHeaderText($lng->txt("lang_refresh_confirm"));
00720 $conf_screen->addItem("d", "d", $lng->txt("lang_refresh_confirm_info"));
00721 $conf_screen->setCancel($lng->txt("cancel"), "view");
00722 $conf_screen->setConfirm($lng->txt("ok"), "refresh");
00723
00724 $this->tpl->setContent($conf_screen->getHTML());
00725 }
00726
00727
00728 }
00729 ?>