format($text); $html = $f->out; if (false) { /* saveHTML messes with the encoding */ /* tidy it up */ @$d = DOMDocument::loadHTML($html); if ($d) { $d->formatOutput = true; $d->substituteEntities = false; $html = $d->saveHTML(); $html = preg_replace("/^.*/sm", '', $html); $html = preg_replace(",.*,sm", '', $html); } } return $html; } static function format_to_oneliner($text) { $f = new MTrack_Wiki_OneLinerFormatter; $f->format($text); return $f->out; } static function format_wiki_page($name) { $d = new MTrack_Wiki_Item($name); if ($d->file) { return self::format_to_html($d->content); } return null; } static function register_macro($name, $callback) { self::$macros[$name] = $callback; } static function register_processor($name, $callback) { self::$processors[$name] = $callback; } static function macro_IncludeWiki($pagename) { return self::format_wiki_page($pagename); } static function macro_IncludeHelp($pagename) { return self::format_to_html(file_get_contents( dirname(__FILE__) . '/../defaults/help/' . basename($pagename))); } static function macro_comment() { return ''; } static function processor_comment($name, $content) { return ''; } static function processor_html($name, $content) { return join("\n", $content); } static function processor_dataset($name, $content) { $res = ''; while (count($content)) { $row = array_shift($content); $next_row = array_shift($content); $cols = preg_split("/\s*\|\s*/", $row); if ($next_row[0] == '-') { // it's a header $res .= ''; foreach ($cols as $c) { $res .= "\n"; } $res .= ""; } else { if (is_string($next_row)) { array_unshift($content, $next_row); } // regular row $res .= ""; foreach ($cols as $c) { $res .= "\n"; } $res .= "\n"; } } $res .= "
" . htmlentities($c, ENT_QUOTES, 'utf-8') . "
" . htmlentities($c, ENT_QUOTES, 'utf-8') . "
\n"; return $res; } }