Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

pmwiki 2.2.65 update

  • Loading branch information...
commit ff2a6ece1f2bb5ae21a3a59df43b81050800fd06 1 parent 73a7083
@MichaelPaulukonis MichaelPaulukonis authored
Showing with 699 additions and 650 deletions.
  1. +99 −58 pmwiki.php
  2. +3 −2 pub/skins/bootstrap-fluid/bootstrap-fluid.tmpl
  3. +2 −2 scripts/.htaccess
  4. +4 −5 scripts/author.php
  5. +4 −3 scripts/blocklist.php
  6. +2 −2 scripts/caches.php
  7. +17 −17 scripts/creole.php
  8. +10 −6 scripts/draft.php
  9. +17 −15 scripts/forms.php
  10. +3 −3 scripts/guiedit.php
  11. +21 −20 scripts/markupexpr.php
  12. +23 −18 scripts/pagelist.php
  13. +3 −3 scripts/pagerev.php
  14. +1 −4 scripts/prefs.php
  15. +13 −6 scripts/simuledit.php
  16. +132 −126 scripts/stdmarkup.php
  17. +7 −7 scripts/trails.php
  18. +4 −4 scripts/transition.php
  19. +21 −14 scripts/upload.php
  20. +4 −3 scripts/urlapprove.php
  21. +5 −5 scripts/vardoc.php
  22. +1 −1  scripts/version.php
  23. +9 −9 scripts/wikistyles.php
  24. +4 −4 scripts/wikiwords.php
  25. +5 −5 scripts/xlpage-utf-8.php
  26. +6 −8 wikilib.d/Main.HomePage
  27. +7 −7 wikilib.d/PmWiki.AvailableActions
  28. +6 −6 wikilib.d/PmWiki.BasicEditing
  29. +7 −7 wikilib.d/PmWiki.BasicVariables
  30. +6 −8 wikilib.d/PmWiki.Blocklist
  31. +7 −7 wikilib.d/PmWiki.Categories
  32. +5 −5 wikilib.d/PmWiki.ChangeLog
  33. +6 −8 wikilib.d/PmWiki.ConditionalMarkup
  34. +6 −6 wikilib.d/PmWiki.ContactUs
  35. +6 −8 wikilib.d/PmWiki.Contributors
  36. +6 −6 wikilib.d/PmWiki.CustomMarkup
  37. +6 −6 wikilib.d/PmWiki.CustomWikiStyles
  38. +7 −7 wikilib.d/PmWiki.DeletingPages
  39. +7 −7 wikilib.d/PmWiki.EditVariables
  40. +6 −6 wikilib.d/PmWiki.Functions
  41. +6 −8 wikilib.d/PmWiki.GroupCustomizations
  42. +6 −8 wikilib.d/PmWiki.Images
  43. +6 −6 wikilib.d/PmWiki.Installation
  44. +6 −6 wikilib.d/PmWiki.LayoutVariables
  45. +6 −6 wikilib.d/PmWiki.LinkVariables
  46. +7 −7 wikilib.d/PmWiki.Links
  47. +7 −7 wikilib.d/PmWiki.LocalCustomizations
  48. +7 −6 wikilib.d/PmWiki.MailingLists
  49. +6 −6 wikilib.d/PmWiki.MarkupExpressions
  50. +6 −6 wikilib.d/PmWiki.MarkupMasterIndex
  51. +6 −6 wikilib.d/PmWiki.Notify
  52. +6 −8 wikilib.d/PmWiki.OtherVariables
  53. +6 −6 wikilib.d/PmWiki.PageDirectives
  54. +6 −6 wikilib.d/PmWiki.PageFileFormat
  55. +6 −6 wikilib.d/PmWiki.PageLists
  56. +6 −8 wikilib.d/PmWiki.PageTextVariables
  57. +7 −7 wikilib.d/PmWiki.PageVariables
  58. +7 −7 wikilib.d/PmWiki.PathVariables
  59. +5 −5 wikilib.d/PmWiki.ReleaseNotes
  60. +7 −7 wikilib.d/PmWiki.Requirements
  61. +7 −7 wikilib.d/PmWiki.Security
  62. +6 −6 wikilib.d/PmWiki.TableDirectives
  63. +6 −8 wikilib.d/PmWiki.TextFormattingRules
  64. +6 −6 wikilib.d/PmWiki.Troubleshooting
  65. +5 −5 wikilib.d/PmWiki.UploadVariables
  66. +7 −7 wikilib.d/PmWiki.UploadsAdmin
  67. +6 −8 wikilib.d/PmWiki.WikiGroup
  68. +6 −6 wikilib.d/PmWiki.WikiStyles
  69. +6 −6 wikilib.d/PmWiki.WikiWikiWeb
  70. +1 −1  wikilib.d/Site.SideBar
  71. +6 −8 wikilib.d/Site.Site
  72. +4 −6 wikilib.d/SiteAdmin.AuthUser
View
157 pmwiki.php
@@ -1,7 +1,7 @@
<?php
/*
PmWiki
- Copyright 2001-2013 Patrick R. Michaud
+ Copyright 2001-2014 Patrick R. Michaud
pmichaud@pobox.com
http://www.pmichaud.com/
@@ -210,6 +210,13 @@ class='createlink' href='{\$PageUrl}?action=edit'>?</a>";
$SessionEncode = 'base64_encode';
$SessionDecode = 'base64_decode';
+$CallbackFnTemplates = array(
+ 'default' => '%s',
+ 'return' => 'return %s;',
+ 'markup_e' => 'extract($GLOBALS["MarkupToHTML"]); return %s;',
+ 'qualify' => 'extract($GLOBALS["tmp_qualify"]); return %s;',
+);
+
$Conditions['enabled'] = '(boolean)@$GLOBALS[$condparm]';
$Conditions['false'] = 'false';
$Conditions['true'] = 'true';
@@ -265,8 +272,8 @@ function CondExpr($pagename, $condname, $condparm) {
Markup('links','>inline');
Markup('block','>links');
Markup('style','>block');
-Markup('closeall', '_begin',
- '/^\\(:closeall:\\)$/e',
+Markup_e('closeall', '_begin',
+ '/^\\(:closeall:\\)$/',
"'<:block>' . MarkupClose()");
$ImgExtPattern="\\.(?:gif|jpg|jpeg|png|GIF|JPG|JPEG|PNG)";
@@ -286,11 +293,11 @@ function CondExpr($pagename, $condname, $condparm) {
'table' => array("<table width='100%'>",'','</table>',0));
foreach(array('http:','https:','mailto:','ftp:','news:','gopher:','nap:',
- 'file:') as $m)
+ 'file:', 'tel:', 'geo:') as $m)
{ $LinkFunctions[$m] = 'LinkIMap'; $IMap[$m]="$m$1"; }
$LinkFunctions['<:page>'] = 'LinkPage';
-$q = preg_replace('/(\\?|%3f)([-\\w]+=)/', '&$2', @$_SERVER['QUERY_STRING']);
+$q = preg_replace('/(\\?|%3f)([-\\w]+=)/i', '&$2', @$_SERVER['QUERY_STRING']);
if ($q != @$_SERVER['QUERY_STRING']) {
unset($_GET);
parse_str($q, $_GET);
@@ -401,7 +408,7 @@ function PZZ($x,$y='') { return ''; }
function PRR($x=NULL)
{ if ($x || is_null($x)) $GLOBALS['RedoMarkupLine']++; return $x; }
function PUE($x)
- { return preg_replace('/[\\x80-\\xff \'"<>]/e', "'%'.dechex(ord('$0'))", $x); }
+ { return PPRE('/[\\x80-\\xff \'"<>]/', "'%'.dechex(ord(\$m[0]))", $x); }
function PQA($x) {
$out = '';
if (preg_match_all('/([a-zA-Z][-\\w]*)\\s*=\\s*("[^"]*"|\'[^\']*\'|\\S*)/',
@@ -409,8 +416,8 @@ function PQA($x) {
foreach($attr as $a) {
if (preg_match('/^on/i', $a[1])) continue;
$out .= $a[1] . '='
- . preg_replace( '/^([\'"]?)(.*)\\1$/e',
- "\"'\".str_replace(\"'\", '&#39;', PSS('$2')).\"'\"", $a[2])
+ . PPRE( '/^([\'"]?)(.*)\\1$/',
+ "\"'\".str_replace(\"'\", '&#39;', \$m[2]).\"'\"", $a[2])
. ' ';
}
}
@@ -440,6 +447,30 @@ function PHSC($x, $flags=ENT_COMPAT, $enc=null) { # for PHP 5.4
if(is_null($enc)) $enc = "ISO-8859-1"; # $GLOBALS['Charset']
return htmlspecialchars($x, $flags, $enc);
}
+function PCCF($code, $template = 'default', $args = '$m') {
+ global $CallbackFnTemplates, $CallbackFunctions;
+ if(!isset($CallbackFnTemplates[$template]))
+ Abort("No \$CallbackFnTemplates[$template]).");
+ $code = sprintf($CallbackFnTemplates[$template], $code);
+ if(!isset($CallbackFunctions[$code])) {
+ $fn = create_function($args, $code);
+ $CallbackFunctions[$code] = $fn;
+ }
+ return $CallbackFunctions[$code];
+}
+function PPRE($pat, $rep, $x) {
+ $lambda = PCCF("return $rep;");
+ return preg_replace_callback($pat, $lambda, $x);
+}
+function PPRA($array, $x) {
+ foreach($array as $pat => $rep) {
+ $fmt = $x; # for $FmtP
+ if(is_callable($rep)) $x = preg_replace_callback($pat,$rep,$x);
+ else $x = preg_replace($pat,$rep,$x);
+ }
+ return $x;
+}
+
function StopWatch($x) {
global $StopWatch, $EnableStopWatch;
if (!$EnableStopWatch) return;
@@ -584,7 +615,8 @@ function fixperms($fname, $add = 0, $set = 0) {
}
else {
$bp = 0;
- if (fileowner($fname)!=@fileowner('.')) $bp = (is_dir($fname)) ? 007 : 006;
+ if (fileowner($fname)!=@fileowner('.') && @fileowner('.')!==0)
+ $bp = (is_dir($fname)) ? 007 : 006;
if (filegroup($fname)==@filegroup('.')) $bp <<= 3;
$bp |= $add;
if ($bp && (fileperms($fname) & $bp) != $bp)
@@ -671,27 +703,25 @@ function ResolvePageName($pagename) {
## group of the returned pagename.
function MakePageName($basepage, $str) {
global $MakePageNameFunction, $PageNameChars, $PagePathFmt,
- $MakePageNamePatterns;
+ $MakePageNamePatterns, $MakePageNameSplitPattern;
if (@$MakePageNameFunction) return $MakePageNameFunction($basepage, $str);
SDV($PageNameChars,'-[:alnum:]');
SDV($MakePageNamePatterns, array(
"/'/" => '', # strip single-quotes
"/[^$PageNameChars]+/" => ' ', # convert everything else to space
- '/((^|[^-\\w])\\w)/e' => "strtoupper('$1')",
+ '/((^|[^-\\w])\\w)/' => PCCF("return strtoupper(\$m[1]);"),
'/ /' => ''));
+ SDV($MakePageNameSplitPattern, '/[.\\/]/');
$str = preg_replace('/[#?].*$/', '', $str);
- $m = preg_split('/[.\\/]/', $str);
+ $m = preg_split($MakePageNameSplitPattern, $str);
if (count($m)<1 || count($m)>2 || $m[0]=='') return '';
## handle "Group.Name" conversions
if (@$m[1] > '') {
- $group = preg_replace(array_keys($MakePageNamePatterns),
- array_values($MakePageNamePatterns), $m[0]);
- $name = preg_replace(array_keys($MakePageNamePatterns),
- array_values($MakePageNamePatterns), $m[1]);
+ $group = PPRA($MakePageNamePatterns, $m[0]);
+ $name = PPRA($MakePageNamePatterns, $m[1]);
return "$group.$name";
}
- $name = preg_replace(array_keys($MakePageNamePatterns),
- array_values($MakePageNamePatterns), $m[0]);
+ $name = PPRA($MakePageNamePatterns, $m[0]);
$isgrouphome = count($m) > 1;
foreach((array)$PagePathFmt as $pg) {
if ($isgrouphome && strncmp($pg, '$1.', 3) !== 0) continue;
@@ -715,7 +745,7 @@ function MakeBaseName($pagename, $patlist = NULL) {
global $BaseNamePatterns;
if (is_null($patlist)) $patlist = (array)@$BaseNamePatterns;
foreach($patlist as $pat => $rep)
- $pagename = preg_replace($pat, $rep, $pagename);
+ $pagename = preg_replace($pat, $rep, $pagename); # TODO
return $pagename;
}
@@ -738,8 +768,8 @@ function SetProperty($pagename, $prop, $value, $sep=NULL, $keep=NULL) {
global $PCache, $KeepToken;
NoCache();
$prop = "=p_$prop";
- $value = preg_replace("/$KeepToken(\\d.*?)$KeepToken/e",
- "\$GLOBALS['KPV']['$1']", $value);
+ $value = PPRE("/$KeepToken(\\d.*?)$KeepToken/",
+ "\$GLOBALS['KPV'][\$m[1]]", $value);
if (!is_null($sep) && isset($PCache[$pagename][$prop]))
$value = $PCache[$pagename][$prop] . $sep . $value;
if (is_null($keep) || !isset($PCache[$pagename][$prop]))
@@ -811,22 +841,22 @@ function FmtPageName($fmt, $pagename) {
global $GroupPattern, $NamePattern, $EnablePathInfo, $ScriptUrl,
$GCount, $UnsafeGlobals, $FmtV, $FmtP, $FmtPV, $PCache, $AsSpacedFunction;
if (strpos($fmt,'$')===false) return $fmt;
- $fmt = preg_replace('/\\$([A-Z]\\w*Fmt)\\b/e','$GLOBALS[\'$1\']',$fmt);
- $fmt = preg_replace('/\\$\\[(?>([^\\]]+))\\]/e',"XL(PSS('$1'))",$fmt);
+ $fmt = PPRE('/\\$([A-Z]\\w*Fmt)\\b/','$GLOBALS[$m[1]]',$fmt);
+ $fmt = PPRE('/\\$\\[(?>([^\\]]+))\\]/',"XL(\$m[1])",$fmt);
$fmt = str_replace('{$ScriptUrl}', '$ScriptUrl', $fmt);
$fmt =
- preg_replace('/\\{(\\$[A-Z]\\w+)\\}/e', "PageVar(\$pagename, '$1')", $fmt);
+ PPRE('/\\{(\\$[A-Z]\\w+)\\}/', "PageVar('$pagename', \$m[1])", $fmt);
if (strpos($fmt,'$')===false) return $fmt;
- if ($FmtP) $fmt = preg_replace(array_keys($FmtP), array_values($FmtP), $fmt);
+ if ($FmtP) $fmt = PPRA($FmtP, $fmt); # FIXME
static $pv, $pvpat;
if ($pv != count($FmtPV)) {
$pvpat = str_replace('$', '\\$', implode('|', array_keys($FmtPV)));
$pv = count($FmtPV);
}
- $fmt = preg_replace("/(?:$pvpat)\\b/e", "PageVar(\$pagename, '$0')", $fmt);
- $fmt = preg_replace('!\\$ScriptUrl/([^?#\'"\\s<>]+)!e',
- (@$EnablePathInfo) ? "'$ScriptUrl/'.PUE('$1')" :
- "'$ScriptUrl?n='.str_replace('/','.',PUE('$1'))",
+ $fmt = PPRE("/(?:$pvpat)\\b/", "PageVar('$pagename', \$m[0])", $fmt);
+ $fmt = PPRE('!\\$ScriptUrl/([^?#\'"\\s<>]+)!',
+ (@$EnablePathInfo) ? "'$ScriptUrl/'.PUE(\$m[1])" :
+ "'$ScriptUrl?n='.str_replace('/','.',PUE(\$m[1]))",
$fmt);
if (strpos($fmt,'$')===false) return $fmt;
static $g;
@@ -841,8 +871,8 @@ function FmtPageName($fmt, $pagename) {
krsort($g); reset($g);
}
$fmt = str_replace(array_keys($g),array_values($g),$fmt);
- $fmt = preg_replace('/(?>(\\$[[:alpha:]]\\w+))/e',
- "isset(\$FmtV['$1']) ? \$FmtV['$1'] : '$1'", $fmt);
+ $fmt = PPRE('/(?>(\\$[[:alpha:]]\\w+))/',
+ "isset(\$GLOBALS['FmtV'][\$m[1]]) ? \$GLOBALS['FmtV'][\$m[1]] : \$m[1]", $fmt);
return $fmt;
}
@@ -869,8 +899,8 @@ function FmtTemplateVars($text, $vars, $pagename = NULL) {
global $FmtPV, $EnableUndefinedTemplateVars;
if ($pagename) {
$pat = implode('|', array_map('preg_quote', array_keys($FmtPV)));
- $text = preg_replace("/\\{\\$($pat)\\}/e",
- "PageVar('$pagename', '$1')", $text);
+ $text = PPRE("/\\{\\$($pat)\\}/",
+ "PageVar('$pagename', \$m[1])", $text);
}
foreach(preg_grep('/^[\\w$]/', array_keys($vars)) as $k)
if (!is_array($vars[$k]))
@@ -938,9 +968,10 @@ class PageStore {
function PageStore($d='$WorkDir/$FullName', $w=0, $a=NULL) {
$this->dirfmt = $d; $this->iswrite = $w; $this->attr = (array)$a;
$GLOBALS['PageExistsCache'] = array();
- if (function_exists('iconv') && @iconv("UTF-8", "WINDOWS-1252//IGNORE", 'test')=='test' )
+ # can we rely on iconv() or on mb_convert_encoding() ?
+ if (function_exists('iconv') && @iconv("UTF-8", "WINDOWS-1252//IGNORE", "te\xd0\xafst")=='test' )
$this->recodefn = create_function('$s,$from,$to', 'return @iconv($from,"$to//IGNORE",$s);');
- elseif (function_exists('mb_convert_encoding') && @mb_convert_encoding("test", "WINDOWS-1252", "UTF-8")=="test")
+ elseif (function_exists('mb_convert_encoding') && @mb_convert_encoding("te\xd0\xafst", "WINDOWS-1252", "UTF-8")=="te?st")
$this->recodefn = create_function('$s,$from,$to', 'return @mb_convert_encoding($s,$to,$from);');
else $this->recodefn = false;
}
@@ -1154,7 +1185,7 @@ function Abort($msg, $info='') {
$info
<p class='vspace'><a href='$ScriptUrl'>$[Return to] $ScriptUrl</a></p>";
@header("Content-type: text/html; charset=$Charset");
- echo preg_replace('/\\$\\[([^\\]]+)\\]/e', "XL(PSS('$1'))", $msg);
+ echo PPRE('/\\$\\[([^\\]]+)\\]/', "XL(\$m[1])", $msg);
exit;
}
@@ -1225,7 +1256,7 @@ function PrintWikiPage($pagename, $wikilist=NULL, $auth='read') {
function Keep($x, $pool=NULL) {
# Keep preserves a string from being processed by wiki markups
global $BlockPattern, $KeepToken, $KPV, $KPCount;
- $x = preg_replace("/$KeepToken(\\d.*?)$KeepToken/e", "\$KPV['\$1']", $x);
+ $x = PPRE("/$KeepToken(\\d.*?)$KeepToken/", "\$GLOBALS['KPV'][\$m[1]]", $x);
if (is_null($pool) && preg_match("!</?($BlockPattern)\\b!", $x)) $pool = 'B';
$KPCount++; $KPV[$KPCount.$pool]=$x;
return $KeepToken.$KPCount.$pool.$KeepToken;
@@ -1238,24 +1269,24 @@ function Keep($x, $pool=NULL) {
function MarkupEscape($text) {
global $EscapePattern;
SDV($EscapePattern, '\\[([=@]).*?\\1\\]');
- return preg_replace("/$EscapePattern/es", "Keep(PSS('$0'))", $text);
+ return PPRE("/$EscapePattern/s", "Keep(\$m[0])", $text);
}
function MarkupRestore($text) {
global $KeepToken, $KPV;
- return preg_replace("/$KeepToken(\\d.*?)$KeepToken/e", "\$KPV['$1']", $text);
+ return PPRE("/$KeepToken(\\d.*?)$KeepToken/", "\$GLOBALS['KPV'][\$m[1]]", $text);
}
## Qualify() applies $QualifyPatterns to convert relative links
## and references into absolute equivalents.
function Qualify($pagename, $text) {
- global $QualifyPatterns, $KeepToken, $KPV;
+ global $QualifyPatterns, $KeepToken, $KPV, $tmp_qualify;
if (!@$QualifyPatterns) return $text;
$text = MarkupEscape($text);
- $group = PageVar($pagename, '$Group');
- $name = PageVar($pagename, '$Name');
- foreach((array)$QualifyPatterns as $pat => $rep)
- $text = preg_replace($pat, $rep, $text);
+ $group = $tmp_qualify['group'] = PageVar($pagename, '$Group');
+ $name = $tmp_qualify['name'] = PageVar($pagename, '$Name');
+ $tmp_qualify['pagename'] = $pagename;
+ $text = PPRA((array)$QualifyPatterns, $text);
return MarkupRestore($text);
}
@@ -1451,9 +1482,10 @@ function MarkupClose($key = '') {
function FormatTableRow($x, $sep = '\\|\\|') {
- global $Block, $TableCellAttrFmt, $MarkupFrame, $TableRowAttrFmt,
- $TableRowIndexMax, $FmtV;
+ global $TableCellAttrFmt, $TableCellAlignFmt, $TableRowAttrFmt,
+ $TableRowIndexMax, $MarkupFrame, $FmtV;
static $rowcount;
+ SDV($TableCellAlignFmt, " align='%s'");
$x = preg_replace("/$sep\\s*$/",'',$x);
$td = preg_split("/$sep/", $x); $y = '';
for($i=0;$i<count($td);$i++) {
@@ -1466,9 +1498,11 @@ function FormatTableRow($x, $sep = '\\|\\|') {
elseif (preg_match('/^!(.*)$/',$td[$i],$match))
{ $td[$i]=$match[1]; $t='th'; }
else $t='td';
- if (preg_match('/^\\s.*\\s$/',$td[$i])) { if ($t!='caption') $attr .= " align='center'"; }
- elseif (preg_match('/^\\s/',$td[$i])) { $attr .= " align='right'"; }
- elseif (preg_match('/\\s$/',$td[$i])) { $attr .= " align='left'"; }
+ if (preg_match('/^\\s.*\\s$/',$td[$i])) {
+ if ($t!='caption') $attr .= sprintf($TableCellAlignFmt, 'center');
+ }
+ elseif (preg_match('/^\\s/',$td[$i])) { $attr .= sprintf($TableCellAlignFmt, 'right'); }
+ elseif (preg_match('/\\s$/',$td[$i])) { $attr .= sprintf($TableCellAlignFmt, 'left'); }
for ($colspan=1;$i+$colspan<count($td);$colspan++)
if ($td[$colspan+$i]!='') break;
if ($colspan>1) { $attr .= " colspan='$colspan'"; }
@@ -1486,7 +1520,7 @@ function LinkIMap($pagename,$imap,$path,$alt,$txt,$fmt=NULL) {
global $FmtV, $IMap, $IMapLinkFmt, $UrlLinkFmt, $IMapLocalPath;
SDVA($IMapLocalPath, array('Path:'=>1));
if(@$IMapLocalPath[$imap]) {
- $path = preg_replace('/^\\w+:/e', "urlencode('$0')", $path);
+ $path = preg_replace('/^(\\w+):/', "$1%3a", $path); # PITS:01260
}
$FmtV['$LinkUrl'] = PUE(str_replace('$1',$path,$IMap[$imap]));
$FmtV['$LinkText'] = $txt;
@@ -1503,6 +1537,7 @@ function LinkPage($pagename,$imap,$path,$alt,$txt,$fmt=NULL) {
$alt = str_replace(array('"',"'"),array('&#34;','&#39;'),$alt);
if (!$fmt && $path{0} == '#') {
$path = preg_replace("/[^-.:\\w]/", '', $path);
+ if (trim($txt) == '+') $txt = PageVar($pagename, '$Title');
if($alt) $alt = " title='$alt'";
return ($path) ? "<a href='#$path'$alt>".str_replace("$", "&#036;", $txt)."</a>" : '';
}
@@ -1577,6 +1612,11 @@ function Markup($id, $when, $pat=NULL, $rep=NULL) {
}
}
+function Markup_e($id, $when, $pat, $rep, $template = 'markup_e') {
+ if (!is_callable($rep)) $rep = PCCF($rep, $template);
+ Markup($id, $when, $pat, $rep);
+}
+
function DisableMarkup() {
global $MarkupTable;
$idlist = func_get_args();
@@ -1604,7 +1644,8 @@ function BuildMarkupRules() {
function MarkupToHTML($pagename, $text, $opt = NULL) {
# convert wiki markup text to HTML output
global $MarkupRules, $MarkupFrame, $MarkupFrameBase, $WikiWordCount,
- $K0, $K1, $RedoMarkupLine;
+ $K0, $K1, $RedoMarkupLine, $MarkupToHTML;
+ $MarkupToHTML['pagename'] = $pagename;
StopWatch('MarkupToHTML begin');
array_unshift($MarkupFrame, array_merge($MarkupFrameBase, (array)$opt));
@@ -1618,7 +1659,10 @@ function MarkupToHTML($pagename, $text, $opt = NULL) {
$RedoMarkupLine=0;
$markrules = BuildMarkupRules();
foreach($markrules as $p=>$r) {
- if ($p{0} == '/') $x=preg_replace($p,$r,$x);
+ if ($p{0} == '/') {
+ if(is_callable($r)) $x = preg_replace_callback($p,$r,$x);
+ else $x=preg_replace($p,$r,$x);
+ }
elseif (strstr($x,$p)!==false) $x=eval($r);
if (isset($php_errormsg))
{ echo "ERROR: pat=$p $php_errormsg"; unset($php_errormsg); }
@@ -1765,11 +1809,9 @@ function RestorePage($pagename,&$page,&$new,$restore=NULL) {
## is being posted (as signaled by $EnablePost).
function ReplaceOnSave($pagename,&$page,&$new) {
global $EnablePost, $ROSPatterns, $ROEPatterns;
- foreach ((array)@$ROEPatterns as $pat => $rep)
- $new['text'] = preg_replace($pat, $rep, $new['text']);
+ $new['text'] = PPRA((array)@$ROEPatterns, $new['text']);
if ($EnablePost) {
- foreach((array)@$ROSPatterns as $pat=>$rep)
- $new['text'] = preg_replace($pat, $rep, $new['text']);
+ $new['text'] = PPRA((array)@$ROSPatterns, $new['text']);
}
$new['=preview'] = $new['text'];
PCache($pagename, $new);
@@ -1779,8 +1821,7 @@ function SaveAttributes($pagename,&$page,&$new) {
global $EnablePost, $LinkTargets, $SaveAttrPatterns, $PCache,
$SaveProperties;
if (!$EnablePost) return;
- $text = preg_replace(array_keys($SaveAttrPatterns),
- array_values($SaveAttrPatterns), $new['text']);
+ $text = PPRA($SaveAttrPatterns, $new['text']);
$LinkTargets = array();
$html = MarkupToHTML($pagename,$text);
$new['targets'] = implode(',',array_keys((array)$LinkTargets));
View
5 pub/skins/bootstrap-fluid/bootstrap-fluid.tmpl
@@ -102,9 +102,9 @@
</div><!--/span-->
</div><!--/row-->
- <hr>
-
<!--PageFooterFmt-->
+ <hr />
+
<footer>
<div id='wikifoot'>
<div class='footnav'>
@@ -117,6 +117,7 @@
<div class='lastmod'>$[Page last modified on {$LastModified}]</div>
</div>
</footer>
+<!--/PageFooterFmt-->
</div><!--/.fluid-container-->
View
4 scripts/.htaccess
@@ -1,5 +1,5 @@
-# This file is cookbook/.htaccess -- the default distribution contains this
-# file to prevent cookbook/ scripts from being accessed directly by browsers
+# This file is script/.htaccess -- the default distribution contains this
+# file to prevent script/ files from being accessed directly by browsers
# (this is a potential, albeit very unlikely, security hole).
#
# If you alter or replace this file, it will likely be overwritten when
View
9 scripts/author.php
@@ -1,5 +1,5 @@
<?php if (!defined('PmWiki')) exit();
-/* Copyright 2004-2009 Patrick R. Michaud (pmichaud@pobox.com)
+/* Copyright 2004-2013 Patrick R. Michaud (pmichaud@pobox.com)
This file is part of PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
@@ -35,10 +35,9 @@
if (IsEnabled($EnableAuthorSignature,1)) {
SDVA($ROSPatterns, array(
- '/(?<!~)~~~~(?!~)/e'
- => "FmtPageName('[[~\$Author]] \$CurrentTime', \$pagename)",
- '/(?<!~)~~~(?!~)/e'
- => "FmtPageName('[[~\$Author]]', \$pagename)"));
+ '/(?<!~)~~~~(?!~)/' => "[[~$Author]] $CurrentTime",
+ '/(?<!~)~~~(?!~)/' => "[[~$Author]]",
+ ));
Markup('~~~~','<[[~','/(?<!~)~~~~(?!~)/',"[[~$Author]] $CurrentTime");
Markup('~~~','>~~~~','/(?<!~)~~~(?!~)/',"[[~$Author]]");
}
View
7 scripts/blocklist.php
@@ -44,8 +44,9 @@
## but at some point we may change the default to disabled.
if (IsEnabled($EnableBlocklistImmediate, 1)) {
SDVA($BlocklistActions, array('comment' => 1));
- if (isset($_POST['text']) && @$BlocklistActions[$action]) {
- Blocklist($pagename, $_POST['text']);
+ $ptext = implode(' ', @$_POST);
+ if ($ptext && @$BlocklistActions[$action]) {
+ Blocklist($pagename, $ptext);
if (!$EnablePost) {
unset($_POST['post']);
unset($_POST['postattr']);
@@ -73,7 +74,7 @@
array_unshift($EditFunctions, 'CheckBlocklist');
function CheckBlocklist($pagename, &$page, &$new) {
StopWatch("CheckBlocklist: begin $pagename");
- $ptext = implode('', @$_POST);
+ $ptext = implode(' ', @$_POST);
if (@$ptext) Blocklist($pagename, $ptext);
StopWatch("CheckBlocklist: end $pagename");
}
View
4 scripts/caches.php
@@ -1,5 +1,5 @@
<?php if (!defined('PmWiki')) exit();
-/* Copyright 2006-2009 Patrick R. Michaud (pmichaud@pobox.com)
+/* Copyright 2006-2014 Patrick R. Michaud (pmichaud@pobox.com)
This file is part of PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
@@ -50,7 +50,7 @@
if ($NoHTMLCache
|| !@$PageCacheDir
|| count($_POST) > 0
- || count($_GET) > 2
+ || count($_GET) > 1
|| (count($_GET) == 1 && !@$_GET['n'])) { $NoHTMLCache |= 1; return; }
mkdirp($PageCacheDir);
View
34 scripts/creole.php
@@ -1,5 +1,5 @@
<?php if (!defined('PmWiki')) exit();
-/* Copyright 2007-2010 Patrick R. Michaud (pmichaud@pobox.com)
+/* Copyright 2007-2014 Patrick R. Michaud (pmichaud@pobox.com)
This file is part of PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
@@ -24,31 +24,31 @@
'<em>$1</em>');
## == Headings ==
-Markup('^=', 'block',
- '/^(={1,6})\\s?(.*?)(\\s*=*\\s*)$/e',
- "'<:block,1><h'.strlen('$1').PSS('>$2</h').strlen('$1').'>'");
+Markup_e('^=', 'block',
+ '/^(={1,6})\\s?(.*?)(\\s*=*\\s*)$/',
+ "'<:block,1><h'.strlen(\$m[1]).'>'.\$m[2].'</h'.strlen(\$m[1]).'>'");
## Line breaks
Markup('\\\\', 'inline', '/\\\\\\\\/', '<br />');
## Preformatted
-Markup('^{{{', '[=',
- "/^\\{\\{\\{\n(.*?\n)\\}\\}\\}[^\\S\n]*\n/sme",
- "Keep(PSS('<pre class=\"escaped\">$1</pre>'))");
-Markup('{{{', '>{{{',
- '/\\{\\{\\{(.*?)\\}\\}\\}/se',
- "Keep(PSS('<code class=\"escaped\">$1</code>'))");
+Markup_e('^{{{', '[=',
+ "/^\\{\\{\\{\n(.*?\n)\\}\\}\\}[^\\S\n]*\n/sm",
+ "Keep('<pre class=\"escaped\">'.\$m[1].'</pre>')");
+Markup_e('{{{', '>{{{',
+ '/\\{\\{\\{(.*?)\\}\\}\\}/s',
+ "Keep('<code class=\"escaped\">'.\$m[1].'</code>')");
## Tables
-Markup('|-table', '>^||',
- '/^\\|(.*)$/e',
- "FormatTableRow(PSS('$0'), '\\|')");
+Markup_e('|-table', '>^||',
+ '/^\\|(.*)$/',
+ "FormatTableRow(\$m[0], '\\|')");
## Images
-Markup('{{', 'inline',
- '/\\{\\{(?>(\\L))([^|\\]]*)(?:\\|\\s*(.*?)\\s*)?\\}\\}/e',
- "Keep(\$GLOBALS['LinkFunctions']['$1'](\$pagename, '$1', '$2', '$3',
- '$1$2', \$GLOBALS['ImgTagFmt']),'L')");
+Markup_e('{{', 'inline',
+ '/\\{\\{(?>(\\L))([^|\\]]*)(?:\\|\\s*(.*?)\\s*)?\\}\\}/',
+ "Keep(\$GLOBALS['LinkFunctions'][\$m[1]](\$pagename, \$m[1], \$m[2], \$m[3],
+ \$m[1].\$m[2], \$GLOBALS['ImgTagFmt']),'L')");
## GUIButtons
View
16 scripts/draft.php
@@ -1,5 +1,5 @@
<?php if (!defined('PmWiki')) exit();
-/* Copyright 2006, 2010 Patrick R. Michaud (pmichaud@pobox.com)
+/* Copyright 2006-2013 Patrick R. Michaud (pmichaud@pobox.com)
This file is part of PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
@@ -48,15 +48,21 @@
## add the draft handler into $EditFunctions
array_unshift($EditFunctions, 'EditDraft');
function EditDraft(&$pagename, &$page, &$new) {
- global $WikiDir, $DraftSuffix, $DeleteKeyPattern,
- $DraftRecentChangesFmt, $RecentChangesFmt;
+ global $WikiDir, $DraftSuffix, $DeleteKeyPattern, $EnableDraftAtomicDiff,
+ $DraftRecentChangesFmt, $RecentChangesFmt, $Now;
SDV($DeleteKeyPattern, "^\\s*delete\\s*$");
$basename = preg_replace("/$DraftSuffix\$/", '', $pagename);
$draftname = $basename . $DraftSuffix;
if ($_POST['postdraft'] || $_POST['postedit']) $pagename = $draftname;
else if ($_POST['post'] && !preg_match("/$DeleteKeyPattern/", $new['text'])) {
$pagename = $basename;
- $page = ReadPage($basename);
+ if(IsEnabled($EnableDraftAtomicDiff, 0)) {
+ $page = ReadPage($basename);
+ foreach($new as $k=>$v) # delete draft history
+ if(preg_match('/:\\d+(:\\d+:)?$/', $k) && ! preg_match("/:$Now(:\\d+:)?$/", $k)) unset($new[$k]);
+ unset($new['rev']);
+ SDVA($new, $page);
+ }
$WikiDir->delete($draftname);
}
else if (PageExists($draftname) && $pagename != $draftname)
@@ -64,5 +70,3 @@ function EditDraft(&$pagename, &$page, &$new) {
if ($pagename == $draftname && isset($DraftRecentChangesFmt))
$RecentChangesFmt = $DraftRecentChangesFmt;
}
-
-
View
32 scripts/forms.php
@@ -1,5 +1,5 @@
<?php if (!defined('PmWiki')) exit();
-/* Copyright 2005-2010 Patrick R. Michaud (pmichaud@pobox.com)
+/* Copyright 2005-2014 Patrick R. Michaud (pmichaud@pobox.com)
This file is part of PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
@@ -9,7 +9,9 @@
# $InputAttrs are the attributes we allow in output tags
SDV($InputAttrs, array('name', 'value', 'id', 'class', 'rows', 'cols',
'size', 'maxlength', 'action', 'method', 'accesskey', 'tabindex', 'multiple',
- 'checked', 'disabled', 'readonly', 'enctype', 'src', 'alt'));
+ 'checked', 'disabled', 'readonly', 'enctype', 'src', 'alt',
+ 'required', 'placeholder', 'autocomplete'
+ ));
# Set up formatting for text, submit, hidden, radio, etc. types
foreach(array('text', 'submit', 'hidden', 'password', 'radio', 'checkbox',
@@ -56,14 +58,14 @@
SDVA($InputTags['defaults'], array(':fn' => 'InputDefault'));
## (:input ...:) directives
-Markup('input', 'directives',
- '/\\(:input\\s+(\\w+)(.*?):\\)/ei',
- "InputMarkup(\$pagename, '$1', PSS('$2'))");
+Markup_e('input', 'directives',
+ '/\\(:input\\s+(\\w+)(.*?):\\)/i',
+ "InputMarkup(\$pagename, \$m[1], \$m[2])");
## (:input select:) has its own markup processing
-Markup('input-select', '<input',
- '/\\(:input\\s+select\\s.*?:\\)(?:\\s*\\(:input\\s+select\\s.*?:\\))*/ei',
- "InputSelect(\$pagename, 'select', PSS('$0'))");
+Markup_e('input-select', '<input',
+ '/\\(:input\\s+select\\s.*?:\\)(?:\\s*\\(:input\\s+select\\s.*?:\\))*/i',
+ "InputSelect(\$pagename, 'select', \$m[0])");
## The 'input+sp' rule combines multiple (:input select ... :)
## into a single markup line (to avoid split line effects)
@@ -81,7 +83,7 @@ function InputToHTML($pagename, $type, $args, &$opt) {
$InputFocusLevel, $InputFocusId, $InputFocusFmt, $HTMLFooterFmt;
if (!@$InputTags[$type]) return "(:input $type $args:)";
## get input arguments
- if (!is_array($args)) $args = ParseArgs($args);
+ if (!is_array($args)) $args = ParseArgs($args, '(?>([\\w-]+)[:=])');
## convert any positional arguments to named arguments
$posnames = @$InputTags[$type][':args'];
if (!$posnames) $posnames = array('name', 'value');
@@ -241,11 +243,11 @@ function RequestArgs($req = NULL) {
## Form-based authorization prompts (for use with PmWikiAuth)
-
-$r = str_replace("'", '%37', stripmagic($_SERVER['REQUEST_URI']));
SDVA($InputTags['auth_form'], array(
- ':html' => "<form action='$r' method='post'
- name='authform'>\$PostVars"));
+ ':html' => "<form \$InputFormArgs>\$PostVars",
+ 'action' => str_replace("'", '%37', stripmagic($_SERVER['REQUEST_URI'])),
+ 'method' => 'post',
+ 'name' => 'authform'));
SDV($AuthPromptFmt, array(&$PageStartFmt, 'page:$SiteGroup.AuthForm',
"<script language='javascript' type='text/javascript'><!--
try { document.authform.authid.focus(); }
@@ -276,8 +278,8 @@ function RequestArgs($req = NULL) {
$Conditions['e_preview'] = '(boolean)$_REQUEST["preview"]';
# (:e_preview:) displays the preview of formatted text.
-Markup('e_preview', 'directives',
- '/^\\(:e_preview:\\)/e',
+Markup_e('e_preview', 'directives',
+ '/^\\(:e_preview:\\)/',
"isset(\$GLOBALS['FmtV']['\$PreviewText']) ? Keep(\$GLOBALS['FmtV']['\$PreviewText']): ''");
# If we didn't load guiedit.php, then set (:e_guibuttons:) to
View
6 scripts/guiedit.php
@@ -1,5 +1,5 @@
<?php if (!defined('PmWiki')) exit();
-/* Copyright 2004-2010 Patrick R. Michaud (pmichaud@pobox.com)
+/* Copyright 2004-2013 Patrick R. Michaud (pmichaud@pobox.com)
This file is part of PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
@@ -50,8 +50,8 @@
'center' => array(410, '%center%', '', '',
'$GUIButtonDirUrlFmt/center.gif"$[Center]"')));
-Markup('e_guibuttons', 'directives',
- '/\\(:e_guibuttons:\\)/e',
+Markup_e('e_guibuttons', 'directives',
+ '/\\(:e_guibuttons:\\)/',
"Keep(FmtPageName(GUIButtonCode(\$pagename), \$pagename))");
function GUIButtonCode($pagename) {
View
41 scripts/markupexpr.php
@@ -1,5 +1,5 @@
<?php if (!defined('PmWiki')) exit();
-/* Copyright 2007-2010 Patrick R. Michaud (pmichaud@pobox.com)
+/* Copyright 2007-2014 Patrick R. Michaud (pmichaud@pobox.com)
This file is part of PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
@@ -51,29 +51,30 @@
results of other expressions; these values may be un-escaped
by using "preg_replace($rpat, $rrep, $params)".
*/
-Markup('{(', '>{$var}',
- '/\\{(\\(\\w+\\b.*?\\))\\}/e',
- "MarkupExpression(\$pagename, PSS('$1'))");
+Markup_e('{(', '>{$var}',
+ '/\\{(\\(\\w+\\b.*?\\))\\}/',
+ "MarkupExpression(\$pagename, \$m[1])");
SDVA($MarkupExpr, array(
- 'substr' => 'call_user_func_array("substr", $args)',
- 'strlen' => 'strlen($args[0])',
- 'ftime' => 'ME_ftime(@$args[0], @$args[1], $argp)',
- 'rand' => '($args) ? rand($args[0], $args[1]) : rand()',
- 'ucfirst' => 'ucfirst($args[0])',
- 'ucwords' => 'ucwords($args[0])',
- 'tolower' => 'strtolower($args[0])',
- 'toupper' => 'strtoupper($args[0])',
+ 'substr' => 'call_user_func_array("substr", $args)',
+ 'strlen' => 'strlen($args[0])',
+ 'ftime' => 'ME_ftime(@$args[0], @$args[1], $argp)',
+ 'rand' => '($args) ? rand($args[0], $args[1]) : rand()',
+ 'ucfirst' => 'ucfirst($args[0])',
+ 'ucwords' => 'ucwords($args[0])',
+ 'tolower' => 'strtolower($args[0])',
+ 'toupper' => 'strtoupper($args[0])',
+ 'mod' => '0 + ($args[0] % $args[1])',
'asspaced' => '$GLOBALS["AsSpacedFunction"]($args[0])',
- 'pagename' => 'MakePageName($pagename, preg_replace($rpat, $rrep, $params))',
+ 'pagename' => 'MakePageName($pagename, PPRE($rpat, $rrep, $params))',
));
function MarkupExpression($pagename, $expr) {
global $KeepToken, $KPV, $MarkupExpr;
- $rpat = "/$KeepToken(\\d+P)$KeepToken/e";
- $rrep = '$KPV[\'$1\']';
- $expr = preg_replace('/([\'"])(.*?)\\1/e', "Keep(PSS('$2'),'P')", $expr);
- $expr = preg_replace('/\\(\\W/e', "Keep(PSS('$2'),'P')", $expr);
+ $rpat = "/$KeepToken(\\d+P)$KeepToken/";
+ $rrep = '$GLOBALS["KPV"][$m[1]]';
+ $expr = PPRE('/([\'"])(.*?)\\1/', "Keep(\$m[2],'P')", $expr);
+ $expr = PPRE('/\\(\\W/', "Keep(\$m[0],'P')", $expr);
while (preg_match('/\\((\\w+)(\\s[^()]*)?\\)/', $expr, $match)) {
list($repl, $func, $params) = $match;
$code = @$MarkupExpr[$func];
@@ -92,16 +93,16 @@ function MarkupExpression($pagename, $expr) {
while ($x) {
list($k, $v) = array_splice($x, 0, 2);
if ($k == '' || $k == '+' || $k == '-')
- $args[] = $k.preg_replace($rpat, $rrep, $v);
+ $args[] = $k.PPRE($rpat, $rrep, $v);
}
## fix any quoted arguments
foreach ($argp as $k => $v)
- if (!is_array($v)) $argp[$k] = preg_replace($rpat, $rrep, $v);
+ if (!is_array($v)) $argp[$k] = PPRE($rpat, $rrep, $v);
$out = eval("return ({$code});");
if ($expr == $repl) { $expr = $out; break; }
$expr = str_replace($repl, Keep($out, 'P'), $expr);
}
- return preg_replace($rpat, $rrep, $expr);
+ return PPRE($rpat, $rrep, $expr);
}
## ME_ftime handles {(ftime ...)} expressions.
View
41 scripts/pagelist.php
@@ -1,5 +1,5 @@
<?php if (!defined('PmWiki')) exit();
-/* Copyright 2004-2011 Patrick R. Michaud (pmichaud@pobox.com)
+/* Copyright 2004-2014 Patrick R. Michaud (pmichaud@pobox.com)
This file is part of PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
@@ -66,16 +66,16 @@
SDV($PageListArgPattern, '((?:\\$:?)?\\w+)[:=]');
-Markup('pagelist', 'directives',
- '/\\(:pagelist(\\s+.*?)?:\\)/ei',
- "FmtPageList('\$MatchList', \$pagename, array('o' => PSS('$1 ')))");
-Markup('searchbox', 'directives',
- '/\\(:searchbox(\\s.*?)?:\\)/e',
- "SearchBox(\$pagename, ParseArgs(PSS('$1'), '$PageListArgPattern'))");
-Markup('searchresults', 'directives',
- '/\\(:searchresults(\\s+.*?)?:\\)/ei',
+Markup_e('pagelist', 'directives',
+ '/\\(:pagelist(\\s+.*?)?:\\)/i',
+ "FmtPageList('\$MatchList', \$pagename, array('o' => \$m[1].' '))");
+Markup_e('searchbox', 'directives',
+ '/\\(:searchbox(\\s.*?)?:\\)/',
+ "SearchBox(\$pagename, ParseArgs(\$m[1], '$PageListArgPattern'))");
+Markup_e('searchresults', 'directives',
+ '/\\(:searchresults(\\s+.*?)?:\\)/i',
"FmtPageList(\$GLOBALS['SearchResultsFmt'], \$pagename,
- array('req' => 1, 'request'=>1, 'o' => PSS('$1')))");
+ array('req' => 1, 'request'=>1, 'o' => \$m[1]))");
SDV($SaveAttrPatterns['/\\(:(searchresults|pagelist)(\\s+.*?)?:\\)/i'], ' ');
@@ -150,8 +150,13 @@ function FmtPageList($outfmt, $pagename, $opt) {
}
$opt = array_merge($opt, ParseArgs($opt['o'], $PageListArgPattern));
# merge markup options with form and url
- if (@$opt['request'])
- $opt = array_merge($opt, ParseArgs($rq, $PageListArgPattern), @$_REQUEST);
+ if (@$opt['request']) {
+ $cleanrequest = array();
+ if(@$_REQUEST)foreach($_REQUEST as $k=>$v)
+ $cleanrequest[$k] = stripmagic($v);
+ $opt = array_merge($opt, ParseArgs($rq, $PageListArgPattern), $cleanrequest);
+ }
+
# non-posted blank search requests return nothing
if (@($opt['req'] && !$opt['-'] && !$opt[''] && !$opt['+'] && !$opt['q']))
return '';
@@ -312,8 +317,8 @@ function PageListIf(&$list, &$opt, $pn, &$page) {
$Cursor['='] = $pn;
$varpat = '\\{([=*]|!?[-\\w.\\/\\x80-\\xff]*)(\\$:?\\w+)\\}';
while (preg_match("/$varpat/", $condspec, $match)) {
- $condspec = preg_replace("/$varpat/e",
- "PVSE(PageVar(\$pn, '$2', '$1'))", $condspec);
+ $condspec = PPRE("/$varpat/",
+ "PVSE(PageVar('$pn', \$m[2], \$m[1]))", $condspec);
}
if (!preg_match("/^\\s*(!?)\\s*(\\S*)\\s*(.*?)\\s*$/", $condspec, $match))
return 0;
@@ -604,7 +609,7 @@ function FPLTemplateDefaults($pagename, $matches, &$opt, &$tparts){
if ($tparts[$i] != 'template') { $i++; continue; }
if ($tparts[$i+2] != 'defaults' && $tparts[$i+2] != 'default') { $i+=5; continue; }
$pvars = $GLOBALS['MarkupTable']['{$var}']; # expand {$PVars}
- $ttext = preg_replace($pvars['pat'], $pvars['rep'], $tparts[$i+3]);
+ $ttext = preg_replace_callback($pvars['pat'], $pvars['rep'], $tparts[$i+3]);
$opt = array_merge(ParseArgs($ttext, $PageListArgPattern), $opt);
array_splice($tparts, $i, 4);
}
@@ -706,11 +711,11 @@ function FPLTemplateFormat($pagename, $matches, $opt, $tparts, &$output){
function FPLExpandItemVars($item, $matches, $idx, $psvars) {
global $Cursor, $EnableUndefinedTemplateVars;
$Cursor['<'] = $Cursor['&lt;'] = (string)@$matches[$idx-1];
- $Cursor['='] = (string)@$matches[$idx];
+ $Cursor['='] = $pn = (string)@$matches[$idx];
$Cursor['>'] = $Cursor['&gt;'] = (string)@$matches[$idx+1];
$item = str_replace(array_keys($psvars), array_values($psvars), $item);
- $item = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w[-\\w]*)\\}/e',
- "PVSE(PageVar(\$pn, '$2', '$1'))", $item);
+ $item = PPRE('/\\{(=|&[lg]t;)(\\$:?\\w[-\\w]*)\\}/',
+ "PVSE(PageVar('$pn', \$m[2], \$m[1]))", $item);
if(! IsEnabled($EnableUndefinedTemplateVars, 0))
$item = preg_replace("/\\{\\$\\$\\w+\\}/", '', $item);
return $item;
View
6 scripts/pagerev.php
@@ -1,5 +1,5 @@
<?php if (!defined('PmWiki')) exit();
-/* Copyright 2004-2012 Patrick R. Michaud (pmichaud@pobox.com)
+/* Copyright 2004-2014 Patrick R. Michaud (pmichaud@pobox.com)
This file is part of PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
@@ -127,7 +127,7 @@ function DiffHTML($pagename, $diff) {
.$DiffRenderSourceFunction($in, $out, 0)
."</div>";
else $html .= MarkupToHTML($pagename,
- preg_replace('/\\(:.*?:\\)/e',"Keep(PHSC(PSS('$0')))", join("\n",$in)));
+ PPRE('/\\(:.*?:\\)/',"Keep(PHSC(\$m[0]))", join("\n",$in)));
}
if ($match[4]=='d' || $match[4]=='c') {
$txt = str_replace('line',$lines,$DiffAddFmt[$match[4]]);
@@ -138,7 +138,7 @@ function DiffHTML($pagename, $diff) {
.$DiffRenderSourceFunction($in, $out, 1)
."</div>";
else $html .= MarkupToHTML($pagename,
- preg_replace('/\\(:.*?:\\)/e',"Keep(PHSC(PSS('$0')))",join("\n",$out)));
+ PPRE('/\\(:.*?:\\)/',"Keep(PHSC(\$m[0]))",join("\n",$out)));
}
$html .= FmtPageName($DiffEndDelAddFmt,$pagename);
}
View
5 scripts/prefs.php
@@ -1,5 +1,5 @@
<?php if (!defined('PmWiki')) exit();
-/* Copyright 2005-2013 Patrick R. Michaud (pmichaud@pobox.com)
+/* Copyright 2005-2014 Patrick R. Michaud (pmichaud@pobox.com)
This file is part of PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
@@ -38,9 +38,6 @@
}
}
-if(preg_match('/^e_(rows|cols)$/', $k)) $v = intval($v);
- elseif(preg_match('/^ak_/', $k)) $v = $v{0};
-
XLSDV('en', array(
'ak_view' => '',
'ak_edit' => 'e',
View
19 scripts/simuledit.php
@@ -1,5 +1,5 @@
<?php if (!defined('PmWiki')) exit();
-/* Copyright 2004-2006 Patrick R. Michaud (pmichaud@pobox.com)
+/* Copyright 2004-2014 Patrick R. Michaud (pmichaud@pobox.com)
This file is part of PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
@@ -16,7 +16,7 @@
font-style:italic; margin-top:1.33em; margin-bottom:1.33em; }\n";
function Merge($newtext,$oldtext,$pagetext) {
- global $WorkDir,$SysMergeCmd;
+ global $WorkDir,$SysMergeCmd, $SysMergePassthru;
SDV($SysMergeCmd,"/usr/bin/diff3 -L '' -L '' -L '' -m -E");
if (substr($newtext,-1,1)!="\n") $newtext.="\n";
if (substr($oldtext,-1,1)!="\n") $oldtext.="\n";
@@ -28,10 +28,17 @@ function Merge($newtext,$oldtext,$pagetext) {
if ($oldfp=fopen($tempold,'w')) { fputs($oldfp,$oldtext); fclose($oldfp); }
if ($pagfp=fopen($temppag,'w')) { fputs($pagfp,$pagetext); fclose($pagfp); }
$mergetext = '';
- $merge_handle = popen("$SysMergeCmd $tempnew $tempold $temppag",'r');
- if ($merge_handle) {
- while (!feof($merge_handle)) $mergetext .= fread($merge_handle,4096);
- pclose($merge_handle);
+ if (IsEnabled($SysMergePassthru, 0)) {
+ ob_start();
+ passthru("$SysMergeCmd $tempnew $tempold $temppag");
+ $mergetext = ob_get_clean();
+ }
+ else {
+ $merge_handle = popen("$SysMergeCmd $tempnew $tempold $temppag",'r');
+ if ($merge_handle) {
+ while (!feof($merge_handle)) $mergetext .= fread($merge_handle,4096);
+ pclose($merge_handle);
+ }
}
@unlink($tempnew); @unlink($tempold); @unlink($temppag);
return $mergetext;
View
258 scripts/stdmarkup.php
@@ -1,5 +1,5 @@
<?php if (!defined('PmWiki')) exit();
-/* Copyright 2004-2011 Patrick R. Michaud (pmichaud@pobox.com)
+/* Copyright 2004-2014 Patrick R. Michaud (pmichaud@pobox.com)
This file is part of PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
@@ -27,10 +27,10 @@ function PreserveText($sigil, $text, $lead) {
return "$lead<:pre,1>".Keep($text);
}
-Markup('[=','_begin',"/(\n[^\\S\n]*)?\\[([=@])(.*?)\\2\\]/se",
- "PreserveText('$2', PSS('$3'), '$1')");
-Markup('restore','<_end',"/$KeepToken(\\d.*?)$KeepToken/e",
- '$GLOBALS[\'KPV\'][\'$1\']');
+Markup_e('[=','_begin',"/(\n[^\\S\n]*)?\\[([=@])(.*?)\\2\\]/s",
+ "PreserveText(\$m[2], \$m[3], \$m[1])");
+Markup_e('restore','<_end',"/$KeepToken(\\d.*?)$KeepToken/",
+ '$GLOBALS[\'KPV\'][$m[1]]');
Markup('<:', '>restore',
'/<:[^>]*>/', '');
Markup('<vspace>', '<restore',
@@ -44,13 +44,13 @@ function PreserveText($sigil, $text, $lead) {
Markup('\\r','<[=','/\\r/','');
# $[phrase] substitutions
-Markup('$[phrase]', '>[=',
- '/\\$\\[(?>([^\\]]+))\\]/e', "NoCache(XL(PSS('$1')))");
+Markup_e('$[phrase]', '>[=',
+ '/\\$\\[(?>([^\\]]+))\\]/', "NoCache(XL(\$m[1]))");
# {$var} substitutions
-Markup('{$var}', '>$[phrase]',
- '/\\{(\\*|!?[-\\w.\\/\\x80-\\xff]*)(\\$:?\\w[-\\w]*)\\}/e',
- "PRR(PVSE(PageVar(\$pagename, '$2', '$1')))");
+Markup_e('{$var}', '>$[phrase]',
+ '/\\{(\\*|!?[-\\w.\\/\\x80-\\xff]*)(\\$:?\\w[-\\w]*)\\}/',
+ "PRR(PVSE(PageVar(\$pagename, \$m[2], \$m[1])))");
# invisible (:textvar:...:) definition
Markup('textvar:', '<split',
@@ -58,8 +58,9 @@ function PreserveText($sigil, $text, $lead) {
## handle relative text vars in includes
if (IsEnabled($EnableRelativePageVars, 1))
- SDV($QualifyPatterns["/\\{([-\\w\\x80-\\xfe]*)(\\$:?\\w+\\})/e"],
- "'{' . ('$1' ? MakePageName(\$pagename, '$1') : \$pagename) . '$2'");
+ SDV($QualifyPatterns["/\\{([-\\w\\x80-\\xfe]*)(\\$:?\\w+\\})/"],
+ PCCF("'{' . (\$m[1] ? MakePageName(\$pagename, \$m[1]) : \$pagename) . \$m[2]", 'qualify'));
+
## character entities
Markup('&','<if','/&amp;(?>([A-Za-z0-9]+|#\\d+|#[xX][A-Fa-f0-9]+));/',
@@ -74,13 +75,14 @@ function PreserveText($sigil, $text, $lead) {
(?: \\(: (?:if\\1|if\\1end) \\s* :\\)
| (?=\\(:(?:if\\1|if\\1end)\\b[^\n]*?:\\) | $)
)
- /seix");
-SDV($CondTextReplacement, "CondText2(\$pagename, PSS('$0'), '$1')");
-Markup('if', 'fulltext', $CondTextPattern, $CondTextReplacement);
+ /six");
+SDV($CondTextReplacement, "CondText2(\$pagename, \$m[0], \$m[1])");
+Markup_e('if', 'fulltext', $CondTextPattern, $CondTextReplacement);
function CondText2($pagename, $text, $code = '') {
global $Conditions, $CondTextPattern, $CondTextReplacement;
$if = "if$code";
+ $repl = str_replace('$pagename', "'$pagename'", $CondTextReplacement);
$parts = preg_split("/\\(:(?:{$if}end|$if|else *$if|else$code)\\b\\s*(.*?)\\s*:\\)/",
$text, -1, PREG_SPLIT_DELIM_CAPTURE);
@@ -89,40 +91,41 @@ function CondText2($pagename, $text, $code = '') {
list($condspec, $condtext) = array_splice($parts, 0, 2);
if (!preg_match("/^\\s*(!?)\\s*(\\S*)\\s*(.*?)\\s*$/", $condspec, $match)) continue;
list($x, $not, $condname, $condparm) = $match;
+
if (!isset($Conditions[$condname]))
- return preg_replace($CondTextPattern, $CondTextReplacement, $condtext);
+ return PPRE($CondTextPattern, $repl, $condtext);
$tf = @eval("return ({$Conditions[$condname]});");
if ($tf xor $not)
- return preg_replace($CondTextPattern, $CondTextReplacement, $condtext);
+ return PPRE($CondTextPattern, $repl, $condtext);
}
return '';
}
## (:include:)
-Markup('include', '>if',
- '/\\(:include\\s+(\\S.*?):\\)/ei',
- "PRR(IncludeText(\$pagename, PSS('$1')))");
+Markup_e('include', '>if',
+ '/\\(:include\\s+(\\S.*?):\\)/i',
+ "PRR(IncludeText(\$pagename, \$m[1]))");
## (:redirect:)
-Markup('redirect', '<include',
- '/\\(:redirect\\s+(\\S.*?):\\)/ei',
- "RedirectMarkup(\$pagename, PSS('$1'))");
+Markup_e('redirect', '<include',
+ '/\\(:redirect\\s+(\\S.*?):\\)/i',
+ "RedirectMarkup(\$pagename, \$m[1])");
$SaveAttrPatterns['/\\(:(if\\d*|include|redirect)(\\s.*?)?:\\)/i'] = ' ';
## GroupHeader/GroupFooter handling
-Markup('nogroupheader', '>include',
- '/\\(:nogroupheader:\\)/ei',
+Markup_e('nogroupheader', '>include',
+ '/\\(:nogroupheader:\\)/i',
"PZZ(\$GLOBALS['GroupHeaderFmt']='')");
-Markup('nogroupfooter', '>include',
- '/\\(:nogroupfooter:\\)/ei',
+Markup_e('nogroupfooter', '>include',
+ '/\\(:nogroupfooter:\\)/i',
"PZZ(\$GLOBALS['GroupFooterFmt']='')");
-Markup('groupheader', '>nogroupheader',
- '/\\(:groupheader:\\)/ei',
+Markup_e('groupheader', '>nogroupheader',
+ '/\\(:groupheader:\\)/i',
"PRR(FmtPageName(\$GLOBALS['GroupHeaderFmt'],\$pagename))");
-Markup('groupfooter','>nogroupfooter',
- '/\\(:groupfooter:\\)/ei',
+Markup_e('groupfooter','>nogroupfooter',
+ '/\\(:groupfooter:\\)/i',
"PRR(FmtPageName(\$GLOBALS['GroupFooterFmt'],\$pagename))");
## (:nl:)
@@ -130,50 +133,50 @@ function CondText2($pagename, $text, $code = '') {
Markup('nl1','>nl0',"/\\(:nl:\\)/i",'');
## \\$ (end of line joins)
-Markup('\\$','>nl1',"/\\\\(?>(\\\\*))\n/e",
- "str_repeat('<br />',strlen('$1'))");
+Markup_e('\\$','>nl1',"/\\\\(?>(\\\\*))\n/",
+ "str_repeat('<br />',strlen(\$m[1]))");
## Remove one <:vspace> after !headings
Markup('!vspace', '>\\$', "/^(!(?>[^\n]+)\n)<:vspace>/m", '$1');
## (:noheader:),(:nofooter:),(:notitle:)...
-Markup('noheader', 'directives',
- '/\\(:noheader:\\)/ei',
+Markup_e('noheader', 'directives',
+ '/\\(:noheader:\\)/i',
"SetTmplDisplay('PageHeaderFmt',0)");
-Markup('nofooter', 'directives',
- '/\\(:nofooter:\\)/ei',
+Markup_e('nofooter', 'directives',
+ '/\\(:nofooter:\\)/i',
"SetTmplDisplay('PageFooterFmt',0)");
-Markup('notitle', 'directives',
- '/\\(:notitle:\\)/ei',
+Markup_e('notitle', 'directives',
+ '/\\(:notitle:\\)/i',
"SetTmplDisplay('PageTitleFmt',0)");
-Markup('noleft', 'directives',
- '/\\(:noleft:\\)/ei',
+Markup_e('noleft', 'directives',
+ '/\\(:noleft:\\)/i',
"SetTmplDisplay('PageLeftFmt',0)");
-Markup('noright', 'directives',
- '/\\(:noright:\\)/ei',
+Markup_e('noright', 'directives',
+ '/\\(:noright:\\)/i',
"SetTmplDisplay('PageRightFmt',0)");
-Markup('noaction', 'directives',
- '/\\(:noaction:\\)/ei',
+Markup_e('noaction', 'directives',
+ '/\\(:noaction:\\)/i',
"SetTmplDisplay('PageActionFmt',0)");
## (:spacewikiwords:)
-Markup('spacewikiwords', 'directives',
- '/\\(:(no)?spacewikiwords:\\)/ei',
- "PZZ(\$GLOBALS['SpaceWikiWords']=('$1'!='no'))");
+Markup_e('spacewikiwords', 'directives',
+ '/\\(:(no)?spacewikiwords:\\)/i',
+ "PZZ(\$GLOBALS['SpaceWikiWords']=(\$m[1]!='no'))");
## (:linkwikiwords:)
-Markup('linkwikiwords', 'directives',
- '/\\(:(no)?linkwikiwords:\\)/ei',
- "PZZ(\$GLOBALS['LinkWikiWords']=('$1'!='no'))");
+Markup_e('linkwikiwords', 'directives',
+ '/\\(:(no)?linkwikiwords:\\)/i',
+ "PZZ(\$GLOBALS['LinkWikiWords']=(\$m[1]!='no'))");
## (:linebreaks:)
-Markup('linebreaks', 'directives',
- '/\\(:(no)?linebreaks:\\)/ei',
- "PZZ(\$GLOBALS['HTMLPNewline'] = ('$1'!='no') ? '<br />' : '')");
+Markup_e('linebreaks', 'directives',
+ '/\\(:(no)?linebreaks:\\)/i',
+ "PZZ(\$GLOBALS['HTMLPNewline'] = (\$m[1]!='no') ? '<br />' : '')");
## (:messages:)
-Markup('messages', 'directives',
- '/^\\(:messages:\\)/ei',
+Markup_e('messages', 'directives',
+ '/^\\(:messages:\\)/i',
"'<:block>'.Keep(
FmtPageName(implode('',(array)\$GLOBALS['MessagesFmt']), \$pagename))");
@@ -183,19 +186,19 @@ function CondText2($pagename, $text, $code = '') {
## (:title:) +fix for PITS:00266, 00779
$tmpwhen = IsEnabled($EnablePageTitlePriority, 0) ? '<include' : 'directives';
$tmpkeep = IsEnabled($EnablePageTitlePriority, 0) ? '1' : 'NULL';
-Markup('title', $tmpwhen,
- '/\\(:title\\s(.*?):\\)/ei',
+Markup_e('title', $tmpwhen,
+ '/\\(:title\\s(.*?):\\)/i',
"PZZ(PCache(\$pagename,
- \$zz=array('title' => SetProperty(\$pagename, 'title', PSS('$1'), NULL, $tmpkeep))))");
+ \$zz=array('title' => SetProperty(\$pagename, 'title', \$m[1], NULL, $tmpkeep))))");
unset($tmpwhen, $tmpkeep);
## (:keywords:), (:description:)
-Markup('keywords', 'directives',
- "/\\(:keywords?\\s+(.+?):\\)/ei",
- "PZZ(SetProperty(\$pagename, 'keywords', PSS('$1'), ', '))");
-Markup('description', 'directives',
- "/\\(:description\\s+(.+?):\\)/ei",
- "PZZ(SetProperty(\$pagename, 'description', PSS('$1'), '\n'))");
+Markup_e('keywords', 'directives',
+ "/\\(:keywords?\\s+(.+?):\\)/i",
+ "PZZ(SetProperty(\$pagename, 'keywords', \$m[1], ', '))");
+Markup_e('description', 'directives',
+ "/\\(:description\\s+(.+?):\\)/i",
+ "PZZ(SetProperty(\$pagename, 'description', \$m[1], '\n'))");
$HTMLHeaderFmt['meta'] = 'function:PrintMetaTags';
function PrintMetaTags($pagename, $args) {
global $PCache;
@@ -229,9 +232,9 @@ function PrintMetaTags($pagename, $args) {
Markup("'_","<'''''","/'_(.*?)_'/",'<sub>$1</sub>');
## [+big+], [-small-]
-Markup('[+','inline','/\\[(([-+])+)(.*?)\\1\\]/e',
- "'<span style=\'font-size:'.(round(pow(6/5,$2strlen('$1'))*100,0)).'%\'>'.
- PSS('$3</span>')");
+Markup_e('[+','inline','/\\[(([-+])+)(.*?)\\1\\]/',
+ "'<span style=\'font-size:'.(round(pow(6/5,(\$m[2]=='-'? -1:1)*strlen(\$m[1]))*100,0)).'%\'>'.
+ \$m[3].'</span>'");
## {+ins+}, {-del-}
Markup('{+','inline','/\\{\\+(.*?)\\+\\}/','<ins>$1</ins>');
@@ -242,14 +245,14 @@ function PrintMetaTags($pagename, $args) {
###### Links ######
## [[free links]]
-Markup('[[','links',"/(?>\\[\\[\\s*(.*?)\\]\\])($SuffixPattern)/e",
- "Keep(MakeLink(\$pagename,PSS('$1'),NULL,'$2'),'L')");
+Markup_e('[[','links',"/(?>\\[\\[\\s*(.*?)\\]\\])($SuffixPattern)/",
+ "Keep(MakeLink(\$pagename,\$m[1],NULL,\$m[2]),'L')");
## [[!Category]]
SDV($CategoryGroup,'Category');
SDV($LinkCategoryFmt,"<a class='categorylink' href='\$LinkUrl'>\$LinkText</a>");
-Markup('[[!','<[[','/\\[\\[!(.*?)\\]\\]/e',
- "Keep(MakeLink(\$pagename,PSS('$CategoryGroup/$1'),NULL,'',\$GLOBALS['LinkCategoryFmt']),'L')");
+Markup_e('[[!','<[[','/\\[\\[!(.*?)\\]\\]/',
+ "Keep(MakeLink(\$pagename,'$CategoryGroup/'.\$m[1],NULL,'',\$GLOBALS['LinkCategoryFmt']),'L')");
# This is a temporary workaround for blank category pages.
# It may be removed in a future release (Pm, 2006-01-24)
if (preg_match("/^$CategoryGroup\\./", $pagename)) {
@@ -258,44 +261,45 @@ function PrintMetaTags($pagename, $args) {
}
## [[target | text]]
-Markup('[[|','<[[',
- "/(?>\\[\\[([^|\\]]*)\\|\\s*)(.*?)\\s*\\]\\]($SuffixPattern)/e",
- "Keep(MakeLink(\$pagename,PSS('$1'),PSS('$2'),'$3'),'L')");
+Markup_e('[[|','<[[',
+ "/(?>\\[\\[([^|\\]]*)\\|\\s*)(.*?)\\s*\\]\\]($SuffixPattern)/",
+ "Keep(MakeLink(\$pagename,\$m[1],\$m[2],\$m[3]),'L')");
## [[text -> target ]]
-Markup('[[->','>[[|',
- "/(?>\\[\\[([^\\]]+?)\\s*-+&gt;\\s*)(.*?)\\]\\]($SuffixPattern)/e",
- "Keep(MakeLink(\$pagename,PSS('$2'),PSS('$1'),'$3'),'L')");
+Markup_e('[[->','>[[|',
+ "/(?>\\[\\[([^\\]]+?)\\s*-+&gt;\\s*)(.*?)\\]\\]($SuffixPattern)/",
+ "Keep(MakeLink(\$pagename,\$m[2],\$m[1],\$m[3]),'L')");
if (IsEnabled($EnableRelativePageLinks, 1))
- SDV($QualifyPatterns['/(\\[\\[(?>[^\\]]+?->)?\\s*)([-\\w\\x80-\\xfe\\s\'()]+([|#?].*?)?\\]\\])/e'], "PSS('$1').\$group.PSS('/$2')");
+ SDV($QualifyPatterns['/(\\[\\[(?>[^\\]]+?->)?\\s*)([-\\w\\x80-\\xfe\\s\'()]+([|#?].*?)?\\]\\])/'],
+ PCCF("\$m[1].\$group.'/'.\$m[2]", 'qualify'));
## [[#anchor]]
-Markup('[[#','<[[','/(?>\\[\\[#([A-Za-z][-.:\\w]*))\\]\\]/e',
- "Keep(TrackAnchors('$1') ? '' : \"<a name='$1' id='$1'></a>\", 'L')");
+Markup_e('[[#','<[[','/(?>\\[\\[#([A-Za-z][-.:\\w]*))\\]\\]/',
+ "Keep(TrackAnchors(\$m[1]) ? '' : \"<a name='{\$m[1]}' id='{\$m[1]}'></a>\", 'L')");
function TrackAnchors($x) { global $SeenAnchor; return @$SeenAnchor[$x]++; }
## [[target |#]] reference links
-Markup('[[|#', '<[[|',
- "/(?>\\[\\[([^|\\]]+))\\|\\s*#\\s*\\]\\]/e",
- "Keep(MakeLink(\$pagename,PSS('$1'),'['.++\$MarkupFrame[0]['ref'].']'),'L')");
+Markup_e('[[|#', '<[[|',
+ "/(?>\\[\\[([^|\\]]+))\\|\\s*#\\s*\\]\\]/",
+ "Keep(MakeLink(\$pagename,\$m[1],'['.++\$GLOBALS['MarkupFrame'][0]['ref'].']'),'L')");
## [[target |+]] title links moved inside LinkPage()
## bare urllinks
-Markup('urllink','>[[',
- "/\\b(?>(\\L))[^\\s$UrlExcludeChars]*[^\\s.,?!$UrlExcludeChars]/e",
- "Keep(MakeLink(\$pagename,'$0','$0'),'L')");
+Markup_e('urllink','>[[',
+ "/\\b(?>(\\L))[^\\s$UrlExcludeChars]*[^\\s.,?!$UrlExcludeChars]/",
+ "Keep(MakeLink(\$pagename,\$m[0],\$m[0]),'L')");
## mailto: links
-Markup('mailto','<urllink',
- "/\\bmailto:([^\\s$UrlExcludeChars]*[^\\s.,?!$UrlExcludeChars])/e",
- "Keep(MakeLink(\$pagename,'$0','$1'),'L')");
+Markup_e('mailto','<urllink',
+ "/\\bmailto:([^\\s$UrlExcludeChars]*[^\\s.,?!$UrlExcludeChars])/",
+ "Keep(MakeLink(\$pagename,\$m[0],\$m[1]),'L')");
## inline images
-Markup('img','<urllink',
- "/\\b(?>(\\L))([^\\s$UrlExcludeChars]+$ImgExtPattern)(\"([^\"]*)\")?/e",
- "Keep(\$GLOBALS['LinkFunctions']['$1'](\$pagename,'$1','$2','$4','$1$2',
+Markup_e('img','<urllink',
+ "/\\b(?>(\\L))([^\\s$UrlExcludeChars]+$ImgExtPattern)(\"([^\"]*)\")?/",
+ "Keep(\$GLOBALS['LinkFunctions'][\$m[1]](\$pagename,\$m[1],\$m[2],\$m[4],\$m[1].\$m[2],
\$GLOBALS['ImgTagFmt']),'L')");
## bare wikilinks
@@ -304,16 +308,16 @@ function TrackAnchors($x) { global $SeenAnchor; return @$SeenAnchor[$x]++; }
## escaped `WikiWords
## v2.2: rule kept here for markup compatibility with 2.1 and earlier
-Markup('`wikiword', '<wikilink',
- "/`(($GroupPattern([\\/.]))?($WikiWordPattern))/e",
- "Keep('$1')");
+Markup_e('`wikiword', '<wikilink',
+ "/`(($GroupPattern([\\/.]))?($WikiWordPattern))/",
+ "Keep(\$m[1])");
#### Block markups ####
## Completely blank lines don't do anything.
Markup('blank', '<block', '/^\\s+$/', '');
## process any <:...> markup (after all other block markups)
-Markup('^<:','>block','/^(?=\\s*\\S)(<:([^>]+)>)?/e',"Block('$2')");
+Markup_e('^<:','>block','/^(?=\\s*\\S)(<:([^>]+)>)?/',"Block(\$m[2])");
## unblocked lines w/block markup become anonymous <:block>
Markup('^!<:', '<^<:',
@@ -322,14 +326,15 @@ function TrackAnchors($x) { global $SeenAnchor; return @$SeenAnchor[$x]++; }
## Lines that begin with displayed images receive their own block. A
## pipe following the image indicates a "caption" (generates a linebreak).
-Markup('^img', 'block',
- "/^((?>(\\s+|%%|%[A-Za-z][-,=:#\\w\\s'\".]*%)*)$KeepToken(\\d+L)$KeepToken)(\\s*\\|\\s?)?(.*)$/e",
- "PSS((strpos(\$GLOBALS['KPV']['$3'],'<img')===false) ? '$0' :
- '<:block,1><div>$1' . ('$4' ? '<br />' : '') .'$5</div>')");
+Markup_e('^img', 'block',
+ "/^((?>(\\s+|%%|%[A-Za-z][-,=:#\\w\\s'\".]*%)*)$KeepToken(\\d+L)$KeepToken)(\\s*\\|\\s?)?(.*)$/",
+ "(strpos(\$GLOBALS['KPV'][\$m[3]],'<img')===false) ? \$m[0] :
+ '<:block,1><div>'.\$m[1] . (\$m[4] ? '<br />' : '') .\$m[5].'</div>'");
+
## Whitespace at the beginning of lines can be used to maintain the
## indent level of a previous list item, or a preformatted text block.
-Markup('^ws', '<^img', '/^\\s+ #1/ex', "WSIndent('$0')");
+Markup_e('^ws', '<^img', '/^\\s+ #1/x', "WSIndent(\$m[0])");
function WSIndent($i) {
global $MarkupFrame;
$icol = strlen($i);
@@ -345,10 +350,10 @@ function WSIndent($i) {
## The $EnableWSPre setting uses leading spaces on markup lines to indicate
## blocks of preformatted text.
SDV($EnableWSPre, 1);
-Markup('^ ', 'block',
- '/^\\s+ #2/ex',
- "(\$GLOBALS['EnableWSPre'] > 0 && strlen('$0') >= \$GLOBALS['EnableWSPre'])
- ? '<:pre,1>$0' : '$0'");
+Markup_e('^ ', 'block',
+ '/^\\s+ #2/x',
+ "(\$GLOBALS['EnableWSPre'] > 0 && strlen(\$m[0]) >= \$GLOBALS['EnableWSPre'])
+ ? '<:pre,1>'.\$m[0] : \$m[0]");
## bullet lists
Markup('^*','block','/^(\\*+)\\s?(\\s*)/','<:ul,$1,$0>$2');
@@ -369,25 +374,25 @@ function WSIndent($i) {
## tables
## ||cell||, ||!header cell||, ||!caption!||
-Markup('^||||', 'block',
- '/^\\|\\|.*\\|\\|.*$/e',
- "FormatTableRow(PSS('$0'))");
+Markup_e('^||||', 'block',
+ '/^\\|\\|.*\\|\\|.*$/',
+ "FormatTableRow(\$m[0])");
## ||table attributes
-Markup('^||','>^||||','/^\\|\\|(.*)$/e',
- "PZZ(\$GLOBALS['BlockMarkups']['table'][0] = '<table '.PQA(PSS('$1')).'>')
+Markup_e('^||','>^||||','/^\\|\\|(.*)$/',
+ "PZZ(\$GLOBALS['BlockMarkups']['table'][0] = '<table '.PQA(\$m[1]).'>')
.'<:block,1>'");
## headings
-Markup('^!', 'block',
- '/^(!{1,6})\\s?(.*)$/e',
- "'<:block,1><h'.strlen('$1').PSS('>$2</h').strlen('$1').'>'");
+Markup_e('^!', 'block',
+ '/^(!{1,6})\\s?(.*)$/',
+ "'<:block,1><h'.strlen(\$m[1]).'>'.\$m[2].'</h'.strlen(\$m[1]).'>'");
## horiz rule
Markup('^----','>^->','/^----+/','<:block,1><hr />');
#### (:table:) markup (AdvancedTables)
function Cells($name,$attr) {
- global $MarkupFrame;
+ global $MarkupFrame, $EnableTableAutoValignTop;
$attr = PQA($attr);
$tattr = @$MarkupFrame[0]['tattr'];
$name = strtolower($name);
@@ -398,7 +403,8 @@ function Cells($name,$attr) {
$cf = & $MarkupFrame[0]['closeall'];
if ($name == 'table') $MarkupFrame[0]['tattr'] = $attr;
else if ($key == 'cell') {
- if (strpos($attr, "valign=")===false) $attr .= " valign='top'";
+ if (IsEnabled($EnableTableAutoValignTop, 1) && strpos($attr, "valign=")===false)
+ $attr .= " valign='top'";
$t = (strpos($name, 'head')===0 ) ? 'th' : 'td';
if (!@$cf['table']) {
$tattr = @$MarkupFrame[0]['tattr'];
@@ -414,9 +420,9 @@ function Cells($name,$attr) {
return $out;
}
-Markup('table', '<block',
- '/^\\(:(table|cell|cellnr|head|headnr|tableend|div\\d*(?:end)?)(\\s.*?)?:\\)/ie',
- "Cells('$1',PSS('$2'))");
+Markup_e('table', '<block',
+ '/^\\(:(table|cell|cellnr|head|headnr|tableend|div\\d*(?:end)?)(\\s.*?)?:\\)/i',
+ "Cells(\$m[1],\$m[2])");
Markup('^>>', '<table',
'/^&gt;&gt;(.+?)&lt;&lt;(.*)$/',
'(:div:)%div $1 apply=div%$2 ');
@@ -445,12 +451,12 @@ function MarkupMarkup($pagename, $text, $opt = '') {
class='markup2' valign='top'>$html</td></tr></table>");
}
-Markup('markup', '<[=',
- "/\\(:markup(\\s+([^\n]*?))?:\\)[^\\S\n]*\\[([=@])(.*?)\\3\\]/sei",
- "MarkupMarkup(\$pagename, PSS('$4'), PSS('$2'))");
-Markup('markupend', '>markup',
- "/\\(:markup(\\s+([^\n]*?))?:\\)[^\\S\n]*\n(.*?)\\(:markupend:\\)/sei",
- "MarkupMarkup(\$pagename, PSS('$3'), PSS('$1'))");
+Markup_e('markup', '<[=',
+ "/\\(:markup(\\s+([^\n]*?))?:\\)[^\\S\n]*\\[([=@])(.*?)\\3\\]/si",
+ "MarkupMarkup(\$pagename, \$m[4], \$m[2])");
+Markup_e('markupend', '>markup',
+ "/\\(:markup(\\s+([^\n]*?))?:\\)[^\\S\n]*\n(.*?)\\(:markupend:\\)/si",
+ "MarkupMarkup(\$pagename, \$m[3], \$m[1])");
SDV($HTMLStylesFmt['markup'], "
table.markup { border:2px dotted #ccf; width:90%; }
@@ -491,5 +497,5 @@ function CondDate($condparm) {
# This pattern enables the (:encrypt <phrase>:) markup/replace-on-save
# pattern.
-SDV($ROSPatterns['/\\(:encrypt\\s+([^\\s:=]+).*?:\\)/e'], "crypt(PSS('$1'))");
+SDV($ROSPatterns['/\\(:encrypt\\s+([^\\s:=]+).*?:\\)/'], PCCF("return crypt(\$m[1]);"));
View
14 scripts/trails.php
@@ -1,5 +1,5 @@
<?php if (!defined('PmWiki')) exit();
-/* Copyright 2002-2011 Patrick R. Michaud (pmichaud@pobox.com)
+/* Copyright 2002-2013 Patrick R. Michaud (pmichaud@pobox.com)
This file is part of PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
@@ -27,12 +27,12 @@
markups and the original suggestion for WikiTrails.
*/
-Markup('<<|','<links','/&lt;&lt;\\|([^|]+|\\[\\[(.+?)\\]\\])\\|&gt;&gt;/e',
- "PRR(MakeTrailStop(\$pagename,'$1'))");
-Markup('<|','><<|','/&lt;\\|([^|]+|\\[\\[(.+?)\\]\\])\\|&gt;/e',
- "PRR(MakeTrailStopB(\$pagename,'$1'))");
-Markup('^|','<links','/\\^\\|([^|]+|\\[\\[(.+?)\\]\\])\\|\\^/e',
- "PRR(MakeTrailPath(\$pagename,'$1'))");
+Markup_e('<<|','<links','/&lt;&lt;\\|([^|]+|\\[\\[(.+?)\\]\\])\\|&gt;&gt;/',
+ "PRR(MakeTrailStop(\$pagename,\$m[1]))");
+Markup_e('<|','><<|','/&lt;\\|([^|]+|\\[\\[(.+?)\\]\\])\\|&gt;/',
+ "PRR(MakeTrailStopB(\$pagename,\$m[1]))");
+Markup_e('^|','<links','/\\^\\|([^|]+|\\[\\[(.+?)\\]\\])\\|\\^/',
+ "PRR(MakeTrailPath(\$pagename,\$m[1]))");
SDVA($SaveAttrPatterns, array(
'/<<\\|([^|]+|\\[\\[(.+?)\\]\\])\\|>>/' => '$1',
View
8 scripts/transition.php
@@ -1,5 +1,5 @@
<?php if (!defined('PmWiki')) exit();
-/* Copyright 2005-2007 Patrick R. Michaud (pmichaud@pobox.com)
+/* Copyright 2005-2014 Patrick R. Michaud (pmichaud@pobox.com)
This file is part of PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
@@ -146,9 +146,9 @@ function TCells($name,$attr) {
return $out;
}
- Markup('table', '<block',
- '/^\\(:(table|cell|cellnr|tableend|div|divend)(\\s.*?)?:\\)/ie',
- "TCells('$1',PSS('$2'))");
+ Markup_e('table', '<block',
+ '/^\\(:(table|cell|cellnr|tableend|div|divend)(\\s.*?)?:\\)/i',
+ "TCells(\$m[1],\$m[2])");
}
View
35 scripts/upload.php
@@ -1,5 +1,5 @@
<?php if (!defined('PmWiki')) exit();
-/* Copyright 2004-2013 Patrick R. Michaud (pmichaud@pobox.com)
+/* Copyright 2004-2014 Patrick R. Michaud (pmichaud@pobox.com)
This file is part of PmWiki; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
@@ -37,6 +37,9 @@
'hqx' => 'application/mac-binhex40', 'sit' => 'application/x-stuffit',
'doc' => 'application/msword', 'ppt' => 'application/vnd.ms-powerpoint',
'xls' => 'application/vnd.ms-excel', 'mdb' => 'text/plain',
+ 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
+ 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'exe' => 'application/octet-stream',
'pdf' => 'application/pdf', 'psd' => 'text/plain',
'ps' => 'application/postscript', 'ai' => 'application/postscript',
@@ -106,9 +109,9 @@
SDV($AuthCascade['upload'], 'read');
SDV($FmtPV['$PasswdUpload'], 'PasswdVar($pn, "upload")');
-Markup('attachlist', 'directives',
- '/\\(:attachlist\\s*(.*?):\\)/ei',
- "Keep('<ul>'.FmtUploadList('$pagename',PSS('$1')).'</ul>')");
+Markup_e('attachlist', 'directives',
+ '/\\(:attachlist\\s*(.*?):\\)/i',
+ "Keep('<ul>'.FmtUploadList('$pagename',\$m[1]).'</ul>')");
SDV($GUIButtons['attach'], array(220, 'Attach:', '', '$[file.ext]',
'$GUIButtonDirUrlFmt/attach.gif"$[Attach file]"'));
SDV($LinkFunctions['Attach:'], 'LinkUpload');
@@ -126,16 +129,15 @@ function MakeUploadName($pagename,$x) {
SDV($UploadNameChars, "-\\w. ");
SDV($MakeUploadNamePatterns, array(
"/[^$UploadNameChars]/" => '',
- '/\\.[^.]*$/e' => 'strtolower("$0")',
+ '/\\.[^.]*$/' => PCCF('return strtolower($m[0]);'),
'/^[^[:alnum:]_]+/' => '',
'/[^[:alnum:]_]+$/' => ''));
- return preg_replace(array_keys($MakeUploadNamePatterns),
- array_values($MakeUploadNamePatterns), $x);
+ return PPRA($MakeUploadNamePatterns, $x);
}
function LinkUpload($pagename, $imap, $path, $alt, $txt, $fmt=NULL) {
- global $FmtV, $UploadFileFmt, $LinkUploadCreateFmt, $UploadUrlFmt,
- $UploadPrefixFmt, $EnableDirectDownload;
+ global $FmtV, $UploadFileFmt, $LinkUploadCreateFmt,
+ $UploadUrlFmt, $UploadPrefixFmt, $EnableDirectDownload;
if (preg_match('!^(.*)/([^/]+)$!', $path, $match)) {
$pagename = MakePageName($pagename, $match[1]);
$path = $match[2];
@@ -143,7 +145,7 @@ function LinkUpload($pagename, $imap, $path, $alt, $txt, $fmt=NULL) {
$upname = MakeUploadName($pagename, $path);
$encname = rawurlencode($upname);
$filepath = FmtPageName("$UploadFileFmt/$upname", $pagename);
- $FmtV['$LinkUpload'] =
+ $FmtV['$LinkUpload'] =
FmtPageName("\$PageUrl?action=upload&amp;upname=$encname", $pagename);
$FmtV['$LinkText'] = $txt;
if (!file_exists($filepath))
@@ -303,7 +305,7 @@ function dirsize($dir) {
function FmtUploadList($pagename, $args) {
global $UploadDir, $UploadPrefixFmt, $UploadUrlFmt, $EnableUploadOverwrite,
- $TimeFmt, $EnableDirectDownload;
+ $TimeFmt, $EnableDirectDownload, $IMapLinkFmt, $UrlLinkFmt, $FmtV;
$opt = ParseArgs($args);
if (@$opt[''][0]) $pagename = MakePageName($pagename, $opt[''][0]);
@@ -330,14 +332,19 @@ function FmtUploadList($pagename, $args) {
$out = array();