ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 159 of file class.ilTranslationGUI.php.

160 {
161
162 if($_POST["title"])
163 {
164 $k = max(array_keys($_POST["title"]));
165 $k++;
166 $_POST["title"][$k] = "";
167 $this->editTranslations(true);
168 }
169 else
170 {
171 $this->editTranslations(false, true);
172 }
173 }
editTranslations($a_get_post_values=false, $a_add=false)
$_POST['username']
Definition: cron.php:12

References $_POST, and editTranslations().

+ Here is the call graph for this function:

◆ deleteTranslations()

ilTranslationGUI::deleteTranslations ( )

Remove translation.

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

179 {
180 foreach($_POST["title"] as $k => $v)
181 {
182 if ($_POST["check"][$k])
183 {
184 // default translation cannot be deleted
185 if($k != $_POST["default"])
186 {
187 unset($_POST["title"][$k]);
188 unset($_POST["desc"][$k]);
189 unset($_POST["lang"][$k]);
190 }
191 else
192 {
193 ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
194 return $this->editTranslations();
195 }
196 }
197 }
198 $this->saveTranslations();
199 }
saveTranslations()
Save title and translations.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

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

+ Here is the call graph for this function:

◆ editTranslations()

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

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

72 {
73 $this->lng->loadLanguageModule($this->ilObjectOrgUnit->getType());
74
75 $table = new ilObjectTranslationTableGUI($this, "editTranslations", true,
76 "Translation");
77 if ($a_get_post_values)
78 {
79 $vals = array();
80 foreach($_POST["title"] as $k => $v)
81 {
82 $vals[] = array("title" => $v,
83 "desc" => $_POST["desc"][$k],
84 "lang" => $_POST["lang"][$k],
85 "default" => ($_POST["default"] == $k));
86 }
87 $table->setData($vals);
88 }
89 else
90 {
91 $data = $this->ilObjectOrgUnit->getTranslations();
92 foreach($data["Fobject"] as $k => $v)
93 {
94 $data["Fobject"][$k]["default"] = ($k == $data["default_language"]);
95 }
96 if($a_add)
97 {
98 $data["Fobject"][++$k]["title"] = "";
99 }
100 $table->setData($data["Fobject"]);
101 }
102 $this->tpl->setContent($table->getHTML());
103 }
TableGUI class for title/description translations.
$data

References $_POST, and $data.

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

+ Here is the caller graph for this function:

◆ executeCommand()

ilTranslationGUI::executeCommand ( )

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

65 {
66 $cmd = $this->ctrl->getCmd();
67 $this->$cmd();
68 }
$cmd
Definition: sahs_server.php:35

References $cmd.

◆ saveTranslations()

ilTranslationGUI::saveTranslations ( )

Save title and translations.

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

110 {
111 // default language set?
112 if (!isset($_POST["default"]))
113 {
114 ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
115 return $this->editTranslations(true);
116 }
117
118 // all languages set?
119 if (array_key_exists("",$_POST["lang"]))
120 {
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 {
128 ilUtil::sendFailure($this->lng->txt("msg_multi_language_selected"));
129 return $this->editTranslations(true);
130 }
131
132 // save the stuff
133 $this->ilObjectOrgUnit->removeTranslations();
134 foreach($_POST["title"] as $k => $v)
135 {
136 // update object data if default
137 $is_default = ($_POST["default"] == $k);
138 if($is_default)
139 {
140 $this->ilObjectOrgUnit->setTitle(ilUtil::stripSlashes($v));
141 $this->ilObjectOrgUnit->setDescription(ilUtil::stripSlashes($_POST["desc"][$k]));
142 $this->ilObjectOrgUnit->update();
143 }
144
145 $this->ilObjectOrgUnit->addTranslation(
147 ilUtil::stripSlashes($_POST["desc"][$k]),
148 ilUtil::stripSlashes($_POST["lang"][$k]),
149 $is_default);
150 }
151
152 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
153 $this->ctrl->redirect($this, "editTranslations");
154 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

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

Referenced by deleteTranslations().

+ 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: