• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/class.ilObjLanguageFolderGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 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 
00037 require_once "classes/class.ilObjLanguage.php";
00038 require_once "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;
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                 //add template for buttons
00069                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00070                 
00071                 $this->tpl->setCurrentBlock("btn_cell");
00072                 $this->tpl->setVariable("BTN_LINK",
00073                         $this->ctrl->getLinkTarget($this, "refresh"));
00074                 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("refresh_languages"));
00075                 $this->tpl->parseCurrentBlock();
00076                 
00077                 $this->tpl->setCurrentBlock("btn_cell");
00078                 $this->tpl->setVariable("BTN_LINK",
00079                         $this->ctrl->getLinkTarget($this, "checkLanguage"));
00080                 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("check_languages"));
00081                 $this->tpl->parseCurrentBlock();
00082 
00083                 //prepare objectlist
00084                 $this->data = array();
00085                 $this->data["data"] = array();
00086                 $this->data["ctrl"] = array();
00087                 $this->data["cols"] = array("","language","status","last_change", "usr_agreement");
00088 
00089                 $languages = $this->object->getLanguages();
00090                 
00091                 foreach ($languages as $lang_key => $lang_data)
00092                 {
00093                         $status = "";
00094         
00095                         // set status info (in use or systemlanguage)
00096                         if ($lang_data["status"])
00097                         {
00098                                 $status = "<span class=\"small\"> (".$this->lng->txt($lang_data["status"]).")</span>";
00099                         }
00100 
00101                         // set remark color
00102                         switch ($lang_data["info"])
00103                         {
00104                                 case "file_not_found":
00105                                         $remark = "<span class=\"smallred\"> ".$this->lng->txt($lang_data["info"])."</span>";
00106                                         break;
00107                                 case "new_language":
00108                                         $remark = "<span class=\"smallgreen\"> ".$this->lng->txt($lang_data["info"])."</span>";
00109                                         break;
00110                                 default:
00111                                         $remark = "";
00112                                         break;
00113                         }
00114 
00115                         if (file_exists(ilUtil::getWebspaceDir()."/agreement/agreement_".$lang_key.".html"))
00116                         {
00117                                 $agreement_exists_str = $this->lng->txt("available")." (".$this->lng->txt("client").")";
00118                         }
00119                         else if (file_exists("./agreement/agreement_".$lang_key.".html"))
00120                         {
00121                                 $agreement_exists_str = $this->lng->txt("available");
00122                         }
00123                         else
00124                         {
00125                                 if ($lang_data["status"] == "system_language")
00126                                 {
00127                                         $agreement_exists_str = "<b>".$this->lng->txt("missing")."</b>";
00128                                 }
00129                                 else
00130                                 {
00131                                         $agreement_exists_str = $this->lng->txt("missing");
00132                                 }
00133                         }
00134 
00135                         // visible data part
00136                         $this->data["data"][] = array(
00137                                                                         "language"              => $lang_data["name"].$status,
00138                                                                         "status"                => $this->lng->txt($lang_data["desc"])."<br/>".$remark,
00139                                                                         "last_change"   => $lang_data["last_update"],
00140                                                                         "obj_id"                => $lang_data["obj_id"],
00141                                                                         "agreement"             => $agreement_exists_str
00142                                                                                 );
00143 
00144                 }
00145         
00146                 $this->maxcount = count($this->data["data"]);
00147 
00148                 // sorting array
00149                 $this->data["data"] = ilUtil::sortArray($this->data["data"],$_GET["sort_by"],$_GET["sort_order"]);
00150 
00151                 // now compute control information
00152                 foreach ($this->data["data"] as $key => $val)
00153                 {
00154                         $this->data["ctrl"][$key] = array(
00155                                                                                         "obj_id"        => $val["obj_id"],
00156                                                                                         "type"          => $val["type"]
00157                                                                                         );              
00158 
00159                         unset($this->data["data"][$key]["obj_id"]);
00160                         $this->data["data"][$key]["last_change"] = ilFormat::formatDate($this->data["data"][$key]["last_change"]);
00161                 }
00162 
00163                 $this->displayList();
00164         }
00165 
00171         function displayList()
00172         {
00173                 global $tree, $rbacsystem;
00174 
00175                 require_once "./classes/class.ilTableGUI.php";
00176 
00177                 // load template for table
00178                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00179                 // load template for table content data
00180                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
00181 
00182                 $num = 0;
00183 
00184                 $this->tpl->setVariable("FORMACTION",
00185                         $this->ctrl->getFormAction($this));
00186 
00187                 // create table
00188                 $tbl = new ilTableGUI();
00189                 
00190                 // title & header columns
00191                 //$tbl->setTitle($this->lng->txt("obj_".$this->object->getType()),"icon_".$this->object->getType().".gif",$this->lng->txt("obj_".$this->object->getType()));
00192                 //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00193                 //$tbl->disable("header");
00194                 $tbl->disable("title");
00195                 
00196                 foreach ($this->data["cols"] as $val)
00197                 {
00198                         $header_names[] = $this->lng->txt($val);
00199                 }
00200                 
00201                 $tbl->setHeaderNames($header_names);
00202 
00203                 $header_params = array("ref_id" => $this->ref_id);
00204                 $tbl->setHeaderVars($this->data["cols"],$header_params);
00205                 
00206                 // control
00207                 $tbl->setOrderColumn($_GET["sort_by"]);
00208                 $tbl->setOrderDirection($_GET["sort_order"]);
00209                 $tbl->setLimit(0);
00210                 $tbl->setOffset(0);
00211                 $tbl->setMaxCount($this->maxcount);
00212                 $tbl->disable("sort");
00213                 
00214                 // SHOW VALID ACTIONS
00215                 $this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
00216                 $this->showActions();
00217                 
00218                 // footer
00219                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00220                 //$tbl->disable("footer");
00221                 
00222                 // render table
00223                 $tbl->render();
00224 
00225                 if (is_array($this->data["data"][0]))
00226                 {
00227                         //table cell
00228                         for ($i=0; $i < count($this->data["data"]); $i++)
00229                         {
00230                                 $data = $this->data["data"][$i];
00231                                 $ctrl = $this->data["ctrl"][$i];
00232 
00233                                 // color changing
00234                                 $css_row = ilUtil::switchColor($i+1,"tblrow1","tblrow2");
00235 
00236                                 $this->tpl->setCurrentBlock("checkbox");
00237                                 $this->tpl->setVariable("CHECKBOX_ID",$ctrl["obj_id"]);
00238                                 $this->tpl->setVariable("CSS_ROW",$css_row);
00239                                 $this->tpl->parseCurrentBlock();
00240 
00241                                 $this->tpl->setCurrentBlock("table_cell");
00242                                 $this->tpl->setVariable("CELLSTYLE", "tblrow1");
00243                                 $this->tpl->parseCurrentBlock();
00244 
00245                                 foreach ($data as $key => $val)
00246                                 {
00247 
00248                                         $this->tpl->setCurrentBlock("text");
00249 
00250                                         $this->tpl->setVariable("TEXT_CONTENT", $val);                                  
00251                                         $this->tpl->parseCurrentBlock();
00252 
00253                                         $this->tpl->setCurrentBlock("table_cell");
00254                                         $this->tpl->parseCurrentBlock();
00255 
00256                                 } //foreach
00257 
00258                                 $this->tpl->setCurrentBlock("tbl_content");
00259                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00260                                 $this->tpl->parseCurrentBlock();
00261                         } //for
00262                 } //if is_array
00263         }
00264 
00268         function installObject()
00269         {
00270                 if (!isset($_POST["id"]))
00271                 {
00272                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00273                 }
00274 
00275                 foreach ($_POST["id"] as $obj_id)
00276                 {
00277                         $langObj = new ilObjLanguage($obj_id);
00278                         $key = $langObj->install();
00279 
00280                         if ($key != "")
00281                         {
00282                                 $lang_installed[] = $key;
00283                         }
00284 
00285                         unset($langObj);
00286                 }
00287 
00288                 if (isset($lang_installed))
00289                 {
00290                         if (count($lang_installed) == 1)
00291                         {
00292                                 $this->data = $this->lng->txt("lang_" . $lang_installed[0]) . " " . strtolower($this->lng->txt("installed")) . ".";
00293                         }
00294                         else
00295                         {
00296                                 foreach ($lang_installed as $lang_key)
00297                                 {
00298                                         $langnames[] = $this->lng->txt("lang_" . $lang_key);
00299                                 }
00300                                 $this->data = implode(", ",$langnames) . " " . strtolower($this->lng->txt("installed")) . ".";
00301                         }
00302                 }
00303                 else
00304                 {
00305                         $this->data = $this->lng->txt("languages_already_installed");
00306                 }
00307 
00308                 $this->out();
00309         }
00310 
00311 
00315         function installLocalObject()
00316         {
00317                 if (!isset($_POST["id"]))
00318                 {
00319                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00320                 }
00321 
00322                 foreach ($_POST["id"] as $obj_id)
00323                 {
00324                         $langObj = new ilObjLanguage($obj_id);
00325                         $key = $langObj->install();
00326 
00327                         if ($key != "")
00328                         {
00329                                 $lang_installed[] = $key;
00330                         }
00331 
00332                         unset($langObj);
00333 
00334                         $langObj = new ilObjLanguage($obj_id);
00335                         $key = $langObj->install('local');
00336 
00337                         if ($key != "")
00338                         {
00339                                 $local_installed[] = $key;
00340                         }
00341 
00342                         unset($langObj);
00343                 }
00344 
00345                 if (isset($lang_installed))
00346                 {
00347                         if (count($lang_installed) == 1)
00348                         {
00349                                 $this->data = $this->lng->txt("lang_" . $lang_installed[0]) . " " . strtolower($this->lng->txt("installed")) . ".";
00350                         }
00351                         else
00352                         {
00353                                 foreach ($lang_installed as $lang_key)
00354                                 {
00355                                         $langnames[] = $this->lng->txt("lang_" . $lang_key);
00356                                 }
00357                                 $this->data = implode(", ",$langnames) . " " . strtolower($this->lng->txt("installed")) . ".";
00358                         }
00359                 }
00360 
00361                 if (isset($local_installed))
00362                 {
00363                         if (count($local_installed) == 1)
00364                         {
00365                                 $this->data .= " " . $this->lng->txt("lang_" . $local_installed[0]) . " " . $this->lng->txt("local_language_file") . " " . strtolower($this->lng->txt("installed")) . ".";
00366                         }
00367                         else
00368                         {
00369                                 foreach ($local_installed as $lang_key)
00370                                 {
00371                                         $langnames[] = $this->lng->txt("lang_" . $lang_key);
00372                                 }
00373                                 $this->data .= " " . implode(", ",$langnames) . " " . $this->lng->txt("local_language_files") . " " . strtolower($this->lng->txt("installed")) . ".";
00374                         }
00375                 }
00376                 else
00377                 {
00378                         $this->data .= " " . $this->lng->txt("local_languages_already_installed");
00379                 }
00380 
00381                 $this->out();
00382         }
00383 
00384 
00388         function uninstallObject()
00389         {
00390                 if (!isset($_POST["id"]))
00391                 {
00392                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00393                 }
00394 
00395                 // uninstall all selected languages
00396                 foreach ($_POST["id"] as $obj_id)
00397                 {
00398                         $langObj = new ilObjLanguage($obj_id);
00399                         if (!($sys_lang = $langObj->isSystemLanguage()))
00400                                 if (!($usr_lang = $langObj->isUserLanguage()))
00401                                 {
00402                                         $key = $langObj->uninstall();
00403                                         if ($key != "")
00404                                                 $lang_uninstalled[] = $key;
00405                                 }
00406                         unset($langObj);
00407                 }
00408 
00409                 // generate output message
00410                 if (isset($lang_uninstalled))
00411                 {
00412                         if (count($lang_uninstalled) == 1)
00413                         {
00414                                 $this->data = $this->lng->txt("lang_".$lang_uninstalled[0])." ".$this->lng->txt("uninstalled");
00415                         }
00416                         else
00417                         {
00418                                 foreach ($lang_uninstalled as $lang_key)
00419                                 {
00420                                         $langnames[] = $this->lng->txt("lang_".$lang_key);
00421                                 }
00422 
00423                                 $this->data = implode(", ",$langnames)." ".$this->lng->txt("uninstalled");
00424                         }
00425                 }
00426                 elseif ($sys_lang)
00427                 {
00428                         $this->data = $this->lng->txt("cannot_uninstall_systemlanguage");
00429                 }
00430                 elseif ($usr_lang)
00431                 {
00432                         $this->data = $this->lng->txt("cannot_uninstall_language_in_use");
00433                 }
00434                 else
00435                 {
00436                         $this->data = $this->lng->txt("languages_already_uninstalled");
00437                 }
00438 
00439                 $this->out();
00440         }
00441 
00445         function refreshObject()
00446         {
00447                 $languages = getObjectList("lng");
00448 
00449                 foreach ($languages as $lang)
00450                 {
00451                         $langObj = new ilObjLanguage($lang["obj_id"],false);
00452 
00453                         if ($langObj->isInstalled() == true)
00454                         {
00455                                 if ($langObj->check())
00456                                 {
00457                                         $langObj->flush();
00458                                         $langObj->insert();
00459                                         $langObj->setTitle($langObj->getKey());
00460                                         $langObj->setDescription($langObj->getStatus());
00461                                         $langObj->update();
00462                                         $langObj->optimizeData();
00463 
00464                                         if ($langObj->isLocal() == true)
00465                                         {
00466                                                 if ($langObj->check('local'))
00467                                                 {
00468                                                         $langObj->insert('local');
00469                                                         $langObj->setTitle($langObj->getKey());
00470                                                         $langObj->setDescription($langObj->getStatus());
00471                                                         $langObj->update();
00472                                                         $langObj->optimizeData();
00473                                                 }
00474                                         }
00475                                 }
00476                         }
00477 
00478                         unset($langObj);
00479                 }
00480 
00481                 $this->data = $this->lng->txt("languages_updated");
00482 
00483                 $this->out();
00484         }
00485 
00486 
00490         function setUserLanguageObject()
00491         {
00492                 require_once "classes/class.ilObjUser.php";
00493 
00494                 if (!isset($_POST["id"]))
00495                 {
00496                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00497                 }
00498 
00499                 if (count($_POST["id"]) != 1)
00500                 {
00501                         $this->ilias->raiseError($this->lng->txt("choose_only_one_language")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
00502                 }
00503 
00504                 $obj_id = $_POST["id"][0];
00505 
00506                 $newUserLangObj = new ilObjLanguage($obj_id);
00507 
00508                 if ($newUserLangObj->isUserLanguage())
00509                 {
00510                         $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);
00511                 }
00512 
00513                 if ($newUserLangObj->isInstalled() == false)
00514                 {
00515                         $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);
00516                 }
00517 
00518                 $curUser = new ilObjUser($_SESSION["AccountId"]);
00519                 $curUser->setLanguage($newUserLangObj->getKey());
00520                 $curUser->update();
00521                 //$this->setUserLanguage($new_lang_key);
00522 
00523                 $this->data = $this->lng->txt("user_language")." ".$this->lng->txt("changed_to")." ".$this->lng->txt("lang_".$newUserLangObj->getKey()).".";
00524 
00525                 $this->out();
00526         }
00527 
00528 
00532         function setSystemLanguageObject()
00533         {
00534                 if (!isset($_POST["id"]))
00535                 {
00536                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00537                 }
00538 
00539                 if (count($_POST["id"]) != 1)
00540                 {
00541                         $this->ilias->raiseError($this->lng->txt("choose_only_one_language")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
00542                 }
00543 
00544                 $obj_id = $_POST["id"][0];
00545 
00546                 $newSysLangObj = new ilObjLanguage($obj_id);
00547 
00548                 if ($newSysLangObj->isSystemLanguage())
00549                 {
00550                         $this->ilias->raiseError($this->lng->txt("lang_".$newSysLangObj->getKey())." is already the system language!<br>Action aborted!",$this->ilias->error_obj->MESSAGE);
00551                 }
00552 
00553                 if ($newSysLangObj->isInstalled() == false)
00554                 {
00555                         $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);
00556                 }
00557 
00558                 $this->ilias->setSetting("language", $newSysLangObj->getKey());
00559 
00560                 // update ini-file
00561                 $this->ilias->ini->setVariable("language","default",$newSysLangObj->getKey());
00562                 $this->ilias->ini->write();
00563 
00564                 $this->data = $this->lng->txt("system_language")." ".$this->lng->txt("changed_to")." ".$this->lng->txt("lang_".$newSysLangObj->getKey()).".";
00565 
00566                 $this->out();
00567         }
00568 
00569 
00573         function checkLanguageObject()
00574         {
00575                 //$langFoldObj = new ilObjLanguageFolder($_GET["obj_id"]);
00576                 //$this->data = $langFoldObj->checkAllLanguages();
00577                 $this->data = $this->object->checkAllLanguages();
00578                 $this->out();
00579         }
00580 
00581 
00582         function out()
00583         {
00584                 sendInfo($this->data,true);
00585                 $this->ctrl->redirect($this, "view");
00586         }
00587         
00588         function getAdminTabs(&$tabs_gui)
00589         {
00590                 $this->getTabs($tabs_gui);
00591         }
00592         
00598         function getTabs(&$tabs_gui)
00599         {
00600                 global $rbacsystem;
00601 
00602                 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00603                 {
00604                         $tabs_gui->addTarget("settings",
00605                                 $this->ctrl->getLinkTarget($this, "view"), array("view",""), "", "");
00606                 }
00607 
00608                 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00609                 {
00610                         $tabs_gui->addTarget("perm_settings",
00611                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00612                 }
00613         }
00614         
00615         function &executeCommand()
00616         {
00617                 $next_class = $this->ctrl->getNextClass($this);
00618                 $cmd = $this->ctrl->getCmd();
00619                 $this->prepareOutput();
00620 
00621                 switch($next_class)
00622                 {
00623                         case 'ilpermissiongui':
00624                                 include_once("./classes/class.ilPermissionGUI.php");
00625                                 $perm_gui =& new ilPermissionGUI($this);
00626                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00627                                 break;
00628 
00629                         default:
00630                                 if(!$cmd)
00631                                 {
00632                                         $cmd = "view";
00633                                 }
00634                                 $cmd .= "Object";
00635                                 $this->$cmd();
00636 
00637                                 break;
00638                 }
00639                 return true;
00640         }
00641 } // END class.ilObjLanguageFolderGUI
00642 ?>

Generated on Fri Dec 13 2013 11:57:54 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1