Split up the looooooooooooooong page into separate files, to make editing

a little easier!
This commit is contained in:
moodler 2003-10-08 05:44:56 +00:00
parent 8aed17838e
commit 094640f170

View file

@ -3,6 +3,7 @@
require_once("../config.php"); require_once("../config.php");
optional_variable($mode, ""); optional_variable($mode, "");
optional_variable($currentfile, "moodle.php");
require_login(); require_login();
@ -65,7 +66,7 @@
} }
foreach ($stringfiles as $key => $file) { foreach ($stringfiles as $key => $file) {
if ($file == "README" or $file == "help" or $file == "docs" or $file == "fonts") { if (substr($file, -4) != ".php") {
unset($stringfiles[$key]); unset($stringfiles[$key]);
} }
} }
@ -135,54 +136,61 @@
} else if ($mode == "compare") { } else if ($mode == "compare") {
if (isset($_POST['file'])){ // Save a file if (isset($_POST['currentfile'])){ // Save a file
$newstrings = $_POST; $newstrings = $_POST;
$file = $newstrings['file']; unset($newstrings['currentfile']);
unset($newstrings['file']); if (lang_save_file($langdir, $currentfile, $newstrings)) {
if (lang_save_file($langdir, $file, $newstrings)) { notify(get_string("changessaved")." ($langdir/$currentfile)", "green");
notify(get_string("changessaved")." ($langdir/$file)");
} else { } else {
error("Could not save the file '$file'!", "lang.php?mode=compare"); error("Could not save the file '$currentfile'!", "lang.php?mode=compare&currentfile=$currentfile");
} }
} }
print_heading($strcomparelanguage); print_heading_with_help($strcomparelanguage, "langedit");
echo "<center>";
helpbutton("langedit",$strcomparelanguage);
echo "</center>";
print_simple_box_start("center", "80%");
echo '<center><font size="2">';
foreach ($stringfiles as $file) { foreach ($stringfiles as $file) {
if ($file == $currentfile) {
echo "<b>$file</b> &nbsp; ";
} else {
echo "<a href=\"lang.php?mode=compare&currentfile=$file\">$file</a> &nbsp; ";
}
}
echo '</font></center>';
print_simple_box_end();
print_heading("$file", "LEFT", 4);
if (!file_exists("$langdir/$file")) { print_heading("$currentfile", "LEFT", 4);
if (!touch("$langdir/$file")) {
echo "<p><font color=red>".get_string("filemissing", "", "$langdir/$file")."</font></p>"; if (!file_exists("$langdir/$currentfile")) {
if (!touch("$langdir/$currentfile")) {
echo "<p><font color=red>".get_string("filemissing", "", "$langdir/$currentfile")."</font></p>";
continue; continue;
} }
} }
error_reporting(0); error_reporting(0);
if ($f = fopen("$langdir/$file","r+")) { if ($f = fopen("$langdir/$currentfile","r+")) {
$editable = true; $editable = true;
fclose($f); fclose($f);
} else { } else {
$editable = false; $editable = false;
echo "<p><font size=1>".get_string("makeeditable", "", "$langdir/$file")."</font></p>"; echo "<p><font size=1>".get_string("makeeditable", "", "$langdir/$currentfile")."</font></p>";
} }
error_reporting(7); error_reporting(7);
unset($string); unset($string);
include("$enlangdir/$file"); include("$enlangdir/$currentfile");
$enstring = $string; $enstring = $string;
ksort($enstring); ksort($enstring);
unset($string); unset($string);
include("$langdir/$file"); include("$langdir/$currentfile");
if ($editable) { if ($editable) {
echo "<form name=\"$file\" action=\"lang.php\" method=\"post\">"; echo "<form name=\"$currentfile\" action=\"lang.php\" method=\"post\">";
} }
echo "<table width=\"100%\" cellpadding=2 cellspacing=3 border=0>"; echo "<table width=\"100%\" cellpadding=2 cellspacing=3 border=0>";
foreach ($enstring as $key => $envalue) { foreach ($enstring as $key => $envalue) {
@ -231,17 +239,14 @@
} }
} }
if ($editable) { if ($editable) {
echo "<tr><td colspan=2>&nbsp;<td>"; echo "<tr><td colspan=2>&nbsp;<td><br />";
echo " <input type=\"hidden\" name=\"file\" value=\"$file\">"; echo " <input type=\"hidden\" name=\"currentfile\" value=\"$currentfile\">";
echo " <input type=\"hidden\" name=\"mode\" value=\"compare\">"; echo " <input type=\"hidden\" name=\"mode\" value=\"compare\">";
echo " <input type=\"submit\" name=\"update\" value=\"".get_string("savechanges").": $file\">"; echo " <input type=\"submit\" name=\"update\" value=\"".get_string("savechanges").": $currentfile\">";
echo "</td></tr>"; echo "</td></tr>";
} }
echo "</table>"; echo "</table>";
echo "</form>"; echo "</form>";
}
print_continue("lang.php");
} }