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
00035 require_once "classes/class.ilObjLanguage.php";
00036 require_once "class.ilObjectGUI.php";
00037
00038 class ilObjLanguageFolderGUI extends ilObjectGUI
00039 {
00044 function ilObjLanguageFolderGUI($a_data,$a_id,$a_call_by_reference)
00045 {
00046 $this->type = "lngf";
00047 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference);
00048 }
00049
00055 function viewObject()
00056 {
00057 global $rbacsystem;
00058
00059 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00060 {
00061 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00062 }
00063
00064
00065 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00066
00067 $this->tpl->setCurrentBlock("btn_cell");
00068 $this->tpl->setVariable("BTN_LINK","adm_object.php?ref_id=".$this->ref_id."&cmd=refresh");
00069 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("refresh_languages"));
00070 $this->tpl->parseCurrentBlock();
00071
00072 $this->tpl->setCurrentBlock("btn_cell");
00073 $this->tpl->setVariable("BTN_LINK","adm_object.php?ref_id=".$this->ref_id."&cmd=checkLanguage");
00074 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("check_languages"));
00075 $this->tpl->parseCurrentBlock();
00076
00077
00078 $this->data = array();
00079 $this->data["data"] = array();
00080 $this->data["ctrl"] = array();
00081 $this->data["cols"] = array("","type","language","status","last_change", "usr_agreement");
00082
00083 $languages = $this->object->getLanguages();
00084
00085 foreach ($languages as $lang_key => $lang_data)
00086 {
00087 $status = "";
00088
00089
00090 if ($lang_data["status"])
00091 {
00092 $status = "<span class=\"small\"> (".$this->lng->txt($lang_data["status"]).")</span>";
00093 }
00094
00095
00096 switch ($lang_data["info"])
00097 {
00098 case "file_not_found":
00099 $remark = "<span class=\"smallred\"> ".$this->lng->txt($lang_data["info"])."</span>";
00100 break;
00101 case "new_language":
00102 $remark = "<span class=\"smallgreen\"> ".$this->lng->txt($lang_data["info"])."</span>";
00103 break;
00104 default:
00105 $remark = "";
00106 break;
00107 }
00108
00109 if (file_exists("./agreement/agreement_".$lang_key.".html"))
00110 {
00111 $agreement_exists_str = $this->lng->txt("available");
00112 }
00113 else
00114 {
00115 if ($lang_data["status"] == "system_language")
00116 {
00117 $agreement_exists_str = "<b>".$this->lng->txt("missing")."</b>";
00118 }
00119 else
00120 {
00121 $agreement_exists_str = $this->lng->txt("missing");
00122 }
00123 }
00124
00125
00126 $this->data["data"][] = array(
00127 "type" => "lng",
00128 "language" => $lang_data["name"].$status,
00129 "status" => $this->lng->txt($lang_data["desc"])."<br/>".$remark,
00130 "last_change" => $lang_data["last_update"],
00131 "obj_id" => $lang_data["obj_id"],
00132 "agreement" => $agreement_exists_str
00133 );
00134
00135 }
00136
00137 $this->maxcount = count($this->data["data"]);
00138
00139
00140 $this->data["data"] = ilUtil::sortArray($this->data["data"],$_GET["sort_by"],$_GET["sort_order"]);
00141
00142
00143 foreach ($this->data["data"] as $key => $val)
00144 {
00145 $this->data["ctrl"][$key] = array(
00146 "obj_id" => $val["obj_id"],
00147 "type" => $val["type"]
00148 );
00149
00150 unset($this->data["data"][$key]["obj_id"]);
00151 $this->data["data"][$key]["last_change"] = ilFormat::formatDate($this->data["data"][$key]["last_change"]);
00152 }
00153
00154 $this->displayList();
00155 }
00156
00162 function displayList()
00163 {
00164 global $tree, $rbacsystem;
00165
00166 require_once "./classes/class.ilTableGUI.php";
00167
00168
00169 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00170
00171 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
00172
00173 $num = 0;
00174
00175 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=gateway");
00176
00177
00178 $tbl = new ilTableGUI();
00179
00180
00181 $tbl->setTitle($this->lng->txt("obj_".$this->object->getType()),"icon_".$this->object->getType()."_b.gif",$this->lng->txt("obj_".$this->object->getType()));
00182 $tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00183
00184 foreach ($this->data["cols"] as $val)
00185 {
00186 $header_names[] = $this->lng->txt($val);
00187 }
00188
00189 $tbl->setHeaderNames($header_names);
00190
00191 $header_params = array("ref_id" => $this->ref_id);
00192 $tbl->setHeaderVars($this->data["cols"],$header_params);
00193
00194
00195 $tbl->setOrderColumn($_GET["sort_by"]);
00196 $tbl->setOrderDirection($_GET["sort_order"]);
00197 $tbl->setLimit(0);
00198 $tbl->setOffset(0);
00199 $tbl->setMaxCount($this->maxcount);
00200
00201
00202 $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
00203 $this->showActions();
00204
00205
00206 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00207
00208
00209
00210 $tbl->render();
00211
00212 if (is_array($this->data["data"][0]))
00213 {
00214
00215 for ($i=0; $i < count($this->data["data"]); $i++)
00216 {
00217 $data = $this->data["data"][$i];
00218 $ctrl = $this->data["ctrl"][$i];
00219
00220
00221 $css_row = ilUtil::switchColor($i+1,"tblrow1","tblrow2");
00222
00223 $this->tpl->setCurrentBlock("checkbox");
00224 $this->tpl->setVariable("CHECKBOX_ID",$ctrl["obj_id"]);
00225 $this->tpl->setVariable("CSS_ROW",$css_row);
00226 $this->tpl->parseCurrentBlock();
00227
00228 $this->tpl->setCurrentBlock("table_cell");
00229 $this->tpl->setVariable("CELLSTYLE", "tblrow1");
00230 $this->tpl->parseCurrentBlock();
00231
00232 foreach ($data as $key => $val)
00233 {
00234
00235 $this->tpl->setCurrentBlock("text");
00236
00237 if ($key == "type")
00238 {
00239 $val = ilUtil::getImageTagByType($val,$this->tpl->tplPath);
00240 }
00241
00242 $this->tpl->setVariable("TEXT_CONTENT", $val);
00243 $this->tpl->parseCurrentBlock();
00244
00245 $this->tpl->setCurrentBlock("table_cell");
00246 $this->tpl->parseCurrentBlock();
00247
00248 }
00249
00250 $this->tpl->setCurrentBlock("tbl_content");
00251 $this->tpl->setVariable("CSS_ROW", $css_row);
00252 $this->tpl->parseCurrentBlock();
00253 }
00254 }
00255 }
00256
00260 function installObject()
00261 {
00262 if (!isset($_POST["id"]))
00263 {
00264 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00265 }
00266
00267 foreach ($_POST["id"] as $obj_id)
00268 {
00269 $langObj = new ilObjLanguage($obj_id);
00270 $key = $langObj->install();
00271
00272 if ($key != "")
00273 {
00274 $lang_installed[] = $key;
00275 }
00276
00277 unset($langObj);
00278 }
00279
00280 if (isset($lang_installed))
00281 {
00282 if (count($lang_installed) == 1)
00283 {
00284 $this->data = $this->lng->txt("lang_".$lang_installed[0])." ".strtolower($this->lng->txt("installed")).".";
00285 }
00286 else
00287 {
00288 foreach ($lang_installed as $lang_key)
00289 {
00290 $langnames[] = $this->lng->txt("lang_".$lang_key);
00291 }
00292 $this->data = implode(", ",$langnames)." ".strtolower($this->lng->txt("installed")).".";
00293 }
00294 }
00295 else
00296 $this->data = $this->lng->txt("languages_already_installed");
00297
00298 $this->out();
00299 }
00300
00301
00305 function uninstallObject()
00306 {
00307 if (!isset($_POST["id"]))
00308 {
00309 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00310 }
00311
00312
00313 foreach ($_POST["id"] as $obj_id)
00314 {
00315 $langObj = new ilObjLanguage($obj_id);
00316 if (!($sys_lang = $langObj->isSystemLanguage()))
00317 if (!($usr_lang = $langObj->isUserLanguage()))
00318 {
00319 $key = $langObj->uninstall();
00320 if ($key != "")
00321 $lang_uninstalled[] = $key;
00322 }
00323 unset($langObj);
00324 }
00325
00326
00327 if (isset($lang_uninstalled))
00328 {
00329 if (count($lang_uninstalled) == 1)
00330 {
00331 $this->data = $this->lng->txt("lang_".$lang_uninstalled[0])." ".$this->lng->txt("uninstalled");
00332 }
00333 else
00334 {
00335 foreach ($lang_uninstalled as $lang_key)
00336 {
00337 $langnames[] = $this->lng->txt("lang_".$lang_key);
00338 }
00339
00340 $this->data = implode(", ",$langnames)." ".$this->lng->txt("uninstalled");
00341 }
00342 }
00343 elseif ($sys_lang)
00344 {
00345 $this->data = $this->lng->txt("cannot_uninstall_systemlanguage");
00346 }
00347 elseif ($usr_lang)
00348 {
00349 $this->data = $this->lng->txt("cannot_uninstall_language_in_use");
00350 }
00351 else
00352 {
00353 $this->data = $this->lng->txt("languages_already_uninstalled");
00354 }
00355
00356 $this->out();
00357 }
00358
00362 function refreshObject()
00363 {
00364 $languages = getObjectList("lng");
00365
00366 foreach ($languages as $lang)
00367 {
00368 $langObj = new ilObjLanguage($lang["obj_id"],false);
00369
00370 if ($langObj->getStatus() == "installed")
00371 {
00372 if ($langObj->check())
00373 {
00374 $langObj->flush();
00375 $langObj->insert();
00376 $langObj->setTitle($langObj->getKey());
00377 $langObj->setDescription($langObj->getStatus());
00378 $langObj->update();
00379 $langObj->optimizeData();
00380 }
00381 }
00382
00383 unset($langObj);
00384 }
00385
00386 $this->data = $this->lng->txt("languages_updated");
00387
00388 $this->out();
00389 }
00390
00391
00395 function setUserLanguageObject()
00396 {
00397 require_once "classes/class.ilObjUser.php";
00398
00399 if (!isset($_POST["id"]))
00400 {
00401 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00402 }
00403
00404 if (count($_POST["id"]) != 1)
00405 {
00406 $this->ilias->raiseError($this->lng->txt("choose_only_one_language")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
00407 }
00408
00409 $obj_id = $_POST["id"][0];
00410
00411 $newUserLangObj = new ilObjLanguage($obj_id);
00412
00413 if ($newUserLangObj->isUserLanguage())
00414 {
00415 $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);
00416 }
00417
00418 if ($newUserLangObj->getStatus() != "installed")
00419 {
00420 $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);
00421 }
00422
00423 $curUser = new ilObjUser($_SESSION["AccountId"]);
00424 $curUser->setLanguage($newUserLangObj->getKey());
00425 $curUser->update();
00426
00427
00428 $this->data = $this->lng->txt("user_language")." ".$this->lng->txt("changed_to")." ".$this->lng->txt("lang_".$newUserLangObj->getKey()).".";
00429
00430 $this->out();
00431 }
00432
00433
00437 function setSystemLanguageObject ()
00438 {
00439 if (!isset($_POST["id"]))
00440 {
00441 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00442 }
00443
00444 if (count($_POST["id"]) != 1)
00445 {
00446 $this->ilias->raiseError($this->lng->txt("choose_only_one_language")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
00447 }
00448
00449 $obj_id = $_POST["id"][0];
00450
00451 $newSysLangObj = new ilObjLanguage($obj_id);
00452
00453 if ($newSysLangObj->isSystemLanguage())
00454 {
00455 $this->ilias->raiseError($this->lng->txt("lang_".$newSysLangObj->getKey())." is already the system language!<br>Action aborted!",$this->ilias->error_obj->MESSAGE);
00456 }
00457
00458 if ($newSysLangObj->getStatus() != "installed")
00459 {
00460 $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);
00461 }
00462
00463 $this->ilias->setSetting("language", $newSysLangObj->getKey());
00464
00465
00466 $this->ilias->ini->setVariable("language","default",$newSysLangObj->getKey());
00467 $this->ilias->ini->write();
00468
00469 $this->data = $this->lng->txt("system_language")." ".$this->lng->txt("changed_to")." ".$this->lng->txt("lang_".$newSysLangObj->getKey()).".";
00470
00471 $this->out();
00472 }
00473
00474
00478 function checkLanguageObject ()
00479 {
00480
00481
00482 $this->data = $this->object->checkAllLanguages();
00483 $this->out();
00484 }
00485
00486
00487 function out()
00488 {
00489 sendInfo($this->data,true);
00490 header("location: adm_object.php?ref_id=".$_GET["ref_id"]);
00491 exit();
00492 }
00493 }
00494 ?>