Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1:/tmp/cvs-serv11361
Modified Files:
serendipity_lang_en.inc.php serendipity_lang_de.inc.php
serendipity_functions.inc.php comment.php
Log Message:
Argl, have to type this in again. Hope I didn't forgget any files in this commit. It implements the trackback functionality into the blog (you can now actually see the trackbacks - hooray).
I guess there's bugs or such, so test it and tell me. Good night.
Index: serendipity_lang_en.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_lang_en.inc.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- serendipity_lang_en.inc.php 22 May 2003 22:45:38 -0000 1.10
+++ serendipity_lang_en.inc.php 22 May 2003 23:01:00 -0000 1.11
@@ -138,6 +138,9 @@
define("IMAGE_AS_A_LINK", "Image as a link");
define("POWERED_BY", "Powered by");
define("SUPERUSER", "Superuser");
+define("TRACKBACKS", "Trackbacks");
+define("TRACKBACK", "Trackback");
+define("NO_TRACKBACKS", "No Trackbacks");
define("serendipity_LANG_LOADED", true);
Index: serendipity_lang_de.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_lang_de.inc.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- serendipity_lang_de.inc.php 21 May 2003 18:40:09 -0000 1.7
+++ serendipity_lang_de.inc.php 22 May 2003 23:01:00 -0000 1.8
@@ -137,8 +137,9 @@
define("IMAGE_AS_A_LINK", "Bild als Link");
define("POWERED_BY", "Powered by");
define("SUPERUSER", "Besitzer login");
-
-
+define("TRACKBACKS", "Trackbacks");
+define("TRACKBACK", "Trackback");
+define("NO_TRACKBACKS", "Keine Trackbacks");
define("serendipity_LANG_LOADED", true);
?>
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- serendipity_functions.inc.php 22 May 2003 21:08:27 -0000 1.42
+++ serendipity_functions.inc.php 22 May 2003 23:01:00 -0000 1.43
@@ -308,9 +308,13 @@
if (!isset($serendipity['GET']['id'])) {
$label = $entry['comments'] == 1 ? COMMENT : COMMENTS;
- echo " | <a href=\"{$serendipity['serendipityHTTPPath']}comment.php?serendipity[entry_id]={$entry['id']}\" "
+ echo " | <a href=\"{$serendipity['serendipityHTTPPath']}comment.php?serendipity[entry_id]={$entry['id']}&serendipity[type]=comments\" "
. "onClick=\"window.open(this.href, 'comments', 'width=480,height=480,scrollbars=yes'); return false;\">"
. $entry['comments'] . " $label</a>";
+ $label = $entry['trackbacks'] == 1 ? TRACKBACK : TRACKBACKS;
+ echo " | <a href=\"{$serendipity['serendipityHTTPPath']}comment.php?serendipity[entry_id]={$entry['id']}&serendipity[type]=trackbacks\" "
+ . "onClick=\"window.open(this.href, 'comments', 'width=480,height=480,scrollbars=yes'); return false;\">"
+ . "{$entry['trackbacks']} $label</a>";
}
echo "</div>"; // serendipity_time
@@ -368,7 +372,22 @@
{
global $serendipity;
- $query = "SELECT * FROM {$serendipity['dbPrefix']}comments WHERE entry_id=$id";
+ $query = "SELECT * FROM {$serendipity['dbPrefix']}comments WHERE entry_id=$id AND type LIKE 'NORMAL'";
+ if (isset($limit)) {
+ $query .= " LIMIT $limit";
+ }
+
+ $comments = serendipity_db_query($query);
+ if (!is_array($comments))
+ return array();
+ return $comments;
+}
+
+function serendipity_fetchTrackbacks($id, $limit = null)
+{
+ global $serendipity;
+
+ $query = "SELECT * FROM {$serendipity['dbPrefix']}comments WHERE entry_id=$id AND type LIKE 'TRACKBACK' AND title!=''";
if (isset($limit)) {
$query .= " LIMIT $limit";
}
@@ -414,6 +433,43 @@
print '</table>';
}
+function serendipity_printTrackbacks($comments)
+{
+ global $serendipity;
+
+ print '<table width="100%" border="0">';
+ if (!count($comments)) {
+ print "<tr><td><i>".NO_TRACKBACKS."</i></td></tr>";
+ }
+
+ foreach ($comments as $comment) {
+ $link = empty($comment['url']) ? $comment['email'] : $comment['url'];
+ $name = empty($comment['author']) ? 'Anonymous' : $comment['author'];
+ $title= strip_tags($comment['title']);
+ $type = $comment['type'] == 'trackback' ? TRACKBACK_FROM : POSTED_BY;
+?>
+ <tr>
+ <td class="serendipity_comment">
+ <a href="<?=strip_tags($link)?>" target="_blank"><?=$title?></a><br />
+ <b>Excerpt: </b>
+ <?=htmlentities(strip_tags($comment['body']))?><br />
+ <div class="serendipity_comment_source">
+ <b>Weblog: </b> <?=strip_tags($name)?><br />
+ <b>Tracked: </b><?=date("M d, h:i", $comment['timestamp'])?><p />
+ <?php
+ if ($_SESSION["serendipityAuthedUser"] === true) {
+ ?>
+ (<a href="<?=$serendipity["baseURL"]?>comment.php?delete=<?=$comment['id']?>&entry=<?=$comment['entry_id']?>"><?= DELETE ?></a>)
+ <?php
+ }
+ ?></div>
+ </td>
+ </tr>
+<?php
+ }
+ print '</table>';
+}
+
function serendipity_saveComment($id, $commentInfo, $type='NORMAL') {
global $serendipity;
@@ -430,10 +486,9 @@
serendipity_db_query($query);
- $field = ($type=='NORMAL' ? 'comments' : 'trackbacks');
-
+ $field = ($type=='NORMAL' ? 'comments' : 'trackbacks');
$query = "UPDATE {$serendipity['dbPrefix']}entries SET $field=$field+1 WHERE id='$id'";
- var_dump(serendipity_db_query($query));
+ serendipity_db_query($query);
$query = "SELECT email, title, mail_comments
FROM {$serendipity['dbPrefix']}entries e, {$serendipity['dbPrefix']}authors a
@@ -447,6 +502,20 @@
serendipity_purgeEntry($id, $t);
}
+/**
+* Adds a comment
+**/
+function serendipity_addComment($entry, $id) {
+ global $serendipity;
+
+ $querystring = "INSERT INTO ".$serendipity["dbPrefix"]."comments VALUES ".
+ "VALUES (NULL, $id, ".time().", '".strip_tags($entry["author"])."', ".
+ "'".strip_tags($entry["email"])."', '".strip_tags($entry["url"])."', '$REMOTE_ADDR', ".
+ "'".strip_tags($entry["body"])."')";
+ serendipity_db_query($querystring);
+ serendipity_db_query("UPDATE ".$serendipity["dbPrefix"]." SET comments=comments+1 WHERE id LIKE $id");
+}
+
function serendipity_sendComment($to, $fromName, $fromEmail, $fromUrl, $id, $title, $comment) {
global $serendipity;
$text =
@@ -1157,21 +1226,6 @@
return $i;
}
-
-/**
-* Adds a comment
-**/
-function serendipity_addComment($entry, $id) {
- global $serendipity;
-
- $querystring = "INSERT INTO ".$serendipity["dbPrefix"]."comments VALUES ".
- "VALUES (NULL, $id, ".time().", '".strip_tags($entry["author"])."', ".
- "'".strip_tags($entry["email"])."', '".strip_tags($entry["url"])."', '$REMOTE_ADDR', ".
- "'".strip_tags($entry["body"])."')";
- serendipity_db_query($querystring);
- serendipity_db_query("UPDATE ".$serendipity["dbPrefix"]." SET comments=comments+1 WHERE id LIKE $id");
-}
-
/**
* Prints a form to enter new diary entries
Index: comment.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/comment.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- comment.php 1 May 2003 13:09:25 -0000 1.4
+++ comment.php 22 May 2003 23:01:00 -0000 1.5
@@ -6,7 +6,7 @@
serendipity_deleteComment($_GET['delete'],$_GET['entry']);
}
-
+
if (!($type = @$_GET['type'])) {
$type = 'normal';
}
@@ -19,7 +19,7 @@
$id = $matches[1];
}
- if (add_trackback($id, $_POST['title'], $_POST['url'],
+ if (add_trackback($id, $_POST['title'], $_POST['url'],
$_POST['blog_name'], $_POST['excerpt'])) {
report_trackback_success();
} else {
@@ -43,11 +43,17 @@
<body>
<?php
if (!isset($serendipity['POST']['comment'])) {
+if ($serendipity['GET']['type'] == "trackbacks") {
+echo '<div class="serendipity_commentsTitle">Trackbacks</div>';
+ serendipity_printTrackbacks(serendipity_fetchTrackbacks($id));
+}
+else {
?>
<div class="serendipity_commentsTitle">Comments</div>
<?php serendipity_printComments(serendipity_fetchComments($id)); ?>
<div class="serendipity_commentsTitle">Add A Comment</div>
<?php serendipity_displayCommentForm($id);
+}
} else {
$remember = 0;
$comment['url'] = $serendipity['POST']['url'];
@@ -62,7 +68,7 @@
the comments, and <a href="#" onClick="self.close()">here</a> to close this window.
<?php } else { ?>
Your comment did not contain anything, please <a href="#" onClick="history.go(-1)">go back</a> and try again
-<?php }
+<?php }
} ?>
</body>
</html>
|