. if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); require_once('cUrlHelper.php'); require_once('BzBug.php'); class syntax_plugin_bugzillaHTTP extends DokuWiki_Syntax_Plugin { private $starttime; private $endtime; function getInfo(){ return array( 'author' => 'andreas parschalk', 'email' => 'dprskavec@gmail.com', 'date' => '2012-08-17', 'name' => 'bugzilla http plugin', 'desc' => 'Gets information about bugs via HTTP (xml-view).', 'url' => 'http://www.dokuwiki.org/plugin:bugzillaHTTP', ); } function getType() { return 'substition'; } function getPType() { return 'normal'; } function getSort() { return 777; } function connectTo($mode) { $this->Lexer->addSpecialPattern('^\[buglist\s*\|\s*\d+\s*(?:\s*,\s*\d+)*\s*\]', $mode, 'plugin_bugzillaHTTP'); } function fetchBugs($idString) { // $this->starttime = microtime(true); $url = $this->getConf('bug_xml_url'); $url .= $idString; $curl = new cUrlHelper(); $content = $curl->fetchContent($url); $bug = new BzBug(); $buglist = $bug->unmarshall($content); // $this->endtime = microtime(true); return $buglist; } function handle($match, $state, $pos, &$handler) { preg_match('/^\[buglist\s*\|([\s(\d),]+)\]/', $match, $submatch); $idString = preg_replace('/\s/', '', $submatch[1]); return $idString; } function uncachedHandle($idString) { return $this->fetchBugs($idString); } function render($mode, &$renderer, $idString) { $bugData = $this->uncachedHandle($idString); //var_dump($bugData); $url = $this->getConf('bug_url'); if($mode == 'xhtml'){ // render tableheader $bugtable = ''; //print_r($data_bugs); foreach($bugData as $bug) { $rowclass = "bugtable_".$bug->getPriority(); if ($bug->getStatus() === 'CLOSED') { $rowclass = "bugtable_closed"; } if ($bug->getStatus() === 'VERIFIED') { $rowclass = "bugtable_verified"; } if ($bug->getStatus() === 'RESOLVED') { $rowclass = "bugtable_resolved"; } $bugtable .= ''; $bugtable .= ''; $bugtable .= ''; } $bugtable .= '
IDPRISEVASSIGNEESTATUSSHORT DESCRIPTION
'.$bug->getId().''.$bug->getPriority().''.$bug->getSeverity().''. $bug->getAssignedTo().''.$bug->getStatus().''.$bug->getShortDesc().'
'; $renderer->doc .= $bugtable; // $renderer->doc .= 'fetchted buglist in '.($this->endtime - $this->starttime) .'s'; return true; } return false; } } ?>