From a535a9e7e017629178b45acc2e96e1d674a0d6fc Mon Sep 17 00:00:00 2001 From: Nicolas BERNSTEIN Date: Fri, 13 Apr 2012 19:17:17 +0200 Subject: Added : ATOM feed for blog ; abilty to comment posts. --- tpl/blog/atom_feed.php | 37 +++++++++++++++++++++++++++++++++++++ tpl/blog/index.php | 15 +++++++++++++++ tpl/blog/view.php | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 tpl/blog/atom_feed.php create mode 100644 tpl/blog/view.php (limited to 'tpl') 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 @@ +'."\n"; +echo ''."\n"; +echo '' . $blog_title . ''."\n"; +echo '' . $blog_base_url . "blog". "\n"; +echo '' . "\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\n"; + echo '' . $post['title'] . "\n"; + echo '' . @date("c", $post['date_ts']) . "\n"; + echo '' . $blog_base_url . "view-blog-" . $post['id'] . "\n"; + foreach (explode(', ', $post['tags']) as $tag) { + echo '' . "\n"; + } + echo '' . "\n"; + echo '' . "\n"; + echo '\n"; + echo "".$post['owner']."\n"; + echo "\n"; +} + +echo ''; + +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 ' | edit'; if ($can_delete && $post['owner_id'] == $user['id']) echo ' | delete'; + echo ' | read & comment (' . $post['comments'] . ')'; echo ''; echo '
published ' . $post['date'] . '
'; if ($post['tags'] != '') { @@ -50,4 +51,18 @@ foreach ($fa as $kname => $kdata) { } } +echo "

...

"; +$ze = array(); +foreach ($fvalues as $k => $v) { $ze[] = "$k-$v"; } +$ze[] = "feed-atom"; +$zd = implode("-", $ze); +echo ''; + 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 @@ +'; +echo 'Written by ' . $post['owner']; +if ($can_edit && $post['owner_id'] == $user['id']) + echo ' | edit'; +if ($can_delete && $post['owner_id'] == $user['id']) + echo ' | delete'; +if ($can_comment) + echo ' | post comment'; +echo ''; +echo '
published ' . $post['date'] . '
'; +if ($post['tags'] != '') { + echo '
tags: ' . $post['tags'] . '
'; +} +echo $post['text_html']; + +echo '

Comments

'; + +if (count($comments) == 0) { + echo 'No comments at the moment.'; +} else { + foreach ($comments as $comment) { + echo '
'; + $a = array(); + if ($can_delcom) $a[] = 'delete'; + if ($can_comment && $comment['author_id'] == $user['id']) + $a[] = 'edit'; + if (count($a) > 0) + echo '
' . implode(" | ", $a) . '
'; + + echo '

' . $comment['date'] . ' by ' . $comment['author'] . '

'; + echo '
' . $comment['text_html'] . '
'; + echo '
'; + } +} + +echo '

Post a comment

'; +if ($can_comment) { + echo '

 
'; +} else { + echo 'Please log in or register to post a comment.'; +} + + +require("tpl/general/bottom.php"); -- cgit v1.2.3