diff options
author | Nicolas BERNSTEIN <alexis211@gmail.com> | 2012-04-13 19:17:17 +0200 |
---|---|---|
committer | Nicolas BERNSTEIN <alexis211@gmail.com> | 2012-04-13 19:17:17 +0200 |
commit | a535a9e7e017629178b45acc2e96e1d674a0d6fc (patch) | |
tree | b983c468aa37422bb58ff560b91eed067ca1a96e /tpl | |
parent | ccff9ce8d8a2818699ce4e20a310986fc95ea022 (diff) | |
download | Bits-a535a9e7e017629178b45acc2e96e1d674a0d6fc.tar.gz Bits-a535a9e7e017629178b45acc2e96e1d674a0d6fc.zip |
Added : ATOM feed for blog ; abilty to comment posts.
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/blog/atom_feed.php | 37 | ||||
-rw-r--r-- | tpl/blog/index.php | 15 | ||||
-rw-r--r-- | tpl/blog/view.php | 50 |
3 files changed, 102 insertions, 0 deletions
diff --git a/tpl/blog/atom_feed.php b/tpl/blog/atom_feed.php new file mode 100644 index 0000000..20dc0ea --- /dev/null +++ b/tpl/blog/atom_feed.php @@ -0,0 +1,37 @@ +<?php +header("Content-Type: application/xml"); + +echo '<?xml version="1.0" encoding="utf-8"?>'."\n"; +echo '<feed xmlns="http://www.w3.org/2005/Atom">'."\n"; +echo '<title>' . $blog_title . '</title>'."\n"; +echo '<id>' . $blog_base_url . "blog". "</id>\n"; +echo '<link href="' . $blog_base_url . "blog". '" rel="self" />' . "\n"; + + +function beginning($text, $len = 500) { + $text = preg_replace('#<.+>#isU', ' ', $text); + if (strlen($text) > $len) { + $text = substr($text, 0, $len)."..."; + } + return $text; +} + +foreach ($posts as $post) { + echo "\n<entry>\n"; + echo '<title>' . $post['title'] . "</title>\n"; + echo '<published>' . @date("c", $post['date_ts']) . "</published>\n"; + echo '<id>' . $blog_base_url . "view-blog-" . $post['id'] . "</id>\n"; + foreach (explode(', ', $post['tags']) as $tag) { + echo '<category term="' . $tag . '" />' . "\n"; + } + echo '<link href="' . $blog_base_url . "view-blog-" . $post['id'] . '" />' . "\n"; + echo '<summary type="html"><![CDATA['. beginning($post['text_html']) .']]></summary>' . "\n"; + echo '<content type="html"><![CDATA['. $post['text_html'] ."]]></content>\n"; + echo "<author><name>".$post['owner']."</name></author>\n"; + echo "</entry>\n"; +} + +echo '</feed>'; + +die(); + diff --git a/tpl/blog/index.php b/tpl/blog/index.php index 07e3388..6d07efa 100644 --- a/tpl/blog/index.php +++ b/tpl/blog/index.php @@ -17,6 +17,7 @@ foreach ($posts as $post) { echo ' | <a href="edit-blog-' . $post['id'] . '">edit</a>'; if ($can_delete && $post['owner_id'] == $user['id']) echo ' | <a href="delete-blog-' . $post['id'] . '">delete</a>'; + echo ' | <a href="view-blog-' . $post['id'] . '">read & comment (' . $post['comments'] . ')</a>'; echo '</div>'; echo '<div class="small_right">published ' . $post['date'] . '</div>'; if ($post['tags'] != '') { @@ -50,4 +51,18 @@ foreach ($fa as $kname => $kdata) { } } +echo "<h1>...</h1>"; +$ze = array(); +foreach ($fvalues as $k => $v) { $ze[] = "$k-$v"; } +$ze[] = "feed-atom"; +$zd = implode("-", $ze); +echo '<ul>'; +if (count($fvalues) > 0) { + echo '<li><a href="index-blog-' . $zd . '">Atom feed for this selection</a></li>'; + echo '<li><a href="index-blog-feed-atom">Homepage Atom feed</a></li>'; +} else { + echo '<li><a href="index-blog-feed-atom">Atom feed</a></li>'; +} +echo '</ul>'; + require("tpl/general/bottom.php"); diff --git a/tpl/blog/view.php b/tpl/blog/view.php new file mode 100644 index 0000000..0f0c89c --- /dev/null +++ b/tpl/blog/view.php @@ -0,0 +1,50 @@ +<?php + +$title = $post['title']; + +require("tpl/general/top.php"); + +echo '<div class="small_right">'; +echo 'Written by ' . $post['owner']; +if ($can_edit && $post['owner_id'] == $user['id']) + echo ' | <a href="edit-blog-' . $post['id'] . '">edit</a>'; +if ($can_delete && $post['owner_id'] == $user['id']) + echo ' | <a href="delete-blog-' . $post['id'] . '">delete</a>'; +if ($can_comment) + echo ' | <a href="comment-blog-' . $post['id'] . '">post comment</a>'; +echo '</div>'; +echo '<div class="small_right">published ' . $post['date'] . '</div>'; +if ($post['tags'] != '') { + echo '<div class="small_right">tags: ' . $post['tags'] . '</div>'; +} +echo $post['text_html']; + +echo '<h2>Comments</h2>'; + +if (count($comments) == 0) { + echo 'No comments at the moment.'; +} else { + foreach ($comments as $comment) { + echo '<div class="blog_post">'; + $a = array(); + if ($can_delcom) $a[] = '<a href="delcom-blog-' . $comment['id'] . '">delete</a>'; + if ($can_comment && $comment['author_id'] == $user['id']) + $a[] = '<a href="edcom-blog-' . $comment['id'] . '">edit</a>'; + if (count($a) > 0) + echo '<div class="small_right">' . implode(" | ", $a) . '</div>'; + + echo '<h3>' . $comment['date'] . ' by ' . $comment['author'] . '</h3>'; + echo '<div class="inside">' . $comment['text_html'] . '</div>'; + echo '</div>'; + } +} + +echo '<h3>Post a comment</h3>'; +if ($can_comment) { + echo '<form class="blog_post" method="POST" action="index.php?p=comment-blog-' . $post['id'] . '"><textarea name="comment" style="height: 200px"></textarea><br /><div class="empty_label"> </div><input type="submit" value="Comment" /></form>'; +} else { + echo 'Please log in or register to post a comment.'; +} + + +require("tpl/general/bottom.php"); |