ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 157 of file class.ilTranslationGUI.php.

References $_POST, and editTranslations().

158  {
159  if ($_POST["title"]) {
160  $k = max(array_keys($_POST["title"]));
161  $k++;
162  $_POST["title"][$k] = "";
163  $this->editTranslations(true);
164  } else {
165  $this->editTranslations(false, true);
166  }
167  }
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 172 of file class.ilTranslationGUI.php.

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

173  {
174  foreach ($_POST["title"] as $k => $v) {
175  if ($_POST["check"][$k]) {
176  // default translation cannot be deleted
177  if ($k != $_POST["default"]) {
178  unset($_POST["title"][$k]);
179  unset($_POST["desc"][$k]);
180  unset($_POST["lang"][$k]);
181  } else {
182  ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
183  return $this->editTranslations();
184  }
185  }
186  }
187  $this->saveTranslations();
188  }
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 75 of file class.ilTranslationGUI.php.

References $_POST, $data, and $table.

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

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

◆ executeCommand()

ilTranslationGUI::executeCommand ( )

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

69  {
70  $cmd = $this->ctrl->getCmd();
71  $this->$cmd();
72  }

◆ saveTranslations()

ilTranslationGUI::saveTranslations ( )

Save title and translations.

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

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

Referenced by deleteTranslations().

112  {
113  // default language set?
114  if (!isset($_POST["default"])) {
115  ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
116  return $this->editTranslations(true);
117  }
118 
119  // all languages set?
120  if (array_key_exists("", $_POST["lang"])) {
121  ilUtil::sendFailure($this->lng->txt("msg_no_language_selected"));
122  return $this->editTranslations(true);
123  }
124 
125  // no single language is selected more than once?
126  if (count(array_unique($_POST["lang"])) < count($_POST["lang"])) {
127  ilUtil::sendFailure($this->lng->txt("msg_multi_language_selected"));
128  return $this->editTranslations(true);
129  }
130 
131  // save the stuff
132  $this->ilObjectOrgUnit->removeTranslations();
133  foreach ($_POST["title"] as $k => $v) {
134  // update object data if default
135  $is_default = ($_POST["default"] == $k);
136  if ($is_default) {
137  $this->ilObjectOrgUnit->setTitle(ilUtil::stripSlashes($v));
138  $this->ilObjectOrgUnit->setDescription(ilUtil::stripSlashes($_POST["desc"][$k]));
139  $this->ilObjectOrgUnit->update();
140  }
141 
142  $this->ilObjectOrgUnit->addTranslation(
144  ilUtil::stripSlashes($_POST["desc"][$k]),
145  ilUtil::stripSlashes($_POST["lang"][$k]),
146  $is_default
147  );
148  }
149 
150  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
151  $this->ctrl->redirect($this, "editTranslations");
152  }
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: