* Create a MyPitsGroup.MyPitsForm file and put in it: (:pitsform:) * Create a MyPitsGroup.MyPitsList file and put in it: (:pitslist[ somefield=somevalue,othervalue otherfield=!excludevalue ...]:) where "somefield" is the name of a field and "somevalue,othervalue" are the values you want to list. On the opposite "otherfield=!excludevalue" will exclude the records where "otherfield" correspond to "excludevalue". But you can just put (:pitslist:) to display the full list. * ... That's it ! ---- Notes: * All vars in the templates MUST be escaped (ex: \$SomeVar) * Vars can be "local" ones or "global" ones * Local vars correspond to field names: (ex: $summary = content of the 'summary' field) * Global vars are those given by PmWiki, like $Author and $Now. Currently, $Author and $Now are the only ones supported, but you can add others in function PitsEvalTemplate(). You must avoid $...Url vars like $PageUrl and such, since the http://... link in them would be interpretated twice. But you can use [[...]] type of links anyway. * You can even use PHP functions in templates: ex: ".strftime('%Y-%m-%d %H:%M',$Now)." (see $PitsEditTemplateFmt) ---- History: 0.1 - Initial version released by Pm with the disclaimers above 0.2 - By Didier Lebrun : * 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 ?) */ define(PITS_VERSION, '0.20'); # ---- 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($PitsIDLenght,5); ## 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, "
Author:
Summary:
Category:
Priority: Low High
PmWiki Version:
OS/Webserver/
PHP Version:
Description:
"); ## 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: ".strftime('%Y-%m-%d %H:%M',$Now)." Status: Open Category: \$category From: [[~\$author]] Assigned: Priority: \$priority Version: \$version OS: \$os Description: \$description ---- "); ## Template for list table. ## The "(/)PitsListItemFmt" tags MUST be present as delimiters of the entry part. SDV($PitsListTemplateFmt, "
Issue# Created Category Version Priority Status Summary
[[\$name]] \$created \$category \$version \$priority \$status \$summary
"); ## HTML styles SDV($PitsStylesFmt, " table.pitsform {} td.pitsformlabel { text-align:right; font-weight:bold; } td.pitsforminput {} div.pitspage {} span.pitspagelabel {} span.pitspagedata {} table.pitslist {} table.pitslist th a { text-decoration:none; } table.pitslist th { background-color:#eeeeee; } "); ## 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 ---- # $PitsGroup = FmtPageName('$Group',$pagename); $PitsGroupUrl = "$ScriptUrl/$PitsGroup"; $HTMLStylesFmt[] = $PitsStylesFmt; markup('pitsform','inline','/\\(:pitsform:\\)/e',"Keep(PitsForm(\$pagename))"); markup('pitslist','directive','/\\(:pitslist\\s*(.*?):\\)/e', "FmtPitsList('',\$pagename,array('q'=>PSS('$1')))"); markup('pitsread','directive','/^('.implode('|',array_keys($PitsLabels)).')\s*:(.*)/', "<:block>
$1:\ $2
"); include_once("$FarmD/scripts/author.php"); ## 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($pagename) { global $PitsFormTemplateFmt; $tmpl = preg_replace('/\s*\n\s*/','',$PitsFormTemplateFmt); $out = PitsEvalTemplate(array(),$tmpl); return FmtPageName($out,$pagename); } ## Fills the edit form with formatted input if ($action=='postpits') { Lock(2); foreach(ListPages("/^$PitsGroup\\.\\d/") as $i) $issue = max(@$issue,substr($i,strlen($PitsGroup)+1)); $pagename = sprintf("$PitsGroup.%0".$PitsIDLenght."d",@$issue+1); $action = 'edit'; $EditMessageFmt = $PitsEditMessageFmt; $_REQUEST['post'] = 1; $_POST['text'] = PitsEvalTemplate($_REQUEST,$PitsEditTemplateFmt); } ## FmtPitsList() creates a table of PITS issues according to various ## criteria. function FmtPitsList($fmt,$pagename,$opt) { global $PitsGroup,$PitsListTemplateFmt,$PitsLabels,$PitsHtmlEntitiesCharset, $PitsListFilters,$PitsListDefaultSort; $opt = array_merge($opt,@$_REQUEST); $pitslist = ListPages("/^$PitsGroup\\.\\d+$/"); $tmpl = preg_replace('/\s*\n\s*/','',$PitsListTemplateFmt); $sect = preg_split('#[[<]!--(/?(?:PitsListItemFmt)\\s?.*?)--[]>]#',$tmpl); if(count($sect)!=3) Abort("\$PitsListTemplateFmt MUST have 3 sections !"); $out[] = FmtPageName(array_shift($sect),$pagename); $terms = preg_split('/((?$v) $$k = $v; return(@eval("return(\"$tmpl\");")); } ?>