Add page text functionality, to define arbritary page text to be displayed on pages without having to edit the actual files.

Also shrunk the padding on summarytable, 4px seemed just way too big of a waste of space :)
This commit is contained in:
james 2005-11-21 20:33:18 +00:00
parent 343c70f633
commit b639308993
6 changed files with 109 additions and 16 deletions

View File

@ -744,8 +744,16 @@ function email_send($val,$to,$sub_subject=array(),$sub_body=array())
function output_page_text($textname)
{
$q=mysql_query("SELECT * FROM pagetext WHERE textname='$textname'");
$r=mysql_fetch_object($q);
global $config;
$q=mysql_query("SELECT * FROM pagetext WHERE textname='$textname' AND year='".$config['FAIRYEAR']."'");
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'");
$r=mysql_fetch_object($q);
}
echo nl2br(i18n($r->text));
}
?>

View File

@ -32,6 +32,8 @@
echo "<a href=\"categories.php\">Project Age Categories</a> <br />";
echo "<a href=\"divisions.php\">Project Divisons</a> <br />";
echo "<a href=\"subdivisions.php\">Project Sub-Divisons</a> <br />";
echo "<a href=\"pagetexts.php\">Page Texts</a> <br />";
echo "<a href=\"images.php\">Images (Fair Logo)</a> <br />";
echo "<hr />";
echo "<a href=\"rollover.php\">Rollover Fair Year</a> <br />";

89
config/pagetexts.php Normal file
View File

@ -0,0 +1,89 @@
<?
/*
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>
Copyright (C) 2005 James Grant <james@lightbox.org>
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");
auth_required('config');
send_header("Configuration - Page Texts");
echo "<a href=\"index.php\">&lt;&lt; ".i18n("Back to Configuration")."</a><br />";
$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")
{
mysql_query("UPDATE pagetext SET lastupdate=NOW(), text='".mysql_escape_string(stripslashes($_POST['text']))."' WHERE textname='".$_POST['textname']."' AND year='".$config['FAIRYEAR']."'");
echo happy(i18n("Page text successfully saved"));
}
if($_GET['textname'])
{
$q=mysql_query("SELECT * FROM pagetext WHERE textname='".$_GET['textname']."' AND year='".$config['FAIRYEAR']."'");
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> &nbsp;&nbsp; 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";
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 />";
}
else
{
echo error(i18n("Invalid text name"));
}
}
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");
echo "<tr><th>Page Text Name</th><th>Last Update</th></tr>";
while($r=mysql_fetch_object($q))
{
echo "<tr><td><a href=\"pagetexts.php?textname=$r->textname\">$r->textname</a></td>";
if($r->lastupdate=="0000-00-00 00:00:00") $lastupdate="Never";
else $lastupdate=$r->lastupdate;
echo "<td>$lastupdate</td>";
echo "</tr>";
}
echo "</table>";
send_footer();
?>

View File

@ -10,3 +10,9 @@ INSERT INTO `award_types` VALUES (2, 'Special', 2, 2006);
INSERT INTO `award_types` VALUES (3, 'Interdisciplinary', 3, 2006);
INSERT INTO `award_types` VALUES (4, 'Grand', 5, 2006);
INSERT INTO `award_types` VALUES (5, 'Other', 4, 2006);
ALTER TABLE `pagetext` DROP INDEX `textname`;
ALTER TABLE `pagetext` ADD UNIQUE(textname,year);
ALTER TABLE `pagetext` CHANGE `year` `year` INT NOT NULL DEFAULT '0';
INSERT INTO `pagetext` VALUES (1, 'register_participants_main_instructions', 'Once all sections are complete, please print the signature page, obtain the required signatures, and mail the signature form, along with any required registration fees to:\r\nInsert address here\r\n\r\nYour forms must be received, post marked by <b>insert date here</b>. Late entries will not be accepted', -1);
INSERT INTO `pagetext` VALUES (2, 'index', 'Welcome to the online registration and management system for the fair. Using the links on the left the public can register as a participant or register as a judge. \r\n\r\nThe committee can use the Fair Administration link to manage the fair, see who''s registered, renerate reports, etc. \r\n\r\nThe SFIAB configuration link is for the committee webmaster to manage the configuration of the Science Fair In A Box for the fair.\r\n', -1);
ALTER TABLE `pagetext` ADD `lastupdate` DATETIME NOT NULL ;

View File

@ -24,18 +24,6 @@
<?
include "common.inc.php";
send_header($config['fairname']);
echo i18n("Welcome to the online registration and management system for the fair. Using the links on the left the public can register as a participant or register as a judge.
<br />
<br />
The committee can use the Fair Administration link to manage the fair, see who's registered, renerate reports, etc.
<br />
<br />
The SFIAB configuration link is for the committee webmaster to manage the configuration of the Science Fair In A Box for the fair.
");
output_page_text("index");
send_footer();
?>

View File

@ -165,7 +165,7 @@ a {
.summarytable td {
border: 2px solid black;
margin: 0px;
padding: 4px;
padding: 2px;
}