-
Notifications
You must be signed in to change notification settings - Fork 6
/
driver_detail.php
362 lines (344 loc) · 11.7 KB
/
driver_detail.php
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<?php
include('inc/common.php');
if(empty($_GET['driver'])) {
header('Location: /drivers');
exit;
}
$drivertypes = array(
"ghostscript" => 'Ghostscript built-in',
"uniprint" => 'Ghostscript Uniprint',
"filter" => 'Filter',
"ijs" => 'IJS',
"cups" => 'CUPS Raster',
"opvp" => 'OpenPrinting Vector',
"postscript" => 'PostScript');
$driverparameters = array(
"text" => 'Text',
"lineart" => 'Line Art',
"graphics" => 'Graphics',
"photo" => 'Photo',
"load_time" => 'System Load',
"speed" => 'Speed');
$PAGE->setPageTitle('Driver: ' . $_GET['driver']);
$PAGE->setActiveID('driver');
$PAGE->addBreadCrumb('Drivers',$CONF->baseURL.'drivers/');
$PAGE->addBreadCrumb($_GET['driver']);
// Driver data
$res = $DB->query("SELECT * FROM driver WHERE id = ?", $_GET['driver']);
$driver = $res->getRow();
$SMARTY->assign('driver',$driver);
// Load driver printer assoc
$resDPA = $DB->query("SELECT dpa.*, p.make, p.model
FROM driver_printer_assoc dpa, printer p
WHERE driver_id = ?
AND p.id = dpa.printer_id", $_GET['driver']);
$driverPrinterAssoc = $resDPA->getRow();
$SMARTY->assign('driverPrinterAssoc',$driverPrinterAssoc);
// Load printers for this driver
$res = $DB->query("
SELECT pr.id AS id, make, model
FROM (SELECT dpa.printer_id AS id, p.make, p.model
FROM driver_printer_assoc dpa
LEFT JOIN printer p
ON p.id = dpa.printer_id
WHERE dpa.driver_id = ?) AS pr
ORDER BY pr.id, pr.make, pr.model ", $_GET['driver']);
$printers = $res->toArray('id');
// For unregistered printers (only mentioned in driver's printer list)
// make and model name are empty. Derive make and model name from the
// printer ID in such a case.
foreach($printers as $pr) {
if (strlen($pr['make']) == 0) {
$matches = array();
if (preg_match("/^([^\-]+)\-(.*)$/", $pr['id'], $matches) != 0) {
$printers[$pr['id']]['make'] =
preg_replace("/_+/", " ", $matches[1]);
$printers[$pr['id']]['model'] =
preg_replace("/_+/", " ", preg_replace("/plus\b/", "+", $matches[2]));
}
}
}
$SMARTY->assign('printers',$printers);
$res = $DB->query("SELECT *
FROM `driver_support_contact`
WHERE driver_id = ?", $_GET['driver']);
$contacts = $res->toArray();
$res = $DB->query("SELECT *
FROM `driver_package`
WHERE driver_id = ?", $_GET['driver']);
$packages = $res->toArray();
$packagedownloads = "";
$mask = "";
foreach($packages as $p) {
if (strlen($p['name']) > 0) {
$params =
(strlen($p['fingerprint']) > 0 ?
(strlen($p['scope']) > 0 ? "({$p['scope']}:" : "(general:") .
$p['fingerprint'] . ")" :
(strlen($p['scope']) > 0 ? "({$p['scope']})" : ""));
$pattern = preg_replace("/;/", ";$params", $p['name']);
$mask .= (strlen($mask) > 0 ? ";" : "") . $params . $pattern;
}
}
if (strlen($mask) <= 0) {
$mask = "{$_GET['driver']};openprinting-{$_GET['driver']};" .
"openprinting-ppds-{$_GET['driver']}";
}
$out = array();
exec("cd foomatic; ./packageinfo " . escapeshellarg($mask), $out, $ret_value);
if (sizeof($out) > 0)
$packagedownloads = $out[0];
$res = $DB->query("SELECT *
FROM `driver_dependency`
WHERE driver_id = ?", $_GET['driver']);
$dependencies = $res->toArray();
$infobox = "<p>" .
"<table border=\"0\" bgcolor=\"#f5f5f5\" cellpadding=\"1\"" .
"cellspacing=\"0\" width=\"100%\">" .
"<tr><td colspan=\"8\">" .
"<table border=\"0\" bgcolor=\"#eeeeee\" cellpadding=\"0\"" .
"cellspacing=\"0\" width=\"100%\">" .
"<tr valign=\"center\" bgcolor=\"#eeeeee\">" .
"<td width=\"2%\"></td>" .
"<td width=\"96%\"><font size=\"-4\"> " .
"</font></td><td width=\"2%\"></td></tr>" .
"<tr valign=\"center\" bgcolor=\"#eeeeee\">" .
"<td width=\"2%\"></td>" .
"<td width=\"96%\"><font size=\"+2\"><b>";
if ($driver['url']) {
$infobox .= "<a href=\"{$driver['url']}\">{$driver['name']}</a>";
} else {
$infobox .= "{$driver['name']}";
}
$infobox .= "</b></font></td><td width=\"2%\"></td></tr>" .
"<tr valign=\"center\" bgcolor=\"#eeeeee\">" .
"<td width=\"2%\"></td>" .
"<td width=\"96%\"><font size=\"-4\"> " .
"</font></td><td width=\"2%\"></td></tr>" .
"</table>" .
"</td></tr>";
if ($driver['obsolete']) {
$infobox .= "<tr valign=\"top\"><td width=\"2%\"></td>" .
"<td width=\"96%\" colspan=\"6\"><b><i><font size=\"-2\">" .
"This driver is obsolete. " .
"Recommended replacement driver: " .
"<a href=\"{$CONF->baseURL}driver/{$driver['obsolete']}/\">" .
"{$driver['obsolete']}</a>" .
"</font></i></b></td>" .
"<td width=\"2%\"></td></tr>";
}
if ($driver['shortdescription'] or $driver['supplier'] or
(strlen($driver['manufacturersupplied']) > 0 and
$driver['manufacturersupplied'] != "0") or
(strlen($driver['thirdpartysupplied']) > 0 and
$driver['thirdpartysupplied'] == "0") or
$driver['license'] or
$driver['licensetext'] or $driver['licenselink'] or
strlen($driver['nonfreesoftware']) > 0 or
(strlen($driver['patents']) > 0 and
$driver['patents'] != "0")) {
$infobox .= "<tr valign=\"top\"><td width=\"2%\"></td>" .
"<td width=\"96%\" colspan=\"6\"><font size=\"-2\">";
if ($driver['shortdescription']) {
$infobox .= "<b>{$driver['shortdescription']}</b><br>";
}
if ($driver['supplier'] or
(strlen($driver['manufacturersupplied']) > 0 and
$driver['manufacturersupplied'] != "0") or
(strlen($driver['thirdpartysupplied']) > 0 and
$driver['thirdpartysupplied'] == "0")) {
if ($driver['supplier']) {
$infobox .= "Supplier: {$driver['supplier']}";
if ((strlen($driver['manufacturersupplied']) > 0 and
$driver['manufacturersupplied'] != "0") or
(strlen($driver['thirdpartysupplied']) > 0 and
$driver['thirdpartysupplied'] == "0")) {
$infobox .= " (printer manufacturer)";
}
} else {
$infobox .= "Supplied by printer manufacturer";
}
$infobox .= "<br>";
}
if ($driver['license'] or
$driver['licensetext'] or $driver['licenselink'] or
strlen($driver['nonfreesoftware']) > 0) {
if ($driver['license']) {
$infobox .= "License: {$driver['license']}";
if (strlen($driver['nonfreesoftware']) > 0 and
$driver['nonfreesoftware'] != "0") {
$infobox .= " (non-free software";
} else {
$infobox .= " (free software";
}
if ($driver['licensetext'] or
$driver['licenselink']) {
$infobox .= ", ";
if ($driver['licenselink']) {
$infobox .= "<a href=\"{$driver['licenselink']}\">";
} else {
$infobox .=
"<a href=\"{$CONF->baseURL}driver/" .
"{$driver['name']}/license/\">";
}
$infobox .= "show license text</a>)";
} else {
$infobox .= ")";
}
} else {
if (strlen($driver['nonfreesoftware']) > 0 and
$driver['nonfreesoftware'] != "0") {
$infobox .= "This driver is non-free software";
} else {
$infobox .= "This driver is free software";
}
if ($driver['licensetext'] or
$driver['licenselink']) {
$infobox .= " (";
if ($driver['licenselink']) {
$infobox .= "<a href=\"{$driver['licenselink']}\">";
} else {
$infobox .= "<a href=\"{$CONF->baseURL}driver/" .
"{$driver['name']}/license/\">";
}
$infobox .= "show license text</a>).";
} else {
$infobox .= ".";
}
}
$infobox .= "<br>";
}
if (strlen($driver['patents']) and $driver['patents'] != "0") {
$infobox .= "<b> This driver contains algorithms " .
"which are (possibly) patented";
if ($driver['licensetext'] or
$driver['licenselink']) {
$infobox .= " (See ";
if ($driver['licenselink']) {
$infobox .= "<a href=\"{$driver['licenselink']}\">";
} else {
$infobox .= "<a href=\"{$CONF->baseURL}driver/" .
"{$driver['name']}/license/\">";
}
$infobox .= "license text</a>).";
} else {
$infobox .= ".";
}
$infobox .= "</b><br>";
}
$infobox .= "</font></td>" .
"<td width=\"2%\"></td></tr>";
}
if (is_array($contacts) and count($contacts) > 0) {
$infobox .= "<tr valign=\"top\"><td width=\"2%\"></td>" .
"<td width=\"16%\"><font size=\"-2\">" .
"User support:" .
"</font></td>" .
"<td width=\"80%\" colspan=\"5\"><font size=\"-2\">";
foreach ($contacts as $c)
if ($c['description'])
$infobox .= "<a href=\"{$c['url']}\">{$c['description']}</a>" .
" ({$c['level']})<br>";
$infobox .= "</td>" .
"<td width=\"2%\"></td></tr>";
}
if ($driver['max_res_x'] or $driver['max_res_y'] or
strlen($driver['color']) > 0 or strlen($driver['execution']) > 0) {
$infobox .= "<tr valign=\"top\"><td width=\"2%\"></td>" .
"<td width=\"96%\" colspan=\"6\"><font size=\"-2\">";
if ($driver['max_res_x'] or $driver['max_res_y']) {
if ($driver['max_res_x'])
$xr = $driver['max_res_x'];
else
$xr = $driver['max_res_y'];
if ($driver['max_res_y'])
$yr = $driver['max_res_y'];
else
$yr = $driver['max_res_x'];
$infobox .= "Max. rendering resolution: {$xr}x{$yr}dpi ";
}
if (strlen($driver['color']) > 0) {
if ($driver['color'] == "0") {
$infobox .= "Only monochrome output ";
} else {
$infobox .= "Color output ";
}
}
if (strlen($driver['execution']) > 0) {
$infobox .= "Type: {$drivertypes[$driver['execution']]}";
}
$infobox .= "</font></td>" .
"<td width=\"2%\"></td></tr>";
}
if (strlen($driver['text']) > 0 or strlen($driver['lineart']) > 0 or
strlen($driver['graphics']) > 0 or strlen($driver['photo']) > 0 or
strlen($driver['load_time']) > 0 or strlen($driver['speed']) > 0) {
$infobox .= "<tr valign=\"top\"><td width=\"2%\"></td>";
foreach(array('text', 'graphics', 'load_time',
'lineart', 'photo', 'speed') as $par) {
$infobox .= "<td width=\"16%\"><font size=\"-2\">" .
"{$driverparameters[$par]}:</font></td>" .
"<td width=\"16%\"><font size=\"-2\">";
if (strlen($driver[$par]) > 0) {
$value = $driver[$par];
if ($value <= 33) {
$color = "red";
} elseif ($value <= 66) {
$color = "orange";
} else {
$color = "green";
}
$units = $value / 10;
$infobox .= "<font color=\"$color\">";
for ($i = 0; $i < $units; $i ++) $infobox .= "|";
$infobox .= "</font><font color=\"#ffffff\">";
for ($i = $units; $i < 10; $i ++) $infobox .= "|";
$infobox .= "</font> $driver[$par]</font></td>";
} else {
$infobox .= "Unknown</font></td>";
}
if ($par == 'load_time') {
$infobox .= "<td width=\"2%\"></td></tr>" .
"<tr valign=\"top\"><td width=\"2%\"></td>";
}
}
$infobox .= "<td width=\"2%\"></td></tr>";
}
if ($packagedownloads != "") {
$infobox .= "<tr valign=\"top\"><td width=\"2%\"></td>" .
"<td width=\"16%\"><font size=\"-2\"><b>" .
"Download:" .
"</b></font></td>" .
"<td width=\"80%\" colspan=\"5\"><font size=\"-2\">" .
"Driver packages: {$packagedownloads}" .
"<font size=\"-3\">" .
" (<a href=\"http://www.linux-foundation.org/en/OpenPrinting/Database/DriverPackages\">" .
"How to install</a>)</font><br>" .
"</font></td>" .
"<td width=\"2%\"></td></tr>";
}
if (is_array($dependencies) and count($dependencies) > 0) {
$infobox .= "<tr valign=\"top\"><td width=\"2%\"></td>" .
"<td width=\"16%\"><font size=\"-2\">" .
"<b>Dependencies:</b>" .
"</font></td>" .
"<td width=\"80%\" colspan=\"5\"><font size=\"-2\">" .
"To use this driver the following drivers " .
"need also to be installed: ";
foreach ($dependencies as $d)
if (strlen($d['required_driver']) > 0)
$infobox .= "<a href=\"{$CONF->baseURL}driver/" .
"{$d['required_driver']}\">{$d['required_driver']}</a>" .
" ({$d['version']}), ";
$infobox = substr($infobox, 0, -2);
$infobox .= "</td>" .
"<td width=\"2%\"></td></tr>";
}
$infobox .= "<tr>" .
"<td width=\"2%\"></td>" .
"<td width=\"96%\" colspan=\"6\"><font size=\"-4\"> " .
"</font></td><td width=\"2%\"></td></tr>" .
"</table></p><p></p>";
$SMARTY->assign('driverinfobox', $infobox);
$SMARTY->display('drivers/detail.tpl');
?>