'Feature/Change Request',
'Documentation', 'Cookbook', 'CoreCandidate','PHP Compatibility', 'Other'));
Markup('pitsform','inline','/\\(:pitsform:\\)/',"PitsForm");
Markup('pitslist','directives','/\\(:(pits2?list)\\s*(.*?):\\)/',
"MarkupPitsList");
function MarkupPitsList($m) {
extract($GLOBALS["MarkupToHTML"]); # get $pagename
return ($m[1] == 'pitslist')
? FmtPitsList('',$pagename,array('q'=>$m[2]))
: FmtPits2List('',$pagename,array('q'=>$m[2]));
}
Markup('pits','directives',
'/^(Summary|Created|Status|Category|From|Assigned|Version|OS|Priority):.*/',
"<:block>
$0
");
## PitsForm() generates the form for entering a new issue. Note that
## once an issue has been created, it's a normal wikipage and is edited
## according to the normal editing code (i.e., there's no form-based
## editing yet).
function PitsForm() {
extract($GLOBALS["MarkupToHTML"]); # get $pagename
global $PitsCategories, $Version;
$ver = str_replace('pmwiki-', '', $Version);
$out[] = "";
$out[] = <<
(function(){
var q = document.getElementById('versionq');// in wiki page
if(!q) return;
document.getElementById('versioncell').appendChild(q);
function cmpver() {
var ver = input.value;
var clean = ver.replace(/[^\d.,]+/g, '').replace(/[^\d.]+/g, '.');
q.style.display = (ver == '' || clean == '$ver') ? 'none': 'inline';
}
var input = document.getElementById('versioninput');
input.addEventListener('change', cmpver, false);
})();
EOF;
return Keep(FmtPageName(implode('',$out),$pagename));
}
SDVA($HTMLStylesFmt, array('PITS'=>"
.pitsfield { text-align:right; font-weight:bold; }
table.pits th a { text-decoration:none; }
table.pits th { background-color:#eeeeee; }
dl.pits2 { font-size: 85%; color: #888888; clear:both;border-top: 1px solid #dddddd; }
dl.pits2 dt { float:left; padding-right:0.5em; }
dl.pits2 dd { margin-left: 8.5em; }
dl.pits2 dd em { float: right; }
dl.pits2 dd strong { font-weight: normal; }
"));
include_once("$FarmD/scripts/author.php");
if ($action=='postpits') {
Lock(2);
$g = PageVar($pagename, '$Group');
$glen = strlen($g)+1;
foreach(ListPages("/^$g\\.\\d/") as $i)
$issue = max(@$issue, intval(substr($i,$glen), 10));
$pagename = sprintf("$g.%05d",@$issue+1);
$action = 'edit';
$_REQUEST['post'] = 1;
$CreateTime = PSFT('%Y-%m-%d %H:%M',$Now);
$EditMessageFmt = "Please review and make any edits
to your issue below, then press 'Save'.
";
$_POST['csum'] = $_REQUEST['summary'];
$vers = str_replace('pmwiki-', '', $_REQUEST['version']);
$_POST['text'] = "
Summary: {$_REQUEST['summary']}
Created: $CreateTime
Status: Open
Category: ".implode(' ',(array)@$_REQUEST['category'])."
From: $AuthorLink
Assigned:
Priority: {$_REQUEST['priority']}
Version: {$vers}
OS: {$_REQUEST['os']}
Description:
{$_REQUEST['description']}
~~~~
";
}
## FmtPitsList creates a table of PITS issues according to various
## criteria.
function FmtPitsList($fmt,$pagename,$opt) {
global $EnablePITSAuth;
$opt = array_merge($opt,@$_REQUEST);
$g = PageVar($pagename, '$Group');
$pitslist = ListPages("/^$g\\.\\d+$/");
$out[] = FmtPageName("";
return implode('',$out);
}
## This function creates specialized ordering functions needed to
## (more efficiently) perform sorts on arbitrary sets of criteria.
function CreateOrderFunction($order) {
$code = '';
$orders = array();
foreach(preg_split('/[\\s,|]+/',strtolower($order),-1,PREG_SPLIT_NO_EMPTY)
as $o) {
if (substr($o,0,1)=='-') { $r=-1; $o=substr($o,1); }
else $r=1;
if (preg_match('/\\W/',$o)) continue;
$orders[] = [ $o, $r ];
}
$cmpfn = new PITSCOF($orders);
return array($cmpfn, 'compare');
}
class PITSCOF {
public $orders;
function __construct($orders = false) {
if ($orders) $this->orders = $orders;
}
function compare($x, $y) {
$orders = $this->orders;
foreach ($orders as $order) {
list($o, $r) = $order;
$c = strcasecmp($x[$o],$y[$o]);
if ($c != 0) return $r * $c;
}
}
}
## FmtPits2List creates a table of PITS issues according to various
## criteria.
function FmtPits2List($fmt,$pagename,$opt) {
global $AutoSuspendDaysInactive, $Now, $PITSCache, $EnablePITSAuth;
SDV($AutoSuspendDaysInactive, 180);
$opt = array_merge($opt,@$_REQUEST);
$g = PageVar($pagename, '$Group');
$pitslist = ListPages("/^$g\\.\\d+$/");
$terms = preg_split('/((?';
foreach($plist as $p) {
$cnt ++;
$out[] = Keep(FmtPageName("- \$Name : {$p['category']}
",$p['name'])
."- {$p['status']} "
."{$p['priority2']} "
." {$p['summary']}
");
if(@$opt['count'] && $cnt>$opt['count']) break;
}
$out[] = '';
return implode('',$out);
}
# for {(priority2 "{=$:Priority}")}
SDVA($MarkupExpr, array('priority2' => 'Priority2($args[0])'));
function Priority2($x){
global $PriorityFmt, $PriorityMinVotes;
SDV($PriorityFmt, '%1.1f (%d)');
SDV($PriorityMinVotes, 4);
if(trim(strval(@$x))=='') return sprintf($PriorityFmt, 0, 0);
preg_match_all("/[0-5x]/i", $x, $m, PREG_PATTERN_ORDER);
$count = count($m[0]);
if($count==0) return sprintf($PriorityFmt, 0, 0);
$sum = array_sum($m[0]);
$avg = ($count<$PriorityMinVotes)? 0: $sum/$count;
return sprintf($PriorityFmt, $avg, $count);
}