-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjob.diff.inc
94 lines (76 loc) · 1.61 KB
/
job.diff.inc
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
<?php
require_once 'class.Diff.php';
function boa_job_diff($jobId, $oldJobId) {
if (!isValidJob($jobId))
if (!boa_public_access($jobId))
invalidJob($jobId);
if (!isValidJob($oldJobId))
if (!boa_public_access($oldJobId))
invalidJob($oldJobId);
$jobSrc = getSrc($jobId);
$oldJobSrc = getSrc($oldJobId);
echo <<<HTML
<html>
<head>
<style type="text/css">
.titlebar {
position: fixed;
top: 0px;
width: 50%;
height: 1.5em;
background-color: #fff;
margin-top: 0px;
border-bottom: 1px solid #000;
line-height: 1.5em;
}
.diff {
width: 100%;
margin-top: 3em;
border-collapse: collapse;
}
.diff td {
width: 50%;
padding: 0 1em;
vertical-align: top;
white-space: pre;
white-space: pre-wrap;
font-family: Consolas,'Courier New',Courier,monospace;
font-size: 0.75em;
border-left: 1px solid #fff;
}
.diff td:last-child {
border-left: 1px solid #000;
}
.diff span {
padding: 0 3px;
}
.diff span:first-child {
margin-top: 0;
}
.diffDeleted {
border: 1px solid rgb(255,192,192);
background: rgb(255,224,224);
}
.diffInserted {
border: 1px solid rgb(192,255,192);
background: rgb(224,255,224);
}
</style>
</head>
<body>
<h1 class="titlebar">Diff from job <a href="?q=boa/job/$oldJobId">$oldJobId</a></h1><h1 class="titlebar" style="left: 50%;">to job <a href="?q=boa/job/$jobId">$jobId</a></h1>
HTML;
echo Diff::toTable(Diff::compare($oldJobSrc, $jobSrc));
echo <<<HTML
</body>
</html>
HTML;
drupal_exit();
}
function getSrc($jobId) {
$query = db_select('boa_jobs', 'r');
$query->fields('r', array('source'));
$query->condition('id', $jobId);
return $query->execute()->fetchObject()->source;
}
?>