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,114 +136,118 @@
} 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) {
print_heading("$file", "LEFT", 4); echo "<b>$file</b> &nbsp; ";
if (!file_exists("$langdir/$file")) {
if (!touch("$langdir/$file")) {
echo "<p><font color=red>".get_string("filemissing", "", "$langdir/$file")."</font></p>";
continue;
}
}
error_reporting(0);
if ($f = fopen("$langdir/$file","r+")) {
$editable = true;
fclose($f);
} else { } else {
$editable = false; echo "<a href=\"lang.php?mode=compare&currentfile=$file\">$file</a> &nbsp; ";
echo "<p><font size=1>".get_string("makeeditable", "", "$langdir/$file")."</font></p>";
} }
error_reporting(7); }
echo '</font></center>';
print_simple_box_end();
print_heading("$currentfile", "LEFT", 4);
unset($string); if (!file_exists("$langdir/$currentfile")) {
include("$enlangdir/$file"); if (!touch("$langdir/$currentfile")) {
$enstring = $string; echo "<p><font color=red>".get_string("filemissing", "", "$langdir/$currentfile")."</font></p>";
ksort($enstring); continue;
unset($string);
include("$langdir/$file");
if ($editable) {
echo "<form name=\"$file\" action=\"lang.php\" method=\"post\">";
} }
echo "<table width=\"100%\" cellpadding=2 cellspacing=3 border=0>";
foreach ($enstring as $key => $envalue) {
$envalue = nl2br(htmlspecialchars($envalue));
$envalue = preg_replace('/(\$a\-\&gt;[a-zA-Z0-9]*|\$a)/', '<b>$0</b>', $envalue); // Make variables bold.
$envalue = str_replace("%%","%",$envalue);
echo "<tr>";
echo "<td width=20% bgcolor=\"$THEME->cellheading\" nowrap valign=top>$key</td>";
echo "<td width=40% bgcolor=\"$THEME->cellheading\" valign=top>$envalue</td>";
$value = $string[$key];
$value = str_replace("\r","",$value); // Bad character caused by Windows
$value = str_replace("\n\n\n\n\n\n","\n",$value); // Collapse runs of blank lines
$value = str_replace("\n\n\n\n\n","\n",$value);
$value = str_replace("\n\n\n\n","\n",$value);
$value = str_replace("\n\n\n","\n",$value);
$value = str_replace("\n\n\n","\n",$value);
$value = str_replace("\\","",$value); // Delete all slashes
$value = str_replace("%%","%",$value);
$value = htmlspecialchars($value);
$cellcolour = $value ? $THEME->cellcontent: $THEME->highlight;
if ($editable) {
echo "<td width=40% bgcolor=\"$cellcolour\" valign=top>";
if (isset($string[$key])) {
$valuelen = strlen($value);
} else {
$valuelen = strlen($envalue);
}
$cols=50;
if (strstr($value, "\r") or strstr($value, "\n") or $valuelen > $cols) {
$rows = ceil($valuelen / $cols);
echo "<textarea name=\"string-$key\" cols=\"$cols\" rows=\"$rows\">$value</textarea>";
} else {
if ($valuelen) {
$cols = $valuelen + 2;
}
echo "<input type=\"text\" name=\"string-$key\" value=\"$value\" size=\"$cols\"></td>";
}
echo "</TD>";
} else {
echo "<td width=40% bgcolor=\"$cellcolour\" valign=top>$value</td>";
}
}
if ($editable) {
echo "<tr><td colspan=2>&nbsp;<td>";
echo " <input type=\"hidden\" name=\"file\" value=\"$file\">";
echo " <input type=\"hidden\" name=\"mode\" value=\"compare\">";
echo " <input type=\"submit\" name=\"update\" value=\"".get_string("savechanges").": $file\">";
echo "</td></tr>";
}
echo "</table>";
echo "</form>";
} }
print_continue("lang.php"); error_reporting(0);
if ($f = fopen("$langdir/$currentfile","r+")) {
$editable = true;
fclose($f);
} else {
$editable = false;
echo "<p><font size=1>".get_string("makeeditable", "", "$langdir/$currentfile")."</font></p>";
}
error_reporting(7);
unset($string);
include("$enlangdir/$currentfile");
$enstring = $string;
ksort($enstring);
unset($string);
include("$langdir/$currentfile");
if ($editable) {
echo "<form name=\"$currentfile\" action=\"lang.php\" method=\"post\">";
}
echo "<table width=\"100%\" cellpadding=2 cellspacing=3 border=0>";
foreach ($enstring as $key => $envalue) {
$envalue = nl2br(htmlspecialchars($envalue));
$envalue = preg_replace('/(\$a\-\&gt;[a-zA-Z0-9]*|\$a)/', '<b>$0</b>', $envalue); // Make variables bold.
$envalue = str_replace("%%","%",$envalue);
echo "<tr>";
echo "<td width=20% bgcolor=\"$THEME->cellheading\" nowrap valign=top>$key</td>";
echo "<td width=40% bgcolor=\"$THEME->cellheading\" valign=top>$envalue</td>";
$value = $string[$key];
$value = str_replace("\r","",$value); // Bad character caused by Windows
$value = str_replace("\n\n\n\n\n\n","\n",$value); // Collapse runs of blank lines
$value = str_replace("\n\n\n\n\n","\n",$value);
$value = str_replace("\n\n\n\n","\n",$value);
$value = str_replace("\n\n\n","\n",$value);
$value = str_replace("\n\n\n","\n",$value);
$value = str_replace("\\","",$value); // Delete all slashes
$value = str_replace("%%","%",$value);
$value = htmlspecialchars($value);
$cellcolour = $value ? $THEME->cellcontent: $THEME->highlight;
if ($editable) {
echo "<td width=40% bgcolor=\"$cellcolour\" valign=top>";
if (isset($string[$key])) {
$valuelen = strlen($value);
} else {
$valuelen = strlen($envalue);
}
$cols=50;
if (strstr($value, "\r") or strstr($value, "\n") or $valuelen > $cols) {
$rows = ceil($valuelen / $cols);
echo "<textarea name=\"string-$key\" cols=\"$cols\" rows=\"$rows\">$value</textarea>";
} else {
if ($valuelen) {
$cols = $valuelen + 2;
}
echo "<input type=\"text\" name=\"string-$key\" value=\"$value\" size=\"$cols\"></td>";
}
echo "</TD>";
} else {
echo "<td width=40% bgcolor=\"$cellcolour\" valign=top>$value</td>";
}
}
if ($editable) {
echo "<tr><td colspan=2>&nbsp;<td><br />";
echo " <input type=\"hidden\" name=\"currentfile\" value=\"$currentfile\">";
echo " <input type=\"hidden\" name=\"mode\" value=\"compare\">";
echo " <input type=\"submit\" name=\"update\" value=\"".get_string("savechanges").": $currentfile\">";
echo "</td></tr>";
}
echo "</table>";
echo "</form>";
} }
print_footer(); print_footer();