:
* De-specialized the original code (hardcoded -> config vars)
* Stripped $PageUrl vars in template
* Allowed space after label ("Label : content")
* Limited parsing to the PITS header (leave out the comments below)
* Allowed links in any table fields (ex: [[~Author]])
* Stripped LF and other spaces between HTML lines (avoid vspace)
* Added HTML entities charset for some systems (mainly NTFS ?)
0.21 - Modifications by Didier Lebrun
:
* Fixed label parsing for i18n charsets
* Fixed description entry in edit template (LF problem)
* Transfered default values from edit template to form template
* Suppressed unuseful $PitsGroup global var
* Added (:pitstrail[ PageName|Label]:) markup and assorted function
0.22 - Modification by Fabrice Mousset
* Fixed (:pitlist:) makeup (directive ==> directives)
* Fixed misspelled variable $PitsIDLenght ==> $PitsIDLength
* Fixed PITS page list to add $PitsIDLength into scan pattern
* Fixed FmtPitsList() function when no PITS are defined (deadlock)
* Fixed PitsTrail() function when less than 2 PITS are defined (deadlock)
0.23 - Modification by Fabrice Mousset
* Fixed html code output to remove '\' miss placed
* Added $PitsNoItemText variable to personalize output when no PITS present
*/
define(PITS_VERSION, '0.23');
# ---- Config vars ---- #
## These vars can be overriden in the PITS group configuration file
## (local/YourPITSGroupName.php). Whenever you see something like:
## SDV($SomeVar, "default setup");
## you must put in your config something like:
## $SomeVar = "custom setup";
## SDV() is a just PmWiki function allowing to set a default value
## when none has been setup in the config.
## Number of chars for page names
SDV($PitsIDLength, 5);
## Template for empty PITS list
SDV($PitsNoItemText, "No bugs ;-)");
## Label to field name mapping. Labels and names can be whatever you like,
## as long as they are consistent through all configuration vars.
SDV($PitsLabels, array(
'Summary' => 'summary',
'Created' => 'created',
'Status' => 'status',
'Category' => 'category',
'From' => 'author',
'Assigned' => 'assigned',
'Priority' => 'priority',
'Version' => 'version',
'OS' => 'os',
'Description' => 'description'
));
## Template for the input form
SDV($PitsFormTemplateFmt, "
");
## Template for filling the edit box with input data
## "----" MUST be present at the end to separate the entries from the
## eventual comments that could be added afterwards.
SDV($PitsEditTemplateFmt, "
Summary: \$summary
Created: \$created
Status: \$status
Category: \$category
From: [[~\$author]]
Assigned: \$assigned
Priority: \$priority
Version: \$version
##OS: os (changed 2013/05/04) to OS: \$os
OS: \$os
Description:[[<<]]\$description
----
!!!Comments
----
(:pitstrail:)
");
## Template for list table.
## The "(/)PitsListItemFmt" tags MUST be present as delimiters of the entry part.
SDV($PitsListTemplateFmt, "
");
## HTML styles
SDV($PitsStylesFmt, "
.pitsform {}
.pitsform td.label { text-align:right; font-weight:bold; }
.pitsform td.input {}
.pitspage {}
.pitspage span.label {}
.pitspage span.data {}
.pitslist {}
.pitslist th { background-color:#eeeeee; }
.pitslist th a { text-decoration:none; }
");
## Edit form top message
SDV($PitsEditMessageFmt, "Please review and make any edits
to your issue below, then press 'Save'.
");
## Fields that can be filtered by name=criteria args
SDV($PitsListFilters, array('summary','created','status','category','priority','version'));
## Criteria used for default and complementary sorting after explicit criteria
SDV($PitsListDefaultSort, array('-priority','status','category','name'));
## Charset for HTML entities conversion ('ISO-8859-1' usually, 'UTF-8' on NTFS systems)
SDV($PitsHtmlEntitiesCharset, 'ISO-8859-1');
# ---- end of Config vars ---- #
$HTMLStylesFmt[] = $PitsStylesFmt;
markup('pitsform', 'inline', '/\\(:pitsform:\\)/e', "Keep(PitsForm(\$pagename))");
markup('pitslist', 'directives', '/\\(:pitslist\\s*(.*?):\\)/e',
"FmtPitsList('', \$pagename, array('q' => PSS('$1')))");
markup('pitsread', 'directives', '/^('.implode('|', array_keys($PitsLabels)) . ')\s*:(.*)/',
"<:block>$1:
$2
");
markup('pitstrail', ']#', $tmpl);
if(count($sect) != 3)
Abort("\$PitsListTemplateFmt MUST have 3 sections !");
$out[] = FmtPageName(array_shift($sect), $pagename);
$terms = preg_split('/((?= @$min; $i--)
{
$prev = sprintf("%0" . $PitsIDLength . "d", @$i);
if(PageExists("$group.$prev"))
{
$prev = '[[' . $prev . ']]';
break;
}
$prev = '';
}
$i = @$name+1;
list(,$max) = explode('.', array_pop($pitslist));
for($i; $i <= @$max; $i++)
{
$next = sprintf("%0" . $PitsIDLength . "d", @$i);
if(PageExists("$group.$next"))
{
$next = '[[' . $next . ']]';
break;
}
$next = '';
}
return "<< $prev | $trailindex | $next >>";
}
## This function creates specialized ordering functions needed to
## (more efficiently) perform sorts on arbitrary sets of criteria.
function CreateOrderFunction($order)
{
$code = '';
foreach(preg_split('/[\\s,|]+/', strtolower($order), -1, PREG_SPLIT_NO_EMPTY) as $o)
{
if (substr($o, 0, 1) == '-')
{
$r = '-';
$o = substr($o, 1);
}
else
$r='';
if (preg_match('/\\W/', $o))
continue;
$code .= "\$c=strcasecmp(@\$x['$o'],@\$y['$o']); if (\$c!=0) return $r\$c;\n";
}
$code .= "return 0;\n";
return create_function('$x,$y', $code);
}
## This function is used to evaluate the templates while insulating their
## vars from potential name conflicts
function PitsEvalTemplate($hash, $tmpl)
{
global $Author,$Now;
foreach($hash as $k=>$v)
$$k = $v;
return(@eval("return(\"$tmpl\");"));
}
?>