aboutsummaryrefslogtreecommitdiff
path: root/mod/blog
diff options
context:
space:
mode:
Diffstat (limited to 'mod/blog')
-rw-r--r--mod/blog/actions/add.php84
-rw-r--r--mod/blog/actions/delete.php38
-rw-r--r--mod/blog/actions/edit.php86
-rw-r--r--mod/blog/add.php36
-rw-r--r--mod/blog/archive.php50
-rw-r--r--mod/blog/edit.php41
-rw-r--r--mod/blog/everyone.php37
-rw-r--r--mod/blog/friends.php47
-rw-r--r--mod/blog/index.php53
-rw-r--r--mod/blog/languages/en.php81
-rw-r--r--mod/blog/manifest.xml10
-rw-r--r--mod/blog/preview.php47
-rw-r--r--mod/blog/read.php59
-rw-r--r--mod/blog/savedraft.php26
-rw-r--r--mod/blog/start.php283
-rw-r--r--mod/blog/views/default/blog/categorylist.php14
-rw-r--r--mod/blog/views/default/blog/css.php210
-rw-r--r--mod/blog/views/default/blog/forms/edit.php200
-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/previewpane.php6
-rw-r--r--mod/blog/views/default/blog/view.php26
-rw-r--r--mod/blog/views/default/object/blog.php150
-rw-r--r--mod/blog/views/default/river/object/blog/annotate.php13
-rw-r--r--mod/blog/views/default/river/object/blog/create.php20
-rw-r--r--mod/blog/views/default/river/object/blog/update.php13
28 files changed, 1724 insertions, 0 deletions
diff --git a/mod/blog/actions/add.php b/mod/blog/actions/add.php
new file mode 100644
index 000000000..97634638e
--- /dev/null
+++ b/mod/blog/actions/add.php
@@ -0,0 +1,84 @@
+<?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-2010
+ * @link http://elgg.org/
+ */
+
+ // Make sure we're logged in (send us to the front page if not)
+ gatekeeper();
+
+ // Get input data
+ $title = get_input('blogtitle');
+ $body = get_input('blogbody');
+ $tags = get_input('blogtags');
+ $access = get_input('access_id');
+ $comments_on = get_input('comments_select','Off');
+
+ // Cache to the session
+ $_SESSION['user']->blogtitle = $title;
+ $_SESSION['user']->blogbody = $body;
+ $_SESSION['user']->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($_SERVER['HTTP_REFERER']);
+ }
+
+
+ // 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 = get_loggedin_userid();
+ // Set it's container
+ $blog->container_guid = (int)get_input('container_guid', get_loggedin_userid());
+ // For now, set its access
+ $blog->access_id = $access;
+ // Set its title and description appropriately
+ $blog->title = $title;
+ $blog->description = $body;
+ // Now let's add tags. We can pass an array directly to the object property! Easy.
+ if (is_array($tagarray)) {
+ $blog->tags = $tagarray;
+ }
+ //whether the user wants to allow comments or not on the blog post
+ $blog->comments_on = $comments_on;
+
+ // Now save the object
+ if (!$blog->save()) {
+ register_error(elgg_echo("blog:error"));
+ forward($_SERVER['HTTP_REFERER']);
+ }
+
+ // Success message
+ system_message(elgg_echo("blog:posted"));
+ // add to river
+ add_to_river('river/object/blog/create', 'create', get_loggedin_userid(), $blog->guid);
+ // Remove the blog post cache
+ //unset($_SESSION['blogtitle']); unset($_SESSION['blogbody']); unset($_SESSION['blogtags']);
+ remove_metadata($_SESSION['user']->guid,'blogtitle');
+ remove_metadata($_SESSION['user']->guid,'blogbody');
+ remove_metadata($_SESSION['user']->guid,'blogtags');
+
+ // Forward to the main blog page
+ $page_owner = get_entity($blog->container_guid);
+ if ($page_owner instanceof ElggUser) {
+ $username = $page_owner->username;
+ } else if ($page_owner instanceof ElggGroup) {
+ $username = "group:" . $page_owner->guid;
+ }
+
+ forward("pg/blog/$username");
+
+?>
diff --git a/mod/blog/actions/delete.php b/mod/blog/actions/delete.php
new file mode 100644
index 000000000..c01ca3844
--- /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-2010
+ * @link http://elgg.org/
+ */
+
+ // Make sure we're logged in (send us to the front page if not)
+ gatekeeper();
+
+ // 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..b44106645
--- /dev/null
+++ b/mod/blog/actions/edit.php
@@ -0,0 +1,86 @@
+<?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-2010
+ * @link http://elgg.org/
+ */
+
+ // Make sure we're logged in (send us to the front page if not)
+ gatekeeper();
+
+ // Get input data
+ $guid = (int) get_input('blogpost');
+ $title = get_input('blogtitle');
+ $body = get_input('blogbody');
+ $access = get_input('access_id');
+ $tags = get_input('blogtags');
+ $comments_on = get_input('comments_select','Off');
+
+ // Make sure we actually have permission to edit
+ $blog = get_entity($guid);
+ if ($blog->getSubtype() == "blog" && $blog->canEdit()) {
+
+ // Cache to the session
+
+ $_SESSION['user']->blogtitle = $title;
+ $_SESSION['user']->blogbody = $body;
+ $_SESSION['user']->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 = $access;
+ // 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;
+ }
+
+ $blog->comments_on = $comments_on; //whether the users wants to allow comments or not on the blog post
+
+ // Success message
+ system_message(elgg_echo("blog:posted"));
+ //add to the river
+ add_to_river('river/object/blog/update','update',$_SESSION['user']->guid,$blog->guid);
+ // Remove the blog post cache
+ //unset($_SESSION['blogtitle']); unset($_SESSION['blogbody']); unset($_SESSION['blogtags']);
+ remove_metadata($_SESSION['user']->guid,'blogtitle');
+ remove_metadata($_SESSION['user']->guid,'blogbody');
+ remove_metadata($_SESSION['user']->guid,'blogtags');
+ // Forward to the main blog page
+ $page_owner = get_entity($blog->container_guid);
+ if ($page_owner instanceof ElggUser)
+ $username = $page_owner->username;
+ else if ($page_owner instanceof ElggGroup)
+ $username = "group:" . $page_owner->guid;
+ forward("pg/blog/$username");
+
+ }
+
+ }
+
+?>
diff --git a/mod/blog/add.php b/mod/blog/add.php
new file mode 100644
index 000000000..cb3a3fc93
--- /dev/null
+++ b/mod/blog/add.php
@@ -0,0 +1,36 @@
+<?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-2010
+ * @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']);
+ }
+ if ($page_owner instanceof ElggGroup)
+ $container = $page_owner->guid;
+
+ //set the title
+ $area1 = elgg_view_title(elgg_echo('blog:addpost'));
+
+ // Get the form
+ $area1 .= elgg_view("blog/forms/edit", array('container_guid' => $container));
+
+ // Display page
+ page_draw(elgg_echo('blog:addpost'),elgg_view_layout("edit_layout", $area1));
+
+
+?> \ No newline at end of file
diff --git a/mod/blog/archive.php b/mod/blog/archive.php
new file mode 100644
index 000000000..a1a6a528e
--- /dev/null
+++ b/mod/blog/archive.php
@@ -0,0 +1,50 @@
+<?php
+
+ /**
+ * Elgg blog archive 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-2010
+ * @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']);
+ }
+
+ // Get timestamp upper and lower bounds
+ $timelower = (int) get_input('param2');
+ $timeupper = (int) get_input('param3');
+ if (empty($timelower)) {
+ forward('pg/blog/'.$page_owner->username);
+ exit;
+ }
+ if (empty($timeupper)) {
+ $timeupper = $timelower + (86400 * 30);
+ }
+
+ // Set blog title
+ $area2 = elgg_view_title(sprintf(elgg_echo('date:month:'.date('m',$timelower)),date('Y',$timelower)));
+
+ // Get a list of blog posts
+ $area2 .= list_user_objects($page_owner->getGUID(),'blog',10,false,false,true,$timelower,$timeupper);
+
+ // Get blog tags
+
+ // Get blog categories
+
+ // 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/edit.php b/mod/blog/edit.php
new file mode 100644
index 000000000..fbaf79108
--- /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-2010
+ * @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()) {
+
+ $area1 = elgg_view_title(elgg_echo('blog:editpost'));
+ $area1 .= elgg_view("blog/forms/edit", array('entity' => $post));
+ $body = elgg_view_layout("edit_layout", $area1);
+
+ }
+
+ }
+
+ // 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..47d22f35b
--- /dev/null
+++ b/mod/blog/everyone.php
@@ -0,0 +1,37 @@
+<?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-2010
+ * @link http://elgg.com/
+ */
+
+ // Load Elgg engine
+ define('everyoneblog','true');
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+// Get the current page's owner
+ $page_owner = $_SESSION['user'];
+ set_page_owner($_SESSION['guid']);
+
+ $area2 = elgg_view_title(elgg_echo('blog:everyone'));
+
+ $area2 .= "<div id='blogs'>" . elgg_list_entities(array('type' => 'object', 'subtype' => 'blog', 'limit' => 10, 'full_view' => FALSE)) . "<div class='clearfloat'></div></div>";
+
+ // get tagcloud
+ // $area3 = "This will be a tagcloud for all blog posts";
+
+ // Get categories, if they're installed
+ global $CONFIG;
+ $area3 = elgg_view('blog/categorylist',array('baseurl' => $CONFIG->wwwroot . 'search/?subtype=blog&tagtype=universal_categories&tag=','subtype' => 'blog'));
+
+ $body = elgg_view_layout("two_column_left_sidebar", '', $area2, $area3);
+
+ // 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..2cef9c9e8
--- /dev/null
+++ b/mod/blog/friends.php
@@ -0,0 +1,47 @@
+<?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-2010
+ * @link http://elgg.com/
+ */
+
+ // Load Elgg engine
+ define('everyoneblog','true');
+ 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']){
+ $title = elgg_echo('blog:yourfriends');
+ }else{
+ $title = $page_owner->name . "'s " . elgg_echo('blog:friends');
+ }
+
+ $area2 = elgg_view_title($title);
+
+ // Get a list of blog posts
+ $area2 .= "<div id='blogs'>" . list_user_friends_objects($page_owner->getGUID(),'blog',10,false) . "<div class='clearfloat'></div></div>";
+
+ // Get categories, if they're installed
+ global $CONFIG;
+ $area3 = elgg_view('blog/categorylist',array('baseurl' => $CONFIG->wwwroot . 'search/?subtype=blog&owner_guid='.$page_owner->guid.'&friends='.$page_owner->guid.'&tagtype=universal_categories&tag=','subtype' => 'blog'));
+
+ // Display them in the page
+ $body = elgg_view_layout("two_column_left_sidebar", '', $area1 . $area2, $area3);
+
+ // Display page
+ page_draw($title, $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..7c23e4089
--- /dev/null
+++ b/mod/blog/index.php
@@ -0,0 +1,53 @@
+<?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-2010
+ * @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)) {
+
+ // guess that logged in user is the owner - if no logged in send to all blogs page
+ if (!isloggedin()) {
+ forward('mod/blog/everyone.php');
+ }
+
+ $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 .= "<div id=\"blogs\">";
+ $area2 .= elgg_list_entities(array('type' => 'object', 'subtype' => 'blog', 'container_guid' => page_owner(), 'limit' => 10, 'full_view' => FALSE, 'view_type_toggle' => FALSE));
+ $area2 .= "<div class='clearfloat'></div></div>";
+
+ // Get blog tags
+
+ // Get categories, if they're installed
+ global $CONFIG;
+ $area3 = elgg_view('blog/categorylist',array('baseurl' => $CONFIG->wwwroot . 'search/?subtype=blog&owner_guid='.$page_owner->guid.'&tagtype=universal_categories&tag=','subtype' => 'blog', 'owner_guid' => $page_owner->guid));
+
+ // Display them in the page
+ $body = elgg_view_layout("two_column_left_sidebar", '', $area1 . $area2, $area3);
+
+ // 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..9496cee00
--- /dev/null
+++ b/mod/blog/languages/en.php
@@ -0,0 +1,81 @@
+<?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:newpost' => "New blog post",
+ 'blog:via' => "via blog",
+ '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:never' => 'never',
+ 'blog:preview' => 'Preview',
+
+ 'blog:draft:save' => 'Save draft',
+ 'blog:draft:saved' => 'Draft last saved',
+ 'blog:comments:allow' => 'Allow comments',
+
+ 'blog:preview:description' => 'This is an unsaved preview of your blog post.',
+ 'blog:preview:description:link' => 'To continue editing or save your post, click here.',
+
+ 'blog:enableblog' => 'Enable group blog',
+
+ 'blog:group' => 'Group blog',
+
+ /**
+ * 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 titled",
+ 'blog:river:update' => "a blog post titled",
+ 'blog:river:annotate' => "a comment on this blog post",
+
+
+ /**
+ * Status messages
+ */
+
+ 'blog:posted' => "Your blog post was successfully posted.",
+ 'blog:deleted' => "Your blog post was successfully deleted.",
+
+ /**
+ * Error messages
+ */
+
+ 'blog:error' => 'Something went wrong. Please try again.',
+ '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..98c22b76f
--- /dev/null
+++ b/mod/blog/manifest.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin_manifest>
+ <field key="author" value="Curverider" />
+ <field key="version" value="1.7" />
+ <field key="description" value="Elgg blog plugin" />
+ <field key="website" value="http://www.elgg.org/" />
+ <field key="copyright" value="(C) Curverider 2008-2010" />
+ <field key="licence" value="GNU Public License version 2" />
+ <field key="elgg_version" value="2010030101" />
+</plugin_manifest>
diff --git a/mod/blog/preview.php b/mod/blog/preview.php
new file mode 100644
index 000000000..88d293487
--- /dev/null
+++ b/mod/blog/preview.php
@@ -0,0 +1,47 @@
+<?php
+
+ /**
+ * Elgg blog: preview 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-2010
+ * @link http://elgg.org/
+ */
+
+ require_once(dirname(dirname(dirname(__FILE__))).'/engine/start.php');
+
+ // Make sure we're logged in (send us to the front page if not)
+ gatekeeper();
+
+ // Get input data
+
+ $blogpost = new stdClass;
+ $blogpost->title = get_input('blogtitle');
+ $blogpost->description = get_input('blogbody');
+ $blogpost->tags = get_input('blogtags');
+ $blogpost->access = get_input('access_id');
+ $blogpost->comments_on = get_input('comments_select');
+ $blogpost->time_created = time();
+
+ // Convert string of tags into a preformatted array
+ $blogpost->tags = string_to_tag_array($blogpost->tags);
+
+ // Display it
+ $area2 = elgg_view("blog/previewpane") .
+ elgg_view("object/blog",array(
+ 'entity' => $blogpost,
+ 'entity_owner' => $_SESSION['user']->guid,
+ 'comments' => false,
+ 'full' => true
+ ));
+
+ // Set the title appropriately
+ $title = sprintf(elgg_echo("blog:posttitle"),$_SESSION['user']->name,$blogpost->title);
+
+ // Display through the correct canvas area
+ $body = elgg_view_layout("two_column_left_sidebar", '', $area1 . $area2);
+ page_draw($blogpost->title,$body);
+
+?>
diff --git a/mod/blog/read.php b/mod/blog/read.php
new file mode 100644
index 000000000..7be396759
--- /dev/null
+++ b/mod/blog/read.php
@@ -0,0 +1,59 @@
+<?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-2010
+ * @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
+ if ($blogpost->container_guid) {
+ set_page_owner($blogpost->container_guid);
+ } else {
+ set_page_owner($blogpost->owner_guid);
+ }
+
+ // Display it
+ $area2 = elgg_view_entity($blogpost, true);
+ /*$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/savedraft.php b/mod/blog/savedraft.php
new file mode 100644
index 000000000..fd8197abd
--- /dev/null
+++ b/mod/blog/savedraft.php
@@ -0,0 +1,26 @@
+<?php
+
+ /**
+ * Elgg blog autosaver
+ *
+ * @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-2010
+ * @link http://elgg.com/
+ */
+
+ // Load engine
+ require_once(dirname(dirname(dirname(__FILE__))) . '/engine/start.php');
+ gatekeeper();
+
+ // Get input data
+ $title = $_POST['blogtitle'];
+ $body = $_POST['blogbody'];
+ $tags = $_POST['blogtags'];
+
+ $_SESSION['user']->blogtitle = $title;
+ $_SESSION['user']->blogbody = $body;
+ $_SESSION['user']->blogtags = $tags;
+
+?> \ No newline at end of file
diff --git a/mod/blog/start.php b/mod/blog/start.php
new file mode 100644
index 000000000..358c0f014
--- /dev/null
+++ b/mod/blog/start.php
@@ -0,0 +1,283 @@
+<?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-2010
+ * @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;
+
+ // 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('blogs'), $CONFIG->wwwroot . "mod/blog/everyone.php");
+ }
+
+ // Extend system CSS with our own styles, which are defined in the blog/css view
+ elgg_extend_view('css','blog/css');
+
+ // Extend hover-over menu
+ elgg_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');
+
+ // Register granular notification for this type
+ if (is_callable('register_notification_object'))
+ register_notification_object('object', 'blog', elgg_echo('blog:newpost'));
+
+ // Listen to notification events and supply a more useful message
+ register_plugin_hook('notify:entity:message', 'object', 'blog_notify_message');
+
+
+ // Listen for new pingbacks
+ register_elgg_event_handler('create', 'object', 'blog_incoming_ping');
+
+ // Register entity type
+ register_entity_type('object','blog');
+
+ // Register an annotation handler for comments etc
+ register_plugin_hook('entity:annotate', 'object', 'blog_annotate_comments');
+
+ // Add group menu option
+ add_group_tool_option('blog',elgg_echo('blog:enableblog'),true);
+ }
+
+ function blog_pagesetup() {
+
+ global $CONFIG;
+
+ //add submenu options
+ if (get_context() == "blog") {
+ $page_owner = page_owner_entity();
+
+ 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");
+
+ } else if (page_owner()) {
+ 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");
+ }
+
+ if (can_write_to_container(0, page_owner()) && isloggedin())
+ add_submenu_item(elgg_echo('blog:addpost'),$CONFIG->wwwroot."pg/blog/{$page_owner->username}/new/");
+
+ if (!defined('everyoneblog') && page_owner()) {
+
+ if ($dates = get_entity_dates('object','blog',page_owner())) {
+ foreach($dates as $date) {
+ $timestamplow = mktime(0,0,0,substr($date,4,2),1,substr($date,0,4));
+ $timestamphigh = mktime(0,0,0,((int) substr($date,4,2)) + 1,1,substr($date,0,4));
+ if (!isset($page_owner)) $page_owner = page_owner_entity();
+ $link = $CONFIG->wwwroot . 'pg/blog/' . $page_owner->username . '/archive/' . $timestamplow . '/' . $timestamphigh;
+ add_submenu_item(sprintf(elgg_echo('date:month:'.substr($date,4,2)),substr($date,0,4)),$link,'filter');
+ }
+ }
+
+ }
+
+ }
+
+ // Group submenu
+ $page_owner = page_owner_entity();
+
+ if ($page_owner instanceof ElggGroup && get_context() == 'groups') {
+ if($page_owner->blog_enable != "no"){
+ add_submenu_item(sprintf(elgg_echo("blog:group"),$page_owner->name), $CONFIG->wwwroot . "pg/blog/" . $page_owner->username );
+ }
+ }
+ }
+
+ /**
+ * 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]);
+ }
+
+ // In case we have further input
+ if (isset($page[2])) {
+ set_input('param2',$page[2]);
+ }
+ // In case we have further input
+ if (isset($page[3])) {
+ set_input('param3',$page[3]);
+ }
+
+ // 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"); return true;
+ break;
+ case "archive": include(dirname(__FILE__) . "/archive.php"); return true;
+ break;
+ case "friends": include(dirname(__FILE__) . "/friends.php"); return true;
+ break;
+ case "new": include(dirname(__FILE__) . "/add.php"); return true;
+ 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;
+
+ }
+
+ /**
+ * Hook into the framework and provide comments on blog entities.
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $returnvalue
+ * @param unknown_type $params
+ * @return unknown
+ */
+ function blog_annotate_comments($hook, $entity_type, $returnvalue, $params)
+ {
+ $entity = $params['entity'];
+ $full = $params['full'];
+
+ if (
+ ($entity instanceof ElggEntity) && // Is the right type
+ ($entity->getSubtype() == 'blog') && // Is the right subtype
+ ($entity->comments_on!='Off') && // Comments are enabled
+ ($full) // This is the full view
+ )
+ {
+ // Display comments
+ return elgg_view_comments($entity);
+ }
+
+ }
+
+ /**
+ * Returns a more meaningful message
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $entity_type
+ * @param unknown_type $returnvalue
+ * @param unknown_type $params
+ */
+ function blog_notify_message($hook, $entity_type, $returnvalue, $params)
+ {
+ $entity = $params['entity'];
+ $to_entity = $params['to_entity'];
+ $method = $params['method'];
+ if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'blog'))
+ {
+ $descr = $entity->description;
+ $title = $entity->title;
+ if ($method == 'sms') {
+ $owner = $entity->getOwnerEntity();
+ return $owner->name . ' via blog: ' . $title;
+ }
+ if ($method == 'email') {
+ $owner = $entity->getOwnerEntity();
+ return $owner->name . ' via blog: ' . $title . "\n\n" . $descr . "\n\n" . $entity->getURL();
+ }
+ }
+ return null;
+ }
+
+
+ /**
+ * 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/categorylist.php b/mod/blog/views/default/blog/categorylist.php
new file mode 100644
index 000000000..90403c550
--- /dev/null
+++ b/mod/blog/views/default/blog/categorylist.php
@@ -0,0 +1,14 @@
+<?php
+ $list = elgg_view('categories/list',$vars);
+ if (!empty($list)) {
+?>
+
+ <div class="blog_categories">
+ <?php echo $list; ?>
+ </div>
+
+<?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..c9522c901
--- /dev/null
+++ b/mod/blog/views/default/blog/css.php
@@ -0,0 +1,210 @@
+<?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-2010
+ * @link http://elgg.com/
+ */
+
+?>
+#blogs .pagination {
+ margin:5px 10px 0 10px;
+ padding:5px;
+ display:block;
+}
+#blogs #two_column_left_sidebar_maincontent {
+ padding-bottom:10px;
+}
+
+.singleview {
+ margin-top:10px;
+}
+
+.blog_post_icon {
+ float:left;
+ margin:3px 0 0 0;
+ padding:0;
+}
+
+.blog_post h3 {
+ font-size: 150%;
+ margin:0 0 10px 0;
+ padding:0;
+}
+
+.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 7px 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_post_body img {
+ margin: 10px !important;
+}
+
+.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;
+}
+
+/* New blog edit column */
+#blog_edit_page {
+ /* background: #bbdaf7; */
+ margin-top:-10px;
+}
+#blog_edit_page #content_area_user_title h2 {
+ background: none;
+ border-top: none;
+ margin:0 0 10px 0px;
+ padding:0px 0 0 0;
+}
+#blog_edit_page #blog_edit_sidebar #content_area_user_title h2 {
+ background:none;
+ border-top:none;
+ margin:inherit;
+ padding:0 0 5px 5px;
+ font-size:1.25em;
+ line-height:1.2em;
+}
+#blog_edit_page #blog_edit_sidebar {
+ margin:0px 0 22px 0;
+ background: #dedede;
+ padding:5px;
+ -webkit-border-radius: 8px;
+ -moz-border-radius: 8px;
+ border-bottom:1px solid #cccccc;
+ border-right:1px solid #cccccc;
+}
+#blog_edit_page #two_column_left_sidebar_210 {
+ width:210px;
+ margin:0px 0 20px 0px;
+ min-height:360px;
+ float:left;
+ padding:0;
+}
+#blog_edit_page #two_column_left_sidebar_maincontent {
+ margin:0 0px 20px 20px;
+ padding:10px 20px 20px 20px;
+ width:670px;
+ background: #bbdaf7;
+}
+/* unsaved blog post preview */
+.blog_previewpane {
+ border:1px solid #D3322A;
+ background:#F7DAD8;
+ padding:10px;
+ margin:10px;
+ -webkit-border-radius: 8px;
+ -moz-border-radius: 8px;
+}
+.blog_previewpane p {
+ margin:0;
+}
+
+#blog_edit_sidebar .publish_controls,
+#blog_edit_sidebar .blog_access,
+#blog_edit_sidebar .publish_options,
+#blog_edit_sidebar .publish_blog,
+#blog_edit_sidebar .allow_comments,
+#blog_edit_sidebar .categories {
+ margin:0 5px 5px 5px;
+ border-top:1px solid #cccccc;
+}
+#blog_edit_page ul {
+ padding-left:0px;
+ margin:5px 0 5px 0;
+ list-style: none;
+}
+#blog_edit_page p {
+ margin:5px 0 5px 0;
+}
+#blog_edit_page #two_column_left_sidebar_maincontent p {
+ margin:0 0 15px 0;
+}
+#blog_edit_page .publish_blog input[type="submit"] {
+ font-weight: bold;
+ padding:2px;
+ height:auto;
+}
+#blog_edit_page .preview_button a {
+ font: 12px/100% Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ background:white;
+ border: 1px solid #cccccc;
+ color:#999999;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ width: auto;
+ height: auto;
+ padding: 3px;
+ margin:1px 1px 5px 10px;
+ cursor: pointer;
+ float:right;
+}
+#blog_edit_page .preview_button a:hover {
+ background:#4690D6;
+ color:white;
+ text-decoration: none;
+ border: 1px solid #4690D6;
+}
+#blog_edit_page .allow_comments label {
+ font-size: 100%;
+}
+
+
+
+
+
+
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..d3f4d7e52
--- /dev/null
+++ b/mod/blog/views/default/blog/forms/edit.php
@@ -0,0 +1,200 @@
+<?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-2010
+ * @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;
+ if ($vars['entity']->comments_on == 'Off') {
+ $comments_on = false;
+ } else {
+ $comments_on = true;
+ }
+ $access_id = $vars['entity']->access_id;
+ } else {
+ $title = elgg_echo("blog:addpost");
+ $action = "blog/add";
+ $tags = "";
+ $title = "";
+ $comments_on = true;
+ $description = "";
+ if (defined('ACCESS_DEFAULT'))
+ $access_id = ACCESS_DEFAULT;
+ else
+ $access_id = 0;
+
+ $container = $vars['container_guid'] ? elgg_view('input/hidden', array('internalname' => 'container_guid', 'value' => $vars['container_guid'])) : "";
+ }
+
+ // Just in case we have some cached details
+ if (empty($body)) {
+ $body = $vars['user']->blogbody;
+ if (!empty($body)) {
+ $title = $vars['user']->blogtitle;
+ $tags = $vars['user']->blogtags;
+ }
+ }
+
+ // set the required variables
+
+ $title_label = elgg_echo('title');
+ $title_textbox = elgg_view('input/text', array('internalname' => 'blogtitle', 'value' => $title));
+ $text_label = elgg_echo('blog:text');
+ $text_textarea = elgg_view('input/longtext', array('internalname' => 'blogbody', 'value' => $body));
+ $tag_label = elgg_echo('tags');
+ $tag_input = elgg_view('input/tags', array('internalname' => 'blogtags', 'value' => $tags));
+ $access_label = elgg_echo('access');
+
+ //$comments_select = elgg_view('input/checkboxes', array('internalname' => 'comments_on', 'value' => ''));
+ if($comments_on)
+ $comments_on_switch = "checked=\"checked\"";
+ else
+ $comment_on_switch = "";
+
+ $access_input = elgg_view('input/access', array('internalname' => 'access_id', 'value' => $access_id));
+ $submit_input = elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('publish')));
+ $conversation = elgg_echo('Conversation');
+ $publish = elgg_echo('publish');
+ $cat = elgg_echo('categories');
+ $preview = elgg_echo('blog:preview');
+ $privacy = elgg_echo('access');
+ $savedraft = elgg_echo('blog:draft:save');
+ $draftsaved = elgg_echo('blog:draft:saved');
+ $never = elgg_echo('blog:never');
+ $allowcomments = elgg_echo('blog:comments:allow');
+
+ // INSERT EXTRAS HERE
+ $extras = elgg_view('categories',$vars);
+ if (!empty($extras)) $extras = '<div id="blog_edit_sidebar">' . $extras . '</div>';
+
+?>
+
+<?php
+
+ $form_body = <<<EOT
+
+ <div id="two_column_left_sidebar_210">
+
+ <div id="blog_edit_sidebar">
+ <div id="content_area_user_title">
+ <div class="preview_button"><a onclick="javascript:saveDraft(true);return true;">{$preview}</a></div>
+ <h2>{$publish}</h2></div>
+ <div class="publish_controls">
+ <p>
+ <a href="#" onclick="javascript:saveDraft(false);return false;">{$savedraft}</a>
+ </p>
+ </div>
+ <div class="publish_options">
+ <!-- <p><b>{$publish}:</b> now <a href="">edit</a></p> -->
+ <p class="auto_save">{$draftsaved}: <span id="draftSavedCounter">{$never}</span></p>
+ </div>
+ <div class="blog_access">
+ <p>{$privacy}: {$access_input}
+ </p></div>
+ <div class="publish_blog">
+ {$submit_input}
+ </div>
+ </div>
+
+ <div id="blog_edit_sidebar">
+ <div id="content_area_user_title"><h2>{$conversation}</h2></div>
+ <div class="allow_comments">
+ <p><label>
+ <input type="checkbox" name="comments_select" {$comments_on_switch} /> {$allowcomments}
+ </label></p>
+ </div>
+ </div>
+
+ {$extras}
+
+ $container
+
+ </div><!-- /two_column_left_sidebar_210 -->
+
+ <!-- main content -->
+ <div id="two_column_left_sidebar_maincontent">
+EOT;
+
+?>
+
+<?php
+
+ if (isset($vars['entity'])) {
+ $entity_hidden = elgg_view('input/hidden', array('internalname' => 'blogpost', 'value' => $vars['entity']->getGUID()));
+ } else {
+ $entity_hidden = '';
+ }
+
+ $form_body .= <<<EOT
+ <p>
+ <label>$title_label</label><br />
+ $title_textbox
+ </p>
+ <p class='longtext_editarea'>
+ <label>$text_label</label><br />
+ $text_textarea
+ </p>
+ <p>
+ <label>$tag_label</label><br />
+ $tag_input
+ </p>
+ <!-- <p>
+ <label>$access_label</label><br />
+ $access_input
+ </p> -->
+ <p>
+ $entity_hidden
+ <!-- $submit_input -->
+ </p>
+ </div><div class="clearfloat"></div><!-- /two_column_left_sidebar_maincontent -->
+EOT;
+
+ echo elgg_view('input/form', array('action' => "{$vars['url']}action/$action", 'body' => $form_body, 'internalid' => 'blogPostForm'));
+?>
+
+<script type="text/javascript">
+ setInterval( "saveDraft(false)", 120000);
+ function saveDraft(preview) {
+ temppreview = preview;
+
+ if (typeof(tinyMCE) != 'undefined') {
+ tinyMCE.triggerSave();
+ }
+
+ var drafturl = "<?php echo $vars['url']; ?>mod/blog/savedraft.php";
+ var temptitle = $("input[name='blogtitle']").val();
+ var tempbody = $("textarea[name='blogbody']").val();
+ var temptags = $("input[name='blogtags']").val();
+
+ var postdata = { blogtitle: temptitle, blogbody: tempbody, blogtags: temptags };
+
+ $.post(drafturl, postdata, function() {
+ var d = new Date();
+ var mins = d.getMinutes() + '';
+ if (mins.length == 1) mins = '0' + mins;
+ $("span#draftSavedCounter").html(d.getHours() + ":" + mins);
+ if (temppreview == true) {
+ $("form#blogPostForm").attr("action","<?php echo $vars['url']; ?>mod/blog/preview.php");
+ $("input[name='submit']").click();
+ //$("form#blogPostForm").submit();
+ //document.blogPostForm.submit();
+ }
+ });
+
+ }
+
+</script>
diff --git a/mod/blog/views/default/blog/gallery.php b/mod/blog/views/default/blog/gallery.php
new file mode 100644
index 000000000..23f0418bc
--- /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-2010
+ * @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..b2dad2570
--- /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-2010
+ * @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..45384ae72
--- /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-2010
+ * @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..543b98374
--- /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-2010
+ * @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/previewpane.php b/mod/blog/views/default/blog/previewpane.php
new file mode 100644
index 000000000..0828c06a9
--- /dev/null
+++ b/mod/blog/views/default/blog/previewpane.php
@@ -0,0 +1,6 @@
+<div class="blog_previewpane">
+ <p>
+ <?php echo elgg_echo("blog:preview:description"); ?>
+ <a href="javascript:history.go(-1);"><?php echo elgg_echo("blog:preview:description:link"); ?></a>
+ </p>
+</div> \ 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..18841d224
--- /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-2010
+ * @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..898705911
--- /dev/null
+++ b/mod/blog/views/default/object/blog.php
@@ -0,0 +1,150 @@
+<?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-2010
+ * @link http://elgg.com/
+ *
+ * @uses $vars['entity'] Optionally, the blog post to view
+ */
+
+ if (isset($vars['entity'])) {
+
+ //display comments link?
+ if ($vars['entity']->comments_on == 'Off') {
+ $comments_on = false;
+ } else {
+ $comments_on = true;
+ }
+
+ if (get_context() == "search" && $vars['entity'] instanceof ElggObject) {
+
+ //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 {
+
+ if ($vars['entity'] instanceof ElggObject) {
+
+ $url = $vars['entity']->getURL();
+ $owner = $vars['entity']->getOwnerEntity();
+ $canedit = $vars['entity']->canEdit();
+
+ } else {
+
+ $url = 'javascript:history.go(-1);';
+ $owner = $vars['user'];
+ $canedit = false;
+
+ }
+?>
+
+ <div class="contentWrapper singleview">
+
+ <div class="blog_post">
+ <h3><a href="<?php echo $url; ?>"><?php echo $vars['entity']->title; ?></a></h3>
+ <!-- display the user icon -->
+ <div class="blog_post_icon">
+ <?php
+ echo elgg_view("profile/icon",array('entity' => $owner, '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 $owner->username; ?>"><?php echo $owner->name; ?></a> &nbsp;
+ <!-- display the comments link -->
+ <?php
+ if($comments_on && $vars['entity'] instanceof ElggObject){
+ //get the number of comments
+ $num_comments = elgg_count_comments($vars['entity']);
+ ?>
+ <a href="<?php echo $url; ?>"><?php echo sprintf(elgg_echo("comments")) . " (" . $num_comments . ")"; ?></a><br />
+ <?php
+ }
+ ?>
+ </p>
+ <!-- display tags -->
+ <?php
+
+ $tags = elgg_view('output/tags', array('tags' => $vars['entity']->tags));
+ if (!empty($tags)) {
+ echo '<p class="tags">' . $tags . '</p>';
+ }
+
+ $categories = elgg_view('categories/view', $vars);
+ if (!empty($categories)) {
+ echo '<p class="categories">' . $categories . '</p>';
+ }
+
+ ?>
+ <div class="clearfloat"></div>
+ <div class="blog_post_body">
+
+ <!-- display the actual blog post -->
+ <?php
+
+ echo elgg_view('output/longtext',array('value' => $vars['entity']->description));
+
+ ?>
+ </div><div class="clearfloat"></div>
+ <!-- display edit options if it is the blog post owner -->
+ <p class="options">
+ <?php
+
+ if ($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>
+ </div>
+
+<?php
+
+ // If we've been asked to display the full view
+ // Now handled by annotation framework
+ /*if (isset($vars['full']) && $vars['full'] == true && $comments_on == 'on' && $vars['entity'] instanceof ElggEntity) {
+ echo elgg_view_comments($vars['entity']);
+ }*/
+
+ }
+
+ }
+
+?>
diff --git a/mod/blog/views/default/river/object/blog/annotate.php b/mod/blog/views/default/river/object/blog/annotate.php
new file mode 100644
index 000000000..77b75c6d9
--- /dev/null
+++ b/mod/blog/views/default/river/object/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 .= elgg_echo("blog:river:annotate:create") . " <a href=\"" . $object->getURL() . "\">" . $object->title . "</a>";
+
+?>
+
+<?php echo $string; ?> \ No newline at end of file
diff --git a/mod/blog/views/default/river/object/blog/create.php b/mod/blog/views/default/river/object/blog/create.php
new file mode 100644
index 000000000..b5b3dc2e4
--- /dev/null
+++ b/mod/blog/views/default/river/object/blog/create.php
@@ -0,0 +1,20 @@
+<?php
+
+ $performed_by = get_entity($vars['item']->subject_guid); // $statement->getSubject();
+ $object = get_entity($vars['item']->object_guid);
+ $url = $object->getURL();
+
+ $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
+ $contents = strip_tags($object->description); //strip tags from the contents to stop large images etc blowing out the river view
+ $string = sprintf(elgg_echo("blog:river:created"),$url) . " ";
+ $string .= elgg_echo("blog:river:create") . " <a href=\"" . $object->getURL() . "\">" . $object->title . "</a>";
+ $string .= "<div class=\"river_content_display\">";
+ if(strlen($contents) > 200) {
+ $string .= substr($contents, 0, strpos($contents, ' ', 200)) . "...";
+ }else{
+ $string .= $contents;
+ }
+ $string .= "</div>";
+?>
+
+<?php echo $string; ?> \ No newline at end of file
diff --git a/mod/blog/views/default/river/object/blog/update.php b/mod/blog/views/default/river/object/blog/update.php
new file mode 100644
index 000000000..cf98afa8b
--- /dev/null
+++ b/mod/blog/views/default/river/object/blog/update.php
@@ -0,0 +1,13 @@
+<?php
+
+ $performed_by = get_entity($vars['item']->subject_guid); // $statement->getSubject();
+ $object = get_entity($vars['item']->object_guid);
+ $url = $object->getURL();
+
+ $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
+ $string = sprintf(elgg_echo("blog:river:updated"),$url) . " ";
+ $string .= elgg_echo("blog:river:update") . " <a href=\"" . $object->getURL() . "\">" . $object->title . "</a>";
+
+?>
+
+<?php echo $string; ?> \ No newline at end of file