-
Notifications
You must be signed in to change notification settings - Fork 0
/
grid.php
372 lines (352 loc) · 13.4 KB
/
grid.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<?php
error_reporting(0);
include 'core/init.php';
protect_page();
$user_id = $_SESSION['user_id'];
$project_id = $activeProject['project_id'];
$factions = get_project_factions($project_id);
foreach ($factions as $faction) {
if ($faction['deleted']) {
continue;
}
if ( ! isset($bearer)) {
$bearer = $faction['faction_num'];
$receiver = $faction['faction_num'];
} else {
$receiver = $faction['faction_num'];
break;
}
}
if ( ! empty($_GET['bearer']) && ! empty($_GET['receiver'])) {
$bearer = $_GET['bearer'];
$receiver = $_GET['receiver'];
}
$bearer_id = mysql_result(mysql_query("SELECT `faction_id` FROM `factions` WHERE `project_id`='$project_id' AND `faction_num`='$bearer'"), 0);
$receiver_id = mysql_result(mysql_query("SELECT `faction_id` FROM `factions` WHERE `project_id`='$project_id' AND `faction_num`='$receiver'"), 0);
$bearer_data = array();
$receiver_data = array();
// Get list of characters in faction 1
$bearer_result = mysql_query("SELECT `character_id`, `character_name`, `faction`, `player_name`, `deleted` FROM `characters` WHERE `project_id`='$project_id' && `faction`='$bearer' ORDER BY `character_id`");
while($row = mysql_fetch_assoc($bearer_result)){
$bearer_data[] = $row;
//data appears as $bearer_data[0]['character_id'] range is 0 to 11
}
// Get list of characters in faction 2
$receiver_result = mysql_query("SELECT `character_id`, `character_name`, `faction`, `player_name`, `deleted` FROM `characters` WHERE `project_id`='$project_id' && `faction`='$receiver' ORDER BY `character_id`");
while($row = mysql_fetch_assoc($receiver_result)){
$receiver_data[] = $row;
//data appears as $receiver_data[0]['character_id'] range is 0 to 11
}
$q = "SELECT `faction_1_id`, `faction_2_id`, `opinion_word`, `opinion_text` FROM `opinions_f2f` WHERE (`project_id`='$project_id' && `faction_1_id`='$bearer_id' && `faction_2_id`='$receiver_id') ORDER BY `faction_1_id`";
$result = mysql_query($q) or die(mysql_error());
$f2f_opinion_word = "Neutral";
$f2f_opinion_text = "No opinion";
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$f2f_opinion_word = $row['opinion_word'];
$f2f_opinion_text = $row['opionion_text'];
}
}
$list = array();
foreach ($bearer_data as $character) {
$list[] = $character['character_id'];
}
$q = "
SELECT `character_1_id`, `faction_2_id`, `opinion_word`, `opinion_text`
FROM `opinions_c2f`
WHERE `project_id`='$project_id'
AND `faction_2_id` = '$receiver_id'
AND `character_1_id` IN ('" . implode("','", $list) . "')
ORDER BY `character_1_id`";
$result = mysql_query($q);
$c2f_data = array();
while ($row = mysql_fetch_assoc($result)) {
$c2f_data[$row['character_1_id']] = array(
'opinion_word' => $row['opinion_word'],
'opinion_text' => $row['opinion_text']
);
}
$q = "
SELECT `character_1_id`, `character_2_id`, `opinion_word`, `opinion_text`
FROM `opinions_c2c`
WHERE `project_id` = '$project_id'
AND `character_1_id` IN ('" . implode("','", $list) . "')
ORDER BY `character_1_id`
";
$result = mysql_query($q);
$c2c_data = array();
while ($row = mysql_fetch_assoc($result)) {
$c2c_data[$row['character_1_id']][$row['character_2_id']] = array(
'opinion_word' => $row['opinion_word'],
'opinion_text' => $row['opinion_text']
);
}
$display_data = array();
foreach ($bearer_data as $character) {
$c2f = (isset($c2f_data[$character['character_id']])) ? $c2f_data[$character['character_id']]['opinion_word'] : $f2f_opinion_word;
$display_data[$character['character_id']] = array(
'character' => $character,
'opposite_faction_opinion' => $c2f
);
foreach ($receiver_data as $target) {
$opinion = $c2f;
if (isset($c2c_data[$character['character_id']]) && isset($c2c_data[$character['character_id']][$target['character_id']])) {
$opinion = $c2c_data[$character['character_id']][$target['character_id']]['opinion_word'];
}
$display_data[$character['character_id']]['targets'][$target['character_id']] = array('opinion' => $opinion, 'deleted' => $target['deleted']);
}
}
$bearer_faction = mysql_result(mysql_query("SELECT `faction_name` FROM `factions` WHERE `project_id`='$project_id' && `faction_num`='$bearer'"), 0);
$receiver_faction = mysql_result(mysql_query("SELECT `faction_name` FROM `factions` WHERE `project_id`='$project_id' && `faction_num`='$receiver'"), 0);
$faction_data = get_faction_data($project_id); //data is used to determine if a faction is deleted
$alpha = array('a','b','c','d','e','f','g','h','i','j','k', 'l','m','n','o'); //used in identifying opinion location
$factionListA = array();
$factionListB = array();
for ($number = 1; $number <= 12; $number++) {
if (isset($faction_data['faction_id_' . $number])) {
if ($faction_data['faction_num_' . $number . '_deleted'] == 0) {
$selected = '';
if ($number == $bearer) {
$selected = 'selected="selected"';
}
$factionListA[] = '<option ' . $selected . ' value="' . $number . '">' . $faction_data["faction_name_" . $number] . '</option>';
}
}
}
for ($number = 1; $number <= 12; $number++) {
if (isset($faction_data['faction_id_' . $number])) {
if ($faction_data['faction_num_' . $number . '_deleted'] == 0) {
$selected = '';
if ($number == $receiver) {
$selected = 'selected="selected"';
}
$factionListB[] = '<option ' . $selected . ' value="' . $number . '">' . $faction_data["faction_name_" . $number] . '</option>';
}
}
}
$columnCount = 0;
foreach ($receiver_data as $data) {
if ( ! $data['deleted']) {
$columnCount++;
}
}
$rowCount = 0;
foreach ($display_data as $data) {
if ( ! $data['character']['deleted']) {
$rowCount++;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/bootstrap-tour.min.css">
<link rel="stylesheet" href="css/primary.css">
<script src="includes/jquery-1.9.0.min.js"></script>
<script type="text/javascript" src="/includes/colorbox.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="javascript/bootstrap-tour.min.js"></script>
<script type="text/javascript">
var user_viewed_tutorial = <?php echo $user_data['viewed_tutorial'];?>;
var user_id = <?php echo $_SESSION['user_id'];?>;
</script>
<script src="javascript/tour.js"></script>
<script>
$(document).ready(function(){
$(".iframe").colorbox();
$(".iframe").colorbox({
iframe:true,
width:"85%",
height:"85%",
top: '20px'
});
});
</script>
<style>
.grid-columns {
position:absolute;
left:0px;
top:69px;
height:<?php echo ($rowCount * 48) + 96;?>px;
width:82px;
background:#104E8B;
/*z-index:999;*/
opacity:.7;
visibility:hidden;
}
#grid_container>.columnfaction {left:132px;}
<?php
$left = 132;
for ($count = 1; $count <= $columnCount; $count++) {
$left += 82;
echo "#grid_container>.column" . $alpha[$count - 1] . " {left: {$left}px;}\n";
} ?>
.hidden_visible{
visibility:hidden;
}
<?php
$rowClasses = '';
for ($count = 1; $count <= $rowCount; $count++) {
$rowClasses .= ".row$count, ";
} ?>
<?php echo substr($rowClasses, 0, -2);?> {
position:absolute;
height:48px;
width:<?php echo ($columnCount * 82) + 164;?>px;
background:red;
/*z-index:999;*/
opacity:.7;
visibility:hidden;
}
<?php
$top = 117;
for ($count = 1; $count <= $rowCount; $count++) {
$top += 48;
echo "#grid_container>.row" . $count . " {top: {$top}px;}\n";
} ?>
/* Hover commands */
.block:hover { /* cell highlight */
background:purple;
}
.faction{
background:black;
color:#00ff00;
}
<?php
$visibleClasses = "#grid_container>.columna:hover,\n";
$visibleClasses .= "#faction2faction:hover~.columnfaction,\n";
for ($count = 1; $count <= $columnCount; $count++) {
$visibleClasses .= "#grid_container>.column" . $alpha[$count - 1] . ":hover, \n";
$visibleClasses .= "#columnheader" . $alpha[$count - 1] . ":hover ~.column" . $alpha[$count - 1] . ",\n";
}
for ($count = 1; $count <= $rowCount; $count++) {
$visibleClasses .= "#character_to_faction_" . $count . ":hover~.columnfaction,\n";
$visibleClasses .= "#grid_container>.row" . $count . ":hover,\n";
$visibleClasses .= "#character_to_faction_" . $count . ":hover~.row" . $count . ",\n";
$visibleClasses .= "#rowheader" . $count . ":hover~.row" . $count . ",\n";
}
for ($columnNum = 0; $columnNum < $columnCount; $columnNum ++) {
$letter = $alpha[$columnNum];
for ($rownum = 1; $rownum <= $rowCount; $rownum++) {
$visibleClasses .= "#block" . $rownum . $letter . ":hover~.row" . $rownum . ",\n";
$visibleClasses .= "#block" . $rownum . $letter . ":hover~.column" . $letter . ",\n";
}
$visibleClasses .= "#block" . $rowCount . $letter . ":hover~.column,\n";
}
?>
<?php echo substr($visibleClasses, 0, -2);?> {
visibility: visible;
}
</style>
</head>
<body>
<div id="container">
<div class="logo">
<img src="/images/Factionizerlogo.png">
</div>
<!-- <h1>The Factionizer - Project: <?php echo $activeProject['project_name'];?></h1> -->
<ul class="menu">
<li><a href="index.php">Home</a></li>
<li><a href="new_project.php">New</a></li>
<li><a href="load.php">Open</a></li>
<li><a href="edit_project.php">Edit Project</a></li>
<li class="selected"><a href="grid.php">Grid</a></li>
<li id="character-cards"><a href="character_card.php" target="_blank">Character Cards</a></li>
<li id="print-character-cards"><a href="print.php" target="_blank">Print CC's</a></li>
</ul>
<div id="grid_container">
<?php if ( ! empty($factionListA)) : ?>
<form class="faction_picker" action="">
How <select class="dropdown" name="bearer" id="faction-left">
<?php
foreach ($factionListA as $item) {
echo $item;
}
?>
</select> feels about <select class="dropdown" name="receiver" id="faction-top">
<?php
foreach ($factionListB as $item) {
echo $item;
}
?>
</select>
<input class="btn btn-primary" type="submit" value="Update">
<button id="tour-start-grid" class="btn btn-primary" style="float:right;"><i class="fa fa-question-circle" style="color: #ffffff;"></i> Show the Tour</button>
</form>
<br >
<div class="block hidden_visible"></div>
<div id="columnheader_receiver" class="block faction">
<!--<a class="iframe" href="character_card.php?faction_overview=<?php echo $receiver_id;?>">--><?php echo $receiver_faction;?><!--</a>-->
</div>
<?php
$count = 0;
foreach ($receiver_data as $target) :
if ($target['deleted']) {
continue;
}
$letter = $alpha[$count];
$count++;
?>
<div class="block <?php echo ($target['deleted']) ? 'hidden' : '';?>" id="columnheader<?php echo $letter;?>"><a href="character_card.php?character=<?php echo $target['character_id'];?>" class="iframe"><?php echo $target['character_name'];?></a></div>
<?php endforeach; ?>
<span class="clear"></span>
<div id="rowheader_receiver" class="block faction"><!--<a class="iframe" href="character_card.php?faction_overview=<?php echo $bearer_id;?>">--><?php echo $bearer_faction;?><!--</a>--></div>
<div id="faction2faction" class="block"><a class="iframe" href="input.php?type=f2f&bearer=<?php echo $bearer_id;?>&receiver=<?php echo $receiver_id;?>"><?php echo $f2f_opinion_word;?></a></div>
<span class="clear"></span>
<?php
$row = 1;
foreach ($display_data as $source) :
$count = 0;
if ($source['character']['deleted']) {
continue;
}
?>
<div id="rowheader<?php echo $row;?>" class="block">
<a class="iframe" href="character_card.php?character=<?php echo $source['character']['character_id'];?>"><?php echo $source['character']['character_name'];?></a>
</div>
<div id="character_to_faction_<?php echo $row;?>" class="block">
<a class="iframe" href="input.php?type=c2f&bearer=<?php echo $source['character']['character_id'];?>&receiver=<?php echo $receiver_id;?>"><?php echo $source['opposite_faction_opinion'];?></a>
</div>
<?php foreach ($source['targets'] as $target_id => $target) :
if ($target['deleted']) {
continue;
}
$letter = $alpha[$count];
$count++;
$class = '';
if ($source['character']['character_id'] == $target_id) {
$class = 'block-self';
}
?>
<div id="block<?php echo $row . $letter;?>" class="<?php echo $class;?> block">
<?php if ($source['character']['character_id'] == $target_id) : ?>
<a class="iframe" href="character_bio.php?character=<?php echo $source['character']['character_id'];?>">SELF</a>
<?php else : ?>
<a class="iframe" href="input.php?type=c2c&bearer=<?php echo $source['character']['character_id'];?>&receiver=<?php echo $target_id;?>"><?php echo $target['opinion'];?></a>
<?php endif; ?>
</div>
<?php endforeach;
$row++;
?>
<span class="clear"></span>
<?php endforeach; ?>
<?php /* ADD BUTTONS (cut into email) */ ?>
<div class="columnfaction grid-columns"></div>
<?php for ($columnNum = 0; $columnNum < $columnCount; $columnNum++) {
$letter = $alpha[$columnNum]; ?>
<div class="column<?php echo $letter;?> grid-columns"></div>
<?php } ?>
<?php for ($rowNum = 0; $rowNum < $rowCount; $rowNum++) { ?>
<div class="row<?php echo $rowNum + 1;?>" id="row-<?php echo $rowNum + 1;?>"></div>
<?php } ?>
<?php else: ?>
<p>No factions configured or all factions deleted.</p>
<a href="edit_project.php">Edit Project</a>
<?php endif; ?>
<?php include 'includes/footer.php'; ?>
</div>
</div>
</body>
</html>