Skip to content

Commit 3de0853

Browse files
committed
Next pass at bootstrap conversion
1 parent b2b95f2 commit 3de0853

File tree

6 files changed

+213
-251
lines changed

6 files changed

+213
-251
lines changed

src/templates/Comment/Section.inc.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $c_delete_visible_admin = ($logged_in && ($logged_in->getOptionsBitmask() & User
1010
<div class="col">
1111
<h2><a name="comments">Comments</a></h2>
1212
<? if (!$comments) { ?>
13-
<div class="border border-secondary rounded-pill p-2"><p class="text-center mb-0"><em>no one has commented yet.</em></p></div>
13+
<div class="border border-secondary m-auto rounded-pill p-2" style="max-width:400px;"><p class="text-center mb-0"><em>no one has commented yet.</em></p></div>
1414
<? } else { ?>
1515
<table class="table table-striped text-white-50"><tbody>
1616
<? foreach ($comments as $c) {

src/templates/Document/Index.phtml

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,32 @@ use \BNETDocs\Libraries\User;
55
use \CarlBennett\MVC\Libraries\Common;
66
use \CarlBennett\MVC\Libraries\Pair;
77
$title = 'All Documents';
8-
$description = 'This page is an index for all of the document pages on BNETDocs';
8+
$description = 'The index for all of the document pages on BNETDocs';
99
$this->opengraph->attach(new Pair('url', '/document/index'));
1010
$order = $this->getContext()->order;
11+
$form_order_by = [
12+
'created-asc' => 'Created (Ascending)',
13+
'created-desc' => 'Created (Descending)',
14+
'id-asc' => 'Id (Ascending)',
15+
'id-desc' => 'Id (Descending)',
16+
'title-asc' => 'Title (Ascending)',
17+
'title-desc' => 'Title (Descending)',
18+
'updated-asc' => 'Updated (Ascending)',
19+
'updated-desc' => 'Updated (Descending)',
20+
'user-id-asc' => 'User Id (Ascending)',
21+
'user-id-desc' => 'User Id (Descending)',
22+
];
1123
require('./header.inc.phtml'); ?>
1224
<div class="container mb-3">
1325
<h2><?=$title?></h2>
1426
<p><?=$description?></p>
1527
<form method="GET" class="m-2" id="order_by_form">
16-
<label for="order">Order by:</label>
17-
<select class="form-control form-control-sm" name="order" id="order" onchange="form.submit();"
18-
style="display:inline-block;width:200px;">
19-
<option value="created-asc"<?
20-
if ($order === 'created-asc') { echo ' selected="selected"';
21-
} ?>>Created (Ascending)</option>
22-
<option value="created-desc"<?
23-
if ($order === 'created-desc') { echo ' selected="selected"';
24-
} ?>>Created (Descending)</option>
25-
<option value="id-asc"<?
26-
if ($order === 'id-asc') { echo ' selected="selected"';
27-
} ?>>Id (Ascending)</option>
28-
<option value="id-desc"<?
29-
if ($order === 'id-desc') { echo ' selected="selected"';
30-
} ?>>Id (Descending)</option>
31-
<option value="title-asc"<?
32-
if ($order === 'title-asc') { echo ' selected="selected"';
33-
} ?>>Title (Ascending)</option>
34-
<option value="title-desc"<?
35-
if ($order === 'title-desc') { echo ' selected="selected"';
36-
} ?>>Title (Descending)</option>
37-
<option value="updated-asc"<?
38-
if ($order === 'updated-asc') { echo ' selected="selected"';
39-
} ?>>Updated (Ascending)</option>
40-
<option value="updated-desc"<?
41-
if ($order === 'updated-desc') { echo ' selected="selected"';
42-
} ?>>Updated (Descending)</option>
43-
<option value="user-id-asc"<?
44-
if ($order === 'user-id-asc') { echo ' selected="selected"';
45-
} ?>>User Id (Ascending)</option>
46-
<option value="user-id-desc"<?
47-
if ($order === 'user-id-desc') { echo ' selected="selected"';
48-
} ?>>User Id (Descending)</option>
28+
<label for="order" class="font-weight-bold m-1">Order by:</label>
29+
<select class="form-control form-control-sm" name="order" id="order" onchange="form.submit();" style="display:inline-block;width:200px;">
30+
<? foreach ($form_order_by as $item_value => $item_label) {
31+
$item_selected = ($order === $item_value);
32+
echo sprintf('<option value="%s"%s>%s</option>' . PHP_EOL, $item_value, $item_selected, $item_label);
33+
} ?>
4934
</select>
5035
<input class="btn btn-sm btn-secondary" type="submit" value="Reorder"/>
5136
</form>

src/templates/Document/View.phtml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,17 @@ require('./header.inc.phtml'); ?>
4848
<?=\BNETDocs\Templates\MarkdownBootstrapFix($object->getContent(true))?>
4949

5050
<div class="card"><div class="card-body">
51-
<span class="float-right">
51+
<span class="float-right text-muted">
5252
<time datetime="<?=$created_dt->format('c')?>"><?=$created_dt->format('l, F j, Y')?></time>
5353
<? if ($edited_dt) { ?>
54-
| Edited: <time datetime="<?=$edited_dt->format('c')?>"><?=$edited_dt->format('l, F j, Y'); ?></time>
54+
| <strong>Edited:</strong> <time datetime="<?=$edited_dt->format('c')?>"><?=$edited_dt->format('l, F j, Y'); ?></time>
5555
<? } ?>
5656
</span>
57-
<? if ($user !== null) { ?>
58-
<span><a href="<?php echo $user->getURI(); ?>"><img class="avatar" src="<?php echo $user->getAvatarURI(22); ?>"/> <?php echo filter_var($user->getName(), FILTER_SANITIZE_STRING); ?></a></span>
59-
<? } ?>
57+
<? echo ($user ?
58+
sprintf('<a href="%s"><img class="img-fluid rounded mr-2" src="%s"/>%s</a>',
59+
$user->getURI(), $user->getAvatarURI(40), filter_var($user->getName(), FILTER_SANITIZE_FULL_SPECIAL_CHARS)
60+
) : 'Anonymous'
61+
); ?>
6062
</div></div>
6163
<? $comment_parent_type = Comment::PARENT_TYPE_DOCUMENT; require('./Comment/Section.inc.phtml');
6264
} else { ?>

src/templates/MarkdownBootstrapFix.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function MarkdownBootstrapFix(string $v)
1919
$v = str_replace('<code>', '<code class="language-plaintext">', $v);
2020

2121
// Code Blocks
22-
$v = str_replace('<pre><code', '<pre class="border border-primary overflow-auto pre-scrollable rounded text-light"><code', $v);
22+
$v = str_replace('<pre><code', '<pre class="border border-primary overflow-auto pre-scrollable rounded bg-dark text-light"><code', $v);
2323

2424
return $v;
2525
}

src/templates/Packet/Index.phtml

Lines changed: 90 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,104 @@
1-
<?php
2-
1+
<?php /* vim: set colorcolumn=: */
32
namespace BNETDocs\Templates\Packet;
4-
53
use \BNETDocs\Libraries\Packet;
64
use \BNETDocs\Libraries\User;
75
use \CarlBennett\MVC\Libraries\Common;
86
use \CarlBennett\MVC\Libraries\Pair;
9-
10-
$title = 'Packet Index';
11-
$description = 'The index for packets on BNETDocs';
7+
$title = 'All Packets';
8+
$description = 'The index for all of the packets documented on BNETDocs';
129
$this->opengraph->attach(new Pair('url', '/packet/index'));
13-
1410
$order = $this->getContext()->order;
11+
$form_order_by = [
12+
'created-datetime-asc' => 'Created Timestamp (Ascending)',
13+
'created-datetime-desc' => 'Created Timestamp (Descending)',
14+
'id-asc' => 'Database Id (Ascending)',
15+
'id-desc' => 'Database Id (Descending)',
16+
'packet-id-asc' => 'Packet Id (Ascending)',
17+
'packet-id-desc' => 'Packet Id (Descending)',
18+
'user-id-asc' => 'User Id (Ascending)',
19+
'user-id-desc' => 'User Id (Descending)',
20+
];
21+
require('./header.inc.phtml'); ?>
22+
<div class="container mb-3">
23+
<h2><?=$title?></h2>
24+
<p><?=$description?></p>
25+
<form method="GET" class="m-2" id="filter_form">
26+
<div class="form-group" id="order_by_form">
27+
<label for="order" class="font-weight-bold m-1">Order by:</label>
28+
<select class="form-control form-control-sm m-1" name="order" id="order" onchange="form.submit();" style="display:inline-block;width:200px;">
29+
<? foreach ($form_order_by as $item_value => $item_label) {
30+
$item_selected = ($order === $item_value ? ' selected="selected"' : '');
31+
echo sprintf('<option value="%s"%s>%s</option>' . PHP_EOL, $item_value, $item_selected, $item_label);
32+
} ?>
33+
</select>
34+
</div>
35+
<div class="form-group">
36+
<table class="table d-inline-block"><thead><tr><th colspan="3" class="text-center">Packet Types</th></tr></thead><tbody>
37+
<? $x = 0;
38+
foreach ($this->getContext()->application_layers as $layer)
39+
{
40+
$id = 'pktapplayer-' . $layer->getId();
41+
$chk = in_array($layer->getId(), $this->getContext()->pktapplayer);
42+
if ( $x % 3 == 0 ) { echo '<tr>'; }
43+
echo sprintf(
44+
'<td><div class="custom-control custom-switch"><input class="custom-control-input" type="checkbox" name="pktapplayer[]" id="%s" value="%s"%s><label class="custom-control-label" for="%s">%s</label></div></td>',
45+
$id, $layer->getId(), ($chk ? ' checked="checked"' : ''), $id, $layer->getTag()
46+
);
47+
if ( $x % 3 == 2 ) { echo '</tr>'; }
48+
$x++;
49+
}
50+
if ( $x % 3 > 0 ) { echo '</tr>'; } ?>
51+
<tr><td colspan="3" class="text-center"><input class="btn btn-sm btn-secondary" type="submit" value="Set Filter"/></td></tr>
52+
</tbody></table>
53+
</div>
54+
</form>
55+
<table class="table table-hover table-striped" id="packets_tbl">
56+
<thead><tr><th>Packet</th><th>Author</th></tr></thead><tbody>
57+
<? foreach ($this->getContext()->packets as $packet)
58+
{
59+
$user = $packet->getUser();
60+
if ($user)
61+
{
62+
$avatar_url = $user->getAvatarURI(22);
63+
$user_url = $user->getURI();
64+
}
65+
$deprecated = $packet->isDeprecated();
66+
$packet_id = $packet->getPacketId(true);
67+
$published = $packet->isPublished();
68+
$research = $packet->isInResearch();
1569

16-
require('./header.inc.phtml');
17-
?>
18-
<article>
19-
<header>Packet Index</header>
20-
<section>
21-
<form method="GET">
22-
<div style="text-align:center;">
23-
<label for="order">Order by:</label>
24-
<select name="order" id="order" onchange="form.submit();"
25-
style="display:inline-block;width:200px;">
26-
<option value="created-datetime-asc"<?php
27-
if ($order === 'created-datetime-asc') { echo ' selected="selected"';
28-
} ?>>Created Timestamp (Ascending)</option>
29-
<option value="created-datetime-desc"<?php
30-
if ($order === 'created-datetime-desc') { echo ' selected="selected"';
31-
} ?>>Created Timestamp (Descending)</option>
32-
<option value="id-asc"<?php
33-
if ($order === 'id-asc') { echo ' selected="selected"';
34-
} ?>>Database Id (Ascending)</option>
35-
<option value="id-desc"<?php
36-
if ($order === 'id-desc') { echo ' selected="selected"';
37-
} ?>>Database Id (Descending)</option>
38-
<option value="packet-id-asc"<?php
39-
if ($order === 'packet-id-asc') { echo ' selected="selected"';
40-
} ?>>Packet Id (Ascending)</option>
41-
<option value="packet-id-desc"<?php
42-
if ($order === 'packet-id-desc') { echo ' selected="selected"';
43-
} ?>>Packet Id (Descending)</option>
44-
<option value="user-id-asc"<?php
45-
if ($order === 'user-id-asc') { echo ' selected="selected"';
46-
} ?>>User Id (Ascending)</option>
47-
<option value="user-id-desc"<?php
48-
if ($order === 'user-id-desc') { echo ' selected="selected"';
49-
} ?>>User Id (Descending)</option>
50-
</select>
51-
</div>
52-
<table><thead><tr><th colspan="6">Packet Types</th></tr></thead><tbody>
53-
<?php $x = 0; foreach ($this->getContext()->application_layers as $layer) {
54-
$id = 'pktapplayer-' . $layer->getId();
55-
$chk = in_array( $layer->getId(), $this->getContext()->pktapplayer );
56-
if ( $x % 3 == 0 ) { ?>
57-
<tr>
58-
<?php } ?>
59-
<td style="width:20px;"><input type="checkbox" name="pktapplayer[]" id="<?php echo $id; ?>" value="<?php echo $layer->getId(); ?>"<?php if ($chk) { ?> checked="checked"<?php } ?>></td><td><label style="display:inline-block;" for="<?php echo $id; ?>"><?php echo $layer->getTag(); ?></label></td>
60-
<?php if ( $x % 3 == 2 ) { ?>
61-
</tr>
62-
<?php } ?>
63-
<?php $x++; } ?>
64-
<?php if ( $x % 3 > 0 ) { ?>
65-
</tr>
66-
<?php } ?>
67-
</tbody></table>
68-
<div style="text-align:center;"><input type="submit" value="Submit"/></div>
69-
</form>
70-
<hr/>
71-
<table>
72-
<thead>
73-
<tr>
74-
<th class="left">Packet</th>
75-
<th class="left">Author</th>
76-
</tr>
77-
</thead><tbody>
78-
<?php foreach ($this->getContext()->packets as $packet) {
79-
$user = $packet->getUser();
80-
if ($user) {
81-
$user_url = $user->getURI();
82-
$avatar_url = $user->getAvatarURI(22);
83-
}
84-
$packet_id = $packet->getPacketId(true);
85-
$deprecated = $packet->isDeprecated();
86-
$research = $packet->isInResearch();
87-
$published = $packet->isPublished();
88-
89-
ob_start();
90-
if ($deprecated) require('./Deprecated.inc.phtml');
91-
if ($research) require('./InResearch.inc.phtml');
92-
if (!$published) require('./Draft.inc.phtml');
93-
$tpl_packet_flags = ob_get_clean();
94-
if (!empty($tpl_packet_flags)) $tpl_packet_flags = ' ' . $tpl_packet_flags;
95-
?>
96-
<tr>
97-
<td><strong><a href="<?php echo $packet->getURI(); ?>"><?php echo filter_var($packet->getPacketDirectionTag() . " " . $packet_id . " " . $packet->getPacketName(), FILTER_SANITIZE_STRING); ?></a></strong><?=$tpl_packet_flags?><br/><span style="color:#aaa;"><?php echo rtrim(Common::stripUpTo(Common::stripUpTo(trim(filter_var($packet->getPacketRemarks(true), FILTER_SANITIZE_STRING)), "\n", 90), ". ", 90), "."); ?></span></td>
98-
<td><?php if ($user) { ?><a href="<?php echo $user_url; ?>"><img class="avatar" src="<?php echo $avatar_url; ?>"/>&nbsp;<?php echo filter_var($user->getName(), FILTER_SANITIZE_STRING); ?></a><?php } else { ?>Anonymous<?php } ?></td>
99-
</tr>
100-
<?php } ?>
101-
</tbody></table>
70+
ob_start();
71+
if ($deprecated) require('./Deprecated.inc.phtml');
72+
if ($research) require('./InResearch.inc.phtml');
73+
if (!$published) require('./Draft.inc.phtml');
74+
$tpl_packet_flags = ob_get_clean();
75+
if (!empty($tpl_packet_flags)) $tpl_packet_flags = ' ' . $tpl_packet_flags; ?>
76+
<tr>
77+
<td><strong><a href="<? echo $packet->getURI(); ?>"><? echo filter_var($packet->getPacketDirectionTag() . " " . $packet_id . " " . $packet->getPacketName(), FILTER_SANITIZE_STRING); ?></a></strong><?=$tpl_packet_flags?><br/><span style="color:#aaa;"><? echo rtrim(Common::stripUpTo(Common::stripUpTo(trim(filter_var($packet->getPacketRemarks(true), FILTER_SANITIZE_STRING)), "\n", 90), ". ", 90), "."); ?></span></td>
78+
<td><? if ($user) { ?><a href="<? echo $user_url; ?>"><img class="avatar" src="<? echo $avatar_url; ?>"/>&nbsp;<? echo filter_var($user->getName(), FILTER_SANITIZE_STRING); ?></a><? } else { ?>Anonymous<? } ?></td>
79+
</tr>
80+
<? } ?>
81+
</tbody></table>
10282
</section>
10383
<section>
10484
<p>These packets are also available as constants in
105-
<?php $q = getenv('QUERY_STRING'); if (!empty($q)) { $q = '?' . $q; } ?>
106-
<a href="<?php echo Common::relativeUrlToAbsolute('/packet/index.cpp' . $q); ?>">C++</a>,
107-
<a href="<?php echo Common::relativeUrlToAbsolute('/packet/index.java' . $q); ?>">Java</a>,
108-
<a href="<?php echo Common::relativeUrlToAbsolute('/packet/index.json' . $q); ?>">JSON</a>,
109-
<a href="<?php echo Common::relativeUrlToAbsolute('/packet/index.php' . $q); ?>">PHP</a>, and
110-
<a href="<?php echo Common::relativeUrlToAbsolute('/packet/index.vb' . $q); ?>">VB6</a>.
85+
<? $q = getenv('QUERY_STRING'); if (!empty($q)) { $q = '?' . $q; } ?>
86+
<a href="<? echo Common::relativeUrlToAbsolute('/packet/index.cpp' . $q); ?>">C++</a>,
87+
<a href="<? echo Common::relativeUrlToAbsolute('/packet/index.java' . $q); ?>">Java</a>,
88+
<a href="<? echo Common::relativeUrlToAbsolute('/packet/index.json' . $q); ?>">JSON</a>,
89+
<a href="<? echo Common::relativeUrlToAbsolute('/packet/index.php' . $q); ?>">PHP</a>, and
90+
<a href="<? echo Common::relativeUrlToAbsolute('/packet/index.vb' . $q); ?>">VB6</a>.
11191
</p>
11292
</section>
11393
</article>
114-
<?php require("./footer.inc.phtml"); ?>
94+
<? ob_start(); ?>
95+
<script type="text/javascript">
96+
$(document).ready(function(){
97+
$('#order_by_form').hide();
98+
$('#packets_tbl').DataTable({
99+
"language": {"zeroRecords": "No matching packets found"},
100+
"responsive": true,
101+
});
102+
});
103+
</script>
104+
<? $_footer_script = ob_get_clean(); require('./footer.inc.phtml'); ?>

0 commit comments

Comments
 (0)