Skip to content

Commit c4eb190

Browse files
committed
Next pass at bootstrap conversion
1 parent e83d8fe commit c4eb190

File tree

3 files changed

+90
-70
lines changed

3 files changed

+90
-70
lines changed

src/templates/EventLog/Index.phtml

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ require('./header.inc.phtml'); ?>
5454
<th>Event Type</th>
5555
<th>Timestamp</th>
5656
<th>User Account</th>
57+
<th></th>
5758
</tr>
5859
</thead><tbody>
5960
<? foreach ($this->getContext()->events as $event) {
@@ -73,6 +74,7 @@ require('./header.inc.phtml'); ?>
7374
<td><?=$event->getEventTypeName()?></td>
7475
<td><time datetime="<?=$event->getEventDateTime()->format('c')?>"><?=$event->getEventDateTime()->format('l, F j, Y')?></time></td>
7576
<td><?=$e_user?></td>
77+
<td><a class="btn btn-sm btn-primary" href="<?=Common::relativeUrlToAbsolute('/eventlog/view?id=' . $e_id)?>" title="View Event #<?=$e_id?>">🔎</a></td>
7678
</tr>
7779
<? } ?>
7880
</tbody></table>

src/templates/Server/View.phtml

+68-56
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,79 @@
1-
<?php
2-
1+
<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */
32
namespace BNETDocs\Templates\Server;
4-
53
use \BNETDocs\Libraries\Server;
64
use \CarlBennett\MVC\Libraries\Common;
75
use \CarlBennett\MVC\Libraries\Pair;
6+
$title = 'Server Not Found';
7+
$description = 'The requested server does not exist or could not be found.';
8+
$server = $this->getContext()->server;
9+
$server_id = $this->getContext()->server_id;
10+
$server_type = $this->getContext()->server_type;
11+
if (!$server)
12+
{
13+
$server_user = null;
14+
$url = Common::relativeUrlToAbsolute(sprintf('/server/', rawurlencode($server_id)));
15+
}
16+
else
17+
{
18+
$server_address = filter_var(sprintf('%s:%s', $server->getAddress(), $server->getPort()), FILTER_SANITIZE_FULL_SPECIAL_CHARS);
19+
$server_name = filter_var($server->getName(), FILTER_SANITIZE_FULL_SPECIAL_CHARS);
820

9-
$object_id = $this->getContext()->server_id;
10-
$object = $this->getContext()->server;
11-
$object_status = null;
12-
$object_type = $this->getContext()->server_type;
13-
14-
$object_user = ($object ? $object->getUser() : null);
15-
$object_user_avatar = ($object_user ? $object_user->getAvatarURI(22) : null);
16-
$object_user_url = ($object_user ? $object_user->getURI() : null);
17-
18-
$title = ($object ? $object->getName() : "Server Not Found");
19-
$description = ($object ? "The BNETDocs Status Page for " . $object->getName()
20-
: "The requested server does not exist or could not be found.");
21-
22-
$this->opengraph->attach(new Pair("type", "article"));
23-
24-
$url = Common::relativeUrlToAbsolute("/server/" . urlencode($object_id));
25-
26-
if ($object) {
21+
$title = $server_name;
22+
$description = sprintf('Server Status for %s', $server_name);
23+
$url = $server->getURI();
24+
$url_json = sprintf('%s.json', $url);
25+
$url_txt = sprintf('%s.txt', $url);
2726

28-
$url = $object->getURI();
27+
$server_type = $server->getType();
28+
$server_type_label = filter_var($server_type->getLabel(), FILTER_SANITIZE_FULL_SPECIAL_CHARS);
2929

30-
$object_status_bitmask = $object->getStatusBitmask();
31-
if ($object_status_bitmask & Server::STATUS_ONLINE) {
32-
$object_status = "<span class=\"online\">Online</span>";
33-
} else {
34-
$object_status = "<span class=\"offline\">Offline</span>";
30+
$server_user = $server->getUser();
31+
if (!$server_user)
32+
{
33+
$server_user_string = 'Anonymous';
3534
}
36-
if ($object_status_bitmask & Server::STATUS_DISABLED) {
37-
$object_status .= ", <span class=\"disabled\">Disabled</span>";
35+
else
36+
{
37+
$server_user_avatar = $server_user->getAvatarURI(22);
38+
$server_user_name = filter_var($server_user->getName(), FILTER_SANITIZE_FULL_SPECIAL_CHARS);
39+
$server_user_url = $server_user->getURI();
40+
$server_user_string = sprintf('<a href="%s"><img class="mr-2 rounded" src="%s"/>%s</a>', $server_user_url, $server_user_avatar, $server_user_name);
3841
}
3942

43+
$server_status_bitmask = $server->getStatusBitmask();
44+
$server_status = (
45+
($server_status_bitmask & Server::STATUS_ONLINE) ?
46+
'<span class="text-success">Online</span>' :
47+
'<span class="text-danger">Offline</span>'
48+
) . (
49+
($server_status_bitmask & Server::STATUS_DISABLED) ?
50+
', <span class="text-danger">Disabled</span>' : ''
51+
);
4052
}
41-
42-
$this->opengraph->attach(new Pair("url", $url));
43-
44-
require("./header.inc.phtml");
45-
?>
46-
<article>
47-
<?php if ($object) { ?>
48-
<a href="https://twitter.com/share?text=<?php echo urlencode($title); ?>&amp;url=<?php echo urlencode($url); ?>" rel="external" data-popup="1"><img class="header-button float-right" src="<?php echo Common::relativeUrlToAbsolute("/a/social-twitter-24px.png"); ?>"/></a>
49-
<a href="https://facebook.com/sharer/sharer.php?u=<?php echo urlencode($url); ?>" rel="external" data-popup="1"><img class="header-button float-right" src="<?php echo Common::relativeUrlToAbsolute("/a/social-facebook-24px.png"); ?>"/></a>
50-
<header>Server Status</header>
51-
<section>
52-
<table class="serverview"><tbody>
53-
<tr><th>Label</th><td><?php echo filter_var($object->getLabel(), FILTER_SANITIZE_FULL_SPECIAL_CHARS); ?></td></tr>
54-
<tr><th>Address</th><td class="address" onclick="bnetdocs.fSelectText(this);"><?php echo filter_var($object->getAddress() . ":" . $object->getPort(), FILTER_SANITIZE_FULL_SPECIAL_CHARS); ?></td></tr>
55-
<tr><th>Owner</th><td><?php if ($object_user) { ?><a href="<?php echo $object_user_url; ?>"><img class="avatar" src="<?php echo $object_user_avatar; ?>"/> <?php echo filter_var($object_user->getName(), FILTER_SANITIZE_FULL_SPECIAL_CHARS); ?></a><?php } else { echo "Anonymous"; } ?></td></tr>
56-
<tr><th>Type</th><td><?php echo filter_var($object_type->getLabel(), FILTER_SANITIZE_FULL_SPECIAL_CHARS); ?></td></tr>
57-
<tr><th>Current Status</th><td><?php echo $object_status; ?></td></tr>
58-
</tbody></table>
59-
<hr/>
60-
<p style="font-size:smaller;text-align:center;"><a href="<?php echo Common::relativeUrlToAbsolute( $url . '.json' ); ?>">JSON</a> | <a href="<?php echo Common::relativeUrlToAbsolute( $url . '.txt' ); ?>">TXT</a></p>
61-
</section>
62-
<?php } else { ?>
63-
<header class="red"><?php echo filter_var($title, FILTER_SANITIZE_FULL_SPECIAL_CHARS); ?></header>
64-
<section class="red"><?php echo filter_var($description, FILTER_SANITIZE_FULL_SPECIAL_CHARS); ?></section>
65-
<?php } ?>
66-
</article>
67-
<?php require("./footer.inc.phtml"); ?>
53+
$this->opengraph->attach(new Pair('type', 'article'));
54+
$this->opengraph->attach(new Pair('url', $url));
55+
require('./header.inc.phtml'); ?>
56+
<div class="container">
57+
<? if (!$server) { ?>
58+
<div class="alert alert-danger">
59+
<h1><?=$title?></h1>
60+
<p class="mb-0"><?=$description?></p>
61+
</div>
62+
<? } else { ?>
63+
<span class="float-right">
64+
<a class="btn btn-sm btn-primary" href="<?=$url_json?>">JSON</a>
65+
<a class="btn btn-sm btn-primary" href="<?=$url_txt?>">TXT</a>
66+
<a class="btn btn-sm btn-primary" href="https://twitter.com/share?text=<?=urlencode($title)?>&amp;url=<?=urlencode($url)?>" rel="external" data-popup="1"><img src="<?=Common::relativeUrlToAbsolute('/a/social-twitter-24px.png')?>"/></a>
67+
<a class="btn btn-sm btn-primary" href="https://facebook.com/sharer/sharer.php?u=<?=urlencode($url)?>" rel="external" data-popup="1"><img src="<?=Common::relativeUrlToAbsolute('/a/social-facebook-24px.png')?>"/></a>
68+
</span>
69+
<h1><?=$title?></h1>
70+
<table class="table table-hover table-sm table-striped"><thead></thead><tbody>
71+
<tr><th class="text-right">Label</th><td><?=$server_name?></td></tr>
72+
<tr><th class="text-right">Address</th><td onclick="bnetdocs.fSelectText(this);"><code><?=$server_address?></td></tr>
73+
<tr><th class="text-right">Owner</th><td><?=$server_user_string?></td></tr>
74+
<tr><th class="text-right">Type</th><td><?=$server_type_label?></td></tr>
75+
<tr><th class="text-right">Current Status</th><td><?=$server_status?></td></tr>
76+
</tbody></table>
77+
<? } ?>
78+
</div>
79+
<? require('./footer.inc.phtml'); ?>

src/templates/Servers.phtml

+20-14
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use \BNETDocs\Libraries\Server;
44
use \BNETDocs\Libraries\ServerType;
55
use \CarlBennett\MVC\Libraries\Common;
66
use \CarlBennett\MVC\Libraries\Pair;
7-
$title = 'Servers';
8-
$description = 'A list of servers that our automated system checks the status of. The status represents if the port is opened or closed, not if the service is functioning correctly.';
7+
$title = 'Server List';
8+
$description = 'The list of servers that are well-known and monitored for port status.';
99
$this->opengraph->attach(new Pair('url', '/servers'));
1010

1111
$servers_by_type = [];
@@ -14,23 +14,30 @@ foreach ($this->context->servers as $server) {
1414
}
1515
ksort($servers_by_type);
1616

17-
require('./header.inc.phtml');
18-
?>
17+
require('./header.inc.phtml'); ?>
1918
<div class="container">
20-
<h1>Server List</h1>
19+
<h1><?=$title?></h1>
2120
<div class="row"><div class="col">
22-
<p>Below is a list of servers that our automated system checks the status of. The status represents if the port is opened or closed, not if the service is functioning correctly.</p>
23-
<p>We have a total of <strong><? echo number_format(count($this->context->servers)); ?> servers</strong> that we monitor. <a href="<? echo Common::relativeUrlToAbsolute("/servers.json"); ?>">Click here</a> to see this list in JSON format.</p>
21+
<p><?=$description?></p>
22+
<p>The status represents if the port is opened or closed, not if the service is functioning correctly. These are the statuses a server could be in:</p>
23+
<ul>
24+
<li><span class="text-success">Online</span>: The port is open.</li>
25+
<li><span class="text-danger">Offline</span>: The port is closed.</li>
26+
<li><span class="text-danger">Disabled</span>: The server is not actively checked.</li>
27+
</ul>
28+
<p>We have a total of <strong><?=number_format(count($this->context->servers))?> servers</strong> that we monitor. <a href="<?=Common::relativeUrlToAbsolute('/servers.json')?>">Click here</a> to see this list in JSON format.</p>
2429
</div></div>
2530
<div class="row"><div class="col">
2631
<table class="table table-hover table-sm table-striped" id="servers_tbl">
2732
<thead><tr><th scope="col">Status</th><th scope="col">Label</th><th scope="col">Address</th><th scope="col"></th></tr></thead><tbody>
2833
<? foreach ($servers_by_type as $type_id => $servers)
2934
{
3035
$server_type = new ServerType($type_id);
31-
echo '<tr><th colspan="4">' . filter_var($server_type->getLabel(), FILTER_SANITIZE_FULL_SPECIAL_CHARS) . '</th></tr>';
36+
$server_type_label = filter_var($server_type->getLabel(), FILTER_SANITIZE_FULL_SPECIAL_CHARS);
37+
printf('<tr><th scope="row" colspan="4">%s</th></tr>', $server_type_label);
3238
foreach ($servers as $server)
3339
{
40+
$server_label = filter_var($server->getLabel(), FILTER_SANITIZE_FULL_SPECIAL_CHARS);
3441
$status_bitmask = $server->getStatusBitmask();
3542
if ($status_bitmask & Server::STATUS_ONLINE) {
3643
$status_subclass = 'success'; $status = 'Online';
@@ -40,13 +47,12 @@ require('./header.inc.phtml');
4047
$status_subclass = 'danger'; $status = 'Offline';
4148
} ?>
4249
<tr>
43-
<td class="text-center"><span class="text-<?=$status_subclass?>"><?=$status?></span></td>
44-
<td><?=($server->getLabel() != $server->getAddress() && !empty($server->getLabel()) ? $server->getLabel() : '&nbsp;')?></td>
45-
<td><code><? echo $server->getAddress(); ?>:<? echo $server->getPort(); ?></code></td>
46-
<td><a class="btn btn-sm btn-primary" href="<? echo $server->getURI(); ?>" title="Details">ℹ</a></td>
50+
<td class="text-center text-<?=$status_subclass?>"><?=$status?></td>
51+
<td><?=($server->getLabel() != $server->getAddress() && !empty($server->getLabel()) ? $server_label : '&nbsp;')?></td>
52+
<td><code><?=$server->getAddress()?>:<?=$server->getPort()?></code></td>
53+
<td><a class="btn btn-sm btn-primary" href="<?=$server->getURI()?>" title="View Server Details for <?=$server_label?>">🔎</a></td>
4754
</tr>
48-
<? }
49-
} ?>
55+
<? }} ?>
5056
</tbody>
5157
</table>
5258
</div></div>

0 commit comments

Comments
 (0)