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(ilUtil::getWebspaceDir()."/agreement/agreement_".$lang_key.".html"))
00110 {
00111 $agreement_exists_str = $this->lng->txt("available")." (".$this->lng->txt("client").")";
00112 }
00113 else if (file_exists("./agreement/agreement_".$lang_key.".html"))
00114 {
00115 $agreement_exists_str = $this->lng->txt("available");
00116 }
00117 else
00118 {
00119 if ($lang_data["status"] == "system_language")
00120 {
00121 $agreement_exists_str = "<b>".$this->lng->txt("missing")."</b>";
00122 }
00123 else
00124 {
00125 $agreement_exists_str = $this->lng->txt("missing");
00126 }
00127 }
00128
00129
00130 $this->data["data"][] = array(
00131 "type" => "lng",
00132 "language" => $lang_data["name"].$status,
00133 "status" => $this->lng->txt($lang_data["desc"])."<br/>".$remark,
00134 "last_change" => $lang_data["last_update"],
00135 "obj_id" => $lang_data["obj_id"],
00136 "agreement" => $agreement_exists_str
00137 );
00138
00139 }
00140
00141 $this->maxcount = count($this->data["data"]);
00142
00143
00144 $this->data["data"] = ilUtil::sortArray($this->data["data"],$_GET["sort_by"],$_GET["sort_order"]);
00145
00146
00147 foreach ($this->data["data"] as $key => $val)
00148 {
00149 $this->data["ctrl"][$key] = array(
00150 "obj_id" => $val["obj_id"],
00151 "type" => $val["type"]
00152 );
00153
00154 unset($this->data["data"][$key]["obj_id"]);
00155 $this->data["data"][$key]["last_change"] = ilFormat::formatDate($this->data["data"][$key]["last_change"]);
00156 }
00157
00158 $this->displayList();
00159 }
00160
00166 function displayList()
00167 {
00168 global $tree, $rbacsystem;
00169
00170 require_once "./classes/class.ilTableGUI.php";
00171
00172
00173 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00174
00175 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
00176
00177 $num = 0;
00178
00179 $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=gateway");
00180
00181
00182 $tbl = new ilTableGUI();
00183
00184
00185 $tbl->setTitle($this->lng->txt("obj_".$this->object->getType()),"icon_".$this->object->getType()."_b.gif",$this->lng->txt("obj_".$this->object->getType()));
00186 $tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00187
00188 foreach ($this->data["cols"] as $val)
00189 {
00190 $header_names[] = $this->lng->txt($val);
00191 }
00192
00193 $tbl->setHeaderNames($header_names);
00194
00195 $header_params = array("ref_id" => $this->ref_id);
00196 $tbl->setHeaderVars($this->data["cols"],$header_params);
00197
00198
00199 $tbl->setOrderColumn($_GET["sort_by"]);
00200 $tbl->setOrderDirection($_GET["sort_order"]);
00201 $tbl->setLimit(0);
00202 $tbl->setOffset(0);
00203 $tbl->setMaxCount($this->maxcount);
00204
00205
00206 $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
00207 $this->showActions();
00208
00209
00210 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00211
00212
00213
00214 $tbl->render();
00215
00216 if (is_array($this->data["data"][0]))
00217 {
00218
00219 for ($i=0; $i < count($this->data["data"]); $i++)
00220 {
00221 $data = $this->data["data"][$i];
00222 $ctrl = $this->data["ctrl"][$i];
00223
00224
00225 $css_row = ilUtil::switchColor($i+1,"tblrow1","tblrow2");
00226
00227 $this->tpl->setCurrentBlock("checkbox");
00228 $this->tpl->setVariable("CHECKBOX_ID",$ctrl["obj_id"]);
00229 $this->tpl->setVariable("CSS_ROW",$css_row);
00230 $this->tpl->parseCurrentBlock();
00231
00232 $this->tpl->setCurrentBlock("table_cell");
00233 $this->tpl->setVariable("CELLSTYLE", "tblrow1");
00234 $this->tpl->parseCurrentBlock();
00235
00236 foreach ($data as $key => $val)
00237 {
00238
00239 $this->tpl->setCurrentBlock("text");
00240
00241 if ($key == "type")
00242 {
00243 $val = ilUtil::getImageTagByType($val,$this->tpl->tplPath);
00244 }
00245
00246 $this->tpl->setVariable("TEXT_CONTENT", $val);
00247 $this->tpl->parseCurrentBlock();
00248
00249 $this->tpl->setCurrentBlock("table_cell");
00250 $this->tpl->parseCurrentBlock();
00251
00252 }
00253
00254 $this->tpl->setCurrentBlock("tbl_content");
00255 $this->tpl->setVariable("CSS_ROW", $css_row);
00256 $this->tpl->parseCurrentBlock();
00257 }
00258 }
00259 }
00260
00264 function installObject()
00265 {
00266 if (!isset($_POST["id"]))
00267 {
00268 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00269 }
00270
00271 foreach ($_POST["id"] as $obj_id)
00272 {
00273 $langObj = new ilObjLanguage($obj_id);
00274 $key = $langObj->install();
00275
00276 if ($key != "")
00277 {
00278 $lang_installed[] = $key;
00279 }
00280
00281 unset($langObj);
00282 }
00283
00284 if (isset($lang_installed))
00285 {
00286 if (count($lang_installed) == 1)
00287 {
00288 $this->data = $this->lng->txt("lang_".$lang_installed[0])." ".strtolower($this->lng->txt("installed")).".";
00289 }
00290 else
00291 {
00292 foreach ($lang_installed as $lang_key)
00293 {
00294 $langnames[] = $this->lng->txt("lang_".$lang_key);
00295 }
00296 $this->data = implode(", ",$langnames)." ".strtolower($this->lng->txt("installed")).".";
00297 }
00298 }
00299 else
00300 $this->data = $this->lng->txt("languages_already_installed");
00301
00302 $this->out();
00303 }
00304
00305
00309 function uninstallObject()
00310 {
00311 if (!isset($_POST["id"]))
00312 {
00313 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00314 }
00315
00316
00317 foreach ($_POST["id"] as $obj_id)
00318 {
00319 $langObj = new ilObjLanguage($obj_id);
00320 if (!($sys_lang = $langObj->isSystemLanguage()))
00321 if (!($usr_lang = $langObj->isUserLanguage()))
00322 {
00323 $key = $langObj->uninstall();
00324 if ($key != "")
00325 $lang_uninstalled[] = $key;
00326 }
00327 unset($langObj);
00328 }
00329
00330
00331 if (isset($lang_uninstalled))
00332 {
00333 if (count($lang_uninstalled) == 1)
00334 {
00335 $this->data = $this->lng->txt("lang_".$lang_uninstalled[0])." ".$this->lng->txt("uninstalled");
00336 }
00337 else
00338 {
00339 foreach ($lang_uninstalled as $lang_key)
00340 {
00341 $langnames[] = $this->lng->txt("lang_".$lang_key);
00342 }
00343
00344 $this->data = implode(", ",$langnames)." ".$this->lng->txt("uninstalled");
00345 }
00346 }
00347 elseif ($sys_lang)
00348 {
00349 $this->data = $this->lng->txt("cannot_uninstall_systemlanguage");
00350 }
00351 elseif ($usr_lang)
00352 {
00353 $this->data = $this->lng->txt("cannot_uninstall_language_in_use");
00354 }
00355 else
00356 {
00357 $this->data = $this->lng->txt("languages_already_uninstalled");
00358 }
00359
00360 $this->out();
00361 }
00362
00366 function refreshObject()
00367 {
00368 $languages = getObjectList("lng");
00369
00370 foreach ($languages as $lang)
00371 {
00372 $langObj = new ilObjLanguage($lang["obj_id"],false);
00373
00374 if ($langObj->getStatus() == "installed")
00375 {
00376 if ($langObj->check())
00377 {
00378 $langObj->flush();
00379 $langObj->insert();
00380 $langObj->setTitle($langObj->getKey());
00381 $langObj->setDescription($langObj->getStatus());
00382 $langObj->update();
00383 $langObj->optimizeData();
00384 }
00385 }
00386
00387 unset($langObj);
00388 }
00389
00390 $this->data = $this->lng->txt("languages_updated");
00391
00392 $this->out();
00393 }
00394
00395
00399 function setUserLanguageObject()
00400 {
00401 require_once "classes/class.ilObjUser.php";
00402
00403 if (!isset($_POST["id"]))
00404 {
00405 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00406 }
00407
00408 if (count($_POST["id"]) != 1)
00409 {
00410 $this->ilias->raiseError($this->lng->txt("choose_only_one_language")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
00411 }
00412
00413 $obj_id = $_POST["id"][0];
00414
00415 $newUserLangObj = new ilObjLanguage($obj_id);
00416
00417 if ($newUserLangObj->isUserLanguage())
00418 {
00419 $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);
00420 }
00421
00422 if ($newUserLangObj->getStatus() != "installed")
00423 {
00424 $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);
00425 }
00426
00427 $curUser = new ilObjUser($_SESSION["AccountId"]);
00428 $curUser->setLanguage($newUserLangObj->getKey());
00429 $curUser->update();
00430
00431
00432 $this->data = $this->lng->txt("user_language")." ".$this->lng->txt("changed_to")." ".$this->lng->txt("lang_".$newUserLangObj->getKey()).".";
00433
00434 $this->out();
00435 }
00436
00437
00441 function setSystemLanguageObject ()
00442 {
00443 if (!isset($_POST["id"]))
00444 {
00445 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00446 }
00447
00448 if (count($_POST["id"]) != 1)
00449 {
00450 $this->ilias->raiseError($this->lng->txt("choose_only_one_language")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
00451 }
00452
00453 $obj_id = $_POST["id"][0];
00454
00455 $newSysLangObj = new ilObjLanguage($obj_id);
00456
00457 if ($newSysLangObj->isSystemLanguage())
00458 {
00459 $this->ilias->raiseError($this->lng->txt("lang_".$newSysLangObj->getKey())." is already the system language!<br>Action aborted!",$this->ilias->error_obj->MESSAGE);
00460 }
00461
00462 if ($newSysLangObj->getStatus() != "installed")
00463 {
00464 $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);
00465 }
00466
00467 $this->ilias->setSetting("language", $newSysLangObj->getKey());
00468
00469
00470 $this->ilias->ini->setVariable("language","default",$newSysLangObj->getKey());
00471 $this->ilias->ini->write();
00472
00473 $this->data = $this->lng->txt("system_language")." ".$this->lng->txt("changed_to")." ".$this->lng->txt("lang_".$newSysLangObj->getKey()).".";
00474
00475 $this->out();
00476 }
00477
00478
00482 function checkLanguageObject ()
00483 {
00484
00485
00486 $this->data = $this->object->checkAllLanguages();
00487 $this->out();
00488 }
00489
00490
00491 function out()
00492 {
00493 sendInfo($this->data,true);
00494 header("location: adm_object.php?ref_id=".$_GET["ref_id"]);
00495 exit();
00496 }
00497 }
00498 ?>