summaryrefslogtreecommitdiff
path: root/template.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2000-09-11 07:45:22 +0000
committerDries Buytaert <dries@buytaert.net>2000-09-11 07:45:22 +0000
commit1f0a87f4e704fff7f6c94191afbe7dc0fa9f031e (patch)
tree968ffbc61a794f7ec18b649273a86d42e4081050 /template.inc
parent17d8330e44fdd03429605d3131bd36c10fddf991 (diff)
downloadbrdo-1f0a87f4e704fff7f6c94191afbe7dc0fa9f031e.tar.gz
brdo-1f0a87f4e704fff7f6c94191afbe7dc0fa9f031e.tar.bz2
Over the last 2 days I redid and reorganized an afwul lot of code and
made quite a lot of additions. The most remarkable addition is the diary server, which I slapped together in less then 40 minutes. Most of the other changes are however `unvisible' for the user but add much value to a better maintainability from a developer's objective. Like always, I fixed quite a number of small bugs that creeped into the code so we should have a bigger, better and more stable drop.org. Unfortunatly, some theme update _are_ required: REQUIRED THEME UPDATES: ======================= * use format_username() where usernames are used * use format_date() where timestamps/dates are used * use format_email() where e-mail addresses are displayed * use format_url() where url are displayed * replace 'formatTimestamp' with format_date * replace 'morelink_*' with 'display_morelink' [most of these functions are in function.inc or template.inc] ___PLEASE___ (<- this should get your attention ;) update your themes as soon as possible - it only takes 30 min. to get in sync with the other themes. Don't start whining about the fact you don't know what to change ... either eat the source cookie, or ask me to elaborate on a few changes. Just let me know what's puzzling you and I'll try to help you out! TODO LIST FOR NEXT WEEK ======================= * Add checks for max. text length in textarea's? Is there an HMTL attribute for this or ...? * Comment moderation + mojo * Edit/admin user accounts: block, delete, change permissions, ... * E-mail password, change password, change e-mail address -> extra checks and routines to validate such `special' changes. * Input checking - input filter: bad words, html tags, ...
Diffstat (limited to 'template.inc')
-rw-r--r--template.inc148
1 files changed, 148 insertions, 0 deletions
diff --git a/template.inc b/template.inc
new file mode 100644
index 000000000..d4148b84c
--- /dev/null
+++ b/template.inc
@@ -0,0 +1,148 @@
+<?
+include "user.class.php";
+
+function display_morelink($theme, $story) {
+ return ($story->article) ? "[ ". format_story_link($story, "<FONT COLOR=\"$theme->hlcolor2\"><B>read more</B></FONT>") ." | ". strlen($story->article) ." bytes | ". format_story_link($story, "<FONT COLOR=\"$theme->hlcolor2\">". format_plural($story->comments, "comment", "comments") ."</FONT>") ." ]" : "[ ". format_story_link($story, "<FONT COLOR=\"$theme->hlcolor2\">". format_plural($story->comments, "comment", "comments") ."</FONT>") ." ]";
+}
+
+function displayModerationResults($theme, $story) {
+ global $user;
+
+ if ($user->id && $story->id && $vote = user_getHistory($user->history, "s$story->id")) {
+ $output .= "<P><B>You voted `$vote'.</B></P>\n";
+ $output .= "<P>\n";
+ $output .= "<B>Other people voted:</B><BR>\n";
+
+ $result = db_query("SELECT * FROM users WHERE history LIKE '%s$story->id%'");
+ while ($account = db_fetch_object($result)) {
+ $output .= "". format_username($account->userid) ." voted `". user_getHistory($account->history, "s$story->id") ."'.<BR>";
+ }
+
+ $theme->box("Moderation results", $output);
+ }
+}
+
+function displayRelatedLinks($theme, $story) {
+ ### Parse story for <A HREF="">-tags:
+ $text = stripslashes("$story->abstract $story->updates $story->article");
+ while ($text = stristr($text, "<A HREF=")) {
+ $link = substr($text, 0, strpos(strtolower($text), "</a>") + 4);
+ $text = stristr($text, "</A>");
+ if (!stristr($link, "mailto:")) $content .= "<LI>$link</LI>";
+ }
+
+ ### Stories in the same category:
+ $content .= " <LI>More about <A HREF=\"search.php?category=". urlencode($story->category) ."\">$story->category</A>.</LI>";
+
+ ### Stories from the same author:
+ if ($story->userid) $content .= " <LI>Also by <A HREF=\"search.php?author=". urlencode($story->userid) ."\">$story->userid</A>.</LI>";
+
+ $theme->box("Related links", $content);
+}
+
+function displayOldHeadlines($theme, $num = 10) {
+ global $user;
+
+ if ($user->storynum) $result = db_query("SELECT id, subject, timestamp FROM stories WHERE status = 2 ORDER BY timestamp DESC LIMIT $user->storynum, $num");
+ else $result = db_query("SELECT id, subject, timestamp FROM stories WHERE status = 2 ORDER BY timestamp DESC LIMIT $num, $num");
+
+ while ($story = db_fetch_object($result)) {
+ if ($time != date("F jS", $story->timestamp)) {
+ $content .= "<P><B>". date("l, F jS", $story->timestamp) ."</B></P>\n";
+ $time = date("F jS", $story->timestamp);
+ }
+ $content .= "<LI>". format_story_link($story) ."</LI>\n";
+ }
+ $content .= "<P ALIGN=\"right\">[ <A HREF=\"search.php\"><FONT COLOR=\"$theme->hlcolor2\">more</FONT></A> ]</P>";
+
+ $theme->box("Older headlines", $content);
+}
+
+function displayNewDiaries($theme, $num = 20) {
+ $result = db_query("SELECT u.userid FROM diaries d LEFT JOIN users u ON d.author = u.id GROUP BY u.userid ORDER BY timestamp DESC LIMIT $num");
+ while ($diary = db_fetch_object($result)) {
+ $content .= "<LI><A HREF=\"diary.php?op=view&name=$diary->userid\">$diary->userid</A></LI>\n";
+ }
+ $theme->box("Recent diary entries", $content);
+}
+
+function displayNewHeadlines($theme, $num = 10) {
+ global $user;
+
+ $content = "";
+ $result = db_query("SELECT id, subject FROM stories WHERE status = 2 ORDER BY id DESC LIMIT $num");
+ while ($story = db_fetch_object($result)) $content .= "<LI>". format_story_link($story) ."</LI>\n";
+ $content .= "<P ALIGN=\"right\">[ <A HREF=\"search.php\"><FONT COLOR=\"$theme->hlcolor2\">more</FONT></A> ]</P>";
+ $theme->box("Latest headlines", $content);
+}
+
+function displayAdminblock($theme) {
+ $result = db_query("SELECT title, content FROM blocks");
+ while (list($title, $content) = mysql_fetch_array($result)) {
+ $theme->box($title, nl2br($content));
+ }
+}
+
+function displayUserblock($theme) {
+ global $user;
+
+ if ($user && $user->ublockon) {
+ $content .= "<P ALIGN=\"right\">[ <A HREF=\"account.php?op=edithome\"><FONT COLOR=\"$theme->hlcolor2\">edit</FONT></A> | <A HREF=\"account.php?op=discussion\"><FONT COLOR=\"$theme->hlcolor2\">Track comments</FONT></A> | <A HREF=\"account.php?op=logout\"><FONT COLOR=\"$theme->hlcolor2\">logout</FONT></A>]</P>";
+ $theme->box("$user->userid's box", $user->content);
+ }
+}
+
+function displayLogin($theme) {
+ global $user;
+
+ if ($user && $user->userid) {
+ ### Display userblock if any:
+ displayUserblock();
+ }
+ else {
+ $content = "<CENTER><FORM METHOD=\"post\" ACTION=\"account.php\">\n";
+ $content .= "<P>Username:<BR><INPUT NAME=userid MAXLENGTH=50 SIZE=12></P>\n";
+ $content .= "<P>Password:<BR> <INPUT TYPE=password NAME=passwd MAXLENGTH=25 SIZE=12></P>\n";
+ $content .= "<INPUT TYPE=submit NAME=op VALUE=\"Login\">\n";
+ $content .= "</FORM>\n";
+ $content .= "<P><A HREF=\"account.php?op=new\">Register</A> as new user.<BR><A HREF=\"account.php?op=forgot\">Forgot</A> your password?</P></CENTER>";
+ $theme->box("Login", $content);
+ }
+}
+
+function displayCalendar($theme, $date) {
+ include "calendar.class.php";
+ $calendar = new calendar($date);
+ $theme->box("Browse archives", $calendar->display());
+}
+
+function displayAccount($theme) {
+ global $user;
+
+ if ($user && $user->userid) {
+
+ function submission_number() {
+ $result = db_query("SELECT COUNT(id) FROM stories WHERE status = 1");
+ return ($result) ? mysql_result($result, 0) : 0;
+ }
+
+ ### Display account settings:
+ $content = "<LI><A HREF=\"account.php\">view your information</A></LI>";
+ $content .= "<LI><A HREF=\"account.php?op=user\">edit your information</A></LI>";
+ $content .= "<LI><A HREF=\"account.php?op=page\">customize your page</A></LI>";
+ $content .= "<LI><A HREF=\"account.php?op=discussion\">track your comments</A></LI>";
+ $content .= "<LI><A HREF=\"submission.php\">moderate submissions</A> (<FONT COLOR=\"red\">". submission_number() ."</FONT>)</LI>";
+ $content .= "<LI><A HREF=\"diary.php\">update your diary</A></LI>";
+ $content .= "<LI><A HREF=\"account.php?op=logout\">logout</A></LI>";
+
+ $theme->box("$user->userid's account", "$content");
+ }
+}
+
+function displayPoll($theme) {
+ global $answer, $answer1, $answer2, $answer3, $answer4, $answer5, $answer6, $id, $method, $section, $poll, $question;
+ // Pass the URI and FORM parameters along to poll.php.
+ $box = 1;
+ include "poll.php";
+}
+?>