2005-11-21 20:33:18 +00:00
< ?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website : http :// www . sfiab . ca
Copyright ( C ) 2005 Sci - Tech Ontario Inc < info @ scitechontario . org >
2008-08-20 20:25:42 +00:00
Copyright ( C ) 2008 James Grant < james @ lightbox . org >
2005-11-21 20:33:18 +00:00
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation , version 2.
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; see the file COPYING . If not , write to
the Free Software Foundation , Inc . , 59 Temple Place - Suite 330 ,
Boston , MA 02111 - 1307 , USA .
*/
?>
< ?
require ( " ../common.inc.php " );
2007-11-21 17:04:35 +00:00
require_once ( " ../user.inc.php " );
2007-11-19 00:33:38 +00:00
user_auth_required ( 'committee' , 'config' );
2008-08-18 21:08:23 +00:00
//make sure storage folder exists
if ( ! file_exists ( " ../data/userfiles " ))
mkdir ( " ../data/userfiles " );
2007-11-19 00:33:38 +00:00
send_header ( " Page Texts " ,
array ( 'Committee Main' => 'committee_main.php' ,
'SFIAB Configuration' => 'config/index.php' )
2008-08-22 20:34:38 +00:00
, " page_texts "
2007-11-19 00:33:38 +00:00
);
2005-11-21 20:33:18 +00:00
$q = mysql_query ( " SELECT * FROM pagetext WHERE year='-1' ORDER BY textname " );
while ( $r = mysql_fetch_object ( $q ))
{
mysql_query ( " INSERT INTO pagetext (textname,text,year) VALUES (
'".mysql_escape_string($r->textname)."' ,
'".mysql_escape_string($r->text)."' ,
'".$config[' FAIRYEAR ']."' ) " );
}
if ( $_POST [ 'action' ] == " save " )
{
2008-08-18 21:08:23 +00:00
foreach ( $config [ 'languages' ] AS $lang => $langname ) {
$textvar = " text_ $lang " ;
$text = mysql_escape_string ( stripslashes ( $_POST [ $textvar ]));
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 " ));
2005-11-21 20:33:18 +00:00
}
if ( $_GET [ 'textname' ])
{
2008-08-18 21:08:23 +00:00
$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
2005-11-21 20:33:18 +00:00
if ( $r = mysql_fetch_object ( $q ))
{
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 " ;
2007-10-23 21:24:01 +00:00
2008-08-18 21:08:23 +00:00
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 /> " ;
2007-10-23 21:24:01 +00:00
require_once ( " ../fckeditor/fckeditor.php " );
2008-08-18 21:08:23 +00:00
$oFCKeditor = new FCKeditor ( " text_ $lang " ) ;
2007-10-23 21:24:01 +00:00
$oFCKeditor -> BasePath = " ../fckeditor/ " ;
$oFCKeditor -> Value = $r -> text ;
$oFCKeditor -> Width = " 100% " ;
2008-08-18 21:08:23 +00:00
$oFCKeditor -> Height = 300 ;
2007-10-23 21:24:01 +00:00
$oFCKeditor -> Create () ;
2008-08-18 21:08:23 +00:00
echo " <hr /> " ;
2007-10-23 21:24:01 +00:00
}
2008-08-18 21:08:23 +00:00
echo " <table><tr><td> " ;
echo " <input type= \" submit \" value= \" " . i18n ( " Save Page Texts " ) . " \" /> \n " ;
2005-11-21 20:33:18 +00:00
echo " </form> " ;
2008-08-18 21:08:23 +00:00
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 " ;
2005-11-21 20:33:18 +00:00
}
else
{
echo error ( i18n ( " Invalid text name " ));
}
}
2008-08-18 21:08:23 +00:00
else
2005-11-21 20:33:18 +00:00
{
2008-08-18 21:08:23 +00:00
echo " <br /> " ;
echo i18n ( " Choose a page text to edit " );
echo " <table class= \" summarytable \" > " ;
$q = mysql_query ( " SELECT * FROM pagetext WHERE year=' " . $config [ 'FAIRYEAR' ] . " ' AND lang=' " . $config [ 'default_language' ] . " ' ORDER BY textname " );
2008-08-26 21:06:05 +00:00
echo " <tr><th> " . i18n ( " Page Text Description " ) . " </th><th> " . i18n ( " Last Update " ) . " </th></tr> " ;
2008-08-18 21:08:23 +00:00
while ( $r = mysql_fetch_object ( $q ))
{
2008-08-26 21:06:05 +00:00
echo " <tr><td><a href= \" pagetexts.php?textname= $r->textname\ " > $r -> textdescription </ a ></ td > " ;
2008-08-18 21:08:23 +00:00
if ( $r -> lastupdate == " 0000-00-00 00:00:00 " ) $lastupdate = " Never " ;
else $lastupdate = $r -> lastupdate ;
echo " <td> $lastupdate </td> " ;
echo " </tr> " ;
2005-11-21 20:33:18 +00:00
2008-08-18 21:08:23 +00:00
}
echo " </table> " ;
2005-11-21 20:33:18 +00:00
}
send_footer ();
?>