Пример #1
0
/**
* Returns a list of events to be used in left / right rails of different pages.
*
* @param int $market_id
* @param bool $refreshed - prevents infinite loop if the function had to be called again .
* @return Array - list of object with url, and title
*
* @todo : add a check that it's not a barcrawl
*/
function getLeftRailEvents($query, $refresh = false)
{
    global $cache_refresh;
    $cache_key = 'cache::leftrail:market';
    foreach ($query as $key => $value) {
        $cache_key .= '::' . $key . ':' . $value;
    }
    $cache_name = $cache_key;
    if (!$cache_refresh && !$refresh) {
        $left_events = \mem($cache_name);
    }
    if (!$left_events) {
        $left_events = [];
        $left_eventIds = \Crave\Model\ct_event::getList($query);
        foreach ($left_eventIds as $id) {
            $obj = new stdClass();
            $e = new \Crave\Api\Event(['id' => $id, 'no_tickets' => true]);
            $obj->url = parseEventUrl($e);
            $obj->title = $e->is->bc ? $e->event_name : $e->where->name;
            $left_events[] = $obj;
        }
        \mem($cache_name, $left_events, $event_cache_duration);
    } else {
        if (!$refresh && !is_array($left_events)) {
            // there has been a problem with the cached data .
            // calling the function again while refreshing the cache
            return getLeftRailEvents($query, true);
        }
    }
    return $left_events;
}
Пример #2
0
if (!isset($a)) {
    // Setup the query
    $a = $website->site_criteria;
    if (isset($_GET['q']) && !empty($_GET['q'])) {
        $a['where'][] = "(venue.name ilike '%{$_GET[q]}%' OR ct_event.name ilike '%{$_GET[q]}%')";
    }
    if (isset($filters) && is_array($filters)) {
        $a = array_merge($a, $filters);
    } else {
        $filters = [];
    }
}
// $a['where'][] = " ct_event.id = 5366 " ;
// get the left rail events (if applicable)
if ($left_rail_query) {
    $left_events = getLeftRailEvents($left_rail_query);
} else {
    if ($auto_set_left_rail) {
        $left_rail_query = ['override_order_by' => true, 'order_by' => 'venue.name', 'min' => true];
        $left_rail_query = array_merge($a, $left_rail_query);
    }
}
// making sure the ct_promoter_id is provided
$a['seller__ct_promoter_id'] = $website->ct_promoter_id;
$nhoods = [];
$ages = [];
$event_types = [];
$event_times = [];
$cache_filters = [];
foreach ($a as $key => $value) {
    if (is_array($value)) {