示例#1
0
function wikify($content)
{
    $content = htmlify($content, false);
    $content = preg_replace('#\\[\\[([\\w ]+);([\\w ]+)?\\]\\]#', '<a href = "wpage.php?title=$1">$2</a>', $content);
    $content = preg_replace('#\\[\\[([\\w ]+)\\]\\]#', '<a href = "wpage.php?title=$1">$1</a>', $content);
    $matches = array('#\\[url\\=(http://.*?)\\](.*?)\\[/url\\]#', '#\\[email:([\\w\\. ]+);([\\w\\@\\.]+)\\]#', '#funcFullArticle\\(([\\w ]+)\\)#', '#\\_([\\w ]+)\\_#', '#\\*([\\w \\d\\p{P}]+)\\*#', '#-([\\w \\&]+)-#', '#^=([\\w?\'\\"\\(\\)\\\\.,/ \\&]+)=#m', '#\\[img\\.(\\d+)\\](.+)\\[\\/img\\]#', '#\\[img\\](.+)\\[\\/img\\]#', '#\\|-([^\\|]+)#sm', '#{.(.+?).}#sm', '#^\\!(.+?)\\n#m', '#\\%(.+?)\\n#', '#\\[list\\]#', '#\\[\\/list\\]#', '#\\n-([\\w \\p{P}]+)#', '#\\[center\\]#', '#\\[\\/center\\]#', '#\\[space\\]#', '#\\[br\\]#');
    $replacements = array('<a href = "$1" class = "external" title = "This is an external link.">$2</a>', '<a href = "mailto:$2" class = "external" title = "This is an email address.">$1</a>', '<span class = "subtle">The following is a snippit, there is a full article available: <a href = "wiki.php?title=$1">$1</a>.</span><br />', '<em>$1</em>', '<b>$1</b>', '<del>$1</del>', '<h3>$1</h3>' . "\n", '<img src = "$2" width = "$1" alt = "unknown" />', '<img src = "$1" alt = "unknown" />', '<tr>\\1</tr>', '<table>\\1</table>', '<td>\\1</td>', '<th>\\1</th>', '<ul>', '</ul>', '<li>\\1</li>', '<div class = "centered">', '</div>', '&nbsp;', '<br />');
    $content = preg_replace($matches, $replacements, $content);
    while (strpos($content, 'imgPromo') !== FALSE) {
        $img = Galleries::getRandomImage();
        $rep = '<a href = "viewGalleryImage.php?filename=' . $img['filename'] . '&amp;galleryId=' . $img['galleryId'] . '"><img src = "' . $img['fullPath'] . '" width = "$1" alt = "unknown"></a>';
        $content = preg_replace('#\\[imgPromo\\.(\\d+)\\]#', $rep, $content, 1);
    }
    return $content;
}