ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLanguageTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Table/classes/class.ilTable2GUI.php");
5 
15 {
16 
20  function __construct($a_parent_obj, $a_parent_cmd, $a_folder)
21  {
22  global $ilCtrl, $lng, $ilAccess, $lng, $ilSetting;
23 
24  $this->folder = $a_folder;
25 
26  parent::__construct($a_parent_obj, $a_parent_cmd);
27 // $this->setTitle($lng->txt(""));
28  $this->setLimit(9999);
29 
30  $this->addColumn("", "", "1", 1);
31  $this->addColumn($this->lng->txt("language"));
32  $this->addColumn($this->lng->txt("status"));
33  $this->addColumn($this->lng->txt("users"));
34  $this->addColumn($this->lng->txt("last_refresh"));
35  if ($ilSetting->get("lang_ext_maintenance"))
36  {
37  $this->addColumn($this->lng->txt("last_change"));
38  }
39  $this->setSelectAllCheckbox("id[]");
40 
41  $this->setEnableHeader(true);
42  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
43  if ($ilSetting->get("lang_ext_maintenance"))
44  {
45  $this->setRowTemplate("tpl.lang_list_row_extended.html", "Services/Language");
46  }
47  else
48  {
49  $this->setRowTemplate("tpl.lang_list_row.html", "Services/Language");
50  }
51  $this->disable("footer");
52  $this->setEnableTitle(true);
53 
54  if ($ilSetting->get("lang_ext_maintenance") == "1")
55  {
56  $this->addMultiCommand("confirmRefreshSelected", $lng->txt("refresh"));
57  }
58  else
59  {
60  $this->addMultiCommand("RefreshSelected", $lng->txt("refresh"));
61  }
62  $this->addMultiCommand("install", $lng->txt("install"));
63  $this->addMultiCommand("installLocal", $lng->txt("install_local"));
64  $this->addMultiCommand("uninstall", $lng->txt("uninstall"));
65  $this->addMultiCommand("setSystemLanguage", $lng->txt("setSystemLanguage"));
66  $this->addMultiCommand("setUserLanguage", $lng->txt("setUserLanguage"));
67  $this->getItems();
68  }
69 
73  function getItems()
74  {
75  $languages = $this->folder->getLanguages();
76  $data = array();
77  foreach ($languages as $k => $l)
78  {
79  $data[] = array_merge($l, array("key" => $k));
80  }
81 
82  // sort alphabetically but shoe installed languages first
83  $data = ilUtil::stableSortArray($data, 'name', 'asc', false);
84  $data = ilUtil::stableSortArray($data, 'desc', 'asc', false);
85 
86  $this->setData($data);
87  }
88 
89 
93  protected function fillRow($a_set)
94  {
95  global $lng, $rbacsystem, $ilCtrl, $ilSetting;
96 
97  // set status info (in use or systemlanguage)
98  if ($a_set["status"])
99  {
100  $status = "<span class=\"small\"> (".$lng->txt($a_set["status"]).")</span>";
101  }
102 
103  // set remark color
104  switch ($a_set["info"])
105  {
106  case "file_not_found":
107  $remark = "<span class=\"smallred\"> ".$lng->txt($a_set["info"])."</span>";
108  break;
109  case "new_language":
110  //$remark = "<span class=\"smallgreen\"> ".$lng->txt($a_set["info"])."</span>";
111  break;
112  default:
113  $remark = "";
114  break;
115  }
116 
117  // show page translation
118  if($ilSetting->get("lang_ext_maintenance")
119  and $ilSetting->get("lang_translate_". $a_set['key'], false))
120  {
121  $remark .= $remark ? '<br />' : '';
122  $remark .= "<span class=\"smallgreen\"> ".$lng->txt('language_translation_enabled')."</span>";
123  }
124 
125  // make language name clickable
126  if ($rbacsystem->checkAccess("write", $this->folder->getRefId()))
127  {
128  if ($ilSetting->get("lang_ext_maintenance") == "1")
129  {
130  if (substr($lang_data["description"],0,9) == "installed")
131  {
132  $ilCtrl->setParameterByClass("ilobjlanguageextgui","obj_id",$a_set["obj_id"]);
133  $url = $ilCtrl->getLinkTargetByClass("ilobjlanguageextgui","");
134  $a_set["name"] = '<a href="'.$url.'">'.$a_set["name"].'</a>';
135  }
136  }
137  }
138 
139  if ($a_set["desc"] != "not_installed")
140  {
141  $this->tpl->setVariable("LAST_REFRESH",
142  ilDatePresentation::formatDate(new ilDateTime($a_set["last_update"],IL_CAL_DATETIME)));
143 
144  if ($ilSetting->get("lang_ext_maintenance"))
145  {
146  $last_change = ilObjLanguage::_getLastLocalChange($a_set['key']);
147  $this->tpl->setVariable("LAST_CHANGE",
149  }
150  }
151 
152  $this->tpl->setVariable("NR_OF_USERS", ilObjLanguage::countUsers($a_set["key"]));
153 
154  // make language name clickable
155  if ($rbacsystem->checkAccess("write",$this->folder->getRefId()))
156  {
157  if ($ilSetting->get("lang_ext_maintenance") == "1")
158  {
159  if (substr($a_set["description"],0,9) == "installed")
160  {
161  $ilCtrl->setParameterByClass("ilobjlanguageextgui", "obj_id", $a_set["obj_id"]);
162  $url = $ilCtrl->getLinkTargetByClass("ilobjlanguageextgui", "");
163  $a_set["name"] = '<a href="'.$url.'">'.$a_set["name"].'</a>';
164  }
165  }
166  }
167 
168  $this->tpl->setVariable("VAL_LANGUAGE", $a_set["name"].$status);
169  $this->tpl->setVariable("VAL_STATUS", $lng->txt($a_set["desc"])."<br/>".$remark);
170  $this->tpl->setVariable("OBJ_ID", $a_set["obj_id"]);
171  }
172 
173 }
174 ?>