basic gettext integration
parent
96a263f712
commit
aad54bfe88
@ -1,88 +1,92 @@
|
|||||||
<?php
|
<?php
|
||||||
|
function admin_faq_title() {
|
||||||
|
return _("Edit FAQs");
|
||||||
|
}
|
||||||
|
|
||||||
function admin_faq() {
|
function admin_faq() {
|
||||||
if (!isset ($_REQUEST['action'])) {
|
if (! isset($_REQUEST['action'])) {
|
||||||
$faqs_html = "";
|
$faqs_html = "";
|
||||||
$faqs = sql_select("SELECT * FROM `FAQ`");
|
$faqs = sql_select("SELECT * FROM `FAQ`");
|
||||||
foreach ($faqs as $faq) {
|
foreach ($faqs as $faq) {
|
||||||
$faqs_html .= sprintf('<tr><td> <dl><dt>%s</dt><dd>%s</dd></dl> </td>' . '<td> <dl><dt>%s</dt><dd>%s</dd></dl> </td>' . '<td><a href="%s&action=edit&id=%s">Edit</a></td></tr>', $faq['Frage_de'], $faq['Antwort_de'], $faq['Frage_en'], $faq['Antwort_en'], page_link_to('admin_faq'), $faq['FID']);
|
$faqs_html .= sprintf('<tr><td> <dl><dt>%s</dt><dd>%s</dd></dl> </td>' . '<td> <dl><dt>%s</dt><dd>%s</dd></dl> </td>' . '<td><a href="%s&action=edit&id=%s">Edit</a></td></tr>', $faq['Frage_de'], $faq['Antwort_de'], $faq['Frage_en'], $faq['Antwort_en'], page_link_to('admin_faq'), $faq['FID']);
|
||||||
}
|
}
|
||||||
return template_render('../templates/admin_faq.html', array (
|
return template_render('../templates/admin_faq.html', array(
|
||||||
'link' => page_link_to("admin_faq"),
|
'link' => page_link_to("admin_faq"),
|
||||||
'faqs' => $faqs_html
|
'faqs' => $faqs_html
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
case 'create' :
|
case 'create':
|
||||||
$frage = strip_request_item_nl('frage');
|
$frage = strip_request_item_nl('frage');
|
||||||
$antwort = strip_request_item_nl('antwort');
|
$antwort = strip_request_item_nl('antwort');
|
||||||
$question = strip_request_item_nl('question');
|
$question = strip_request_item_nl('question');
|
||||||
$answer = strip_request_item_nl('answer');
|
$answer = strip_request_item_nl('answer');
|
||||||
|
|
||||||
sql_query("INSERT INTO `FAQ` SET `Frage_de`='" . sql_escape($frage) . "', `Frage_en`='" . sql_escape($question) . "', `Antwort_de`='" . sql_escape($antwort) . "', `Antwort_en`='" . sql_escape($answer) . "'");
|
sql_query("INSERT INTO `FAQ` SET `Frage_de`='" . sql_escape($frage) . "', `Frage_en`='" . sql_escape($question) . "', `Antwort_de`='" . sql_escape($antwort) . "', `Antwort_en`='" . sql_escape($answer) . "'");
|
||||||
|
|
||||||
redirect(page_link_to("admin_faq"));
|
redirect(page_link_to("admin_faq"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'save' :
|
case 'save':
|
||||||
if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
|
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
|
||||||
$id = $_REQUEST['id'];
|
$id = $_REQUEST['id'];
|
||||||
else
|
else
|
||||||
return error("Incomplete call, missing FAQ ID.", true);
|
return error("Incomplete call, missing FAQ ID.", true);
|
||||||
|
|
||||||
$faq = sql_select("SELECT * FROM `FAQ` WHERE `FID`=" . sql_escape($id) . " LIMIT 1");
|
$faq = sql_select("SELECT * FROM `FAQ` WHERE `FID`=" . sql_escape($id) . " LIMIT 1");
|
||||||
if (count($faq) > 0) {
|
if (count($faq) > 0) {
|
||||||
list ($faq) = $faq;
|
list($faq) = $faq;
|
||||||
|
|
||||||
$frage = strip_request_item_nl('frage');
|
$frage = strip_request_item_nl('frage');
|
||||||
$antwort = strip_request_item_nl('antwort');
|
$antwort = strip_request_item_nl('antwort');
|
||||||
$question = strip_request_item_nl('question');
|
$question = strip_request_item_nl('question');
|
||||||
$answer = strip_request_item_nl('answer');
|
$answer = strip_request_item_nl('answer');
|
||||||
|
|
||||||
sql_query("UPDATE `FAQ` SET `Frage_de`='" . sql_escape($frage) . "', `Frage_en`='" . sql_escape($question) . "', `Antwort_de`='" . sql_escape($antwort) . "', `Antwort_en`='" . sql_escape($answer) . "' WHERE `FID`=" . sql_escape($id) . " LIMIT 1");
|
sql_query("UPDATE `FAQ` SET `Frage_de`='" . sql_escape($frage) . "', `Frage_en`='" . sql_escape($question) . "', `Antwort_de`='" . sql_escape($antwort) . "', `Antwort_en`='" . sql_escape($answer) . "' WHERE `FID`=" . sql_escape($id) . " LIMIT 1");
|
||||||
|
|
||||||
redirect(page_link_to("admin_faq"));
|
redirect(page_link_to("admin_faq"));
|
||||||
} else
|
} else
|
||||||
return error("No FAQ found.", true);
|
return error("No FAQ found.", true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'edit' :
|
case 'edit':
|
||||||
if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
|
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
|
||||||
$id = $_REQUEST['id'];
|
$id = $_REQUEST['id'];
|
||||||
else
|
else
|
||||||
return error("Incomplete call, missing FAQ ID.", true);
|
return error("Incomplete call, missing FAQ ID.", true);
|
||||||
|
|
||||||
$faq = sql_select("SELECT * FROM `FAQ` WHERE `FID`=" . sql_escape($id) . " LIMIT 1");
|
$faq = sql_select("SELECT * FROM `FAQ` WHERE `FID`=" . sql_escape($id) . " LIMIT 1");
|
||||||
if (count($faq) > 0) {
|
if (count($faq) > 0) {
|
||||||
list ($faq) = $faq;
|
list($faq) = $faq;
|
||||||
|
|
||||||
return template_render('../templates/admin_faq_edit_form.html', array (
|
return template_render('../templates/admin_faq_edit_form.html', array(
|
||||||
'link' => page_link_to("admin_faq"),
|
'link' => page_link_to("admin_faq"),
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'frage' => $faq['Frage_de'],
|
'frage' => $faq['Frage_de'],
|
||||||
'antwort' => $faq['Antwort_de'],
|
'antwort' => $faq['Antwort_de'],
|
||||||
'question' => $faq['Frage_en'],
|
'question' => $faq['Frage_en'],
|
||||||
'answer' => $faq['Antwort_en']
|
'answer' => $faq['Antwort_en']
|
||||||
));
|
));
|
||||||
} else
|
} else
|
||||||
return error("No FAQ found.", true);
|
return error("No FAQ found.", true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete' :
|
case 'delete':
|
||||||
if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
|
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
|
||||||
$id = $_REQUEST['id'];
|
$id = $_REQUEST['id'];
|
||||||
else
|
else
|
||||||
return error("Incomplete call, missing FAQ ID.", true);
|
return error("Incomplete call, missing FAQ ID.", true);
|
||||||
|
|
||||||
$faq = sql_select("SELECT * FROM `FAQ` WHERE `FID`=" . sql_escape($id) . " LIMIT 1");
|
$faq = sql_select("SELECT * FROM `FAQ` WHERE `FID`=" . sql_escape($id) . " LIMIT 1");
|
||||||
if (count($faq) > 0) {
|
if (count($faq) > 0) {
|
||||||
list ($faq) = $faq;
|
list($faq) = $faq;
|
||||||
|
|
||||||
sql_query("DELETE FROM `FAQ` WHERE `FID`=" . sql_escape($id) . " LIMIT 1");
|
sql_query("DELETE FROM `FAQ` WHERE `FID`=" . sql_escape($id) . " LIMIT 1");
|
||||||
redirect(page_link_to("admin_faq"));
|
redirect(page_link_to("admin_faq"));
|
||||||
} else
|
} else
|
||||||
return error("No FAQ found.", true);
|
return error("No FAQ found.", true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,105 +0,0 @@
|
|||||||
<?php
|
|
||||||
function admin_language() {
|
|
||||||
global $user;
|
|
||||||
global $languages;
|
|
||||||
|
|
||||||
$html = "";
|
|
||||||
if (!isset ($_POST["TextID"])) {
|
|
||||||
$html .= Get_Text("Hello") . User_Nick_render($user) . ", <br />\n";
|
|
||||||
$html .= Get_Text("pub_sprache_text1") . "<br /><br />\n";
|
|
||||||
|
|
||||||
$html .= "<a href=\"" . page_link_to("admin_language") . "&ShowEntry=y\">" . Get_Text("pub_sprache_ShowEntry") . "</a>";
|
|
||||||
// ausgabe Tabellenueberschift
|
|
||||||
$html .= "\t<table border=\"0\" class=\"border\" cellpadding=\"2\" cellspacing=\"1\">\n\t\t<tr>";
|
|
||||||
$html .= "\t\t<td class=\"contenttopic\"><b>" . Get_Text("pub_sprache_TextID") . "</b></td>";
|
|
||||||
foreach($languages as $language => $language_name) {
|
|
||||||
$html .= "<td class=\"contenttopic\"><b>" .
|
|
||||||
Get_Text("pub_sprache_Sprache") . " " . $language .
|
|
||||||
"</b></td>";
|
|
||||||
$Sprachen[$language] = $language_name;
|
|
||||||
}
|
|
||||||
$html .= "\t\t<td class=\"contenttopic\"><b>" . Get_Text("pub_sprache_Edit") . "</b></td>";
|
|
||||||
$html .= "\t\t</tr>";
|
|
||||||
|
|
||||||
if (isset ($_GET["ShowEntry"])) {
|
|
||||||
// ausgabe eintraege
|
|
||||||
$sprache_source = sql_select("SELECT * FROM `Sprache` ORDER BY `TextID`, `Sprache`");
|
|
||||||
|
|
||||||
$TextID_Old = $sprache_source[0]['TextID'];
|
|
||||||
foreach($sprache_source as $sprache_entry) {
|
|
||||||
$TextID_New = $sprache_entry['TextID'];
|
|
||||||
if ($TextID_Old != $TextID_New) {
|
|
||||||
$html .= "<form action=\"" . page_link_to("admin_language") . "\" method=\"post\">";
|
|
||||||
$html .= "<tr class=\"content\">\n";
|
|
||||||
$html .= "\t\t<td>$TextID_Old " .
|
|
||||||
"<input name=\"TextID\" type=\"hidden\" value=\"$TextID_Old\"> </td>\n";
|
|
||||||
|
|
||||||
foreach ($Sprachen as $Name => $Value) {
|
|
||||||
$Value = html_entity_decode($Value, ENT_QUOTES);
|
|
||||||
$html .= "\t\t<td><textarea name=\"$Name\" cols=\"22\" rows=\"8\">$Value</textarea></td>\n";
|
|
||||||
$Sprachen[$Name] = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
$html .= "\t\t<td><input type=\"submit\" value=\"Save\"></td>\n";
|
|
||||||
$html .= "</tr>";
|
|
||||||
$html .= "</form>\n";
|
|
||||||
$TextID_Old = $TextID_New;
|
|
||||||
}
|
|
||||||
$Sprachen[$sprache_entry['Sprache']] = $sprache_entry['Text'];
|
|
||||||
} /*FOR*/
|
|
||||||
}
|
|
||||||
|
|
||||||
//fuer neu eintraege
|
|
||||||
$html .= "<form action=\"" . page_link_to("admin_language") . "\" method=\"post\">";
|
|
||||||
$html .= "<tr class=\"content\">\n";
|
|
||||||
$html .= "\t\t<td><input name=\"TextID\" type=\"text\" size=\"40\" value=\"new\"> </td>\n";
|
|
||||||
|
|
||||||
foreach ($Sprachen as $Name => $Value)
|
|
||||||
$html .= "\t\t<td><textarea name=\"$Name\" cols=\"22\" rows=\"8\">$Name Text</textarea></td>\n";
|
|
||||||
|
|
||||||
$html .= "\t\t<td><input type=\"submit\" value=\"Save\"></td>\n";
|
|
||||||
$html .= "</tr>";
|
|
||||||
$html .= "</form>\n";
|
|
||||||
|
|
||||||
$html .= "</table>\n";
|
|
||||||
} /*if( !isset( $TextID ) )*/
|
|
||||||
else {
|
|
||||||
$html .= "edit: " . $_POST["TextID"] . "<br /><br />";
|
|
||||||
foreach ($_POST as $k => $v) {
|
|
||||||
if ($k != "TextID") {
|
|
||||||
$sql_test = "SELECT * FROM `Sprache` " .
|
|
||||||
"WHERE `TextID`='" . sql_escape($_POST["TextID"])
|
|
||||||
. "' AND `Sprache`='"
|
|
||||||
. sql_escape($k) . "'";
|
|
||||||
|
|
||||||
$erg_test = sql_select("SELECT * FROM `Sprache` WHERE `TextID`='" . sql_escape($_POST["TextID"]) . "' AND `Sprache`='" . sql_escape($k) . "'");
|
|
||||||
if (count($erg_test) == 0) {
|
|
||||||
$sql_save = "INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) " .
|
|
||||||
"VALUES ('" . sql_escape($_POST["TextID"]) . "', '"
|
|
||||||
. sql_escape($k) . "', '"
|
|
||||||
. sql_escape($v) . "')";
|
|
||||||
|
|
||||||
$html .= $sql_save . "<br />";
|
|
||||||
$Erg = sql_query($sql_save);
|
|
||||||
$html .= success("$k Save: OK<br />\n", true);
|
|
||||||
} else
|
|
||||||
if ($erg_test[0]['Text'] != $v) {
|
|
||||||
$sql_save = "UPDATE `Sprache` SET `Text`='"
|
|
||||||
. sql_escape($v) . "' " .
|
|
||||||
"WHERE `TextID`='"
|
|
||||||
. sql_escape($_POST["TextID"])
|
|
||||||
. "' AND `Sprache`='" . sql_escape($k) . "' ";
|
|
||||||
|
|
||||||
$html .= $sql_save . "<br />";
|
|
||||||
$Erg = sql_query($sql_save);
|
|
||||||
$html .= success(" $k Update: OK<br />\n", true);
|
|
||||||
} else
|
|
||||||
$html .= "\t $k no changes<br />\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue