コード例 #1
0
ファイル: main.inc.php プロジェクト: vvp24/tsvshop
<?php

if (IN_MANAGER_MODE != "true") {
    die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the MODx Content Manager instead of accessing this file directly.");
}
$output .= '<div class="tab-page" id="ShopSales">';
$output .= '<h2 class="tab">' . $shop_lang['sales_title'] . '</h2>';
$output .= '<p><img src="' . TSVSHOP_SURL . 'addons/sales/img/cart.png" alt="' . $shop_lang['sales_title'] . '" class="icon" style="vertical-align: middle; text-align: left; " />' . $shop_lang['sales_intro'];
$output .= '<ul class="actionButtons">';
if ($_GET['act'] == 'vieworder') {
    $output .= '<li id="Button1"><a href="index.php?a=' . $modulea . '&id=' . $moduleid . '" ><img src="' . TSVSHOP_SURL . 'addons/sales/img/back.png"> ' . $shop_lang['sales_back'] . '</a></li>';
}
$output .= '<li id="Button1"><a href="javascript:void(0)" onclick=\'window.location.reload(true);\'><img src="media/style' . $theme . '/images/icons/refresh.png"> ' . $shop_lang['refresh'] . '</a></li>';
$res = $modx->db->select("*", $tsvshop['dborders'], '', 'numorder desc');
if ($modx->db->getRecordCount($res) >= 1 && $_GET['act'] != 'vieworder') {
    $output .= '<li id="Button1"><a href="index.php?a=' . $modulea . '&id=' . $moduleid . '&act=clearorders"><img src="media/style' . $theme . '/images/icons/delete.png"> ' . $shop_lang['sales_delete_all'] . '</a></li><li id="Button1"><a href="#" onclick=\'document.getElementById("check_del").submit();return false;\'><img src="media/style' . $theme . '/images/icons/delete.png"> ' . $shop_lang['sales_del_checked'] . '</a></li>';
}
$output .= '</ul>';
//-- тут вывод сообщений
$output .= $snotice;
$output .= vieworder(TSVSHOP_PATH . 'addons/sales/tpl/orderview.tpl');
if ($_GET['act'] != 'vieworder') {
    $output .= parsetable($res, TSVSHOP_PATH . 'addons/sales/tpl/saletable.tpl');
    $output .= '<script src="' . TSVSHOP_SURL . 'addons/sales/js/script.js" language="javascript" type="text/javascript"></script>';
}
$output .= '</div>';
コード例 #2
0
ファイル: wakka__.php プロジェクト: YesWiki/yeswiki-sandstorm
 function wakka2callbacktableaux($things)
 {
     $thing = $things[1];
     global $wiki;
     if (preg_match("/^\\[\\|(.*)\\|\\]/s", $thing)) {
         $thing = preg_replace("/<br \\/>/", "", $thing);
         return parsetable($thing);
     }
     // if we reach this point, it must have been an accident.
     return $thing;
 }
コード例 #3
0
function discuzcode($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0, $parsetype = '0', $authorid = '0', $allowmediacode = '0', $pid = 0, $lazyload = 0, $pdateline = 0, $first = 0)
{
    global $_G;
    static $authorreplyexist;
    if ($pid && strpos($message, '[/password]') !== FALSE) {
        if ($authorid != $_G['uid'] && !$_G['forum']['ismoderator']) {
            $message = preg_replace_callback("/\\s?\\[password\\](.+?)\\[\\/password\\]\\s?/i", function ($matches) use($pid) {
                return parsepassword($matches[1], $pid);
            }, $message);
            if ($_G['forum_discuzcode']['passwordlock'][$pid]) {
                return '';
            }
        } else {
            $message = preg_replace("/\\s?\\[password\\](.+?)\\[\\/password\\]\\s?/i", "", $message);
            $_G['forum_discuzcode']['passwordauthor'][$pid] = 1;
        }
    }
    if ($parsetype != 1 && !$bbcodeoff && $allowbbcode && (strpos($message, '[/code]') || strpos($message, '[/CODE]')) !== FALSE) {
        $message = preg_replace_callback("/\\s?\\[code\\](.+?)\\[\\/code\\]\\s?/is", function ($matches) {
            return codedisp($matches[1]);
        }, $message);
    }
    $msglower = strtolower($message);
    $htmlon = $htmlon && $allowhtml ? 1 : 0;
    if (!$htmlon) {
        $message = dhtmlspecialchars($message);
    } else {
        $message = preg_replace("/<script[^\\>]*?>(.*?)<\\/script>/i", '', $message);
    }
    if ($_G['setting']['plugins']['func'][HOOKTYPE]['discuzcode']) {
        $_G['discuzcodemessage'] =& $message;
        $param = func_get_args();
        hookscript('discuzcode', 'global', 'funcs', array('param' => $param, 'caller' => 'discuzcode'), 'discuzcode');
    }
    if (!$smileyoff && $allowsmilies) {
        $message = parsesmiles($message);
    }
    if ($_G['setting']['allowattachurl'] && strpos($msglower, 'attach://') !== FALSE) {
        $message = preg_replace_callback("/attach:\\/\\/(\\d+)\\.?(\\w*)/i", function ($matches) {
            return parseattachurl($matches[1], $matches[2], 1);
        }, $message);
    }
    if ($allowbbcode) {
        if (strpos($msglower, 'ed2k://') !== FALSE) {
            $message = preg_replace_callback("/ed2k:\\/\\/(.+?)\\//", function ($matches) {
                return parseed2k($matches[1]);
            }, $message);
        }
    }
    if (!$bbcodeoff && $allowbbcode) {
        if (strpos($msglower, '[/url]') !== FALSE) {
            $message = preg_replace_callback("/\\[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\\/\\/|www\\.|mailto:)?([^\r\n\\[\"']+?))?\\](.+?)\\[\\/url\\]/is", function ($matches) {
                return parseurl($matches[1], $matches[5], $matches[2]);
            }, $message);
        }
        if (strpos($msglower, '[/email]') !== FALSE) {
            $message = preg_replace_callback("/\\[email(=([a-z0-9\\-_.+]+)@([a-z0-9\\-_]+[.][a-z0-9\\-_.]+))?\\](.+?)\\[\\/email\\]/is", function ($matches) {
                return parseemail($matches[1], $matches[4]);
            }, $message);
        }
        $nest = 0;
        while (strpos($msglower, '[table') !== FALSE && strpos($msglower, '[/table]') !== FALSE) {
            $message = preg_replace_callback("/\\[table(?:=(\\d{1,4}%?)(?:,([\\(\\)%,#\\w ]+))?)?\\]\\s*(.+?)\\s*\\[\\/table\\]/is", function ($matches) {
                return parsetable($matches[1], $matches[2], $matches[3]);
            }, $message);
            if (++$nest > 4) {
                break;
            }
        }
        $message = str_replace(array('[/color]', '[/backcolor]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]', '[s]', '[/s]', '[hr]', '[/p]', '[i=s]', '[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]', '[list=A]', "\r\n[*]", '[*]', '[/list]', '[indent]', '[/indent]', '[/float]'), array('</font>', '</font>', '</font>', '</font>', '</div>', '<strong>', '</strong>', '<strike>', '</strike>', '<hr class="l" />', '</p>', '<i class="pstatus">', '<i>', '</i>', '<u>', '</u>', '<ul>', '<ul type="1" class="litype_1">', '<ul type="a" class="litype_2">', '<ul type="A" class="litype_3">', '<li>', '<li>', '</ul>', '<blockquote>', '</blockquote>', '</span>'), preg_replace(array("/\\[color=([#\\w]+?)\\]/i", "/\\[color=((rgb|rgba)\\([\\d\\s,]+?\\))\\]/i", "/\\[backcolor=([#\\w]+?)\\]/i", "/\\[backcolor=((rgb|rgba)\\([\\d\\s,]+?\\))\\]/i", "/\\[size=(\\d{1,2}?)\\]/i", "/\\[size=(\\d{1,2}(\\.\\d{1,2}+)?(px|pt)+?)\\]/i", "/\\[font=([^\\[\\<]+?)\\]/i", "/\\[align=(left|center|right)\\]/i", "/\\[p=(\\d{1,2}|null), (\\d{1,2}|null), (left|center|right)\\]/i", "/\\[float=left\\]/i", "/\\[float=right\\]/i"), array("<font color=\"\\1\">", "<font style=\"color:\\1\">", "<font style=\"background-color:\\1\">", "<font style=\"background-color:\\1\">", "<font size=\"\\1\">", "<font style=\"font-size:\\1\">", "<font face=\"\\1\">", "<div align=\"\\1\">", "<p style=\"line-height:\\1px;text-indent:\\2em;text-align:\\3\">", "<span style=\"float:left;margin-right:5px\">", "<span style=\"float:right;margin-left:5px\">"), $message));
        if ($pid && !defined('IN_MOBILE')) {
            $message = preg_replace_callback("/\\s?\\[postbg\\]\\s*([^\\[\\<\r\n;'\"\\?\\(\\)]+?)\\s*\\[\\/postbg\\]\\s?/is", function ($matches) use($pid) {
                return parsepostbg($matches[1], $pid);
            }, $message);
        } else {
            $message = preg_replace("/\\s?\\[postbg\\]\\s*([^\\[\\<\r\n;'\"\\?\\(\\)]+?)\\s*\\[\\/postbg\\]\\s?/is", "", $message);
        }
        if ($parsetype != 1) {
            if (strpos($msglower, '[/quote]') !== FALSE) {
                $message = preg_replace("/\\s?\\[quote\\][\n\r]*(.+?)[\n\r]*\\[\\/quote\\]\\s?/is", tpl_quote(), $message);
            }
            if (strpos($msglower, '[/free]') !== FALSE) {
                $message = preg_replace("/\\s*\\[free\\][\n\r]*(.+?)[\n\r]*\\[\\/free\\]\\s*/is", tpl_free(), $message);
            }
        }
        if (!defined('IN_MOBILE')) {
            if (strpos($msglower, '[/media]') !== FALSE) {
                $message = preg_replace_callback("/\\[media=([\\w,]+)\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/media\\]/is", function ($matches) use($allowmediacode) {
                    return $allowmediacode ? parsemedia($matches[1], $matches[2]) : bbcodeurl($matches[2], '<a href="{url}" target="_blank">{url}</a>');
                }, $message);
            }
            if (strpos($msglower, '[/audio]') !== FALSE) {
                $message = preg_replace_callback("/\\[audio(=1)*\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/audio\\]/is", function ($matches) use($allowmediacode) {
                    return $allowmediacode ? parseaudio($matches[2], 400) : bbcodeurl($matches[2], '<a href="{url}" target="_blank">{url}</a>');
                }, $message);
            }
            if (strpos($msglower, '[/flash]') !== FALSE) {
                $message = preg_replace_callback("/\\[flash(=(\\d+),(\\d+))?\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/flash\\]/is", function ($matches) use($allowmediacode) {
                    return $allowmediacode ? parseflash($matches[2], $matches[3], $matches[4]) : bbcodeurl($matches[4], '<a href="{url}" target="_blank">{url}</a>');
                }, $message);
            }
        } else {
            if (strpos($msglower, '[/media]') !== FALSE) {
                $message = preg_replace("/\\[media=([\\w,]+)\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/media\\]/is", "[media]\\2[/media]", $message);
            }
            if (strpos($msglower, '[/audio]') !== FALSE) {
                $message = preg_replace("/\\[audio(=1)*\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/audio\\]/is", "[media]\\2[/media]", $message);
            }
            if (strpos($msglower, '[/flash]') !== FALSE) {
                $message = preg_replace("/\\[flash(=(\\d+),(\\d+))?\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/flash\\]/is", "[media]\\4[/media]", $message);
            }
        }
        if ($parsetype != 1 && $allowbbcode < 0 && isset($_G['cache']['bbcodes'][-$allowbbcode])) {
            $message = preg_replace($_G['cache']['bbcodes'][-$allowbbcode]['searcharray'], $_G['cache']['bbcodes'][-$allowbbcode]['replacearray'], $message);
        }
        if ($parsetype != 1 && strpos($msglower, '[/hide]') !== FALSE && $pid) {
            if ($_G['setting']['hideexpiration'] && $pdateline && (TIMESTAMP - $pdateline) / 86400 > $_G['setting']['hideexpiration']) {
                $message = preg_replace("/\\[hide[=]?(d\\d+)?[,]?(\\d+)?\\]\\s*(.*?)\\s*\\[\\/hide\\]/is", "\\3", $message);
                $msglower = strtolower($message);
            }
            if (strpos($msglower, '[hide=d') !== FALSE) {
                $message = preg_replace_callback("/\\[hide=(d\\d+)?[,]?(\\d+)?\\]\\s*(.*?)\\s*\\[\\/hide\\]/is", function ($matches) use($pdateline) {
                    return expirehide($matches[1], $matches[2], $matches[3], $pdateline);
                }, $message);
                $msglower = strtolower($message);
            }
            if (strpos($msglower, '[hide]') !== FALSE) {
                if ($authorreplyexist === null) {
                    if (!$_G['forum']['ismoderator']) {
                        if ($_G['uid']) {
                            $_post = C::t('forum_post')->fetch('tid:' . $_G['tid'], $pid);
                            $authorreplyexist = $_post['tid'] == $_G['tid'] ? C::t('forum_post')->fetch_pid_by_tid_authorid($_G['tid'], $_G['uid']) : FALSE;
                        }
                    } else {
                        $authorreplyexist = TRUE;
                    }
                }
                if ($authorreplyexist) {
                    $message = preg_replace("/\\[hide\\]\\s*(.*?)\\s*\\[\\/hide\\]/is", tpl_hide_reply(), $message);
                } else {
                    $message = preg_replace("/\\[hide\\](.*?)\\[\\/hide\\]/is", tpl_hide_reply_hidden(), $message);
                    $message = '<script type="text/javascript">replyreload += \',\' + ' . $pid . ';</script>' . $message;
                }
            }
            if (strpos($msglower, '[hide=') !== FALSE) {
                $message = preg_replace_callback("/\\[hide=(\\d+)\\]\\s*(.*?)\\s*\\[\\/hide\\]/is", function ($matches) use($pid, $authorid) {
                    return creditshide($matches[1], $matches[2], $pid, $authorid);
                }, $message);
            }
        }
    }
    if (!$bbcodeoff) {
        if ($parsetype != 1 && strpos($msglower, '[swf]') !== FALSE) {
            $message = preg_replace_callback("/\\[swf\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/swf\\]/is", function ($matches) {
                return bbcodeurl($matches[1], ' <img src="' . STATICURL . 'image/filetype/flash.gif" align="absmiddle" alt="" /> <a href="{url}" target="_blank">Flash: {url}</a> ');
            }, $message);
        }
        if (defined('IN_MOBILE') && !defined('TPL_DEFAULT') && !defined('IN_MOBILE_API')) {
            $allowimgcode = false;
        }
        $attrsrc = !IS_ROBOT && $lazyload ? 'file' : 'src';
        if (strpos($msglower, '[/img]') !== FALSE) {
            $patterns = array("/\\[img\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/is", "/\\[img=(\\d{1,4})[x|\\,](\\d{1,4})\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/is");
            $callbacks = $allowimgcode ? array(function ($matches) use($lazyload, $pid) {
                return parseimg(0, 0, $matches[1], intval($lazyload), intval($pid), 'onmouseover="img_onmouseoverfunc(this)" ' . ($lazyload ? 'lazyloadthumb="1"' : 'onload="thumbImg(this)"'));
            }, function ($matches) use($lazyload, $pid) {
                return parseimg($matches[1], $matches[2], $matches[3], intval($lazyload), intval($pid));
            }) : ($allowbbcode ? array(function ($matches) {
                return !defined('IN_MOBILE') ? bbcodeurl($matches[1], '<a href="{url}" target="_blank">{url}</a>') : bbcodeurl($matches[1], '');
            }, function ($matches) {
                return !defined('IN_MOBILE') ? bbcodeurl($matches[3], '<a href="{url}" target="_blank">{url}</a>') : bbcodeurl($matches[3], '');
            }) : array(function ($matches) {
                return bbcodeurl($matches[1], '{url}');
            }, function ($matches) {
                return bbcodeurl($matches[3], '{url}');
            }));
            foreach ($patterns as $key => $p) {
                $message = preg_replace_callback($p, $callbacks[$key], $message);
            }
        }
    }
    for ($i = 0; $i <= $_G['forum_discuzcode']['pcodecount']; $i++) {
        $message = str_replace("[\tDISCUZ_CODE_{$i}\t]", $_G['forum_discuzcode']['codehtml'][$i], $message);
    }
    unset($msglower);
    if ($jammer) {
        $message = preg_replace_callback("/\r\n|\n|\r/", "jammer", $message);
    }
    if ($first) {
        if (helper_access::check_module('group')) {
            $message = preg_replace("/\\[groupid=(\\d+)\\](.*)\\[\\/groupid\\]/i", lang('forum/template', 'fromgroup') . ': <a href="forum.php?mod=forumdisplay&fid=\\1" target="_blank">\\2</a>', $message);
        } else {
            $message = preg_replace("/(\\[groupid=\\d+\\].*\\[\\/groupid\\])/i", '', $message);
        }
    }
    return $htmlon ? $message : nl2br(str_replace(array("\t", '   ', '  '), array('&nbsp; &nbsp; &nbsp; &nbsp; ', '&nbsp; &nbsp;', '&nbsp;&nbsp;'), $message));
}
コード例 #4
0
ファイル: wakka.php プロジェクト: rhertzog/lcs
	function wakka2callback($things)
	{
		$thing = $things[1];
        $result='';

		static $oldIndentLevel = 0;
		static $oldIndentLength= 0;
		static $indentClosers = array();
		static $newIndentSpace= array();
		static $br = 1;
		/* > 0 when parsing an included page */
		static $nested_level = 0;
		static $l5 = 0;
		static $l4 = 0;
		static $l3 = 0;
		static $l2 = 0;
		static $l1 = 0;
		$brf=0;
		global $wiki;
		// escaped text
		if (preg_match("/^\"\"(.*)\"\"$/s", $thing, $matches))
		{
			return $matches[1];
		}
		// convert HTML thingies
		else if ($thing == "<")
			return "&lt;";
		else if ($thing == ">")
			return "&gt;";
		//EF=> tableaux
		else if (preg_match("/^\[\|(.*)\|\]/s", $thing))
		{
			return parsetable($thing);
		}	//end tableaux
		// bold
		else if ($thing == "**")
		{
			static $bold = 0;
			return (++$bold % 2 ? "<strong>" : "</strong>");
		}
		// italic
		else if ($thing == "//")
		{
			static $italic = 0;
			return (++$italic % 2 ? "<em>" : "</em>");
		}
		// underline
		else if ($thing == "__")
		{
			static $underline = 0;
			return (++$underline % 2 ? "<span class=\"souligne\">" : "</span>");
		}
		// monospace
		else if ($thing == "##")
		{
			static $monospace = 0;
			return (++$monospace % 2 ? "<tt>" : "</tt>");
		}
		//pour prez:PL
		else if ($thing =="#D#")
		{
			static $slide=0;
			return (++$slide % 2 ? "<div class=\"slide\">" : "</div>");
		}
		else if ($thing =="#F#")
		{
			static $pied=0;
			return (++$pied % 2 ? "<div id=\"footer\">" : "</div>");
		}
		else if ($thing =="#I#")
		{
			static $imprime=0;
			return (++$imprime % 2 ? "<div class=\"handout\">" : "</div>");
		}
		//pour bouton collapse - mobile PL
		else if ($thing =="#h#")
		{
			static $collapse=0;
			return (++$collapse % 2 ? "<div data-role=\"collapsible\" data-collapsed=\"true\">" : "</div>");
		}		
		//pour la couleur rouge : jobin
		else if ($thing =="#R#")
		{
			static $rouge=0;
			return (++$rouge % 2 ? "<span class=\"rouge\">" : "</span>");
		}
		//pour la couleur vert : jobin
		else if ($thing =="#V#")
		{
			static $vert=0;
			return (++$vert % 2 ? "<span class=\"vert\">" : "</span>");
		}
		else if ($thing =="#B#")
		{
			static $bleu=0;
			return (++$bleu % 2 ? "<span class=\"bleu\">" : "</span>");
		}

		//pour la surbrillance : jobin
		else if ($thing =="~~")
		{
			static $surbrillance=0;
			return (++$surbrillance % 2 ? "<span class=\"surbrillance\">" : "</span>");
		}
		//pour le centrage: pierrel
		else if ($thing =="#C#")
		{
			static $centrer=0;
			return (++$centrer % 2 ? "<div class=\"centrer\">" : "</div>");
		}
		//pour le contour pointillé bleu: pierrel
		else if ($thing ==":::")
		{
			static $pointille=0;
			return (++$pointille % 2 ? "<div class=\"pointille\">" : "</div>");
			//return (++$pointille % 2 ? "<CENTER>" : "</CENTER>");
		}
		// Deleted 
                else if ($thing == "@@")
                {
                        static $deleted = 0;
                        return (++$deleted % 2 ? "<span class=\"del\">" : "</span>");
                }
                // Inserted
                else if ($thing == "££")
                {
                        static $inserted = 0;
                        return (++$inserted % 2 ? "<span class=\"add\">" : "</span>");
                }

		// urls sans freemind
		else if (preg_match("/^([a-z]+:\/\/\S+?)([^[:alnum:]^\/])?$/", $thing, $matches)) {
			$url = $matches[1];
			 if (!isset($matches[2])) $matches[2] = '';	
			return "<a href=\"$url\">$url</a>".$matches[2];
		}
		// header level 5
                else if ($thing == "==")
                {
                        //static $l5 = 0;
			$br = 0;
                        return (++$l5 % 2 ? "<a id=\"TOC_"
				.$nested_level."_5_".($l5)."\"></a><h5>" : "</h5>");
                }
		// header level 4
                else if ($thing == "===")
                {
                        //static $l4 = 0;
			$br = 0;
                        return (++$l4 % 2 ? "<a id=\"TOC_"
				.$nested_level."_4_".($l4)."\"></a><h4>" : "</h4>");
                }
		// header level 3
                else if ($thing == "====")
                {
                        //static $l3 = 0;
			$br = 0;
                        return (++$l3 % 2 ? "<a id=\"TOC_"
				.$nested_level."_3_".($l3)."\"></a><h3>" : "</h3>");
                }
		// header level 2
                else if ($thing == "=====")
                {
                        //static $l2 = 0;
			$br = 0;
                        return (++$l2 % 2 ? "<a id=\"TOC_"
				.$nested_level."_2_".($l2)."\"></a><h2>" : "</h2>");
                }
		// header level 1
                else if ($thing == "======")
                {
                        //static $l1 = 0;
			$br = 0;
			
                        return (++$l1 % 2 ? "<a id=\"TOC_"
			.$nested_level."_1_".($l1)."\"></a><h1>" : "</h1>");
                }
		// forced line breaks
		else if ($thing == "---")
		{
			return "<br />";
		}
		// escaped text
		else if (preg_match("/^\"\"(.*)\"\"$/s", $thing, $matches))
		{
			return $matches[1];
		}
		
			// \(math\)=======================================================================
                else if (preg_match("/^[\\\\]\\((.*)[\\\\]\\)$/s",
                                   $thing, $matches))
                {
                        $output = "<div class=\"math_inline\">";
                        $output .= $wiki->Format(trim($matches[1]), "math");
                        $output .= "</div>";

                        return $output;
               }
                // \[math\]
                else if (preg_match("/^[\\\\]\\[(.*)[\\\\]\\]$/s",
                                    $thing, $matches))
                {
                        $output = "<div class=\"math_center\">";
                        $output .= $wiki->Format(trim($matches[1]), "math");
                       $output .= "</div>";
		       
                        return $output;
                }
	//Fin de math

        // Tables csv
        else if (preg_match("/^(\|\|)(.*?)(\|\|)$/s", $thing, $matches))
        {
		$result = "\n<table class=\"csvtable\">\n";
		$matches[2] = trim($matches[2]);
		$lignes = split ("\n", $matches[2]);
		$code=$matches[2];
		$lien=$wiki->href();
		$n = 0;
		foreach ($lignes as $ligne)
		{
			if ($n==0) {
				$result .= "<tr>\n";
				$colonnes = split (";", $ligne);
				
				foreach ($colonnes as $colonne) {
				$result .= "<th>".$colonne."</th>\n";
				}
				$result .= "</tr>\n";
				$n++;
				}
			else {
				$result .= "<tr>\n";
				$colonnes = split (";", $ligne);
				
				foreach ($colonnes as $colonne) {
				
				$result .= "<td>".$colonne."</td>\n";
				}
				$result .= "</tr>\n";
				$n++;
				}
		}
	
		$result .= "</table>\n\n";
		$result .="<form action=\"$lien/grabcode\" method=\"post\">
		<p><input type=\"submit\" name=\"save\" class=\"grabcodebutton\" value=\"-> .csv\" title=\"T&eacute;l&eacute;charger le contenu du tableau (csv)\" />
		<input type=\"hidden\" name=\"contenu\" value=\"$code\" /></p></form>\n";

		return $result;

	}
        
	// fin Tables csv

        // Tables PL
        else if (preg_match("/^(\|\>)(.*?)(\<\|)$/s", $thing, $matches))
        {
		$result = "\n<table class=\"csvtable\">\n";
		$matches[2] = trim($matches[2]);
		$lignes = split ("\n\n", $matches[2]);
		$code=$matches[2];
		$lien=$wiki->href();
		$n = 0;
		foreach ($lignes as $ligne)
		{
			if ($n==0) {
				$result .= "<tr>\n";
				$colonnes = split (";", $ligne);
				
				foreach ($colonnes as $colonne) {
				$result .= "<th>".$colonne."</th>\n";
				}
				$result .= "</tr>\n";
				$n++;
				}
			else {
				$result .= "<tr>\n";
				$colonnes = split (";", $ligne);
				
				foreach ($colonnes as $colonne) {
				$colonne = $wiki->Format($colonne);
				$result .= "<td>".$colonne."</td>\n";
				}
				$result .= "</tr>\n";
				$n++;
				}
		}
	
		$result .= "</table>\n\n";
		return $result;

	}
        
	// fin Tables PL

		// code text
		else if (preg_match("/^\%\%(.*)\%\%$/s", $thing, $matches))
		{
			// check if a language has been specified
			$code = $matches[1];
			$language='';
			if (preg_match("/^\((.+?)\)(.*)$/s", $code, $matches))
			{
				list(, $language, $code) = $matches;
			}
			//Select formatter for syntaxe hightlighting
			if (file_exists("formatters/coloration_".$language.".php")){
				$formatter = "coloration_".$language;
			}else{
				$formatter = "code";
			}

			$output = "<div class=\"code\">";
			$output .= $wiki->Format(trim($code), $formatter);
			$output .= "</div>";

			return $output;
		}

		
		// raw inclusion from another wiki
		// (regexp documentation : see "forced link" below)
		else if (preg_match("/^\[\[\|(\S*)(\s+(.+))?\]\]$/", $thing, $matches))
		{
			list (,$url,,$text) = $matches;
			if (!$text) $text = "404";
			if ($url)
			{
    				$url.="/wakka.php?wiki=".$text."/raw";
				return $wiki->Format($wiki->Format($url, "raw"),"wakka");
			}
			else
			{
				return "";
			}
		}
		// forced links
		// \S : any character that is not a whitespace character
		// \s : any whitespace character
		else if (preg_match("/^\[\[(\S*)(\s+(.+))?\]\]$/", $thing, $matches))
		{
			if (isset($matches[2]) && isset($matches[3]))
			{
				list (, $url, , $text) = $matches;
			}
			else
			{
				list (, $url) = $matches;
			}
			if ($url)
			{
				if ($url!=($url=(preg_replace("/@@|££|\[\[/","",$url))))$result="</span>";
				if (!isset($text)) $text = $url;
				$text=preg_replace("/@@|££|\[\[/","",$text);
				return $result.$wiki->Link($url, "", $text);
			}
			else
			{
				return "";
			}
		}
		// indented text
		
		else if ((preg_match("/\n(\t+|([ ]{1})+)(~|-|=|([0-9,a-z,A-Z]+)\))?/s", $thing, $matches))
		 ||  (preg_match("/^(\t+|([ ]{1})+)(~|-|=|([0-9,a-z,A-Z]+)\))?/s", $thing, $matches) && $brf=1))
		{
			// new line
			if ($brf) $br=0;
			$result .= ($br ? "<br />\n" : "");

			// we definitely want no line break in this one.
			$br = 0;

			// find out which indent type we want
			 if (!isset($matches[3])) $matches[3] = '';
			$newIndentType = $matches[3];
			if (!$newIndentType) { $opener = "<div class=\"indent\">"; $closer = "</div>"; $br = 1; }
			else if ($newIndentType == "-") { $opener = "<ul>\n"; $closer = "</li>\n</ul>"; $li = 1; }
			else if ($newIndentType == "~") { $opener = "<ul class=\"incremental\">\n"; $closer = "</li>\n</ul>"; $li = 1; }
			else if ($newIndentType == "=") { $opener = "<ul  data-role=\"listview\" data-inset=\"true\" data-theme=\"a\" data-dividertheme=\"a\">\n"; $closer = "</li>\n</ul>"; $li = 1; }
			else { 
			 if (preg_match('`[0-9]+`', $matches[4]))
                                        $style = 'style="list-style: decimal;"';
                                    if (preg_match('`[a-hj-z]+`', $matches[4]))
                                        $style = 'style="list-style: lower-alpha;"';
                                    if (preg_match('`[A-HJ-Z]+`', $matches[4]))
                                        $style = 'style="list-style: upper-alpha;"';
                                    if (preg_match('`[i]+`', $matches[4]))
                                        $style = 'style="list-style: lower-roman;"';
                                    if (preg_match('`[I]+`', $matches[4]))
                                        $style = 'style="list-style: upper-roman;"';
			$opener = "<ol $style>\n"; $closer = "</li>\n</ol>"; $li = 1; }

			// get new indent level
			
			if (strpos($matches[1],"\t")) $newIndentLevel = strlen($matches[1]);
			else
			{
				$newIndentLevel=$oldIndentLevel;
				$newIndentLength = strlen($matches[1]);
				if ($newIndentLength>$oldIndentLength)
				{ 
					$newIndentLevel++;
					$newIndentSpace[$newIndentLength]=$newIndentLevel;
				}
				else if ($newIndentLength<$oldIndentLength)
						$newIndentLevel=$newIndentSpace[$newIndentLength];
			}
  			$op=0;
			if ($newIndentLevel > $oldIndentLevel)
			{
				for ($i = 0; $i < $newIndentLevel - $oldIndentLevel; $i++)
				{
					$result .= $opener;
					$op=1;
					array_push($indentClosers, $closer);
				}
			}
			else if ($newIndentLevel < $oldIndentLevel)
			{
				for ($i = 0; $i < $oldIndentLevel - $newIndentLevel; $i++)
				{
					$op=1;
					$result .= array_pop($indentClosers);
			                if ($oldIndentLevel && $li) $result .= "</li>";
				}
			}

			if (isset($li) && $op) $result .= "<li>";
			else if (isset($li))
				$result .= "</li>\n<li>";

			$oldIndentLevel = $newIndentLevel;
			$oldIndentLength= $newIndentLength;

			return $result;
		}
		// new lines
		else if ($thing == "\n")
		{
			// if we got here, there was no tab in the next line; this means that we can close all open indents.
			$c = count($indentClosers);
			for ($i = 0; $i < $c; $i++)
			{
				$result .= array_pop($indentClosers);
				$br = 0;
			}
			$oldIndentLevel = 0;
			$oldIndentLength= 0;
			$newIndentSpace=array();

			$result .= ($br ? "<br />\n" : "\n");
			$br = 1;
			return $result;
		}
		// events
		else if (preg_match("/^\{\{(.*?)\}\}$/s", $thing, $matches))
		{
			if ($matches[1])
				{
			    $old_lx = array($l1, $l2, $l3, $l4, $l5);
			    $nested_level++;
			    $retval = $wiki->Action($matches[1]);
			    $nested_level--;
			    list($l1, $l2, $l3, $l4, $l5) = $old_lx;
			    return $retval;
			  }
			else
				return "{{}}";
		}
		// interwiki links!
                else if (preg_match("/^[A-Z][A-Z,a-z]+[:]([A-Z,a-z,0-9]*)$/s", $thing))

		{
			return $wiki->Link($thing);
		}
		// wiki links!
		else if (preg_match("/^[A-Z][a-z]+[A-Z,0-9][A-Z,a-z,0-9]*$/s", $thing))
		{
			return $wiki->Link($thing);
		}
		// separators
		else if (preg_match("/-{4,}/", $thing, $matches))
		{
			// TODO: This could probably be improved for situations where someone puts text on the same line as a separator.
			//       Which is a stupid thing to do anyway! HAW HAW! Ahem.
			$br = 0;
			return "<hr />";
		}
		// if we reach this point, it must have been an accident.
		return $thing;
	}
コード例 #5
0
ファイル: correction.php プロジェクト: rhertzog/lcs
	function wakka2callback($things)
	{
		$thing = $things[1];
        $result='';

		static $oldIndentLevel = 0;
		static $oldIndentLength= 0;
		static $indentClosers = array();
		static $newIndentSpace= array();
		static $br = 1;
		$brf=0;
		global $wiki;
	
		// convert HTML thingies
		if ($thing == "<")
			return "&lt;";
		else if ($thing == ">")
			return "&gt;";
		//EF=> tableaux
		else if (preg_match("/^\[\|(.*)\|\]/s", $thing))
		{
			return parsetable($thing);
		}	//end tableaux
		// bold
		else if ($thing == "**")
		{
			static $bold = 0;
			return (++$bold % 2 ? "<b>" : "</b>");
		}
		// italic
		else if ($thing == "//")
		{
			static $italic = 0;
			return (++$italic % 2 ? "<i>" : "</i>");
		}
		// underlinue
		else if ($thing == "__")
		{
			static $underline = 0;
			return (++$underline % 2 ? "<u>" : "</u>");
		}
		// monospace
		else if ($thing == "##")
		{
			static $monospace = 0;
			return (++$monospace % 2 ? "<tt>" : "</tt>");
		}
		//pour la couleur rouge : jobin
		else if ($thing =="#R#")
		{
			static $rouge=0;
			return (++$rouge % 2 ? "<span class=\"rouge\">" : "</span>");
		}
		//pour la couleur vert : jobin
		else if ($thing =="#V#")
		{
			static $vert=0;
			return (++$vert % 2 ? "<span class=\"vert\">" : "</span>");
		}
		else if ($thing =="#B#")
		{
			static $bleu=0;
			return (++$bleu % 2 ? "<span class=\"bleu\">" : "</span>");
		}

		//pour la surbrillance : jobin
		else if ($thing =="~~")
		{
			static $surbrillance=0;
			return (++$surbrillance % 2 ? "<span class=\"surbrillance\">" : "</span>");
		}
		//pour le centrage: pierrel
		else if ($thing =="#C#")
		{
			static $centrer=0;
			return (++$centrer % 2 ? "<div class=\"centrer\">" : "</div>");
		}
		//pour le contour pointillé bleu: pierrel
		else if ($thing ==":::")
		{
			static $pointille=0;
			return (++$pointille % 2 ? "<div class=\"pointille\">" : "</div>");
			//return (++$pointille % 2 ? "<CENTER>" : "</CENTER>");
		}
		// Deleted 
                else if ($thing == "@@")
                {
                        static $deleted = 0;
                        return (++$deleted % 2 ? "<span class=\"del\">" : "</span>");
                }
                // Inserted
                else if ($thing == "££")
                {
                        static $inserted = 0;
                        return (++$inserted % 2 ? "<span class=\"add\">" : "</span>");
                }
		// urls
		else if (preg_match("/^([a-z]+:\/\/\S+?)([^[:alnum:]^\/])?$/", $thing, $matches)) {
			$url = $matches[1];
			 if (!isset($matches[2])) $matches[2] = '';	
			return "<a href=\"$url\">$url</a>".$matches[2];
		}
		// header level 5
                else if ($thing == "==")
                {
                        static $l5 = 0;
			$br = 0;
                        return (++$l5 % 2 ? "<h5>" : "</h5>");
                }
		// header level 4
                else if ($thing == "===")
                {
                        static $l4 = 0;
			$br = 0;
                        return (++$l4 % 2 ? "<h4>" : "</h4>");
                }
		// header level 3
                else if ($thing == "====")
                {
                        static $l3 = 0;
			$br = 0;
                        return (++$l3 % 2 ? "<h3>" : "</h3>");
                }
		// header level 2
                else if ($thing == "=====")
                {
                        static $l2 = 0;
			$br = 0;
                        return (++$l2 % 2 ? "<h2>" : "</h2>");
                }
		// header level 1
                else if ($thing == "======")
                {
                        static $l1 = 0;
			$br = 0;
                        return (++$l1 % 2 ? "<h1>" : "</h1>");
                }
		// forced line breaks
		else if ($thing == "---")
		{
			return "<br />";
		}
		// escaped text
		else if (preg_match("/^\"\"(.*)\"\"$/s", $thing, $matches))
		{
			return $matches[1];
		}
		
			// \(math\)=======================================================================
                else if (preg_match("/^[\\\\]\\((.*)[\\\\]\\)$/s",
                                   $thing, $matches))
                {
                        $output = "<div class=\"math_inline\">";
                        $output .= $wiki->Format(trim($matches[1]), "math");
                        $output .= "</div>";

                        return $output;
               }
                // \[math\]
                else if (preg_match("/^[\\\\]\\[(.*)[\\\\]\\]$/s",
                                    $thing, $matches))
                {
                        $output = "<div class=\"math_center\">";
                        $output .= $wiki->Format(trim($matches[1]), "math");
                       $output .= "</div>";
		       
                        return $output;
                }
	//Fin de math===========================================================================
		// code text
		else if (preg_match("/^\%\%(.*)\%\%$/s", $thing, $matches))
		{
			// check if a language has been specified
			$code = $matches[1];
			$language='';
			if (preg_match("/^\((.+?)\)(.*)$/s", $code, $matches))
			{
				list(, $language, $code) = $matches;
			}
			//Select formatter for syntaxe hightlighting
			if (file_exists("formatters/coloration_".$language.".php")){
				$formatter = "coloration_".$language;
			}else{
				$formatter = "code";
			}

			$output = "<div class=\"code\">";
			$output .= $wiki->Format(trim($code), $formatter);
			$output .= "</div>";

			return $output;
		}
		// raw inclusion from another wiki
		// (regexp documentation : see "forced link" below)
		else if (preg_match("/^\[\[\|(\S*)(\s+(.+))?\]\]$/", $thing, $matches))
		{
			list (,$url,,$text) = $matches;
			if (!$text) $text = "404";
			if ($url)
			{
    				$url.="/wakka.php?wiki=".$text."/raw";
				return $wiki->Format($wiki->Format($url, "raw"),"wakka");
			}
			else
			{
				return "";
			}
		}
		// forced links
		// \S : any character that is not a whitespace character
		// \s : any whitespace character
		else if (preg_match("/^\[\[(\S*)\s+(.+)?\]\]$/", $thing, $matches))
		{
			list (, $url, $text) = $matches;
			if ($url)
			{
				if ($url!=($url=(preg_replace("/@@|££|\[\[/","",$url))))$result="</span>";
				if (!isset($text)) $text = $url;
				$text=preg_replace("/@@|££|\[\[/","",$text);
				return $result.$wiki->Link($url, "", $text);
			}
			else
			{
				return "";
			}
		}
		// indented text
		else if ((preg_match("/\n(\t+|([ ]{1})+)(-|([0-9,a-z,A-Z]+)\))?/s", $thing, $matches))
		 ||  (preg_match("/^(\t+|([ ]{1})+)(-|([0-9,a-z,A-Z]+)\))?/s", $thing, $matches) && $brf=1))
		{
			// new line
			if ($brf) $br=0;
			$result .= ($br ? "<br />\n" : "");

			// we definitely want no line break in this one.
			$br = 0;

			// find out which indent type we want
			 if (!isset($matches[3])) $matches[3] = '';
			$newIndentType = $matches[3];
			if (!$newIndentType) { $opener = "<div class=\"indent\">"; $closer = "</div>"; $br = 1; }
			else if ($newIndentType == "-") { $opener = "<ul>\n"; $closer = "</li>\n</ul>"; $li = 1; }
			else { $opener = "<ol type=\"".$matches[4]."\">\n"; $closer = "</li>\n</ol>"; $li = 1; }

			// get new indent level
			
			if (strpos($matches[1],"\t")) $newIndentLevel = strlen($matches[1]);
			else
			{
				$newIndentLevel=$oldIndentLevel;
				$newIndentLength = strlen($matches[1]);
				if ($newIndentLength>$oldIndentLength)
				{ 
					$newIndentLevel++;
					$newIndentSpace[$newIndentLength]=$newIndentLevel;
				}
				else if ($newIndentLength<$oldIndentLength)
						$newIndentLevel=$newIndentSpace[$newIndentLength];
			}
  			$op=0;
			if ($newIndentLevel > $oldIndentLevel)
			{
				for ($i = 0; $i < $newIndentLevel - $oldIndentLevel; $i++)
				{
					$result .= $opener;
					$op=1;
					array_push($indentClosers, $closer);
				}
			}
			else if ($newIndentLevel < $oldIndentLevel)
			{
				for ($i = 0; $i < $oldIndentLevel - $newIndentLevel; $i++)
				{
					$op=1;
					$result .= array_pop($indentClosers);
			                if ($oldIndentLevel && $li) $result .= "</li>";
				}
			}

			if (isset($li) && $op) $result .= "<li>";
			else if (isset($li))
				$result .= "</li>\n<li>";

			$oldIndentLevel = $newIndentLevel;
			$oldIndentLength= $newIndentLength;

			return $result;
		}
		// new lines
		else if ($thing == "\n")
		{
			// if we got here, there was no tab in the next line; this means that we can close all open indents.
			$c = count($indentClosers);
			for ($i = 0; $i < $c; $i++)
			{
				$result .= array_pop($indentClosers);
				$br = 0;
			}
			$oldIndentLevel = 0;
			$oldIndentLength= 0;
			$newIndentSpace=array();

			$result .= ($br ? "<br />\n" : "\n");
			$br = 1;
			return $result;
		}
		// events
		else if (preg_match("/^\{\{(.*?)\}\}$/s", $thing, $matches))
		{
			if ($matches[1])
				return $wiki->Action($matches[1]);
			else
				return "{{}}";
		}
		// interwiki links!
                else if (preg_match("/^[A-Z][A-Z,a-z]+[:]([A-Z,a-z,0-9]*)$/s", $thing))

		{
			return $wiki->Link($thing);
		}
		// wiki links!
		else if (preg_match("/^[A-Z][a-z]+[A-Z,0-9][A-Z,a-z,0-9]*$/s", $thing))
		{
			return $wiki->Link($thing);
		}
		// separators
		else if (preg_match("/-{4,}/", $thing, $matches))
		{
			// TODO: This could probably be improved for situations where someone puts text on the same line as a separator.
			//       Which is a stupid thing to do anyway! HAW HAW! Ahem.
			$br = 0;
			return "<hr />";
		}
		// if we reach this point, it must have been an accident.
		return $thing;
	}
コード例 #6
0
 function wakka2callback($things)
 {
     $thing = $things[1];
     $result = '';
     static $oldIndentLevel = 0;
     static $oldIndentLength = 0;
     static $indentClosers = array();
     static $newIndentSpace = array();
     static $br = 1;
     $brf = 0;
     global $wiki;
     // convert HTML thingies
     if ($thing == "<") {
         return "&lt;";
     } else {
         if ($thing == ">") {
             return "&gt;";
         } else {
             if (preg_match("/^\\[\\|(.*)\\|\\]/s", $thing)) {
                 return parsetable($thing);
             } else {
                 if ($thing == "**") {
                     static $bold = 0;
                     return ++$bold % 2 ? "<b>" : "</b>";
                 } else {
                     if ($thing == "//") {
                         static $italic = 0;
                         return ++$italic % 2 ? "<i>" : "</i>";
                     } else {
                         if ($thing == "__") {
                             static $underline = 0;
                             return ++$underline % 2 ? "<u>" : "</u>";
                         } else {
                             if ($thing == "##") {
                                 static $monospace = 0;
                                 return ++$monospace % 2 ? "<tt>" : "</tt>";
                             } else {
                                 if ($thing == "~~") {
                                     static $carto = 0;
                                     static $cartocpt = 0;
                                     $carto % 2 ? $cartocpt++ : "";
                                     if ($_SESSION['location'][$wiki->GetPageTag()][$cartocpt] == 'NF') {
                                         //			if ($_SESSION['location'][$cartocpt]=='NF') {
                                         $msg = "(Localit&eacute; non r&eacute;f&eacute;renc&eacute;e)";
                                     }
                                     if ($_SESSION['location'][$wiki->GetPageTag()][$cartocpt] == 'AF') {
                                         //			if ($_SESSION['location'][$cartocpt]=='AF') {
                                         $msg = "Résultat approch&eacute; : " . $_SESSION['location_message'][$wiki->GetPageTag()][$cartocpt] . " ";
                                     }
                                     return ++$carto % 2 ? "<a name=\"MAP_" . $cartocpt . "\">" . $msg . "</a>" : " <a href=\"#topmap\">(Carte)</a>";
                                 } else {
                                     if ($thing == "@@") {
                                         static $deleted = 0;
                                         return ++$deleted % 2 ? "<span class=\"del\">" : "</span>";
                                     } else {
                                         if ($thing == "££") {
                                             static $inserted = 0;
                                             return ++$inserted % 2 ? "<span class=\"add\">" : "</span>";
                                         } else {
                                             if (preg_match("/^([a-z]+:\\/\\/\\S+?)([^[:alnum:]^\\/])?\$/", $thing, $matches)) {
                                                 $url = $matches[1];
                                                 if (!isset($matches[2])) {
                                                     $matches[2] = '';
                                                 }
                                                 return "<a href=\"{$url}\">{$url}</a>" . $matches[2];
                                             } else {
                                                 if ($thing == "==") {
                                                     static $l5 = 0;
                                                     $br = 0;
                                                     return ++$l5 % 2 ? "<h5>" : "</h5>";
                                                 } else {
                                                     if ($thing == "===") {
                                                         static $l4 = 0;
                                                         $br = 0;
                                                         return ++$l4 % 2 ? "<h4>" : "</h4>";
                                                     } else {
                                                         if ($thing == "====") {
                                                             static $l3 = 0;
                                                             $br = 0;
                                                             return ++$l3 % 2 ? "<h3>" : "</h3>";
                                                         } else {
                                                             if ($thing == "=====") {
                                                                 static $l2 = 0;
                                                                 $br = 0;
                                                                 return ++$l2 % 2 ? "<h2>" : "</h2>";
                                                             } else {
                                                                 if ($thing == "======") {
                                                                     static $l1 = 0;
                                                                     $br = 0;
                                                                     return ++$l1 % 2 ? "<h1>" : "</h1>";
                                                                 } else {
                                                                     if ($thing == "---") {
                                                                         return "<br />";
                                                                     } else {
                                                                         if (preg_match("/^\"\"(.*)\"\"\$/s", $thing, $matches)) {
                                                                             return $matches[1];
                                                                         } else {
                                                                             if (preg_match("/^\\%\\%(.*)\\%\\%\$/s", $thing, $matches)) {
                                                                                 // check if a language has been specified
                                                                                 $code = $matches[1];
                                                                                 $language = '';
                                                                                 if (preg_match("/^\\((.+?)\\)(.*)\$/s", $code, $matches)) {
                                                                                     list(, $language, $code) = $matches;
                                                                                 }
                                                                                 //Select formatter for syntaxe hightlighting
                                                                                 if (file_exists("formatters/coloration_" . $language . ".php")) {
                                                                                     $formatter = "coloration_" . $language;
                                                                                 } else {
                                                                                     $formatter = "code";
                                                                                 }
                                                                                 $output = "<div class=\"code\">";
                                                                                 $output .= $wiki->Format(trim($code), $formatter);
                                                                                 $output .= "</div>";
                                                                                 return $output;
                                                                             } else {
                                                                                 if (preg_match("/^\\[\\[\\|(\\S*)(\\s+(.+))?\\]\\]\$/", $thing, $matches)) {
                                                                                     list(, $url, , $text) = $matches;
                                                                                     if (!$text) {
                                                                                         $text = "404";
                                                                                     }
                                                                                     if ($url) {
                                                                                         $url .= "/wakka.php?wiki=" . $text . "/raw";
                                                                                         return $wiki->Format($wiki->Format($url, "raw"), "wakka");
                                                                                     } else {
                                                                                         return "";
                                                                                     }
                                                                                 } else {
                                                                                     if (preg_match("/^\\[\\[(\\S*)(\\s+(.+))?\\]\\]\$/", $thing, $matches)) {
                                                                                         list(, $url, $text) = $matches;
                                                                                         if ($url) {
                                                                                             if ($url != ($url = preg_replace("/@@|££|\\[\\[/", "", $url))) {
                                                                                                 $result = "</span>";
                                                                                             }
                                                                                             if (!$text) {
                                                                                                 $text = $url;
                                                                                             }
                                                                                             $text = preg_replace("/@@|££|\\[\\[/", "", $text);
                                                                                             return $result . $wiki->Link($url, "", $text);
                                                                                         } else {
                                                                                             return "";
                                                                                         }
                                                                                     } else {
                                                                                         if (preg_match("/\n(\t+|([ ]{1})+)(-|([0-9,a-z,A-Z]+)\\))?/s", $thing, $matches) || preg_match("/^(\t+|([ ]{1})+)(-|([0-9,a-z,A-Z]+)\\))?/s", $thing, $matches) && ($brf = 1)) {
                                                                                             // new line
                                                                                             if ($brf) {
                                                                                                 $br = 0;
                                                                                             }
                                                                                             $result .= $br ? "<br />\n" : "";
                                                                                             // we definitely want no line break in this one.
                                                                                             $br = 0;
                                                                                             // find out which indent type we want
                                                                                             if (!isset($matches[3])) {
                                                                                                 $matches[3] = '';
                                                                                             }
                                                                                             $newIndentType = $matches[3];
                                                                                             if (!$newIndentType) {
                                                                                                 $opener = "<div class=\"indent\">";
                                                                                                 $closer = "</div>";
                                                                                                 $br = 1;
                                                                                             } else {
                                                                                                 if ($newIndentType == "-") {
                                                                                                     $opener = "<ul>\n";
                                                                                                     $closer = "</li>\n</ul>";
                                                                                                     $li = 1;
                                                                                                 } else {
                                                                                                     $opener = "<ol type=\"" . $matches[4] . "\">\n";
                                                                                                     $closer = "</li>\n</ol>";
                                                                                                     $li = 1;
                                                                                                 }
                                                                                             }
                                                                                             // get new indent level
                                                                                             if (strpos($matches[1], "\t")) {
                                                                                                 $newIndentLevel = strlen($matches[1]);
                                                                                             } else {
                                                                                                 $newIndentLevel = $oldIndentLevel;
                                                                                                 $newIndentLength = strlen($matches[1]);
                                                                                                 if ($newIndentLength > $oldIndentLength) {
                                                                                                     $newIndentLevel++;
                                                                                                     $newIndentSpace[$newIndentLength] = $newIndentLevel;
                                                                                                 } else {
                                                                                                     if ($newIndentLength < $oldIndentLength) {
                                                                                                         $newIndentLevel = $newIndentSpace[$newIndentLength];
                                                                                                     }
                                                                                                 }
                                                                                             }
                                                                                             $op = 0;
                                                                                             if ($newIndentLevel > $oldIndentLevel) {
                                                                                                 for ($i = 0; $i < $newIndentLevel - $oldIndentLevel; $i++) {
                                                                                                     $result .= $opener;
                                                                                                     $op = 1;
                                                                                                     array_push($indentClosers, $closer);
                                                                                                 }
                                                                                             } else {
                                                                                                 if ($newIndentLevel < $oldIndentLevel) {
                                                                                                     for ($i = 0; $i < $oldIndentLevel - $newIndentLevel; $i++) {
                                                                                                         $op = 1;
                                                                                                         $result .= array_pop($indentClosers);
                                                                                                         if ($oldIndentLevel && $li) {
                                                                                                             $result .= "</li>";
                                                                                                         }
                                                                                                     }
                                                                                                 }
                                                                                             }
                                                                                             if (isset($li) && $op) {
                                                                                                 $result .= "<li>";
                                                                                             } else {
                                                                                                 if (isset($li)) {
                                                                                                     $result .= "</li>\n<li>";
                                                                                                 }
                                                                                             }
                                                                                             $oldIndentLevel = $newIndentLevel;
                                                                                             $oldIndentLength = $newIndentLength;
                                                                                             return $result;
                                                                                         } else {
                                                                                             if ($thing == "\n") {
                                                                                                 // if we got here, there was no tab in the next line; this means that we can close all open indents.
                                                                                                 $c = count($indentClosers);
                                                                                                 for ($i = 0; $i < $c; $i++) {
                                                                                                     $result .= array_pop($indentClosers);
                                                                                                     $br = 0;
                                                                                                 }
                                                                                                 $oldIndentLevel = 0;
                                                                                                 $oldIndentLength = 0;
                                                                                                 $newIndentSpace = array();
                                                                                                 $result .= $br ? "<br />\n" : "\n";
                                                                                                 $br = 1;
                                                                                                 return $result;
                                                                                             } else {
                                                                                                 if (preg_match("/^\\{\\{(.*?)\\}\\}\$/s", $thing, $matches)) {
                                                                                                     if ($matches[1]) {
                                                                                                         return $wiki->Action($matches[1]);
                                                                                                     } else {
                                                                                                         return "{{}}";
                                                                                                     }
                                                                                                 } else {
                                                                                                     if (preg_match("/^[A-Z][A-Z,a-z]+[:]([A-Z,a-z,0-9]*)\$/s", $thing)) {
                                                                                                         return $wiki->Link($thing);
                                                                                                     } else {
                                                                                                         if (preg_match("/^[A-Z][a-z]+[A-Z,0-9][A-Z,a-z,0-9]*\$/s", $thing)) {
                                                                                                             return $wiki->Link($thing);
                                                                                                         } else {
                                                                                                             if (preg_match("/-{4,}/", $thing, $matches)) {
                                                                                                                 // TODO: This could probably be improved for situations where someone puts text on the same line as a separator.
                                                                                                                 //       Which is a stupid thing to do anyway! HAW HAW! Ahem.
                                                                                                                 $br = 0;
                                                                                                                 return "<hr />";
                                                                                                             }
                                                                                                         }
                                                                                                     }
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // if we reach this point, it must have been an accident.
     return $thing;
 }