Skip to content

Commit 39db81c

Browse files
committed
Next pass at bootstrap conversion
1 parent 0cd709c commit 39db81c

File tree

6 files changed

+65
-90
lines changed

6 files changed

+65
-90
lines changed

src/controllers/Packet/Delete.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public function &run(Router &$router, View &$view, array &$args) {
3838
if ($model->packet === null) {
3939
$model->error = 'NOT_FOUND';
4040
} else {
41-
$model->title = $model->packet->getPacketDirectionTag() .
42-
' ' . $model->packet->getPacketName();
41+
$model->title = $model->packet->getName();
4342

4443
if ($router->getRequestMethod() == 'POST') {
4544
$this->tryDelete($router, $model);

src/templates/Packet/Index.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ require('./header.inc.phtml'); ?>
7474
$tpl_packet_flags = ob_get_clean();
7575
if (!empty($tpl_packet_flags)) $tpl_packet_flags = ' ' . $tpl_packet_flags; ?>
7676
<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>
77+
<td><strong><a href="<?=$packet->getURI()?>"><?=filter_var($packet->getName(), FILTER_SANITIZE_FULL_SPECIAL_CHARS)?></a></strong><?=$tpl_packet_flags?><br/><span class="text-muted"><?=rtrim(Common::stripUpTo(Common::stripUpTo(trim(filter_var($packet->getPacketRemarks(true), FILTER_SANITIZE_STRING)), "\n", 128), '. ', 128), '.')?></span></td>
7878
<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>
7979
</tr>
8080
<? } ?>

src/templates/Packet/Search.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ require("./header.inc.phtml");
4141
$packet_id = $packet->getPacketId(true);
4242
?>
4343
<tr>
44-
<td><strong><a href="<?php echo $packet->getURI(); ?>"><?php echo htmlspecialchars($packet->getPacketDirectionTag() . " " . $packet_id . " " . $packet->getPacketName(), ENT_HTML5, "UTF-8"); ?></a></strong><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>
44+
<td><strong><a href="<?=$packet->getURI()?>"><?=filter_var($packet->getName(), FILTER_SANITIZE_FULL_SPECIAL_CHARS)?></a></strong><br/><span class="text-muted"><?=rtrim(Common::stripUpTo(Common::stripUpTo(trim(filter_var($packet->getPacketRemarks(true), FILTER_SANITIZE_STRING)), "\n", 128), ". ", 128), ".")?></span></td>
4545
<td><?php if ($user) { ?><a href="<?php echo $user_url; ?>"><img class="avatar" src="<?php echo $avatar_url; ?>"/> <?php echo htmlspecialchars($user->getName(), ENT_HTML5, "UTF-8"); ?></a><?php } else { ?>Anonymous<?php } ?></td>
4646
</tr>
4747
<?php } ?>

src/templates/Packet/View.phtml

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ if ($object)
1919
$edited_dt = $object->getEditedDateTime();
2020
$packet_id = $object->getPacketId(true);
2121
$url = $object->getURI();
22-
$title = sprintf('%s %s %s',
23-
$object->getPacketDirectionTag(), $packet_id, $object->getPacketName()
24-
);
22+
$title = $object->getName();
2523
$description = Common::stripUpTo(trim(filter_var(
2624
$object->getPacketRemarks(true), FILTER_SANITIZE_STRING
2725
)), "\n", 300);
+60-82
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,63 @@
1-
<?php
2-
1+
<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */
32
namespace BNETDocs\Templates\User;
4-
3+
use \CarlBennett\MVC\Libraries\Common;
54
use \CarlBennett\MVC\Libraries\Pair;
6-
7-
$title = "Change Password";
8-
$description = "This form allows an individual to change the password to their account.";
9-
$this->opengraph->attach(new Pair("url", "/user/changepassword"));
10-
11-
switch ($this->getContext()->error) {
12-
case "NOT_LOGGED_IN":
13-
$message = "You were not logged in to begin with.";
14-
break;
15-
case "NONMATCHING_PASSWORD":
16-
$message = "The new password does not match its confirmation.";
17-
break;
18-
case "PASSWORD_CONTAINS_EMAIL":
19-
$message = "The password contains the email address, "
20-
. "use a better password.";
21-
break;
22-
case "PASSWORD_CONTAINS_USERNAME":
23-
$message = "The password contains the username, use a better password.";
24-
break;
25-
case "PASSWORD_INCORRECT":
26-
$message = "You did not enter your correct current password.";
27-
break;
28-
case "PASSWORD_TOO_LONG":
29-
$message = "The password is too long, shorten it.";
30-
break;
31-
case "PASSWORD_TOO_SHORT":
32-
$message = "The password is too short, use a better password.";
33-
break;
34-
case "PASSWORD_BLACKLIST":
35-
$message = $this->getContext()->error_extra;
36-
if (empty($message)) $message = "The new password is blacklisted.";
37-
break;
38-
case "INTERNAL_ERROR":
39-
$message = "An internal error occurred while processing your request. "
40-
. "Our staff have been notified of the issue. Try again later.";
41-
break;
42-
default:
43-
$message = $this->getContext()->error;
5+
$title = 'Change Password';
6+
$description = 'This form allows an individual to change the password to their account.';
7+
$this->opengraph->attach(new Pair('url', '/user/changepassword'));
8+
$error = $this->getContext()->error;
9+
switch ($error)
10+
{
11+
case 'NOT_LOGGED_IN': $message = 'You were not logged in to begin with.'; break;
12+
case 'NONMATCHING_PASSWORD': $message = 'The new password does not match its confirmation.'; break;
13+
case 'PASSWORD_CONTAINS_EMAIL': $message = 'The password contains the email address, use a better password.'; break;
14+
case 'PASSWORD_CONTAINS_USERNAME': $message = 'The password contains the username, use a better password.'; break;
15+
case 'PASSWORD_INCORRECT': $message = 'You did not enter your correct current password.'; break;
16+
case 'PASSWORD_TOO_LONG': $message = 'The password is too long, shorten it.'; break;
17+
case 'PASSWORD_TOO_SHORT': $message = 'The password is too short, use a better password.'; break;
18+
case 'PASSWORD_BLACKLIST': $message = $this->getContext()->error_extra; if (empty($message)) $message = 'The new password is blacklisted.'; break;
19+
case 'INTERNAL_ERROR': $message = 'An internal error occurred while processing your request. Our staff have been notified of the issue. Try again later.'; break;
20+
default: $message = $error;
4421
}
45-
46-
require("./header.inc.phtml");
47-
?>
48-
<article>
49-
<?php if ($this->getContext()->error !== false) { ?>
50-
<header>Change Password</header>
51-
<?php if (!empty($message)) { ?>
52-
<section class="red">
53-
<p><?php echo $message; ?></p>
54-
</section>
55-
<?php } ?>
56-
<form method="POST" action="?">
57-
<section>
58-
<table><tbody><tr>
59-
<td colspan="2">
60-
<label for="pw1">Current password:</label><br/>
61-
<input type="password" name="pw1" id="pw1" tabindex="1"
62-
value="" required autofocus="autofocus"/>
63-
</td></tr><tr><td>
64-
<label for="pw2">New password:</label><br/>
65-
<input type="password" name="pw2" id="pw2" tabindex="2"
66-
value="" required/>
67-
</td><td>
68-
<label for="pw3">Confirm password:</label><br/>
69-
<input type="password" name="pw3" id="pw3" tabindex="3"
70-
value="" required/>
71-
</td></tr><tr><td colspan="2" style="padding-top:16px;">
72-
<input type="submit" value="Submit" tabindex="4"/>
73-
</td>
74-
</tr></tbody></table>
75-
</section>
76-
</form>
77-
<?php } else { ?>
78-
<header class="green">Password Changed</header>
79-
<section class="green">
80-
<p>You have successfully changed your password!</p>
81-
<p>Use the navigation to the left to move to another page.</p>
82-
</section>
83-
<?php } ?>
84-
</article>
85-
<?php require("./footer.inc.phtml"); ?>
22+
require('./header.inc.phtml'); ?>
23+
<div class="container mb-3">
24+
<div class="card mx-auto mb-3" style="width:18rem;">
25+
<h3 class="card-header text-lg-center"><?=$title?></h3>
26+
<div class="card-body">
27+
<? if ($error !== false) { ?>
28+
<? if (!empty($message)) { ?>
29+
<div class="alert alert-danger">
30+
<p class="mb-0"><?=$message?></p>
31+
</div>
32+
<? } ?>
33+
<form method="POST" action="?">
34+
<div class="form-group">
35+
<label class="form-input-label" for="pw1">Current password:</label>
36+
<input class="form-control border border-secondary bg-dark text-light" type="password" name="pw1" id="pw1" tabindex="1" value="" required autofocus="autofocus"/>
37+
</div>
38+
<div class="form-group">
39+
<label class="form-input-label" for="pw2">New password:</label><br/>
40+
<input class="form-control border border-secondary bg-dark text-light" type="password" name="pw2" id="pw2" tabindex="2" value="" required/>
41+
</div>
42+
<div class="form-group">
43+
<label class="form-input-label" for="pw3">Confirm password:</label><br/>
44+
<input class="form-control border border-secondary bg-dark text-light" type="password" name="pw3" id="pw3" tabindex="3" value="" required/>
45+
</div>
46+
<div class="form-group text-center">
47+
<hr class="border-secondary w-25"/>
48+
<input class="btn btn-success" type="submit" value="Change Password" tabindex="4"/>
49+
</div>
50+
</form>
51+
<? } else { ?>
52+
<div class="alert alert-success">
53+
<h4 class="alert-header">Password Changed</h4>
54+
<p class="mb-0">You have successfully changed your password!</p>
55+
</div>
56+
<? } ?>
57+
</div>
58+
</div>
59+
<div class="text-center">
60+
<a class="btn btn-primary" href="<?=Common::relativeUrlToAbsolute('/user/update')?>"><img class="float-left" src="<?=Common::relativeUrlToAbsolute('/a/svg/chevron-right-white.svg' . $_unique_asset)?>"/> Return to Update Profile</a>
61+
</div>
62+
</div>
63+
<? require('./footer.inc.phtml'); ?>

src/templates/User/View.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ require("./header.inc.phtml");
127127
<section>
128128
<table><tbody>
129129
<?php foreach ($this->getContext()->packets as $packet) { ?>
130-
<tr><td><a href="<?php echo $packet->getURI(); ?>"><?php echo filter_var($packet->getPacketDirectionTag(), FILTER_SANITIZE_FULL_SPECIAL_CHARS); ?> <?php echo filter_var($packet->getPacketId(true), FILTER_SANITIZE_FULL_SPECIAL_CHARS); ?> <?php echo filter_var($packet->getPacketName(), FILTER_SANITIZE_FULL_SPECIAL_CHARS); ?></a></td></tr>
130+
<tr><td><a href="<?=$packet->getURI()?>"><?=filter_var($packet->getName(), FILTER_SANITIZE_FULL_SPECIAL_CHARS)?></a></td></tr>
131131
<?php } ?>
132132
</tbody></table>
133133
</section>

0 commit comments

Comments
 (0)