Exemple #1
0
function FmtPageList($fmt, $pagename, $opt)
{
    global $GroupPattern, $FmtV, $FPLFunctions;
    # if (isset($_REQUEST['q']) && $_REQUEST['q']=='') $_REQUEST['q']="''";
    $rq = htmlspecialchars(stripmagic(@$_REQUEST['q']), ENT_NOQUOTES);
    $FmtV['$Needle'] = $opt['o'] . ' ' . $rq;
    if (preg_match("!^({$GroupPattern}(\\|{$GroupPattern})*)?/!i", $rq, $match)) {
        $opt['group'] = @$match[1];
        $rq = substr($rq, strlen(@$match[1]) + 1);
    }
    $opt = array_merge($opt, ParseArgs($opt['o'] . ' ' . $rq), @$_REQUEST);
    if (@($opt['req'] && !$opt['-'] && !$opt[''] && !$opt['+'] && !$opt['q'])) {
        return;
    }
    $GLOBALS['SearchIncl'] = array_merge((array) @$opt[''], (array) @$opt['+']);
    $GLOBALS['SearchExcl'] = (array) @$opt['-'];
    $GLOBALS['SearchGroup'] = @$opt['group'];
    $matches = array();
    $fmtfn = @$FPLFunctions[$opt['fmt']];
    if (!function_exists($fmtfn)) {
        $fmtfn = 'FPLByGroup';
    }
    $out = $fmtfn($pagename, $matches, $opt);
    $FmtV['$MatchCount'] = count($matches);
    if ($fmt != '$MatchList') {
        $FmtV['$MatchList'] = $out;
        $out = FmtPageName($fmt, $pagename);
    }
    if ($out[0] == '<') {
        return '<div>' . Keep($out) . '</div>';
    }
    PRR();
    return $out;
}
Exemple #2
0
function InputMarkup($pagename, $type, $args)
{
    global $InputTags, $InputAttrs, $InputValues, $FmtV;
    if (!@$InputTags[$type]) {
        return "(:input {$type} {$args}:)";
    }
    $opt = array_merge($InputTags[$type], ParseArgs($args));
    $args = @$opt[':args'];
    if (!$args) {
        $args = array('name', 'value');
    }
    while (count(@$opt['']) > 0 && count($args) > 0) {
        $opt[array_shift($args)] = array_shift($opt['']);
    }
    foreach ((array) @$opt[''] as $a) {
        if (!isset($opt[$a])) {
            $opt[$a] = $a;
        }
    }
    if (!isset($opt['value']) && isset($InputValues[@$opt['name']])) {
        $opt['value'] = $InputValues[$opt['name']];
    }
    $attr = array();
    foreach ($InputAttrs as $a) {
        if (!isset($opt[$a])) {
            continue;
        }
        $attr[] = "{$a}='" . str_replace("'", '&#39;', $opt[$a]) . "'";
    }
    $FmtV['$InputFormArgs'] = implode(' ', $attr);
    $out = FmtPageName($opt[':html'], $pagename);
    return preg_replace('/<(\\w+\\s)(.*)$/es', "'<\$1'.Keep(PSS('\$2'))", $out);
}
function NewPageBox($pagename, $opt)
{
    global $ScriptUrl;
    $defaults = array('base' => $pagename, 'template' => '', 'button' => 'left', 'value' => '', 'label' => FmtPageName(' $[Create a new page called:] ', $pagename));
    $opt = array_merge($defaults, ParseArgs($opt));
    $buttonHTML = "<input class='inputbutton newpagebutton' type='submit' value='{$opt['label']}' />";
    return "<form class='newpage' action='{$ScriptUrl}' method='post'>\r\n     <input type='hidden' name='n' value='{$pagename}' />\r\n     <input type='hidden' name='action' value='new' />\r\n     <input type='hidden' name='base' value='{$opt['base']}' />\r\n     <input type='hidden' name='template' value='{$opt['template']}' />" . ($opt['button'] == "left" ? $buttonHTML : "") . "<input class='inputbox newpagetext' type='text' name='name' size='16' value=' {$opt['value']} '\r\n     onfocus=\"if(this.value='{$opt['value']}') {this.value=''}\"\r\n     onblur=\"if(this.value=='') {this.value='{$opt['value']}'}\" />" . ($opt['button'] == "right" ? $buttonHTML : "") . "</form>";
}
function BDropdownMenu($inp)
{
    $defaults = array('title' => 'Dropdown');
    $args = array_merge($defaults, ParseArgs($inp));
    $inline_code_begin = "<li class='dropdown'><a href='#' class='dropdown-toggle' data-toggle='dropdown'>" . $args['title'] . "<b class='caret'></b></a><ul class='dropdown-menu'>";
    $inline_code_end = "</ul></li>";
    // if we're using MakePageList, we have to pass ALL the opts along...
    // in this case, named $args
    $group_list = BGetWikiPages($args);
    $formatted_list = BBuildGroupList($group_list);
    return Keep($inline_code_begin . $formatted_list . $inline_code_end);
}
Exemple #5
0
function openlayers($args)
{
    global $HTMLHeaderFmt, $HTMLFooterFmt;
    $params = ParseArgs($args);
    $slippymap_default = array('width' => 500, 'height' => 400, 'lat' => '49.4312', 'lon' => '-2.364', 'zoom' => 14);
    $width = $params['width'] ? $params['width'] : $slippymap_default['width'];
    $height = $params['height'] ? $params['height'] : $slippymap_default['height'];
    $lat = $params['lat'] ? $params['lat'] : $slippymap_default['lat'];
    $lon = $params['lon'] ? $params['lon'] : $slippymap_default['lon'];
    $zoom = $params['zoom'] ? $params['zoom'] : $slippymap_default['zoom'];
    $HTMLHeaderFmt['slippymap'] = "\r\n" . '<script src="http://localhost/pmwiki-2.2.0-beta65/pub/js/OpenLayers/OpenLayers.js"></script>' . "\r\n" . '<script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>' . "\r\n" . '<script type="text/javascript">' . "\r\n" . '     var lat = ' . $lat . ";\r\n" . '     var lon = ' . $lon . ";\r\n" . '     var zoom = ' . $zoom . ";\r\n" . '     var map; //complex object of type OpenLayers.Map' . "\r\n" . '     //"map" Objekt initialisieren' . "\r\n" . '     function slippymap_init() {' . "\r\n" . '         map = new OpenLayers.Map ("map", {' . "\r\n" . '             controls:[' . "\r\n" . '                 new OpenLayers.Control.Navigation(),' . "\r\n" . '                 new OpenLayers.Control.PanZoomBar(),' . "\r\n" . '                 new OpenLayers.Control.Attribution()],' . "\r\n" . '             maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),' . "\r\n" . '             maxResolution: 156543.0399,' . "\r\n" . '             numZoomLevels: 19,' . "\r\n" . '             units: \'m\',' . "\r\n" . '             projection: new OpenLayers.Projection("EPSG:900913"),' . "\r\n" . '             displayProjection: new OpenLayers.Projection("EPSG:4326")' . "\r\n" . '         } );' . "\r\n" . '         // weitere Basiskarten: OpenLayers.Layer.OSM.Mapnik, OpenLayers.Layer.OSM.Maplint und OpenLayers.Layer.OSM.CycleMap' . "\r\n" . '         layerTilesAtHome = new OpenLayers.Layer.OSM.Osmarender("Osmarender");' . "\r\n" . '         map.addLayer(layerTilesAtHome);' . "\r\n" . '         var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());' . "\r\n" . '         map.setCenter (lonLat, zoom);' . "\r\n" . '     }' . "\r\n" . '</script>' . "\r\n" . "\r\n";
    $HTMLFooterFmt = '<script type="text/javascript">' . "\n\t" . 'slippymap_init();' . "\n" . '</script>';
    return '<div style="width: ' . $width . 'px; height:' . $height . 'px; border-style:solid; border-width:1px; border-color:lightgrey;" id="map">' . "\n\t" . '<noscript>' . "\n\t\t" . 'Die Nutzung der Karte setzt die Aktivierung von JavaScript voraus.' . "\n\t" . '</noscript>' . "\n" . '</div>';
}
Exemple #6
0
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);
    while (preg_match('/\\((\\w+)(\\s[^()]*)?\\)/', $expr, $match)) {
        list($repl, $func, $params) = $match;
        $code = @$MarkupExpr[$func];
        ##  if not a valid function, save this string as-is and exit
        if (!$code) {
            break;
        }
        ##  if the code uses '$params', we just evaluate directly
        if (strpos($code, '$params') !== false) {
            $out = eval("return ({$code});");
            if ($expr == $repl) {
                $expr = $out;
                break;
            }
            $expr = str_replace($repl, $out, $expr);
            continue;
        }
        ##  otherwise, we parse arguments into $args before evaluating
        $argp = ParseArgs($params);
        $x = $argp['#'];
        $args = array();
        while ($x) {
            list($k, $v) = array_splice($x, 0, 2);
            if ($k == '' || $k == '+' || $k == '-') {
                $args[] = $k . preg_replace($rpat, $rrep, $v);
            }
        }
        ##  fix any quoted arguments
        foreach ($argp as $k => $v) {
            if (!is_array($v)) {
                $argp[$k] = preg_replace($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);
}
Exemple #7
0
function FmtUploadList2($pagename, $args)
{
    global $UploadDir, $UploadPrefixFmt, $UploadUrlFmt, $EnableUploadOverwrite, $FileListTimeFmt, $EnableDirectDownload, $HTMLStylesFmt, $FarmPubDirUrl;
    $HTMLStylesFmt['filelist'] = "\r\n   table.filelist { padding:0; margin:0; border-spacing:0; }\r\n   table.filelist td { padding:3px 0 0 0; margin:0; }\r\n   .filelist a { text-decoration:underline; }\r\n   .dotted  { background:url({$FarmPubDirUrl}/images/dot3.png) repeat-x bottom; }\r\n   .nodots { background:#feffff; }\r\n   ";
    $opt = ParseArgs($args);
    if (@$opt[''][0]) {
        $pagename = MakePageName($pagename, $opt[''][0]);
    }
    if (@$opt['re']) {
        $matchre = '/^(' . $opt['re'] . ')$/i';
    }
    if (@$opt['ext']) {
        $matchext = '/\\.(' . implode('|', preg_split('/\\W+/', $opt['ext'], -1, PREG_SPLIT_NO_EMPTY)) . ')$/i';
    }
    $uploaddir = FmtPageName("{$UploadDir}{$UploadPrefixFmt}", $pagename);
    $uploadurl = FmtPageName(IsEnabled($EnableDirectDownload, 1) ? "{$UploadUrlFmt}{$UploadPrefixFmt}/" : "\$PageUrl?action=download&amp;upname=", $pagename);
    $dirp = @opendir($uploaddir);
    if (!$dirp) {
        return '';
    }
    $filelist = array();
    while (($file = readdir($dirp)) !== false) {
        if ($file[0] == '.') {
            continue;
        }
        if (@$matchext && !preg_match(@$matchext, $file)) {
            continue;
        }
        if (@$matchre && !preg_match(@$matchre, $file)) {
            continue;
        }
        $filelist[$file] = $file;
    }
    closedir($dirp);
    $out = array();
    #asort($filelist);
    $overwrite = '';
    foreach ($filelist as $file => $x) {
        $name = PUE("{$uploadurl}{$file}");
        $stat = stat("{$uploaddir}/{$file}");
        if ($EnableUploadOverwrite) {
            $overwrite = FmtPageName("<a class='createlink'\r\n        href='\$PageUrl?action=upload&amp;upname={$file}'>&nbsp;&Delta;</a>", $pagename);
        }
        $out[] = "<tr><td class='dotted'> <a href='{$name}'>{$file}</a>{$overwrite} &nbsp;&nbsp;</td>" . "<td class='dotted' align=right><span class='nodots'>" . number_format($stat['size'] / 1024) . "Kb</span></td>" . "<td>&nbsp;&nbsp;&nbsp;" . strftime($FileListTimeFmt, $stat['mtime']) . "</td>" . "<tr>";
    }
    return implode("\n", $out);
}
Exemple #8
0
function BootstrapButton($args)
{
    $opt = ParseArgs($args);
    // expect link, class
    // TODO: test for options
    // TODO: handle alt params
    // TODO: handle rel=nofollow per pmwiki settings
    // what about other PmWiki shortcut-type things?
    // like... [[PmWiki/basic editing|+]]%apply=link class="btn"%
    $target = $opt['link'];
    $text = $opt['text'] ? $opt['text'] : $target;
    // if text not provided, default to the link
    $class = $opt['class'];
    $l = '<a href="%s" class="%s">%s</a>';
    $linkf = sprintf($l, $target, $class, $text);
    return $linkf;
}
Exemple #9
0
function HandyTocProcessMarkup($pagename, $argstr)
{
    global $HandyTocEndAt, $HandyTocStartAt, $HandyTocIgnoreSoleH1;
    global $HTMLFooterFmt;
    $args = ParseArgs($argstr);
    $title = $args[''] ? implode(' ', $args['']) : '';
    $start = $args['start'] ? $args['start'] : $HandyTocStartAt;
    $end = $args['end'] ? $args['end'] : $HandyTocEndAt;
    $ignoreh1 = $args['ignoreh1'] ? $args['ignoreh1'] : $HandyTocIgnoreSoleH1;
    $class = $args['class'] ? ' class="' . $args['class'] . '" ' : '';
    $HTMLFooterFmt['handytoc'] = " \n  <script language='javascript' type='text/javascript'\n     src='\$HandyTocPubDirUrl/handytoc.js'></script>\n  <script language='javascript' type='text/javascript'>TOC.set_args({start:{$start}, end:{$end}, ignoreh1:{$ignoreh1}});</script>\n";
    if ($title) {
        return Keep("<div {$class}id='htoc'><h3>{$title}</h3></div>");
    } else {
        return Keep("<div {$class}id='htoc'></div>");
    }
}
Exemple #10
0
function galleria($args = false)
{
    global $galleria, $galleria_unsafe_options, $galleria_safe_mode;
    $args = ParseArgs($args);
    unset($args['#']);
    if ($galleria_safe_mode) {
        #remove unsafe options from markup args -- only allow from config.php
        foreach ($galleria_unsafe_options as $v) {
            unset($args[$v]);
        }
    }
    $o = array_merge($galleria, $args);
    return '
<script type="text/javascript">
$(document).ready(function(){
	$("' . $o['list'] . '").galleria(' . galleria_json_encode($o, false, $galleria_unsafe_options) . ');
});
</script>';
}
Exemple #11
0
function InputMarkup($pagename, $type, $args) {
  global $InputTags, $InputAttrs, $InputValues, $FmtV;
  if (!@$InputTags[$type]) return "(:input $type $args:)";
  $opt = array_merge($InputTags[$type], ParseArgs($args));
  $args = @$opt[':args'];
  if (!$args) $args = array('name', 'value');
  while (count(@$opt['']) > 0 && count($args) > 0) 
    $opt[array_shift($args)] = array_shift($opt['']);
  foreach ((array)@$opt[''] as $a) 
    if (!isset($opt[$a])) $opt[$a] = $a;
  if (!isset($opt['value']) && isset($InputValues[@$opt['name']])) 
    $opt['value'] = $InputValues[$opt['name']];
  $attr = array();
  foreach ($InputAttrs as $a) {
    if (!isset($opt[$a])) continue;
    $attr[] = "$a='".str_replace("'", '&#39;', $opt[$a])."'";
  }
  $FmtV['$InputFormArgs'] = implode(' ', $attr);
  $out = FmtPageName($opt[':html'], $pagename);
  return Keep($out);
}
Exemple #12
0
function MarkupMarkup($pagename, $text, $opt = '')
{
    $MarkupMarkupOpt = array('class' => 'vert');
    $opt = array_merge($MarkupMarkupOpt, ParseArgs($opt));
    $html = MarkupToHTML($pagename, $text, array('escape' => 0));
    if (@$opt['caption']) {
        $caption = str_replace("'", '&#039;', "<caption>{$opt['caption']}</caption>");
    }
    $class = preg_replace('/[^-\\s\\w]+/', ' ', @$opt['class']);
    if (strpos($class, 'horiz') !== false) {
        $sep = '';
        $pretext = wordwrap($text, 40);
    } else {
        $sep = '</tr><tr>';
        $pretext = wordwrap($text, 75);
    }
    return Keep("<table class='markup {$class}' align='center'>{$caption}\n      <tr><td class='markup1' valign='top'><pre>{$pretext}</pre></td>{$sep}<td \n        class='markup2' valign='top'>{$html}</td></tr></table>");
}
Exemple #13
0
function FmtUploadList($pagename, $args)
{
    global $UploadDir, $UploadPrefixFmt, $UploadUrlFmt, $EnableUploadOverwrite, $TimeFmt, $EnableDirectDownload;
    $opt = ParseArgs($args);
    if (@$opt[''][0]) {
        $pagename = MakePageName($pagename, $opt[''][0]);
    }
    if (@$opt['ext']) {
        $matchext = '/\\.(' . implode('|', preg_split('/\\W+/', $opt['ext'], -1, PREG_SPLIT_NO_EMPTY)) . ')$/i';
    }
    $uploaddir = FmtPageName("{$UploadDir}{$UploadPrefixFmt}", $pagename);
    $uploadurl = FmtPageName(IsEnabled($EnableDirectDownload, 1) ? "{$UploadUrlFmt}{$UploadPrefixFmt}/" : "\$PageUrl?action=download&amp;upname=", $pagename);
    $dirp = @opendir($uploaddir);
    if (!$dirp) {
        return '';
    }
    $filelist = array();
    while (($file = readdir($dirp)) !== false) {
        if ($file[0] == '.') {
            continue;
        }
        if (@$matchext && !preg_match(@$matchext, $file)) {
            continue;
        }
        $filelist[$file] = $file;
    }
    closedir($dirp);
    $out = array();
    asort($filelist);
    $overwrite = '';
    foreach ($filelist as $file => $x) {
        $name = PUE("{$uploadurl}{$file}");
        $stat = stat("{$uploaddir}/{$file}");
        if ($EnableUploadOverwrite) {
            $overwrite = FmtPageName("<a class='createlink'\n        href='\$PageUrl?action=upload&amp;upname={$file}'>&nbsp;&Delta;</a>", $pagename);
        }
        $out[] = "<li> <a href='{$name}'>{$file}</a>{$overwrite} ... " . number_format($stat['size']) . " bytes ... " . strftime($TimeFmt, $stat['mtime']) . "</li>";
    }
    return implode("\n", $out);
}
Exemple #14
0
function NotifyUpdate($pagename, $dir = '')
{
    global $NotifyList, $NotifyListPageFmt, $NotifyFile, $IsPagePosted, $FmtV, $NotifyTimeFmt, $NotifyItemFmt, $SearchPatterns, $NotifySquelch, $NotifyDelay, $Now, $NotifySubjectFmt, $NotifyBodyFmt, $NotifyHeaders, $NotifyParameters;
    $abort = ignore_user_abort(true);
    if ($dir) {
        flush();
        chdir($dir);
    }
    $GLOBALS['EnableRedirect'] = 0;
    ##   Read in the current notify configuration
    $pn = FmtPageName($NotifyListPageFmt, $pagename);
    $npage = ReadPage($pn, READPAGE_CURRENT);
    preg_match_all('/^[\\s*:#->]*(notify[:=].*)/m', $npage['text'], $nlist);
    $nlist = array_merge((array) @$NotifyList, (array) @$nlist[1]);
    if (!$nlist) {
        return;
    }
    ##   make sure other processes are locked out
    Lock(2);
    ##   let's load the current .notifylist table
    $nfile = FmtPageName($NotifyFile, $pagename);
    $nfp = @fopen($nfile, 'r');
    if ($nfp) {
        ##   get our current squelch and delay timestamps
        clearstatcache();
        $sz = filesize($nfile);
        list($nextevent, $firstpost) = explode(' ', rtrim(fgets($nfp, $sz)));
        ##   restore our notify array
        $notify = unserialize(fgets($nfp, $sz));
        fclose($nfp);
    }
    if (!is_array($notify)) {
        $notify = array();
    }
    ##   if this is for a newly posted page, get its information
    if ($IsPagePosted) {
        $page = ReadPage($pagename, READPAGE_CURRENT);
        $FmtV['$PostTime'] = strftime($NotifyTimeFmt, $Now);
        $item = urlencode(FmtPageName($NotifyItemFmt, $pagename));
        if ($firstpost < 1) {
            $firstpost = $Now;
        }
    }
    foreach ($nlist as $n) {
        $opt = ParseArgs($n);
        $mailto = preg_split('/[\\s,]+/', $opt['notify']);
        if (!$mailto) {
            continue;
        }
        if ($opt['squelch']) {
            foreach ($mailto as $m) {
                $squelch[$m] = $opt['squelch'];
            }
        }
        if (!$IsPagePosted) {
            continue;
        }
        if ($opt['link']) {
            $link = MakePageName($pagename, $opt['link']);
            if (!preg_match("/(^|,){$link}(,|\$)/i", $page['targets'])) {
                continue;
            }
        }
        $pats = @(array) $SearchPatterns[$opt['list']];
        if ($opt['group']) {
            $pats[] = FixGlob($opt['group'], '$1$2.*');
        }
        if ($opt['name']) {
            $pats[] = FixGlob($opt['name'], '$1*.$2');
        }
        if ($pats && !MatchPageNames($pagename, $pats)) {
            continue;
        }
        if ($opt['trail']) {
            $trail = ReadTrail($pagename, $opt['trail']);
            for ($i = 0; $i < count($trail); $i++) {
                if ($trail[$i]['pagename'] == $pagename) {
                    break;
                }
            }
            if ($i >= count($trail)) {
                continue;
            }
        }
        foreach ($mailto as $m) {
            $notify[$m][] = $item;
        }
    }
    $nnow = time();
    if ($nnow < $firstpost + $NotifyDelay) {
        $nextevent = $firstpost + $NotifyDelay;
    } else {
        $firstpost = 0;
        $nextevent = $nnow + 86400;
        $mailto = array_keys($notify);
        $subject = FmtPageName($NotifySubjectFmt, $pagename);
        $body = FmtPageName($NotifyBodyFmt, $pagename);
        foreach ($mailto as $m) {
            $msquelch = @$notify[$m]['lastmail'] + (@$squelch[$m] ? $squelch[$m] : $NotifySquelch);
            if ($nnow < $msquelch) {
                if ($msquelch < $nextevent && count($notify[$m]) > 1) {
                    $nextevent = $msquelch;
                }
                continue;
            }
            unset($notify[$m]['lastmail']);
            if (!$notify[$m]) {
                unset($notify[$m]);
                continue;
            }
            $mbody = str_replace('$NotifyItems', urldecode(implode("\n", $notify[$m])), $body);
            if ($NotifyParameters) {
                mail($m, $subject, $mbody, $NotifyHeaders, $NotifyParameters);
            } else {
                mail($m, $subject, $mbody, $NotifyHeaders);
            }
            $notify[$m] = array('lastmail' => $nnow);
        }
    }
    ##   save the updated notify status
    $nfp = @fopen($nfile, "w");
    if ($nfp) {
        fputs($nfp, "{$nextevent} {$firstpost}\n");
        fputs($nfp, serialize($notify) . "\n");
        fclose($nfp);
    }
    Lock(0);
    return true;
}
Exemple #15
0
function FPLTemplate($pagename, &$matches, $opt)
{
    global $Cursor, $FPLTemplatePageFmt, $RASPageName, $PageListArgPattern;
    SDV($FPLTemplatePageFmt, array('{$FullName}', '{$SiteGroup}.LocalTemplates', '{$SiteGroup}.PageListTemplates'));
    StopWatch("FPLTemplate begin");
    $template = @$opt['template'];
    if (!$template) {
        $template = @$opt['fmt'];
    }
    $ttext = RetrieveAuthSection($pagename, $template, $FPLTemplatePageFmt);
    $ttext = PVSE(Qualify($RASPageName, $ttext));
    ##  save any escapes
    $ttext = MarkupEscape($ttext);
    ##  remove any anchor markups to avoid duplications
    $ttext = preg_replace('/\\[\\[#[A-Za-z][-.:\\w]*\\]\\]/', '', $ttext);
    ##  extract portions of template
    $tparts = preg_split('/\\(:(template)\\s+(\\w+)\\s*(.*?):\\)/i', $ttext, -1, PREG_SPLIT_DELIM_CAPTURE);
    ##  handle (:template defaults:)
    $i = 0;
    while ($i < count($tparts)) {
        if ($tparts[$i] != 'template') {
            $i++;
            continue;
        }
        if ($tparts[$i + 1] != 'defaults' && $tparts[$i + 1] != 'default') {
            $i += 4;
            continue;
        }
        $opt = array_merge(ParseArgs($tparts[$i + 2], $PageListArgPattern), $opt);
        array_splice($tparts, $i, 3);
    }
    SDVA($opt, array('class' => 'fpltemplate', 'wrap' => 'div'));
    ##  get the list of pages
    $matches = array_values(MakePageList($pagename, $opt, 0));
    ##  extract page subset according to 'count=' parameter
    if (@$opt['count']) {
        list($r0, $r1) = CalcRange($opt['count'], count($matches));
        if ($r1 < $r0) {
            $matches = array_reverse(array_slice($matches, $r1 - 1, $r0 - $r1 + 1));
        } else {
            $matches = array_slice($matches, $r0 - 1, $r1 - $r0 + 1);
        }
    }
    $savecursor = $Cursor;
    $pagecount = 0;
    $groupcount = 0;
    $grouppagecount = 0;
    $pseudovars = array('{$$PageCount}' => &$pagecount, '{$$GroupCount}' => &$groupcount, '{$$GroupPageCount}' => &$grouppagecount);
    foreach (preg_grep('/^[\\w$]/', array_keys($opt)) as $k) {
        if (!is_array($opt[$k])) {
            $pseudovars["{\$\${$k}}"] = htmlspecialchars($opt[$k], ENT_NOQUOTES);
        }
    }
    $vk = array_keys($pseudovars);
    $vv = array_values($pseudovars);
    $lgroup = '';
    $out = '';
    foreach ($matches as $i => $pn) {
        $group = PageVar($pn, '$Group');
        if ($group != $lgroup) {
            $groupcount++;
            $grouppagecount = 0;
            $lgroup = $group;
        }
        $grouppagecount++;
        $pagecount++;
        $t = 0;
        while ($t < count($tparts)) {
            if ($tparts[$t] != 'template') {
                $item = $tparts[$t];
                $t++;
            } else {
                list($when, $control, $item) = array_slice($tparts, $t + 1, 3);
                $t += 4;
                if (!$control) {
                    if ($when == 'first' && $i != 0) {
                        continue;
                    }
                    if ($when == 'last' && $i != count($matches) - 1) {
                        continue;
                    }
                } else {
                    if ($when == 'first' || !isset($last[$t])) {
                        $Cursor['<'] = $Cursor['&lt;'] = (string) @$matches[$i - 1];
                        $Cursor['='] = $pn;
                        $Cursor['>'] = $Cursor['&gt;'] = (string) @$matches[$i + 1];
                        $curr = str_replace($vk, $vv, $control);
                        $curr = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PageVar(\$pn, '\$2', '\$1')", $curr);
                        if ($when == 'first' && $i > 0 && $last[$t] == $curr) {
                            continue;
                        }
                        $last[$t] = $curr;
                    }
                    if ($when == 'last') {
                        $Cursor['<'] = $Cursor['&lt;'] = $pn;
                        $Cursor['='] = (string) @$matches[$i + 1];
                        $Cursor['>'] = $Cursor['&gt;'] = (string) @$matches[$i + 2];
                        $next = str_replace($vk, $vv, $control);
                        $next = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PageVar(\$pn, '\$2', '\$1')", $next);
                        if ($next == $last[$t] && $i != count($matches) - 1) {
                            continue;
                        }
                        $last[$t] = $next;
                    }
                }
            }
            $Cursor['<'] = $Cursor['&lt;'] = (string) @$matches[$i - 1];
            $Cursor['='] = $pn;
            $Cursor['>'] = $Cursor['&gt;'] = (string) @$matches[$i + 1];
            $item = str_replace($vk, $vv, $item);
            $item = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PVSE(PageVar(\$pn, '\$2', '\$1'))", $item);
            $out .= MarkupRestore($item);
        }
    }
    $class = preg_replace('/[^-a-zA-Z0-9\\x80-\\xff]/', ' ', @$opt['class']);
    if ($class) {
        $class = " class='{$class}'";
    }
    $wrap = @$opt['wrap'];
    if ($wrap != 'inline') {
        $out = MarkupToHTML($pagename, $out, array('escape' => 0, 'redirect' => 1));
        if ($wrap != 'none') {
            $out = "<div{$class}>{$out}</div>";
        }
    }
    $Cursor = $savecursor;
    StopWatch("FPLTemplate end");
    return $out;
}
Exemple #16
0
function InputActionForm($pagename, $type, $args) {
  global $InputAttrs;
  $args = ParseArgs($args);
  if (@$args['pagename']) $pagename = $args['pagename'];
  $opt = NULL;
  $html = InputToHTML($pagename, $type, $args, $opt);
  foreach(preg_grep('/^[\\w$]/', array_keys($args)) as $k) {
    if (is_array($args[$k]) || in_array($k, $InputAttrs)) continue;
    if ($k == 'n' || $k == 'pagename') continue;
    $html .= "<input type='hidden' name='$k' value='{$args[$k]}' />";
  }
  return Keep($html);
}
Exemple #17
0
function RedirectMarkup($pagename, $opt)
{
    $k = Keep("(:redirect {$opt}:)");
    global $MarkupFrame, $EnableRedirectQuiet;
    if (!@$MarkupFrame[0]['redirect']) {
        return $k;
    }
    $opt = ParseArgs($opt);
    $to = @$opt['to'];
    if (!$to) {
        $to = @$opt[''][0];
    }
    if (!$to) {
        return $k;
    }
    if (preg_match('/^([^#]+)(#[A-Za-z][-\\w]*)$/', $to, $match)) {
        $to = $match[1];
        $anchor = @$match[2];
    }
    $to = MakePageName($pagename, $to);
    if (!PageExists($to)) {
        return $k;
    }
    if ($to == $pagename) {
        return '';
    }
    if (@$opt['from'] && !MatchPageNames($pagename, FixGlob($opt['from'], '$1*.$2'))) {
        return '';
    }
    if (preg_match('/^30[1237]$/', @$opt['status'])) {
        header("HTTP/1.1 {$opt['status']}");
    }
    Redirect($to, "{\$PageUrl}" . (IsEnabled($EnableRedirectQuiet, 0) && IsEnabled($opt['quiet'], 0) ? '' : "?from={$pagename}") . $anchor);
    exit;
}
Exemple #18
0
function MarkupMarkup($pagename, $text, $opt = '') {
  global $MarkupWordwrapFunction;
  SDV($MarkupWordwrapFunction, 'wordwrap');
  $MarkupMarkupOpt = array('class' => 'vert');
  $opt = array_merge($MarkupMarkupOpt, ParseArgs($opt));
  $html = MarkupToHTML($pagename, $text, array('escape' => 0));
  if (@$opt['caption']) 
    $caption = str_replace("'", '&#039;', 
                           "<caption>{$opt['caption']}</caption>");
  $class = preg_replace('/[^-\\s\\w]+/', ' ', @$opt['class']);
  if (strpos($class, 'horiz') !== false) 
    { $sep = ''; $pretext = $MarkupWordwrapFunction($text, 40); } 
  else 
    { $sep = '</tr><tr>'; $pretext = $MarkupWordwrapFunction($text, 75); }
  return Keep(@"<table class='markup $class' align='center'>$caption
      <tr><td class='markup1' valign='top'><pre>$pretext</pre></td>$sep<td 
        class='markup2' valign='top'>$html</td></tr></table>");
}
Exemple #19
0
function InputMarkup($pagename, $type, $args)
{
    global $InputValues;
    if ($type == 'default') {
        $args = ParseArgs($args);
        $args[''] = (array) @$args[''];
        if (!isset($args['name'])) {
            $args['name'] = array_shift($args['']);
        }
        if (!isset($args['value'])) {
            $args['value'] = array_shift($args['']);
        }
        if (!isset($InputValues[$args['name']])) {
            $InputValues[$args['name']] = $args['value'];
        }
        return '';
    }
    return Keep(InputToHTML($pagename, $type, $args, $opt));
}
Exemple #20
0
/**
* Main routine called from markup within wiki pages
*/
function pmGallery($args)
{
    $o = array('album' => '', 'wikitarget' => '', 'startimg' => '', 'tag' => '', 'random' => '', 'width' => '', 'height' => '', 'imageurl' => '', 'query' => '', 'user' => '', 'thumbsize' => '', 'imagesize' => '', 'maxresults' => '', 'wrapper' => 'ul &gt; li', 'mode' => '', 'provider' => 'picasa', 'exif' => false, 'urlbase' => 'com', 'proxy' => '', 'authkey' => '', 'debug' => false, 'cachedir' => '', 'cachelife' => '7200');
    $o = array_merge($o, $GLOBALS['pmGallery']);
    // Allows the markup to be used in an (:include user="******":) where {$$user} might be blank, and thus passed to this routine as {$$user}.
    $o = array_merge($o, preg_grep('/(\\{\\$\\$.*\\}|^$)/', ParseArgs($args), PREG_GREP_INVERT));
    #find all elements NOT like {$$user} or empty
    $o = array_merge($o, $_GET);
    $o['wikitarget'] = empty($o['wikitarget']) ? $GLOBALS['pmGroup'] : $o['wikitarget'];
    // if the image url supplied, then show the image
    if (!empty($o['imageurl'])) {
        return '<div class="pmGalleryWrapperImage"><img src="http://' . $o['imageurl'] . '" /></div>';
    }
    require_once 'picasa.php5';
    $myPicasaParser = new picasaAPI();
    $myPicasaParser->updateOption('startimg', $o['startimg']);
    $myPicasaParser->updateOption('tag', $o['tag']);
    $myPicasaParser->updateOption('query', $o['query']);
    $myPicasaParser->updateOption('user', $o['user'], false);
    $myPicasaParser->updateOption('thumbsize', $o['thumbsize'], false);
    $myPicasaParser->updateOption('imagesize', $o['imagesize'], false);
    $myPicasaParser->updateOption('maxresults', $o['maxresults'], false);
    $myPicasaParser->updateOption('urlbase', $o['urlbase']);
    $myPicasaParser->updateOption('cachelife', $o['cachelife']);
    $myPicasaParser->updateOption('cachedir', $o['cachedir']);
    $myPicasaParser->updateOption('proxy', $o['proxy']);
    $myPicasaParser->updateOption('authkey', $o['authkey']);
    // parse out the HTML outter and inner wrappers "ul > li" or "div > div", etc
    // NB: html_entity_decode doesn't replace &gt; under RTF8
    $wrapper = explode('>', preg_replace('!&gt;!', '>', $o['wrapper']));
    $wrapper[0] = trim($wrapper[0]);
    $wrapper[1] = trim($wrapper[empty($wrapper[1]) ? 0 : 1]);
    // holds the album/image sequencing; used to allow randomizing. Format: $seqA[n]='album#:image#'
    $seqA = array();
    $albums = explode(',', $o['album']);
    $text = '';
    // displaying one or more album covers: either $o['display'] is 'cover' or no album specified
    $displayCover = $o['mode'] == 'cover' || empty($o['album']);
    $linkDirect = $o['mode'] == 'linkdirect';
    // handle procesing of more than one album, ie, (:pmGallery album=album1,album2 :)
    for ($albumN = 0; $displayCover && $albumN == 0 || !$displayCover && $albumN < count($albums) || count($albums) == 0; $albumN++) {
        $albumsA[$albumN] = $myPicasaParser->parseFeed($myPicasaParser->createFeedUrl($displayCover ? '' : $albums[$albumN], false));
        genArray($seqA, $albumN, count($albumsA[$albumN]['main']));
    }
    $seqN = empty($o['random']) || $o['random'] > count($seqA) ? count($seqA) : $o['random'];
    if (!empty($o['random'])) {
        randomizeArray($seqA, $seqN);
    }
    // loop through the sequential album/image or the randomized album/images
    for ($i = 0; $i < $seqN; $i++) {
        $x = explode(':', $seqA[$i]);
        $albumN = $x[0];
        $imageN = $x[1];
        $image = $albumsA[$albumN]['main'][$imageN];
        $entry = $albumsA[$albumN]['entry'][$imageN];
        $gphoto = $albumsA[$albumN]['gphoto'][$imageN];
        $exif = $albumsA[$albumN]['exif'][$imageN];
        //remove filename extension, otherwise PmWiki thinks it's a group.pagename format
        $image_title = explode('.', $image['title']);
        if ($displayCover && in_array($gphoto['name'], $albums) || !$displayCover) {
            $text .= '<' . $wrapper[1] . '>' . MakeLink($GLOBALS['pagename'], $linkDirect ? $image['largeSrc'] : (preg_match('!(\\.|\\/)!', $o['wikitarget']) ? $o['wikitarget'] : $image_title[0]), '<img src="' . $image['thumbSrc'] . '" ' . ($displayCover ? '' : 'height="' . (empty($o['height']) ? $entry['thumbnail_h'] : $o['height']) . '"' . 'width="' . (empty($o['width']) ? $entry['thumbnail_w'] : $o['width']) . '"') . ' />', '', '<a class="pmGallery' . ($displayCover ? 'Album' : 'Image') . 'Thumb" ' . "href='\$LinkUrl" . ($linkDirect ? '' : ($displayCover ? '?album=' . htmlentities($gphoto['name']) : '?imageurl=' . htmlentities(str_replace('http://', '', $image['largeSrc'])))) . "' " . (empty($entry['description']) ? '' : 'title="' . htmlentities($entry['description']) . '"') . ">\$LinkText" . '</a>') . '</' . $wrapper[1] . ">\n";
        }
    }
    return '<div class="pmGalleryWrapper">' . (empty($text) ? '' : '<' . $wrapper[0] . " class='pmGallery" . ($displayCover ? 'Album' : 'Image') . "List'>\n" . $text . '</' . $wrapper[0] . '>') . '</div>';
}
Exemple #21
0
function IncludeText($pagename, $inclspec)
{
    global $MaxIncludes, $InclCount;
    SDV($MaxIncludes, 50);
    $npat = '[[:alpha:]][-\\w]*';
    if ($InclCount++ >= $MaxIncludes) {
        return Keep($inclspec);
    }
    $args = ParseArgs($inclspec);
    while (count($args['#']) > 0) {
        $k = array_shift($args['#']);
        $v = array_shift($args['#']);
        if ($k == '') {
            preg_match('/^([^#\\s]*)(.*)$/', $v, $match);
            if ($match[1]) {
                # include a page
                if (isset($itext)) {
                    continue;
                }
                $iname = MakePageName($pagename, $match[1]);
                if (!PageExists($iname)) {
                    continue;
                }
                $ipage = RetrieveAuthPage($iname, 'read', false, READPAGE_CURRENT);
                $itext = @$ipage['text'];
            }
            if (preg_match("/^#({$npat})?(\\.\\.)?(#({$npat})?)?\$/", $match[2], $m)) {
                @(list($x, $aa, $dots, $b, $bb) = $m);
                if (!$dots && !$b) {
                    $bb = $npat;
                }
                if ($aa) {
                    $itext = preg_replace("/^.*?([^\n]*\\[\\[#{$aa}\\]\\])/s", '$1', $itext, 1);
                }
                if ($bb) {
                    $itext = preg_replace("/(.)[^\n]*\\[\\[#{$bb}\\]\\].*\$/s", '$1', $itext, 1);
                }
            }
            continue;
        }
        if (in_array($k, array('line', 'lines', 'para', 'paras'))) {
            preg_match('/^(\\d*)(\\.\\.(\\d*))?$/', $v, $match);
            @(list($x, $a, $dots, $b) = $match);
            $upat = $k[0] == 'p' ? ".*?(\n\\s*\n|\$)" : "[^\n]*\n";
            if (!$dots) {
                $b = $a;
                $a = 0;
            }
            if ($a > 0) {
                $a--;
            }
            $itext = preg_replace("/^(({$upat}){0,{$b}}).*\$/s", '$1', $itext, 1);
            $itext = preg_replace("/^({$upat}){0,{$a}}/s", '', $itext, 1);
            continue;
        }
    }
    return PVS(htmlspecialchars(@$itext, ENT_NOQUOTES));
}
Exemple #22
0
function FPLTemplateDefaults($pagename, $matches, &$opt, &$tparts){
  global $PageListArgPattern;
  $i = 0;
  while ($i < count($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]);
    $opt = array_merge(ParseArgs($ttext, $PageListArgPattern), $opt);
    array_splice($tparts, $i, 4);
  }
  SDVA($opt, array('class' => 'fpltemplate', 'wrap' => 'div'));
}
Exemple #23
0
function FPLTemplateDefaults($pagename, $matches, &$opt, &$tparts){
  global $PageListArgPattern;
  $i = 0;
  while ($i < count($tparts)) {
    if ($tparts[$i] != 'template') { $i++; continue; }
    if ($tparts[$i+2] != 'defaults' && $tparts[$i+2] != 'default') { $i+=5; continue; }
    $opt = array_merge(ParseArgs($tparts[$i+3], $PageListArgPattern), $opt);
    array_splice($tparts, $i, 4);
  }
  SDVA($opt, array('class' => 'fpltemplate', 'wrap' => 'div'));
}
Exemple #24
0
function GroupDropdownMenu($inp)
{
    $defaults = array('title' => 'Dropdown');
    $args = array_merge($defaults, ParseArgs($inp));
    $inline_code_begin = "<li class='dropdown'><a href='#' class='dropdown-toggle' data-toggle='dropdown'>" . $args['title'] . "<b class='caret'></b></a><ul class='dropdown-menu'>";
    $inline_code_end = "</ul></li>";
    // NOTE: if pattern not present, will default to ALL pages in wiki
    // hrm. "pattern" should probably change to "include"....
    $pattern = $args['pattern'];
    $exclude = $args['exclude'];
    // initial implementation is a naive string-check
    // TODO: improve exclude pattern
    // look at http://www.pmwiki.org/wiki/PmWiki/PageLists
    $group_list = GetWikiPages($pattern, $exclude);
    $formatted_list = BuildGroupList($group_list);
    return Keep($inline_code_begin . $formatted_list . $inline_code_end);
}
Exemple #25
0
function InputDefault($pagename, $type, $args)
{
    global $InputValues;
    $args = ParseArgs($args);
    $args[''] = (array) @$args[''];
    if (!isset($args['name'])) {
        $args['name'] = array_shift($args['']);
    }
    if (!isset($args['value'])) {
        $args['value'] = array_shift($args['']);
    }
    if (!isset($InputValues[$args['name']])) {
        $InputValues[$args['name']] = $args['value'];
    }
    return '';
}
Exemple #26
0
function ImagePageCondition($pagename, $arg)
{
    global $ThumbShoeImgExt;
    $arg = ParseArgs($arg);
    $check = @$arg[''][0];
    $imgRx = '(' . implode('|', $ThumbShoeImgExt) . ')';
    $name = PageVar($check, '$Name', $pagename);
    if (preg_match('/(.*)_' . $imgRx . '$/i', $name)) {
        return true;
    }
    return false;
}
Exemple #27
0
function RedirectMarkup($pagename, $opt) {
  $k = Keep("(:redirect $opt:)");
  global $MarkupFrame;
  if (!@$MarkupFrame[0]['redirect']) return $k;
  $opt = ParseArgs($opt);
  $to = @$opt['to']; if (!$to) $to = @$opt[''][0];
  if (!$to) return $k;
  if (preg_match('/^([^#]+)(#[A-Za-z][-\\w]*)$/', $to, $match)) 
    { $to = $match[1]; $anchor = $match[2]; }
  $to = MakePageName($pagename, $to);
  if (!PageExists($to)) return $k;
  if ($to == $pagename) return '';
  if (@$opt['from'] 
      && !MatchPageNames($pagename, FixGlob($opt['from'], '$1*.$2')))
    return '';
  if (preg_match('/^30[1237]$/', @$opt['status'])) 
     header("HTTP/1.1 {$opt['status']}");
  Redirect($to, "{\$PageUrl}?from=$pagename$anchor");
  exit();
}
Exemple #28
0
function pmcal($opts)
{
    global $pagename, $MaxIncludes, $HTMLHeaderFmt, $PmCalTextLinkMark, $PmCalIncludeTextLinkMark, $PmCalACALTextLinkMark, $PmCalSubIncludeTextLinkMark, $PmCalSubACALTextLinkMark, $PmCaltyear, $PmCaltmonth, $PmCaltday;
    //Initial PmWiki markup for textlinks
    SDV($PmCalTextLinkMark, '!!');
    SDV($PmCalIncludeTextLinkMark, '!!');
    SDV($PmCalACALTextLinkMark, '!!');
    SDV($PmCalSubIncludeTextLinkMark, $PmCalIncludeTextLinkMark);
    SDV($PmCalSubACALTextLinkMark, $PmCalACALTextLinkMark);
    // Determine this Group
    //
    $group = FmtPageName('$Group', $pagename);
    $name = FmtPageName('$Name', $pagename);
    // What is today?
    //
    // $tmonth = date("m");
    // $tyear = date("Y");
    // $tday = date("d");
    // Process markup arguments first
    //
    $defaults = array('year' => $PmCaltyear, 'month' => $PmCaltmonth, 'day' => $PmCaltday, 'alwaystoday' => 'false', 'acalfmt' => NULL, 'calfmt' => '%s', 'callinks' => 'true', 'caltype' => 'normal', 'cssprefix' => 'pmcal', 'dayofweektitlefmt' => '%a', 'expire' => 'false', 'overrides' => 'true', 'includes' => 'true', 'isodate' => 'false', 'lines' => NULL, 'locale' => NULL, 'monthsahead' => 0, 'monthsback' => 0, 'monthtitlefmt' => '%B %Y', 'navnext' => '&raquo;', 'navprev' => '&laquo;', 'onedate' => 'false', 'paras' => NULL, 'reverse' => 'false', 'stopafter' => 'false', 'textacalfmt' => NULL, 'textcalfmt' => '(%s)', 'textdatefmt' => '%x', 'textlinks' => 'true', 'weekstart' => 0, 'zebra' => 'true', 'acals' => NULL, 'cals' => NULL, 'dayofweektitle' => NULL, 'monthtitle' => NULL, 'styles' => NULL);
    // If name is of the format YYYYMMDD, then we'll
    // override the year, month, day defaults
    //
    // Hack for ACAL isn't perfect here... but ok.
    //
    if (preg_match("/([A0-9][C0-9][A0-9][L0-9])([01][0-9])([0-3][0-9])/", $name, $matches)) {
        $defaults['year'] = $matches[1];
        $defaults['month'] = $matches[2];
        $defaults['day'] = $matches[3];
    }
    $args = array_merge($defaults, ParseArgs($opts));
    $urladd = '';
    // Default to today if nothing supplied on the URL
    // line... ?month=12&day=25&year=2005 would be
    // Christmas 2005
    // URL GET vars override markup arguments
    //
    // With that said, might be useful to have a command line
    // augment the markup arguments in the case of foreign
    // calendar overlays... hmmm...  possible new feature.
    // calsplus=Calendar maybe...
    //
    // Build a url tack on of get vars when get vars are used.
    //
    $year = isset($_GET['year']) ? $_GET['year'] : $args['year'];
    $month = isset($_GET['month']) ? $_GET['month'] : $args['month'];
    $day = isset($_GET['day']) ? $_GET['day'] : $args['day'];
    // Sneaky fix for default monthtitlefmt for ACAL
    if ($year == 'ACAL') {
        $ayear = 'ACAL';
        $args['monthtitlefmt'] = '%B ACAL';
    }
    // Allows overrides=false in the :pmcal: markup to disallow
    // settings on the URL line.
    //
    $overrides = $args['overrides'];
    if ($overrides == 'false') {
        $_GET = NULL;
    }
    $acals = isset($_GET['acals']) ? explode(',', $_GET['acals']) : explode(',', $args['acals']);
    if (isset($_GET['acals'])) {
        $urladd .= "&amp;acals=" . urlencode($_GET['acals']);
    }
    $alwaystoday = isset($_GET['alwaystoday']) ? $_GET['alwaystoday'] : $args['alwaystoday'];
    if (isset($_GET['alwaystoday'])) {
        $urladd .= "&amp;alwaystoday=" . urlencode($_GET['alwaystoday']);
    }
    $acalfmt = isset($_GET['acalfmt']) ? $_GET['acalfmt'] : $args['acalfmt'];
    if (isset($_GET['acalfmt'])) {
        $urladd .= "&amp;acalfmt=" . urlencode($_GET['acalfmt']);
    }
    $calfmt = isset($_GET['calfmt']) ? $_GET['calfmt'] : $args['calfmt'];
    if (isset($_GET['calfmt'])) {
        $urladd .= "&amp;calfmt=" . urlencode($_GET['calfmt']);
    }
    $callinks = isset($_GET['callinks']) ? $_GET['callinks'] : $args['callinks'];
    if (isset($_GET['callinks'])) {
        $urladd .= "&amp;callinks=" . urlencode($_GET['callinks']);
    }
    $cals = isset($_GET['cals']) ? explode(',', $_GET['cals']) : explode(',', $args['cals']);
    if (isset($_GET['cals'])) {
        $urladd .= "&amp;cals=" . urlencode($_GET['cals']);
    }
    $caltype = isset($_GET['caltype']) ? $_GET['caltype'] : $args['caltype'];
    if (isset($_GET['caltype'])) {
        $urladd .= "&amp;caltype=" . urlencode($_GET['caltype']);
    }
    $cssprefix = isset($_GET['cssprefix']) ? $_GET['cssprefix'] : $args['cssprefix'];
    if (isset($_GET['cssprefix'])) {
        $urladd .= "&amp;cssprefix=" . urlencode($_GET['cssprefix']);
    }
    $dayofweektitle = isset($_GET['dayofweektitle']) ? explode(',', $_GET['dayofweektitle']) : explode(',', $args['dayofweektitle']);
    if (isset($_GET['dayofweektitle'])) {
        $urladd .= "&amp;dayofweektitle=" . urlencode($_GET['dayofweektitle']);
    }
    $dayofweektitlefmt = isset($_GET['dayofweektitlefmt']) ? $_GET['dayofweektitlefmt'] : $args['dayofweektitlefmt'];
    if (isset($_GET['dayofweektitlefmt'])) {
        $urladd .= "&amp;dayofweektitlefmt=" . urlencode($_GET['dayofweektitlefmt']);
    }
    $expire = isset($_GET['expire']) ? $_GET['expire'] : $args['expire'];
    if (isset($_GET['expire'])) {
        $urladd .= "&amp;expire=" . urlencode($_GET['expire']);
    }
    $includes = isset($_GET['includes']) ? $_GET['includes'] : $args['includes'];
    if (isset($_GET['includes'])) {
        $urladd .= "&amp;includes=" . urlencode($_GET['includes']);
    }
    $isodate = isset($_GET['isodate']) ? $_GET['isodate'] : $args['isodate'];
    if (isset($_GET['isodate'])) {
        $urladd .= "&amp;isodate=" . urlencode($_GET['isodate']);
    }
    $lines = isset($_GET['lines']) ? $_GET['lines'] : $args['lines'];
    if (isset($_GET['lines'])) {
        $urladd .= "&amp;lines=" . urlencode($_GET['lines']);
    }
    $locale = isset($_GET['locale']) ? $_GET['locale'] : $args['locale'];
    if (isset($_GET['locale'])) {
        $urladd .= "&amp;locale=" . urlencode($_GET['locale']);
    }
    $monthsahead = isset($_GET['monthsahead']) ? $_GET['monthsahead'] : $args['monthsahead'];
    if (isset($_GET['monthsahead'])) {
        $urladd .= "&amp;monthsahead=" . urlencode($_GET['monthsahead']);
    }
    $monthsback = isset($_GET['monthsback']) ? $_GET['monthsback'] : $args['monthsback'];
    if (isset($_GET['monthsback'])) {
        $urladd .= "&amp;monthsback=" . urlencode($_GET['monthsback']);
    }
    $monthtitle = isset($_GET['monthtitle']) ? explode(',', $_GET['monthtitle']) : explode(',', $args['monthtitle']);
    if (isset($_GET['monthtitle'])) {
        $urladd .= "&amp;monthtitle=" . urlencode($_GET['monthtitle']);
    }
    $monthtitlefmt = isset($_GET['monthtitlefmt']) ? $_GET['monthtitlefmt'] : $args['monthtitlefmt'];
    if (isset($_GET['monthtitlefmt'])) {
        $urladd .= "&amp;monthtitlefmt=" . urlencode($_GET['monthtitlefmt']);
    }
    $navnext = isset($_GET['navnext']) ? $_GET['navnext'] : $args['navnext'];
    if (isset($_GET['navnext'])) {
        $urladd .= "&amp;navnext=" . urlencode($_GET['navnext']);
    }
    $navprev = isset($_GET['navprev']) ? $_GET['navprev'] : $args['navprev'];
    if (isset($_GET['navprev'])) {
        $urladd .= "&amp;navprev=" . urlencode($_GET['navprev']);
    }
    $onedate = isset($_GET['onedate']) ? $_GET['onedate'] : $args['onedate'];
    if (isset($_GET['onedate'])) {
        $urladd .= "&amp;paras=" . urlencode($_GET['onedate']);
    }
    $paras = isset($_GET['paras']) ? $_GET['paras'] : $args['paras'];
    if (isset($_GET['paras'])) {
        $urladd .= "&amp;paras=" . urlencode($_GET['paras']);
    }
    $reverse = isset($_GET['reverse']) ? $_GET['reverse'] : $args['reverse'];
    if (isset($_GET['reverse'])) {
        $urladd .= "&amp;reverse=" . urlencode($_GET['reverse']);
    }
    $stopafter = isset($_GET['stopafter']) ? $_GET['stopafter'] : $args['stopafter'];
    if (isset($_GET['stopafter'])) {
        $urladd .= "&amp;stopafter=" . urlencode($_GET['stopafter']);
    }
    $styles = isset($_GET['styles']) ? explode(',', $_GET['styles']) : explode(',', $args['styles']);
    if (isset($_GET['styles'])) {
        $urladd .= "&amp;styles=" . urlencode($_GET['styles']);
    }
    $textacalfmt = isset($_GET['textacalfmt']) ? $_GET['textacalfmt'] : $args['textacalfmt'];
    if (isset($_GET['textacalfmt'])) {
        $urladd .= "&amp;textacalfmt=" . urlencode($_GET['textacalfmt']);
    }
    $textcalfmt = isset($_GET['textcalfmt']) ? $_GET['textcalfmt'] : $args['textcalfmt'];
    if (isset($_GET['textcalfmt'])) {
        $urladd .= "&amp;textcalfmt=" . urlencode($_GET['textcalfmt']);
    }
    $textdatefmt = isset($_GET['textdatefmt']) ? $_GET['textdatefmt'] : $args['textdatefmt'];
    if (isset($_GET['textdatefmt'])) {
        $urladd .= "&amp;textdatefmt=" . urlencode($_GET['textdatefmt']);
    }
    $textlinks = isset($_GET['textlinks']) ? $_GET['textlinks'] : $args['textlinks'];
    if (isset($_GET['textlinks'])) {
        $urladd .= "&amp;textlinks=" . urlencode($_GET['textlinks']);
    }
    $weekstart = isset($_GET['weekstart']) ? $_GET['weekstart'] : $args['weekstart'];
    if (isset($_GET['weekstart'])) {
        $urladd .= "&amp;weekstart=" . urlencode($_GET['weekstart']);
    }
    if (isset($_GET['zebra'])) {
        $urladd .= "&amp;zebra=" . urlencode($_GET['zebra']);
    }
    $zebra = isset($_GET['zebra']) ? $_GET['zebra'] : $args['zebra'];
    // Experimenting with CSS
    // Styles can come out of the upload area for the group!
    //
    $first = 1;
    //Set first style to the preferred.
    if ($styles[0] != NULL) {
        foreach ((array) $styles as $stylename) {
            $filepath = FmtPageName("pub/css/{$stylename}.css", $pagename);
            if ($first) {
                $rel = "rel='stylesheet'";
                $first = 0;
            } else {
                $rel = "rel='alternate stylesheet'";
            }
            if (file_exists($filepath)) {
                $HTMLHeaderFmt[] = "<link {$rel} type='text/css' href='\$PubDirUrl/css/{$stylename}.css' title='{$stylename}'/>\n";
            } else {
                $filepath = FmtPageName("\$UploadFileFmt/{$stylename}.css", "{$pagename}");
                if (file_exists($filepath)) {
                    $HTMLHeaderFmt[] = "<link {$rel} type='text/css' href='\$UploadUrlFmt/{$group}/{$stylename}.css' title='{$stylename}'/>\n";
                }
            }
        }
    }
    // Set the locale
    //
    if ($isodate == 'true') {
        $textdatefmt = '%Y-%m-%d';
    }
    if ($locale != NULL) {
        setlocale(LC_TIME, $locale);
    }
    // Number of paragraphs to include
    $parasorlines = 'paras';
    if ($lines != NULL) {
        $parasorlines = 'lines';
        $normallinesparas = $lines;
        $otherlinesparas = $lines;
    } else {
        if ($paras == NULL) {
            $normallinesparas = '1';
            $otherlinesparas = '-1';
        } else {
            $normallinesparas = $paras;
            $otherlinesparas = $paras;
        }
    }
    // Fallback to today/default information if something doesn't look right.
    //
    if ($month < 1 || $month > 12) {
        $month = $PmCaltmonth;
    }
    if ($year < 1 || $year > 2038) {
        if ($year != 'ACAL') {
            $year = $PmCaltyear;
        }
    }
    if ($alwaystoday == 'true') {
        $year = $PmCaltyear;
        $month = $PmCaltmonth;
        $day = $PmCaltday;
    }
    switch ($caltype) {
        case 'text':
            break;
        case 'normal':
            break;
        default:
            $caltype = 'normal';
    }
    // Set acalfmt to calfmt if not set.
    if ($acalfmt == NULL) {
        $acalfmt = $calfmt;
    }
    // Set textacalfmt to textcalfmt if not set.
    if ($textacalfmt == NULL) {
        $textacalfmt = $textcalfmt;
    }
    // Set PmCalPrefix to cssprefix.
    $PmCalPrefix = $cssprefix;
    // Try to limit look backs and lookaheads (5 years)
    //
    if ($monthsback < 0 || $monthsback > 60) {
        $monthsback = 0;
    }
    if ($monthsahead < 0 || $monthsahead > 60) {
        $monthsahead = 0;
    }
    // Handle expiration.
    //
    $eyear = $PmCaltyear;
    $emonth = $PmCaltmonth;
    $eday = $PmCaltday;
    if ($expire != 'true' && $expire != 'false') {
        // expire could be a day delta off from today
        //
        if ($expire <= 1780 && $expire >= -1780) {
            $expire_time = time() + $expire * 86400;
            $emonth = date("m", $expire_time);
            $eyear = date("Y", $expire_time);
            $eday = date("d", $expire_time);
        }
    }
    // Handle stop after days.
    //
    $syear = 0;
    $smonth = 0;
    $sday = 0;
    if ($stopafter != 'false') {
        // expire could be a day delta off from today
        //
        if ($stopafter <= 1780 && $stopafter >= -1780) {
            $stopafter_time = time() + $stopafter * 86400;
            $smonth = date("m", $stopafter_time);
            $syear = date("Y", $stopafter_time);
            $sday = date("d", $stopafter_time);
        }
    }
    // weekstart should be from 0 to 6.
    // weekstart should be from 0 to 6.
    $weekstart = abs($weekstart) % 7;
    if ($reverse == 'true') {
        $weekstart = (abs($weekstart - 6) + 1) % 7;
    }
    // Begin a new month.
    // If monthsahead is zero, then monthsahead is not used.  Don't go beyond this month.
    // If monthsback is zero, then monthsback is not used, starts with this month (or specified month).
    // If not zero, it is relative to whatever month is set to.
    // We're reindexing to consider months going from 0..11
    // Thus we subtract 1 from month.
    //
    $yearadjust = 0;
    if ($reverse == 'true') {
        $startmonth = $month - 1 + $monthsahead;
        if ($startmonth > 11) {
            $yearadjust = floor($startmonth / 12);
            $year = $year + $yearadjust;
        }
    } else {
        $startmonth = $month - 1 - $monthsback;
        if ($startmonth <= 0) {
            $yearadjust = floor($startmonth / 12);
            $year = $year + $yearadjust;
        }
    }
    $out = "";
    $zebraflag = 0;
    // Adjust month from 0..11 back to 1..12
    //
    $month = (abs($yearadjust * 12) + $startmonth) % 12 + 1;
    // Computer total number of months to display
    //
    $totalmonths = $monthsback + $monthsahead;
    for ($mcount = 0; $mcount <= $totalmonths; $mcount++) {
        // Calculate next month and prev month
        // Used for navigation forward and backward
        //
        if ($month == 12) {
            $nextmonth = 1;
            if ($ayear == "ACAL") {
                $nextyear = "ACAL";
            } else {
                $nextyear = $year + 1;
            }
        } else {
            $nextmonth = $month + 1;
            if ($ayear == "ACAL") {
                $nextyear = "ACAL";
            } else {
                $nextyear = $year;
            }
        }
        if ($month == 1) {
            $prevmonth = 12;
            if ($ayear == "ACAL") {
                $prevyear = "ACAL";
            } else {
                $prevyear = $year - 1;
            }
        } else {
            $prevmonth = $month - 1;
            if ($ayear == "ACAL") {
                $prevyear = "ACAL";
            } else {
                $prevyear = $year;
            }
        }
        // Get number of days in the month, day of week the first day starts on
        // and get month name
        //
        $totaldays = date("t", mktime(0, 0, 0, $month, 1, pmcal_year($year)));
        if ($day > $totaldays) {
            $day = $PmCaltday;
        }
        if ($reverse == 'true') {
            $startdayofweek = date('w', mktime(0, 0, 0, $nextmonth, 1, pmcal_year($nextyear))) - 1;
            if ($startdayofweek < 0) {
                $startdayofweek = 6;
            }
            $startdayofweek = abs($startdayofweek - 6);
        } else {
            $startdayofweek = date('w', mktime(0, 0, 0, $month, 1, pmcal_year($year)));
        }
        // Format monthtitle.
        //
        $m = $month - 1;
        if ($monthtitle[$m] == NULL) {
            // Do not use $day... use 1
            $mt = strftime($monthtitlefmt, mktime(0, 0, 0, $month, 1, pmcal_year($year)));
        } else {
            // This isn't perfect.  Difficulties with apostrophes.
            $mt = strftime(urldecode($monthtitle[$m]), mktime(0, 0, 0, $month, 1, pmcal_year($year)));
        }
        // Fill in array of textual day titles
        // I did this like this so the locale could be changed someday.
        //
        $d = $PmCaltday;
        for ($i = 0; $i < 7; $i++) {
            $titleindex = date("w", mktime(0, 0, 0, $month, $d, pmcal_year($year)));
            if ($dayofweektitle[$titleindex] != NULL) {
                $dayofweektitlefmt = urldecode($dayofweektitle[$titleindex]);
            }
            $title = strftime($dayofweektitlefmt, mktime(0, 0, 0, $month, $d, pmcal_year($year)));
            $dayofweektitle[$titleindex] = $title;
            $d++;
        }
        // It's necessary to force a line break before the (:pmcal:) output.
        //
        if ($callinks != 'false' && $caltype == 'normal') {
            $out .= "\\\\\n";
            // Output Today link
            //
            $cl = "{$PmCalPrefix}todaylink";
            $out .= "%class='{$cl}'%";
            $out .= "[[{$group}?year={$PmCaltyear}&amp;month={$PmCaltmonth}&amp;day={$PmCaltday}{$urladd}|";
            $out .= "Today]]%%\n";
            // Output Extra Included Calendars links
            //
            $cl = sprintf("{$PmCalPrefix}include%slink pmcalincludelink", $cal);
            foreach ($cals as $cal) {
                if ($cal != '') {
                    $out .= "%class='{$cl}'%";
                    $out .= sprintf("[[%s|%s]]\n", $cal, $cal);
                }
            }
        }
        if ($caltype == 'normal') {
            // Note: had to insert some forced returns... still some problems
            // with PmWiki and table begins I guess.
            //
            $out .= "\\\\\n\\\\\n\n";
            // Output monthtitle, the banner with prev and next month links
            //
            $navprevout = strftime($navprev, mktime(0, 0, 0, $prevmonth, $day, pmcal_year($prevyear)));
            $navnextout = strftime($navnext, mktime(0, 0, 0, $nextmonth, $day, pmcal_year($nextyear)));
            $cl = 'pmcal';
            $out .= "(:table ";
            $out .= "class='{$cl}' ";
            $out .= "border=1 cellspacing=0 cellpadding=3 width=100%:)\n";
            $out .= "(:cellnr class='{$PmCalPrefix}monthtitle' colspan=7:)\n";
            // Large one liner broken up into multiple appends
            $out .= "%class='{$PmCalPrefix}navlinks {$PmCalPrefix}navlinksprev'%";
            $out .= "[[{$group}?month={$prevmonth}&amp;day=1&amp;year={$prevyear}{$urladd}|{$navprevout}]] %%";
            $out .= "[[{$group}?month={$month}&amp;day={$day}&amp;year={$year}{$urladd}|{$mt}]]";
            $out .= "%class='{$PmCalPrefix}navlinks {$PmCalPrefix}navlinksnext'%";
            $out .= " [[{$group}?month={$nextmonth}&amp;day=1&amp;year={$nextyear}{$urladd}|{$navnextout}]]%%\n";
            // Output days of week headings
            //
            $ctype = "cellnr";
            for ($i = 0; $i < 7; $i++) {
                $out .= "(:{$ctype} ";
                $out .= "class='{$PmCalPrefix}dayofweektitle' ";
                $out .= "width=10% ";
                $out .= ":)\n";
                $d = ($i + $weekstart) % 7;
                if ($reverse == 'true') {
                    $d = abs($d - 6);
                }
                $out .= "{$dayofweektitle[$d]}\n";
                $ctype = "cell";
            }
            // Output null cells, the empty cells before the first day
            // of the month.
            $ctype = "cellnr";
            for ($i = 0; $i < 7; $i++) {
                $d = ($i + $weekstart) % 7;
                if ($d == $startdayofweek) {
                    break;
                }
                $out .= "(:{$ctype} class='{$PmCalPrefix}null':)\n";
                $ctype = "cell";
            }
        }
        // Output the calendar cells
        // Use a special class for today
        //
        $d = $startdayofweek;
        if ($reverse == 'true') {
            $iday = $totaldays;
        } else {
            $iday = 1;
        }
        // Default flag for monitoring repeated days (included text calendar entries)
        $onedatedone = 0;
        $lyear = 0;
        $lmonth = 0;
        $lday = 0;
        // $i isn't the day now... it's just a counter.
        // $iday is the day now.
        //
        for ($i = 1; $i <= $totaldays; $i++) {
            $dayindex = $d % 7;
            if ($ayear == 'ACAL') {
                $year = 'ACAL';
            } else {
                $year = sprintf("%04d", $year);
            }
            $pmcalpagename = sprintf("%s.%s%02d%02d", $group, $year, $month, $iday);
            // Keep skip here in case we want to use it in caltype=normal??
            //
            $skip = 0;
            if ($expire != 'false') {
                if ($year < $eyear) {
                    $skip = 1;
                } else {
                    if ($year == $eyear && $month < $emonth) {
                        $skip = 1;
                    } else {
                        if ($year == $eyear && $month == $emonth && $iday < $eday) {
                            $skip = 1;
                        }
                    }
                }
            }
            if ($stopafter != 'false') {
                if ($year > $syear) {
                    $skip = 1;
                } else {
                    if ($year == $syear && $month > $smonth) {
                        $skip = 1;
                    } else {
                        if ($year == $syear && $month == $smonth && $iday > $sday) {
                            $skip = 1;
                        }
                    }
                }
            }
            if ($zebra == "resetdaily") {
                $zebraflag = 0;
            }
            $istoday = 0;
            if ($year == $PmCaltyear && $month == $PmCaltmonth && $iday == $PmCaltday) {
                $istoday = 1;
            }
            if ($caltype == 'normal') {
                if ($dayindex == $weekstart) {
                    $ctype = "cellnr";
                } else {
                    $ctype = "cell";
                }
                $cl = "{$PmCalPrefix}day";
                $dn = "{$PmCalPrefix}daynumber";
                if ($istoday) {
                    $cl = "{$PmCalPrefix}today";
                    $dn = "{$dn} {$PmCalPrefix}todaynumber";
                }
                if (!PageExists($pmcalpagename)) {
                    // Bizarre hack added due to PmWiki change.
                    $dn = $dn . " {$PmCalPrefix}createtextlink";
                }
                $out .= sprintf("(:{$ctype} class='%s' height=80px :)\n", $cl);
                $out .= "%class='{$dn}'%";
                $out .= sprintf("[[{$group}.%s%02d%02d?year=%s&amp;month=%s&amp;day=%s%s|%s]]\n", $year, $month, $iday, $year, $month, $iday, $urladd, $iday);
                if ($includes != 'false' && PageExists($pmcalpagename)) {
                    $MaxIncludes++;
                    $out .= sprintf("\\\\\n\n(:include %s %s=%s:)\n", $pmcalpagename, $parasorlines, $normallinesparas);
                }
            } else {
                if ($caltype == "text") {
                    if (!$skip && PageExists($pmcalpagename)) {
                        if ($zebra != 'false' && $zebraflag) {
                            $out .= "(:div id={$PmCalPrefix}zebra:)\n";
                        }
                        if ($textlinks != 'false') {
                            $cl = "{$PmCalPrefix}daytextlink";
                            if ($istoday) {
                                $cl = "{$PmCalPrefix}todaytextlink";
                            }
                            if ($onedate != 'false' && ($lyear != $year || $lmonth != $month || $lday != $iday)) {
                                $onedatedone = 0;
                                $lyear = $year;
                                $lmonth = $month;
                                $lday = $iday;
                            }
                            if (!$onedatedone) {
                                $formatteddate = strftime($textdatefmt, mktime(0, 0, 0, $month, $iday, pmcal_year($year)));
                                if ($textlinks == 'nolinks') {
                                    $out .= sprintf("{$PmCalTextLinkMark}%%class='%s'%%[=%s=]\n", $cl, $formatteddate);
                                } else {
                                    $out .= sprintf("{$PmCalTextLinkMark}%%class='%s'%%[[%s|[=%s=]]]\n", $cl, $pmcalpagename, $formatteddate);
                                }
                                if ($onedate != 'false') {
                                    $onedatedone = 1;
                                }
                            }
                        }
                        if ($includes != 'false') {
                            $MaxIncludes++;
                            $out .= sprintf("(:include %s %s=%s:)\n", $pmcalpagename, $parasorlines, $otherlinesparas);
                        }
                        if ($zebra != 'false' && $zebraflag) {
                            $out .= "(:divend:)\n";
                        }
                        if ($zebraflag) {
                            $zebraflag = 0;
                        } else {
                            $zebraflag = 1;
                        }
                    }
                }
            }
            // Include day pages from other calendars if present.
            // NOTE: The pmcalinclude class will only hold true if no new block construct is begun as a part of
            // the included page.
            //
            foreach ($cals as $cal) {
                if ($cal != '') {
                    $pmcalincpagename = sprintf("%s.%s%02d%02d", $cal, $year, $month, $iday);
                    if (!$skip && PageExists($pmcalincpagename)) {
                        if ($caltype == "text") {
                            if ($zebra != 'false' && $zebraflag) {
                                $out .= "(:div id={$PmCalPrefix}zebra:)\n";
                            }
                            if ($onedate != 'false' && ($lyear != $year || $lmonth != $month || $lday != $iday)) {
                                $onedatedone = 0;
                                $lyear = $year;
                                $lmonth = $month;
                                $lday = $iday;
                            }
                            if (!$onedatedone) {
                                $formatteddate = strftime($textdatefmt, mktime(0, 0, 0, $month, $iday, pmcal_year($year)));
                                $formattedtextcal = sprintf($textcalfmt, $cal);
                                if ($textlinks != 'false') {
                                    $todaycl = "";
                                    if ($istoday) {
                                        $todaycl = sprintf(" {$PmCalPrefix}include%stodaytextlink {$PmCalPrefix}includetodaytextlink", $cal);
                                    }
                                    if ($textlinks == 'nolinks') {
                                        $out .= sprintf("{$PmCalIncludeTextLinkMark}%%class='{$PmCalPrefix}include%stextlink {$PmCalPrefix}includetextlink{$todaycl}'%%[=%s %s=]\n", $cal, $formatteddate, $formattedtextcal);
                                    } else {
                                        $out .= sprintf("{$PmCalIncludeTextLinkMark}%%class='{$PmCalPrefix}include%stextlink {$PmCalPrefix}includetextlink{$todaycl}'%%[[%s|[=%s %s=]]]\n", $cal, $pmcalincpagename, $formatteddate, $formattedtextcal);
                                    }
                                }
                                if ($onedate != 'false') {
                                    $onedatedone = 1;
                                }
                            } elseif ($onedate == "showcals") {
                                $formattedtextcal = sprintf($textcalfmt, $cal);
                                if ($textlinks != 'false') {
                                    $todaycl = "";
                                    if ($istoday) {
                                        $todaycl = sprintf(" {$PmCalPrefix}subinclude%stodaytextlink {$PmCalPrefix}includetodaytextlink", $cal);
                                    }
                                    if ($textlinks == 'nolinks') {
                                        $out .= sprintf("{$PmCalSubIncludeTextLinkMark}%%class='{$PmCalPrefix}subinclude%stextlink {$PmCalPrefix}subincludetextlink{$todaycl}'%%[=%s=]\n", $cal, $formattedtextcal);
                                    } else {
                                        $out .= sprintf("{$PmCalSubIncludeTextLinkMark}%%class='{$PmCalPrefix}subinclude%stextlink {$PmCalPrefix}subincludetextlink{$todaycl}'%%[[%s|[=%s=]]]\n", $cal, $pmcalincpagename, $formattedtextcal);
                                    }
                                }
                            }
                            if ($includes != 'false') {
                                $MaxIncludes++;
                                $out .= sprintf("(:include %s %s=%s:)\n", $pmcalincpagename, $parasorlines, $otherlinesparas);
                            }
                            if ($zebra != 'false' && $zebraflag) {
                                $out .= "(:divend:)\n";
                            }
                            if ($zebraflag) {
                                $zebraflag = 0;
                            } else {
                                $zebraflag = 1;
                            }
                        } else {
                            if ($caltype == "normal") {
                                if ($includes != 'false') {
                                    $formattedcal = sprintf($calfmt, $cal);
                                    $todaycl = "";
                                    if ($istoday) {
                                        $todaycl = sprintf(" {$PmCalPrefix}include%stoday {$PmCalPrefix}includetoday", $cal);
                                    }
                                    $out .= sprintf("%%class='{$PmCalPrefix}include%s {$PmCalPrefix}include{$todaycl}'%%[[%s|%s]]\n", $cal, $pmcalincpagename, $formattedcal);
                                    $MaxIncludes++;
                                    $out .= sprintf("(:include %s %s=%s:)\n", $pmcalincpagename, $parasorlines, $normallinesparas);
                                }
                            }
                        }
                    }
                }
            }
            foreach ($acals as $acal) {
                if ($acal != '') {
                    $pmcalincpagename = sprintf("%s.ACAL%02d%02d", $acal, $month, $iday);
                    if (!$skip && PageExists($pmcalincpagename)) {
                        if ($caltype == "text") {
                            if ($zebra != 'false' && $zebraflag) {
                                $out .= "(:div id={$PmCalPrefix}zebra:)\n";
                            }
                            if ($onedate != 'false' && ($lyear != $year || $lmonth != $month || $lday != $iday)) {
                                $onedatedone = 0;
                                $lyear = $year;
                                $lmonth = $month;
                                $lday = $iday;
                            }
                            if (!$onedatedone) {
                                $formatteddate = strftime($textdatefmt, mktime(0, 0, 0, $month, $iday, pmcal_year($year)));
                                $formattedtextcal = sprintf($textacalfmt, $acal);
                                if ($textlinks != 'false') {
                                    $todaycl = "";
                                    if ($istoday) {
                                        $todaycl = sprintf(" {$PmCalPrefix}include%stodaytextlink {$PmCalPrefix}includetodaytextlink", $cal);
                                    }
                                    if ($textlinks == 'nolinks') {
                                        $out .= sprintf("{$PmCalACALTextLinkMark}%%class='{$PmCalPrefix}include%stextlink {$PmCalPrefix}includetextlink{$todaycl}'%%[=%s %s=]\n", $acal, $formatteddate, $formattedtextcal);
                                    } else {
                                        $out .= sprintf("{$PmCalACALTextLinkMark}%%class='{$PmCalPrefix}include%stextlink {$PmCalPrefix}includetextlink{$todaycl}'%%[[%s|[=%s %s=]]]\n", $acal, $pmcalincpagename, $formatteddate, $formattedtextcal);
                                    }
                                }
                                if ($onedate != 'false') {
                                    $onedatedone = 1;
                                }
                            } elseif ($onedate == "showcals") {
                                $formattedtextcal = sprintf($textacalfmt, $acal);
                                if ($textlinks != 'false') {
                                    $todaycl = "";
                                    if ($istoday) {
                                        $todaycl = sprintf(" {$PmCalPrefix}sbuinclude%stodaytextlink {$PmCalPrefix}subincludetodaytextlink", $cal);
                                    }
                                    if ($textlinks == 'nolinks') {
                                        $out .= sprintf("{$PmCalSubACALTextLinkMark}%%class='{$PmCalPrefix}subinclude%stextlink {$PmCalPrefix}subincludetextlink{$todaycl}'%%[=%s=]\n", $cal, $formattedtextcal);
                                    } else {
                                        $out .= sprintf("{$PmCalSubACALTextLinkMark}%%class='{$PmCalPrefix}subinclude%stextlink {$PmCalPrefix}subincludetextlink{$todaycl}'%%[[%s|[=%s=]]]\n", $cal, $pmcalincpagename, $formattedtextcal);
                                    }
                                }
                            }
                            if ($includes != 'false') {
                                $MaxIncludes++;
                                $out .= sprintf("(:include %s %s=%s:)\n", $pmcalincpagename, $parasorlines, $otherlinesparas);
                            }
                            if ($zebra != 'false' && $zebraflag) {
                                $out .= "(:divend:)\n";
                            }
                            if ($zebraflag) {
                                $zebraflag = 0;
                            } else {
                                $zebraflag = 1;
                            }
                        } else {
                            if ($caltype == "normal") {
                                if ($includes != 'false') {
                                    $formattedcal = sprintf($acalfmt, $acal);
                                    $todaycl = "";
                                    if ($istoday) {
                                        $todaycl = sprintf(" {$PmCalPrefix}include%stoday {$PmCalPrefix}includetoday", $cal);
                                    }
                                    $out .= sprintf("%%class='{$PmCalPrefix}include%s {$PmCalPrefix}include{$todaycl}'%%[[%s|%s]]\n", $acal, $pmcalincpagename, $formattedcal);
                                    $MaxIncludes++;
                                    $out .= sprintf("(:include %s %s=%s:)\n", $pmcalincpagename, $parasorlines, $normallinesparas);
                                }
                            }
                        }
                    }
                }
            }
            if ($reverse == 'true') {
                $iday--;
            } else {
                $iday++;
            }
            $d++;
        }
        // Output null cells, the empty cells after the last day
        // of the month.
        //
        if ($caltype == 'normal') {
            $dayindex = ($d + 7 - $weekstart) % 7;
            if ($dayindex != 0) {
                for ($i = $dayindex; $i < 7; $i++) {
                    $ctype = "cell";
                    $out .= "(:{$ctype} class='{$PmCalPrefix}null':)\n";
                }
            }
            // End the calendar table
            //
            $out .= "(:tableend:)\n";
        }
        if ($reverse == 'true') {
            $year = $prevyear;
            $month = $prevmonth;
        } else {
            $year = $nextyear;
            $month = $nextmonth;
        }
    }
    //end of  month loop
    PRR();
    return $out;
}
Exemple #29
0
function FmtUploadList($pagename, $args) {
  global $UploadDir, $UploadPrefixFmt, $UploadUrlFmt, $EnableUploadOverwrite,
    $TimeFmt, $EnableDirectDownload;

  $opt = ParseArgs($args);
  if (@$opt[''][0]) $pagename = MakePageName($pagename, $opt[''][0]);
  if (@$opt['ext']) 
    $matchext = '/\\.(' 
      . implode('|', preg_split('/\\W+/', $opt['ext'], -1, PREG_SPLIT_NO_EMPTY))
      . ')$/i';

  $uploaddir = FmtPageName("$UploadDir$UploadPrefixFmt", $pagename);
  $uploadurl = FmtPageName(IsEnabled($EnableDirectDownload, 1) 
                          ? "$UploadUrlFmt$UploadPrefixFmt/"
                          : "\$PageUrl?action=download&amp;upname=",
                      $pagename);

  $dirp = @opendir($uploaddir);
  if (!$dirp) return '';
  $filelist = array();
  while (($file=readdir($dirp)) !== false) {
    if ($file{0} == '.') continue;
    if (@$matchext && !preg_match(@$matchext, $file)) continue;
    $filelist[$file] = $file;
  }
  closedir($dirp);
  $out = array();
  natcasesort($filelist);
  $overwrite = '';
  foreach($filelist as $file=>$x) {
    $name = PUE("$uploadurl$file");
    $stat = stat("$uploaddir/$file");
    if ($EnableUploadOverwrite) 
      $overwrite = FmtPageName("<a rel='nofollow' class='createlink'
        href='\$PageUrl?action=upload&amp;upname=$file'>&nbsp;&Delta;</a>", 
        $pagename);
    $out[] = "<li> <a href='$name'>$file</a>$overwrite ... ".
      number_format($stat['size']) . " bytes ... " . 
      strftime($TimeFmt, $stat['mtime']) . "</li>";
  }
  return implode("\n",$out);
}
Exemple #30
0
function FmtPageList($outfmt, $pagename, $opt)
{
    global $GroupPattern, $FmtV, $FPLFormatOpt, $FPLFunctions;
    # get any form or url-submitted request
    $rq = htmlspecialchars(stripmagic(@$_REQUEST['q']), ENT_NOQUOTES);
    # build the search string
    $FmtV['$Needle'] = $opt['o'] . ' ' . $rq;
    # Handle "group/" at the beginning of the form-submitted request
    if (preg_match("!^({$GroupPattern}(\\|{$GroupPattern})*)?/!i", $rq, $match)) {
        $opt['group'] = @$match[1];
        $rq = substr($rq, strlen(@$match[1]) + 1);
    }
    # merge markup options with form and url
    $opt = array_merge($opt, ParseArgs($opt['o'] . ' ' . $rq), @$_REQUEST);
    # non-posted blank search requests return nothing
    if (@($opt['req'] && !$opt['-'] && !$opt[''] && !$opt['+'] && !$opt['q'])) {
        return '';
    }
    # terms and group to be included and excluded
    $GLOBALS['SearchIncl'] = array_merge((array) @$opt[''], (array) @$opt['+']);
    $GLOBALS['SearchExcl'] = (array) @$opt['-'];
    $GLOBALS['SearchGroup'] = @$opt['group'];
    $fmt = @$opt['fmt'];
    if (!$fmt) {
        $fmt = 'default';
    }
    $fmtopt = @$FPLFormatOpt[$fmt];
    if (!is_array($fmtopt)) {
        if ($fmtopt) {
            $fmtopt = array('fn' => $fmtopt);
        } elseif (@$FPLFunctions[$fmt]) {
            $fmtopt = array('fn' => $FPLFunctions[$fmt]);
        } else {
            $fmtopt = $FPLFormatOpt['default'];
        }
    }
    $fmtfn = @$fmtopt['fn'];
    if (!is_callable($fmtfn)) {
        $fmtfn = $FPLFormatOpt['default']['fn'];
    }
    $matches = array();
    $opt = array_merge($fmtopt, $opt);
    $out = $fmtfn($pagename, $matches, $opt);
    $FmtV['$MatchCount'] = count($matches);
    if ($outfmt != '$MatchList') {
        $FmtV['$MatchList'] = $out;
        $out = FmtPageName($outfmt, $pagename);
    }
    $out = preg_replace('/^(<[^>]+>)(.*)/esm', "PSS('\$1').Keep(PSS('\$2'))", $out);
    return PRR($out);
}