$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 //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 //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));
function action_wikiLingo(JitFilter $input) { global $user, $prefs, $page; $tikilib = TikiLib::lib('tiki'); $globalPerms = Perms::get(); $page = urldecode($input->page->none()); if (!self::page_editable($input->autoSaveId->text(), $page)) { return array(); } $scripts = new WikiLingo\Utilities\Scripts("vendor/wikilingo/wikilingo/"); $wikiLingo = new WikiLingo\Parser($scripts); require_once "lib/wikiLingo_tiki/WikiLingoEvents.php"; new WikiLingoEvents($wikiLingo); if ($input->wysiwyg->int() == 1) { $toWikiLingo = new WYSIWYGWikiLingo\Parser(); $data = $input->data->none(); $source = $toWikiLingo->parse($data); } else { $source = $input->data->none(); } $result = array(); //save a wiki page if ($input->save->int() === 1) { $wysiwyg = $input->wysiwyg->int(); $info = $tikilib->get_page_info($page, false); $exists = $tikilib->page_exists($page); $wiki_authors_style = ''; if ($prefs['wiki_authors_style_by_page'] === 'y') { $wiki_authors_style_updated = $input->wiki_authors_style->text(); if ($globalPerms->admin_wiki && !empty($wiki_authors_style_updated)) { $wiki_authors_style = $wiki_authors_style_updated; } elseif (isset($info['wiki_authors_style'])) { $wiki_authors_style = $info['wiki_authors_style']; } } $hash = array('lock_it' => !$input->lock_it->text() === 'on' ? 'y' : 'n', 'comments_enabled' => $input->comments_enabled->text() === 'on' ? 'y' : 'n', 'contributions' => $input->contributions->text(), 'contributors' => $input->contributors->text()); if ($exists) { $tikilib->update_page($page, $source, $input->comment->text() ?: $info['comment'], $user, $tikilib->get_ip_address(), $input->description->text() ?: $info['description'], $input->isminor->text() === 'on' ? 1 : 0, $input->lang->text() ?: $info['lang'], false, $hash, null, $wysiwyg == 0 ? 'n' : 'y', $wiki_authors_style); $result['status'] = 'updated'; } else { $tikilib->create_page($page, 0, $source, $tikilib->now, $input->comment->text(), $user, $tikilib->get_ip_address(), $input->description->text(), $input->lang->text(), false, $hash, $wysiwyg == 0 ? 'n' : 'y', $wiki_authors_style); $result['status'] = 'created'; } } $version = $result['version'] = $tikilib->getOne("SELECT version FROM `tiki_pages` WHERE pageName=? ORDER BY `version` DESC", array($page)); $tikilib->query("INSERT INTO tiki_output (entityId, objectType, outputType, version) VALUES (?,?,?,?)", array($page, 'wikiPage', 'wikiLingo', $version)); if ($input->preview->bool()) { $result['parsed'] = $wikiLingo->parse($source); $result['script'] = $scripts->renderScript(); $result['css'] = $scripts->renderCss(); } return $result; }
<?php require_once "vendor/autoload.php"; use WikiLingo\Event; use WikiLingo\Expression; $original = "{TABS()}{TAB(title=`Misc.`)}\n||item1|item2\nitem3|item4||\n # <> &\n''Test'' %argument%\n!!!Test\n/*Comments ''Parsed?''*/\n~~blue:hello world~~\n<a href='http://google.com'>This is a link to Google</a>\n<script>alert('test');</script>\n-~This ''Is a test'' ~-\n{TAB}{TAB(title=`Unordered List`)}\n*1.1\n*1.2\n**2.1\n**2.2\n*****5.1\n*****5.2\n*****5.3\n**2.3\n*1.3\n{TAB}{TAB(title=`Ordered List`)}\n#__Test__\n#__Test__\n##__Test__\n##__Test__\n#####__Test__\n#####__Test__\n#####__Test__\n##__Test__\n#__Test__\n{TAB}{TABS}\n\n!+Header\n{ILLEGAL()}\n <script>alert('t');</script>\n{ILLEGAL}\n\n{ACCORDIONS()}\n\t{ACCORDION(title=`Thumb Wars`)}{flash movie=`https://youtube.googleapis.com/v/lJ06RKGcPBI`}{ACCORDION}\n\t{ACCORDION(title=`ThumbTanic`)}{flash movie=`http://www.youtube.com/v/Rgdd8kMeaj0`}{ACCORDION}\n\t{ACCORDION(title=`BatThumb`)}{flash movie=`https://www.youtube.com/v/HUlbfmKtKcw`}{ACCORDION}\n{ACCORDIONS}\n\n"; $scripts = (new WikiLingo\Utilities\Scripts())->addCssLocation("//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css")->addScriptLocation("//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js")->addScriptLocation("http://code.jquery.com/ui/1.10.3/jquery-ui.js"); $wikiLingo = new WikiLingo\Parser($scripts); $wikiLingoWYSIWYG = new WikiLingoWYSIWYG\Parser($scripts); $wYSIWYGWikiLingo = new WYSIWYGWikiLingo\Parser(); /* Type::Events($wikiLingo->events) ->bind(new Event\Expression\Tag\Allowed(function(&$expression) { if (!$expression->allowed) { } })) ->bind(new Event\Parsed\RenderPermission(function(Parsed &$parsed) { if ( $parsed->type == "Plugin" && $parsed->expression->type == "illegal" ) { $parsed->expressionPermissible = false; } })) ->bind(new Event\Parsed\RenderBlocked(function(Parsed &$parsed, &$return) { $return = ''; })) ->bind(new Event\Expression\Variable\Lookup(function($key, &$element) {