Extension talk:Jira Ticket
From MediaWiki.org
[edit] Patchversion
works fine. for others: The code must be (copy and paste 1:1)
<?php /** * Links a single Jira ticket with status and priority into an article. * * Author : David Seymore with RNSolutions * Version : 2008-03-11 * License : GPLv2 * * Modified by Stephane GALLAND * 2010-07-19 for janus-project.org usage. */ if( !defined( 'MEDIAWIKI' ) ) { echo(" This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); die( -1 ); } #SETUP - we need to know which thing we are looking at $jiraHost='http://localhost'; $jiraUser=''; $jiraPass=''; $wgExtensionCredits['other'][] = array( 'name' => 'JiraTicket', 'author' => array('David Seymore', 'Stephane Galland'), 'url' => 'http://www.mediawiki.org/wiki/Extension:Jira_Ticket', 'description' => 'Jira Status & Priority icon parser.', 'description' => 'Jira Status & Priority icon parser, modifier to work on janus-project.org.', ); $wgExtensionFunctions[] = "wfSetupJiraTicket"; function wfSetupJiraTicket() { global $wgParser; # register the extension with the WikiText parser # the first parameter is the name of the new tag. # In this case it defines the tag <jira>GS-1</jira> # the second parameter is the callback function for # processing the text between the tags $wgParser->setHook( 'jira', 'jiraTicket_render' ); } # The callback function for converting the input text to HTML output function jiraTicket_render( $input='', $argv='', $parser=null, $frame ) { global $jiraHost, $jiraUser, $jiraPass; # You can disable the cache, but, rememeber that this'll hit jira everytime the page is read.. not exactly that smart # resaving an article will automatically pull down the fresh status of the jira ticket. # $parser->disableCache(); # In case we are being called from within a template, we must first expand the parameter: $issueId = $parser->recursiveTagParse( $input, $frame ); $jiraUrl = "$jiraHost/rpc/soap/jirasoapservice-v2?wsdl"; try { $jiraSoap = new SoapClient($jiraUrl); $auth = $jiraSoap->login($jiraUser,$jiraPass); $issue = $jiraSoap->getIssue($auth,$issueId); } catch(Exception $e) { return "<!-- ".$e->getMessage(). " --><span title=\"".$e->getMessage()."\"><s>$issueId</s></span>"; } $issuelabel = "$issueId"; $output1 = '<a href="'.$jiraHost.'/browse/'.$issueId.'" alt="'.$issue->summary.'" title="'.$issue->summary.'">'; $output2 = '</a> <img src="'.$jiraHost.'/images/icons/status_'; #The status switch.. you may have reconfigured your custom statuses, so, edit here.. switch($issue->status){ case 1: $output2 .= 'open'; break; case 3: $output2 .= 'inprogress'; break; case 4: $output2 .= 'reopened'; break; case 5: $output2 .= 'resolved'; $issuelabel = "<s>$issuelabel</s>"; break; case 6: $output2 .= 'closed'; $issuelabel = "<s>$issuelabel</s>"; break; default: $output2 .= $issue->status; break; } $output2 .= '.gif">'; #The priority switch... you may have reconfigured your custom priorities, so, edit here... $output2 .= '<img src="'.$jiraHost.'/images/icons/priority_'; switch($issue->priority){ case 1: $output2 .= 'blocker'; break; case 2: $output2 .= 'critical'; break; case 3: $output2 .= 'major'; break; case 4: $output2 .= 'minor'; break; case 5: $output2 .= 'trivial'; break; default: $output2 .= $issue->priority; break; } $output2 .= '.gif">'; return "$output1$issuelabel$output2"; } ?>