"!
"!(.*?)!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 "
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 " \n"; exit(); } ?>