@@ -133,16 +133,27 @@ public function pre_deleteItem() {
133
133
return true ;
134
134
}
135
135
136
- public function massDeleteTRanslations ($ post ) {
136
+ public function massDeleteTranslations ($ post ) {
137
+ global $ TRANSLATE ;
138
+
139
+ $ form = new PluginFormcreatorForm ();
140
+ if (!$ form ->getFromDB ($ this ->fields ['plugin_formcreator_forms_id ' ])) {
141
+ return ;
142
+ }
143
+ $ translations = $ form ->getTranslations ($ this ->fields ['name ' ]);
137
144
foreach ($ post ['plugin_formcreator_translation ' ] as $ translationId => $ checked ) {
138
145
if ($ checked != '1 ' ) {
139
146
continue ;
140
147
}
141
- $ translation = new PluginFormcreatorTranslation ();
142
- $ translation -> delete ( $ this , [
143
- 'id ' => $ translationId ,
148
+ $ translated = $ form -> getTranslatableStrings ([
149
+ ' id ' => $ translationId ,
150
+ 'language ' => $ this -> fields [ ' name ' ] ,
144
151
]);
152
+ $ original = $ translated [$ translated ['id ' ][$ translationId ]][$ translationId ];
153
+ unset($ translations [$ original ]);
145
154
}
155
+ $ form ->setTranslations ($ this ->fields ['name ' ], $ translations );
156
+ $ TRANSLATE ->clearCache ('formcreator ' , $ this ->fields ['name ' ]);
146
157
}
147
158
148
159
public function showForm ($ ID , $ options = []) {
@@ -202,29 +213,25 @@ public function showNewTranslation($options = []) {
202
213
203
214
echo '<div data-itemtype="PluginFormcreatorForm_Language" data-id=" ' . $ this ->getID () . '"> ' ;
204
215
$ options ['formtitle ' ] = __ ('Add a translation ' , 'formcreator ' );
216
+ $ options ['target ' ] = 'javascript:plugin_formcreator.saveNewTranslation(this); ' ;
217
+
205
218
$ this ->initForm ($ this ->getID (), $ options );
206
- $ this ->showFormHeader ($ options );
207
- echo "<tr class='tab_bg_1'> " ;
219
+ //$this->showFormHeader($options);
220
+ echo '<form name="plugin_formcreator_translation" onsubmit="plugin_formcreator.saveNewTranslation(this); return false;" > ' ;
221
+ echo "<div class='spaced' id='tabsbody'> " ;
222
+ echo "<table class='tab_cadre_fixe' id='mainformtable'> " ;
223
+
224
+ echo "<tr class='tab_bg_1'><td> " ;
208
225
echo Html::hidden ('name ' , ['value ' => $ this ->fields ['name ' ]]);
209
226
echo "</td><td width='50%'> </td></tr> " ;
210
227
211
- echo '<tr> ' ;
212
- echo '<td> ' . __ ('String to translate ' , 'formcreator ' ) . '</td> ' ;
213
- echo '<td> ' ;
214
- echo PluginFormcreatorTranslation::dropdown ([
215
- 'condition ' => [
216
- self ::getForeignKeyField () => $ this ->getID (),
217
- 'is_translated ' => false ,
218
- ],
219
- 'on_change ' => "plugin_formcreator.showTranslationEditor(this) " ,
220
- ]);
221
- echo '</td> ' ;
222
- echo '</tr> ' ;
223
-
224
228
echo '<tr id="plugin_formcreator_editTranslation"> ' ;
225
- echo '<td> ' ;
226
- echo '</td> ' ;
229
+ // echo '<td>';
230
+ // echo '</td>';
231
+ echo PluginFormcreatorTranslation::getEditorFieldsHtml ($ this );
227
232
echo '</tr> ' ;
233
+ echo "<tr class='tab_bg_1'><td> " ;
234
+ echo "</td><td width='50%'> </td></tr> " ;
228
235
229
236
echo '<tr class="tab_bg_2"> '
230
237
. '<td class="center" colspan="4"> '
@@ -242,9 +249,11 @@ public function showNewTranslation($options = []) {
242
249
public function showTranslationEntry ($ input ) : void {
243
250
$ options ['formtitle ' ] = __ ('Add a translation ' , 'formcreator ' );
244
251
$ this ->initForm ($ this ->getID (), $ options );
245
- $ this ->showFormHeader ($ options );
252
+ echo '<form name="plugin_formcreator_translation" onsubmit="plugin_formcreator.saveNewTranslation(this); return false;" > ' ;
253
+ echo "<div class='spaced' id='tabsbody'> " ;
254
+ echo "<table class='tab_cadre_fixe' id='mainformtable'> " ;
246
255
247
- PluginFormcreatorTranslation::getEditor ($ this , $ input ['plugin_formcreator_translations_id ' ]);
256
+ echo PluginFormcreatorTranslation::getEditorFieldsHtml ($ this , $ input ['plugin_formcreator_translations_id ' ]);
248
257
249
258
echo '<tr class="tab_bg_2"> '
250
259
. '<td class="center" colspan="4"> '
0 commit comments