-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBugzillaOutput.class.php
More file actions
86 lines (62 loc) · 2.52 KB
/
BugzillaOutput.class.php
File metadata and controls
86 lines (62 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
require_once('smarty/Smarty.class.php');
abstract class BugzillaOutput {
public function __construct($config, $options, $title='') {
$this->title = $title;
$this->config = $config;
// Make our query and possibly fetch the data
$this->query = BugzillaQuery::create($config['type'], $options, $title);
//error_log($this->query);
//error_log($this->query->id());
//error_log(print_r($this->query->data, true));
}
protected function _render_error() {
$what = (!empty($this->error)) ? $this->error : 'Unknown Error';
return "<div class='bugzilla error'>Bugzilla Error: $what</div>";
}
public function render() {
global $wgBugzillaURL;
global $wgBugzillaSmartyTemplateDir;
global $wgBugzillaSmartyCompileDir;
global $wgBugzillaSmartyConfigDir;
global $wgBugzillaSmartyCacheDir;
// Get our template path
$this->template = dirname(__FILE__) . '/templates/' .
$this->config['type'] . '/' .
$this->config['display'] . '.tpl';
//error_log($this->template);
// Make sure a template is there
if( !file_exists($this->template) ) {
$this->error = 'Invalid type and display combination';
}
$this->smarty = new Smarty();
$this->smarty->assign('bz_url', $wgBugzillaURL);
$this->smarty->template_dir = $wgBugzillaSmartyTemplateDir;
$this->smarty->compile_dir = $wgBugzillaSmartyCompileDir;
$this->smarty->config_dir = $wgBugzillaSmartyConfigDir;
$this->smarty->cache_dir = $wgBugzillaSmartyCacheDir;
$this->_setup_template_data();
// Bail if we get any errors
if( isset($this->error) && !empty($this->error)) {
return $this->_render_error();
}
return $this->smarty->fetch($this->template);
}
}
class BugzillaTable extends BugzillaOutput {
public function _setup_template_data() {
$this->smarty->assign('bugs', $this->query->data->bugs);
}
}
class BugzillaGraph extends BugzillaOutput {
}
class BugzillaBarGraph extends BugzillaGraph {
public function _setup_template_data() {
$this->smarty->assign('type', 'bhs');
#$smarty->assign('type', 'p');
$this->smarty->assign('size', '200x300');
$this->smarty->assign('x_labels', implode('|', $this->query->data->x_labels));
$this->smarty->assign('data', implode(',', $this->query->data->data));
}
}
?>