-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb_json.php
121 lines (80 loc) · 2.59 KB
/
web_json.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
require_once 'header.php';
require_once 'props_store.php';
require_once 'utils.php';
require_once 'knobs.php';
if (isset($_REQUEST['mode']))
{
if ($_REQUEST['mode'] == "pre")
{
$aj = array();
$aj['status'] = 'The schedule for Barcamp is created on the morning itself. It will be available accordingly.';
$file = fopen("web.json", "w");
echo fwrite($file, json_encode($aj));
fclose($file);
print_r($aj);
exit;
}
}
define('WP_USE_THEMES', false);
/** Loads the WordPress Environment and Template */
require($WP_BLOG_HEADER_PATH);
header("HTTP/1.1 200 OK");
$aj = array();
$version = getProperty("ANDROID_JSON_VERSION");
$aj['version'] = $version;
$aj['status'] = "have stuff";
$aj['tracks'] = $TRACKS;
$schedule = getSchedule();
$slotCounter = 0;
$schedulableSlotCounter = 0;
$slotsArray = array();
foreach ($SLOTS as $slot)
{
$t = array();
if ($slot['type'] == "fixed")
{
$t['type'] = 'fixed';
$t['startTime'] = $slot['start'];
$t['endTime'] = $slot['end'];
$t['time'] = $slot['display_string'];
$t['name'] = $slot['name'];
$t['id'] = ++$slotCounter;
} else
{ // type session
$t['type'] = "session";
$t['startTime'] = $slot['start'];
$t['endTime'] = $slot['end'];
$t['time'] = $slot['display_string'];
$t['name'] = $slot['name'];
$t['id'] = ++$slotCounter;
$t['sessions'] = array();
for ($i = 0; $i < $NUM_TRACKS; $i++)
{
$s = array();
$wpquery = new WP_Query(array("p" => $schedule[$schedulableSlotCounter][$i]));
if ($wpquery->have_posts())
{
while ($wpquery->have_posts())
{
$wpquery->the_post();
$s['id'] = get_the_ID();
$s['title'] = get_the_title();
$s['time'] = $slot['display_string'];
$s['location'] = $TRACKS[$i];
$userobj = get_user_by("login", get_the_author_meta("user_login"));
$s['presenter'] = $userobj->data->user_nicename;
array_push($t['sessions'], $s);
}
}
}
$schedulableSlotCounter++;
}
array_push($slotsArray, $t);
}
$aj['slots'] = $slotsArray;
$file = fopen("web.json","w");
echo fwrite($file, json_encode($aj));
fclose($file);
print_r($aj);
?>