-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_wordsearch.php
34 lines (26 loc) · 999 Bytes
/
create_wordsearch.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
<?php
use Jasonmm\WordSearch\WordSearch;
require_once 'vendor/autoload.php';
$config = require_once('config.php');
$page_title = 'Building Word Search...';
$ws = new WordSearch($_REQUEST['title'], $_REQUEST['rows'], $_REQUEST['cols']);
$ws->setWordList(explode("\n", $_REQUEST['wordlist']), $_REQUEST['sort_wordlist']);
$ws->setShowDate(isset($_REQUEST['show_date']));
$ws->setWordsInUppercase(isset($_REQUEST['words_in_uppercase']));
try {
$ws->build($config['MAX_PLACEMENT_TRIES']);
} catch(Exception $e) {
die($e->getMessage());
}
// Create our Twig object.
$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment($loader, array());
$wordSearchHtml = $ws->getHtml($twig, $config['VERSION_STRING']);
// Render the template.
$params = [
'ws' => $ws,
'wordList' => $ws->getWordList("\n"),
'wordSearchObj' => base64_encode(serialize($ws)),
'wordSearchHtml' => $wordSearchHtml,
];
echo $twig->render('create-wordsearch-complete.twig', $params);