-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanual.php
123 lines (110 loc) · 3.23 KB
/
manual.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
122
123
<?php
require_once 'knobs.php';
include_once 'header.php';
include_once 'utils.php';
define('WP_USE_THEMES', false);
/** Loads the WordPress Environment and Template */
require($WP_BLOG_HEADER_PATH);
if(isset($_REQUEST['mode'])) {
$sessions_list = array();
for($i = 0; $i < $NUM_SLOTS; $i++) {
for($j = 0; $j < $NUM_TRACKS; $j++) {
$sessions_list[] = $_REQUEST[$i.'_'.$j];
}
}
$sessions_list_unique = array_unique($sessions_list, SORT_NUMERIC);
if(count($sessions_list) == count($sessions_list_unique) ) {
$submit_array = array();
for($i = 0; $i < $NUM_SLOTS; $i++) {
$submit_array[$i] = array();
for($j = 0; $j < $NUM_TRACKS; $j++) {
$submit_array[$i][$j] = array( 'session' => $_REQUEST[$i.'_'.$j], 'usercount' => 0 );
}
}
storeSchedule($submit_array);
}
else {
echo count($sessions_list).' '.count($sessions_list_unique);
$message = "Duplicates in the submitted sessions! Please submit again...";
}
}
$query = new WP_Query( array( "cat" => $THIS_BCB_CATEGORY) );
$sessions = array();
if($query->have_posts()) {
while($query->have_posts()) {
$query->the_post();
$this_post = array();
$this_post['id'] = get_the_ID();
$this_post['title'] = get_the_title();
$this_post['author'] = get_the_author();
//array_push($sessions, $this_post);
$sessions[get_the_ID()] = $this_post;
}
}
$schedule = getSchedule();
function printSelect( $sel_name, $curr_session_id ) {
global $sessions;
echo '<select name="'.$sel_name.'">';
foreach($sessions as $session) {
echo '<option value="'.$session['id'].'"'.($session['id'] == $curr_session_id ? 'selected="selected"' : '').'>'.$session['author'].' - '.$session['title'].'</option>';
}
echo '</select>';
}
?>
<html>
<head>
<title>Manual Scheduling</title>
<link type="text/css" rel="stylesheet" href="./schedule.css" />
</head>
<body>
<div id="error_message">
<?php
if(isset($message)) {
echo $message;
}
?>
</div>
<div id="container">
<form action="" method="POST">
<input type="hidden" name="mode" value="true" />
<table cellpadding="0" cellspacing="0">
<!-- Table Header -->
<tr class="head">
<?php
echo '<td class="col_0"> </td>';
for($i = 0; $i < $NUM_TRACKS; $i++) {
echo '<td class="col">';
echo $TRACKS[$i];
echo '</td>';
}
?>
</tr>
<!-- Session info begins here -->
<?php
$sessions_count = 0;
foreach($SLOTS as $SLOT) {
if($SLOT['type'] == "fixed") {
echo '<tr class="important_slot">';
echo '<td class="col_0">'.$SLOT['display_string'].'</td><td colspan="'.($NUM_TRACKS).'">'.$SLOT['name']."</td></tr>";
}
else {
echo '<tr class="normal_slot">';
echo '<td class="col_0">'.$SLOT['display_string'].'</td>';
for($i = 0; $i < $NUM_TRACKS; $i++) {
$curr_id = $schedule[$sessions_count][$i];
echo '<td class="col">';
echo '<span class="small">'.truncateTitle($sessions[$curr_id]['title'], 40).'</span>';
printSelect( $sessions_count."_".$i, $curr_id);
echo '</td>';
}
echo '</tr>';
$sessions_count++;
}
}
?>
</table>
<button type="submit" name="updateSchedule" value="true">Update</button>
</form>
</div>
</body>
</html>