forked from science-ation/science-ation
Update page text's to do multiple languages, instead of storign the text's in the separate language editor
Also - force it to use the newly auto-installed fckeditor, and reduce the height a bit becuase there's now more than one per page.
This commit is contained in:
parent
4cf6c46a6f
commit
3992b68029
@ -991,21 +991,21 @@ function getEmailRecipientsForRegistration($reg_id)
|
||||
function output_page_text($textname)
|
||||
{
|
||||
global $config;
|
||||
$q=mysql_query("SELECT * FROM pagetext WHERE textname='$textname' AND year='".$config['FAIRYEAR']."'");
|
||||
$q=mysql_query("SELECT * FROM pagetext WHERE textname='$textname' AND year='".$config['FAIRYEAR']."' AND lang='".$_SESSION['lang']."'");
|
||||
if(mysql_num_rows($q))
|
||||
$r=mysql_fetch_object($q);
|
||||
else
|
||||
{
|
||||
//not defined, lets grab the default text
|
||||
$q=mysql_query("SELECT * FROM pagetext WHERE textname='$textname' AND year='-1'");
|
||||
$q=mysql_query("SELECT * FROM pagetext WHERE textname='$textname' AND year='-1' AND lang='".$config['default_language']."'");
|
||||
$r=mysql_fetch_object($q);
|
||||
}
|
||||
|
||||
//if it looks like we have HTML content, dont do a nl2br, if there's no html, then do the nl2br
|
||||
if(strlen($r->text)==strlen(strip_tags($r->text)))
|
||||
echo nl2br(i18n($r->text));
|
||||
echo nl2br($r->text);
|
||||
else
|
||||
echo i18n($r->text);
|
||||
echo $r->text;
|
||||
}
|
||||
|
||||
function generatePassword($pwlen=8)
|
||||
|
@ -25,6 +25,12 @@
|
||||
require("../common.inc.php");
|
||||
require_once("../user.inc.php");
|
||||
user_auth_required('committee', 'config');
|
||||
|
||||
//make sure storage folder exists
|
||||
if(!file_exists("../data/userfiles"))
|
||||
mkdir("../data/userfiles");
|
||||
|
||||
|
||||
send_header("Page Texts",
|
||||
array('Committee Main' => 'committee_main.php',
|
||||
'SFIAB Configuration' => 'config/index.php')
|
||||
@ -42,54 +48,81 @@
|
||||
|
||||
if($_POST['action']=="save")
|
||||
{
|
||||
mysql_query("UPDATE pagetext SET lastupdate=NOW(), text='".mysql_escape_string(stripslashes($_POST['text']))."' WHERE textname='".$_POST['textname']."' AND year='".$config['FAIRYEAR']."'");
|
||||
foreach($config['languages'] AS $lang=>$langname) {
|
||||
$textvar="text_$lang";
|
||||
$text=mysql_escape_string(stripslashes($_POST[$textvar]));
|
||||
|
||||
echo happy(i18n("Page text successfully saved"));
|
||||
mysql_query("UPDATE pagetext
|
||||
SET
|
||||
lastupdate=NOW(),
|
||||
text='$text'
|
||||
WHERE
|
||||
textname='".mysql_escape_string($_POST['textname'])."'
|
||||
AND year='".$config['FAIRYEAR']."'
|
||||
AND lang='$lang'");
|
||||
}
|
||||
echo happy(i18n("Page texts successfully saved"));
|
||||
|
||||
}
|
||||
|
||||
if($_GET['textname'])
|
||||
{
|
||||
$q=mysql_query("SELECT * FROM pagetext WHERE textname='".$_GET['textname']."' AND year='".$config['FAIRYEAR']."'");
|
||||
$q=mysql_query("SELECT * FROM pagetext WHERE textname='".mysql_escape_string($_GET['textname'])."' AND year='".$config['FAIRYEAR']."'");
|
||||
//needs to be at least one entry in any languages
|
||||
if($r=mysql_fetch_object($q))
|
||||
{
|
||||
if($r->lastupdate=="0000-00-00 00:00:00") $lastupdate="Never";
|
||||
else $lastupdate=$r->lastupdate;
|
||||
echo "<b>$r->textname</b> Last updated: $lastupdate<br />";
|
||||
echo "<form method=\"post\" action=\"pagetexts.php\">";
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
|
||||
echo "<input type=\"hidden\" name=\"textname\" value=\"$r->textname\">\n";
|
||||
|
||||
if(is_dir("../fckeditor") && file_exists("../fckeditor/fckeditor.php"))
|
||||
|
||||
foreach($config['languages'] AS $lang=>$langname) {
|
||||
$q=mysql_query("SELECT * FROM pagetext WHERE textname='".mysql_escape_string($_GET['textname'])."' AND year='".$config['FAIRYEAR']."' AND lang='$lang'");
|
||||
$r=mysql_fetch_object($q);
|
||||
|
||||
if(!$r)
|
||||
{
|
||||
mysql_query("INSERT INTO pagetext (textname,year,lang) VALUES ('".mysql_escape_string($_GET['textname'])."','".$config['FAIRYEAR']."','$lang')");
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
if($r->lastupdate=="0000-00-00 00:00:00" || !$r->lastupdate) $lastupdate="Never";
|
||||
else $lastupdate=$r->lastupdate;
|
||||
echo "<b>".htmlspecialchars($_GET['textname'])." - $langname</b> ".i18n("Last updated").": $lastupdate<br />";
|
||||
require_once("../fckeditor/fckeditor.php");
|
||||
|
||||
$oFCKeditor = new FCKeditor('text') ;
|
||||
$oFCKeditor = new FCKeditor("text_$lang") ;
|
||||
$oFCKeditor->BasePath = "../fckeditor/";
|
||||
$oFCKeditor->Value = $r->text;
|
||||
$oFCKeditor->Width="100%";
|
||||
$oFCKeditor->Height=500;
|
||||
$oFCKeditor->Height=300;
|
||||
$oFCKeditor->Create() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<textarea rows=8 cols=60 name=\"text\">".htmlspecialchars($r->text)."</textarea>";
|
||||
echo "<br />";
|
||||
}
|
||||
echo "<input type=\"submit\" value=\"".i18n("Save Page Text")."\" />\n";
|
||||
echo "</form>";
|
||||
|
||||
echo "<hr />";
|
||||
}
|
||||
|
||||
echo "<table><tr><td>";
|
||||
echo "<input type=\"submit\" value=\"".i18n("Save Page Texts")."\" />\n";
|
||||
echo "</form>";
|
||||
echo "</td><td>";
|
||||
echo "<form method=\"get\" action=\"pagetexts.php\">";
|
||||
echo "<input type=\"submit\" value=\"".i18n("Cancel Changes")."\" />\n";
|
||||
echo "</form>\n";
|
||||
echo "</td></tr></table>\n";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
echo error(i18n("Invalid text name"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<br />";
|
||||
echo i18n("Choose a page text to edit");
|
||||
echo "<table class=\"summarytable\">";
|
||||
|
||||
$q=mysql_query("SELECT * FROM pagetext WHERE year='".$config['FAIRYEAR']."' ORDER BY textname");
|
||||
$q=mysql_query("SELECT * FROM pagetext WHERE year='".$config['FAIRYEAR']."' AND lang='".$config['default_language']."' ORDER BY textname");
|
||||
echo "<tr><th>".i18n("Page Text Name")."</th><th>".i18n("Last Update")."</th></tr>";
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
@ -102,6 +135,7 @@
|
||||
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
send_footer();
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user