diff options
Diffstat (limited to 'pmwiki.php')
-rw-r--r-- | pmwiki.php | 25 |
1 files changed, 17 insertions, 8 deletions
@@ -167,6 +167,7 @@ $FmtPV = array( '$GroupHomePageName' => 'FmtGroupHome($pn,$group,$var)', '$GroupHomePageTitle' => 'FmtGroupHome($pn,$group,$var)', '$GroupHomePageTitlespaced' => 'FmtGroupHome($pn,$group,$var)', + '$GroupHomePageUrl' => 'FmtGroupHome($pn,$group,$var)', ); $SaveProperties = array('title', 'description', 'keywords'); $PageTextVarPatterns = array( @@ -176,6 +177,7 @@ $PageTextVarPatterns = array( $WikiTitle = 'PmWiki'; $Charset = 'ISO-8859-1'; +$HTMLHeaderFmt['Content-type'] = ''; $HTTPHeaders = array( "Expires: Tue, 01 Jan 2002 00:00:00 GMT", "Cache-Control: no-store, no-cache, must-revalidate", @@ -846,6 +848,11 @@ function PRCB($pat, $repl, $subj, $vars=null, $limit=-1, &$count=null, $flags=0) return preg_replace_callback($pat, $repl, $subj, $limit, $count, $flags); return preg_replace_callback($pat, $repl, $subj, $limit, $count); } +function PRI($glue, $array) { ## Recursive implode + $out = array(); + foreach($array as $v) $out[] = is_array($v)? PRI($glue, $v) : $v; + return implode($glue, $out); +} ## This is a replacement for json_encode+PHSC, but only for arrays that ## are used by the PmWiki core. It may or may not work in other cases. @@ -1244,7 +1251,7 @@ function MatchNames($list, $pat, $caseinsensitive = true) { } return $list; } - + ## ResolvePageName "normalizes" a pagename based on the current ## settings of $DefaultPage and $PagePathFmt. It's normally used ## during initialization to fix up any missing or partial pagenames. @@ -1500,6 +1507,7 @@ function FmtGroupHome($pn,$group,$var) { $gpn = MakePageName($pn, "$group."); $pv = substr($var, 14); if (!$pv) return $gpn; + if ($pv == 'Url') $pv = 'PageUrl'; return PageVar($gpn, "\$$pv"); } @@ -1507,6 +1515,7 @@ function FmtGroupHome($pn,$group,$var) { ## {$$key} in $text with $vars['key']. function FmtTemplateVars($text, $vars, $pagename = NULL) { global $FmtPV, $EnableUndefinedTemplateVars; + $text = strval($text); if ($pagename) { $pat = implode('|', array_map('preg_quote', array_keys($FmtPV))); $pprc = new PPRC($pagename); @@ -1514,8 +1523,8 @@ function FmtTemplateVars($text, $vars, $pagename = NULL) { array($pprc, 'pagevar'), $text); } foreach(preg_grep('/^[\\w$]/', array_keys($vars)) as $k) - if (!is_array($vars[$k])) - $text = str_replace("{\$\$$k}", @$vars[$k], $text); + if (!is_array($vars[$k]) && $text) + $text = str_replace("{\$\$$k}", strval(@$vars[$k]), $text); if (! IsEnabled($EnableUndefinedTemplateVars, 0)) $text = preg_replace("/\\{\\$\\$\\w+\\}/", '', $text); return $text; @@ -1902,14 +1911,14 @@ function ProcessPrintFmt($pagename,$x) { function PostPrintFmt($pagename,$fmt) { global $EnablePrePrintFmt, $KeepToken, $HTTPHeaders, $FmtV; if (is_array($fmt)) { - foreach($fmt as $f) PostPrintFmt($pagename,$f); + foreach($fmt as $f) PostPrintFmt($pagename,$f); return; } if ($fmt == 'headers:') { foreach($HTTPHeaders as $h) (@$sent++) ? @header($h) : header($h); return; } - $fmt = strval($fmt); + if (!is_string($fmt)) $fmt = strval($fmt); $preprint = IsEnabled($EnablePrePrintFmt, 1); if ($preprint && substr($fmt, 0, 4) == "$KeepToken$KeepToken") { @@ -2197,7 +2206,7 @@ function FormatTableRow($x, $sep = '\\|\\|') { static $rowcount; SDV($TableCellAlignFmt, " align='%s'"); - if (IsEnabled($EnableSimpleTableRowspan, 0)) { + if (IsEnabled($EnableSimpleTableRowspan, 1)) { $x = preg_replace("/\\|\\|__+(?=\\|\\|)/", '||', $x); $x = preg_replace("/\\|\\|\\^\\^+(?=\\|\\|)/", '', $x); } @@ -2207,7 +2216,7 @@ function FormatTableRow($x, $sep = '\\|\\|') { if ($td[$i]=='') continue; $FmtV['$TableCellCount'] = $i; $attr = FmtPageName(@$TableCellAttrFmt, ''); - if (IsEnabled($EnableSimpleTableRowspan, 0)) { + if (IsEnabled($EnableSimpleTableRowspan, 1)) { if (preg_match('/(\\+\\++)\\s*$/', $td[$i], $rspn)) { $td[$i] = preg_replace('/\\+\\++(\\s*)$/', '$1', $td[$i]); $attr .= " rowspan='".strlen($rspn[1])."'"; @@ -2596,7 +2605,7 @@ function UpdatePage(&$pagename, &$page, &$new, $fnlist = NULL) { # EditTemplate allows a site administrator to pre-populate new pages # with the contents of another page. function EditTemplate($pagename, &$page, &$new) { - global $EditTemplatesFmt, $ROEPatterns, $TROEPatterns; + global $EditTemplatesFmt, $TROEPatterns; if (@$new['text'] > '') return; $rqt = @$_REQUEST['template']; if ($rqt && PageExists($rqt)) { |