Пример #1
0
 function parse($input)
 {
     $result = "";
     if ($this->parsing == true) {
         $parser = end(self::$spareParsers);
         if (!empty($parser) && $parser->parsing == false) {
             $result = $parser->parse($input);
         } else {
             self::$spareParsers[] = $parser = new JisonParser_Wiki_Handler();
             $result = $parser->parse($input);
         }
     } else {
         $this->parsing = true;
         $result = parent::parse($input);
         $this->parsing = false;
     }
     return $result;
 }
Пример #2
0
 public function stack($level, $content)
 {
     JisonParser_Wiki_Handler::deleteEntities($content);
     $id = implode('_', JisonParser_Phraser_Handler::sanitizeToWords($content));
     if (isset($this->idCount[$id])) {
         $this->idCount[$id]++;
         $id .= $this->idCount[$id];
     } else {
         $this->idCount[$id] = 0;
     }
     if ($level == 1) {
         $this->stack[] = array('content' => $content, 'id' => $id, 'children' => array());
     } else {
         $this->addToStack($this->stack, 1, $level, $content, $id);
     }
     return $id;
 }
Пример #3
0
    function output(&$data, &$params, &$index, &$parser)
    {
        global $headerlib;
        $tempParser = new JisonParser_Wiki_Handler();
        $tempParser->list = new WikiPlugin_expandingoutline_list($parser->list, $tempParser);
        $id = $this->id($index);
        $headerlib->add_jq_onready(<<<JQ
\t\t(function() {
\t\t\tvar base = \$('#{$id}')
\t\t\t\t.click(function(e) {
\t\t\t\t\tif (e.shiftKey) {
\t\t\t\t\t\tvar lists = base.find('.tikiListTableChild');
\t\t\t\t\t\tvar imgs = base.find('.listImg');

\t\t\t\t\t\tif (lists.first().is(':visible')) {
\t\t\t\t\t\t\tlists.hide();
\t\t\t\t\t\t\tswitchImg(imgs);
\t\t\t\t\t\t} else {
\t\t\t\t\t\t\tlists.show();
\t\t\t\t\t\t\tswitchImg(imgs);
\t\t\t\t\t\t}
\t\t\t\t\t}
\t\t\t\t});

\t\t\tvar labels = base.find('td.tikiListTableLabel');

\t\t\tfunction switchImg(img) {
\t\t\t\tvar newImg = img.first().data('altimg');
\t\t\t\tvar oldImg = img.first().attr('src');

\t\t\t\timg
\t\t\t\t\t.attr('src', newImg)
\t\t\t\t\t.data('altimg', oldImg);
\t\t\t}

\t\t\tlabels
\t\t\t\t.toggle(function(e) {
\t\t\t\t    if (e.shiftKey) {
\t\t\t\t\t\tlabels.show();
\t\t\t\t\t\treturn;
\t\t\t\t    }

\t\t\t\t\tvar child = base.find('.parentTrail' + \$(this).data('trail'));

\t\t\t\t\tif (child.stop().fadeIn().length) {
\t\t\t\t\t\tswitchImg(\$(this).find('img.listImg'));
\t\t\t\t\t}
\t\t\t\t}, function(e) {
\t\t\t\t\tif (e.shiftKey) {
\t\t\t\t\t\tlabels.hide();
\t\t\t\t\t\treturn;
\t\t\t\t    }

\t\t\t\t\tvar child = base.find('.parentTrail' + \$(this).data('trail'));

\t\t\t\t\tif (child.stop().fadeOut().length) {
\t\t\t\t\t\tswitchImg(\$(this).find('img.listImg'));
\t\t\t\t\t}
\t\t\t\t});
\t\t})();
JQ
);
        $headerlib->add_css(".wikiplugin_expandingoutline table {\n\t\t\t\twidth: 100%;\n\t\t\t\tborder-collapse:collapse;\n\t\t\t\tborder-width: 0px;\n\t\t\t}\n\t\t\t.wikiplugin_expandingoutline * {\n\t\t\t\tborder-width: 0px;\n\t\t\t\tpadding: 0px;\n\t\t\t}\n\t\t\t.wikiplugin_expandingoutline .tikiListTable td, #{$id} .tikiListTable {\n\t\t\t\tfont-size: 14px;\n\t\t\t\tbackground-color: white;\n\t\t\t\tlist-style-type: none;\n\t\t\t}\n\t\t\t.wikiplugin_expandingoutline .tikiListTableLabel\n\t\t\t{\n\t\t\t\twidth: 1px;\n\t\t\t\twhite-space: nowrap;\n\t\t\t\tcursor: pointer;\n\t\t\t}\n\n\t\t\t.wikiplugin_expandingoutline .tikiListTableChild {\n\t\t\t\tdisplay: none;\n\t\t\t}\n\n\t\t\t.wikiplugin_expandingoutline .tier0 {\n\t\t\t\tbackground-color: rgb(255,37,6) ! important;\n\t\t\t}\n\t\t\t.wikiplugin_expandingoutline .tier1 {\n\t\t\t\tbackground-color: rgb(254,143,17) ! important;\n\t\t\t}\n\t\t\t.wikiplugin_expandingoutline .tier2 {\n\t\t\t\tbackground-color: rgb(249,245,41) ! important;\n\t\t\t}\n\t\t\t.wikiplugin_expandingoutline .tier3 {\n\t\t\t\tbackground-color: rgb(111,244,81) ! important;\n\t\t\t}\n\t\t\t.wikiplugin_expandingoutline .tier4 {\n\t\t\t\tbackground-color: rgb(83,252,243) ! important;\n\t\t\t}\n\t\t\t.wikiplugin_expandingoutline .tier5 {\n\t\t\t\tbackground-color: rgb(138,158,251) ! important;\n\t\t\t}\n\t\t\t.wikiplugin_expandingoutline .tier6 {\n\t\t\t\tbackground-color: rgb(206,127,250) ! important;\n\t\t\t}\n\t\t\t.wikiplugin_expandingoutline .tier7 {\n\t\t\t\tbackground-color: rgb(250,167,251) ! important;\n\t\t\t}\n\t\t\t.wikiplugin_expandingoutline .tier8 {\n\t\t\t\tbackground-color: rgb(255,214,188) ! important;\n\t\t\t}\n\t\t\t.wikiplugin_expandingoutline .tier9 {\n\t\t\t\tbackground-color: rgb(255,214,51) ! important;\n\t\t\t}");
        $result = $tempParser->parse($data);
        unset($tempParser);
        return $result;
    }
Пример #4
0
 function parse_data($data, $options = null)
 {
     global $tikilib;
     // Don't bother if there's nothing...
     if (function_exists('mb_strlen')) {
         if (mb_strlen($data) < 1) {
             return;
         }
     }
     global $page_regex, $slidemode, $prefs, $ownurl_father, $tiki_p_upload_picture, $page, $page_ref_id, $user, $tikidomain, $tikiroot;
     $wikilib = TikiLib::lib('wiki');
     // Handle parsing options
     if ($options == null) {
         $options = array();
     }
     $options['is_html'] = $is_html = isset($options['is_html']) ? $options['is_html'] : false;
     $options['absolute_links'] = $absolute_links = isset($options['absolute_links']) ? $options['absolute_links'] : false;
     $options['language'] = $language = isset($options['language']) ? $options['language'] : '';
     $options['noparseplugins'] = $noparseplugins = isset($options['noparseplugins']) ? $options['noparseplugins'] : false;
     $options['stripplugins'] = $stripplugins = isset($options['stripplugins']) ? $options['stripplugins'] : false;
     $options['noheaderinc'] = $noheaderinc = isset($options['noheaderinc']) ? $options['noheaderinc'] : false;
     $options['page'] = isset($options['page']) ? $options['page'] : $page;
     $options['print'] = isset($options['print']) ? $options['print'] : false;
     $options['parseimgonly'] = isset($options['parseimgonly']) ? $options['parseimgonly'] : false;
     $options['preview_mode'] = isset($options['preview_mode']) ? (bool) $options['preview_mode'] : false;
     $options['suppress_icons'] = isset($options['suppress_icons']) ? (bool) $options['suppress_icons'] : false;
     $options['parsetoc'] = isset($options['parsetoc']) ? (bool) $options['parsetoc'] : true;
     $options['inside_pretty'] = isset($options['inside_pretty']) ? $options['inside_pretty'] : false;
     $options['process_wiki_paragraphs'] = isset($options['process_wiki_paragraphs']) ? $options['process_wiki_paragraphs'] : true;
     $options['min_one_paragraph'] = isset($options['min_one_paragraph']) ? $options['min_one_paragraph'] : false;
     $options['skipvalidation'] = isset($options['skipvalidation']) ? $options['skipvalidation'] : false;
     if (empty($options['ck_editor'])) {
         $options['ck_editor'] = false;
     }
     $old_wysiwyg_parsing = null;
     if ($options['ck_editor']) {
         $headerlib = TikiLib::lib('header');
         $old_wysiwyg_parsing = $headerlib->wysiwyg_parsing;
         $headerlib->wysiwyg_parsing = true;
     }
     //The following will stop and return based off new parser
     if ($prefs['feature_jison_wiki_parser'] == 'y') {
         //Testing new parser ;)
         $parser = new JisonParser_Wiki_Handler();
         return $parser->parse($data);
     }
     // if simple_wiki is true, disable some wiki syntax
     // basically, allow wiki plugins, wiki links and almost
     // everything between {}
     $simple_wiki = false;
     if ($prefs['feature_wysiwyg'] == 'y' and $is_html) {
         if ($prefs['wysiwyg_wiki_semi_parsed'] == 'y') {
             $simple_wiki = true;
         } elseif ($prefs['wysiwyg_wiki_parsed'] == 'n') {
             return $data;
         }
     }
     $this->parse_wiki_argvariable($data, $options);
     /* <x> XSS Sanitization handling */
     // Converts &lt;x&gt; (<x> tag using HTML entities) into the tag <x>. This tag comes from the input sanitizer (XSS filter).
     // This is not HTML valid and avoids using <x> in a wiki text,
     //   but hide '<x>' text inside some words like 'style' that are considered as dangerous by the sanitizer.
     $data = str_replace(array('&lt;x&gt;', '~np~', '~/np~'), array('<x>', '~np~', '~/np~'), $data);
     // Fix false positive in wiki syntax
     //   It can't be done in the sanitizer, that can't know if the input will be wiki parsed or not
     $data = preg_replace('/(\\{img [^\\}]+li)<x>(nk[^\\}]+\\})/i', '\\1\\2', $data);
     // Process pre_handlers here
     if (is_array($this->pre_handlers)) {
         foreach ($this->pre_handlers as $handler) {
             $data = $handler($data);
         }
     }
     // Handle pre- and no-parse sections and plugins
     $preparsed = array('data' => array(), 'key' => array());
     $noparsed = array('data' => array(), 'key' => array());
     if (!$noparseplugins || $stripplugins) {
         $this->parse_first($data, $preparsed, $noparsed, $options);
         $this->parse_wiki_argvariable($data, $options);
     }
     // Handle ~pre~...~/pre~ sections
     $data = preg_replace(';~pre~(.*?)~/pre~;s', '<pre>$1</pre>', $data);
     // Strike-deleted text --text-- (but not in the context <!--[if IE]><--!> or <!--//--<!CDATA[//><!--
     if (!$simple_wiki) {
         // FIXME produces false positive for strings contining html comments. e.g: --some text<!-- comment -->
         $data = preg_replace("#(?<!<!|//)--([^\\s>].+?)--#", "<strike>\$1</strike>", $data);
     }
     // Handle comment sections
     $data = preg_replace(';~tc~(.*?)~/tc~;s', '', $data);
     $data = preg_replace(';~hc~(.*?)~/hc~;s', '<!-- $1 -->', $data);
     // Replace special characters
     // done after url catching because otherwise urls of dyn. sites will be modified
     // not done in wysiwyg mode, i.e. $prefs['feature_wysiwyg'] set to something other than 'no' or not set at all
     //			if (!$simple_wiki and $prefs['feature_wysiwyg'] == 'n')
     //above line changed by mrisch - special functions were not parsing when wysiwyg is set but wysiswyg is not enabled
     // further changed by nkoth - why not parse in wysiwyg mode as well, otherwise it won't parse for display/preview?
     // must be done before color as we can have ~hs~~hs
     // jb 9.0 html entity fix - excluded not $options['is_html'] pages
     if (!$simple_wiki && !$options['is_html']) {
         $this->parse_htmlchar($data, $options);
     }
     //needs to be before text color syntax because of use of htmlentities in lib/core/WikiParser/OutputLink.php
     $data = $this->parse_data_wikilinks($data, $simple_wiki, $options['ck_editor']);
     if (!$simple_wiki) {
         // Replace colors ~~foreground[,background]:text~~
         // must be done before []as the description may contain color change
         $parse_color = 1;
         while ($parse_color) {
             // handle nested colors, parse innermost first
             $data = preg_replace("/~~([^~:,]+)(,([^~:]+))?:([^~]*)(?!~~[^~:,]+(?:,[^~:]+)?:[^~]*~~)~~/Ums", "<span style=\"color:\$1; background-color:\$3\">\$4</span>", $data, -1, $parse_color);
         }
     }
     // Extract [link] sections (to be re-inserted later)
     $noparsedlinks = array();
     // This section matches [...].
     // Added handling for [[foo] sections.  -rlpowell
     if (!$simple_wiki) {
         preg_match_all("/(?<!\\[)(\\[[^\\[][^\\]]+\\])/", $data, $noparseurl);
         foreach (array_unique($noparseurl[1]) as $np) {
             $key = '§' . md5($tikilib->genPass()) . '§';
             $aux["key"] = $key;
             $aux["data"] = $np;
             $noparsedlinks[] = $aux;
             $data = preg_replace('/(^|[^a-zA-Z0-9])' . preg_quote($np, '/') . '([^a-zA-Z0-9]|$)/', '\\1' . $key . '\\2', $data);
         }
     }
     // BiDi markers
     $bidiCount = 0;
     $bidiCount = preg_match_all("/(\\{l2r\\})/", $data, $pages);
     $bidiCount += preg_match_all("/(\\{r2l\\})/", $data, $pages);
     $data = preg_replace("/\\{l2r\\}/", "<div dir='ltr'>", $data);
     $data = preg_replace("/\\{r2l\\}/", "<div dir='rtl'>", $data);
     $data = preg_replace("/\\{lm\\}/", "&lrm;", $data);
     $data = preg_replace("/\\{rm\\}/", "&rlm;", $data);
     // smileys
     $data = $this->parse_smileys($data);
     $data = $this->parse_data_dynamic_variables($data, $options['language']);
     if (!$simple_wiki) {
         // Replace boxes
         $delim = isset($prefs['feature_simplebox_delim']) && $prefs['feature_simplebox_delim'] != "" ? preg_quote($prefs['feature_simplebox_delim']) : preg_quote("^");
         $data = preg_replace("/{$delim}(.+?){$delim}/s", "<div class=\"simplebox\">\$1</div>", $data);
         // Underlined text
         $data = preg_replace("/===(.+?)===/", "<u>\$1</u>", $data);
         // Center text
         if ($prefs['feature_use_three_colon_centertag'] == 'y') {
             $data = preg_replace("/:::(.+?):::/", "<div style=\"text-align: center;\">\$1</div>", $data);
         } else {
             $data = preg_replace("/::(.+?)::/", "<div style=\"text-align: center;\">\$1</div>", $data);
         }
     }
     // reinsert hash-replaced links into page
     foreach ($noparsedlinks as $np) {
         $data = str_replace($np["key"], $np["data"], $data);
     }
     $data = $this->parse_data_externallinks($data, $options);
     $data = $this->parse_data_tables($data, $simple_wiki);
     if (!$simple_wiki && $options['parsetoc']) {
         $this->parse_data_process_maketoc($data, $options, $noparsed);
     } else {
         $data = $this->parse_data_simple($data);
     }
     // linebreaks using %%%
     $data = preg_replace("/\n?%%%/", "<br />", $data);
     // Close BiDi DIVs if any
     for ($i = 0; $i < $bidiCount; $i++) {
         $data .= "</div>";
     }
     // Put removed strings back.
     $this->replace_preparse($data, $preparsed, $noparsed, $is_html, $options);
     // Process pos_handlers here
     foreach ($this->pos_handlers as $handler) {
         $data = $handler($data);
     }
     if ($old_wysiwyg_parsing !== null) {
         $headerlib->wysiwyg_parsing = $old_wysiwyg_parsing;
     }
     return $data;
 }
Пример #5
0
 /**
  * tag creation, should only be used with items that are directly related to wiki syntax, buttons etc, should use createWikiHelper
  *
  * @access  public
  * @param   $syntaxType string from what syntax type
  * @param   $tagType string what output tag type
  * @param   $content string what is inside the tag
  * @param   $params array what params to add to the tag, array, key = param, value = value
  * @param   $type string the content to be ignored and for tag to close, ie <tag />
  * @return  string  $tag desired output from syntax
  */
 public function createWikiTag($syntaxType, $tagType, $content = "", $params = array(), $type = "standard")
 {
     if ($type != "close") {
         $params['data-i'] = self::incrementTypeIndex($syntaxType);
         $params['data-t'] = self::typeShorthand($syntaxType);
         if (!isset($params['class'])) {
             $params['class'] = "";
         }
         $params['class'] .= " jpwc";
         //Jison Parser Wiki CKEditor tag :)
         $params['class'] = trim($params['class']);
     }
     if ($this->isRepairing($syntaxType) == true) {
         $params['data-repair'] = true;
     }
     return parent::createWikiTag($syntaxType, $tagType, $content, $params, $type);
 }