コード例 #1
0
ファイル: htmlconvert.php プロジェクト: hurcane/tiki-azure
function tf($page, &$startTime, &$endTime)
{
    global $xcludeContent;
    //The new parser strips all \r and lets \n do all the line break work
    $syntax = $page['data'];
    $syntax = str_replace("\r", '', $syntax);
    // Determine the page syntax type
    $is_html = isset($page['is_html']) ? $page['is_html'] == 1 : false;
    $parser = new JisonParser_Wiki_Handler();
    $WysiwygParser = new JisonParser_WikiCKEditor_Handler();
    $parserHtmlToWiki = new JisonParser_Html_Handler();
    // Parse
    $startTime = getMicroTime();
    if (!$is_html) {
        $wikiSyntax = $syntax;
        $html = $WysiwygParser->parse($wikiSyntax);
        $wiki = $parserHtmlToWiki->parse($html);
    } else {
        $htmlSyntax = $syntax;
        $wikiSyntax = $parserHtmlToWiki->parse($htmlSyntax);
        $html = $WysiwygParser->parse($wikiSyntax);
        $wiki = $parserHtmlToWiki->parse($html);
    }
    $endTime = getMicroTime();
    $success = $wikiSyntax == $wiki;
    if ($success == false && !$xcludeContent) {
        echo "\n";
        echo '"' . $wikiSyntax . '"';
        echo "\n---------------------" . mb_detect_encoding($wikiSyntax) . "-------------------------\n";
        echo $html;
        echo "\n----------------------------------------------\n";
        echo '"' . $wiki . '"';
        echo "\n----------------------" . mb_detect_encoding($wiki) . "------------------------\n";
    }
    echo $success ? "\tSUCCESS" : "\tFAILURE";
    unset($parser);
    unset($WysiwygParser);
    unset($parserHtmlToWiki);
    unset($html);
    return $success;
}
コード例 #2
0
ファイル: tiki-editpage.php プロジェクト: hurcane/tiki-azure
             $real_len = $real_start;
             $real_start = 0;
         } else {
             list($real_start, $real_len) = $tikilib->get_wiki_section($info['data'], $_REQUEST['hdr']);
         }
     } else {
         include_once 'lib/wiki-plugins/wikiplugin_split.php';
         list($real_start, $real_len) = wikiplugin_split_cell($info['data'], $_REQUEST['pos'], $_REQUEST['cell']);
     }
     if ($edit[strlen($edit) - 1] !== "\n") {
         $edit .= "\r\n";
     }
     $edit = substr($info['data'], 0, $real_start) . $edit . substr($info['data'], $real_start + $real_len);
 }
 if (isset($_REQUEST['jisonWyisywg']) && $_REQUEST['jisonWyisywg'] == 'true' && $prefs['feature_jison_wiki_parser'] == 'y' && $prefs['feature_wysiwyg'] === 'y') {
     $parser = new JisonParser_Html_Handler();
     print_r($edit);
     $edit = $parser->parse($edit);
     print_r($edit);
     print_r(Tikilib::getOne('select data from tiki_pages where pageName = ?', array($page)));
     die;
 } else {
     if ($_SESSION['wysiwyg'] === 'y' && $prefs['wysiwyg_wiki_parsed'] === 'y' && $prefs['wysiwyg_ckeditor'] === 'y') {
         $edit = $editlib->partialParseWysiwygToWiki($edit);
     }
 }
 $tikilib->update_page($_REQUEST["page"], $edit, $_REQUEST["comment"], $user, $tikilib->get_ip_address(), $description, $minor, $pageLang, $is_html, $hash, null, $_REQUEST['wysiwyg'], $wiki_authors_style);
 $info_new = $tikilib->get_page_info($page);
 // Handle translation bits
 if ($prefs['feature_multilingual'] === 'y' && !$minor) {
     global $multilinguallib;
コード例 #3
0
ファイル: Html.php プロジェクト: jkimdon/cohomeals
 function lexer_performAction(&$yy, $yy_, $avoiding_name_collisions, $YY_START = null)
 {
     $YYSTATE = $YY_START;
     switch ($avoiding_name_collisions) {
         case 0:
             //A tag that doesn't need to track state
             if (JisonParser_Html_Handler::isHtmlTag($yy_->yytext) == true) {
                 $yy_->yytext = $this->inlineTag($yy_->yytext);
                 return "HTML_TAG_INLINE";
             }
             //A non-valid html tag, return "<" put the rest back into the parser
             if (isset($yy_->yytext[0])) {
                 $tag = $yy_->yytext;
                 $yy_->yytext = $yy_->yytext[0];
                 $this->unput(substr($tag, 1));
             }
             return 7;
             break;
         case 1:
             //A tag that was left open, and needs to close
             $name = end($this->htmlElementsStack);
             $keyStack = key($this->htmlElementStack);
             end($this->htmlElementStack[$keyStack]);
             $keyElement = key($this->htmlElementStack[$keyStack]);
             $tag =& $this->htmlElementStack[$keyStack][$keyElement];
             $tag['state'] = 'repaired';
             if (!empty($tag['name'])) {
                 $this->unput('</' . $tag['name'] . '>');
             }
             return 7;
             break;
         case 2:
             //A tag that is open and we just found the close for it
             $element = $this->unStackHtmlElement($yy_->yytext);
             if ($this->compareElementClosingToYytext($element, $yy_->yytext) && $this->htmlElementsStackCount == 0) {
                 $yy_->yytext = $element;
                 $this->popState();
                 return "HTML_TAG_CLOSE";
             }
             return 7;
             break;
         case 3:
             //An tag open
             if (JisonParser_Html_Handler::isHtmlTag($yy_->yytext) == true) {
                 if ($this->stackHtmlElement($yy_->yytext)) {
                     if ($this->htmlElementsStackCount == 1) {
                         $this->begin('htmlElement');
                         return "HTML_TAG_OPEN";
                     }
                 }
                 return 7;
             }
             //A non-valid html tag, return the first character in the stack and put the rest back into the parser
             if (isset($yy_->yytext[0])) {
                 $tag = $yy_->yytext;
                 $yy_->yytext = $yy_->yytext[0];
                 $this->unput(substr($tag, 1));
             }
             return 'CONTENT';
             break;
         case 4:
             //A tag that was not opened, needs to be ignored
             return 7;
             break;
         case 5:
             return 7;
             break;
         case 6:
             return 7;
             break;
         case 7:
             if ($this->htmlElementsStackCount == 0 || $this->isStaticTag == true) {
                 return 8;
             }
             return 'CONTENT';
             break;
         case 8:
             return 7;
             break;
         case 9:
             return 5;
             break;
     }
 }
コード例 #4
0
ファイル: Wiki.php プロジェクト: jkimdon/cohomeals
 function lexer_performAction(&$yy, $yy_, $avoiding_name_collisions, $YY_START = null)
 {
     $YYSTATE = $YY_START;
     switch ($avoiding_name_collisions) {
         case 0:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 1:
             if ($this->npStack != true) {
                 return 'CONTENT';
             }
             $this->popState();
             $this->npStack = false;
             $yy_->yytext = $this->noParse($yy_->yytext);
             return 'NO_PARSE_END';
             break;
         case 2:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->begin('np');
             $this->npStack = true;
             return 'NO_PARSE_START';
             break;
         case 3:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 4:
             if ($this->ppStack != true) {
                 return 'CONTENT';
             }
             $this->popState();
             $this->ppStack = false;
             $yy_->yytext = $this->preFormattedText($yy_->yytext);
             return 'PRE_FORMATTED_TEXT_END';
             break;
         case 5:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->begin('pp');
             $this->ppStack = true;
             return 'PRE_FORMATTED_TEXT_START';
             break;
         case 6:
             return 12;
             break;
         case 7:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             return 'DOUBLE_DYNAMIC_VAR';
             break;
         case 8:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             return 'SINGLE_DYNAMIC_VAR';
             break;
         case 9:
             if ($this->isContent(array('linkStack'))) {
                 return 'CONTENT';
             }
             return 'ARGUMENT_VAR';
             break;
         case 10:
             return 55;
             break;
         case 11:
             return 11;
             //For now let individual plugins handle else
             break;
         case 12:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->begin('block');
             return 'BLOCK_START';
             break;
         case 13:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $yy_->yytext = $this->inlinePlugin($yy_->yytext);
             return 'INLINE_PLUGIN';
             break;
         case 14:
             if ($this->npStack == true || $this->ppStack) {
                 return 'CONTENT';
             }
             $this->begin('plugin');
             $this->stackPlugin($yy_->yytext);
             if (count($this->pluginStack) == 1) {
                 return 'PLUGIN_START';
             } else {
                 return 'CONTENT';
             }
             break;
         case 15:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 16:
             $plugin = end($this->pluginStack);
             if ('{' . $plugin['name'] . '}' == $yy_->yytext) {
                 $this->popState();
                 if (!empty($this->pluginStack)) {
                     if (count($this->pluginStack) > 0 && substr($yy_->yytext, 1, -1) == $this->pluginStack[count($this->pluginStack) - 1]['name']) {
                         if (count($this->pluginStack) == 1) {
                             $yy_->yytext = $this->pluginStack[count($this->pluginStack) - 1];
                             $this->pluginStackCount--;
                             array_pop($this->pluginStack);
                             return 'PLUGIN_END';
                         } else {
                             $this->pluginStackCount--;
                             array_pop($this->pluginStack);
                             return 'CONTENT';
                         }
                     }
                 }
             }
             return 'CONTENT';
             break;
         case 17:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 18:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->popState();
             return 'BLOCK_END';
             break;
         case 19:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->begin('block');
             return 'BLOCK_START';
             break;
         case 20:
             if ($this->isContent() || !empty($this->tableStack)) {
                 return 'CONTENT';
             }
             return 'LINE_END';
             break;
         case 21:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             return 'HORIZONTAL_BAR';
             break;
         case 22:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             return 'FORCED_LINE_END';
             break;
         case 23:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 24:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->popState();
             return 'BOLD_END';
             break;
         case 25:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->begin('bold');
             return 'BOLD_START';
             break;
         case 26:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 27:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->popState();
             return 'BOX_END';
             break;
         case 28:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->begin('box');
             return 'BOX_START';
             break;
         case 29:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 30:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->popState();
             return 'CENTER_END';
             break;
         case 31:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->begin('center');
             return 'CENTER_START';
             break;
         case 32:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 33:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->popState();
             return 'CODE_END';
             break;
         case 34:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->begin('code');
             return 'CODE_START';
             break;
         case 35:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 36:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->popState();
             return 'COLOR_END';
             break;
         case 37:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->begin('color');
             return 'COLOR_START';
             break;
         case 38:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 39:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->popState();
             return 'ITALIC_END';
             break;
         case 40:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->begin('italic');
             return 'ITALIC_START';
             break;
         case 41:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 42:
             if ($this->isContent(array('linkStack'))) {
                 return 'CONTENT';
             }
             $this->popState();
             return 'UNLINK_END';
             break;
         case 43:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->begin('unlink');
             return 'UNLINK_START';
             break;
         case 44:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 45:
             if ($this->isContent(array('linkStack'))) {
                 return 'CONTENT';
             }
             $this->linkStack = false;
             $this->popState();
             return 'LINK_END';
             break;
         case 46:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->linkStack = true;
             $this->begin('link');
             $yy_->yytext = 'external';
             return 'LINK_START';
             break;
         case 47:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 48:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->popState();
             return 'STRIKE_END';
             break;
         case 49:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->begin('strike');
             return 'STRIKE_START';
             break;
         case 50:
             return 40;
             break;
         case 51:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 52:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->popState();
             array_pop($this->tableStack);
             return 'TABLE_END';
             break;
         case 53:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->begin('table');
             $this->tableStack[] = true;
             return 'TABLE_START';
             break;
         case 54:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 55:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->popState();
             return 'TITLE_BAR_END';
             break;
         case 56:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->begin('titleBar');
             return 'TITLE_BAR_START';
             break;
         case 57:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 58:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->popState();
             return 'UNDERSCORE_END';
             break;
         case 59:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->begin('underscore');
             return 'UNDERSCORE_START';
             break;
         case 60:
             $this->conditionStackCount = 0;
             $this->conditionStack = array();
             return 5;
             break;
         case 61:
             if ($this->isContent(array('linkStack'))) {
                 return 'CONTENT';
             }
             $this->linkStack = false;
             $this->popState();
             return 'WIKI_LINK_END';
             break;
         case 62:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->linkStack = true;
             $this->begin('wikiLink');
             $yy_->yytext = array('type' => 'wiki', 'syntax' => $yy_->yytext);
             return 'WIKI_LINK_START';
             break;
         case 63:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->linkStack = true;
             $this->begin('wikiLink');
             $yy_->yytext = array('type' => 'np', 'syntax' => $yy_->yytext);
             return 'WIKI_LINK_START';
             break;
         case 64:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             $this->linkStack = true;
             $this->begin('wikiLink');
             $yy_->yytext = array('syntax' => $yy_->yytext, 'type' => substr($yy_->yytext, 1, -1));
             return 'WIKI_LINK_START';
             break;
         case 65:
             if ($this->isContent()) {
                 return 'CONTENT';
             }
             return 'WIKI_LINK';
             break;
         case 66:
             return 55;
             break;
         case 67:
             if (JisonParser_Html_Handler::isHtmlTag($yy_->yytext)) {
                 return 'HTML_TAG';
             }
             $tag = $yy_->yytext;
             $yy_->yytext = $yy_->yytext[0];
             $this->unput(substr($tag, 1));
             return 'CONTENT';
             break;
         case 68:
             return 20;
             break;
         case 69:
             return 11;
             break;
         case 70:
             return 11;
             break;
         case 71:
             return 11;
             break;
         case 72:
             return 11;
             break;
         case 73:
             return 11;
             break;
         case 74:
             return 55;
             break;
         case 75:
             return 55;
             break;
         case 76:
             return 55;
             break;
         case 77:
             return 55;
             break;
         case 78:
             return 55;
             break;
         case 79:
             return 55;
             break;
         case 80:
             return 55;
             break;
         case 81:
             return 55;
             break;
         case 82:
             return 55;
             break;
         case 83:
             return 55;
             break;
         case 84:
             return 55;
             break;
         case 85:
             return 55;
             break;
         case 86:
             return 55;
             break;
         case 87:
             return 11;
             break;
         case 88:
             return 5;
             break;
     }
 }
コード例 #5
0
ファイル: Handler.php プロジェクト: jkimdon/cohomeals
 public function elementFromTag(&$tag, &$contents = null, $parse = false)
 {
     if ($parse == true) {
         $parser = new JisonParser_Html_Handler();
         $parser->isStaticTag(true);
         $contents = $parser->parse($contents);
         unset($parser);
     }
     switch ($tag['state']) {
         case "closed":
             $element = $tag['open'] . $contents . $tag['close'];
             break;
         case "repaired":
             $element = $tag['open'] . $contents;
             break;
         case "inline":
             $element = $tag['open'];
             break;
     }
     return $element;
 }