forked from wikiLingo/wikiLingo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reflect.php
47 lines (37 loc) · 1.06 KB
/
reflect.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
<?php
require_once('vendor/autoload.php');
$plugins = null;
//trap any warnings
ob_start();
//instantiate a script collector
$scripts = new WikiLingo\Utilities\Scripts();
$reflection = (isset($_REQUEST['reflect']) ? $_REQUEST['reflect'] : '');
switch ($reflection) {
//manage wikiLingo to wysiwyg html
case 'wikiLingoWYSIWYG':
$parser = new WikiLingoWYSIWYG\Parser($scripts);
$output = $parser->parse($_REQUEST['w']);
$plugins = $parser->plugins;
break;
//manage wysiwyg html to wikiLingo
case 'WYSIWYGWikiLingo':
$fake = new WikiLingo\Parser();
$parser = new WYSIWYGWikiLingo\Parser($scripts);
$output = $parser->parse($_REQUEST['w']);
break;
//manage wikiLingo to html
default:
$parser = new WikiLingo\Parser($scripts);
$output = $parser->parse($_REQUEST['w']);
$plugins = $parser->plugins;
}
//collect output and return to client
$msg = ob_get_contents();
ob_end_clean();
echo json_encode(array(
'output' => $output,
'script' => $scripts->renderScript(),
'css' => $scripts->renderCss(),
'msg' => $msg,
'plugins' => $plugins
));