|
1 | 1 | <?php
|
2 |
| -include('common.php'); |
3 |
| -$page = $repo . '/issues'; |
4 |
| - |
5 |
| -if (!isset($_REQUEST['id']) && !isset($_REQUEST['new'])) { |
6 |
| - |
7 |
| - //================================================================= |
8 |
| - //====: Display list of tickets :================================== |
9 |
| - //================================================================= |
10 |
| - |
| 2 | +function display_ticket_list() { |
11 | 3 | echo '
|
12 | 4 | <h1 class="imgtitle imgtitle-32">
|
13 | 5 | <img alt="" src="tickets.png"> Tickets
|
|
88 | 80 | }
|
89 | 81 |
|
90 | 82 | echo "</table>";
|
91 |
| - |
92 |
| -} |
93 |
| -else if (!isset($_REQUEST['new'])) { |
94 |
| - |
95 |
| - //================================================================= |
96 |
| - //====: Display individual ticket :================================ |
97 |
| - //================================================================= |
98 |
| - |
99 |
| - $issue = $_REQUEST['id']; |
100 |
| - $js = json_decode(getPage($page . '/' . $issue)); |
101 |
| - |
102 |
| - // This is the regexp we use to check if the comment is from our forum. |
103 |
| - $pregstr = '/^\(Posted by !?\[.*?\]\(' . preg_quote($forum_url, '/') . '\?action=profile;u=([0-9]+)\) on ' . $forum_name . '\)/'; |
104 |
| - |
105 |
| - $from_forums = false; |
106 |
| - $js->user->url = 'http://github.org/' . $js->user->login; |
107 |
| - if ($js->user->login == $gh_username) { |
108 |
| - $num = array(); |
109 |
| - preg_match('/\[u([0-9]+)\]$/',$js->title,$num); |
110 |
| - if (array_key_exists(1,$num)) { |
111 |
| - $from_forums = true; |
112 |
| - $nid = $num[1] + 0; |
113 |
| - if (($lmd = loadMemberData(array($nid))) !== false) { |
114 |
| - $lmc = loadMemberContext($lmd[0]); |
115 |
| - $author_info = $memberContext[$lmd[0]]; |
116 |
| - $js->user->login = $author_info['name']; |
117 |
| - $avaurl = $author_info['avatar']['href']; |
118 |
| - if (!empty($avaurl)) |
119 |
| - $js->user->avatar_url = $avaurl; |
120 |
| - $js->user->url = $forum_url . '?action=profile;u=' . $author_info['id']; |
121 |
| - |
122 |
| - // Remove (Posted by ...) message |
123 |
| - $match = array(); |
124 |
| - preg_match($pregstr, $js->body, $match); |
125 |
| - if (array_key_exists(1,$match)) |
126 |
| - $js->body = substr($js->body, strlen($match[0])); |
127 |
| - } |
128 |
| - } |
129 |
| - } |
130 |
| - |
131 |
| - /* echo ' |
132 |
| - |
133 |
| - <h1> |
134 |
| - <a href="index.php"><img alt="" src="tickets.png" style="vertical-align:middle"></a> ' . $js->title . ' |
135 |
| - </h1><br/> |
136 |
| - '; */ |
137 |
| - |
138 |
| - // Fetch comments |
139 |
| - $comments = json_decode(getPage($page . '/' . $issue . '/comments')); |
140 |
| - $bodies = array(); |
141 |
| - foreach ($comments as $ind => $comment) { |
142 |
| - $comment->forum_user = false; |
143 |
| - if ($comment->user->login == $gh_username) { |
144 |
| - $match = array(); |
145 |
| - preg_match($pregstr,$comment->body,$match); |
146 |
| - if (array_key_exists(1,$match)) { |
147 |
| - $bodies[$ind] = substr($comment->body, strlen($match[0])); |
148 |
| - $nid = $match[1] + 0; |
149 |
| - if (($lmd = loadMemberData(array($nid))) !== false) { |
150 |
| - $lmc = loadMemberContext($lmd[0]); |
151 |
| - $comment->forum_user = true; |
152 |
| - $author_info = $memberContext[$lmd[0]]; |
153 |
| - $comment->user->login = $author_info['name']; |
154 |
| - $avaurl = $author_info['avatar']['href']; |
155 |
| - if (!empty($avaurl)) |
156 |
| - $comment->user->avatar_url = $avaurl; |
157 |
| - $comment->user->url = $forum_url . '?action=profile;u=' . $author_info['id']; |
158 |
| - } |
159 |
| - } |
160 |
| - else { // No match? Push the regular comment body. |
161 |
| - // This should normally not happen, unless the bot that made the post is also a regular poster. |
162 |
| - $bodies[$ind] = 'UNMATCHED: ' . $comment->body; |
163 |
| - echo '<div id="down">Match failure.<br/><textarea cols="128" rows="1">' . $pregstr . '</textarea><br/><textarea cols="128" rows="1">' . $comment->body . '</textarea></div>'; |
164 |
| - } |
165 |
| - } |
166 |
| - else { // Regular comment body. |
167 |
| - $bodies[$ind] = $comment->body; |
168 |
| - $comment->user->url = 'http://github.org/' . $comment->user->login; |
169 |
| - } |
170 |
| - } |
171 |
| - |
172 |
| - // Parse the markdown of the $bodies array and $js->body |
173 |
| - $bodies2 = $bodies; |
174 |
| - $bodies2[] = $js->body; |
175 |
| - $bodies2 = markdown($bodies2); |
176 |
| - |
177 |
| - // Print the issue |
178 |
| - echo '<div id="issueheader">'; |
179 |
| - echo '<div id="issueavatar">'; |
180 |
| - echo '<a style="vertical-align:middle;" href="' . $js->user->url . '"><img src="' |
181 |
| - . $js->user->avatar_url . '" style="vertical-align:middle;" alt="" width="64" height="64"></a>'; |
182 |
| - echo '</div><div id="issueinfo">'; |
183 |
| - echo '<h1 style="padding: 2px 0;"><a href="?">' . $js->title . '</a></h1>'; |
184 |
| - echo 'Reporter: <a href="' . $js->user->url . '"'; |
185 |
| - if (!$from_forums) echo ' style="font-style:italic"'; |
186 |
| - echo '>' . $js->user->login . '</a> | '; |
187 |
| - echo 'Status: ' . $js->state . ' | '; |
188 |
| - echo 'Last Modified: ' . timeformat(strtotime($js->updated_at)); |
189 |
| - echo '<hr/></div>'; |
190 |
| - echo '</div>'; |
191 |
| - echo '<div style="padding: 4px 32px">' . $bodies2[count($bodies2) - 1] . '</div>'; |
192 |
| - |
193 |
| - // Output each comment |
194 |
| - foreach ($comments as $ind => $comment) { |
195 |
| - echo '<div class="commenthead">'; |
196 |
| - echo '<img src="' . $comment->user->avatar_url |
197 |
| - . '" alt="" style="vertical-align:middle;" width="16" height="16" /> '; |
198 |
| - echo '<a style="vertical-align:middle;' . ($comment->forum_user? '' : ' font-style:italic;') |
199 |
| - . '" href="' . $comment->user->url . '">' . $comment->user->login . '</a> '; |
200 |
| - echo '<time class="timefield" datetime="' . $comment->created_at . '" pubdate="" title="' . $comment->created_at . '" >' |
201 |
| - . timeformat(strtotime($comment->created_at)) . '</time>'; // This was supposed to be a nicely formated F j, Y; ie, December 21, 2012. |
202 |
| - //. (new DateTime($dateTimeString))->format('F j, Y') . '</time>'; |
203 |
| - echo '</div>'; |
204 |
| - echo '<div style="padding: 0 32px">' . $bodies2[$ind] . '</div>'; |
205 |
| - } |
206 |
| - |
207 |
| - // Place to leave a comment |
208 |
| - echo '<div class="commenthead">Leave a comment'; |
209 |
| - echo '<a style="float:right;" href="https://github.com/' . $orgrepo . '/issues/' . $issue . '">View this issue on GitHub</a>'; |
210 |
| - echo '</div>'; |
211 |
| - |
212 |
| - if ($context['user']['is_logged']) { |
213 |
| - $avi = isset($context['user']['avatar']['image']) ? $context['user']['avatar']['image'] : ""; |
214 |
| - echo '<form method="post" action="post.php">'; |
215 |
| - echo '<table id="postformtable"><tbody><tr><td rowspan="2" id="useravatar">' |
216 |
| - . ($avi) . '</td>'; |
217 |
| - // Formatting buttons |
218 |
| - echo '<td>'; |
219 |
| - include("editorbuttons.php"); |
220 |
| - echo '<input type="hidden" name="id" value="' . $issue . '" />' |
221 |
| - . '<input type="submit" value="Post comment" style="float:right"></td></tr>'; |
222 |
| - echo '<tr><td><textarea name="body" id="commentfield" rows="4" style="width: 100%" placeholder="Leave a comment via ' . $forum_name . '">' |
223 |
| - . '</textarea></td></tr></tbody></table>'; |
224 |
| - echo '</form>'; |
225 |
| - } |
226 |
| - else { |
227 |
| - echo 'Please sign in to post comments, or you can <a href="https://github.com/' . $orgrepo . '/issues/' . $issue . '">view this issue on GitHub.'; |
228 |
| - } |
229 |
| -} |
230 |
| -else { |
231 |
| - if ($context['user']['is_logged']) { |
232 |
| - echo '<form method="post" action="post.php">'; |
233 |
| - echo '<div id="issueheader"><div id="issueavatar">'; |
234 |
| - echo $context['user']['avatar']['image']; |
235 |
| - echo '</div><div id="issueinfo">'; |
236 |
| - echo '<h1 style="padding: 2px 0;"><div style="float:left">Title:</div> '; |
237 |
| - echo '<div style="margin-left:64px; margin-right:100px;">' |
238 |
| - . '<input type="text" name="title" style="width:100%" placeholder="A succinct title for your issue or suggestion"/>' |
239 |
| - . '</div></h1>'; |
240 |
| - echo '<div style="float:left;">Labels:</div><div style="margin-left:48px; margin-right:100px;">' |
241 |
| - . '<input type="text" name="labels" style="width:100%" placeholder="Comma separated; eg, Parser, Event System, Compile Error"/></div>'; |
242 |
| - echo '<hr/></div></div>'; |
243 |
| - |
244 |
| - echo '<div style="display:block; clear:both; padding-top: 12px;">'; |
245 |
| - include('editorbuttons.php'); |
246 |
| - echo '<input type="submit" value="Post issue" style="float:right">'; |
247 |
| - echo '<br/>'; |
248 |
| - echo '<textarea name="body" id="commentfield" style="width: 100%" rows="15" ' |
249 |
| - . 'placeholder="Enter a description of your issue or suggestion here. Be thorough first, and brief second."' |
250 |
| - . '></textarea>'; |
251 |
| - echo '</div>'; |
252 |
| - } |
253 |
| - else { |
254 |
| - echo 'Please sign in to post comments; or you can <a href="https://github.com/' . $orgrepo . '/issues/">view these issues on GitHub</a>.'; |
255 |
| - } |
256 | 83 | }
|
257 | 84 |
|
258 | 85 | ?>
|
|
0 commit comments