Refactor translationwizard forms by NB-Core · Pull Request #7 · NB-Core/modules · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions systems/translationwizard/translationwizard.php
20 changes: 10 additions & 10 deletions systems/translationwizard/translationwizard/check.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@
case "deleteall":
$sql= "SELECT count( tid ) AS counter, min(tid) as tid, intext, uri,language FROM ".db_prefix("translations")." GROUP BY intext, uri, language HAVING counter >1;";
$result = db_query($sql);
rawoutput("<form action='runmodule.php?module=translationwizard&op=check&mode=delete' method='post'>");
addnav("", "runmodule.php?module=translationwizard&op=check&mode=delete");
rawoutput("<input type='hidden' name='op' value='check'>");
tw_form_open('check&mode=delete', ['op' => 'check']);
addnav("", "runmodule.php?module=translationwizard&op=check&mode=delete");
output("`n`n %s rows have been found not to be unique within your translations table.`n`n",db_num_rows($result));
output("`0This operation will delete one occurrence of each row. `n`n`b`$ CAUTION!`b`0`n`nDue to technical reasons, this operation can't let you select every single line.");
output("The query would cost a lot of time and MySql might time out or the query block your game for more than just seconds.");
Expand All @@ -93,27 +92,28 @@
rawoutput("<option label='min' selected>Delete first</option>");
rawoutput("<option label='max'>Delete last</option>");
rawoutput("</select>");
rawoutput("<br><br><br><br> <input type='submit' value='". translate_inline("Execute") ."' class='button'></form>");
tw_form_close(translate_inline('Execute'));
output("`b`i`$ Attention, no additional confirmation`i`b`0");

break;

default: //if the user hits the button just to check for duplicates
$sql= "SELECT count( tid ) AS counter, min(tid) as tid, intext, uri,language FROM ".db_prefix("translations")." GROUP BY intext, uri, language HAVING counter >1;";
$result = db_query($sql);
rawoutput("<form action='runmodule.php?module=translationwizard&op=check&mode=delete' method='post'>");
addnav("", "runmodule.php?module=translationwizard&op=check&mode=delete");
rawoutput("<input type='hidden' name='op' value='check'>");
tw_form_open('check&mode=delete', ['op' => 'check']);
addnav("", "runmodule.php?module=translationwizard&op=check&mode=delete");
output("`n`n %s rows have been found not to be unique within your translations table.`n`n",db_num_rows($result));
if (db_num_rows($result)==0) //table is fine, no redundant rows
{
output("Congratulations! Your translation table does not have any redundant entries!");
rawoutput("</form");
tw_form_close();
break;
}
output("What do you want to do?`n`n`n`n");
rawoutput("<input type='submit' name='deleteall' value='". translate_inline("Delete multiple automatically") ."' class='button'>");
rawoutput("<input type='submit' name='listing' value='". translate_inline("Delete manually") ."' class='button'></form>");
rawoutput("<input type='submit' name='deleteall' value='". translate_inline("Delete multiple automatically") ."' class='button'>");
rawoutput("<input type='submit' name='listing' value='". translate_inline("Delete manually") ."' class='button'>");
tw_form_close();
break;
}
?>

19 changes: 9 additions & 10 deletions systems/translationwizard/translationwizard/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
$row['intext'] = stripslashes($row['intext']);
$submit = translate_inline("Save Translation");
$skip = translate_inline("Skip Translation");
rawoutput("<form action='runmodule.php?module=translationwizard&op=randomsave' method='post'>");
tw_form_open('randomsave', [
'id' => $row['id'],
'language' => $row['language'],
'namespace' => $row['namespace'],
]);
output("`^`cThere are `&%s`^ untranslated texts in the database.`c`n`n", $count['count']);
rawoutput("<table width='80%'>");
rawoutput("<tr><td width='30%'>");
Expand All @@ -21,14 +25,9 @@
rawoutput("</td><td></td></tr>");
rawoutput("<tr><td width='30%'><textarea cols='35' rows='4' name='intext' readonly>".$row['intext']."</textarea></td>");
rawoutput("<td width='30%'><textarea cols='25' rows='4' name='outtext'></textarea></td></tr></table>");
rawoutput("<input type='hidden' name='id' value='{$row['id']}'>");
rawoutput("<input type='hidden' name='language' value='{$row['language']}'>");
rawoutput("<input type='hidden' name='namespace' value='{$row['namespace']}'>");
rawoutput("<input type='submit' value='$submit' class='button'>");
rawoutput("</form>");
rawoutput("<form action='runmodule.php?module=translationwizard' method='post'>");
rawoutput("<input type='submit' value='$skip' class='button'>");
rawoutput("</form>");
tw_form_close($submit);
tw_form_open('');
tw_form_close($skip);
addnav("", "runmodule.php?module=translationwizard&op=randomsave");
addnav("", "runmodule.php?module=translationwizard");
} else {
Expand All @@ -40,4 +39,4 @@
output("There are no untranslated texts in the database!");
output("Congratulations!!!");
} // end if
?>
?>
30 changes: 30 additions & 0 deletions systems/translationwizard/translationwizard/form_helpers.php