summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2000-06-21 15:41:20 +0000
committerDries Buytaert <dries@buytaert.net>2000-06-21 15:41:20 +0000
commit0f5a60e1095857ae4e9a2c5ea1f3db68a9a57ef5 (patch)
tree6852ef1654c661715dcfcc2554b86851984e7923 /index.php
parent8a7690af5723ec22fccd450097cc8fb0e8216649 (diff)
downloadbrdo-0f5a60e1095857ae4e9a2c5ea1f3db68a9a57ef5.tar.gz
brdo-0f5a60e1095857ae4e9a2c5ea1f3db68a9a57ef5.tar.bz2
IMPORANT - IMPORTANT - :)
========================= Wulp. I did a major upgrade by (a) breaking a lot of stuff and (b) by re-doing those things in a much better way. I redesigned the stories and submissions SQL tables, the way they work and the way they co- operate together. In addition, I changed the way parameters are passed to $theme->abstract() and $theme->article(). Instead of passing a sh!tload of parameters that only cluttered the code and required too much pre-processing on the engine-side, we now pass a singly object $story. $story has more variables then the paramaters we used to pass, so it allows for better theming (if you feel like it). I'm not finished yet but I decided to upload my changes so you can start patching and updating your themes: PLEASE update your themes ASAP! I don't plan making heavy changes like this again, so don't get intimiated. ;) You mainly have to update article() and abstract() as well as a minor update of footer(): article(), abstract(): ---------------------- - use the $story object - see my theme! - the morelink can now be themed. Currently you can use the function morelink_bytes() in function.inc to `render' the old morelink. The idea is to make a morelink_words() or morelink_lines() sooner or later because "188 bytes in body" is not half as clear as "52 words in body". Clearly, "52 words" is much more informative. ;-) footer(): --------- - in the article-part, you need to update the displayRelatedLinks(): instead of passing it $sid, you need to pass it $story (after you globaled $story). Everything should display correct on the following pages: - main page - article page (follow a `read more | xxx bytes in bdoy | x comments' link) - submission queue Check if they work with your theme: they should as they work fine for me (theme `Dries') ... If you got stuck, just look at my theme or ask for a hand on the list! Hopefully you can update your themes asap. Thanks in advance.
Diffstat (limited to 'index.php')
-rw-r--r--index.php45
1 files changed, 13 insertions, 32 deletions
diff --git a/index.php b/index.php
index ccabdf7d1..3a019e6a9 100644
--- a/index.php
+++ b/index.php
@@ -3,44 +3,25 @@
include "functions.inc";
include "theme.inc";
-$theme->header();
-
-### Initialize variables:
+### Initialize/pre-process variables:
$number = ($user->storynum) ? $user->storynum : 10;
$date = ($date) ? $date : time();
### Perform query:
-$result = db_query("SELECT stories.*, COUNT(comments.sid) AS comments FROM stories LEFT JOIN comments ON stories.sid = comments.sid WHERE stories.status = 1 AND stories.time <= $date GROUP BY stories.sid ORDER BY stories.sid DESC LIMIT $number");
- // Note: we use a LEFT JOIN to retrieve the number of comments associated
- // with each story. By retrieving this data now, we elimate a *lot*
- // of individual queries that would otherwise be required inside the
- // while-loop. If there is no matching record for the right table in
- // the ON-part of the LEFT JOIN, a row with all columns set to NULL
- // is used for the right table. This is required, as not every story
- // has a counterpart in the comments table (at a given time).
+$result = db_query("SELECT stories.*, users.userid, COUNT(comments.sid) AS comments FROM stories LEFT JOIN comments ON stories.id = comments.sid LEFT JOIN users ON stories.author = users.id WHERE stories.status = 2 AND stories.timestamp <= $date GROUP BY stories.id ORDER BY stories.id DESC LIMIT $number");
+ // Note on performance:
+ // we use a LEFT JOIN to retrieve the number of comments associated
+ // with each story. By retrieving this data now (outside the while-
+ // loop), we elimate a *lot* of individual queries that would other-
+ // wise be required (inside the while-loop). If there is no matching
+ // record for the right table in the ON-part of the LEFT JOIN, a row
+ // with all columns set to NULL is used for the right table. This is
+ // required, as not every story has a counterpart in the comments
+ // table (at a given time).
### Display stories:
-while ($story = db_fetch_object($result)) {
-
- ### Compose more-link:
- $morelink = "[ ";
- if ($story->article) {
- $morelink .= "<A HREF=\"article.php?sid=$story->sid";
- if (isset($user->umode)) { $morelink .= "&mode=$user->umode"; } else { $morelink .= "&mode=threaded"; }
- if (isset($user->uorder)) { $morelink .= "&order=$user->uorder"; } else { $morelink .= "&order=0"; }
- $bytes = strlen($story->article);
- $morelink .= "\"><FONT COLOR=\"$theme->hlcolor2\"><B>read more</B></FONT></A> | $bytes bytes in body | ";
- }
- $morelink .= "<A HREF=\"article.php?sid=$story->sid";
- if (isset($user->umode)) { $morelink .= "&mode=$user->umode"; } else { $morelink .= "&mode=threaded"; }
- if (isset($user->uorder)) { $morelink .= "&order=$user->uorder"; } else { $morelink .= "&order=0"; }
- if (isset($user->thold)) { $morelink .= "&thold=$user->thold"; } else { $morelink .= "&thold=0"; }
- $morelink .= "\"><FONT COLOR=\"$theme->hlcolor2\">$story->comments comments</FONT></A> ]";
-
- ### Display story:
- $theme->abstract($story->aid, $story->informant, $story->time, stripslashes($story->subject), stripslashes($story->abstract), stripslashes($story->comments), $story->category, $story->department, $morelink);
-}
-
+$theme->header();
+while ($story = db_fetch_object($result)) $theme->abstract($story);
$theme->footer();
?>