Beispiel #1
0
function hj_framework_view_list($list_id, $getter_options = array(), $list_options = array(), $viewer_options = array(), $getter = 'elgg_get_entities')
{
    $default_list_options = array('list_type' => 'list', 'list_class' => null, 'item_class' => null, 'base_url' => current_page_url(), 'num_pages' => 5, 'pagination' => true, 'limit_key' => "__lim_{$list_id}", 'offset_key' => "__off_{$list_id}", 'order_by_key' => "__ord_{$list_id}", 'direction_key' => "__dir_{$list_id}", 'reverse_list' => false);
    $list_options = array_merge($default_list_options, $list_options);
    if (!isset($getter_options['limit'])) {
        $getter_options['limit'] = get_input($list_options['limit_key'], 10);
    }
    if (!isset($getter_options['offset'])) {
        $getter_options['offset'] = get_input($list_options['offset_key'], 0);
    }
    $porder_by = get_input($list_options['order_by_key'], '');
    $pdirection = get_input($list_options['direction_key'], 'DESC');
    $getter_options = hj_framework_get_order_by_clause($porder_by, $pdirection, $getter_options);
    if (isset($list_options['filter_callback']) && is_callable($list_options['filter_callback'])) {
        $getter_options = call_user_func_array($list_options['filter_callback'], array($list_id, $getter_options));
    }
    $getter_options = elgg_trigger_plugin_hook('custom_sql_clause', 'framework:lists', array('list_id' => $list_id, 'list_options' => $list_options, 'viewer_options' => $viewer_options), $getter_options);
    $getter_options['count'] = true;
    $count = $getter($getter_options);
    //error_log(print_r($getter_options, true));
    $getter_options['count'] = false;
    $entities = $getter($getter_options);
    if ($list_options['reverse_list']) {
        $entities = array_reverse($entities);
    }
    $params = array('list_id' => $list_id, 'entities' => $entities, 'count' => $count, 'list_options' => $list_options, 'getter_options' => $getter_options, 'viewer_options' => $viewer_options, 'getter' => $getter);
    if (elgg_view_exists("page/components/grids/{$list_options['list_type']}")) {
        $list = elgg_view("page/components/grids/{$list_options['list_type']}", $params, false, false, 'default');
    } else {
        $list = elgg_view("page/components/grids/list", $params, false, false, 'default');
    }
    if (elgg_is_xhr() && get_input('view') == 'xhr') {
        if (elgg_view_exists("page/components/grids/{$list_options['list_type']}")) {
            $json_list = elgg_view("page/components/grids/{$list_options['list_type']}", $params, false, false, 'xhr');
        } else {
            $json_list = elgg_view("page/components/grids/list", $params, false, false, 'xhr');
        }
        global $XHR_GLOBAL;
        $XHR_GLOBAL['lists'][$list_id] = $json_list;
    }
    return elgg_view('page/components/grids/wrapper', array('body' => $list));
}
Beispiel #2
0
<?php

$list_id = elgg_extract('list_id', $vars, "forumlist");
$container_guids = elgg_extract('container_guids', $vars, ELGG_ENTITIES_ANY_VALUE);
$subtypes = elgg_extract('subtypes', $vars, array('hjforum', 'hjforumtopic'));
$title = false;
$getter_options = array('types' => 'object', 'subtypes' => $subtypes, 'container_guids' => $container_guids);
if (!get_input("__ord_{$list_id}")) {
    $getter_options = hj_framework_get_order_by_clause('e.last_action', 'DESC', $getter_options);
}
$list_options = array('list_type' => 'table', 'list_class' => 'hj-forumlist', 'list_view_options' => array('table' => array('head' => array('forum' => array('text' => elgg_echo('hj:forum:tablecol:forum'), 'sortable' => true, 'sort_key' => 'oe.title'), 'topics' => $container_subtype !== 'hjforum' || HYPEFORUM_SUBFORUMS ? array('text' => elgg_echo('hj:forum:tablecol:topics'), 'sortable' => true, 'sort_key' => 'forum.topics') : NULL, 'posts' => array('text' => elgg_echo('hj:forum:tablecol:posts'), 'sortable' => true, 'sort_key' => 'forum.posts'), 'last_post' => array('text' => elgg_echo('hj:forum:tablecol:last_post'), 'sortable' => true, 'sort_key' => 'e.last_action'), 'menu' => array('text' => '', 'sortable' => false)))), 'pagination' => true);
$viewer_options = array('full_view' => true);
$content .= hj_framework_view_list($list_id, $getter_options, $list_options, $viewer_options, 'elgg_get_entities');
echo elgg_view_module('forum-category', $title, $content);
Beispiel #3
0
<?php

$group = elgg_get_page_owner_entity();
if (HYPEFORUM_CATEGORIES_TOP) {
    // global forum categories are enabled
    $options = array('types' => 'object', 'subtypes' => 'hjforumcategory', 'limit' => 0, 'container_guid' => $group->guid);
    // order by priority
    $options = hj_framework_get_order_by_clause('md.priority', 'ASC', $options);
    $categories = elgg_get_entities($options);
    echo elgg_view_entity_list($categories, array('list_class' => 'forum-category-list'));
} else {
    $params = array('list_id' => "siteforums", 'container_guids' => array($group->guid), 'subtypes' => array('hjforum'));
    echo elgg_view('framework/forum/lists/forums', $params);
}
<?php

$entity = $category = elgg_extract('entity', $vars);
$title = $entity->getTitle();
$container = $entity->getContainerEntity();
if ($container->canEdit()) {
    $handle = elgg_view_icon('cursor-drag-arrow', 'hj-draggable-element-handle');
}
$params = array('entity' => $entity, 'class' => 'elgg-menu-hz elgg-menu-forum-category', 'sort_by' => 'priority', 'handler' => 'forumcategory', 'dropdown' => false);
$menu = elgg_view_menu('entity', $params);
$title = elgg_view_image_block($handle, $title, array('image_alt' => $menu));
$content = elgg_view('framework/bootstrap/object/elements/description', $vars);
$list_id = "fc{$category->guid}";
$getter_options = array('types' => 'object', 'subtypes' => array('hjforum', 'hjforumtopic'), 'relationship' => 'filed_in', 'relationship_guid' => $category->guid, 'inverse_relationship' => true);
if (!get_input("__ord_{$list_id}")) {
    $getter_options = hj_framework_get_order_by_clause('forum.sticky', 'DESC', $getter_options);
}
$list_options = array('list_type' => 'table', 'list_class' => 'hj-forumlist', 'list_view_options' => array('table' => array('head' => array('forum' => array('text' => elgg_echo('hj:forum:tablecol:forum'), 'sortable' => true, 'sort_key' => 'oe.title'), 'topics' => array('text' => elgg_echo('hj:forum:tablecol:topics'), 'sortable' => true, 'sort_key' => 'forum.topics'), 'posts' => array('text' => elgg_echo('hj:forum:tablecol:posts'), 'sortable' => true, 'sort_key' => 'forum.posts'), 'last_post' => array('text' => elgg_echo('hj:forum:tablecol:last_post'), 'sortable' => true, 'sort_key' => 'e.last_action'), 'menu' => array('text' => '', 'sortable' => false)))), 'pagination' => true);
$viewer_options = array('full_view' => true);
$content .= hj_framework_view_list($list_id, $getter_options, $list_options, $viewer_options, 'elgg_get_entities_from_relationship');
$module = elgg_view_module('forum-category', $title, $content);
if ($entity->canEdit()) {
    $module = "<div id=\"uid-{$entity->guid}\"class=\"hj-draggable-element\" data-uid=\"{$entity->guid}\">{$module}</div>";
}
echo $module;