Before:
' . $modified . '
END Before

'; /* All headings */ $modified = preg_replace("#(.*)#Ui", '${2}', $modified); /* All line starts: #, * are already existing. ":" to be implemented */ //'

${1}

' $patterns[0] = '/>[\n[:space:]]?:::(.*)/'; $patterns[1] = '/>[\n[:space:]]?::(.*)/'; $patterns[2] = '/>[\n[:space:]]?:(.*)/'; $replacements[0] = '

${1}

'; $replacements[1] = '

${1}

'; $replacements[2] = '

${1}

'; $modified = preg_replace($patterns, $replacements, $modified); // $modified = preg_replace_callback('/>[\n[:space:]]?:(.*)/', 'replace_callback_colon', $modified); /* All formatting*/ $patterns[0] = '/\^{5}(.*)\^{5}/'; $patterns[1] = '/\^{3}(.*)\^{3}/'; $patterns[2] = '/\^{2}(.*)\^{2}/'; $replacements[0] = '${1}'; $replacements[1] = '${1}'; $replacements[2] = '${1}'; $modified = preg_replace('/(\&#(821[67]);)/', '^', $modified); $modified = preg_replace($patterns, $replacements, $modified); $modified = preg_replace('/\^/', '\'', $modified); /* All Links: */ $modified = preg_replace_callback('/\[http:([a-zA-Z0-9\/=?\.-_&]*) (.*)\]/', 'replace_callback_links_with_substitute', $modified); // NOT working yet: links not surrounded by [] // $modified = preg_replace_callback('/http:([a-zA-Z0-9\/=?\.-_&]*)/', 'replace_callback_links', $modified); // already working for links with [{link}] $modified = preg_replace_callback('/\[http:([a-zA-Z0-9\/=?\.-_&]*)\]/', 'replace_callback_links', $modified); //Replaces wiki links in format [wiki:{PAGE_ID}] with a textile link to the page $modified = preg_replace_callback('/\[wiki:([0-9]*)\]/', 'replace_wiki_link_callback', $modified); //Replaces wiki links in format [[wikipage|title]] with a textile link to the wikipage under the name 'title' $modified = preg_replace_callback('/\[\[(.*)\|(.*)\]\]/', 'replace_wiki_link_title_callback_2', $modified); //Replaces wiki links in format [[wikipage]] with a textile link to the wikipage $modified = preg_replace_callback('/\[\[(.*)\]\]/', 'replace_wiki_link_title_callback', $modified); /* signature shortcuts */ $username = logged_user()->getUsername(); $timestamp = time(); $finalTimeAndDate = date("H:i",$timestamp) . ", " . date("d.m.Y",$timestamp) . " (UTC)";//07:46, 27 November 2005 (UTC) $patterns[0] = '/~~~~~/'; $patterns[1] = '/~~~~/'; $patterns[2] = '/~~~/'; $replacements[0] = '

'.$finalTimeAndDate.'

'; $replacements[1] = '

'.$username . ' ' . $finalTimeAndDate.'

'; $replacements[2] = '

'.$username.'

'; $modified = preg_replace($patterns, $replacements, $modified); $tocContent = getTocContent($content); if ($tocContent != '') printTocFrame($tocContent); return $modified; } function printTocFrame($tocContent) { $tocframe = ' ' . '

Contents

' . //'
    ' . '

    ' . $tocContent . '

    ' . //'
' . '
'; echo $tocframe; } function getTocContent($content) { $string =''; $level[0] =0; $modified = preg_match_all("#(.*)#Ui", $content, $matches); foreach ($matches[2] as $key => $val) { $toclevel=$matches[1][$key]-1; for ($i = $toclevel+1; $i <= 3; $i++) { $level[$i] =0; } $level[$toclevel]++; $numbering[0] =$level[0] .'. '; $numbering[1] =$level[0] . '.' . $level[1] . '. '; $numbering[2] =$level[0] . '.' . $level[1] . '.' . $level[2] . '. '; $numbering[3] =$level[0] . '.' . $level[1] . '.' . $level[2] . '.' . $level[3] . '. '; //$string = $string . '
  • '.$numbering[$matches[1][$key]-1].' '.$val.'
  • ';// . '
    '; //$string = $string . '

    '.$numbering[$matches[1][$key]-1].' '.$val.'

    '; $string = $string . ''.$numbering[$toclevel].' '.$val.'
    '; } return $string; } /** * Call back function for wiki helper to replace colons * * @param mixed $matches * @return function replace_callback_colon($matches) { // echo 'replace_callback_colon: ' . count($matches); // echo '
    ' . $matches[0] . '
    ' . $matches[1] . '
    '; return '

    '.$matches{1}.'

    '; } */ /* All Links: */ /** * Call back function for wiki helper to link by title * * @param mixed $matches * @return */ function replace_callback_links($matches) { // echo 'replace_callback_links: ' . count($matches); // echo '
    ' . $matches[0] . '
    ' . $matches[1] . '
    '; return 'http:' . $matches[1] . ''; } /** * Call back function for wiki helper to link by title * * @param mixed $matches * @return */ function replace_callback_links_with_substitute($matches) { // echo 'replace_callback_links: ' . count($matches); // echo '
    ' . $matches[0] . '
    ' . $matches[1] . '
    '; return '' . $matches[2] . ''; } /** * Call back function for wiki helper to link by title * * @param mixed $matches * @return */ function replace_wiki_link_title_callback($matches) { if(count($matches) < 2){ return null; } $sql = 'SELECT page_id FROM ' . Revisions::instance()->getTableName(true) . ' WHERE name = \'' . $matches[1] . '\' AND project_id = ' . active_project()->getId() . ' ORDER BY revision DESC'; $row = DB::executeOne($sql); if(!count($row)){ return $matches[1] . ' ?'; } return '' . $matches[1] . ''; } /** * Call back function for wiki helper to link by title * * @param mixed $matches * @return */ function replace_wiki_link_callback($matches) { if(count($matches) < 2){ return null; } $sql = 'SELECT name FROM ' . Revisions::instance()->getTableName(true) . ' WHERE page_id = ' . $matches[1] . ' AND project_id = ' . active_project()->getId(); $row = DB::executeOne($sql); if(!count($row)){ return null; } return '' . $row['name'] . ''; } /** * Call back function for wiki helper to link by title * * @param mixed $matches * @return */ function replace_wiki_link_title_callback_2($matches) { if(count($matches) < 2){ return null; } $sql = 'SELECT page_id FROM ' . Revisions::instance()->getTableName(true) . ' WHERE name = \'' . $matches[1] . '\' AND project_id = ' . active_project()->getId() . ' ORDER BY revision DESC'; $row = DB::executeOne($sql); if(!count($row)){ return $matches[1] . ' ?'; } return '' . $matches[2] . ''; } ?>