aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/blog/actions/add.php66
-rw-r--r--mod/blog/actions/delete.php38
-rw-r--r--mod/blog/actions/edit.php70
-rw-r--r--mod/blog/add.php34
-rw-r--r--mod/blog/edit.php41
-rw-r--r--mod/blog/everyone.php31
-rw-r--r--mod/blog/friends.php40
-rw-r--r--mod/blog/index.php39
-rw-r--r--mod/blog/languages/en.php66
-rw-r--r--mod/blog/manifest.xml8
-rw-r--r--mod/blog/read.php55
-rw-r--r--mod/blog/start.php174
-rw-r--r--mod/blog/views/default/blog/css.php96
-rw-r--r--mod/blog/views/default/blog/forms/edit.php86
-rw-r--r--mod/blog/views/default/blog/gallery.php31
-rw-r--r--mod/blog/views/default/blog/listing.php25
-rw-r--r--mod/blog/views/default/blog/menu.php17
-rw-r--r--mod/blog/views/default/blog/notfound.php21
-rw-r--r--mod/blog/views/default/blog/view.php26
-rw-r--r--mod/blog/views/default/object/blog.php115
-rw-r--r--mod/blog/views/default/river/blog/annotate.php13
-rw-r--r--mod/blog/views/default/river/blog/create.php13
-rw-r--r--mod/blog/views/default/river/blog/update.php13
23 files changed, 1118 insertions, 0 deletions
diff --git a/mod/blog/actions/add.php b/mod/blog/actions/add.php
new file mode 100644
index 000000000..5fc6919e8
--- /dev/null
+++ b/mod/blog/actions/add.php
@@ -0,0 +1,66 @@
+<?php
+
+ /**
+ * Elgg blog: add post action
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Make sure we're logged in (send us to the front page if not)
+ if (!isloggedin()) forward();
+
+ // Get input data
+ $title = get_input('blogtitle');
+ $body = get_input('blogbody');
+ $tags = get_input('blogtags');
+
+ // Cache to the session
+ $_SESSION['blogtitle'] = $title;
+ $_SESSION['blogbody'] = $body;
+ $_SESSION['blogtags'] = $tags;
+
+ // Convert string of tags into a preformatted array
+ $tagarray = string_to_tag_array($tags);
+
+ // Make sure the title / description aren't blank
+ if (empty($title) || empty($body)) {
+ register_error(elgg_echo("blog:blank"));
+ forward("mod/blog/add.php");
+
+ // Otherwise, save the blog post
+ } else {
+
+ // Initialise a new ElggObject
+ $blog = new ElggObject();
+ // Tell the system it's a blog post
+ $blog->subtype = "blog";
+ // Set its owner to the current user
+ $blog->owner_guid = $_SESSION['user']->getGUID();
+ // For now, set its access to public (we'll add an access dropdown shortly)
+ $blog->access_id = 2;
+ // Set its title and description appropriately
+ $blog->title = $title;
+ $blog->description = $body;
+ // Before we can set metadata, we need to save the blog post
+ if (!$blog->save()) {
+ register_error(elgg_echo("blog:error"));
+ forward("mod/blog/add.php");
+ }
+ // Now let's add tags. We can pass an array directly to the object property! Easy.
+ if (is_array($tagarray)) {
+ $blog->tags = $tagarray;
+ }
+ // Success message
+ system_message(elgg_echo("blog:posted"));
+ // Remove the blog post cache
+ unset($_SESSION['blogtitle']); unset($_SESSION['blogbody']); unset($_SESSION['blogtags']);
+ // Forward to the main blog page
+ forward("mod/blog/?username=" . $_SESSION['user']->username);
+
+ }
+
+?> \ No newline at end of file
diff --git a/mod/blog/actions/delete.php b/mod/blog/actions/delete.php
new file mode 100644
index 000000000..17db2e934
--- /dev/null
+++ b/mod/blog/actions/delete.php
@@ -0,0 +1,38 @@
+<?php
+
+ /**
+ * Elgg blog: delete post action
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Make sure we're logged in (send us to the front page if not)
+ if (!isloggedin()) forward();
+
+ // Get input data
+ $guid = (int) get_input('blogpost');
+
+ // Make sure we actually have permission to edit
+ $blog = get_entity($guid);
+ if ($blog->getSubtype() == "blog" && $blog->canEdit()) {
+
+ // Get owning user
+ $owner = get_entity($blog->getOwner());
+ // Delete it!
+ $rowsaffected = $blog->delete();
+ if ($rowsaffected > 0) {
+ // Success message
+ system_message(elgg_echo("blog:deleted"));
+ } else {
+ register_error(elgg_echo("blog:notdeleted"));
+ }
+ // Forward to the main blog page
+ forward("mod/blog/?username=" . $owner->username);
+
+ }
+
+?> \ No newline at end of file
diff --git a/mod/blog/actions/edit.php b/mod/blog/actions/edit.php
new file mode 100644
index 000000000..06b5b90b7
--- /dev/null
+++ b/mod/blog/actions/edit.php
@@ -0,0 +1,70 @@
+<?php
+
+ /**
+ * Elgg blog: edit post action
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Make sure we're logged in (send us to the front page if not)
+ if (!isloggedin()) forward();
+
+ // Get input data
+ $guid = (int) get_input('blogpost');
+ $title = get_input('blogtitle');
+ $body = get_input('blogbody');
+ $tags = get_input('blogtags');
+
+ // Make sure we actually have permission to edit
+ $blog = get_entity($guid);
+ if ($blog->getSubtype() == "blog" && $blog->canEdit()) {
+
+ // Cache to the session
+ $_SESSION['blogtitle'] = $title;
+ $_SESSION['blogbody'] = $body;
+ $_SESSION['blogtags'] = $tags;
+
+ // Convert string of tags into a preformatted array
+ $tagarray = string_to_tag_array($tags);
+
+ // Make sure the title / description aren't blank
+ if (empty($title) || empty($body)) {
+ register_error(elgg_echo("blog:blank"));
+ forward("mod/blog/add.php");
+
+ // Otherwise, save the blog post
+ } else {
+
+ // Get owning user
+ $owner = get_entity($blog->getOwner());
+ // For now, set its access to public (we'll add an access dropdown shortly)
+ $blog->access_id = 2;
+ // Set its title and description appropriately
+ $blog->title = $title;
+ $blog->description = $body;
+ // Before we can set metadata, we need to save the blog post
+ if (!$blog->save()) {
+ register_error(elgg_echo("blog:error"));
+ forward("mod/blog/edit.php?blogpost=" . $guid);
+ }
+ // Now let's add tags. We can pass an array directly to the object property! Easy.
+ $blog->clearMetadata('tags');
+ if (is_array($tagarray)) {
+ $blog->tags = $tagarray;
+ }
+ // Success message
+ system_message(elgg_echo("blog:posted"));
+ // Remove the blog post cache
+ unset($_SESSION['blogtitle']); unset($_SESSION['blogbody']); unset($_SESSION['blogtags']);
+ // Forward to the main blog page
+ forward("pg/blog/" . $owner->username);
+
+ }
+
+ }
+
+?> \ No newline at end of file
diff --git a/mod/blog/add.php b/mod/blog/add.php
new file mode 100644
index 000000000..6b5171338
--- /dev/null
+++ b/mod/blog/add.php
@@ -0,0 +1,34 @@
+<?php
+
+ /**
+ * Elgg blog add entry page
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ // Load Elgg engine
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+ gatekeeper();
+
+ // Get the current page's owner
+ $page_owner = page_owner_entity();
+ if ($page_owner === false || is_null($page_owner)) {
+ $page_owner = $_SESSION['user'];
+ set_page_owner($_SESSION['guid']);
+ }
+
+ //set the title
+ $area2 = elgg_view_title(elgg_echo('blog:addpost'));
+
+ // Get the form
+ $area2 .= elgg_view("blog/forms/edit");
+
+ // Display page
+ page_draw(elgg_echo('blog:addpost'),elgg_view_layout("two_column_left_sidebar", $area1, $area2));
+
+
+?> \ No newline at end of file
diff --git a/mod/blog/edit.php b/mod/blog/edit.php
new file mode 100644
index 000000000..f6eada727
--- /dev/null
+++ b/mod/blog/edit.php
@@ -0,0 +1,41 @@
+<?php
+
+ /**
+ * Elgg blog edit entry page
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ // Load Elgg engine
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+ gatekeeper();
+
+ // Get the current page's owner
+ $page_owner = page_owner_entity();
+ if ($page_owner === false || is_null($page_owner)) {
+ $page_owner = $_SESSION['user'];
+ set_page_owner($_SESSION['guid']);
+ }
+
+ // Get the post, if it exists
+ $blogpost = (int) get_input('blogpost');
+ if ($post = get_entity($blogpost)) {
+
+ if ($post->canEdit()) {
+
+ $area2 = elgg_view_title(elgg_echo('blog:editpost'));
+ $area2 .= elgg_view("blog/forms/edit", array('entity' => $post));
+ $body = elgg_view_layout("two_column_left_sidebar", $area1, $area2);
+
+ }
+
+ }
+
+ // Display page
+ page_draw(sprintf(elgg_echo('blog:editpost'),$post->title),$body);
+
+?> \ No newline at end of file
diff --git a/mod/blog/everyone.php b/mod/blog/everyone.php
new file mode 100644
index 000000000..881d7c995
--- /dev/null
+++ b/mod/blog/everyone.php
@@ -0,0 +1,31 @@
+<?php
+
+ /**
+ * Elgg view all blog posts from all users page
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ // Load Elgg engine
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+// Get the current page's owner
+ $page_owner = page_owner_entity();
+ if ($page_owner === false || is_null($page_owner)) {
+ $page_owner = $_SESSION['user'];
+ set_page_owner($_SESSION['guid']);
+ }
+
+ $area2 = elgg_view_title(elgg_echo('blog:everyone'));
+
+ $area2 .= list_entities('object','blog',0,10,false);
+ $body = elgg_view_layout("two_column_left_sidebar", '', $area1 . $area2);
+
+ // Display page
+ page_draw(elgg_echo('blog:everyone'),$body);
+
+?> \ No newline at end of file
diff --git a/mod/blog/friends.php b/mod/blog/friends.php
new file mode 100644
index 000000000..935f5d885
--- /dev/null
+++ b/mod/blog/friends.php
@@ -0,0 +1,40 @@
+<?php
+
+ /**
+ * Elgg blog friends page
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ // Load Elgg engine
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+ // Get the current page's owner
+ $page_owner = page_owner_entity();
+ if ($page_owner === false || is_null($page_owner)) {
+ $page_owner = $_SESSION['user'];
+ set_page_owner($_SESSION['guid']);
+ }
+ if (!($page_owner instanceof ElggEntity)) forward();
+
+ //set the title
+ if($page_owner == $_SESSION['user']){
+ $area2 = elgg_view_title(elgg_echo('blog:yourfriends'));
+ }else{
+ $area2 = elgg_view_title($page_owner->username . "'s " . elgg_echo('blog:friends'));
+ }
+
+ // Get a list of blog posts
+ $area2 .= list_user_friends_objects($page_owner->getGUID(),'blog',10,false);
+
+ // Display them in the page
+ $body = elgg_view_layout("two_column_left_sidebar", '', $area1 . $area2);
+
+ // Display page
+ page_draw(elgg_echo('blog:friends'),$body);
+
+?> \ No newline at end of file
diff --git a/mod/blog/index.php b/mod/blog/index.php
new file mode 100644
index 000000000..e4f9698f3
--- /dev/null
+++ b/mod/blog/index.php
@@ -0,0 +1,39 @@
+<?php
+
+ /**
+ * Elgg blog index page
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ // Load Elgg engine
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+ // Get the current page's owner
+ $page_owner = page_owner_entity();
+ if ($page_owner === false || is_null($page_owner)) {
+ $page_owner = $_SESSION['user'];
+ set_page_owner($_SESSION['guid']);
+ }
+
+ //set blog title
+ if($page_owner == $_SESSION['user']){
+ $area2 = elgg_view_title(elgg_echo('blog:your'));
+ }else{
+ //$area1 = elgg_view_title($page_owner->username . "'s " . elgg_echo('blog'));
+ }
+
+ // Get a list of blog posts
+ $area2 .= list_user_objects($page_owner->getGUID(),'blog',10,false);
+
+ // Display them in the page
+ $body = elgg_view_layout("two_column_left_sidebar", '', $area1 . $area2);
+
+ // Display page
+ page_draw(sprintf(elgg_echo('blog:user'),$page_owner->name),$body);
+
+?> \ No newline at end of file
diff --git a/mod/blog/languages/en.php b/mod/blog/languages/en.php
new file mode 100644
index 000000000..f17ab6045
--- /dev/null
+++ b/mod/blog/languages/en.php
@@ -0,0 +1,66 @@
+<?php
+
+ $english = array(
+
+ /**
+ * Menu items and titles
+ */
+
+ 'blog' => "Blog",
+ 'blogs' => "Blogs",
+ 'blog:user' => "%s's blog",
+ 'blog:user:friends' => "%s's friends' blog",
+ 'blog:your' => "Your blog",
+ 'blog:posttitle' => "%s's blog: %s",
+ 'blog:friends' => "Friends' blogs",
+ 'blog:yourfriends' => "Your friends' latest blogs",
+ 'blog:everyone' => "All site blogs",
+
+ 'blog:read' => "Read blog",
+
+ 'blog:addpost' => "Write a blog post",
+ 'blog:editpost' => "Edit blog post",
+
+ 'blog:text' => "Blog text",
+
+ 'blog:strapline' => "%s",
+
+ 'item:object:blog' => 'Blog posts',
+
+
+ /**
+ * Blog river
+ **/
+
+ //generic terms to use
+ 'blog:river:created' => "%s wrote",
+ 'blog:river:updated' => "%s updated",
+ 'blog:river:posted' => "%s posted",
+
+ //these get inserted into the river links to take the user to the entity
+ 'blog:river:create' => "a new blog post.",
+ 'blog:river:update' => "a blog post.",
+ 'blog:river:annotate:create' => "a comment on a blog post.",
+
+
+ /**
+ * Status messages
+ */
+
+ 'blog:posted' => "Your blog post was successfully posted.",
+ 'blog:deleted' => "Your blog post was successfully deleted.",
+
+ /**
+ * Error messages
+ */
+
+ 'blog:save:failure' => "Your blog post could not be saved. Please try again.",
+ '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.",
+ 'blog:notdeleted' => "Sorry; we could not delete this blog post.",
+
+ );
+
+ add_translation("en",$english);
+
+?> \ No newline at end of file
diff --git a/mod/blog/manifest.xml b/mod/blog/manifest.xml
new file mode 100644
index 000000000..33e925fb7
--- /dev/null
+++ b/mod/blog/manifest.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin_manifest>
+ <field key="author" value="Ben Werdmuller" />
+ <field key="version" value="1.0" />
+ <field key="description" value="Elgg blog plugin" />
+ <field key="website" value="http://www.elgg.org/" />
+ <field key="copyright" value="(C) Curverider 2008" />
+</plugin_manifest>
diff --git a/mod/blog/read.php b/mod/blog/read.php
new file mode 100644
index 000000000..d26d2b01a
--- /dev/null
+++ b/mod/blog/read.php
@@ -0,0 +1,55 @@
+<?php
+
+ /**
+ * Elgg read blog post page
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ // Load Elgg engine
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+ // Get the specified blog post
+ $post = (int) get_input('blogpost');
+
+ // If we can get out the blog post ...
+ if ($blogpost = get_entity($post)) {
+
+ // Get any comments
+ $comments = $blogpost->getAnnotations('comments');
+
+ // Set the page owner
+ set_page_owner($blogpost->getOwner());
+ $page_owner = get_entity($blogpost->getOwner());
+
+ // Display it
+ $area2 = elgg_view("object/blog",array(
+ 'entity' => $blogpost,
+ 'entity_owner' => $page_owner,
+ 'comments' => $comments,
+ 'full' => true
+ ));
+
+ // Set the title appropriately
+ //$title = sprintf(elgg_echo("blog:posttitle"),$page_owner->name,$blogpost->title);
+
+ // Display through the correct canvas area
+ $body = elgg_view_layout("two_column_left_sidebar", '', $area1 . $area2);
+
+ // If we're not allowed to see the blog post
+ } else {
+
+ // Display the 'post not found' page instead
+ $body = elgg_view("blog/notfound");
+ $title = elgg_echo("blog:notfound");
+
+ }
+
+ // Display page
+ page_draw($title,$body);
+
+?> \ No newline at end of file
diff --git a/mod/blog/start.php b/mod/blog/start.php
new file mode 100644
index 000000000..6f952e881
--- /dev/null
+++ b/mod/blog/start.php
@@ -0,0 +1,174 @@
+<?php
+
+ /**
+ * Elgg blog plugin
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ /**
+ * Blog initialisation
+ *
+ * These parameters are required for the event API, but we won't use them:
+ *
+ * @param unknown_type $event
+ * @param unknown_type $object_type
+ * @param unknown_type $object
+ */
+
+ function blog_init() {
+
+ // Load system configuration
+ global $CONFIG;
+
+ // Load the language file
+ register_translations($CONFIG->pluginspath . "blog/languages/");
+
+ // Set up menu for logged in users
+ if (isloggedin()) {
+
+ add_menu(elgg_echo('blogs'), $CONFIG->wwwroot . "pg/blog/" . $_SESSION['user']->username);
+
+ // And for logged out users
+ } else {
+ add_menu(elgg_echo('blog'), $CONFIG->wwwroot . "mod/blog/everyone.php",array(
+ ));
+ }
+
+ // Extend system CSS with our own styles, which are defined in the blog/css view
+ extend_view('css','blog/css');
+
+ // Extend hover-over menu
+ extend_view('profile/menu/links','blog/menu');
+
+ // Register a page handler, so we can have nice URLs
+ register_page_handler('blog','blog_page_handler');
+
+ // Register a URL handler for blog posts
+ register_entity_url_handler('blog_url','object','blog');
+
+ // Register this plugin's object for sending pingbacks
+ register_plugin_hook('pingback:object:subtypes', 'object', 'blog_pingback_subtypes');
+
+ // Listen for new pingbacks
+ register_elgg_event_handler('create', 'object', 'blog_incoming_ping');
+
+ // Register entity type
+ register_entity_type('object','blog');
+ }
+
+ function blog_pagesetup() {
+
+ global $CONFIG;
+
+ //add submenu options
+ if (get_context() == "blog") {
+ if ((page_owner() == $_SESSION['guid'] || !page_owner()) && isloggedin()) {
+ add_submenu_item(elgg_echo('blog:your'),$CONFIG->wwwroot."pg/blog/" . $_SESSION['user']->username);
+ add_submenu_item(elgg_echo('blog:friends'),$CONFIG->wwwroot."pg/blog/" . $_SESSION['user']->username . "/friends/");
+ add_submenu_item(elgg_echo('blog:everyone'),$CONFIG->wwwroot."mod/blog/everyone.php");
+ add_submenu_item(elgg_echo('blog:addpost'),$CONFIG->wwwroot."mod/blog/add.php");
+ } else if (page_owner()) {
+ $page_owner = page_owner_entity();
+ add_submenu_item(sprintf(elgg_echo('blog:user'),$page_owner->name),$CONFIG->wwwroot."pg/blog/" . $page_owner->username);
+ if ($page_owner instanceof ElggUser) // Sorry groups, this isn't for you.
+ add_submenu_item(sprintf(elgg_echo('blog:user:friends'),$page_owner->name),$CONFIG->wwwroot."pg/blog/" . $page_owner->username . "/friends/");
+ add_submenu_item(elgg_echo('blog:everyone'),$CONFIG->wwwroot."mod/blog/everyone.php");
+ } else {
+ add_submenu_item(elgg_echo('blog:everyone'),$CONFIG->wwwroot."mod/blog/everyone.php");
+ }
+ }
+
+ }
+
+ /**
+ * Blog page handler; allows the use of fancy URLs
+ *
+ * @param array $page From the page_handler function
+ * @return true|false Depending on success
+ */
+ function blog_page_handler($page) {
+
+ // The first component of a blog URL is the username
+ if (isset($page[0])) {
+ set_input('username',$page[0]);
+ }
+
+ // The second part dictates what we're doing
+ if (isset($page[1])) {
+ switch($page[1]) {
+ case "read": set_input('blogpost',$page[2]);
+ @include(dirname(__FILE__) . "/read.php");
+ break;
+ case "friends": @include(dirname(__FILE__) . "/friends.php");
+ break;
+ }
+ // If the URL is just 'blog/username', or just 'blog/', load the standard blog index
+ } else {
+ @include(dirname(__FILE__) . "/index.php");
+ return true;
+ }
+
+ return false;
+
+ }
+
+ /**
+ * Populates the ->getUrl() method for blog objects
+ *
+ * @param ElggEntity $blogpost Blog post entity
+ * @return string Blog post URL
+ */
+ function blog_url($blogpost) {
+
+ global $CONFIG;
+ $title = $blogpost->title;
+ $title = friendly_title($title);
+ return $CONFIG->url . "pg/blog/" . $blogpost->getOwnerEntity()->username . "/read/" . $blogpost->getGUID() . "/" . $title;
+
+ }
+
+ /**
+ * This function adds 'blog' to the list of objects which will be looked for pingback urls.
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $returnvalue
+ * @param unknown_type $params
+ * @return unknown
+ */
+ function blog_pingback_subtypes($hook, $entity_type, $returnvalue, $params)
+ {
+ $returnvalue[] = 'blog';
+
+ return $returnvalue;
+ }
+
+ /**
+ * Listen to incoming pings, this parses an incoming target url - sees if its for me, and then
+ * either passes it back or prevents it from being created and attaches it as an annotation to a given
+ *
+ * @param unknown_type $event
+ * @param unknown_type $object_type
+ * @param unknown_type $object
+ */
+ function blog_incoming_ping($event, $object_type, $object)
+ {
+ // TODO: Get incoming ping object, see if its a ping on a blog and if so attach it as a comment
+ }
+
+ // Make sure the blog initialisation function is called on initialisation
+ register_elgg_event_handler('init','system','blog_init');
+ register_elgg_event_handler('pagesetup','system','blog_pagesetup');
+
+ // Register actions
+ global $CONFIG;
+ register_action("blog/add",false,$CONFIG->pluginspath . "blog/actions/add.php");
+ register_action("blog/edit",false,$CONFIG->pluginspath . "blog/actions/edit.php");
+ register_action("blog/delete",false,$CONFIG->pluginspath . "blog/actions/delete.php");
+
+?> \ No newline at end of file
diff --git a/mod/blog/views/default/blog/css.php b/mod/blog/views/default/blog/css.php
new file mode 100644
index 000000000..77a59baae
--- /dev/null
+++ b/mod/blog/views/default/blog/css.php
@@ -0,0 +1,96 @@
+<?php
+
+ /**
+ * Elgg blog CSS extender
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+?>
+
+
+.blog_post {
+ margin-bottom: 15px;
+ border-bottom: 1px solid #aaaaaa;
+}
+
+.blog_post_icon {
+ position: relative;
+ float:left;
+ margin:3px 0 0 0;
+ padding:0;
+}
+
+
+.blog_post h3 {
+ font-size: 150%;
+ margin-bottom: 5px;
+}
+
+.blog_post h3 a {
+ text-decoration: none;
+}
+
+.blog_post p {
+ margin: 0 0 5px 0;
+}
+
+.blog_post .strapline {
+ margin: 0 0 0 35px;
+ padding:0;
+ color: #aaa;
+ line-height:1em;
+}
+.blog_post p.tags {
+ background:transparent url(<?php echo $vars['url']; ?>_graphics/icon_tag.gif) no-repeat scroll left 2px;
+ margin:0 0 0 35px;
+ padding:0pt 0pt 0pt 16px;
+ min-height:22px;
+}
+.blog_post .options {
+ margin:0;
+ padding:0;
+}
+
+.blog_post_body img[align="left"] {
+ margin: 10px 10px 10px 0;
+ float:left;
+}
+.blog_post_body img[align="right"] {
+ margin: 10px 0 10px 10px;
+ float:right;
+}
+
+.blog-comments h3 {
+ font-size: 150%;
+ margin-bottom: 10px;
+}
+.blog-comment {
+ margin-top: 10px;
+ margin-bottom:20px;
+ border-bottom: 1px solid #aaaaaa;
+}
+.blog-comment img {
+ float:left;
+ margin: 0 10px 0 0;
+}
+.blog-comment-menu {
+ margin:0;
+}
+.blog-comment-byline {
+ background: #dddddd;
+ height:22px;
+ padding-top:3px;
+ margin:0;
+}
+.blog-comment-text {
+ margin:5px 0 5px 0;
+}
+
+
+
+
diff --git a/mod/blog/views/default/blog/forms/edit.php b/mod/blog/views/default/blog/forms/edit.php
new file mode 100644
index 000000000..79dca974f
--- /dev/null
+++ b/mod/blog/views/default/blog/forms/edit.php
@@ -0,0 +1,86 @@
+<?php
+
+ /**
+ * Elgg blog edit/add page
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ *
+ * @uses $vars['object'] Optionally, the blog post to edit
+ */
+
+ // Set title, form destination
+ if (isset($vars['entity'])) {
+ $title = sprintf(elgg_echo("blog:editpost"),$object->title);
+ $action = "blog/edit";
+ $title = $vars['entity']->title;
+ $body = $vars['entity']->description;
+ $tags = $vars['entity']->tags;
+ } else {
+ $title = elgg_echo("blog:addpost");
+ $action = "blog/add";
+ $tags = "";
+ $title = "";
+ $description = "";
+ }
+
+ // Just in case we have some cached details
+ if (isset($vars['blogtitle'])) {
+ $title = $vars['blogtitle'];
+ $body = $vars['blogbody'];
+ $tags = $vars['blogtags'];
+ }
+
+?>
+
+ <form action="<?php echo $vars['url']; ?>action/<?php echo $action; ?>" method="post">
+
+ <p>
+ <label><?php echo elgg_echo("title"); ?><br />
+ <?php
+
+ echo elgg_view("input/text", array(
+ "internalname" => "blogtitle",
+ "value" => $title,
+ ));
+
+ ?>
+ </label>
+ </p>
+ <p>
+ <label><?php echo elgg_echo("blog:text"); ?><br />
+ <?php
+
+ echo elgg_view("input/longtext",array(
+ "internalname" => "blogbody",
+ "value" => $body,
+ ));
+ ?>
+ </label>
+ </p>
+ <p>
+ <label><?php echo elgg_echo("tags"); ?><br />
+ <?php
+
+ echo elgg_view("input/tags", array(
+ "internalname" => "blogtags",
+ "value" => $tags,
+ ));
+
+ ?>
+ </p>
+ <p>
+ <?php
+
+ if (isset($vars['entity'])) {
+ ?><input type="hidden" name="blogpost" value="<?php echo $vars['entity']->getGUID(); ?>" /><?php
+ }
+
+ ?>
+ <input type="submit" name="submit" value="<?php echo elgg_echo('save'); ?>" />
+ </p>
+
+ </form> \ No newline at end of file
diff --git a/mod/blog/views/default/blog/gallery.php b/mod/blog/views/default/blog/gallery.php
new file mode 100644
index 000000000..0006ac890
--- /dev/null
+++ b/mod/blog/views/default/blog/gallery.php
@@ -0,0 +1,31 @@
+<?php
+
+ /**
+ * Elgg blog listing
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ $owner = $vars['entity']->getOwnerEntity();
+ $friendlytime = friendly_time($vars['entity']->time_created);
+ $icon = elgg_view(
+ "profile/icon", array(
+ 'entity' => $owner,
+ 'size' => 'small',
+ )
+ );
+ $info = "<p>" . elgg_echo('blog') . ": <a href=\"{$vars['entity']->getURL()}\">{$vars['entity']->title}</a></p>";
+ $info .= "<p><a href=\"{$owner->getURL()}\">{$owner->name}</a> {$friendlytime}</p>";
+
+ //display
+ echo "<div class=\"blog_gallery\">";
+ echo "<div class=\"blog_gallery_icon\">" . $icon . "</div>";
+ echo "<div class=\"blog_gallery_content\">" . $info . "</div>";
+ echo "</div>";
+
+
+?> \ No newline at end of file
diff --git a/mod/blog/views/default/blog/listing.php b/mod/blog/views/default/blog/listing.php
new file mode 100644
index 000000000..13631cca0
--- /dev/null
+++ b/mod/blog/views/default/blog/listing.php
@@ -0,0 +1,25 @@
+<?php
+
+ /**
+ * Elgg blog listing
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ $owner = $vars['entity']->getOwnerEntity();
+ $friendlytime = friendly_time($vars['entity']->time_created);
+ $icon = elgg_view(
+ "profile/icon", array(
+ 'entity' => $owner,
+ 'size' => 'small',
+ )
+ );
+ $info = "<p>" . elgg_echo('blog') . ": <a href=\"{$vars['entity']->getURL()}\">{$vars['entity']->title}</a></p>";
+ $info .= "<p class=\"owner_timestamp\"><a href=\"{$owner->getURL()}\">{$owner->name}</a> {$friendlytime}</p>";
+ echo elgg_view_listing($icon,$info);
+
+?> \ No newline at end of file
diff --git a/mod/blog/views/default/blog/menu.php b/mod/blog/views/default/blog/menu.php
new file mode 100644
index 000000000..3a4b9f8bd
--- /dev/null
+++ b/mod/blog/views/default/blog/menu.php
@@ -0,0 +1,17 @@
+<?php
+
+ /**
+ * Elgg hoverover extender for blog
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+?>
+
+ <p class="user_menu_blog">
+ <a href="<?php echo $vars['url']; ?>pg/blog/<?php echo $vars['entity']->username; ?>"><?php echo elgg_echo("blog"); ?></a>
+ </p> \ No newline at end of file
diff --git a/mod/blog/views/default/blog/notfound.php b/mod/blog/views/default/blog/notfound.php
new file mode 100644
index 000000000..76fc5368c
--- /dev/null
+++ b/mod/blog/views/default/blog/notfound.php
@@ -0,0 +1,21 @@
+<?php
+
+ /**
+ * Elgg blog not found page
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+?>
+
+ <p>
+ <?php
+
+ echo elgg_echo("blog:notfound");
+
+ ?>
+ </p> \ No newline at end of file
diff --git a/mod/blog/views/default/blog/view.php b/mod/blog/views/default/blog/view.php
new file mode 100644
index 000000000..616468280
--- /dev/null
+++ b/mod/blog/views/default/blog/view.php
@@ -0,0 +1,26 @@
+<?php
+
+ /**
+ * Elgg blog view page
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ *
+ * @uses $vars['posts'] An array of posts to view
+ */
+
+ // If there are any posts to view, view them
+ if (is_array($vars['posts']) && sizeof($vars['posts']) > 0) {
+
+ foreach($vars['posts'] as $post) {
+
+ echo elgg_view_entity($post);
+
+ }
+
+ }
+
+?> \ No newline at end of file
diff --git a/mod/blog/views/default/object/blog.php b/mod/blog/views/default/object/blog.php
new file mode 100644
index 000000000..202be6340
--- /dev/null
+++ b/mod/blog/views/default/object/blog.php
@@ -0,0 +1,115 @@
+<?php
+
+ /**
+ * Elgg blog individual post view
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Ben Werdmuller <ben@curverider.co.uk>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ *
+ * @uses $vars['entity'] Optionally, the blog post to view
+ */
+
+ if (isset($vars['entity'])) {
+
+ if (get_context() == "search") {
+
+ //display the correct layout depending on gallery or list view
+ if (get_input('search_viewtype') == "gallery") {
+
+ //display the gallery view
+ echo elgg_view("blog/gallery",$vars);
+
+ } else {
+
+ echo elgg_view("blog/listing",$vars);
+
+ }
+
+
+ } else {
+
+?>
+
+ <div class="blog_post">
+ <h3><a href="<?php echo $vars['entity']->getURL(); ?>"><?php echo $vars['entity']->title; ?></a></h3>
+ <!-- display the user icon -->
+ <div class="blog_post_icon">
+ <?php
+ echo elgg_view("profile/icon",array('entity' => $vars['entity']->getOwnerEntity(), 'size' => 'tiny'));
+ ?>
+ </div>
+ <p class="strapline">
+ <?php
+
+ echo sprintf(elgg_echo("blog:strapline"),
+ date("F j, Y",$vars['entity']->time_created)
+ );
+
+ ?>
+ <?php echo elgg_echo('by'); ?> <a href="<?php echo $vars['url']; ?>pg/blog/<?php echo $vars['entity']->getOwnerEntity()->username; ?>"><?php echo $vars['entity']->getOwnerEntity()->name; ?></a> &nbsp;
+ <!-- display the comments link -->
+ <?php
+ //get the number of comments
+ $num_comments = elgg_count_comments($vars['entity']);
+ ?>
+ <a href="<?php echo $vars['entity']->getURL(); ?>"><?php echo sprintf(elgg_echo("comments")) . " (" . $num_comments . ")"; ?></a><br />
+ </p>
+ <!-- display tags -->
+ <p class="tags">
+ <?php
+
+ echo elgg_view('output/tags', array('tags' => $vars['entity']->tags));
+
+ ?>
+ </p>
+ <div class="blog_post_body">
+
+ <!-- display the actual blog post -->
+ <?php
+
+ echo autop($vars['entity']->description);
+
+ ?>
+ </div>
+ <!-- display edit options if it is the blog post owner -->
+ <p class="options">
+ <?php
+
+ if ($vars['entity']->canEdit()) {
+
+ ?>
+ <a href="<?php echo $vars['url']; ?>mod/blog/edit.php?blogpost=<?php echo $vars['entity']->getGUID(); ?>"><?php echo elgg_echo("edit"); ?></a> &nbsp;
+ <?php
+
+ echo elgg_view("output/confirmlink", array(
+ 'href' => $vars['url'] . "action/blog/delete?blogpost=" . $vars['entity']->getGUID(),
+ 'text' => elgg_echo('delete'),
+ 'confirm' => elgg_echo('deleteconfirm'),
+ ));
+
+ // Allow the menu to be extended
+ echo elgg_view("editmenu",array('entity' => $vars['entity']));
+
+ ?>
+ <?php
+ }
+
+ ?>
+ </p>
+ </div>
+
+<?php
+
+ // If we've been asked to display the full view
+ if (isset($vars['full']) && $vars['full'] == true) {
+ echo elgg_view_comments($vars['entity']);
+ }
+
+ }
+
+ }
+
+?> \ No newline at end of file
diff --git a/mod/blog/views/default/river/blog/annotate.php b/mod/blog/views/default/river/blog/annotate.php
new file mode 100644
index 000000000..a977c296b
--- /dev/null
+++ b/mod/blog/views/default/river/blog/annotate.php
@@ -0,0 +1,13 @@
+<?php
+
+ $statement = $vars['statement'];
+ $performed_by = $statement->getSubject();
+ $object = $statement->getObject();
+
+ $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
+ $string = sprintf(elgg_echo("blog:river:posted"),$url) . " ";
+ $string .= "<a href=\"" . $object->getURL() . "\">" . elgg_echo("blog:river:annotate:create") . "</a>";
+
+?>
+
+<?php echo $string; ?> \ No newline at end of file
diff --git a/mod/blog/views/default/river/blog/create.php b/mod/blog/views/default/river/blog/create.php
new file mode 100644
index 000000000..2a4c19397
--- /dev/null
+++ b/mod/blog/views/default/river/blog/create.php
@@ -0,0 +1,13 @@
+<?php
+
+ $statement = $vars['statement'];
+ $performed_by = $statement->getSubject();
+ $object = $statement->getObject();
+
+ $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
+ $string = sprintf(elgg_echo("blog:river:created"),$url) . " ";
+ $string .= "<a href=\"" . $object->getURL() . "\">" . elgg_echo("blog:river:create") . "</a>";
+
+?>
+
+<?php echo $string; ?> \ No newline at end of file
diff --git a/mod/blog/views/default/river/blog/update.php b/mod/blog/views/default/river/blog/update.php
new file mode 100644
index 000000000..afdfb44f0
--- /dev/null
+++ b/mod/blog/views/default/river/blog/update.php
@@ -0,0 +1,13 @@
+<?php
+
+ $statement = $vars['statement'];
+ $performed_by = $statement->getSubject();
+ $object = $statement->getObject();
+
+ $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
+ $string = sprintf(elgg_echo("blog:river:updated"),$url) . " ";
+ $string .= "<a href=\"" . $object->getURL() . "\">" . elgg_echo("blog:river:update") . "</a>";
+
+?>
+
+<?php echo $string; ?> \ No newline at end of file