/
home.php
388 lines (328 loc) · 15.5 KB
/
home.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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<?php
/** @file home.php Implements the dengine.net homepage.
*
* @authors Copyright © 2009-2013 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/
includeGuard('HomePlugin');
require_once(DIR_CLASSES.'/requestinterpreter.interface.php');
require_once(DIR_CLASSES.'/visual.interface.php');
class HomePlugin extends Plugin implements Actioner, RequestInterpreter
{
public static $name = 'Home Plugin';
private static $title = 'Doomsday Engine';
public function title()
{
return self::$title;
}
/// Implements RequestInterpreter
public function InterpretRequest($request)
{
$url = urldecode($request->url()->path());
// @todo kludge: skip over the first '/' in the home URL.
$url = substr($url, 1);
// Remove any trailing file extension, such as 'something.html'
if(strrpos($url, '.'))
$url = substr($url, 0, strrpos($url, '.'));
// Our only action will be to display a page to the user.
FrontController::fc()->enqueueAction($this, NULL);
return true; // Eat the request.
}
/// Implements Actioner.
public function execute($args=NULL)
{
$fc = &FrontController::fc();
$fc->outputHeader();
$fc->beginPage($this->title());
includeHTML('latestversion', 'z#home');
?><div id="contentbox"><?php
//includeHTML('introduction', 'z#home');
?><script>
(function (e) {
e.fn.interpretMasterServerStatus = function (t) {
var n = {
serverUri: "http://dengine.net/master.php?xml",
maxItems: 3,
generateServerSummaryHtml: 0
};
if (t) {
e.extend(n, t);
}
var r = e(this).attr("id");
e.ajax({
url: n.serverUri,
dataType: 'xml',
success: function (t) {
e("#" + r).empty();
var root = $('masterserver', t);
var serverList = root.find('serverlist')[0];
var serverCount = serverList.attributes.getNamedItem('size').nodeValue;
var d = new Date(root.find('channel>pubdate').text());
var niceDate = $.datepicker.formatDate('MM d, yy', d);
var minItems = serverCount < n.maxItems? serverCount : n.maxItems;
var announceTime = d.toLocaleTimeString();
var html = '<header>'
+ '<h1><a href="/masterserver" title="View the complete list in the server browser">'
+ (serverCount > 0? ('Most active servers '
+ '<label title="Result limit">' + minItems + '</label>/<label title="Total number of servers">' + serverCount + '</label>')
: 'No active servers')
+ '</a></h1>'
+ '<p>' + niceDate + ' @ <label title="' + announceTime + ' (time of the last server announcement)">' + announceTime + '</label></p></header>';
if(serverCount) {
var idx = 0;
var playerCount = 0;
html += '<ol class="servers">';
for(var i = 0; i < serverList.childNodes.length; ++i) {
if(serverList.childNodes[i].nodeName != 'server')
continue;
var server = $(serverList.childNodes[i]);
if(n.maxItems <= 0 || idx < n.maxItems)
{
html += '<li>' + n.generateServerSummaryHtml(n, server) + '</li>';
}
playerCount += Number(server.find('gameinfo>numplayers').text());
idx++;
};
html += '</ol>';
//html += '<span class="summary"><a href="/masterserver" title="See the full listing in the server browser">' + serverCount + ' ' + (serverCount == 1? 'server':'servers') + ' in total, ' + playerCount + ' active ' + (playerCount == 1? 'player':'players') + '</a></span>';
}
e("#" + r).append(html);
}
})
}
})(jQuery)
$(document).ready(function () {
$('#activeservers').interpretMasterServerStatus({
generateServerSummaryHtml: function (n, info) {
var name = info.find('name').text();
var status = info.children('open').text() == 'yes'? 'open' : 'locked';
var serverMetadataLabel = 'I.P address ' + info.children('ip').text() + ', port ' + info.children('port').text()
+ ', ' + status;
// Any required addons?.
/*var addonArr = array_filter(explode(';', info['pwads']));
if(count(addonArr))
{
serverMetadataLabel .= 'Add-ons: '. implode(' ', addonArr);
}*/
var gameInfo = $(info.children('gameinfo'));
var gameMode = gameInfo.children('mode').text();
var mapId = gameInfo.children('map').text();
if(mapId.substring(0, 3) == 'MAP')
{
mapId = 'map ' + mapId.substring(3);
}
else if(mapId.substring(0, 1) == 'E' && mapId.substring(2, 3) == 'M')
{
mapId = 'episode ' + mapId.substring(1, 2) + ', map ' + mapId.substring(3, 4);
}
else
{
mapId = 'map \'' + mapId + '\'';
}
var gameRules = gameInfo.children('setupstring').text().split(/[ ,]+/);
for(var i=0; i < gameRules.length; i++)
{
if(gameRules[i] == 'dm')
gameRules[i] = 'deathmatch';
else if(gameRules[i] == 'coop')
gameRules[i] = 'co-operative';
else if(gameRules[i] == 'nomonst')
gameRules[i] = 'no monsters';
else if(gameRules[i] == 'jump')
gameRules[i] = 'jump enabled';
}
var gameRuleStr = gameRules.join(', ');
var gameMetadataLabel = 'Game; ' + gameMode + '. Server configuration; ' + mapId + ', game-rules; ' + gameRuleStr;
var playerCount = gameInfo.children('numplayers').text();
var playerMax = gameInfo.children('maxplayers').text();
var playerCountLabel = playerCount + ' players currently in-game';
var playerMaxLabel = playerMax + ' player limit';
var html = '<span class="player-summary"><label title="' + playerCountLabel + '">' + playerCount + '</label> / <label title="' + playerMaxLabel + '">' + playerMax + '</label></span> ';
html += '<span class="name"><label title="Server name \'' + name + '\', ' + serverMetadataLabel + '">' + name + '</label></span> ';
html += '<span class="game-mode"><label title="' + gameMetadataLabel + '.">' + gameMode + '</label></span>';
return '<span class="server">' + html + '</span>';
}
});
});
(function (e) {
e.fn.interpretFeed = function (t) {
var n = { feedUri: 'http://rss.cnn.com/rss/edition.rss',
dataType: 'xml',
maxItems: 5,
clearOnSuccess: true,
generateItemHtml: 0
};
if(t) {
e.extend(n, t);
}
var r = e(this).attr('id');
/*if(n.useGoogleApi)
{
e.ajax({
url: 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=' + n.maxItems + '&output=json&q=' + encodeURIComponent(n.feedUri) + '&hl=en&callback=?',
dataType: n.dataType,
success: function (t) {
if(n.clearOnSuccess)
{
e("#" + r).empty();
}
var html = "";
e.each(t.responseData.feed.entries, function (e, t) {
html += n.generateItemHtml(n, t);
});
e("#" + r).append('<ol style="list-style-type: none;">' + html + "</ol>");
}
});
}
else*/
{
e.ajax({
url: n.feedUri,
dataType: n.dataType,
success: function (t) {
if(n.clearOnSuccess)
{
e("#" + r).empty();
}
var html = "";
if(n.dataType === 'xml') {
var xml = $(t);
xml.find('item').slice(0, n.maxItems).each(function() {
var self = $(this),
item = { title: self.children('title').text(),
link: self.children('link').text(),
author: self.children('author').text(),
pubDate: self.children('pubDate').text(),
atomSummary: self.children('atom\\:summary').text(),
description: self.children('description').text(),
author: self.children('author').text()
}
html += n.generateItemHtml(n, item);
});
}
else if (n.dataType === 'json') {
for (var i = 0; i < n.maxItems && i < t.posts.length; ++i) {
var post = t.posts[i];
item = { title: post.title,
link: post.url,
author: post.author.name,
publishedDate: post.date.substring(0, 10),
content: post.content
}
html += n.generateItemHtml(n, item);
}
}
e('#' + r).append('<ol style="list-style-type: none;">' + html + '</ol>');
}
});
}
}
})(jQuery)
$(document).ready(function () {
$('#recentbuilds').interpretFeed({
feedUri: 'http://files.dengine.net/builds/events.rss',
dataType: 'xml',
maxItems: 3,
generateItemHtml : function(n, t) {
var html = '<a href="' + t.link + '" title="' + t.title.toLowerCase() + ' (read more in the repository)">' + t.title + ' completed</a>';
var d = new Date(t.pubDate);
var niceDate = $.datepicker.formatDate('MM d, yy', d);
html += ' ' + niceDate;
d.setDate(d.getDate() + 2);
var isNew = (new Date() < d);
return '<li' + (isNew? ' class="new"' : '') + '>' + html + '</li>';
}
});
/*$('#column1').interpretFeed({
feedUri: 'http://files.dengine.net/builds/events.rss',
dataType: 'xml',
maxItems: 3,
clearOnSuccess: false,
generateItemHtml: function (n, t) {
var html = '<div class="block"><article class="buildevent"><header><h1><a href="' + t.link + '" title="Read more about ' + t.title + ' in the repository">' + t.title + '</a></h1>';
var d = new Date(t.pubDate);
var niceDate = $.datepicker.formatDate('MM d, yy', d);
html += '<p><time datetime="' + d.toISOString() + '" pubdate>' + niceDate + '</time></p>';
html += '</header><br />';
html += t.atomSummary;
html += '</article>';
html += '<div class="links"><a href="' + n.feedUri + '" class="link-rss" title="Doomsday Engine build events are reported via RSS">All builds</a></div></div>';
return '<li>' + html + '</li>';
}
});*/
$('#column2').interpretFeed({
feedUri: 'http://dengine.net/blog/category/news/?json=true',
dataType: 'json',
clearOnSuccess: false,
maxItems: 2,
generateItemHtml: function (n, t) {
var html = '<div class="block"><article class="newspost content"><header><h1><a href="' + t.link + '" title="'' + t.title + '' (full article in the blog)">' + t.title + '</a></h1>';
var d = new Date(t.publishedDate);
var niceDate = $.datepicker.formatDate('MM d, yy', d);
html += '<p><time datetime="' + d.toISOString() + '" pubdate>' + niceDate + '</time></p>';
html += '</header><br />';
html += '<div class="articlecontent">' + t.content + '</div>';
html += '</article>';
html += '<div class="links"><a href="' + n.feedUri + '" class="link-rss" title="Doomsday Engine news via RSS">All news</a></div></div>';
return '<li>' + html + '</li>';
}
});
$('#column1').interpretFeed({
feedUri: 'http://dengine.net/blog/category/dev/?json=true',
dataType: 'json',
clearOnSuccess: false,
maxItems: 1,
generateItemHtml: function (n, t) {
var html = '<div class="block"><article class="blogpost content"><header><h1><a href="' + t.link + '" title="'' + t.title + '' (full article in the blog)">' + t.title + '</a></h1>';
var d = new Date(t.publishedDate);
var niceDate = $.datepicker.formatDate('MM d, yy', d);
html += '<p><time datetime="' + d.toISOString() + '" pubdate>' + niceDate + '</time></p>';
html += '</header><br />';
html += '<div class="articlecontent">' + t.content + '</div>';
html += '</article>';
html += '<div class="links"><a href="' + n.feedUri + '" class="link-rss" title="Doomsday Engine development blog via RSS">All blogs</a></div></div>';
return '<li>' + html + '</li>';
}
});
});
</script>
<aside role="complementary" class="block">
<div id="status">
<div class="twocolumn"><article>
<header><h1><a href="http://files.dengine.net/builds/" title="View the complete index in the build repository">Most recent builds</a></h1>
<p><script>
<!--
var niceDate = $.datepicker.formatDate('MM d, yy', new Date());
document.write(niceDate);
//-->
</script></p></header><div id="recentbuilds">Contacting build repository...</div></article></div>
<div class="twocolumn"><article id="activeservers"></article></div>
<div class="clear"></div>
</div></aside>
<div id="column1" class="twocolumn collapsible"></div>
<div id="column2" class="twocolumn collapsible"></div>
<div class="clear"></div>
</div>
<?php
?><div><div id="downloadbox" class="asidebox"><?php
includeHTML('getitnow', 'z#home');
?></div><?php
?><div id="socialbookmarkbox" class="asidebox"><?php
includeHTML('socialbookmarks', 'z#home');
?></div></div><?php
$fc->endPage();
}
}