summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/comment.inc80
-rw-r--r--includes/database.inc13
-rw-r--r--includes/function.inc9
-rw-r--r--includes/hostname.conf6
-rw-r--r--includes/theme.inc13
5 files changed, 47 insertions, 74 deletions
diff --git a/includes/comment.inc b/includes/comment.inc
index 44909ac65..7ec1d3734 100644
--- a/includes/comment.inc
+++ b/includes/comment.inc
@@ -53,7 +53,7 @@ function comment_reply($pid, $id) {
if ($pid) {
$item = db_fetch_object(db_query("SELECT comments.*, users.userid FROM comments LEFT JOIN users ON comments.author = users.id WHERE comments.cid = $pid"));
- $theme->comment(new Comment($item->userid, $item->subject, $item->comment, $item->timestamp, $item->url, $item->fake_email, comment_score($comment), $comment->votes, $item->cid, $item->lid), "reply to this comment");
+ comment_view(new Comment($item->userid, $item->subject, $item->comment, $item->timestamp, $item->url, $item->fake_email, comment_score($comment), $comment->votes, $item->cid, $item->lid), t("reply to this comment"));
}
else {
$pid = 0;
@@ -87,14 +87,14 @@ function comment_reply($pid, $id) {
$output .= "</FORM>\n";
- $theme->box("Reply", $output);
+ $theme->box(t("Reply"), $output);
}
function comment_preview($pid, $id, $subject, $comment) {
global $allowed_html, $link, $REQUEST_URI, $theme, $user;
// Preview comment:
- $theme->comment(new Comment($user->userid, $subject, $comment, time(), $user->url, $user->fake_email, 0, 0, 0, 0), "reply to this comment");
+ comment_view(new Comment($user->userid, $subject, $comment, time(), $user->url, $user->fake_email, 0, 0, 0, 0), t("reply to this comment"));
// Build reply form:
$output .= "<FORM ACTION=\"$REQUEST_URI\" METHOD=\"post\">\n";
@@ -173,14 +173,16 @@ function comment_moderation($comment) {
global $comment_votes, $op, $user;
if ($op == "reply") {
+ // preview comment:
$output .= "&nbsp;";
}
else if ($user->id && $user->userid != $comment->userid && !user_get($user, "history", "c$comment->cid")) {
- $output .= "<SELECT NAME=\"moderate[$comment->cid]\">\n";
- foreach ($comment_votes as $key=>$value) $output .= " <OPTION VALUE=\"$value\">$key</OPTION>\n";
- $output .= "</SELECT>\n";
+ // comment hasn't been moderated yet:
+ foreach ($comment_votes as $key=>$value) $options .= " <OPTION VALUE=\"$value\">$key</OPTION>\n";
+ $output .= "<SELECT NAME=\"moderate[$comment->cid]\">$options</SELECT>\n";
}
else {
+ // comment has already been moderated:
$output .= "<TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"1\"><TR><TD>". t("score") .":</TD><TD>". check_output($comment->score) ."</TD></TR><TR><TD>". t("votes") .":</TD><TD>". check_output($comment->votes) ."</TR></TABLE>\n";
}
@@ -202,32 +204,20 @@ function comment_controls($threshold = 1, $mode = 3, $order = 1) {
}
function comment_threshold($threshold) {
- $output .= "<SELECT NAME=\"threshold\">\n";
- for ($i = -1; $i < 6; $i++) {
- $output .= " <OPTION VALUE=\"$i\"". ($threshold == $i ? " SELECTED" : "") .">". t("Filter") ." - $i</OPTION>";
- }
- $output .= "</SELECT>\n";
- return $output;
+ for ($i = -1; $i < 6; $i++) $options .= " <OPTION VALUE=\"$i\"". ($threshold == $i ? " SELECTED" : "") .">". t("Filter") ." - $i</OPTION>";
+ return "<SELECT NAME=\"threshold\">$options</SELECT>\n";
}
function comment_mode($mode) {
global $cmodes;
- $output .= "<SELECT NAME=\"mode\">\n";
- foreach ($cmodes as $key=>$value) {
- $output .= " <OPTION VALUE=\"$key\"". ($mode == $key ? " SELECTED" : "") .">$value</OPTION>\n";
- }
- $output .= "</SELECT>\n";
- return $output;
+ foreach ($cmodes as $key=>$value) $options .= " <OPTION VALUE=\"$key\"". ($mode == $key ? " SELECTED" : "") .">$value</OPTION>\n";
+ return "<SELECT NAME=\"mode\">$options</SELECT>\n";
}
function comment_order($order) {
global $corder;
- $output .= "<SELECT NAME=\"order\">\n";
- foreach ($corder as $key=>$value) {
- $output .= " <OPTION VALUE=\"$key\"". ($order == $key ? " SELECTED" : "") .">$value</OPTION>\n";
- }
- $output .= "</SELECT>\n";
- return $output;
+ foreach ($corder as $key=>$value) $options .= " <OPTION VALUE=\"$key\"". ($order == $key ? " SELECTED" : "") .">$value</OPTION>\n";
+ return "<SELECT NAME=\"order\">$options</SELECT>\n";
}
function comment_query($link, $lid, $order, $pid = -1) {
@@ -254,44 +244,42 @@ function comment_uri($args = 0) {
function comment_link($comment, $return = 1) {
global $link, $theme;
- if ($return) return "<A HREF=\"". comment_uri("id=$comment->lid#$comment->cid") ."\"><FONT COLOR=\"$theme->link\">return</FONT></A> | <A HREF=\"". comment_uri("op=reply&id=$comment->lid&pid=$comment->cid") ."\"><FONT COLOR=\"$theme->link\">reply to this comment</FONT></A>";
- else return "<A HREF=\"". comment_uri("op=reply&id=$comment->lid&pid=$comment->cid") ."\"><FONT COLOR=\"$theme->link\">reply to this comment</FONT></A>";
+ if ($return) return "<A HREF=\"". comment_uri("id=$comment->lid#$comment->cid") ."\"><FONT COLOR=\"$theme->link\">". t("return") ."</FONT></A> | <A HREF=\"". comment_uri("op=reply&id=$comment->lid&pid=$comment->cid") ."\"><FONT COLOR=\"$theme->link\">". t("reply to this comment") ."</FONT></A>";
+ else return "<A HREF=\"". comment_uri("op=reply&id=$comment->lid&pid=$comment->cid") ."\"><FONT COLOR=\"$theme->link\">". t("reply to this comment") ."</FONT></A>";
}
-function comment_comment($comment, $folded = 0) {
+function comment_view($comment, $folded = 0) {
global $link, $theme;
+
+ // calculate comment's score:
+ $comment->score = comment_score($comment);
+
+ // display comment:
if ($folded) $theme->comment($comment, $folded);
- else print "<A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A> by ". format_username($comment->userid) ." <SMALL>(". $score = comment_score($comment) .")</SMALL></LI>";
+ else print "<A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A> by ". format_username($comment->userid) ." <SMALL>($comment->score)</SMALL><P>";
}
function comment_thread_min($cid, $threshold) {
- global $user, $theme;
+ global $user;
$result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.pid = $cid ORDER BY c.timestamp, c.cid");
print "<UL>";
while ($comment = db_fetch_object($result)) {
- comment_comment($comment);
+ comment_view($comment);
comment_thread_min($comment->cid, $threshold);
}
print "</UL>";
}
function comment_thread_max($cid, $mode, $threshold, $level = 0, $dummy = 0) {
- global $link, $theme, $user;
+ global $link, $user;
$result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE link = '$link' AND c.pid = $cid ORDER BY c.timestamp, c.cid");
print "<UL>";
while ($comment = db_fetch_object($result)) {
- if (comment_visible($comment, $threshold)) {
- $comment = new Comment($comment->userid, $comment->subject, $comment->comment, $comment->timestamp, $comment->url, $comment->fake_email, comment_score($comment), $comment->votes, $comment->cid, $comment->lid);
- $theme->comment($comment, comment_link($comment, 0));
- }
- else {
- comment_comment($comment);
- print "<P>";
- }
+ comment_view($comment, (comment_visible($comment, $threshold) ? comment_link($comment, 0) : 0));
comment_thread_max($comment->cid, $mode, $threshold, $level + 1, $dummy + 1);
}
print "</UL>";
@@ -318,7 +306,7 @@ function comment_render($lid, $cid) {
if ($cid > 0) {
$result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE cid = $cid");
if ($comment = db_fetch_object($result)) {
- $theme->comment($comment, comment_link($comment));
+ comment_view($comment, comment_link($comment));
}
}
else {
@@ -336,22 +324,20 @@ function comment_render($lid, $cid) {
else if ($mode == 2) {
$result = comment_query($link, $lid, $order);
while ($comment = db_fetch_object($result)) {
- if (comment_visible($comment, $threshold)) {
- $theme->comment($comment, comment_link($comment, 0));
- }
+ comment_view($comment, (comment_visible($comment, $threshold) ? comment_link($comment, 0) : 0));
}
}
else if ($mode == 3) {
$result = comment_query($link, $lid, $order, 0);
while ($comment = db_fetch_object($result)) {
- comment_comment($comment);
+ comment_view($comment);
comment_thread_min($comment->cid, $threshold);
}
}
else {
$result = comment_query($link, $lid, $order, 0);
while ($comment = db_fetch_object($result)) {
- comment_comment($comment, (comment_visible($comment, $threshold) ? comment_link($comment, 0) : 0));
+ comment_view($comment, (comment_visible($comment, $threshold) ? comment_link($comment, 0) : 0));
comment_thread_max($comment->cid, $mode, $threshold, $level + 1);
}
}
@@ -359,8 +345,8 @@ function comment_render($lid, $cid) {
if ($user->id) {
// Print moderation form:
- print " <INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$lid\">\n";
- print " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Moderate comments") ."\">\n";
+ print " <INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$lid\">\n";
+ print " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Moderate comments") ."\">\n";
print "</FORM>\n";
}
}
diff --git a/includes/database.inc b/includes/database.inc
index 6e72de158..9e0d22254 100644
--- a/includes/database.inc
+++ b/includes/database.inc
@@ -1,11 +1,4 @@
<?
-/*
- * These functions build the foundation for accessing the database:
- * it is a general database abstraction layer suitable for several
- * databases. Currently, the only supported database is MySQL but
- * it should be straightforward to port it to any other database:
- * just adjust the handlers to your needs.
- */
function db_connect($host, $user, $pass, $name) {
mysql_pconnect($host, $user, $pass) or die(mysql_Error());
@@ -45,9 +38,7 @@ function db_result($qid, $field = 0) {
if ($qid) return mysql_result($qid, $field);
}
-#
-# Automatically connect to database:
-#
+// Setup database connection:
db_connect($db_host, $db_user, $db_pass, $db_name);
-?>
+?> \ No newline at end of file
diff --git a/includes/function.inc b/includes/function.inc
index de5de07e6..0308a5efc 100644
--- a/includes/function.inc
+++ b/includes/function.inc
@@ -36,19 +36,19 @@ function format_plural($count, $singular, $plural) {
function format_interval($timestamp) {
if ($timestamp >= 86400) {
- $output .= format_plural(floor($timestamp / 86400), "day ", "days ");
+ $output .= format_plural(floor($timestamp / 86400), "day", "days");
$timestamp = $timestamp % 86400;
}
if ($timestamp >= 3600) {
- $output .= format_plural(floor($timestamp / 3600), "hour ", "hours ");
+ $output .= " ". format_plural(floor($timestamp / 3600), "hour", "hours");
$timestamp = $timestamp % 3600;
}
if ($timestamp >= 60) {
- $output .= floor($timestamp / 60) ." min ";
+ $output .= " ". floor($timestamp / 60) ."min";
$timestamp = $timestamp % 60;
}
if ($timestamp > 0) {
- $output .= "$timestamp sec";
+ $output .= " $timestamp sec";
}
return ($output) ? $output : "0 sec";
}
@@ -74,7 +74,6 @@ function format_date($timestamp, $type = "medium") {
return $date;
}
-
function format_username($username) {
global $user;
if ($username) return (user_access($user, "account") ? "<A HREF=\"admin.php?mod=account&op=view&name=$username\">$username</A>" : "<A HREF=\"account.php?op=view&name=$username\">$username</A>");
diff --git a/includes/hostname.conf b/includes/hostname.conf
index affdbd4c8..882b319db 100644
--- a/includes/hostname.conf
+++ b/includes/hostname.conf
@@ -8,12 +8,11 @@ $db_user = "username";
$db_pass = "password";
$db_name = "database";
-
#
# Administrative information
#
$site_name = "site name";
-$site_url = "http://yourdomain.com/";
+$site_url = "http://yourdomain.com/"; // add a trailing slash
$site_email = "info@yourdomain.com";
#
@@ -89,11 +88,12 @@ $submission_votes = array("neutral (+0)" => "+ 0",
$submission_rate = array("comment" => "60", // 60 seconds = 1 minute
"diary" => "300", // 300 seconds = 5 minutes
"story" => "300"); // 300 seconds = 5 minutes
+
#
# Submission size:
# the maximum length (i.e. the maximum number of characters) a
# story, a diary entry, or a comment is allowed to be.
#
-$submission_size = 12000; // 12.000 characters is more or less 300 lines
+$submission_size = 12000; // 12.000 characters is appr. 300 lines
?>
diff --git a/includes/theme.inc b/includes/theme.inc
index 7689ea2c7..0af3797f0 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -101,7 +101,7 @@ function theme_moderation_results($theme, $story) {
$output .= format_username($account->userid) ." voted `". user_get($account, "history", "s$story->id") ."'.<BR>";
}
- $theme->box("Moderation results", ($output ? $output : "This story has not been moderated yet."));
+ $theme->box(t("Moderation results"), ($output ? $output : t("This story has not been moderated yet.")));
}
}
@@ -115,12 +115,9 @@ function theme_related_links($theme, $story) {
}
// Stories in the same section:
- $content .= " <LI>More about <A HREF=\"index.php?section=". urlencode($story->section) ."\">$story->section</A>.</LI>";
+ $content .= " <LI>". t("More about") ." <A HREF=\"index.php?section=". urlencode($story->section) ."\">$story->section</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);
+ $theme->box(t("Related links"), $content);
}
function theme_new_headlines($theme, $num = 10) {
@@ -129,7 +126,7 @@ function theme_new_headlines($theme, $num = 10) {
$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><A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A></LI>\n";
- $theme->box("Latest headlines", $content);
+ $theme->box(t("Latest headlines"), $content);
}
function theme_old_headlines($theme, $num = 10) {
@@ -145,7 +142,7 @@ function theme_old_headlines($theme, $num = 10) {
}
$content .= "<LI><A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A></LI>\n";
}
- $theme->box("Older headlines", $content);
+ $theme->box(t("Older headlines"), $content);
}
?>