ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilTranslationGUI Class Reference

Class ilTranslationGUI. More...

+ Collaboration diagram for ilTranslationGUI:

Public Member Functions

 executeCommand ()
 
 editTranslations ($a_get_post_values=false, $a_add=false)
 
 saveTranslations ()
 Save title and translations. More...
 
 addTranslation ()
 Add a translation. More...
 
 deleteTranslations ()
 Remove translation. More...
 

Data Fields

 $tpl
 

Protected Attributes

 $ctrl
 
 $ilAccess
 
 $lng
 
 $ilObjOrgUnitGui
 
 $ilObjectOrgUnit
 

Detailed Description

Member Function Documentation

◆ addTranslation()

ilTranslationGUI::addTranslation ( )

Add a translation.

Definition at line 164 of file class.ilTranslationGUI.php.

References $_POST, and editTranslations().

165  {
166 
167  if($_POST["title"])
168  {
169  $k = max(array_keys($_POST["title"]));
170  $k++;
171  $_POST["title"][$k] = "";
172  $this->editTranslations(true);
173  }
174  else
175  {
176  $this->editTranslations(false, true);
177  }
178  }
editTranslations($a_get_post_values=false, $a_add=false)
$_POST["username"]
+ Here is the call graph for this function:

◆ deleteTranslations()

ilTranslationGUI::deleteTranslations ( )

Remove translation.

Definition at line 183 of file class.ilTranslationGUI.php.

References $_POST, editTranslations(), saveTranslations(), and ilUtil\sendFailure().

184  {
185  foreach($_POST["title"] as $k => $v)
186  {
187  if ($_POST["check"][$k])
188  {
189  // default translation cannot be deleted
190  if($k != $_POST["default"])
191  {
192  unset($_POST["title"][$k]);
193  unset($_POST["desc"][$k]);
194  unset($_POST["lang"][$k]);
195  }
196  else
197  {
198  ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
199  return $this->editTranslations();
200  }
201  }
202  }
203  $this->saveTranslations();
204  }
saveTranslations()
Save title and translations.
editTranslations($a_get_post_values=false, $a_add=false)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ editTranslations()

ilTranslationGUI::editTranslations (   $a_get_post_values = false,
  $a_add = false 
)

Definition at line 76 of file class.ilTranslationGUI.php.

References $_POST, $data, and array.

Referenced by addTranslation(), deleteTranslations(), and saveTranslations().

77  {
78  $this->lng->loadLanguageModule($this->ilObjectOrgUnit->getType());
79 
80  $table = new ilObjectTranslationTableGUI($this, "editTranslations", true,
81  "Translation");
82  if ($a_get_post_values)
83  {
84  $vals = array();
85  foreach($_POST["title"] as $k => $v)
86  {
87  $vals[] = array("title" => $v,
88  "desc" => $_POST["desc"][$k],
89  "lang" => $_POST["lang"][$k],
90  "default" => ($_POST["default"] == $k));
91  }
92  $table->setData($vals);
93  }
94  else
95  {
96  $data = $this->ilObjectOrgUnit->getTranslations();
97  foreach($data["Fobject"] as $k => $v)
98  {
99  $data["Fobject"][$k]["default"] = ($k == $data["default_language"]);
100  }
101  if($a_add)
102  {
103  $data["Fobject"][++$k]["title"] = "";
104  }
105  $table->setData($data["Fobject"]);
106  }
107  $this->tpl->setContent($table->getHTML());
108  }
Create styles array
The data for the language used.
TableGUI class for title/description translations.
$_POST["username"]
+ Here is the caller graph for this function:

◆ executeCommand()

ilTranslationGUI::executeCommand ( )

Definition at line 69 of file class.ilTranslationGUI.php.

References $cmd.

70  {
71  $cmd = $this->ctrl->getCmd();
72  $this->$cmd();
73  }
$cmd
Definition: sahs_server.php:35

◆ saveTranslations()

ilTranslationGUI::saveTranslations ( )

Save title and translations.

Definition at line 114 of file class.ilTranslationGUI.php.

References $_POST, editTranslations(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and ilUtil\stripSlashes().

Referenced by deleteTranslations().

115  {
116  // default language set?
117  if (!isset($_POST["default"]))
118  {
119  ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
120  return $this->editTranslations(true);
121  }
122 
123  // all languages set?
124  if (array_key_exists("",$_POST["lang"]))
125  {
126  ilUtil::sendFailure($this->lng->txt("msg_no_language_selected"));
127  return $this->editTranslations(true);
128  }
129 
130  // no single language is selected more than once?
131  if (count(array_unique($_POST["lang"])) < count($_POST["lang"]))
132  {
133  ilUtil::sendFailure($this->lng->txt("msg_multi_language_selected"));
134  return $this->editTranslations(true);
135  }
136 
137  // save the stuff
138  $this->ilObjectOrgUnit->removeTranslations();
139  foreach($_POST["title"] as $k => $v)
140  {
141  // update object data if default
142  $is_default = ($_POST["default"] == $k);
143  if($is_default)
144  {
145  $this->ilObjectOrgUnit->setTitle(ilUtil::stripSlashes($v));
146  $this->ilObjectOrgUnit->setDescription(ilUtil::stripSlashes($_POST["desc"][$k]));
147  $this->ilObjectOrgUnit->update();
148  }
149 
150  $this->ilObjectOrgUnit->addTranslation(
152  ilUtil::stripSlashes($_POST["desc"][$k]),
153  ilUtil::stripSlashes($_POST["lang"][$k]),
154  $is_default);
155  }
156 
157  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
158  $this->ctrl->redirect($this, "editTranslations");
159  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
editTranslations($a_get_post_values=false, $a_add=false)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilTranslationGUI::$ctrl
protected

Definition at line 17 of file class.ilTranslationGUI.php.

◆ $ilAccess

ilTranslationGUI::$ilAccess
protected

Definition at line 25 of file class.ilTranslationGUI.php.

◆ $ilObjectOrgUnit

ilTranslationGUI::$ilObjectOrgUnit
protected

Definition at line 37 of file class.ilTranslationGUI.php.

◆ $ilObjOrgUnitGui

ilTranslationGUI::$ilObjOrgUnitGui
protected

Definition at line 33 of file class.ilTranslationGUI.php.

◆ $lng

ilTranslationGUI::$lng
protected

Definition at line 29 of file class.ilTranslationGUI.php.

◆ $tpl

ilTranslationGUI::$tpl

Definition at line 21 of file class.ilTranslationGUI.php.


The documentation for this class was generated from the following file: