"!(.*?)!s" => '[=$1=]', #

,

,

headers "!

(.*?)

!" => "\n! $1", "!

(.*?)

!" => "\n!! $1", "!

(.*?)

!" => "\n!!! $1", # =, ==, === headers "/^(=+)(.*?)\\1/me" => "str_repeat('!',strlen('$1')).PSS('$2')", # , "!(.*?)!" => "'''$1'''", "!(.*?)!" => "''$1''", #
"!
!" => "\\\\\n", # indented text: "!^(:+)!em" => "str_repeat('-', strlen('$1')).'>'", # Term + definition: "!^(;+)(.*?):!em" => "str_repeat(':', strlen('$1')).PSS('$2').':'", # [bracketed links] "/\\[(http:[^$UrlExcludeChars\\s]+)\\]/e" => "Keep(PSS('[[$1 |#]]'))", "/\\[(http:.*?)\\s(.*?)\\]/" => '[[$1 | $2 ]]', # "!(.*?)!" => '%$1%$2%%', #
  "!
(.*?)
!s" => " [=$1=]", # /SubPage "!\\B/($WikiWordPattern)!" => "[[{\$Name}-$1 |$0]]", )); class UseModStore extends PageStore { var $umgroup; function setgroup($group) { $this->umgroup = $group; } function pfile($pagename) { global $FmtV; $ninit = substr(FmtPageName('$Name', $pagename), 0, 1); $pagefile = FmtPageName($this->dirfmt."/$ninit/\$Name.db", $pagename); $pagefile = preg_replace('!-([^-/]+)$!', '/$1', $pagefile); return $pagefile; } function read($pagename) { global $UseModConversions, $KeepToken; $group = FmtPageName('$Group', $pagename); if ($group != $this->umgroup) return false; $pagefile = $this->pfile($pagename); if ($pagefile && $fp=@fopen($pagefile,"r")) { while (!feof($fp)) { $text .= fgets($fp, 4096); } fclose($fp); preg_match('/\\xb3[23]text\\xb33(.*?)\\xb33/s',$text,$match); $text = preg_replace('!(.*?)!se', "Keep(PSS('$1'))", $match[1]); $text = preg_replace(array_keys($UseModConversions), array_values($UseModConversions), $text); $page['text'] = preg_replace("/$KeepToken(\\d.*?)$KeepToken/e", "\$GLOBALS['KPV']['$1']", $text); } return @$page; } function exists($pagename) { $group = FmtPageName('$Group', $pagename); if ($group != $this->umgroup) return false; $pagefile = $this->pfile($pagename); return file_exists($pagefile); } function ls($pats=NULL) { $dir = FmtPageName($this->dirfmt,''); $dirlist = array(preg_replace('!/?[^/]*\$.*$!', '', $dir)); $out = array(); $base = array(); while (count($dirlist)>0) { $dir = array_shift($dirlist); $pref = in_array(basename($dir), $base) ? '.'.basename($dir).'-' : '.'; $dfp = opendir($dir); if (!$dfp) continue; while ( ($pagefile = readdir($dfp)) !== false) { if ($pagefile{0} == '.') continue; if (is_dir("$dir/$pagefile")) { array_push($dirlist, "$dir/$pagefile"); continue; } if (@$seen[$pagefile]++) continue; if (substr($pagefile, -3) != '.db') continue; $pn = substr($pagefile, 0, strlen($pagefile)-3); $base[] = $pn; $out[] = $this->umgroup . $pref . substr($pagefile, 0, strlen($pagefile)-3); } } return $out; } } function UseModPageDir($path, $group='UseMod') { global $WikiLibDirs; if (!is_dir($path)) { Abort("?$path is not an accessible directory"); exit(); } $UseModDir = new UseModStore($path); $UseModDir->setgroup($group); array_splice($WikiLibDirs, 1, 0, array($UseModDir)); } function ConvertUseModPageDir($path, $group='UseMod') { if (!is_dir($path)) { Abort("?$path is not an accessible directory"); exit(); } $UseModDir = new UseModStore($path); $UseModDir->setgroup($group); $oldlist = $UseModDir->ls(); $newlist = ListPages(); $bothlist = array_intersect($oldlist,$newlist); sort($bothlist); $difflist = array_diff($oldlist,$newlist); sort($difflist); $bcount = count($bothlist); $dcount = count($difflist); echo " Convert UseMod pages to PmWiki

Convert and Copy UseMod pages into PmWiki v2

"; $copy = array(); if (@$_POST['copydiff']) $copy = $difflist; if (@$_POST['copyboth']) $copy = array_merge($copy,$bothlist); if (@$_POST['copy']) $copy = array_merge($copy,$_POST['copy']); if (@$copy) { echo "

Okay, I'm now converting the pages you've requested. When this is finished, you can see if anything else needs to be converted, otherwise you can get rid of the include_once('cookbook/usemod.php'); and ConvertUseModPageDir() lines that are in your local/config.php file.

"; $copy = array_unique($copy); foreach($copy as $p) { echo "
  • Converting $p
  • \n"; $page = $UseModDir->read($p); WritePage($p,$page); } echo "

    Converted ", count($copy), " pages.

    \n"; } else { echo "

    This function will migrate pages from a UseMod page directory ($path) into your 2.x wiki.d/ directory, converting markups as it proceeds. Note that the files in your UseMod directory are not affected by this script, so if the conversion doesn't work out for any reason you still have your original pages lying around.

    "; } /* now rebuild the lists */ $oldlist = $UseModDir->ls(); $newlist = ListPages(); $bothlist = array_intersect($oldlist,$newlist); sort($bothlist); $difflist = array_diff($oldlist,$newlist); sort($difflist); $bcount = count($bothlist); $dcount = count($difflist); echo "
    "; echo "

    Migrate pages from UseMod to v2 (don't overwrite existing v2 pages)

    "; if ($difflist) { echo "

    The following $dcount pages exist only in the UseMod page/ directory.

    or

    "; foreach($difflist as $p) echo "
    $p
    \n"; } else { echo "

    There aren't any pages in your UseMod page/ directory that are not already in your version 2 directory.

    "; } echo "

    Migrate pages from UseMod to v2 (overwrite existing v2 pages)

    The following $bcount pages exist in both the UseMod and PmWiki wiki.d/ directories. If you use one of the buttons below, then your converted version 1 pages will overwrite the existing version 2 pages, and you will lose any edits that you might have made in the version 2 installation (it's possible that this is what you want).

    or

    "; foreach($bothlist as $p) echo "
    $p
    \n"; echo "
    \n"; exit(); } ?>