Exemplo n.º 1
0
function get_create_forms($page)
{
    $parent_guid = 0;
    switch ($page[0]) {
        case "blog":
            echo "<h2>Add a Blog</h2>";
            elgg_load_library('elgg:blog');
            $body_vars = blog_prepare_form_vars();
            echo elgg_view_form('blog/save', array(), array_merge($body_vars, $vars));
            exit;
        case "event":
            echo "<h2>Add an Event</h2>";
            elgg_set_page_owner_guid(elgg_get_logged_in_user_guid());
            echo elgg_view("event_manager/forms/event/edit");
            exit;
        case "group":
            echo "<h2>" . elgg_echo('groups:add') . "</h2>";
            elgg_load_library('elgg:groups');
            elgg_set_page_owner_guid(elgg_get_logged_in_user_guid());
            elgg_push_breadcrumb($title);
            if (elgg_get_plugin_setting('limited_groups', 'groups') != 'yes' || elgg_is_admin_logged_in()) {
                $content = elgg_view('groups/edit');
            } else {
                $content = elgg_echo('groups:cantcreate');
            }
            echo $content;
            exit;
        case "project":
            echo "<h2>" . elgg_echo('projects:add') . "</h2>";
            $vars = projects_prepare_form_vars(null, $parent_guid);
            $content = elgg_view_form('projects/edit', array('enctype' => 'multipart/form-data'), $vars);
            echo $content;
            exit;
        case "page":
            elgg_load_library('elgg:pages');
            echo "<h2>" . elgg_echo('pages:add') . "</h2>";
            $vars = pages_prepare_form_vars(null, $parent_guid);
            $content = elgg_view_form('pages/edit', array(), $vars);
            echo $content;
            exit;
        case "answer":
            echo "<h2>" . elgg_echo('answers:add') . "</h2>";
            elgg_set_page_owner_guid(elgg_get_logged_in_user_guid());
            echo elgg_view("answers/forms/question", array('container_guid' => elgg_get_page_owner_guid()));
            exit;
        case "task":
            elgg_load_library('elgg:tasks');
            echo "<h2>" . elgg_echo('tasks:add') . "</h2>";
            $vars = tasks_prepare_form_vars(null, $parent_guid);
            $content = elgg_view_form('tasks/edit', array(), $vars);
            echo $content;
            exit;
    }
}
/**
 * Get page components to edit/create a 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($page, $guid = 0, $revision = NULL)
{
    elgg_load_js('elgg.blog');
    $return = array('filter' => '');
    $vars = array();
    $vars['id'] = 'blog-post-edit';
    $vars['name'] = 'blog_post';
    $vars['class'] = 'elgg-form-alt';
    if ($page == 'edit') {
        $blog = get_entity((int) $guid);
        $title = elgg_echo('blog:edit');
        if (elgg_instanceof($blog, 'object', 'blog') && $blog->canEdit()) {
            $vars['entity'] = $blog;
            $title .= ": \"{$blog->title}\"";
            if ($revision) {
                $revision = elgg_get_annotation_from_id((int) $revision);
                $vars['revision'] = $revision;
                $title .= ' ' . elgg_echo('blog:edit_revision_notice');
                if (!$revision || !($revision->entity_guid == $guid)) {
                    $content = elgg_echo('blog:error:revision_not_found');
                    $return['content'] = $content;
                    $return['title'] = $title;
                    return $return;
                }
            }
            $body_vars = blog_prepare_form_vars($blog, $revision);
            elgg_push_breadcrumb($blog->title, $blog->getURL());
            elgg_push_breadcrumb(elgg_echo('edit'));
            elgg_load_js('elgg.blog');
            $content = elgg_view_form('blog/save', $vars, $body_vars);
            $sidebar = elgg_view('blog/sidebar/revisions', $vars);
        } else {
            $content = elgg_echo('blog:error:cannot_edit_post');
        }
    } else {
        if (!$guid) {
            $container = elgg_get_logged_in_user_entity();
        } else {
            $container = get_entity($guid);
        }
        elgg_push_breadcrumb(elgg_echo('blog:add'));
        $body_vars = blog_prepare_form_vars($blog);
        $title = elgg_echo('blog:add');
        $content = elgg_view_form('blog/save', $vars, $body_vars);
    }
    $return['title'] = $title;
    $return['content'] = $content;
    $return['sidebar'] = $sidebar;
    return $return;
}
Exemplo n.º 3
0
                return $params;
            }
        }
        $body_vars = blog_prepare_form_vars($blog, $revision);
        elgg_push_breadcrumb($blog->title, $blog->getURL());
        elgg_push_breadcrumb(elgg_echo('edit'));
        elgg_load_js('elgg.blog');
        $content = elgg_view_form('blog/save', $vars, $body_vars);
        $sidebar = elgg_view('blog/sidebar/revisions', $vars);
    } else {
        $content = elgg_echo('blog:error:cannot_edit_post');
    }
} else {
    if (!$guid) {
        $container = elgg_get_logged_in_user_entity();
    } else {
        $container = get_entity($guid);
    }
    elgg_push_breadcrumb(elgg_echo('blog:add'));
    $body_vars = blog_prepare_form_vars($blog);
    $title = elgg_echo('blog:add');
    $content = elgg_view_form('blog/save', $vars, $body_vars);
    $blog_js = elgg_get_simplecache_url('js', 'blog/save_draft');
    elgg_register_js('elgg.blog', $blog_js);
}
$params['title'] = $title;
$params['content'] = $content;
$params['sidebar'] = $sidebar;
$params['sidebar'] .= elgg_view('blog/sidebar', array('page' => $page_type));
$body = elgg_view_layout('content', $params);
echo elgg_view_page($params['title'], $body);
Exemplo n.º 4
0
        $class = 'wall-form';
        if ($default !== 'poll') {
            $class .= ' hidden';
        }
        $forms .= elgg_view_form('poll/edit', array('id' => 'wall-form-poll', 'class' => $class, 'enctype' => 'multipart/form-data'), $vars);
    }
}
// add blog support through blog plugin
if (elgg_is_active_plugin('blog') && elgg_get_plugin_setting('blog', HYPEWALL_EXTENDED_ID) == HYPEWALL_EXTENDED_GENERAL_YES) {
    elgg_load_library('elgg:blog');
    elgg_register_menu_item('wall-filter', array('name' => 'blog', 'text' => '<i class="wall-icon wall-icon-blog"></i>', 'title' => elgg_echo('hypeWall_extended:blog'), 'href' => '#wall-form-blog', 'link_class' => 'wall-tab', 'selected' => $default == 'blog', 'priority' => 400));
    $class = 'wall-form';
    if ($default !== 'blog') {
        $class .= ' hidden';
    }
    $body_vars = blog_prepare_form_vars(null);
    $forms .= elgg_view_form('blog/save', array('id' => 'wall-form-blog', 'class' => $class, 'title' => '', 'enctype' => 'multipart/form-data'), $body_vars);
}
// add events support through event_manager plugin
if (elgg_is_active_plugin('event_manager') && elgg_get_plugin_setting('event_manager', HYPEWALL_EXTENDED_ID) == HYPEWALL_EXTENDED_GENERAL_YES) {
    $who_create_site_events = elgg_get_plugin_setting('who_create_site_events', 'event_manager');
    if ($who_create_site_events != 'admin_only' || elgg_is_admin_logged_in()) {
        elgg_register_menu_item('wall-filter', array('name' => 'event', 'text' => '<i class="wall-icon wall-icon-event"></i>', 'title' => elgg_echo('hypeWall_extended:event'), 'href' => elgg_normalize_url('events/event/new'), 'style' => "font-size: {$icon_size}%;", 'selected' => $default == 'event', 'priority' => 500));
        $class = 'wall-form';
        if ($default !== 'event') {
            $class .= ' hidden';
        }
        $forms .= elgg_view_form('wall/events', array('id' => 'wall-form-event', 'class' => $class, 'enctype' => 'multipart/form-data'), $vars);
    }
}
echo $forms;