forked from mysociety/theyworkforyou
/
glossary.php
150 lines (123 loc) · 4.33 KB
/
glossary.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
<?php
/* Remember, we are currently within the GLOSSARYLIST class,
in the render() function.
We cycle through the $data array and output the comment(s).
It should be something like this:
$data = array (
'info' => array (
'user_id' => '34' // Might be used to highlight the user's comments.
),
'terms' => array (
0 => array (
'comment_id' => '1',
'user_id' => '4',
'epobject_id' => '304',
'body' => 'My comment goes here...',
'posted' => '2003-12-31 23:00:00',
'firstname' => 'Guy',
'lastname' => 'Fawkes',
'url' => '/permalink/to/this/comment/?id=304#c1',
'hbody' => 'To answer the honourable gentleman...',
'major' => 1,
),
1 => array (
etc....
)
)
);
*/
global $PAGE, $DATA, $this_page, $THEUSER;
// Something's telling me these subheadings shouldn't be in this template...!
if (isset($data['comments'][0]['preview']) && $data['comments'][0]['preview'] == true) {
// If we're just previewing a comment, we passed in 'preview' => true.
$subheading = 'Your annotation would look like this:';
} elseif ($this_page == 'addcomment') {
$subheading = 'Previous annotations';
} elseif ($this_page == 'commentreport' || $this_page == 'admin_commentreport') {
$subheading = "";
} else {
$subheading = 'Annotations';
}
?>
<div class="comments" id="comments">
<a name="comments"></a>
<?php if ($subheading != '') { echo "<h4>$subheading</h4>"; }?>
<?php
if (isset($data['comments']) && count($data['comments']) > 0) {
foreach ($data['comments'] as $n => $comment) {
$style = $n % 2 == 0 ? '1' : '2';
if (isset($data['info']['user_id']) &&
$comment['user_id'] == $data['info']['user_id']) {
$style .= '-on';
}
?>
<div class="block<?php echo $style; ?>"<?php
if (isset($comment['comment_id'])) {
?> id="c<?php echo $comment['comment_id']; ?>"><a name="c<?php echo $comment['comment_id']; ?>"></a>
<?php
} else {
echo ">\n";
}
$USERURL = new URL('userview');
$USERURL->insert(array('u'=>$comment['user_id']));
?>
<div class="comment">
<p><a href="<?php echo $USERURL->generate(); ?>" title="See information about this user"><strong><?php echo _htmlentities($comment['firstname']) .' '. _htmlentities($comment['lastname']); ?></strong></a><br>
<?php
// Make URLs into links and do <br>s.
$body = prepare_comment_for_display($comment['body']); // In utility.php
echo $body;
?></p>
</div>
<div class="sidebar">
<p> Posted on
<?php
list($date, $time) = explode(' ', $comment['posted']);
$date = format_date($date, SHORTDATEFORMAT);
$time = format_time($time, TIMEFORMAT);
echo $date; ?>,
<?php
if (isset($comment['url'])) {
?>
<a href="<?php echo $comment['url']; ?>" title="Link to this annotation"><?php echo $time; ?></a>
<?php
} else {
// There won't be a URL when we're just previewing a comment.
echo "\t\t$time";
}
if (($this_page != 'commentreport' &&
$this_page != 'addcomment' &&
$this_page != 'admin_commentreport')
&& $THEUSER->is_able_to('reportcomment')
&& !$comment['modflagged']
) {
// The comment hasn't been reported and we're on a page where we want to
// display this link.
$URL = new URL('commentreport');
$URL->insert(array(
'id' => $comment['comment_id'],
'ret' => $comment['url']
));
?><br>
<a href="<?php echo $URL->generate(); ?>" title="Notify moderators that this annotation needs editing or deleting">Report this annotation</a>
<?php
} elseif ($comment['modflagged']) {
?><br>
This annotation has been reported
<?php
}
?>
</p>
</div>
<div class="break"> </div>
</div>
<?php
}
} else {
?>
<p>No annotations</p>
<?php
}
?>
<div class="break"></div>
</div> <!-- end comments -->