ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 166 of file class.ilTranslationGUI.php.

References $_POST, and editTranslations().

167  {
168  if ($_POST["title"]) {
169  $k = max(array_keys($_POST["title"]));
170  $k++;
171  $_POST["title"][$k] = "";
172  $this->editTranslations(true);
173  } else {
174  $this->editTranslations(false, true);
175  }
176  }
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 182 of file class.ilTranslationGUI.php.

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

183  {
184  foreach ($_POST["title"] as $k => $v) {
185  if ($_POST["check"][$k]) {
186  // default translation cannot be deleted
187  if ($k != $_POST["default"]) {
188  unset($_POST["title"][$k]);
189  unset($_POST["desc"][$k]);
190  unset($_POST["lang"][$k]);
191  } else {
192  ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
193 
194  return $this->editTranslations();
195  }
196  }
197  }
198  $this->saveTranslations();
199  }
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, and $data.

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

77  {
78  $this->lng->loadLanguageModule($this->ilObjectOrgUnit->getType());
79 
80  $table = new ilObjectTranslationTableGUI(
81  $this,
82  "editTranslations",
83  true,
84  "Translation"
85  );
86  if ($a_get_post_values) {
87  $vals = array();
88  foreach ($_POST["title"] as $k => $v) {
89  $vals[] = array(
90  "title" => $v,
91  "desc" => $_POST["desc"][$k],
92  "lang" => $_POST["lang"][$k],
93  "default" => ($_POST["default"] == $k),
94  );
95  }
96  $table->setData($vals);
97  } else {
98  $data = $this->ilObjectOrgUnit->getTranslations();
99  if ($a_add) {
100  $data[]["title"] = "";
101  }
102  $table->setData($data);
103  }
104  $this->tpl->setContent($table->getHTML());
105  }
$data
Definition: storeScorm.php:23
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.

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

◆ 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 
117  return $this->editTranslations(true);
118  }
119 
120  // all languages set?
121  if (array_key_exists("", $_POST["lang"])) {
122  ilUtil::sendFailure($this->lng->txt("msg_no_language_selected"));
123 
124  return $this->editTranslations(true);
125  }
126 
127  // no single language is selected more than once?
128  if (count(array_unique($_POST["lang"])) < count($_POST["lang"])) {
129  ilUtil::sendFailure($this->lng->txt("msg_multi_language_selected"));
130 
131  return $this->editTranslations(true);
132  }
133 
134  // save the stuff
135  $this->ilObjectOrgUnit->removeTranslations();
136  foreach ($_POST["title"] as $k => $v) {
137 
138 
139  $translations = $this->ilObjectOrgUnit->getTranslations();
140 
141  if(array_key_exists($_POST["lang"][$k], $translations)) {
142  $this->ilObjectOrgUnit->updateTranslation(
144  ilUtil::stripSlashes($_POST["desc"][$k]),
145  ilUtil::stripSlashes($_POST["lang"][$k]),
146  ($_POST["default"]==$k)?1:0
147  );
148  } else {
149  $this->ilObjectOrgUnit->addTranslation(
151  ilUtil::stripSlashes($_POST["desc"][$k]),
152  ilUtil::stripSlashes($_POST["lang"][$k]),
153  ($_POST["default"]==$k)?1:0
154  );
155  }
156  }
157 
158  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
159  $this->ctrl->redirect($this, "editTranslations");
160  }
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 19 of file class.ilTranslationGUI.php.

◆ $ilAccess

ilTranslationGUI::$ilAccess
protected

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

◆ $ilObjectOrgUnit

ilTranslationGUI::$ilObjectOrgUnit
protected

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

◆ $ilObjOrgUnitGui

ilTranslationGUI::$ilObjOrgUnitGui
protected

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

◆ $lng

ilTranslationGUI::$lng
protected

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

◆ $tpl

ilTranslationGUI::$tpl

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


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