From b6393089937f46223f2294849358c9801f8bbe26 Mon Sep 17 00:00:00 2001 From: james Date: Mon, 21 Nov 2005 20:33:18 +0000 Subject: [PATCH] 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 :) --- common.inc.php | 12 +++++- config/index.php | 2 + config/pagetexts.php | 89 ++++++++++++++++++++++++++++++++++++++++++++ db/db.update.8.php | 6 +++ index.php | 14 +------ sfiab.css | 2 +- 6 files changed, 109 insertions(+), 16 deletions(-) create mode 100644 config/pagetexts.php diff --git a/common.inc.php b/common.inc.php index e089527..3042f96 100644 --- a/common.inc.php +++ b/common.inc.php @@ -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)); } ?> diff --git a/config/index.php b/config/index.php index 1d3447f..caaef9c 100644 --- a/config/index.php +++ b/config/index.php @@ -32,6 +32,8 @@ echo "Project Age Categories
"; echo "Project Divisons
"; echo "Project Sub-Divisons
"; + + echo "Page Texts
"; echo "Images (Fair Logo)
"; echo "
"; echo "Rollover Fair Year
"; diff --git a/config/pagetexts.php b/config/pagetexts.php new file mode 100644 index 0000000..32a8614 --- /dev/null +++ b/config/pagetexts.php @@ -0,0 +1,89 @@ + + Copyright (C) 2005 James Grant + + 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. +*/ +?> +<< ".i18n("Back to Configuration")."
"; + + $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 "$r->textname    Last updated: $lastupdate
"; + echo "
"; + echo "\n"; + echo "textname\">\n"; + echo ""; + echo "
"; + echo "\n"; + echo "
"; + echo "
"; + } + else + { + echo error(i18n("Invalid text name")); + } + } + echo "
"; + echo i18n("Choose a page text to edit"); + echo ""; + + $q=mysql_query("SELECT * FROM pagetext WHERE year='".$config['FAIRYEAR']."' ORDER BY textname"); + echo ""; + while($r=mysql_fetch_object($q)) + { + echo ""; + if($r->lastupdate=="0000-00-00 00:00:00") $lastupdate="Never"; + else $lastupdate=$r->lastupdate; + echo ""; + echo ""; + + + } + echo "
Page Text NameLast Update
textname\">$r->textname$lastupdate
"; + + send_footer(); +?> diff --git a/db/db.update.8.php b/db/db.update.8.php index 135c697..b5b1527 100644 --- a/db/db.update.8.php +++ b/db/db.update.8.php @@ -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 insert date here. 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 ; diff --git a/index.php b/index.php index 6c6ed99..c1d873e 100644 --- a/index.php +++ b/index.php @@ -24,18 +24,6 @@ -
-The committee can use the Fair Administration link to manage the fair, see who's registered, renerate reports, etc. -
-
- -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(); ?> diff --git a/sfiab.css b/sfiab.css index c26fcea..e3a8685 100644 --- a/sfiab.css +++ b/sfiab.css @@ -165,7 +165,7 @@ a { .summarytable td { border: 2px solid black; margin: 0px; - padding: 4px; + padding: 2px; }