Beispiel #1
0
<?php

$username = get_input('username');
$user = get_user_by_username($username);
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));
}
$body = elgg_view_layout('content', $params);
echo elgg_view_page($params['title'], $body);
Beispiel #2
0
/**
 * Dispatches blog pages.
 * URLs take the form of
 *  All blogs:       blog/all
 *  User's blogs:    blog/owner/<username>
 *  Friends' blog:   blog/friends/<username>
 *  User's archives: blog/archives/<username>/<time_start>/<time_stop>
 *  Blog post:       blog/view/<guid>/<title>
 *  New post:        blog/add/<guid>
 *  Edit post:       blog/edit/<guid>/<revision>
 *  Preview post:    blog/preview/<guid>
 *  Group blog:      blog/group/<guid>/all
 *
 * Title is ignored
 *
 * @todo no archives for all blogs or friends
 *
 * @param array $page
 * @return bool
 */
function blog_page_handler($page)
{
    elgg_load_library('elgg:blog');
    // @todo remove the forwarder in 1.9
    // forward to correct URL for blog pages pre-1.7.5
    blog_url_forwarder($page);
    // push all blogs breadcrumb
    elgg_push_breadcrumb(elgg_echo('blog:blogs'), "blog/all");
    if (!isset($page[0])) {
        $page[0] = 'all';
    }
    $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 'view':
        case 'read':
            // Elgg 1.7 compatibility
            $params = blog_get_page_content_read($page[1]);
            break;
        case 'add':
            gatekeeper();
            $params = blog_get_page_content_edit($page_type, $page[1]);
            break;
        case 'edit':
            gatekeeper();
            $params = blog_get_page_content_edit($page_type, $page[1], $page[2]);
            break;
        case 'group':
            if ($page[2] == 'all') {
                $params = blog_get_page_content_list($page[1]);
            } else {
                $params = blog_get_page_content_archive($page[1], $page[3], $page[4]);
            }
            break;
        case 'all':
            $params = blog_get_page_content_list();
            break;
        default:
            return false;
    }
    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));
    }
    $body = elgg_view_layout('content', $params);
    echo elgg_view_page($params['title'], $body);
    return true;
}
Beispiel #3
0
/**
 * Dispatches blog pages.
 * URLs take the form of
 *  All blogs:       blog/all
 *  User's blogs:    blog/owner/<username>
 *  Friends' blog:   blog/friends/<username>
 *  User's archives: blog/archives/<username>/<time_start>/<time_stop>
 *  Blog post:       blog/view/<guid>/<title>
 *  New post:        blog/add/<guid>
 *  Edit post:       blog/edit/<guid>/<revision>
 *  Preview post:    blog/preview/<guid>
 *  Group blog:      blog/group/<guid>/all
 *
 * Title is ignored
 *
 * @todo no archives for all blogs or friends
 *
 * @param array $page
 * @return bool
 */
function blog_page_handler($page)
{
    elgg_load_library('elgg:blog');
    // push all blogs breadcrumb
    elgg_push_breadcrumb(elgg_echo('blog:blogs'), "blog/all");
    if (!isset($page[0])) {
        $page[0] = 'all';
    }
    $page_type = $page[0];
    switch ($page_type) {
        case 'owner':
            $user = get_user_by_username($page[1]);
            if (!$user) {
                forward('', '404');
            }
            $params = blog_get_page_content_list($user->guid);
            break;
        case 'friends':
            $user = get_user_by_username($page[1]);
            if (!$user) {
                forward('', '404');
            }
            $params = blog_get_page_content_friends($user->guid);
            break;
        case 'archive':
            $user = get_user_by_username($page[1]);
            if (!$user) {
                forward('', '404');
            }
            $params = blog_get_page_content_archive($user->guid, $page[2], $page[3]);
            break;
        case 'view':
            $params = blog_get_page_content_read($page[1]);
            break;
        case 'add':
            elgg_gatekeeper();
            $params = blog_get_page_content_edit($page_type, $page[1]);
            break;
        case 'edit':
            elgg_gatekeeper();
            $params = blog_get_page_content_edit($page_type, $page[1], $page[2]);
            break;
        case 'group':
            $group = get_entity($page[1]);
            if (!elgg_instanceof($group, 'group')) {
                forward('', '404');
            }
            if ($page[2] == 'all') {
                $params = blog_get_page_content_list($page[1]);
            } else {
                $params = blog_get_page_content_archive($page[1], $page[3], $page[4]);
            }
            break;
        case 'all':
            $params = blog_get_page_content_list();
            break;
        default:
            return false;
    }
    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));
    }
    $body = elgg_view_layout('content', $params);
    echo elgg_view_page($params['title'], $body);
    return true;
}
<?php

$page_type = get_input('page_type');
$offset = get_input('offset');
$base_url = get_input('base_url');
if ($page_type == 'all') {
    $return = blog_get_page_content_list($offset, $base_url, NULL);
    echo $return['content'];
} elseif ($page_type == 'friends') {
    $user = elgg_get_logged_in_user_entity();
    $return = blog_get_page_content_friends($offset, $base_url, $user->guid);
    echo $return['content'];
} elseif ($page_type == 'owner') {
    $container_guid = get_input('group_guid');
    if (!$container_guid) {
        $container_guid = $user->getGUID();
    }
    $return = blog_get_page_content_list($offset, $base_url, $container_guid);
    echo $return['content'];
}
function blog_get_page_content_list($offset, $base_url, $container_guid = NULL)
{
    $return = array();
    $return['filter_context'] = $container_guid ? 'mine' : 'all';
    $options = array('base_url' => $base_url, 'type' => 'object', 'subtype' => 'blog', 'full_view' => false, 'offset' => $offset);
    $current_user = elgg_get_logged_in_user_entity();
    if ($container_guid) {
        // access check for closed groups
        group_gatekeeper();
        $options['container_guid'] = $container_guid;
        $container = get_entity($container_guid);