mirror of
https://git.code.sf.net/p/quake/website
synced 2024-11-30 16:01:24 +00:00
OK, here's the plan system. It's not linked into the menu yet, but everything
seems to work now.
This commit is contained in:
parent
ec93093821
commit
29d34a6894
6 changed files with 206 additions and 21 deletions
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
have ("feature");
|
||||
|
||||
function featureOpen ($title, $url, $id)
|
||||
function featureOpen ($title, $url=null, $id=null)
|
||||
{
|
||||
if ($url) {
|
||||
$part1 = '<A href="' . $url . '">';
|
||||
|
@ -35,7 +35,7 @@
|
|||
if ($id)
|
||||
$id = " id=\"$id\"";
|
||||
|
||||
echo '<DIV' . $id . ' class="featureBox">';
|
||||
echo "<DIV$id class=\"featureBox\">";
|
||||
echo '<H2 class="featureTitle">' . $part1 . $title . $part2 . '</H2>';
|
||||
echo '<DIV class="featureContent">';
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ function printNewsArray ($a)
|
|||
}
|
||||
|
||||
|
||||
function latestNews ($max)
|
||||
function latestNews ($max=5)
|
||||
{
|
||||
need ('sql');
|
||||
|
||||
|
@ -77,7 +77,7 @@ function latestNews ($max)
|
|||
}
|
||||
|
||||
|
||||
function printLatestNews ($max)
|
||||
function printLatestNews ($max=5)
|
||||
{
|
||||
$filler = date ('d M Y');
|
||||
$entries = latestNews ($max);
|
||||
|
|
144
lib/plan.inc
Normal file
144
lib/plan.inc
Normal file
|
@ -0,0 +1,144 @@
|
|||
<?
|
||||
/*
|
||||
plan.php
|
||||
|
||||
SQL-backed blog-like thing akin to a .plan, with archives
|
||||
|
||||
Copyright (C) 2000-2007 Jeff Teunissen <deek@quakeforge.net>
|
||||
Copyright (C) 2000 Daniel David Olson <theoddone33@users.sourceforge.net>
|
||||
|
||||
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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
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; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
have ('plan');
|
||||
// SQL definition for news table
|
||||
$createQuery="CREATE TABLE plans ("
|
||||
." p_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,"
|
||||
." p_date TIMESTAMP NOT NULL DEFAULT NOW(),"
|
||||
." p_user TINYTEXT NOT NULL,"
|
||||
." p_title TINYTEXT NOT NULL,"
|
||||
." p_plan TEXT NOT NULL"
|
||||
.")";
|
||||
|
||||
function formatPlan ($date, $user, $subj, $text)
|
||||
{
|
||||
return "<DL>\n"
|
||||
.' <DT>'
|
||||
. "<EM>Posted on </EM>$date<EM> by </EM><STRONG>$user</STRONG>"
|
||||
. "</DT>\n"
|
||||
." <DD><H4>$subj</H4>\n"
|
||||
." $text</DD>\n"
|
||||
."</DL>\n";
|
||||
}
|
||||
|
||||
|
||||
function formatPlanArray ($a)
|
||||
{
|
||||
need ('date');
|
||||
|
||||
return formatPlan (dateFromSQLDateTime ($a['p_date']), $a['p_user'], stripSlashes ($a['p_title']), stripSlashes ($a['p_plan']));
|
||||
}
|
||||
|
||||
|
||||
function printPlan ($date, $user, $subj, $text)
|
||||
{
|
||||
echo formatPlan ($date, $user, $subj, $text);
|
||||
}
|
||||
|
||||
|
||||
function printPlanArray ($a)
|
||||
{
|
||||
echo formatPlanArray ($a);
|
||||
}
|
||||
|
||||
|
||||
function latestPlans ($user = null, $max = 5)
|
||||
{
|
||||
need ('sql');
|
||||
|
||||
if ($user) {
|
||||
$query = 'SELECT p_date, p_user, p_title, p_plan FROM plans'
|
||||
." WHERE p_user = "
|
||||
." (SELECT u_displayname FROM members WHERE u_username='$user')"
|
||||
." ORDER BY p_date DESC LIMIT $max";
|
||||
} else {
|
||||
$query = 'SELECT p_date, p_user, p_title, p_plan FROM plans, members'
|
||||
." WHERE p_user = u_displayname"
|
||||
." ORDER BY p_date DESC LIMIT $max";
|
||||
}
|
||||
|
||||
return sqlReadQuery ($query);
|
||||
}
|
||||
|
||||
|
||||
function printLatestPlans ($user = null, $max = 5)
|
||||
{
|
||||
$filler = date ('d M Y');
|
||||
$entries = latestPlans ($user, $max);
|
||||
|
||||
if ($entries === true) { // success, but no data
|
||||
printPlan ($filler, 'Web Server', 'Sorry', 'Nobody has posted news yet, so I got nothing to say right now.');
|
||||
} elseif ($entries === false) { // bad query
|
||||
printPlan ($filler, 'Web Server', 'Sorry', 'Got an error while finding news. Bug a project administrator, eh?');
|
||||
} elseif ($entries === null) { // boom
|
||||
printPlan ($filler, 'Web Server', 'Sorry', 'Couldn\'t connect to the project news server...Sorry.');
|
||||
} else foreach ($entries as $entry) {
|
||||
printPlanArray ($entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchPlans ($string, $user = null)
|
||||
{
|
||||
need ('sql');
|
||||
|
||||
if ($user)
|
||||
$where = " AND p_user='$user' ";
|
||||
|
||||
$filler = date ('d M Y');
|
||||
$search = addSlashes ("%$string%");
|
||||
$query = 'SELECT p_date, p_user, p_title, p_plan FROM plans'
|
||||
." WHERE p_plan LIKE '$search'"
|
||||
. $where
|
||||
.' ORDER BY n_date DESC';
|
||||
|
||||
$entries = sqlReadQuery ($query);
|
||||
if ($entries === true) { // success, but no data
|
||||
printPlan ($filler, 'Web Server', 'Sorry', "No plan entries found matching '$string'");
|
||||
} elseif ($entries === false) { // bad query
|
||||
printPlan ($filler, 'Web Server', 'Sorry', 'Got an error while finding news. Bug a project administrator, eh?');
|
||||
} elseif ($entries === null) { // boom
|
||||
printPlan ($filler, 'Web Server', 'Sorry', 'Couldn\'t connect to the project plan server.');
|
||||
} else foreach ($entries as $entry) {
|
||||
printPlanArray ($entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function usersWithPlans ()
|
||||
{
|
||||
need ('sql');
|
||||
|
||||
$query = 'SELECT u_username, u_displayname FROM members,plans'
|
||||
.' WHERE u_displayname=p_user'
|
||||
.' ORDER BY u_displayname';
|
||||
|
||||
return sqlReadQuery ($query);
|
||||
}
|
||||
?>
|
21
parts/plan_search.inc
Normal file
21
parts/plan_search.inc
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?
|
||||
function planUsers ()
|
||||
{
|
||||
need ('boxes feature plan');
|
||||
|
||||
featureOpen ('Users with Plans');
|
||||
if (is_array ($users = usersWithPlans ())) {
|
||||
foreach ($users as $user) {
|
||||
$displayName = $user['u_displayname'];
|
||||
$userName = $user['u_username'];
|
||||
echo '<P><A class="planUser" href="' . thisURL . "/$userName/"
|
||||
.'">' . $displayName . '</A></P>';
|
||||
}
|
||||
} else {
|
||||
echo '<P>Sorry, no users have posted Plan entries at this time.</P>';
|
||||
}
|
||||
featureClose ();
|
||||
}
|
||||
|
||||
planUsers ();
|
||||
?>
|
37
plan.php
Normal file
37
plan.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<? // Preamble
|
||||
$pageName = "Developer Plans";
|
||||
$currPage = "plans"; // Name of the page, for the menu
|
||||
$modules = "plan_search";
|
||||
require "parts/preamble.php"; // Load most of document
|
||||
|
||||
$user = $_SERVER['PATH_INFO'];
|
||||
|
||||
need ('plan');
|
||||
|
||||
if (strlen ($user) > 1) {
|
||||
$user = substr ($user, 1); // strip off the starting slash
|
||||
if (($pos = strpos ($user, '/')) !== false) { // and all others
|
||||
$user = substr ($user, 0, $pos);
|
||||
}
|
||||
|
||||
if (is_array ($plans = latestPlans ($user, 5))) {
|
||||
newsBoxOpen ("Latest Plans for " . $plans[0]['p_user']);
|
||||
foreach ($plans as $plan) {
|
||||
printPlanArray ($plan);
|
||||
}
|
||||
newsBoxClose ();
|
||||
} else {
|
||||
newsBoxOpen ("Latest Plans for " . $user);
|
||||
printPlan ("Now", "Web Server", "Sorry", "<P>I don't know any user named "$user".</P>");
|
||||
newsBoxClose ();
|
||||
}
|
||||
} else {
|
||||
if (is_array ($plans = latestPlans (null, 5))) {
|
||||
newsBoxOpen ("Latest Plans for All Users");
|
||||
foreach ($plans as $plan) {
|
||||
printPlanArray ($plan);
|
||||
}
|
||||
newsBoxClose ();
|
||||
}
|
||||
}
|
||||
?>
|
17
plans.php
17
plans.php
|
@ -1,17 +0,0 @@
|
|||
<? // Preamble
|
||||
$pageName = "Developer Plans";
|
||||
$focused = "none"; // Dock icon name to gets a border
|
||||
$currPage = "plans"; // Name of the page, for the menu
|
||||
require "parts/preamble.php"; // Load most of document
|
||||
?>
|
||||
<TABLE width="100%" cellSpacing="0" cellPadding="0" border="0">
|
||||
<TR vAlign="top">
|
||||
<TD colSpan="2"><? // News display
|
||||
tableBoxHeader ('black', tableHeadColor);
|
||||
tableTitle ('Developer Plans', 1, tableHeadColor);
|
||||
need ("news");
|
||||
include "plancache.php";
|
||||
tableBoxFooter ();
|
||||
?></TD>
|
||||
</TR>
|
||||
</TABLE>
|
Loading…
Reference in a new issue