forked from aaronbronow/php-crossword
-
Notifications
You must be signed in to change notification settings - Fork 4
/
demo.php
120 lines (97 loc) · 3.68 KB
/
demo.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
<? require 'init.php'; ?>
<html>
<head>
<meta charset="<?=$charset?>">
<title>PHP Crossword Generator</title>
<style>
body, td { font-family: Courier; font-size: 10pt; }
.crossTable { border-spacing:0px; border-collapse: collapse; }
.cellEmpty { padding: 0px; }
.cellNumber { padding: 1px; background-color: #FFFFFF; border: 0px solid #000000; width: 20px; height: 20px; }
.cellLetter { padding: 1px; background-color: #EEEEEE; border: 1px solid #000000; width: 20px; height: 20px; }
.cellDebug { padding: 1px; border: 1px solid #000000; width: 20px; height: 20px; }
.crossTableA { border-spacing:0px; border-collapse: collapse; }
.cellEmptyA { padding: 0px; }
.cellNumberA { padding: 1px; background-color: #FFFFFF; border: 0px solid #000000; width: 30px; height: 30px; }
.cellLetterA { padding: 1px; background-color: #EEEEEE; border: 1px solid #000000; width: 30px; height: 30px; }
.cellDebugA { padding: 1px; border: 1px solid #000000; width: 30px; height: 30px; }
.crossTableB { border-spacing:0px; border-collapse: collapse; }
.cellEmptyB { padding: 0px; }
.cellNumberB { padding: 1px; background-color: #FFFFFF; border: 0px solid #000000; width: 10px; height: 10px; }
.cellLetterB { padding: 1px; background-color: #EEEEEE; border: 1px solid #000000; width: 10px; height: 10px; }
.cellDebugB { padding: 1px; border: 1px solid #000000; width: 10px; height: 10px; }
</style>
</head>
<body>
<?php $success = $pc->generate(); ?>
<div align="center">
<form>
Columns: <input type="text" name="cols" value="<?=$pc->cols?>" size="5" />
Rows: <input type="text" name="rows" value="<?=$pc->rows?>" size="5" />
Words: <input type="text" name="max_words" value="<?=$pc->max_words?>" size="5" />
Group:
<select name="groupid">
<? foreach ($pc->getGroupIDs() as $groupid): ?>
<option value="<?=$groupid?>" <? if ($groupid == $pc->groupid) echo 'selected'; ?>>
<?=$groupid?> [w: <?=$pc->countWordsInGroup($groupid);?>]
</option>
<? endforeach; ?>
</select>
Colors:
<input type="checkbox" name="colors" value="1" <? if (!empty($_REQUEST['colors'])) echo 'checked'; ?> />
Big blocks?:
<input type="checkbox" name="bigblocks" value="1" <? if (!empty($_REQUEST['bigblocks'])) echo 'checked'; ?> />
<input type="submit" value="Generate" />
</form>
<? if (!$success): ?>
SORRY, UNABLE TO GENERATE DEMO CROSSWORD - TRY WITH MORE AREA OR LESS WORDS.
<? else: ?>
<?
$params = array(
'colors' => (isset($_REQUEST['colors']) && $_REQUEST['colors']) ? $_REQUEST['colors'] : 0,
'fillflag' => 0,
'cellflag' => (isset($_REQUEST['bigblocks']) && $_REQUEST['bigblocks']) ? 'A' : ''
);
$html = $pc->getHTML($params);
$words = $pc->getWords();
?>
<? print "\n\n<hr><!-- break here -->\n\n"; ?>
<p><?=$html?></p>
<!-- <p><b>Words: <?=count($words)?></b></p> -->
<table border=0 align="center" cellpadding=4>
<tr align=left>
<th>Num.</th>
<!-- <th>Word</th> -->
<th>Question</th>
<!-- <th>X</th>
<th>Y</th>
<th>Axis</th> -->
</tr>
<? foreach ($words as $key=>$word): ?>
<tr align=left>
<td><?=$key+1?>.</td>
<!-- <td><?=$word["word"]?></td> -->
<td><?=$word["question"]?></td>
<!-- <td><?=$word["x"]?></td>
<td><?=$word["y"]?></td>
<td><?=$word["axis"]?></td> -->
</tr>
<? endforeach; ?>
</table>
<?=sprintf("<p>Generated in %.4f sec.</p>",(getmicrotime() - $script_start))?>
<p>
<?
$params = array(
'colors' => (isset($_REQUEST['colors']) && $_REQUEST['colors']) ? $_REQUEST['colors'] : 0,
'fillflag' => 1,
'cellflag' => 'B'
);
$html = $pc->getHTML($params);
print "\n\n<hr><!-- break here -->\n\n";
print $html;
print "\n\n<hr><!-- break here -->\n\n";
?>
<? endif; ?>
</div>
</body>
</html>