From 36abf69637671a1cf65101212596118d155ef54a Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 12 Mar 2010 02:12:47 +0000 Subject: Rough first version of a new blog plugin. git-svn-id: http://code.elgg.org/elgg/trunk@5370 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/blog/actions/add.php | 113 ----- mod/blog/actions/blog/delete.php | 25 + mod/blog/actions/blog/save.php | 282 ++++++++++++ mod/blog/actions/blog/save_draft.php | 146 ++++++ mod/blog/actions/delete.php | 32 -- mod/blog/actions/edit.php | 108 ----- mod/blog/add.php | 27 -- mod/blog/all.php | 39 -- mod/blog/archive.php | 56 --- mod/blog/blog_lib.php | 181 ++++++++ mod/blog/edit.php | 29 -- mod/blog/endpoint/index.php | 92 ---- mod/blog/everyone.php | 37 -- mod/blog/friends.php | 41 -- mod/blog/index.php | 55 --- mod/blog/languages/en.php | 88 ---- mod/blog/manifest.xml | 14 +- mod/blog/preview.php | 41 -- mod/blog/read.php | 66 --- mod/blog/savedraft.php | 20 - mod/blog/shared.php | 59 --- mod/blog/start.php | 501 +++++++++------------ mod/blog/views/default/blog/archive.php | 22 - mod/blog/views/default/blog/categorylist.php | 14 - mod/blog/views/default/blog/css.php | 269 ----------- mod/blog/views/default/blog/forms/edit.php | 489 ++++++++++---------- mod/blog/views/default/blog/gallery.php | 21 - mod/blog/views/default/blog/listing.php | 64 --- mod/blog/views/default/blog/menu.php | 9 - mod/blog/views/default/blog/notfound.php | 13 - mod/blog/views/default/blog/previewpane.php | 6 - mod/blog/views/default/blog/sidebar_menu.php | 42 ++ mod/blog/views/default/blog/stats.php | 13 - mod/blog/views/default/blog/view.php | 15 - mod/blog/views/default/object/blog.php | 265 +++++------ .../views/default/river/object/blog/annotate.php | 13 - .../views/default/river/object/blog/create.php | 20 - .../views/default/river/object/blog/update.php | 13 - 38 files changed, 1263 insertions(+), 2077 deletions(-) delete mode 100644 mod/blog/actions/add.php create mode 100644 mod/blog/actions/blog/delete.php create mode 100644 mod/blog/actions/blog/save.php create mode 100644 mod/blog/actions/blog/save_draft.php delete mode 100644 mod/blog/actions/delete.php delete mode 100644 mod/blog/actions/edit.php delete mode 100644 mod/blog/add.php delete mode 100644 mod/blog/all.php delete mode 100644 mod/blog/archive.php create mode 100644 mod/blog/blog_lib.php delete mode 100644 mod/blog/edit.php delete mode 100644 mod/blog/endpoint/index.php delete mode 100644 mod/blog/everyone.php delete mode 100644 mod/blog/friends.php delete mode 100644 mod/blog/index.php delete mode 100644 mod/blog/languages/en.php delete mode 100644 mod/blog/preview.php delete mode 100644 mod/blog/read.php delete mode 100644 mod/blog/savedraft.php delete mode 100644 mod/blog/shared.php delete mode 100644 mod/blog/views/default/blog/archive.php delete mode 100644 mod/blog/views/default/blog/categorylist.php delete mode 100644 mod/blog/views/default/blog/gallery.php delete mode 100644 mod/blog/views/default/blog/listing.php delete mode 100644 mod/blog/views/default/blog/menu.php delete mode 100644 mod/blog/views/default/blog/notfound.php delete mode 100644 mod/blog/views/default/blog/previewpane.php create mode 100644 mod/blog/views/default/blog/sidebar_menu.php delete mode 100644 mod/blog/views/default/blog/stats.php delete mode 100644 mod/blog/views/default/blog/view.php delete mode 100644 mod/blog/views/default/river/object/blog/annotate.php delete mode 100644 mod/blog/views/default/river/object/blog/create.php delete mode 100644 mod/blog/views/default/river/object/blog/update.php (limited to 'mod') diff --git a/mod/blog/actions/add.php b/mod/blog/actions/add.php deleted file mode 100644 index ade0c2544..000000000 --- a/mod/blog/actions/add.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @copyright Curverider Ltd 2008-2009 - * @link http://elgg.org/ - */ - - // Make sure we're logged in (send us to the front page if not) - gatekeeper(); - - // Make sure action is secure - action_gatekeeper(); - - // Get input data - $title = get_input('blogtitle'); - $body = get_input('blogbody'); - $tags = get_input('blogtags'); - $access = get_input('access_id'); - //there are three options for an excerpt 1) the user adds one 2) the user uses the {{more}} options - //3) we take the first 50 words - check for the excerpt first, then the more option, then grab 50 words - $excerpt = get_input('blogexcerpt'); - if($excerpt){ - if(strlen($excerpt) > 300) - $excerpt = substr($excerpt, 0, strpos($excerpt, ' ', 300)); - else - $excerpt = $excerpt; - - $show_excerpt = true; - } - //if(!$excerpt){ - //if no user excerpt,check for the {{more}} option in the post - // $excerpt = explode("{{more}}", $body); - // $excerpt = $excerpt[0]; - //} - if(!$excerpt){ - //grab the first 300 characters - if(strlen($body) > 300) - $excerpt = substr($body, 0, strpos($body, ' ', 300)) . "..."; - else - $excerpt = $body; - - $show_excerpt = false; - } - $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']); - - // 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(); - // Set it's container - $blog->container_guid = (int)get_input('container_guid', $_SESSION['user']->getGUID()); - // 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($_SERVER['HTTP_REFERER']); - } - // Now let's add tags. We can pass an array directly to the object property! Easy. - 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 - $blog->excerpt = $excerpt; - $blog->show_excerpt = $show_excerpt; - - // Success message - system_message(elgg_echo("blog:posted")); - // add to river - add_to_river('river/object/blog/create','create',$_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/actions/blog/delete.php b/mod/blog/actions/blog/delete.php new file mode 100644 index 000000000..8fa1ff889 --- /dev/null +++ b/mod/blog/actions/blog/delete.php @@ -0,0 +1,25 @@ +canEdit()) { + if ($blog->delete()) { + system_message(elgg_echo('blog:message:deleted_post')); + } else { + register_error(elgg_echo('blog:error:cannot_delete_post')); + } +} else { + register_error(elgg_echo('blog:error:post_not_found')); +} + +forward($_SERVER['HTTP_REFERER']); \ No newline at end of file diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php new file mode 100644 index 000000000..eade7cad8 --- /dev/null +++ b/mod/blog/actions/blog/save.php @@ -0,0 +1,282 @@ +canEdit()) { + $blog = $entity; + } else { + register_error(elgg_echo('blog:error:post_not_found')); + forward(get_input('forward', $_SERVER['HTTP_REFERER'])); + } + $success_forward_url = get_input('forward', $blog->getURL()); +} else { + $blog = new ElggObject(); + $blog->subtype = 'blog'; + $success_forward_url = get_input('forward'); +} + +// set defaults and required values. +$values = array( + 'title' => '', + 'description' => '', + 'status' => 'draft', + //'publish_date' => time(), + 'access_id' => ACCESS_DEFAULT, + 'comments_on' => 'On', + 'excerpt' => '', + 'tags' => '', + 'container_guid' => '' +); + +$required = array('title', 'description'); + +foreach ($values as $name => $default) { + $values[$name] = get_input($name, $default); +} + + +// load from POST and do sanity and access checking +foreach ($values as $name => $default) { + $value = get_input($name, $default); + + if (in_array($name, $required) && empty($value)) { + $error = elgg_echo("blog:error:missing:$name"); + } + + if ($error) { + break; + } + + switch ($name) { + case 'tags': + if ($value) { + $values[$name] = string_to_tag_array($value); + } else { + unset ($values[$name]); + } + break; + + case 'excerpt': + // restrict to 300 chars + if ($value) { + $value = substr(strip_tags($value), 0, 300); + } else { + $value = substr(strip_tags($values['description']), 0, 300); + } + $values[$name] = $value; + break; + + case 'container_guid': + // this can't be empty. + if (!empty($value)) { + if (can_write_to_container($user->getGUID(), $value)) { + $values[$name] = $value; + } else { + $error = elgg_echo("blog:error:cannot_write_to_container"); + } + } else { + unset($values[$name]); + } + break; + + // don't try to set the guid + case 'guid': + unset($values['guid']); + break; + + default: + $values[$name] = $value; + break; + } +} + +// assign values to the entity, stopping on error. +if (!$error) { + foreach ($values as $name => $value) { + if (!$blog->$name = $value) { + $error = elgg_echo('blog:error:cannot_save1' . $name); + break; + } + } +} + +// only try to save base entity if no errors +if (!$error && !$blog->save()) { + $error = elgg_echo('blog:error:cannot_save'); +} + +// forward with success or failure +if ($ajax) { + if ($error) { + $json = array('success' => FALSE, 'message' => $error); + echo json_encode($json); + } else { + $msg = elgg_echo('blog:message:saved'); + $json = array('success' => TRUE, 'message' => $msg, 'guid' => $blog->getGUID()); + echo json_encode($json); + } +} else { + if ($error) { + register_error($error); + forward($error_forward_url); + } else { + system_message(elgg_echo('blog:message:saved')); + forward($success_forward_url); + } +} + + + +/* + * This might have been a good idea. + * It's not. + +// edit or create a new entity +$guid = get_input('guid'); +$user = get_loggedin_user(); +$ajax = get_input('ajax', FALSE); + +// store errors to pass along +$error = FALSE; +$error_forward_url = $_SERVER['HTTP_REFERER']; + +if ($guid) { + $entity = get_entity($guid); + if (elgg_instanceof($entity, 'object', 'blog') && $entity->canEdit()) { + $blog = $entity; + } else { + register_error(elgg_echo('blog:error:post_not_found')); + forward(get_input('forward', $_SERVER['HTTP_REFERER'])); + } + $success_forward_url = get_input('forward', $blog->getURL()); +} else { + $blog = new ElggObject(); + $blog->subtype = 'blog'; + $success_forward_url = get_input('forward'); +} + +// set defaults and required values. +$values = array( + 'title' => '', + 'description' => '', + 'access_id' => ACCESS_DEFAULT, + 'comments_on' => 'On', + 'excerpt' => '', + 'tags' => '', + 'container_guid' => '' +); + +$required = array('title', 'description'); + +foreach ($values as $name => $default) { + $values[$name] = get_input($name, $default); +} + + +// load from POST and do sanity and access checking +foreach ($values as $name => $default) { + + if ($error) { + break; + } + + $value = get_input($name, $default); + + if (in_array($name, $required) && empty($value)) { + register_error(elgg_echo("blog:error:missing:$name")); + forward($error_forward_url); + } + + switch ($name) { + case 'tags': + $values[$name] = string_to_tag_array($value); + break; + + case 'excerpt': + // restrict to 300 chars + if ($value) { + $value = substr(strip_tags($value), 0, 300); + } else { + $value = substr(strip_tags($values['description']), 0, 300); + } + $values[$name] = $value; + break; + + case 'container_guid': + // this can't be empty. + if (!empty($value)) { + if (can_write_to_container($user->getGUID(), $value)) { + $values[$name] = $value; + } else { + $error = elgg_echo("blog:error:cannot_write_to_container"); + } + } else { + unset($values[$name]); + } + break; + + // don't try to set the guid + case 'guid': + unset($values['guid']); + break; + + default: + $values[$name] = $value; + break; + } +} + +// assign values to the entity, stopping on error. +foreach ($values as $name => $value) { + if (!$blog->$name = $value) { + $error = elgg_echo('blog:error:cannot_save'); + break; + } +} + +// only try to save base entity if no errors +if (!$error && !$blog->save()) { + $error = elgg_echo('blog:error:cannot_save'); +} + +// forward or return ajax data. +if ($ajax) { + if ($error) { + $json = array('success' => FALSE, 'message' => $error); + echo json_encode($json); + } else { + $msg = elgg_echo('blog:message:saved'); + $json = array('success' => TRUE, 'message' => $msg); + echo json_encode($json); + } +} else { + if ($error) { + register_error($error); + forward($error_forward_url); + } else { + system_message(elgg_echo('blog:message:saved')); + forward($success_forward_url); + } +} + +*/ \ No newline at end of file diff --git a/mod/blog/actions/blog/save_draft.php b/mod/blog/actions/blog/save_draft.php new file mode 100644 index 000000000..64a79c667 --- /dev/null +++ b/mod/blog/actions/blog/save_draft.php @@ -0,0 +1,146 @@ +canEdit()) { + $blog = $entity; + } else { + register_error(elgg_echo('blog:error:post_not_found')); + forward(get_input('forward', $_SERVER['HTTP_REFERER'])); + } + $success_forward_url = get_input('forward', $blog->getURL()); +} else { + $blog = new ElggObject(); + $blog->subtype = 'blog'; + $success_forward_url = get_input('forward'); +} + +// set defaults and required values. +$values = array( + 'title' => '', + 'description' => '', + 'status' => 'draft', + //'publish_date' => '', + 'access_id' => ACCESS_DEFAULT, + 'comments_on' => 'On', + 'excerpt' => '', + 'tags' => '', + 'container_guid' => '' +); + +$required = array('title', 'description'); + +foreach ($values as $name => $default) { + $values[$name] = get_input($name, $default); +} + + +// load from POST and do sanity and access checking +foreach ($values as $name => $default) { + $value = get_input($name, $default); + + if (in_array($name, $required) && empty($value)) { + $error = elgg_echo("blog:error:missing:$name"); + } + + if ($error) { + break; + } + + switch ($name) { + case 'tags': + if ($value) { + $values[$name] = string_to_tag_array($value); + } else { + unset ($values[$name]); + } + break; + + case 'excerpt': + // restrict to 300 chars + if ($value) { + $value = substr(strip_tags($value), 0, 300); + } else { + $value = substr(strip_tags($values['description']), 0, 300); + } + $values[$name] = $value; + break; + + case 'container_guid': + // this can't be empty. + if (!empty($value)) { + if (can_write_to_container($user->getGUID(), $value)) { + $values[$name] = $value; + } else { + $error = elgg_echo("blog:error:cannot_write_to_container"); + } + } else { + unset($values[$name]); + } + break; + + // don't try to set the guid + case 'guid': + unset($values['guid']); + break; + + default: + $values[$name] = $value; + break; + } +} + +// assign values to the entity, stopping on error. +if (!$error) { + foreach ($values as $name => $value) { + if (!$blog->$name = $value) { + $error = elgg_echo('blog:error:cannot_save'); + break; + } + } +} + +// only try to save base entity if no errors +if (!$error && !$blog->save()) { + $error = elgg_echo('blog:error:cannot_save'); +} + +// forward with success or failure +if ($ajax) { + if ($error) { + $json = array('success' => FALSE, 'message' => $error); + echo json_encode($json); + } else { + $msg = elgg_echo('blog:message:saved'); + $json = array('success' => TRUE, 'message' => $msg, 'guid' => $blog->getGUID()); + echo json_encode($json); + } +} else { + if ($error) { + register_error($error); + forward($error_forward_url); + } else { + system_message(elgg_echo('blog:message:saved')); + forward($success_forward_url); + } +} \ No newline at end of file diff --git a/mod/blog/actions/delete.php b/mod/blog/actions/delete.php deleted file mode 100644 index 5b0120cef..000000000 --- a/mod/blog/actions/delete.php +++ /dev/null @@ -1,32 +0,0 @@ -getSubtype() == "blog" && $blog->canEdit()) { - $container = get_entity($blog->container_guid); - - // 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("pg/blog/" . $container->username); -}else{ - forward($_SERVER['HTTP_REFERER']); -} \ No newline at end of file diff --git a/mod/blog/actions/edit.php b/mod/blog/actions/edit.php deleted file mode 100644 index 3c16a2e8d..000000000 --- a/mod/blog/actions/edit.php +++ /dev/null @@ -1,108 +0,0 @@ - - * @copyright Curverider Ltd 2008-2009 - * @link http://elgg.org/ - */ - - // Make sure we're logged in (send us to the front page if not) - gatekeeper(); - - // make sure action is secure - action_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'); - $excerpt = get_input('blogexcerpt'); - if($excerpt){ - if(strlen($excerpt) > 300) - $excerpt = substr($excerpt, 0, strpos($excerpt, ' ', 300)); - else - $excerpt = strip_tags($excerpt); - - $show_excerpt = true; - } - if(!$excerpt){ - //grab the first 300 characters - if(strlen($body) > 300) - $excerpt = substr($body, 0, strpos($body, ' ', 300)) . "..."; - else - $excerpt = strip_tags($body); - - $show_excerpt = false; - } - - // 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->excerpt = $excerpt; - $blog->comments_on = $comments_on; //whether the users wants to allow comments or not on the blog post - $blog->show_excerpt = $show_excerpt; - - // 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 deleted file mode 100644 index efc6afc43..000000000 --- a/mod/blog/add.php +++ /dev/null @@ -1,27 +0,0 @@ -guid; - -//set breadcrumbs -//$area1 = elgg_view('elggcampus_layout/breadcrumbs_general', array('object_type' => 'blog')); - -// Get the form -$area1 .= elgg_view("blog/forms/edit", array('container_guid' => $container)); - -// Display page -page_draw(elgg_echo('blog:addpost'),elgg_view_layout("one_column", $area1)); \ No newline at end of file diff --git a/mod/blog/all.php b/mod/blog/all.php deleted file mode 100644 index ab1832d99..000000000 --- a/mod/blog/all.php +++ /dev/null @@ -1,39 +0,0 @@ - "everyone", 'type' => 'blog')); - set_context('search'); - $area2 .= "
" . list_entities('object','blog',0,10,false) . "
"; - set_context('blog'); - - // 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')); - //include a view for plugins to extend - //$area3 .= elgg_view("blogs/favourite", array("object_type" => 'blog')); - //get the latest comments on all blogs - $comments = get_annotations(0, "object", "blog", "generic_comment", "", 0, 4, 0, "desc"); - //$area3 .= elgg_view('page_elements/latest_comments', array('comments' => $comments)); - //include a view for plugins to extend - //$area3 .= elgg_view("blogs/sidebar_options", array("object_type" => 'blog')); - - $area3 .= elgg_view('blog/stats'); - - $body = elgg_view_layout("one_column_with_sidebar", $area1.$area2, $area3); - - // Display page - page_draw(elgg_echo('blog:all'),$body); - -?> \ No newline at end of file diff --git a/mod/blog/archive.php b/mod/blog/archive.php deleted file mode 100644 index 9648c75c0..000000000 --- a/mod/blog/archive.php +++ /dev/null @@ -1,56 +0,0 @@ - 'blog')); -// 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))); - -set_context('search'); -// Get a list of blog posts -$blogs = list_user_objects($page_owner->getGUID(),'blog',10,false,false,true,$timelower,$timeupper); -$area2 .= "
" . $blogs . "
"; -set_context('blog'); - -///if the logged in user is not looking at their stuff, display the ownerblock otherwise -//show the users favourites -if(page_owner() != get_loggedin_user()->guid){ - $area3 = elgg_view('blog/ownerblock'); -} - -//get the latest comments on user's blog posts -$comments = get_annotations(0, "object", "blog", "generic_comment", "", 0, 4, 0, "desc",0,0,page_owner()); -$area3 .= elgg_view('elggcampus_layout/latest_comments', array('comments' => $comments)); -//a view for the favourites plugin to extend -$area3 .= elgg_view("blogs/sidebar_options", array("object_type" => 'blog')); -//display archive -$area3 .= elgg_view("blog/archive"); - -// Display them in the page -$body = elgg_view_layout("one_column_with_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/blog_lib.php b/mod/blog/blog_lib.php new file mode 100644 index 000000000..0fe1b80d4 --- /dev/null +++ b/mod/blog/blog_lib.php @@ -0,0 +1,181 @@ +status == 'final') { + $content = elgg_echo('blog:error:post_not_found'); + } else { + elgg_push_breadcrumb($blog->title, $blog->getURL()); + $content = elgg_view_entity($blog, TRUE); + } + } else { + $content = elgg_list_entities_from_metadata(array( + 'type' => 'object', + 'subtype' => 'blog', + 'owner_guid' => $owner_guid, + 'full_view' => FALSE, + 'metadata_name_value_pair' => array('name' => 'status', 'value' => 'final') + )); + } + + return $content; +} + +/** + * Returns HTML to edit a blog post. + * + * @param int $guid + * @return string html + */ +function blog_get_page_content_edit($guid) { + $vars = array(); + if ($guid) { + $blog = get_entity($guid); + $vars['entity'] = $blog; + + if (!elgg_instanceof($blog, 'object', 'blog') || !$blog->canEdit()) { + $content = elgg_echo('blog:error:post_not_found'); + } + + elgg_push_breadcrumb($blog->title, $blog->getURL()); + elgg_push_breadcrumb(elgg_echo('edit')); + } else { + elgg_push_breadcrumb(elgg_echo('blog:new')); + } + + $content = elgg_view('blog/forms/edit', $vars); + + return $content; +} + +/** + * Saves a blog + * + * @param array $info An array of name=>value pairs to save to the blog entity + * + * @return array('success' => BOOL, 'message' => string); + */ +function blog_save_blog($info) { + // store errors to pass along + $error = FALSE; + + if ($info['guid']) { + $entity = get_entity($info['guid']); + if (elgg_instanceof($entity, 'object', 'blog') && $entity->canEdit()) { + $blog = $entity; + } else { + $error = elgg_echo('blog:error:post_not_found'); + } + } else { + $blog = new ElggObject(); + $blog->subtype = 'blog'; + } + + // check required vars + $required = array('title', 'description'); + + // load from POST and do sanity and access checking + foreach ($info as $name => $value) { + if (in_array($name, $required) && empty($value)) { + $error = elgg_echo("blog:error:missing:$name"); + } + + if ($error) { + break; + } + + switch ($name) { + case 'tags': + if ($value) { + $info[$name] = string_to_tag_array($value); + } else { + unset ($info[$name]); + } + break; + + case 'excerpt': + // restrict to 300 chars + if ($value) { + $value = substr(strip_tags($value), 0, 300); + } else { + $value = substr(strip_tags($info['description']), 0, 300); + } + $info[$name] = $value; + break; + + case 'container_guid': + // this can't be empty. + if (!empty($value)) { + if (can_write_to_container($user->getGUID(), $value)) { + $info[$name] = $value; + } else { + $error = elgg_echo("blog:error:cannot_write_to_container"); + } + } else { + unset($info[$name]); + } + break; + + // don't try to set the guid + case 'guid': + unset($info['guid']); + break; + + default: + $info[$name] = $value; + break; + } + } + + // assign values to the entity, stopping on error. + if (!$error) { + foreach ($info as $name => $value) { + if (!$blog->$name = $value) { + $error = elgg_echo('blog:error:cannot_save'); + break; + } + } + } + + // only try to save base entity if no errors + if (!$error && !$blog->save()) { + $error = elgg_echo('blog:error:cannot_save'); + } + + if ($error) { + $return = array( + 'success' => FALSE, + 'message' => $error + ); + } else { + $return = array( + 'success' => TRUE, + 'message' => elgg_echo('blog:message:saved') + ); + } + + return $return; +} + + +class ElggBlog extends ElggObject { + +} \ No newline at end of file diff --git a/mod/blog/edit.php b/mod/blog/edit.php deleted file mode 100644 index 2d605b647..000000000 --- a/mod/blog/edit.php +++ /dev/null @@ -1,29 +0,0 @@ -canEdit()) { - //$area1 = elgg_view('elggcampus_layout/breadcrumbs_edit', array('object' => $post, 'object_type' => 'blog')); - $area1 .= elgg_view("blog/forms/edit", array('entity' => $post)); - $body = elgg_view_layout("one_column", $area1); - } - } - -//Display page - page_draw(sprintf(elgg_echo('blog:editpost'),$post->title),$body); \ No newline at end of file diff --git a/mod/blog/endpoint/index.php b/mod/blog/endpoint/index.php deleted file mode 100644 index 013770e36..000000000 --- a/mod/blog/endpoint/index.php +++ /dev/null @@ -1,92 +0,0 @@ -" . list_user_objects($user_object->guid,'blog',10,false, false) . "
"; - set_context('blog'); - - //get some user details - $user_name = $user_object->name; - $user_desc = $user_object->briefdescription; - $user_location = $user_object->location; - - //get archive list - if ($dates = get_entity_dates('object','blog',$user_object->guid)) { - 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)); - $link = $CONFIG->wwwroot . 'pg/blog/' . $page_owner->username . '/archive/' . $timestamplow . '/' . $timestamphigh; - $year = substr($date,0,-2); - $month = date('F',mktime(0, 0, 0, substr($date,4,2), 1)); //substr($date,4,2); - $display_date = $month . " " . $year; - $archive_list .= "
  • " . $display_date . "
  • "; - } - } -?> - - -Brighton news blog - - - - - -
    -
    - -
    -
    -
    -
    -
    - -
    - - - - \ No newline at end of file diff --git a/mod/blog/everyone.php b/mod/blog/everyone.php deleted file mode 100644 index 9270b33a6..000000000 --- a/mod/blog/everyone.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @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 .= "
    " . elgg_list_entities(array('type' => 'object', 'subtype' => 'blog', 'limit' => 10, 'full_view' => FALSE)) . "
    "; - - // 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("one_column_with_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 deleted file mode 100644 index 24aa36c8b..000000000 --- a/mod/blog/friends.php +++ /dev/null @@ -1,41 +0,0 @@ - "friends", 'type' => 'blog')); - - // Get a list of blog posts - set_context('search'); - $area2 .= "
    " . list_user_friends_objects($page_owner->getGUID(),'blog',10,false) . "
    "; - set_context('blog'); - - // Get categories, if they're installed - global $CONFIG; - //$area3 .= elgg_view("blogs/favourite", array("object_type" => 'blog')); - $comments = get_annotations(0, "object", "blog", "generic_comment", "", 0, 4, 0, "desc"); - $area3 .= elgg_view('page_elements/latest_comments', array('comments' => $comments)); - //include a view for plugins to extend - $area3 .= elgg_view("blogs/sidebar_options", array("object_type" => 'blog')); - - // Display them in the page - $body = elgg_view_layout("one_column_with_sidebar", $area1.$area2, $area3); - - // 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 deleted file mode 100644 index 5d03ce485..000000000 --- a/mod/blog/index.php +++ /dev/null @@ -1,55 +0,0 @@ - 'blog')); - -//set blog header -if(page_owner()== get_loggedin_user()->guid){ - $area1 .= elgg_view('blog/blog_header', array('context' => "own", 'type' => 'blog')); -}elseif($page_owner instanceof ElggGroup){ - $area1 .= elgg_view('groups/blog_header_group'); -}else{ - $area1 .= elgg_view('blog/blog_header_visit', array('type' => 'blog')); -} - -// Get a list of blog posts -set_context('search'); -$blogs = list_user_objects($page_owner->getGUID(),'blog',10,false, false); -if(!$blogs && ($page_owner->guid == get_loggedin_user()->guid)) - $blogs = elgg_view('help/blogs'); -$area2 = "
    " . $blogs . "
    "; -set_context('blog'); -//if the logged in user is not looking at their stuff, display the ownerblock otherwise -//show the users favourites -if(page_owner() != get_loggedin_user()->guid){ - $area3 = elgg_view('blog/ownerblock'); -}else{ - //a view for the favourites plugin to extend - //$area3 .= elgg_view("blogs/favourite", array("object_type" => 'blog')); -} -//get the latest comments on user's blog posts -$comments = get_annotations(0, "object", "blog", "generic_comment", "", 0, 4, 0, "desc",0,0,page_owner()); -$area3 .= elgg_view('page_elements/latest_comments', array('comments' => $comments)); -//a view for the favourites plugin to extend -$area3 .= elgg_view("blogs/sidebar_options", array("object_type" => 'blog')); -//display archive -$area3 .= elgg_view("blog/archive"); -// Display them in the page -$body = elgg_view_layout("one_column_with_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 deleted file mode 100644 index 3e4b3d6d1..000000000 --- a/mod/blog/languages/en.php +++ /dev/null @@ -1,88 +0,0 @@ - "Blog", - 'blogs' => "Blogs", - 'blog:user' => "%s's blog", - 'blog:user:friends' => "%s's friends' blog", - 'blog:yours' => "My blog", - 'blog:posttitle' => "%s's blog: %s", - 'blog:friends' => "Friends' blogs", - 'blog:workgroup' => "Work Group blogs", - 'blog:yourfriends' => "Your friends' latest blogs", - 'blog:all' => "All site blogs", - 'blog:new' => "New blog post", - 'blog:posts' => "Latest blog posts", - 'blog:title' => "Blog title", - 'blog:via' => "via blog", - 'blog:read' => "Read blog", - 'blog:backto' => "Back to blogs", - 'blog:addpost' => "New blog post", - 'blog:editpost' => "Edit blog post", - 'blog:defaultaccess' => "Your site wide access level is:", - 'blog:text' => "Blog text", - 'blog:access' => "This blog's access is:", - 'blog:strapline' => "%s", - 'blog:none' => "There are no blog posts to display", - 'item:object:blog' => 'Blog posts', - 'blog:latestcomments' => 'Latest comments', - 'blog:never' => 'never', - 'blog:preview' => 'Preview', - 'blog:archive' => 'Archive', - 'blog:excerpt' => 'Excerpt (Optional)', - 'blog:excerptdesc' => 'An optional short summary, displayed on blog and search listings
    (instead of the first 200 characters).', - 'blog:draft:save' => 'Save draft', - 'blog:readmore' => 'Read more', - 'blog:draft:saved' => 'Draft last saved', - 'blog:comments:allow' => 'Allow comments', - 'blog:widget:description' => 'This widget will display your latest blog post titles on your profile.', - - '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 community 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 blog post", - 'blog:river:update' => "a blog post", - 'blog:river:annotate' => "a comment on the 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 index e2b8f89f4..483e83fab 100644 --- a/mod/blog/manifest.xml +++ b/mod/blog/manifest.xml @@ -1,10 +1,10 @@ - - - - - - - + + + + + + + diff --git a/mod/blog/preview.php b/mod/blog/preview.php deleted file mode 100644 index 93e11c222..000000000 --- a/mod/blog/preview.php +++ /dev/null @@ -1,41 +0,0 @@ -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("one_column_with_sidebar", $area1 . $area2); - echo page_draw($blogpost->title,$body); - -?> diff --git a/mod/blog/read.php b/mod/blog/read.php deleted file mode 100644 index 291a7bdf8..000000000 --- a/mod/blog/read.php +++ /dev/null @@ -1,66 +0,0 @@ -container_guid) - set_page_owner($blogpost->container_guid); - else - set_page_owner($blogpost->owner_guid); - - //set breadcrumbs - //$area2 = elgg_view('elggcampus_layout/breadcrumbs', array('object_title' => $blogpost->title, 'object_type' => 'blog')); - // Display it - $area2 .= elgg_view_entity($blogpost, true); - //get the blog's access level - $blog_acl = get_readable_access_level($blogpost->access_id); - // Set the title appropriately - $title = $blogpost->title; - //set blog ownerblock if not your own - if($blogpost->owner_guid != get_loggedin_user()->guid){ - $area3 = elgg_view('blog/ownerblock'); - } - //display the read sidebar - //$area3 .= elgg_view('blog/read_sidebar', array('blog_acl' => $blog_acl, 'entity' => $blogpost)); - //if the logged in user is not looking at their stuff, display the ownerblock otherwise - //show the users favourites - if(page_owner() != get_loggedin_user()->guid){ - $area3 = elgg_view('blog/ownerblock'); - }else{ - //a view for the favourites plugin to extend - $area3 .= elgg_view("blogs/sidebar_options", array("object_type" => 'blog')); - } - //display archive - $area3 .= elgg_view("blog/archive"); - //get the latest comments on user's blog posts - $comments = get_annotations(0, "object", "blog", "generic_comment", "", 0, 4, 0, "desc",0,0,page_owner()); - $area3 .= elgg_view('page_elements/latest_comments', array('comments' => $comments)); - - // Display through the correct canvas area - $body = elgg_view_layout("one_column_with_sidebar", $area1.$area2, $area3); - -// 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 deleted file mode 100644 index 4533939ed..000000000 --- a/mod/blog/savedraft.php +++ /dev/null @@ -1,20 +0,0 @@ -blogtitle = $title; - $_SESSION['user']->blogbody = $body; - $_SESSION['user']->blogtags = $tags; - -?> \ No newline at end of file diff --git a/mod/blog/shared.php b/mod/blog/shared.php deleted file mode 100644 index 67dae202e..000000000 --- a/mod/blog/shared.php +++ /dev/null @@ -1,59 +0,0 @@ - 'blog', 'context' => 'shared', 'sac' => $sac)); - -//set blog header -if(page_owner()== get_loggedin_user()->guid){ - $area1 .= elgg_view('blog/blog_header', array('context' => "own", 'type' => 'blog')); -}elseif($page_owner instanceof ElggGroup){ - $area1 .= elgg_view('groups/blog_header_group'); -}else{ - $area1 .= elgg_view('blog/blog_header_visit', array('type' => 'blog')); -} - -// Get a list of blog posts -set_context('search'); -$get_blogs = list_entities_from_access_id($sac, "object", "blog", 0, 10, false, false,true); -if($get_blogs != "") - $area2 = "
    " . $get_blogs . "
    "; -else - $area2 = "
    There are no blog posts in this work group.
    "; -set_context('blog'); -//if the logged in user is not looking at their stuff, display the ownerblock otherwise -//show the users favourites -if(page_owner() != get_loggedin_user()->guid){ - $area3 = elgg_view('blog/ownerblock'); -}else{ - //a view for the favourites plugin to extend - $area3 .= elgg_view("blogs/favourite", array("object_type" => 'blog')); -} -//get the latest comments on user's blog posts -$comments = get_annotations(0, "object", "blog", "generic_comment", "", 0, 4, 0, "desc",0,0,page_owner()); -$area3 .= elgg_view('page_elements/latest_comments', array('comments' => $comments)); -//a view for the favourites plugin to extend -$area3 .= elgg_view("blogs/sidebar_options", array("object_type" => 'blog')); -//display archive -$area3 .= elgg_view("blog/archive"); -// Display them in the page -$body = elgg_view_layout("one_column_with_sidebar", $area1.$area2, $area3); - -// Display page -page_draw(sprintf(elgg_echo('blog:workgroup'),$page_owner->name),$body); \ No newline at end of file diff --git a/mod/blog/start.php b/mod/blog/start.php index c2ccb1902..bbae1eb6c 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -1,278 +1,223 @@ -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'); - - // 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'); - - // Add a new blog widget - add_widget_type('blog',elgg_echo("blog"),elgg_echo("blog:widget:description"),'profile, dashboard'); - - // 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->username . ' via blog: ' . $title; - } - if ($method == 'email') { - $owner = $entity->getOwnerEntity(); - return $owner->username . ' 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 - } - - /** - * remove the more link in the blog text - **/ - function remove_more($body){ - $text = str_replace("{{more}}", " ", $body); - return $text; - } - - // 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 +wwwroot}pg/blog/", array()); + + extend_view('css', 'blog/css'); + + register_page_handler('blog', 'blog_page_handler'); + register_page_handler('blog_ajax', 'blog_ajax_page_handler'); + + register_entity_url_handler('blog_url_handler', 'object', 'blog'); + + // notifications + register_notification_object('object', 'blog', elgg_echo('blog:newpost')); + register_plugin_hook('notify:entity:message', 'object', 'blog_notify_message'); + + // pingbacks + //register_elgg_event_handler('create', 'object', 'blog_incoming_ping'); + //register_plugin_hook('pingback:object:subtypes', 'object', 'blog_pingback_subtypes'); + + // Register for search. + register_entity_type('object','blog'); + + //add_group_tool_option('blog', elgg_echo('blog:enableblog'), true); + add_widget_type('blog', elgg_echo('blog'), elgg_echo('blog:widget:description'), 'profile, dashboard'); + + $action_path = dirname(__FILE__) . '/actions/blog'; + + register_action('blog/save', FALSE, "$action_path/save.php"); + register_action('blog/delete', FALSE, "$action_path/delete.php"); +} + +/** + * Dispatches blog pages. + * To maintain URL backward compatibility, expects old-style URLs like: + * pg/blog/[username/[read|edit|archive|new/[time_start|guid/[time_end|title]]]] + * + * Without a username, show all blogs + * Without an action (read|edit|archive|new), forward to pg/blog/username/read. + * Without a guid, show all post for that user. + * Title is ignored + * + * If archive, uses time_start/end + * + * @todo There is no way to say "show me archive view for all blog posts" with the + * current URL scheme because $param[0] is the username instead of an action. + * Could do something hideous like make '*' mean "all users" (since a username can't be *). + * Can't change the URL scheme because of URL compatibility. + * + * @param array $page + * @return NULL + */ +function blog_page_handler($page) { + global $CONFIG; + + elgg_push_breadcrumb(elgg_echo('blog:blogs'), "{$CONFIG->site->url}pg/blog"); + + // see if we're showing all or just a user's + if (isset($page[0]) && !empty($page[0])) { + $username = $page[0]; + + // forward away if invalid user. + if (!$user = get_user_by_username($username)) { + register_error('blog:error:unknown_username'); + forward($_SERVER['HTTP_REFERER']); + } + + set_page_owner($user->getGUID()); + $crumbs_title = sprintf(elgg_echo('blog:owned_blogs'), $user->name); + $crumbs_url = "{$CONFIG->site->url}pg/blog/$username/read"; + elgg_push_breadcrumb($crumbs_title, $crumbs_url); + + $action = isset($page[1]) ? $page[1] : FALSE; + // yeah these are crap names, but they're used for different things. + $page2 = isset($page[2]) ? $page[2] : FALSE; + $page3 = isset($page[3]) ? $page[3] : FALSE; + + switch ($action) { + case 'read': + $title = sprintf(elgg_echo('blog:title:user_blogs'), $user->name); + $content = elgg_view('page_elements/content_header', array('context' => $content, 'type' => 'blog')); + $content .= blog_get_page_content_read($user->getGUID(), $page2); + break; + + case 'new': + case 'edit': + $content = blog_get_page_content_edit($page2); + break; + + case 'archives': + $content = elgg_view('page_elements/content_header', array('context' => $content, 'type' => 'blog')); + $content .= blog_get_page_content_archive($user->getGUID(), $page2, $page3); + break; + + case 'friends': + $content = elgg_view('page_elements/content_header', array('context' => $content, 'type' => 'blog')); + $content .= blog_get_page_content_archive($user->getGUID()); + break; + + default: + forward("pg/blog/{$username}/read/"); + break; + } + } else { + $title = elgg_echo('blog:title:all_blogs'); + $content = elgg_view('page_elements/content_header', array('context' => $content, 'type' => 'blog')); + $content .= elgg_list_entities_from_metadata(array( + 'type' => 'object', + 'subtype' => 'blog', + 'full_view' => FALSE, + 'metadata_name_value_pair' => array('name' => 'status', 'value' => 'final') + )); + } + + $sidebar = elgg_view('blog/sidebar_menu'); + $content = elgg_view('navigation/breadcrumbs') . $content; + + $body = elgg_view_layout('one_column_with_sidebar', $content, $sidebar); + + page_draw($title, $body); +} + +/** + * Handles ajax calls for blog. + * + * @param array $page + */ +function blog_ajax_page_handler($page) { + $action = isset($page[0]) ? $page[0] : FALSE; + + var_dump($page); + + switch ($action) { + case 'save_draft': + // @todo recycle the save action + $values = array( + 'title' => '', + 'description' => '', + 'status' => 'draft', + 'access_id' => ACCESS_DEFAULT, + 'comments_on' => 'On', + 'excerpt' => '', + 'tags' => '', + 'container_guid' => '', + 'guid' => '' + ); + + foreach ($values as $name => $default) { + $values[$name] = get_input($name, $default); + } + + + + /* + If a title and body, create a blog post marked as a draft and update the + GUID + */ + break; + + default: + $content = 0; + break; + } + + exit; +} + + +/** + * Format and return the correct URL for blogs. + * + * @param ElggObject $entity + * @return string URL of blog. + */ +function blog_url_handler($entity) { + global $CONFIG; + + if (!$user = get_entity($entity->owner_guid)) { + // default to a standard view if no owner. + return FALSE; + } + + $friendly_title = friendly_title($entity->title); + + $url = "{$CONFIG->site->url}pg/blog/{$user->username}/read/{$entity->getGUID()}/$friendly_title"; + return $url; +} + + +register_elgg_event_handler('init', 'system', 'blog_init'); \ No newline at end of file diff --git a/mod/blog/views/default/blog/archive.php b/mod/blog/views/default/blog/archive.php deleted file mode 100644 index 76ae16696..000000000 --- a/mod/blog/views/default/blog/archive.php +++ /dev/null @@ -1,22 +0,0 @@ -"; - echo "

    " . elgg_echo('blog:archive') ."

    "; - echo "
    "; -} \ No newline at end of file diff --git a/mod/blog/views/default/blog/categorylist.php b/mod/blog/views/default/blog/categorylist.php deleted file mode 100644 index 799c837a7..000000000 --- a/mod/blog/views/default/blog/categorylist.php +++ /dev/null @@ -1,14 +0,0 @@ - - -
    - -
    - - \ No newline at end of file diff --git a/mod/blog/views/default/blog/css.php b/mod/blog/views/default/blog/css.php index 361e1572c..e69de29bb 100644 --- a/mod/blog/views/default/blog/css.php +++ b/mod/blog/views/default/blog/css.php @@ -1,269 +0,0 @@ - -#blogs .pagination { -/* - margin:5px 10px 0 10px; - padding:5px; - display:block; -*/ -} - -.singleview { - /* margin-top:10px !important; */ -} - -/* -we're partly using the #NewListStyle on blogs -ItemMetaData block only -*/ -#blogs .ContentWrapper.Welcome { - padding:10px 0 10px 0; -} -#blogs .search_listing .search_listing_info .ItemMetaData { - float:right; - margin-left:15px; - margin-top:0; - margin-right: 3px; - color:#AAAAAA; - text-align: right; - font-size:90%; -} -#blogs .search_listing .search_listing_info .ItemMetaData table { - width:200px; - /* float:right; removed for ie7 compatability */ -} -#blogs .search_listing .search_listing_info .ItemMetaData .EditItem a { - color:#AAAAAA; - margin:0 0 0 10px; -} -#blogs .search_listing .search_listing_info .ItemMetaData .EditItem a:hover { - color: #0054a7; - text-decoration: underline; -} - -#blogs .search_listing .search_listing_info .ItemMetaData td.FavouriteItem { - padding-top:0; -} -/* IE7 */ -*:first-child+html #blogs .search_listing .search_listing_info .ItemMetaData td.FavouriteItem { width:auto; } - - -/* BLOG TITLE IN LIST VIEWS */ -#blogs h2.blog_title { - line-height:1.1em; - margin-top:0; - font-size:1.4em; -} -#blogs h2.blog_title a { - color:#0054A7; -} -#blogs .search_listing_info p.blog_excerpt { - margin-top:3px; - padding-top:2px; - border-top:1px solid #cccccc; -} -#blogs .search_listing_info p.owner_timestamp { - margin-top:2px; -} - -.Page_Header_Options .cancel_button { - float:right; - margin:0 10px 0 0; -} - -.blog_post_icon { - float:left; - margin:0 0 0 0; - padding:0; -} -#blogs .search_listing_info { - margin-left:34px; -} - -.blog_post #content_area_user_title { - -} -.blog_post #content_area_user_title h2 { - margin:0 0 5px; - padding:0 0 5px; - border-bottom:1px solid #cccccc; -} -.blog_post .strapline { - margin: 0 0 0 30px; - padding:0; - color: #aaa; - line-height:0.8em; -} -.blog_post .strapline .generic_access, -.blog_post .strapline .shared_collection, -.blog_post .strapline .group_open, -.blog_post .strapline .group_closed { - line-height:1.4em; - display:block; -} -.blog_post p.tags { - background:transparent url(_graphics/icon_tag.png) no-repeat scroll left 2px; - margin:0; - padding:0 0 0 16px; - min-height:22px; -} -.blog_post .options { - margin:0; - padding:0; -} -.blog_post_body { - margin-top:2px; - padding-top:8px; - border-top:1px solid #cccccc; -} -.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; -} - - - - -/* 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_page .publish_controls, -#blog_edit_page .blog_access, -#blog_edit_page .publish_options, -#blog_edit_page .publish_blog, -#blog_edit_page .allow_comments, -#blog_edit_page .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 .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%; -} - - -/* blog edit page */ -#blogPostForm .ContentWrapper { - margin-top:10px; -} -#blogPostForm .ContentWrapper #excerpt_editarea { - margin-top:15px; - margin-bottom:15px; -} -#excerpt_editarea .input_textarea { - height:80px; -} -#blogPostForm .current_access { - color:inherit; - font-size:inherit; - line-height:1.0em; - padding-top:0; -} - -/* blog widget on groups */ -.collapsable_box_content .ContentWrapper.blogs.more { - margin:0 10px; - padding:5px 10px; -} -.collapsable_box_content .ContentWrapper.blogs { - line-height:1.2em; - margin-bottom:5px; -} -.collapsable_box_content .ContentWrapper.blogs .river_object_blog_create { - background-position:left 2px; - min-height:17px; - padding:2px 0 2px 19px; - border-bottom:1px solid #DDDDDD; - line-height:1.1em; -} -.collapsable_box_content .ContentWrapper.blogs .river_object_blog_create:first-child { - border-top:1px solid #DDDDDD; -} -.collapsable_box_content .ContentWrapper.blogs .river_object_blog_create span { - font-size: 90%; - color:#666666; -} - - diff --git a/mod/blog/views/default/blog/forms/edit.php b/mod/blog/views/default/blog/forms/edit.php index 28a0980a4..3c9912daa 100644 --- a/mod/blog/views/default/blog/forms/edit.php +++ b/mod/blog/views/default/blog/forms/edit.php @@ -1,257 +1,272 @@ - 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; - $show_excerpt = $vars['entity']->show_excerpt; - if($show_excerpt) - $excerpt = $vars['entity']->excerpt; - else - $excerpt = ""; - $page_title = elgg_view_title(elgg_echo('blog:editpost')); -}else{ - $title = elgg_echo("blog:addpost"); - $action = "blog/add"; - $tags = ""; - $title = ""; - $comments_on = true; - $description = ""; - $excerpt = ""; - $show_excerpt = ''; - $page_title = elgg_view_title(elgg_echo('blog:addpost')); - if(page_owner_entity() instanceof ElggGroup){ - //if in a group, set the access level to default to the group - $access_id = page_owner_entity()->group_acl; - }else{ - $access_id = $loggedin_user_access; - } - $container = $vars['container_guid'] ? elgg_view('input/hidden', array('internalname' => 'container_guid', 'value' => $vars['container_guid'])) : ""; -} + * Edit blog form + * + * @package Blog + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.org/ + */ + +$values = array( + 'title' => NULL, + 'description' => NULL, + 'status' => 'final', + //'publish_date' => NULL, + 'access_id' => ACCESS_DEFAULT, + 'comments_on' => 'On', + 'excerpt' => NULL, + 'tags' => NULL, + 'container_guid' => NULL, + 'guid' => NULL +); + +$forward = $_SERVER['HTTP_REFERER']; + +$action_buttons = ''; +$guid_input = ''; -//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; +// if entity is set, we're editing. +if (isset ($vars['entity'])) { + $blog = $vars['entity']; + + if ($blog && ($blog instanceof ElggObject) && ($blog->getSubtype() == 'blog')) { + foreach (array_keys($values) as $field) { + $values[$field] = $blog->$field; + } + } else { + echo elgg_echo('blog:error:post_not_found'); + return FALSE; } + + // add a delete button if editing + $delete_url = "{$vars['url']}action/blog/delete?guid={$blog->getGUID()}"; + $delete_link = elgg_view('output/confirmlink', array( + 'href' => $delete_url, + 'text' => elgg_echo('delete'), + 'class' => 'action_button' + )); + + $action_buttons = $delete_link; + + $guid_input = elgg_view('input/hidden', array('internalname' => 'guid', 'value' => $values['guid'])); } -//set the required input fields -$title_label = elgg_echo('blog: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)); +$save_button = elgg_view('input/submit', array('value' => elgg_echo('save'), 'class' => 'action_button')); +$action_buttons .= $save_button; + +$title_label = elgg_echo('title'); +$title_input = elgg_view('input/text', array( + 'internalname' => 'title', + 'internalid' => 'blog_title', + 'value' => $values['title'] +)); + $excerpt_label = elgg_echo('blog:excerpt'); -$excerpt_counter = "
    "; -$excerpt_textarea = elgg_view('input/text', array('internalname' => 'blogexcerpt', 'internalid' => 'excerpt', 'class' => 'excerpt input_textarea', 'value' => $excerpt)); -$excerpt_desc = elgg_echo('blog:excerptdesc'); -$show_excerpt_field = elgg_view('input/hidden', array('internalname' => 'show_excerpt', 'value' => $show_excerpt)); -$tag_label = elgg_echo('tags'); -$tag_input = elgg_view('input/tags', array('internalname' => 'blogtags', 'value' => $tags)); +$excerpt_input = elgg_view('input/text', array( + 'internalname' => 'excerpt', + 'internalid' => 'blog_excerpt', + 'value' => $values['excerpt'] +)); + +$body_label = elgg_echo('blog:body'); +$body_input = elgg_view('input/longtext', array( + 'internalname' => 'description', + 'internalid' => 'blog_description', + 'value' => $values['description'] +)); + +$save_status = elgg_echo('blog:save_status'); +$never = elgg_echo('never'); + +$status_label = elgg_echo('blog:status'); +$status_input = elgg_view('input/pulldown', array( + 'internalname' => 'status', + 'internalid' => 'blog_status', + 'value' => $values['status'], + 'options_values' => array( + 'draft' => elgg_echo('blog:draft'), + 'final' => elgg_echo('blog:final') + ) +)); + +$comments_label = elgg_echo('comments'); +$comments_input = elgg_view('input/pulldown', array( + 'internalname' => 'comments_on', + 'internalid' => 'blog_comments_on', + 'value' => $values['comments_on'], + 'options_values' => array('On' => elgg_echo('on'), 'Off' => elgg_echo('off')) +)); + +$tags_label = elgg_echo('tags'); +$tags_input = elgg_view('input/tags', array( + 'internalname' => 'tags', + 'internalid' => 'blog_tags', + 'value' => $values['tags'] +)); + $access_label = elgg_echo('access'); -if($comments_on) - $comments_on_switch = "checked=\"checked\""; -else - $comment_on_switch = ""; -//if it is a group, pull out the group access view -if(page_owner_entity() instanceof ElggGroup){ - $options = group_access_options(page_owner_entity()); -}else{ - $options = ''; -} -$access_input = elgg_view('input/access', array('internalname' => 'access_id', 'value' => $access_id, 'options' => $options)); -$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'); -$user_default_access = elgg_echo('blog:defaultaccess'); -$ownerblock = elgg_view('blog/ownerblock', array('entity' => $vars['entity'])); -if($vars['entity']){ - $deletepage = elgg_view('output/confirmlink',array( - 'href' => $vars['url'] . "action/blog/delete?blogpost=" . $vars['entity']->getGUID(), - 'text' => elgg_echo("delete"), - 'confirm' => elgg_echo("blog:delete:confirm"), - 'class' => "Action_Button Disabled")); -}else{ - $deletepage = ""; -} +$access_input = elgg_view('input/access', array( + 'internalname' => 'access_id', + 'internalid' => 'blog_access_id', + 'value' => $values['access_id'] +)); -//INSERT EXTRAS HERE -$extras = elgg_view('categories',$vars); -if (!empty($extras)) $extras = '
    ' .$cat .'
    '. $extras . '
    '; - -?> +$publish_date_label = elgg_echo('blog:publish_date'); +$publish_date_input = elgg_view('input/datepicker', array( + 'internalname' => 'publish_date', + 'internalid' => 'blog_publish_date', + 'value' => $vars['publish_date'] +)); + +// hidden inputs +//$container_guid_input = elgg_view('input/hidden', array('internalname' => 'container_guid', 'value' => $values['container_guid'])); +$forward_input = elgg_view('input/hidden', array('internalname' => 'forward', 'value' => $forward)); + +$form_body = <<<___END +

    + + $title_input +

    + +

    + +$excerpt_input +

    + +

    + + $body_input +

    + +

    + $save_status:$never +

    + +

    + + $publish_date_input +

    + + +

    + + $tags_input +

    + +

    + + $comments_input +

    + +

    + + $access_input +

    + + + +

    + + $status_input +

    + +$guid_input +$container_guid_input +$forward_input + +$action_buttons + + + +___END; + +echo elgg_view('input/form', array( + 'internalname' => 'blog_post', + 'action' => "{$vars['url']}action/blog/save", + 'body' => $form_body +)); - - {$ownerblock} -
    -

    {$publish}

    - -
    - -
    -

    {$privacy}: {$access_input}

    -
    -
    {$user_default_access}
    {$user_acl}
    -
    - -
    -
    - -
    -
    - -
    - -
    -
    - {$draftsaved}: {$never} - {$savedraft} -
    - - {$submit_input} -
    -
    -
    - - {$extras} - {$container} - - - -
    - - - - - - - -
    -EOT; - -if (isset($vars['entity'])) - $entity_hidden = elgg_view('input/hidden', array('internalname' => 'blogpost', 'value' => $vars['entity']->getGUID())); -else - $entity_hidden = ''; - -$form_body .= <<
    $title_textbox

    -

    - $text_textarea -

    -
    -
    $excerpt_desc $excerpt_counter
    - $excerpt_textarea -
    -


    $tag_input

    -

    $entity_hidden

    - $show_excerpt_field -
    -
    -
    -EOT; - -//display the form -echo elgg_view('input/form', array('action' => "{$vars['url']}action/$action", 'body' => $form_body, 'internalid' => 'blogPostForm')); ?> + + $(document).ready(function(){ + $('#excerpt.excerpt').each(function(){ + var allowed = 200; + + // set the initial value + $('#countervalue').text(allowed); + + // bind on key up event + $(this).keyup(function(){ + var counter_value = ((allowed - ($(this).val().length))); + + $("#countervalue").removeClass(); + + if ((counter_value > 10)) { + $("#countervalue").addClass("positive"); + } + else if ((counter_value <= 10) && (counter_value >= 0)) { + $("#countervalue").addClass("gettingclose"); + } + else if ((counter_value < 0)) { + $("#countervalue").addClass("negative"); + } + + // insert new length + $('#countervalue').text(counter_value); + + }); + }); + }); + + \ No newline at end of file diff --git a/mod/blog/views/default/blog/gallery.php b/mod/blog/views/default/blog/gallery.php deleted file mode 100644 index 7fa05040e..000000000 --- a/mod/blog/views/default/blog/gallery.php +++ /dev/null @@ -1,21 +0,0 @@ -getOwnerEntity(); -$friendlytime = friendly_time($vars['entity']->time_created); -$icon = elgg_view( - "profile/icon", array( - 'entity' => $owner, - 'size' => 'small', - ) - ); -$info = "

    " . elgg_echo('blog') . ": getURL()}\">{$vars['entity']->title}

    "; -$info .= "

    getURL()}\">{$owner->name} {$friendlytime}

    "; - -//display -echo "
    "; -echo ""; -echo ""; -echo "
    "; \ No newline at end of file diff --git a/mod/blog/views/default/blog/listing.php b/mod/blog/views/default/blog/listing.php deleted file mode 100644 index 7aae87b27..000000000 --- a/mod/blog/views/default/blog/listing.php +++ /dev/null @@ -1,64 +0,0 @@ -getOwnerEntity(); -$friendlytime = sprintf(elgg_echo("blog:strapline"), - date("F j, Y",$vars['entity']->time_created) - ); -$tags = elgg_view('output/tags', array('tags' => $vars['entity']->tags)); -$num_comments = elgg_count_comments($vars['entity']); -$icon = elgg_view( - "profile/icon", array( - 'entity' => $owner, - 'size' => 'tiny', - ) - ); -//sort out the access level for display -$object_acl = get_readable_access_level($vars['entity']->access_id); -//files with these access level don't need an icon -$general_access = array('Public', 'Logged in users', 'Friends'); -//set the right class for access level display - need it to set on groups and shared access only -$check_is_group = get_entity($vars['entity']->container_guid); -if($check_is_group instanceof ElggGroup){ - //get the membership type open/closed - $membership = $check_is_group->membership; - //we decided to show that the item is in a group, rather than its actual access level - $object_acl = "Group: " . $is_group->name; - if($membership == 2) - $access_level = "class='group_open'"; - else - $access_level = "class='group_closed'"; -}elseif($object_acl == 'Private'){ - $access_level = "class='private'"; -}else{ - if(!in_array($object_acl, $general_access)) - $access_level = "class='shared_collection'"; - else - $access_level = "class='generic_access'"; -} -//display the access level - $info = ""; - - -$info .= "

    getURL()}\">{$vars['entity']->title}

    "; -$info .= "

    username}\">{$owner->name} {$friendlytime}, "; -$info .= "getURL()}'>" . sprintf(elgg_echo("comments")) . " (" . $num_comments . ")

    "; -$info .= "

    " . display_objects(strip_tags($vars['entity']->excerpt)) . "

    "; - -echo elgg_view_listing($icon,$info); - diff --git a/mod/blog/views/default/blog/menu.php b/mod/blog/views/default/blog/menu.php deleted file mode 100644 index 15e67061c..000000000 --- a/mod/blog/views/default/blog/menu.php +++ /dev/null @@ -1,9 +0,0 @@ - - -
  • - -
  • \ No newline at end of file diff --git a/mod/blog/views/default/blog/notfound.php b/mod/blog/views/default/blog/notfound.php deleted file mode 100644 index 2ef231b17..000000000 --- a/mod/blog/views/default/blog/notfound.php +++ /dev/null @@ -1,13 +0,0 @@ - - -

    - -

    \ No newline at end of file diff --git a/mod/blog/views/default/blog/previewpane.php b/mod/blog/views/default/blog/previewpane.php deleted file mode 100644 index da8fac2e5..000000000 --- a/mod/blog/views/default/blog/previewpane.php +++ /dev/null @@ -1,6 +0,0 @@ -
    -

    - - -

    -
    \ No newline at end of file diff --git a/mod/blog/views/default/blog/sidebar_menu.php b/mod/blog/views/default/blog/sidebar_menu.php new file mode 100644 index 000000000..74d69356b --- /dev/null +++ b/mod/blog/views/default/blog/sidebar_menu.php @@ -0,0 +1,42 @@ + + + \ No newline at end of file diff --git a/mod/blog/views/default/blog/stats.php b/mod/blog/views/default/blog/stats.php deleted file mode 100644 index d5bfe5b8b..000000000 --- a/mod/blog/views/default/blog/stats.php +++ /dev/null @@ -1,13 +0,0 @@ -"; -echo "

    Blog stats

    "; -echo "
    "; -echo $count_blogs . " blog posts written with " . $count_blog_comments . " comments."; -echo "
    "; \ No newline at end of file diff --git a/mod/blog/views/default/blog/view.php b/mod/blog/views/default/blog/view.php deleted file mode 100644 index a90f1775f..000000000 --- a/mod/blog/views/default/blog/view.php +++ /dev/null @@ -1,15 +0,0 @@ - 0) { - foreach($vars['posts'] as $post) { - echo elgg_view_entity($post); - } -}else{ - echo elgg_echo('blog:none'); -} \ 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 8a7cd52b8..7a40de67d 100644 --- a/mod/blog/views/default/object/blog.php +++ b/mod/blog/views/default/object/blog.php @@ -1,161 +1,106 @@ -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; - } - -?> - - - -
    -
    - $vars['entity'])); - ?> -
    -

    title; ?>

    -
    - -
    - $owner, 'size' => 'tiny')); - ?> -
    -

    - - name; ?> - - time_created) - ); - - ?> - - - - access_id); - //files with these access level don't need an icon - $general_access = array('Public', 'Logged in users', 'Friends'); - //set the right class for access level display - need it to set on groups and shared access only - $is_group = get_entity($vars['entity']->container_guid); - if($is_group instanceof ElggGroup){ - //get the membership type open/closed - $membership = $is_group->membership; - if($membership == 2) - $access_level = "class='group_open'"; - else - $access_level = "class='group_closed'"; - }elseif($object_acl == 'Private'){ - $access_level = "class='private'"; - }else{ - if(!in_array($object_acl, $general_access)) - $access_level = "class='shared_collection'"; - else - $access_level = "class='generic_access'"; - } - echo "
    " . $object_acl . ""; - ?> -

    - -
    -
    - - show_excerpt){ - //echo "
    "; - //echo elgg_view('output/longtext',array('value' => $vars['entity']->excerpt)); - //echo "
    "; - } - echo elgg_view('output/longtext',array('value' => $vars['entity']->description)); - ?> -
    - -

    - $vars['entity'])); - ?> -

    - - - $vars['entity']->tags)); - if (!empty($tags)) { - echo '

    ' . $tags . '

    '; - } - - $categories = elgg_view('categories/view', $vars); - if (!empty($categories)) { - echo '

    ' . $categories . '

    '; - } - - ?> - -
    -
    -
    -" . elgg_echo('blog:none') . ""; +owner_guid); +$container = get_entity($blog->container_guid); +$linked_title = "getURL()}\" title=\"" . htmlentities($blog->title) . "\">{$blog->title}"; +$categories = elgg_view('categories/view', $vars); +$excerpt = $blog->excerpt; +$body = $blog->description; +$owner_icon = elgg_view("profile/icon",array('entity' => $owner, 'size' => 'tiny')); +$tags = elgg_view('output/tags', array('tags' => $blog->tags)); +$date = friendly_time($blog->time_created); + +if ($blog->comments_on == 'Yes') { + $comments_count = elgg_count_comments($blog); + $comments_link = "getURL()}#annotations\">" . sprintf(elgg_echo("comments"), $comments_count) . ''; +} else { + $comments_link = ''; +} + +// links to delete or edit. +if ($blog->canEdit()) { + $edit_url = "{$vars['url']}pg/blog/{$owner->username}/edit/{$blog->getGUID()}/"; + $edit_link = "" . elgg_echo('edit') . ''; + + $delete_url = "{$vars['url']}action/blog/delete?guid={$blog->getGUID()}"; + $delete_link = elgg_view('output/confirmlink', array( + 'href' => $delete_url, + 'text' => elgg_echo('delete'), + 'class' => 'action_button' + )); + + $edit = "$edit_link $delete_link"; +} else { + $edit = ''; +} + +if ($full) { + // The "on" status changes for comments, so best to check for !Off + if ($blog->comments_on != 'Off') { + $comments = elgg_view_comments($blog); + } else { + $comments = ''; + } + + $owner_title = sprintf(elgg_echo('blog:owner_title'), $user->name); + +echo <<<___END +
    +

    $owner_title

    + $edit +

    {$blog->title}

    +
    + $owner_icon +
    +
    +

    + $date + $tags + $categories + $comments_link +

    +

    $body

    +
    +
    + +$comments + +___END; + +} else { + echo <<<___END +
    +
    + $owner_icon +
    +
    + $edit +

    $linked_title

    +

    + $date + $tags + $categories + $comments_link +

    +

    $excerpt

    +
    +
    + +___END; } \ No newline at end of file diff --git a/mod/blog/views/default/river/object/blog/annotate.php b/mod/blog/views/default/river/object/blog/annotate.php deleted file mode 100644 index 77b75c6d9..000000000 --- a/mod/blog/views/default/river/object/blog/annotate.php +++ /dev/null @@ -1,13 +0,0 @@ -getSubject(); - $object = $statement->getObject(); - - $url = "getURL()}\">{$performed_by->name}"; - $string = sprintf(elgg_echo("blog:river:posted"),$url) . " "; - $string .= elgg_echo("blog:river:annotate:create") . " getURL() . "\">" . $object->title . ""; - -?> - - \ 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 deleted file mode 100644 index b5b3dc2e4..000000000 --- a/mod/blog/views/default/river/object/blog/create.php +++ /dev/null @@ -1,20 +0,0 @@ -subject_guid); // $statement->getSubject(); - $object = get_entity($vars['item']->object_guid); - $url = $object->getURL(); - - $url = "getURL()}\">{$performed_by->name}"; - $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") . " getURL() . "\">" . $object->title . ""; - $string .= "
    "; - if(strlen($contents) > 200) { - $string .= substr($contents, 0, strpos($contents, ' ', 200)) . "..."; - }else{ - $string .= $contents; - } - $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 deleted file mode 100644 index cf98afa8b..000000000 --- a/mod/blog/views/default/river/object/blog/update.php +++ /dev/null @@ -1,13 +0,0 @@ -subject_guid); // $statement->getSubject(); - $object = get_entity($vars['item']->object_guid); - $url = $object->getURL(); - - $url = "getURL()}\">{$performed_by->name}"; - $string = sprintf(elgg_echo("blog:river:updated"),$url) . " "; - $string .= elgg_echo("blog:river:update") . " getURL() . "\">" . $object->title . ""; - -?> - - \ No newline at end of file -- cgit v1.2.3