Example #1
0
 function parse($info)
 {
     global $prefs, $headerlib;
     $tikilib = TikiLib::lib('tiki');
     //allow for wikiLingo parsing, will only return 'y' if turned on AND enabled for this particular module
     if (isset($info['wikiLingo']) && $info['wikiLingo'] == 'y' && $prefs['feature_wikilingo'] == 'y') {
         //TODO: correct the paths for scripts and output them to the header
         $scripts = new WikiLingo\Utilities\Scripts();
         $parser = new WikiLingo\Parser($scripts);
         $info['data'] = $parser->parse($info['data']);
         $info['title'] = $parser->parse($info['title']);
         /* output css from wikiLingo in a literal so smarty doesn't throw up.
          * NOTE: this is not added to headerlib because it has already passed the opportunity to get more css
          */
         $info['data'] = '{literal}' . $scripts->renderCss() . '{/literal}' . $info['data'];
         //output js to headerlib, because js is at bottom and has not yet been output
         foreach ($scripts->scriptLocations as $scriptLocation) {
             $headerlib->add_jsfile($scriptLocation);
         }
         $headerlib->add_js(implode($scripts->scripts));
     } else {
         if (isset($info['parse']) && $info['parse'] == 'y') {
             $info['data'] = $tikilib->parse_data($info['data'], array('is_html' => true, 'suppress_icons' => true));
             $info['title'] = $tikilib->parse_data($info['title'], array('noparseplugins' => true, 'is_html' => true));
         }
     }
     return $info;
 }
Example #2
0
 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;
 }
Example #3
0
<?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
    //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