Skip to content

Commit

Permalink
Try to create missing string files if possible (thanks Gustav)
Browse files Browse the repository at this point in the history
  • Loading branch information
moodler committed Sep 10, 2003
1 parent 6f4fb1c commit 11863e8
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions admin/lang.php
Expand Up @@ -75,8 +75,10 @@


foreach ($stringfiles as $file) { foreach ($stringfiles as $file) {
if (!file_exists("$langdir/$file")) { if (!file_exists("$langdir/$file")) {
echo "<P><FONT COLOR=red>".get_string("filemissing", "", "$langdir/$file")."</FONT></P>"; if (!touch("$langdir/$file")) {
continue; echo "<p><font color=red>".get_string("filemissing", "", "$langdir/$file")."</font></p>";
continue;
}
} }


unset($string); unset($string);
Expand Down Expand Up @@ -108,7 +110,7 @@


foreach ($files as $filekey => $file) { // check all the help files. foreach ($files as $filekey => $file) { // check all the help files.
if (!file_exists("$langdir/help/$file")) { if (!file_exists("$langdir/help/$file")) {
echo "<P><FONT COLOR=red>".get_string("filemissing", "", "$langdir/help/$file")."</FONT></P>"; echo "<p><font color=red>".get_string("filemissing", "", "$langdir/help/$file")."</font></p>";
$somethingfound = true; $somethingfound = true;
continue; continue;
} }
Expand Down Expand Up @@ -145,17 +147,19 @@
} }


print_heading($strcomparelanguage); print_heading($strcomparelanguage);
echo "<CENTER>"; echo "<center>";
helpbutton("langedit",$strcomparelanguage); helpbutton("langedit",$strcomparelanguage);
echo "</CENTER>"; echo "</center>";


foreach ($stringfiles as $file) { foreach ($stringfiles as $file) {


print_heading("$file", "LEFT", 4); print_heading("$file", "LEFT", 4);


if (!file_exists("$langdir/$file")) { if (!file_exists("$langdir/$file")) {
echo "<P><FONT COLOR=red>".get_string("filemissing", "", "$langdir/$file")."</FONT></P>"; if (!touch("$langdir/$file")) {
continue; echo "<p><font color=red>".get_string("filemissing", "", "$langdir/$file")."</font></p>";
continue;
}
} }


error_reporting(0); error_reporting(0);
Expand All @@ -164,7 +168,7 @@
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/$file")."</font></p>";
} }
error_reporting(7); error_reporting(7);


Expand All @@ -178,17 +182,17 @@
include("$langdir/$file"); include("$langdir/$file");


if ($editable) { if ($editable) {
echo "<FORM NAME=\"$file\" ACTION=\"lang.php\" METHOD=\"POST\">"; echo "<form name=\"$file\" 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) {
$envalue = nl2br(htmlspecialchars($envalue)); $envalue = nl2br(htmlspecialchars($envalue));
$envalue = preg_replace('/(\$a\-\&gt;[a-zA-Z0-9]*|\$a)/', '<b>$0</b>', $envalue); // Make variables bold. $envalue = preg_replace('/(\$a\-\&gt;[a-zA-Z0-9]*|\$a)/', '<b>$0</b>', $envalue); // Make variables bold.
$envalue = str_replace("%%","%",$envalue); $envalue = str_replace("%%","%",$envalue);


echo "<TR>"; echo "<tr>";
echo "<TD WIDTH=20% BGCOLOR=\"$THEME->cellheading\" NOWRAP VALIGN=TOP>$key</TD>"; echo "<td width=20% bgcolor=\"$THEME->cellheading\" nowrap valign=top>$key</td>";
echo "<TD WIDTH=40% BGCOLOR=\"$THEME->cellheading\" VALIGN=TOP>$envalue</TD>"; echo "<td width=40% bgcolor=\"$THEME->cellheading\" valign=top>$envalue</td>";


$value = $string[$key]; $value = $string[$key];
$value = str_replace("\r","",$value); // Bad character caused by Windows $value = str_replace("\r","",$value); // Bad character caused by Windows
Expand All @@ -204,7 +208,7 @@
$cellcolour = $value ? $THEME->cellcontent: $THEME->highlight; $cellcolour = $value ? $THEME->cellcontent: $THEME->highlight;


if ($editable) { if ($editable) {
echo "<TD WIDTH=40% BGCOLOR=\"$cellcolour\" VALIGN=TOP>"; echo "<td width=40% bgcolor=\"$cellcolour\" valign=top>";
if (isset($string[$key])) { if (isset($string[$key])) {
$valuelen = strlen($value); $valuelen = strlen($value);
} else { } else {
Expand All @@ -213,28 +217,28 @@
$cols=50; $cols=50;
if (strstr($value, "\r") or strstr($value, "\n") or $valuelen > $cols) { if (strstr($value, "\r") or strstr($value, "\n") or $valuelen > $cols) {
$rows = ceil($valuelen / $cols); $rows = ceil($valuelen / $cols);
echo "<TEXTAREA NAME=\"string-$key\" cols=\"$cols\" rows=\"$rows\">$value</TEXTAREA>"; echo "<textarea name=\"string-$key\" cols=\"$cols\" rows=\"$rows\">$value</textarea>";
} else { } else {
if ($valuelen) { if ($valuelen) {
$cols = $valuelen + 2; $cols = $valuelen + 2;
} }
echo "<INPUT TYPE=\"TEXT\" NAME=\"string-$key\" VALUE=\"$value\" SIZE=\"$cols\"></TD>"; echo "<input type=\"text\" name=\"string-$key\" value=\"$value\" size=\"$cols\"></td>";
} }
echo "</TD>"; echo "</TD>";


} else { } else {
echo "<TD WIDTH=40% BGCOLOR=\"$cellcolour\" VALIGN=TOP>$value</TD>"; echo "<td width=40% bgcolor=\"$cellcolour\" valign=top>$value</td>";
} }
} }
if ($editable) { if ($editable) {
echo "<TR><TD COLSPAN=2>&nbsp;<TD>"; echo "<tr><td colspan=2>&nbsp;<td>";
echo " <INPUT TYPE=\"hidden\" NAME=\"file\" VALUE=\"$file\">"; echo " <input type=\"hidden\" name=\"file\" value=\"$file\">";
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").": $file\">";
echo "</TD></TR>"; echo "</td></tr>";
} }
echo "</TABLE>"; echo "</table>";
echo "</FORM>"; echo "</form>";
} }


print_continue("lang.php"); print_continue("lang.php");
Expand Down

0 comments on commit 11863e8

Please sign in to comment.