function wiki_directory_listing($dir, $pre = '', $chop = 0) { if (is_dir($dir) && ($handle = opendir($dir))) { echo "<ul>\n"; while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { if ($chop > 0) { $file = substr($file, 0, strlen($file) - $chop); } $label = htmlspecialchars(urldecode($file)); $file = htmlspecialchars($file); echo '<li><a href="' . htmlspecialchars($pre) . $file . '">' . $label . "</a></li>\n"; } } closedir($handle); echo "</ul>\n"; } else { wiki_perror('Cannot access directory: ' . $dir); return false; } }
if (Texy::isRelative($link->URL)) { $link->URL = '?page=' . urlencode($link->URL); } elseif (substr($link->URL, 0, 5) === 'wiki:') { $link->URL = 'http://en.wikipedia.org/wiki/Special:Search?search=' . urlencode(substr($link->URL, 5)); } elseif (substr($link->URL, 0, 4) === 'url:') { $link->URL = substr($link->URL, 4); } return $invocation->proceed(); } $GLOBALS['wiki_format'] = function (&$content) { $cache = $GLOBALS['dir']['cache'] . md5($content) . $GLOBALS['cache_ext']; if ($GLOBALS['enable_cache'] && file_exists($cache)) { $content = file_get_contents($cache) . '<!-- THIS FILE WAS CACHED IN ' . $cache . ' -->'; } else { if (!(require_once $GLOBALS['texy_path'])) { wiki_perror('Cannot load: ' . $GLOBALS['texy_path']); return false; } if (!isset($GLOBALS['texy'])) { $GLOBALS['texy'] = new Texy(); if ($GLOBALS['paranoia']) { TexyConfigurator::safeMode($GLOBALS['texy']); } $GLOBALS['texy']->encoding = $GLOBALS['charset_encoding']; $GLOBALS['texy']->htmlOutputModule->baseIndent = 4; //$GLOBALS['texy']->linkModule->root = '?page='; $GLOBALS['texy']->addHandler('phrase', 'wiki_texy_phraseHandler'); $GLOBALS['texy']->registerLinePattern('wiki_texy_InlineHandler', '#(?<!\\[\\[)\\[\\[(?!\\ |\\[\\[)(.+)' . TEXY_MODIFIER . '?(?<!\\ |\\]\\])\\]\\](?!\\]\\])()#U', 'wikilink'); /*$GLOBALS['texy']->registerLinePattern( 'wiki_texy_InlineHandler', // callback function or method '#(?<!\[)\[(?!\ |\[)(.+)'.TEXY_MODIFIER.'?(?<!\ |\])\](?!\])()#U', // regular expression
function wiki_save_page($arg_page = '', &$content) { $page = $GLOBALS['page']; if ($arg_page != '') { $page = $arg_page; } $page_file = wiki_page_filename($page); if (file_exists($page_file)) { copy($page_file, wiki_backup_filename($page)); } if (!file_put_contents($page_file, $content)) { wiki_perror('Cannot write to file: ' . htmlspecialchars($page_file)); } }