Permalink
Browse files

chore(blog): moved some page handler functions to resource views

BREAKING CHANGE:
The functions blog_get_page_content_read and
blog_get_page_content_friends are no longer available.
  • Loading branch information...
jdalsem committed Jul 2, 2015
1 parent 45d1c2f commit a437f9525c6c96ff34f372e6ee26583f92e51793
@@ -422,6 +422,8 @@ Also note that plugins should not be accessing the global ``$CONFIG`` variable e
Removed Functions
-----------------
- ``blog_get_page_content_friends``
- ``blog_get_page_content_read``
- ``count_unread_messages()``
- ``delete_entities()``
- ``delete_object_entity()``
View
@@ -5,48 +5,6 @@
* @package Blog
*/
/**
* Get page components to view a blog post.
*
* @param int $guid GUID of a blog entity.
* @return array
*/
function blog_get_page_content_read($guid = NULL) {
$return = array();
elgg_entity_gatekeeper($guid, 'object', 'blog');
$blog = get_entity($guid);
// no header or tabs for viewing an individual blog
$return['filter'] = '';
elgg_set_page_owner_guid($blog->container_guid);
elgg_group_gatekeeper();
$return['title'] = $blog->title;
$container = $blog->getContainerEntity();
$crumbs_title = $container->name;
if (elgg_instanceof($container, 'group')) {
elgg_push_breadcrumb($crumbs_title, "blog/group/$container->guid/all");
} else {
elgg_push_breadcrumb($crumbs_title, "blog/owner/$container->username");
}
elgg_push_breadcrumb($blog->title);
$return['content'] = elgg_view_entity($blog, array('full_view' => true));
// check to see if we should allow comments
if ($blog->comments_on != 'Off' && $blog->status == 'published') {
$return['content'] .= elgg_view_comments($blog);
}
return $return;
}
/**
* Get page components to list a user's or all blogs.
*
@@ -107,47 +65,6 @@ function blog_get_page_content_list($container_guid = NULL) {
return $return;
}
/**
* Get page components to list of the user's friends' posts.
*
* @param int $user_guid
* @return array
*/
function blog_get_page_content_friends($user_guid) {
$user = get_user($user_guid);
if (!$user) {
forward('blog/all');
}
$return = array();
$return['filter_context'] = 'friends';
$return['title'] = elgg_echo('blog:title:friends');
$crumbs_title = $user->name;
elgg_push_breadcrumb($crumbs_title, "blog/owner/{$user->username}");
elgg_push_breadcrumb(elgg_echo('friends'));
elgg_register_title_button();
$options = array(
'type' => 'object',
'subtype' => 'blog',
'full_view' => false,
'relationship' => 'friend',
'relationship_guid' => $user_guid,
'relationship_join_on' => 'container_guid',
'no_results' => elgg_echo('blog:none'),
'preload_owners' => true,
'preload_containers' => true,
);
$return['content'] = elgg_list_entities_from_relationship($options);
return $return;
}
/**
* Get page components to show blogs with publish dates between $lower and $upper
*
@@ -6,13 +6,33 @@
if (!$user) {
forward('', '404');
}
$params = blog_get_page_content_friends($user->guid);
if (isset($params['sidebar'])) {
$params['sidebar'] .= elgg_view('blog/sidebar', array('page' => $page_type));
} else {
$params['sidebar'] = elgg_view('blog/sidebar', array('page' => $page_type));
}
$params = [];
$params['filter_context'] = 'friends';
$params['title'] = elgg_echo('blog:title:friends');
$crumbs_title = $user->name;
elgg_push_breadcrumb($crumbs_title, "blog/owner/{$user->username}");
elgg_push_breadcrumb(elgg_echo('friends'));
elgg_register_title_button();
$options = array(
'type' => 'object',
'subtype' => 'blog',
'full_view' => false,
'relationship' => 'friend',
'relationship_guid' => $user->getGUID(),
'relationship_join_on' => 'container_guid',
'no_results' => elgg_echo('blog:none'),
'preload_owners' => true,
'preload_containers' => true,
);
$params['content'] = elgg_list_entities_from_relationship($options);
$params['sidebar'] = elgg_view('blog/sidebar', array('page' => $page_type));
$body = elgg_view_layout('content', $params);
@@ -2,14 +2,40 @@
$page_type = $vars['page_type'];
$guid = get_input('guid');
$params = blog_get_page_content_read($guid);
if (isset($params['sidebar'])) {
$params['sidebar'] .= elgg_view('blog/sidebar', array('page' => $page_type));
elgg_entity_gatekeeper($guid, 'object', 'blog');
elgg_group_gatekeeper();
$blog = get_entity($guid);
elgg_set_page_owner_guid($blog->container_guid);
// no header or tabs for viewing an individual blog
$params = [
'filter' => '',
'title' => $blog->title
];
$container = $blog->getContainerEntity();
$crumbs_title = $container->name;
if (elgg_instanceof($container, 'group')) {
elgg_push_breadcrumb($crumbs_title, "blog/group/$container->guid/all");
} else {
$params['sidebar'] = elgg_view('blog/sidebar', array('page' => $page_type));
elgg_push_breadcrumb($crumbs_title, "blog/owner/$container->username");
}
elgg_push_breadcrumb($blog->title);
$params['content'] = elgg_view_entity($blog, array('full_view' => true));
// check to see if we should allow comments
if ($blog->comments_on != 'Off' && $blog->status == 'published') {
$params['content'] .= elgg_view_comments($blog);
}
$params['sidebar'] = elgg_view('blog/sidebar', array('page' => $page_type));
$body = elgg_view_layout('content', $params);
echo elgg_view_page($params['title'], $body);

0 comments on commit a437f95

Please sign in to comment.