Ejemplo n.º 1
0
 function hours()
 {
     $raw = hours::select()->where($this)->many();
     $hours = array(null, null, null, null, null, null, null);
     foreach ($raw as $h) {
         if ($h->forDay('mon')) {
             $hours[0] = $h;
         }
         if ($h->forDay('tue')) {
             $hours[1] = $h;
         }
         if ($h->forDay('wed')) {
             $hours[2] = $h;
         }
         if ($h->forDay('thu')) {
             $hours[3] = $h;
         }
         if ($h->forDay('fri')) {
             $hours[4] = $h;
         }
         if ($h->forDay('sat')) {
             $hours[5] = $h;
         }
         if ($h->forDay('sun')) {
             $hours[6] = $h;
         }
     }
     return $hours;
 }
Ejemplo n.º 2
0
<?php

$city = city::select()->where("`name` = '?'", $parts[1])->one();
if ($city === false) {
    return 404;
}
$smarty->contentType('text', 'json');
$venues = venue::select()->where(isset($parts[2]) ? array($city, 'type' => $parts[2]) : $city)->order_by('title')->many();
echo '{"license": "Copyright, All Rights Reserved, Usage of this data without explicit permission is strictly forbidden!", "name": "' . $city->name . '", "title": "' . $city->title . '", "data": [';
foreach ($venues as $key => $venue) {
    if ($key > 0) {
        echo ",";
    }
    $data = $venue->get_row();
    $hours = hours::select()->where($venue)->many();
    unset($data['id']);
    unset($data['city_id']);
    $data['hours'] = array(null, null, null, null, null, null, null);
    foreach ($hours as $hour) {
        foreach (explode(',', $hour->weekday) as $day) {
            switch ($day) {
                case 'mon':
                    $data['hours'][0] = array($hour->open, $hour->close);
                    break;
                case 'tue':
                    $data['hours'][1] = array($hour->open, $hour->close);
                    break;
                case 'wed':
                    $data['hours'][2] = array($hour->open, $hour->close);
                    break;
                case 'thu':