From 58bd19d7cf35e6159124716d0da48d91354d3a2f Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 25 Dec 2010 17:07:41 +0000 Subject: amtrak does not have wifi so here is one big commit with group blogs, blog widget, and improved blog sidebar git-svn-id: http://code.elgg.org/elgg/trunk@7720 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/blog/actions/blog/save.php | 10 +- mod/blog/languages/en.php | 13 +- mod/blog/lib/blog.php | 67 +++++++--- mod/blog/start.php | 144 ++++++++++------------ mod/blog/views/default/blog/group_module.php | 40 ++++++ mod/blog/views/default/blog/sidebar.php | 18 +++ mod/blog/views/default/blog/sidebar/archives.php | 30 +++++ mod/blog/views/default/blog/sidebar/revisions.php | 77 ++++++++++++ mod/blog/views/default/blog/sidebar/tagcloud.php | 31 +++++ mod/blog/views/default/blog/sidebar_menu.php | 76 ------------ mod/blog/views/default/blog/sidebar_revisions.php | 77 ------------ mod/blog/views/default/forms/blog/save.php | 7 +- mod/blog/views/default/input/datetime.php | 2 + mod/blog/views/default/object/blog.php | 7 +- mod/blog/views/default/widgets/blog/content.php | 29 +++++ mod/blog/views/default/widgets/blog/edit.php | 22 ++++ mod/groups/views/default/groups/css.php | 23 ++++ 17 files changed, 416 insertions(+), 257 deletions(-) create mode 100644 mod/blog/views/default/blog/group_module.php create mode 100644 mod/blog/views/default/blog/sidebar.php create mode 100644 mod/blog/views/default/blog/sidebar/archives.php create mode 100644 mod/blog/views/default/blog/sidebar/revisions.php create mode 100644 mod/blog/views/default/blog/sidebar/tagcloud.php delete mode 100644 mod/blog/views/default/blog/sidebar_menu.php delete mode 100644 mod/blog/views/default/blog/sidebar_revisions.php create mode 100644 mod/blog/views/default/widgets/blog/content.php create mode 100644 mod/blog/views/default/widgets/blog/edit.php (limited to 'mod') diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php index 11d366a44..4e6e9133b 100644 --- a/mod/blog/actions/blog/save.php +++ b/mod/blog/actions/blog/save.php @@ -24,7 +24,6 @@ if ($guid) { register_error(elgg_echo('blog:error:post_not_found')); forward(get_input('forward', REFERER)); } - $success_forward_url = get_input('forward', $blog->getURL()); // save some data for revisions once we save the new edit $revision_text = $blog->description; @@ -32,7 +31,6 @@ if ($guid) { } else { $blog = new ElggBlog(); $blog->subtype = 'blog'; - $success_forward_url = get_input('forward'); $new_post = TRUE; } @@ -45,7 +43,7 @@ $values = array( 'comments_on' => 'On', 'excerpt' => '', 'tags' => '', - 'container_guid' => '' + 'container_guid' => (int)get_input('container_guid'), ); // fail if a required entity isn't set @@ -150,7 +148,11 @@ if (!$error) { if ($new_post && $blog->status == 'published') { add_to_river('river/object/blog/create', 'create', get_loggedin_userid(), $blog->getGUID()); } - forward($success_forward_url); + if ($blog->status == 'published') { + forward($blog->getURL()); + } else { + forward("pg/blog/edit/$blog->guid"); + } } else { register_error(elgg_echo('blog:error:cannot_save')); forward($error_forward_url); diff --git a/mod/blog/languages/en.php b/mod/blog/languages/en.php index 39e1a7ad0..d247c0150 100644 --- a/mod/blog/languages/en.php +++ b/mod/blog/languages/en.php @@ -16,7 +16,11 @@ $english = array( 'blog:title:user_blogs' => '%s\'s Blogs', 'blog:title:all_blogs' => 'All Site Blogs', - 'blog:title:friends' => 'All Friends\' Blogs', + 'blog:title:friends' => 'Friends\' Blogs', + + 'blog:group' => 'Group blog', + 'blog:enableblog' => 'Enable group blog', + 'blog:write' => 'Write a blog post', // Editing 'blog:new' => 'New blog post', @@ -40,7 +44,7 @@ $english = array( 'blog:message:saved' => 'Blog post saved.', 'blog:error:cannot_save' => 'Cannot save blog post.', 'blog:error:cannot_write_to_container' => 'Insufficient access to save blog to group.', - 'blog:error:post_not_found' => 'This post has been removed or is invalid.', + 'blog:error:post_not_found' => 'This post has been removed, is invalid, or you do not have permission to view it.', 'blog:messages:warning:draft' => 'There is an unsaved draft of this post!', 'blog:edit_revision_notice' => '(Old version)', 'blog:message:deleted_post' => 'Blog post deleted.', @@ -54,6 +58,11 @@ $english = array( // river 'blog:river:create' => 'published a blog post', 'river:commented:object:blog' => 'the blog', + + // widget + 'blog:widget:description' => 'Display your latest blog posts', + 'blog:moreblogs' => 'More blog posts', + 'blog:numbertodisplay' => 'Number of blog posts to display', ); add_translation('en', $english); diff --git a/mod/blog/lib/blog.php b/mod/blog/lib/blog.php index f3d059ae3..3a67af193 100644 --- a/mod/blog/lib/blog.php +++ b/mod/blog/lib/blog.php @@ -22,11 +22,22 @@ function blog_get_page_content_read($guid = NULL) { $return['filter'] = ''; $return['header'] = ''; - if (!elgg_instanceof($blog, 'object', 'blog') || !$blog->canEdit()) { + if (!elgg_instanceof($blog, 'object', 'blog')) { $return['content'] = elgg_echo('blog:error:post_not_found'); return $return; } + elgg_set_page_owner_guid($blog->getContainerGUID()); + $return['title'] = htmlspecialchars($blog->title); + + $container = $blog->getContainerEntity(); + $crumbs_title = elgg_echo('blog:owned_blogs', array($container->name)); + if (elgg_instanceof($container, 'group')) { + elgg_push_breadcrumb($crumbs_title, "pg/blog/group/$container->guid/owner"); + } else { + elgg_push_breadcrumb($crumbs_title, "pg/blog/owner/$container->username"); + } + elgg_push_breadcrumb($blog->title); $return['content'] = elgg_view_entity($blog, TRUE); //check to see if comment are on @@ -43,11 +54,11 @@ function blog_get_page_content_read($guid = NULL) { * @param int $owner_guid The GUID of the page owner or NULL for all blogs * @return array */ -function blog_get_page_content_list($owner_guid = NULL) { +function blog_get_page_content_list($container_guid = NULL) { $return = array(); - $return['filter_context'] = $owner_guid ? 'mine' : 'all'; + $return['filter_context'] = $container_guid ? 'mine' : 'all'; $options = array( 'type' => 'object', @@ -57,16 +68,23 @@ function blog_get_page_content_list($owner_guid = NULL) { ); $loggedin_userid = get_loggedin_userid(); - if ($owner_guid) { - $options['owner_guid'] = $owner_guid; + if ($container_guid) { + $options['container_guid'] = $container_guid; + $container = get_entity($container_guid); + if (!$container) { + + } + $return['title'] = elgg_echo('blog:title:user_blogs', array($container->name)); + elgg_set_page_owner_guid($container_guid); - // do not want to highlight the current page so pop what was already added - elgg_pop_breadcrumb(); - $crumbs_title = elgg_echo('blog:owned_blogs', array(get_user($owner_guid)->name)); + $crumbs_title = elgg_echo('blog:owned_blogs', array($container->name)); elgg_push_breadcrumb($crumbs_title); + if (elgg_instanceof($container, 'group')) { + $return['filter'] = ''; + } - if ($owner_guid == $loggedin_userid) { + if ($container_guid == $loggedin_userid) { $return['filter_context'] = 'mine'; } else{ // do not show button or select a tab when viewing someone else's posts @@ -75,11 +93,12 @@ function blog_get_page_content_list($owner_guid = NULL) { } } else { $return['filter_context'] = 'all'; + $return['title'] = elgg_echo('blog:title:all_blogs'); } // show all posts for admin or users looking at their own blogs // show only published posts for other users. - if (!(isadminloggedin() || (isloggedin() && $owner_guid == $loggedin_userid))) { + if (!(isadminloggedin() || (isloggedin() && $container_guid == $loggedin_userid))) { $options['metadata_name_value_pairs'] = array( array('name' => 'status', 'value' => 'published'), //array('name' => 'publish_date', 'operand' => '<', 'value' => time()) @@ -104,11 +123,17 @@ function blog_get_page_content_list($owner_guid = NULL) { */ function blog_get_page_content_friends($user_guid) { - elgg_push_breadcrumb(elgg_echo('friends')); + elgg_set_page_owner_guid($user_guid); + $user = get_user($user_guid); $return = array(); $return['filter_context'] = 'friends'; + $return['title'] = elgg_echo('blog:title:friends'); + + $crumbs_title = elgg_echo('blog:owned_blogs', array($user->name)); + elgg_push_breadcrumb($crumbs_title, "pg/blog/owner/{$user->username}"); + elgg_push_breadcrumb(elgg_echo('friends')); if (!$friends = get_user_friends($user_guid, ELGG_ENTITIES_ANY_VALUE, 0)) { $return['content'] .= elgg_echo('friends:none:you'); @@ -160,6 +185,10 @@ function blog_get_page_content_archive($owner_guid, $lower = 0, $upper = 0) { $now = time(); + $user = get_user($owner_guid); + + $crumbs_title = elgg_echo('blog:owned_blogs', array($user->name)); + elgg_push_breadcrumb($crumbs_title, "pg/blog/owner/{$user->username}"); elgg_push_breadcrumb(elgg_echo('blog:archives')); if ($lower) { @@ -229,11 +258,12 @@ function blog_get_page_content_archive($owner_guid, $lower = 0, $upper = 0) { /** * Get page components to edit a blog post. * - * @param int $guid GUID of blog post + * @param string $page 'edit' or 'new' + * @param int $guid GUID of blog post or container * @param int $revision Annotation id for revision to edit (optional) * @return array */ -function blog_get_page_content_edit($guid, $revision = NULL) { +function blog_get_page_content_edit($page, $guid = 0, $revision = NULL) { $return = array( 'buttons' => '', @@ -244,7 +274,7 @@ function blog_get_page_content_edit($guid, $revision = NULL) { $vars['internalid'] = 'blog-post-edit'; $vars['internalname'] = 'blog_post'; - if ($guid) { + if ($page == 'edit') { $blog = get_entity((int)$guid); $title = elgg_echo('blog:edit'); @@ -274,11 +304,18 @@ function blog_get_page_content_edit($guid, $revision = NULL) { $content = elgg_view_form('blog/save', $vars, $body_vars); $content .= elgg_view('js/blog/save_draft'); - $sidebar = elgg_view('blog/sidebar_revisions', $vars); + $sidebar = elgg_view('blog/sidebar/revisions', $vars); } else { $content = elgg_echo('blog:error:cannot_edit_post'); } } else { + if (!$guid) { + $container = get_loggedin_user(); + } else { + $container = get_entity($guid); + } + elgg_set_page_owner_guid($container->guid); + elgg_push_breadcrumb(elgg_echo('blog:new')); $body_vars = blog_prepare_form_vars($blog); diff --git a/mod/blog/start.php b/mod/blog/start.php index 3086d9087..8dc3737f8 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -5,12 +5,12 @@ * @package Blog * * @todo - * Either drop support for "publish date" or duplicate more entity getter + * - Either drop support for "publish date" or duplicate more entity getter * functions to work with a non-standard time_created. - * Show friends blog posts - * Widget - * Pingbacks - * Notifications + * - Pingbacks + * - Notifications + * - River entry for posts saved as drafts and later published + * - Group menu */ elgg_register_event_handler('init', 'system', 'blog_init'); @@ -47,7 +47,11 @@ function blog_init() { // Register for search. register_entity_type('object', 'blog'); - //elgg_register_widget_type('blog', elgg_echo('blog'), elgg_echo('blog:widget:description'), 'profile, dashboard'); + // Add group option + add_group_tool_option('blog', elgg_echo('blog:enableblog'), true); + elgg_extend_view('groups/tool_latest', 'blog/group_module'); + + elgg_register_widget_type('blog', elgg_echo('blog'), elgg_echo('blog:widget:description'), 'profile'); // register actions $action_path = elgg_get_plugin_path() . 'blog/actions/blog'; @@ -74,14 +78,19 @@ function blog_runonce() { /** * Dispatches blog pages. * URLs take the form of - * pg/blog/[all|owner|read|edit|archive|new]/[username]/[time_start|guid]/[time_end|title] + * All blogs: pg/blog/all + * User's blogs: pg/blog/owner/ + * Friends' blog: pg/blog/friends/ + * User's archives: pg/blog/archives/// + * Blog post: pg/blog/read// + * New post: pg/blog/new + * Edit post: pg/blog/edit/<guid>/<revision> + * Preview post: pg/blog/preview/<guid> + * Group blog: pg/blog/group/<guid>/owner + * Group new post: pg/blog/group/<guid>/new * - * Without an action, show all blogs - * Without a guid, show all post for that user. * Title is ignored * - * If archive, uses time_start/end - * * @todo no archives for all blogs or friends * * @param array $page @@ -105,80 +114,61 @@ function blog_page_handler($page) { blog_url_forwarder($page); } + elgg_load_library('elgg:blog'); - // push breadcrumb + // push all blogs breadcrumb elgg_push_breadcrumb(elgg_echo('blog:blogs'), "pg/blog/all/"); if (!isset($page[0])) { $page[0] = 'all'; } - - // if username not set, we are showing all blog posts - if (!isset($page[1])) { - $title = elgg_echo('blog:title:all_blogs'); - $params = blog_get_page_content_list(); - } else { - $username = $page[1]; - // forward away if invalid user. - if (!$user = get_user_by_username($username)) { - register_error('blog:error:unknown_username'); - forward(REFERER); - } - - set_page_owner($user->getGUID()); - $crumbs_title = elgg_echo('blog:owned_blogs', array($user->name)); - $crumbs_url = "pg/blog/owner/$username/"; - elgg_push_breadcrumb($crumbs_title, $crumbs_url); - - $action = $page[0]; - // 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 'owner': - $title = elgg_echo('blog:title:user_blogs', array($user->name)); - $params = blog_get_page_content_list($user->getGUID()); - break; - - case 'read': - $title = elgg_echo('blog:title:user_blogs', array($user->name)); - $params = blog_get_page_content_read($page2); - break; - - case 'new': - case 'edit': + + $page_type = $page[0]; + switch ($page_type) { + case 'owner': + $user = get_user_by_username($page[1]); + $params = blog_get_page_content_list($user->guid); + break; + case 'friends': + $user = get_user_by_username($page[1]); + $params = blog_get_page_content_friends($user->guid); + break; + case 'archive': + $user = get_user_by_username($page[1]); + $params = blog_get_page_content_archive($user->guid, $page[2], $page[3]); + break; + case 'read': + $params = blog_get_page_content_read($page[1]); + break; + case 'new': + gatekeeper(); + $params = blog_get_page_content_edit($page_type); + break; + case 'edit': + gatekeeper(); + $params = blog_get_page_content_edit($page_type, $page[1], $page[2]); + break; + case 'group': + if ($page[2] == 'new') { gatekeeper(); - $title = elgg_echo('blog:edit'); - $params = blog_get_page_content_edit($page2, $page3); - break; - - case 'archive': - $title = elgg_echo('blog:archives'); - $params = blog_get_page_content_archive($user->getGUID(), $page2, $page3); - break; - - case 'friends': - $title = elgg_echo('blog:title:friends'); - $params = blog_get_page_content_friends($user->getGUID()); - break; - - default: - forward("pg/blog/owner/$username/"); - break; - } + $params = blog_get_page_content_edit($page_type, $page[1]); + } else { + $params = blog_get_page_content_list($page[1]); + } + break; + case 'all': + default: + $title = elgg_echo('blog:title:all_blogs'); + $params = blog_get_page_content_list(); + break; } - - $sidebar_menu = elgg_view('blog/sidebar_menu', array( - 'page' => $action, - )); - - $params['sidebar'] .= $sidebar_menu; + + $params['sidebar'] .= elgg_view('blog/sidebar', array('page' => $page_type)); $body = elgg_view_layout('content', $params); - echo elgg_view_page($title, $body); + echo elgg_view_page($params['title'], $body); } /** @@ -216,20 +206,20 @@ function blog_url_forwarder($page) { } /** - * Format and return the correct URL for blogs. + * Format and return the URL for blogs. * - * @param ElggObject $entity + * @param ElggObject $entity Blog object * @return string URL of blog. */ function blog_url_handler($entity) { - if (!$user = get_entity($entity->owner_guid)) { + if (!$entity->getOwnerEntity()) { // default to a standard view if no owner. return FALSE; } $friendly_title = elgg_get_friendly_title($entity->title); - return "pg/blog/read/{$user->username}/{$entity->guid}/$friendly_title"; + return "pg/blog/read/{$entity->guid}/$friendly_title"; } /** diff --git a/mod/blog/views/default/blog/group_module.php b/mod/blog/views/default/blog/group_module.php new file mode 100644 index 000000000..6e75966af --- /dev/null +++ b/mod/blog/views/default/blog/group_module.php @@ -0,0 +1,40 @@ +<?php +/** + * Group blog module + */ + +$group = elgg_get_page_owner(); + +$all_link = elgg_view('output/url', array( + 'href' => "pg/blog/group/$group->guid/owner", + 'text' => elgg_echo('link:view:all'), +)); + +$header = "<span class=\"group-widget-viewall\">$all_link</span>"; +$header .= '<h3>' . elgg_echo('blog:group') . '</h3>'; + + +elgg_push_context('widgets'); +$options = array( + 'type' => 'object', + 'subtype' => 'blog', + 'container_guid' => elgg_get_page_owner_guid(), + 'limit' => 6, + 'full_view' => false, + 'pagination' => false, +); +$content = elgg_list_entities($options); +elgg_pop_context(); + +$new_link = elgg_view('output/url', array( + 'href' => "pg/blog/group/$group->guid/new", + 'text' => elgg_echo('blog:write'), +)); +$content .= "<span class='elgg-widget-more'>$new_link</span>"; + + +$params = array( + 'header' => $header, + 'body' => $content, +); +echo elgg_view('layout/objects/module', $params); diff --git a/mod/blog/views/default/blog/sidebar.php b/mod/blog/views/default/blog/sidebar.php new file mode 100644 index 000000000..63ed85c0b --- /dev/null +++ b/mod/blog/views/default/blog/sidebar.php @@ -0,0 +1,18 @@ +<?php +/** + * Blog sidebar + * + * @package Blog + */ + +// fetch & display latest comments +if ($vars['page'] == 'all') { + echo elgg_view_latest_comments(0, 'object', 'blog'); +} elseif ($vars['page'] == 'owner') { + // @todo - what we want is the latest comments on this user's blog posts - elgg does not support this + echo elgg_view_latest_comments(elgg_get_page_owner_guid(), 'object', 'blog'); +} + +echo elgg_view('blog/sidebar/archives', $vars); + +echo elgg_view('blog/sidebar/tagcloud', $vars); diff --git a/mod/blog/views/default/blog/sidebar/archives.php b/mod/blog/views/default/blog/sidebar/archives.php new file mode 100644 index 000000000..9904be288 --- /dev/null +++ b/mod/blog/views/default/blog/sidebar/archives.php @@ -0,0 +1,30 @@ +<?php +/** + * Blog archives + */ + +$loggedin_user = get_loggedin_user(); +$page_owner = elgg_get_page_owner(); + +// This is a limitation of the URL schema. +if ($page_owner && $vars['page'] != 'friends') { + $dates = blog_get_blog_months($user); + + if ($dates) { + $title = elgg_echo('blog:archives'); + $content = '<ul class="blog-archives">'; + foreach($dates as $date) { + $date = $date->yearmonth; + + $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 = elgg_get_site_url() . 'pg/blog/archive/' . $page_owner->username . '/' . $timestamplow . '/' . $timestamphigh; + $month = elgg_echo('date:month:' . substr($date, 4, 2), array(substr($date, 0, 4))); + $content .= "<li><a href=\"$link\" title=\"$month\">$month</a></li>"; + } + $content .= '</ul>'; + + echo elgg_view('layout/objects/module', array('title' => $title, 'body' => $content)); + } +} \ No newline at end of file diff --git a/mod/blog/views/default/blog/sidebar/revisions.php b/mod/blog/views/default/blog/sidebar/revisions.php new file mode 100644 index 000000000..e3919648b --- /dev/null +++ b/mod/blog/views/default/blog/sidebar/revisions.php @@ -0,0 +1,77 @@ +<?php +/** + * Blog sidebar menu showing revisions + * + * @package Blog + */ + +//If editing a post, show the previous revisions and drafts. +$blog = elgg_get_array_value('entity', $vars, FALSE); + +if (elgg_instanceof($blog, 'object', 'blog') && $blog->canEdit()) { + $owner = $blog->getOwnerEntity(); + $revisions = array(); + + $auto_save_annotations = $blog->getAnnotations('blog_auto_save', 1); + if ($auto_save_annotations) { + $revisions[] = $auto_save_annotations[0]; + } + + // count(FALSE) == 1! AHHH!!! + $saved_revisions = $blog->getAnnotations('blog_revision', 10, 0, 'time_created DESC'); + if ($saved_revisions) { + $revision_count = count($saved_revisions); + } else { + $revision_count = 0; + } + + $revisions = array_merge($revisions, $saved_revisions); + + if ($revisions) { + $title = elgg_echo('blog:revisions'); + + $n = count($revisions); + $body = '<ul class="blog-revisions">'; + + $load_base_url = "pg/blog/edit/{$owner->username}/{$blog->getGUID()}/"; + + // show the "published revision" + if ($blog->status == 'published') { + $load = elgg_view('output/url', array( + 'href' => $load_base_url, + 'text' => elgg_echo('blog:status:published') + )); + + $time = "<span class='entity-subtext'>" + . elgg_view_friendly_time($blog->publish_date) . "</span>"; + + $body .= "<li>$load : $time</li>"; + } + + foreach ($revisions as $revision) { + $time = "<span class='entity-subtext'>" + . elgg_view_friendly_time($revision->time_created) . "</span>"; + + if ($revision->name == 'blog_auto_save') { + $revision_lang = elgg_echo('blog:auto_saved_revision'); + } else { + $revision_lang = elgg_echo('blog:revision') . " $n"; + } + $load = elgg_view('output/url', array( + 'href' => $load_base_url . $revision->id, + 'text' => $revision_lang + )); + + $text = "$load: $time"; + $class = 'class="auto-saved"'; + + $n--; + + $body .= "<li $class>$text</li>"; + } + + $body .= '</ul>'; + + echo elgg_view('layout/objects/module', array('title' => $title, 'body' => $body)); + } +} \ No newline at end of file diff --git a/mod/blog/views/default/blog/sidebar/tagcloud.php b/mod/blog/views/default/blog/sidebar/tagcloud.php new file mode 100644 index 000000000..2f5ce3955 --- /dev/null +++ b/mod/blog/views/default/blog/sidebar/tagcloud.php @@ -0,0 +1,31 @@ +<?php +/** + * Blog tag cloud + */ + +$loggedin_user = get_loggedin_user(); +$page_owner = elgg_get_page_owner(); + +if ($page_owner && $vars['page'] != 'friends') { + + // friends page lists all tags; mine lists owner's + $owner_guid = ($vars['page'] == 'friends') ? '' : $page_owner->getGUID(); + $options = array( + 'type' => 'object', + 'subtype' => 'blog', + 'owner_guid' => $owner_guid, + 'threshold' => 0, + 'limit' => 50, + 'tag_name' => 'tags', + ); + echo elgg_view_tagcloud($options); +} else { + $options = array( + 'type' => 'object', + 'subtype' => 'blog', + 'threshold' => 0, + 'limit' => 50, + 'tag_name' => 'tags', + ); + echo elgg_view_tagcloud($options); +} diff --git a/mod/blog/views/default/blog/sidebar_menu.php b/mod/blog/views/default/blog/sidebar_menu.php deleted file mode 100644 index 7dfbeb1bc..000000000 --- a/mod/blog/views/default/blog/sidebar_menu.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php -/** - * Blog sidebar menu. - * - * @package Blog - */ - -// a few cases to consider: -// 1. looking at all posts -// 2. looking at a user's post -// 3. looking at your posts - -/* -Logged in or not doesn't matter unless you're looking at your blog. - Does it matter then on the side bar? - -All blogs: - Archives - -Owned blogs; - Archives -*/ - -$loggedin_user = get_loggedin_user(); -$page_owner = elgg_get_page_owner(); - -// include a view for plugins to extend -echo elgg_view("blogs/sidebar", array("object_type" => 'blog')); - -// fetch & display latest comments on all blog posts -echo elgg_view_latest_comments(0, 'object', 'blog'); - -// only show archives for users or groups. -// This is a limitation of the URL schema. -if ($page_owner && $vars['page'] != 'friends') { - $dates = blog_get_blog_months($user); - - if ($dates) { - $title = elgg_echo('blog:archives'); - $content = '<ul class="blog-archives">'; - foreach($dates as $date) { - $date = $date->yearmonth; - - $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 = elgg_get_site_url() . 'pg/blog/archive/' . $page_owner->username . '/' . $timestamplow . '/' . $timestamphigh; - $month = elgg_echo('date:month:' . substr($date, 4, 2), array(substr($date, 0, 4))); - $content .= "<li><a href=\"$link\" title=\"$month\">$month</a></li>"; - } - $content .= '</ul>'; - - echo elgg_view('layout/objects/module', array('title' => $title, 'body' => $content)); - } - - // friends page lists all tags; mine lists owner's - $owner_guid = ($vars['page'] == 'friends') ? '' : $page_owner->getGUID(); - $options = array( - 'type' => 'object', - 'subtype' => 'blog', - 'owner_guid' => $owner_guid, - 'threshold' => 0, - 'limit' => 50, - 'tag_name' => 'tags', - ); - echo elgg_view_tagcloud($options); -} else { - $options = array( - 'type' => 'object', - 'subtype' => 'blog', - 'threshold' => 0, - 'limit' => 50, - 'tag_name' => 'tags', - ); - echo elgg_view_tagcloud($options); -} diff --git a/mod/blog/views/default/blog/sidebar_revisions.php b/mod/blog/views/default/blog/sidebar_revisions.php deleted file mode 100644 index e3919648b..000000000 --- a/mod/blog/views/default/blog/sidebar_revisions.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php -/** - * Blog sidebar menu showing revisions - * - * @package Blog - */ - -//If editing a post, show the previous revisions and drafts. -$blog = elgg_get_array_value('entity', $vars, FALSE); - -if (elgg_instanceof($blog, 'object', 'blog') && $blog->canEdit()) { - $owner = $blog->getOwnerEntity(); - $revisions = array(); - - $auto_save_annotations = $blog->getAnnotations('blog_auto_save', 1); - if ($auto_save_annotations) { - $revisions[] = $auto_save_annotations[0]; - } - - // count(FALSE) == 1! AHHH!!! - $saved_revisions = $blog->getAnnotations('blog_revision', 10, 0, 'time_created DESC'); - if ($saved_revisions) { - $revision_count = count($saved_revisions); - } else { - $revision_count = 0; - } - - $revisions = array_merge($revisions, $saved_revisions); - - if ($revisions) { - $title = elgg_echo('blog:revisions'); - - $n = count($revisions); - $body = '<ul class="blog-revisions">'; - - $load_base_url = "pg/blog/edit/{$owner->username}/{$blog->getGUID()}/"; - - // show the "published revision" - if ($blog->status == 'published') { - $load = elgg_view('output/url', array( - 'href' => $load_base_url, - 'text' => elgg_echo('blog:status:published') - )); - - $time = "<span class='entity-subtext'>" - . elgg_view_friendly_time($blog->publish_date) . "</span>"; - - $body .= "<li>$load : $time</li>"; - } - - foreach ($revisions as $revision) { - $time = "<span class='entity-subtext'>" - . elgg_view_friendly_time($revision->time_created) . "</span>"; - - if ($revision->name == 'blog_auto_save') { - $revision_lang = elgg_echo('blog:auto_saved_revision'); - } else { - $revision_lang = elgg_echo('blog:revision') . " $n"; - } - $load = elgg_view('output/url', array( - 'href' => $load_base_url . $revision->id, - 'text' => $revision_lang - )); - - $text = "$load: $time"; - $class = 'class="auto-saved"'; - - $n--; - - $body .= "<li $class>$text</li>"; - } - - $body .= '</ul>'; - - echo elgg_view('layout/objects/module', array('title' => $title, 'body' => $body)); - } -} \ No newline at end of file diff --git a/mod/blog/views/default/forms/blog/save.php b/mod/blog/views/default/forms/blog/save.php index f49340985..8597c135c 100644 --- a/mod/blog/views/default/forms/blog/save.php +++ b/mod/blog/views/default/forms/blog/save.php @@ -5,8 +5,6 @@ * @package Blog */ -$forward = $_SERVER['HTTP_REFERER']; - $draft_warning = $vars['draft_warning']; if ($draft_warning) { $draft_warning = '<span class="message warning">' . $draft_warning . '</span>'; @@ -89,6 +87,7 @@ $access_input = elgg_view('input/access', array( 'value' => $vars['access_id'] )); +// not being used $publish_date_label = elgg_echo('blog:publish_date'); $publish_date_input = elgg_view('input/datetime', array( 'internalname' => 'publish_date', @@ -99,9 +98,8 @@ $publish_date_input = elgg_view('input/datetime', array( $categories_input = elgg_view('categories', $vars); // hidden inputs -//$container_guid_input = elgg_view('input/hidden', array('internalname' => 'container_guid', 'value' => $vars['container_guid'])); +$container_guid_input = elgg_view('input/hidden', array('internalname' => 'container_guid', 'value' => elgg_get_page_owner_guid())); $guid_input = elgg_view('input/hidden', array('internalname' => 'guid', 'value' => $vars['guid'])); -$forward_input = elgg_view('input/hidden', array('internalname' => 'forward', 'value' => $forward)); echo <<<___HTML @@ -150,7 +148,6 @@ $categories_input $guid_input $container_guid_input -$forward_input $action_buttons diff --git a/mod/blog/views/default/input/datetime.php b/mod/blog/views/default/input/datetime.php index 5586464f1..f4bad188c 100644 --- a/mod/blog/views/default/input/datetime.php +++ b/mod/blog/views/default/input/datetime.php @@ -1,6 +1,8 @@ <?php /** * A date-time view for the blog publication date. + * + * not being used */ // default date to current time diff --git a/mod/blog/views/default/object/blog.php b/mod/blog/views/default/object/blog.php index 639031113..19018492a 100644 --- a/mod/blog/views/default/object/blog.php +++ b/mod/blog/views/default/object/blog.php @@ -69,7 +69,7 @@ if ($blog->canEdit()) { $metadata .= "<li>$status_text</li>"; } - $edit_url = elgg_get_site_url() . "pg/blog/edit/{$owner->username}/{$blog->getGUID()}/"; + $edit_url = elgg_get_site_url() . "pg/blog/edit/{$blog->getGUID()}/"; $edit_link = elgg_view('output/url', array( 'href' => $edit_url, 'text' => elgg_echo('edit'), @@ -91,6 +91,11 @@ $metadata .= '</ul>'; $subtitle = "$author_text $date $categories $comments_link"; +// do not show the metadata and controls in widget view +if (elgg_in_context('widgets')) { + $metadata = ''; +} + if ($full) { $header = elgg_view_title($blog->title); diff --git a/mod/blog/views/default/widgets/blog/content.php b/mod/blog/views/default/widgets/blog/content.php new file mode 100644 index 000000000..83d1c0c41 --- /dev/null +++ b/mod/blog/views/default/widgets/blog/content.php @@ -0,0 +1,29 @@ +<?php +/** + * User blog widget display view + */ + +$num = $vars['entity']->num_display; + +$options = array( + 'type' => 'object', + 'subtype' => 'blog', + 'container_guid' => $vars['entity']->owner_guid, + 'limit' => $num, + 'full_view' => FALSE, + 'pagination' => FALSE, +); +$content = elgg_list_entities($options); + +echo $content; + +if ($content) { + $blog_url = "pg/blog/owner/" . elgg_get_page_owner()->username; + $more_link = elgg_view('output/url', array( + 'href' => $blog_url, + 'text' => elgg_echo('blog:moreblogs'), + )); + echo "<span class=\"elgg-widget-more\">$more_link</span>"; +} else { + echo elgg_echo('blog:noblogs'); +} diff --git a/mod/blog/views/default/widgets/blog/edit.php b/mod/blog/views/default/widgets/blog/edit.php new file mode 100644 index 000000000..aaa9d1a10 --- /dev/null +++ b/mod/blog/views/default/widgets/blog/edit.php @@ -0,0 +1,22 @@ +<?php +/** + * User blog widget edit view + */ + +// set default value +if (!isset($vars['entity']->num_display)) { + $vars['entity']->num_display = 4; +} + +$params = array( + 'internalname' => 'params[num_display]', + 'value' => $vars['entity']->num_display = 4, + 'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), +); +$dropdown = elgg_view('input/pulldown', $params); + +?> +<p> + <?php echo elgg_echo('blog:numbertodisplay'); ?>: + <?php echo $dropdown; ?> +</p> diff --git a/mod/groups/views/default/groups/css.php b/mod/groups/views/default/groups/css.php index acd18550e..da80cc7a7 100644 --- a/mod/groups/views/default/groups/css.php +++ b/mod/groups/views/default/groups/css.php @@ -6,6 +6,29 @@ */ ?> +#group_tools_latest > .elgg-module { + float: left; + margin-bottom: 40px; + min-height: 200px; + width: 350px; +} + +#group_tools_latest > .elgg-module .elgg-head { + padding: 5px 5px 3px; + background-color: #e4e4e4; + border-bottom: 1px solid #cccccc; + -moz-border-radius: 4px 4px 0 0; +} + +#group_tools_latest > .elgg-module .elgg-head h3 { + color: #333333; +} + +.group-widget-viewall { + float: right; + font-size: 85%; +} + /* group listings */ .group_count { float:right; -- cgit v1.2.3