-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathBugzillaOutput.class.php
More file actions
102 lines (74 loc) · 2.75 KB
/
BugzillaOutput.class.php
File metadata and controls
102 lines (74 loc) · 2.75 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
abstract class BugzillaOutput {
public $response;
public function __construct($config, $options, $title='') {
$this->title = $title;
$this->config = $config;
$this->error = false;
$this->response = new stdClass();
$this->query = BugzillaQuery::create($config['type'], $options, $title);
}
protected function _render_error($error) {
$this->template = dirname(__FILE__) . '/templates/error.tpl';
ob_start(); // Start output buffering.
require($this->template);
return ob_get_clean();
}
public function fetch() {
$this->query->fetch();
}
public function render() {
if( $this->query->error ) {
return $this->_render_error($this->query->error);
}
// Get our template path
$this->template = dirname(__FILE__) . '/templates/' .
$this->config['type'] . '/' .
$this->config['display'] . '.tpl';
// Make sure a template is there
if( !file_exists($this->template) ) {
$this->error = 'Invalid type ' .
'(' . htmlspecialchars($this->config['type']) . ')' .
' and display ' .
'(' . htmlspecialchars($this->config['display']) . ')' .
' combination';
}
if( $this->error ) {
return $this->_render_error($this->error);
}
$this->setup_template_data();
$response = $this->response;
ob_start(); // Start output buffering.
require($this->template);
$results = ob_get_clean();
return $results;
}
abstract protected function setup_template_data();
}
class BugzillaNumber extends BugzillaOutput {
function setup_template_data() {
}
function _render_error($error) {
return '<span style="color: red;">Bugzilla: '.htmlspecialchars($error).'</span>';
}
function render() {
return '<span>'.count($this->query->data['bugs']).'</span>';
}
}
class BugzillaBugListing extends BugzillaOutput {
protected function setup_template_data() {
global $wgBugzillaDefaultFields;
$this->response->bugs = array();
$this->response->fields = array();
$this->response->full_query_url = $this->query->full_query_url();
// Set the bug data for the templates
if(isset($this->query->data['bugs']) && count($this->query->data['bugs']) > 0) {
$this->response->bugs = $this->query->data['bugs'];
}
$this->response->fields = $this->query->options['include_fields'];
}
}
class BugzillaList extends BugzillaBugListing {
}
class BugzillaTable extends BugzillaBugListing {
}