예제 #1
0
function writeText($body, &$status)
{
    $status->trace(TC_Util2, "writeText: {$body}");
    $count = 0;
    while (strlen($body) > 0 && preg_match('/^(.*?)(__|\'{2,4}' . '|\\[([a-z]+:\\S+)(\\s+[^]]*)?\\]' . '|(https?|ftp|mailto):\\/\\/\\S+' . '|!?\\b[A-ZÄÖÜ][äüö\\w]+[A-ZÄÖÜ][ÄÖÜäöü\\w]*' . '|\\[.\\]' . '\\[\\[\\]' . '|\\[Newline\\]' . '|\\[([A-ZÄÖÜ][-äöüß\\w]+)\\s*([^]]*)?\\]' . '|<\\?plugin (\\w+)(.*)\\?>)/', $body, $match)) {
        $args = count($match);
        $count++;
        if ($match[1] != '') {
            echo htmlentities($match[1]);
        }
        switch ($match[2]) {
            case '__':
                $status->handleEmphasis('u');
                break;
            case '\'\'':
                $status->handleEmphasis('i');
                break;
            case '\'\'\'':
                $status->handleEmphasis('b');
                break;
            case '\'\'\'\'':
                $status->handleEmphasis('x');
                break;
            default:
                # $status->trace (TC_X, '$#match: ' . count ($match));
                if ($args > 5 && $match[5] != '') {
                    writeExternLink($match[2], '', $status);
                } elseif ($args == 8 && $match[6] != '') {
                    writeWikiName($match[6], $match[7], $status);
                } elseif (($pos = strpos($match[2], '[')) == 0 && is_int($pos)) {
                    if ($args <= 4) {
                        if (strlen($match[0]) == 3) {
                            echo $match[0] == '[[]' ? '[' : $match[0];
                        } else {
                            echo '<br />';
                        }
                    } else {
                        writeExternLink($match[3], $match[4], $status);
                    }
                } elseif ($args > 9 && ($pos = strpos($match[2], '<?')) == 0 && is_int($pos)) {
                    writePlugin($match[8], $match[9], $status);
                } else {
                    writeWikiName($match[2], '', $status);
                }
                break;
        }
        // switch
        $body = substr($body, strlen($match[1]) + strlen($match[2]));
    }
    if ($body != '') {
        echo $status->fSession->replaceMacrosHTML(htmlentities($status->fSession->replaceMacrosNoHTML($body)));
    }
}
예제 #2
0
function writeText($body, &$status)
{
    $status->trace(TC_Util2, "writeText: {$body}");
    $count = 0;
    while (strlen($body) > 0 && preg_match(IB_REG_EXPR, $body, $match)) {
        $args = count($match);
        $count++;
        if ($match[1] != '') {
            echo htmlentities($match[1]);
        }
        #$status->trace (TC_X, "writeText-2:" . dumpArray ($match, 'match', 2));
        // Alle Ausdrücke ohne Klammern:
        if ($args == 3) {
            switch ($match[2]) {
                case '__':
                    $status->handleEmphasis('u');
                    break;
                case '\'\'':
                    $status->handleEmphasis('i');
                    break;
                case '\'\'\'':
                    $status->handleEmphasis('b');
                    break;
                case '\'\'\'\'':
                    $status->handleEmphasis('x');
                    break;
                case '%%%':
                    outNewline();
                    break;
                default:
                    if (strpos($match[2], "hex(") == 1) {
                        for ($ii = 5; $ii < strlen($match[2]) - 1; $ii++) {
                            printf("%02x ", ord(substr($match[2], $ii, 1)));
                        }
                    } elseif (getPos($match[2], '[[') == 0) {
                        if (strlen($match[2]) == 5) {
                            echo substr($match[2], 2, 1);
                        } else {
                            writeExternLink(substr($match[2], 2, strlen($match[2]) - 4), null, true, $status);
                        }
                    } else {
                        echo htmlentities($match[2]);
                    }
            }
        } else {
            if ($args == 9) {
                writeWikiName($match[7], substr($match[8], 1), $status);
            } elseif ($args == 8) {
                writeWikiName($match[7], null, $status);
            } elseif ($args == 5) {
                // Direkter Verweis (ohne [[]]:
                writeExternLink($match[2], null, false, $status);
            } elseif ($args == 4) {
                // [[Verweis]]:
                $len = strpos($match[2], '|') - 2;
                writeExternLink(substr($match[2], 2, $len > 0 ? $len : strlen($match[2])), substr($match[3], 1), true, $status);
            } elseif ($args == 6) {
                // (Nicht-)Wikiname
                writeWikiName($match[2], null, $status);
            } elseif ($args == 7) {
                switch ($match[6]) {
                    case 'newline':
                        echo '<br />';
                        break;
                    case 'big':
                    case '/big':
                    case 'small':
                    case '/small':
                    case 'sub':
                    case '/sub':
                    case 'sup':
                    case '/sup':
                    case 'tt':
                    case '/tt':
                        echo TAG_PREFIX;
                        echo $match[6];
                        echo TAG_SUFFIX;
                        break;
                    case 'subscript':
                        echo TAG_SUB;
                        break;
                    case 'superscript':
                        echo TAG_SUP;
                        break;
                    case '/subscript':
                        echo TAG_SUP_END;
                        break;
                    case '/superscript':
                        echo TAG_SUP_END;
                        break;
                    case '/teletype':
                        echo TAG_TT;
                        break;
                    case 'teletype':
                        echo TAG_TT_END;
                        break;
                    default:
                        echo $match[2];
                        break;
                }
            } elseif ($args == 11) {
                writePlugin($match[9], $match[10], $status);
            } else {
                echo $match[2];
            }
        }
        // args != 3
        $body = substr($body, strlen($match[1]) + strlen($match[2]));
    }
    if ($body != '') {
        echo $status->fSession->replaceMacrosHTML(htmlentities($status->fSession->replaceMacrosNoHTML($body)));
    }
}