Example #1
0
<?php

$guid = elgg_extract('guid', $vars);
$reply_guid = elgg_extract('reply_guid', $vars);
elgg_register_rss_link();
elgg_entity_gatekeeper($guid, 'object', 'discussion');
$entity = get_entity($guid);
elgg_group_gatekeeper(true, $entity->container_guid);
$container = $entity->getContainerEntity();
elgg_set_page_owner_guid($container->guid);
if ($container instanceof ElggGroup) {
    $owner_url = "discussion/group/{$container->guid}";
} else {
    $owner_url = "discussion/owner/{$container->guid}";
}
elgg_push_breadcrumb($container->getDisplayName(), $owner_url);
elgg_push_breadcrumb($entity->title);
$content = elgg_view_entity($entity, ['full_view' => true]);
$content .= elgg_view('discussion/replies', ['topic' => $entity, 'reply' => get_entity($reply_guid), 'show_add_form' => $entity->canWriteToContainer(0, 'object', 'discussion_reply'), 'expand_form' => true, 'full_view' => true]);
$params = array('content' => $content, 'title' => $entity->title, 'sidebar' => elgg_view('discussion/sidebar'), 'filter' => '', 'class' => 'elgg-discussion-layout');
$body = elgg_view_layout('content', $params);
echo elgg_view_page($entity->title, $body);
Example #2
0
File: views.php Project: elgg/elgg
/**
 * Returns a string of a rendered annotation.
 *
 * Annotation views are expected to be in annotation/$annotation_name.
 * If a view is not found for $annotation_name, the default annotation/default
 * will be used.
 *
 * @warning annotation/default is not currently defined in core.
 *
 * The annotation view is called with the following in $vars:
 *  - \ElggEntity 'annotation' The annotation being viewed.
 *
 * @param \ElggAnnotation $annotation The annotation to display
 * @param array           $vars       Variable array for view.
 *      'item_view'  Alternative view used to render an annotation
 * @param bool            $bypass     Ignored and will be removed eventually
 * @param bool            $debug      Complain if views are missing
 *
 * @return string/false Rendered annotation
 */
function elgg_view_annotation(\ElggAnnotation $annotation, array $vars = array(), $bypass = false, $debug = false)
{
    elgg_register_rss_link();
    $defaults = array('full_view' => true);
    $vars = array_merge($defaults, $vars);
    $vars['annotation'] = $annotation;
    $name = $annotation->name;
    if (empty($name)) {
        return false;
    }
    $annotation_views = array(elgg_extract('item_view', $vars, ''), "annotation/{$name}", "annotation/default");
    $contents = '';
    foreach ($annotation_views as $view) {
        if (elgg_view_exists($view)) {
            $contents = elgg_view($view, $vars, $bypass, $debug);
            break;
        }
    }
    return $contents;
}
Example #3
0
File: river.php Project: elgg/elgg
/**
 * List river items
 *
 * @param array $options Any options from elgg_get_river() plus:
 *   item_view  => STR         Alternative view to render list items
 *   pagination => BOOL        Display pagination links (true)
 *   no_results => STR|Closure Message to display if no items
 *
 * @return string
 * @since 1.8.0
 */
function elgg_list_river(array $options = array())
{
    elgg_register_rss_link();
    $defaults = array('offset' => (int) max(get_input('offset', 0), 0), 'limit' => (int) max(get_input('limit', max(20, elgg_get_config('default_limit'))), 0), 'pagination' => true, 'list_class' => 'elgg-list-river', 'no_results' => '');
    $options = array_merge($defaults, $options);
    if (!$options["limit"] && !$options["offset"]) {
        // no need for pagination if listing is unlimited
        $options["pagination"] = false;
    }
    $options['count'] = true;
    $count = elgg_get_river($options);
    if ($count > 0) {
        $options['count'] = false;
        $items = elgg_get_river($options);
    } else {
        $items = array();
    }
    $options['count'] = $count;
    $options['items'] = $items;
    return elgg_view('page/components/list', $options);
}
Example #4
0
/**
 * Returns a viewable list of entities based on the registered types.
 *
 * @see elgg_view_entity_list
 *
 * @param array $options Any elgg_get_entity() options plus:
 *
 * 	full_view => BOOL Display full view entities
 *
 * 	list_type_toggle => BOOL Display gallery / list switch
 *
 * 	allowed_types => true|ARRAY True to show all types or an array of valid types.
 *
 * 	pagination => BOOL Display pagination links
 *
 * @return string A viewable list of entities
 * @since 1.7.0
 */
function elgg_list_registered_entities(array $options = array())
{
    elgg_register_rss_link();
    $defaults = array('full_view' => false, 'allowed_types' => true, 'list_type_toggle' => false, 'pagination' => true, 'offset' => 0, 'types' => array(), 'type_subtype_pairs' => array());
    $options = array_merge($defaults, $options);
    $types = get_registered_entity_types();
    foreach ($types as $type => $subtype_array) {
        if (in_array($type, $options['allowed_types']) || $options['allowed_types'] === true) {
            // you must explicitly register types to show up in here and in search for objects
            if ($type == 'object') {
                if (is_array($subtype_array) && count($subtype_array)) {
                    $options['type_subtype_pairs'][$type] = $subtype_array;
                }
            } else {
                if (is_array($subtype_array) && count($subtype_array)) {
                    $options['type_subtype_pairs'][$type] = $subtype_array;
                } else {
                    $options['type_subtype_pairs'][$type] = ELGG_ENTITIES_ANY_VALUE;
                }
            }
        }
    }
    if (!empty($options['type_subtype_pairs'])) {
        $count = elgg_get_entities(array_merge(array('count' => true), $options));
        if ($count > 0) {
            $entities = elgg_get_entities($options);
        } else {
            $entities = array();
        }
    } else {
        $count = 0;
        $entities = array();
    }
    $options['count'] = $count;
    return elgg_view_entity_list($entities, $options);
}