Пример #1
0
if ($search_type == 'list') {
    $limit = 10;
    $options['limit'] = $limit;
    $entities = event_manager_search_events($options);
    $returnData['content'] = elgg_view_entity_list($entities['entities'], array("count" => $entities['count'], "offset" => $offset, "limit" => $limit, 'full_view' => false, 'pagination' => false));
    if ($entities['count'] - ($offset + $limit) > 0) {
        $returnData['content'] .= '<div id="event_manager_event_list_search_more" rel="' . ($offset + $limit) . '">';
        $returnData['content'] .= elgg_echo('event_manager:list:showmorevents') . ' (' . ($entities['count'] - ($offset + $limit)) . ')</div>';
    }
    if ($entities['count'] < 1) {
        $returnData['content'] .= elgg_echo('event_manager:list:noresults');
    }
} else {
    $options['latitude'] = $latitude;
    $options['longitude'] = $longitude;
    $options['distance'] = $distance;
    $options['limit'] = 50;
    $entities = event_manager_search_events($options);
    foreach ($entities['entities'] as $event) {
        if ($event->location) {
            elgg_push_context("maps");
            $returnData['markers'][] = array('guid' => $event->getGUID(), 'lat' => $event->getLatitude(), 'lng' => $event->getLongitude(), 'title' => $event->title, 'html' => elgg_view_entity($event, array("full_view" => false)), 'hasrelation' => $event->getRelationshipByUser(), 'iscreator' => $event->getOwnerGUID() == elgg_get_logged_in_user_guid() ? 'owner' : null);
            elgg_pop_context();
        }
    }
}
$returnData['count'] = $entities['count'];
$returnData['valid'] = 1;
$returnData['offset'] = $offset;
echo json_encode($returnData);
exit;
Пример #2
0
<?php

$events_options = ['limit' => false, 'past_events' => true];
$start = get_input('start');
$end = get_input('end');
if ($start) {
    $events_options['event_start'] = strtotime($start);
}
if ($end) {
    $events_options['event_end'] = strtotime($end);
}
$container_guid = (int) get_input('container_guid');
if ($container_guid) {
    $events_options['container_guid'] = $container_guid;
}
$events = event_manager_search_events($events_options);
$result = [];
foreach ($events['entities'] as $event) {
    $start = $event->getStartDate();
    $end = $event->getEndDate();
    $event_result = ['title' => $event->title, 'start' => $start, 'end' => $end, 'allDay' => $event->isMultiDayEvent(), 'url' => $event->getURL()];
    $result[] = $event_result;
}
header('Content-type: application/json');
echo json_encode($result);