From b71a8f06f1670d0e2d3eeb4457e1ac06c25975a0 Mon Sep 17 00:00:00 2001
From: ben
Date: Thu, 3 Apr 2008 17:10:42 +0000
Subject: Added comments to blog
git-svn-id: https://code.elgg.org/elgg/trunk@396 36083f99-b078-4883-b0ff-0f9b5a30f544
---
mod/blog/actions/comments/add.php | 44 +++++++++++++++++++++++++
mod/blog/languages/en.php | 6 ++++
mod/blog/start.php | 1 +
mod/blog/views/default/object/blog-comment.php | 31 +++++++++++++++++
mod/blog/views/default/object/blog-comments.php | 27 +++++++++++++++
mod/blog/views/default/object/blog.php | 3 +-
6 files changed, 111 insertions(+), 1 deletion(-)
create mode 100644 mod/blog/actions/comments/add.php
create mode 100644 mod/blog/views/default/object/blog-comment.php
create mode 100644 mod/blog/views/default/object/blog-comments.php
(limited to 'mod/blog')
diff --git a/mod/blog/actions/comments/add.php b/mod/blog/actions/comments/add.php
new file mode 100644
index 000000000..8a54cde13
--- /dev/null
+++ b/mod/blog/actions/comments/add.php
@@ -0,0 +1,44 @@
+
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Make sure we're logged in; forward to the front page if not
+ if (!isloggedin()) forward();
+
+ // Get input
+ $blogpost_guid = (int) get_input('blogpost_guid');
+ $comment = get_input('comment');
+
+ // Let's see if we can get an entity with the specified GUID, and that it's a blog post
+ if ($blogpost = get_entity($blogpost_guid)) {
+ if ($blogpost->getSubtype() == "blog") {
+
+ // If posting the comment was successful, say so
+ if ($blogpost->annotate('comment',$comment,$blogpost->access_id, $_SESSION['guid'])) {
+
+ system_message(elgg_echo("comment:success"));
+
+ } else {
+ system_message(elgg_echo("comment:failure"));
+ }
+
+ }
+
+ } else {
+
+ system_message(elgg_echo("blog:notfound"));
+
+ }
+
+ // Forward to the
+ forward("mod/blog/read.php?blogpost=" . $blogpost_guid);
+
+?>
\ No newline at end of file
diff --git a/mod/blog/languages/en.php b/mod/blog/languages/en.php
index 1beb5129d..dbccfd98d 100644
--- a/mod/blog/languages/en.php
+++ b/mod/blog/languages/en.php
@@ -22,17 +22,23 @@
'blog:comment:add' => "Add a comment",
'blog:comment:text' => "Comment text",
+ 'comments' => "Comments",
+
/**
* Status messages
*/
'blog:posted' => "Your blog post was successfully posted.",
+ 'comment:success' => "Your comment was successfully added.",
/**
* Error messages
*/
'blog:blank' => "Sorry; you need to fill in both the title and body before you can make a post.",
+ 'blog:notfound' => "Sorry; we could not find the specified blog post.",
+
+ 'comment:failure' => "An unexpected error occurred when adding your comment. Please try again.",
);
diff --git a/mod/blog/start.php b/mod/blog/start.php
index 6b1ca3766..bd9dac913 100644
--- a/mod/blog/start.php
+++ b/mod/blog/start.php
@@ -47,5 +47,6 @@
// Register actions
global $CONFIG;
register_action("blog/add",false,$CONFIG->pluginspath . "blog/actions/add.php");
+ register_action("blog/comments/add",false,$CONFIG->pluginspath . "blog/actions/comments/add.php");
?>
\ No newline at end of file
diff --git a/mod/blog/views/default/object/blog-comment.php b/mod/blog/views/default/object/blog-comment.php
new file mode 100644
index 000000000..ecbf5fcff
--- /dev/null
+++ b/mod/blog/views/default/object/blog-comment.php
@@ -0,0 +1,31 @@
+
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ *
+ * @uses $vars['entity'] The comment to view
+ */
+
+
+?>
+
+
+
+ $vars['entity']->value)); ?>
+
+ owner_guid)) {
+ echo $owner->name;
+ }
+
+ ?>, time_created); ?>
+
+
+
\ No newline at end of file
diff --git a/mod/blog/views/default/object/blog-comments.php b/mod/blog/views/default/object/blog-comments.php
new file mode 100644
index 000000000..991c42301
--- /dev/null
+++ b/mod/blog/views/default/object/blog-comments.php
@@ -0,0 +1,27 @@
+
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ *
+ * @uses $vars['comments'] Array of comments
+ */
+
+ if (isset($vars['comments']) && is_array($vars['comments']) && sizeof($vars['comments']) > 0) {
+
+ echo "". elgg_echo("comments") ."
";
+ foreach($vars['comments'] as $comment) {
+
+ echo elgg_view("object/blog-comment",array('entity' => $comment));
+
+ }
+ echo "
";
+
+ }
+
+?>
\ No newline at end of file
diff --git a/mod/blog/views/default/object/blog.php b/mod/blog/views/default/object/blog.php
index b023d76e5..d64495f9d 100644
--- a/mod/blog/views/default/object/blog.php
+++ b/mod/blog/views/default/object/blog.php
@@ -61,7 +61,7 @@
echo elgg_view('object/blog-comments',array('comments' => $vars['comments']));
?>
-
+
" />
--
cgit v1.2.3