Skip to content

Commit bd62c68

Browse files
committed
Fix formatting errors in document and packet view
1 parent 2a085e3 commit bd62c68

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

controllers/Packet/View.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ public function run(Router &$router) {
4343
} catch (PacketNotFoundException $e) {
4444
$model->packet = null;
4545
}
46-
$model->used_by = $this->getUsedBy($model->packet);
46+
if ($model->packet) {
47+
$model->used_by = $this->getUsedBy($model->packet);
48+
} else {
49+
$model->used_by = null;
50+
}
4751
$model->user_session = UserSession::load($router);
4852
ob_start();
4953
$view->render($model);

templates/Document/View.phtml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ use \BNETDocs\Libraries\Pair;
77
$object_id = $this->getContext()->document_id;
88
$object = $this->getContext()->document;
99

10-
$title = ($object ? $object->getTitle() : "Document Not Found");
11-
$description = Common::stripUpTo(trim(filter_var(
12-
($object ? $object->getContent(true) : "The requested document does not exist or could not be found."),
13-
FILTER_SANITIZE_STRING
14-
)), "\n", 300);
10+
$title = "Document Not Found";
11+
$description = "The requested document does not exist or could not be found.";
12+
1513
$this->opengraph->attach(new Pair("type", "article"));
1614

1715
$url = Common::relativeUrlToAbsolute("/document/" . urlencode($object_id));
1816
if ($object) {
1917
$url .= "/" . Common::sanitizeForUrl($object->getTitle(), true);
2018
$this->opengraph->attach(new Pair("url", "/document/" . urlencode($object_id)
2119
. "/" . Common::sanitizeForUrl($object->getTitle(), true)));
20+
$title = htmlspecialchars($object->getTitle(), ENT_HTML5, "UTF-8");
21+
$description = Common::stripUpTo(trim(filter_var(
22+
$object->getContent(true), FILTER_SANITIZE_STRING
23+
)), "\n", 300);
2224
} else {
2325
$this->opengraph->attach(new Pair("url", "/document/" . urlencode($object_id)));
2426
}
@@ -31,7 +33,7 @@ require("./header.inc.phtml");
3133
<a href="https://plus.google.com/share?url=<?php echo urlencode($url); ?>" rel="external" data-popup="1"><img class="social-btn float-right" src="<?php echo Common::relativeUrlToAbsolute("/a/social-gplus-24px.png"); ?>"/></a>
3234
<a href="https://twitter.com/share?text=<?php echo urlencode($object->getTitle()); ?>&amp;url=<?php echo urlencode($url); ?>" rel="external" data-popup="1"><img class="social-btn float-right" src="<?php echo Common::relativeUrlToAbsolute("/a/social-twitter-24px.png"); ?>"/></a>
3335
<a href="https://facebook.com/sharer/sharer.php?u=<?php echo urlencode($url); ?>" rel="external" data-popup="1"><img class="social-btn float-right" src="<?php echo Common::relativeUrlToAbsolute("/a/social-facebook-24px.png"); ?>"/></a>
34-
<header><a href="<?php echo $url; ?>"><?php echo htmlspecialchars($object->getTitle(), ENT_HTML5, "UTF-8"); ?></a></header>
36+
<header><a href="<?php echo $url; ?>"><?php echo $title; ?></a></header>
3537
<section>
3638
<?php echo $object->getContent(true); ?>
3739
</section>

templates/Packet/View.phtml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ use \BNETDocs\Libraries\Pair;
77
$object_id = $this->getContext()->packet_id;
88
$object = $this->getContext()->packet;
99

10-
$title = ($object ? $object->getPacketName() : "Packet Not Found");
11-
$description = Common::stripUpTo(trim(filter_var(
12-
($object ? $object->getPacketRemarks(true) : "The requested packet does not exist or could not be found."),
13-
FILTER_SANITIZE_STRING
14-
)), "\n", 300);
10+
$title = "Packet Not Found";
11+
$description = "The requested packet does not exist or could not be found.";
12+
$description = "The requested packet does not exist or could not be found.";
13+
1514
$this->opengraph->attach(new Pair("type", "article"));
1615

1716
$url = Common::relativeUrlToAbsolute("/packet/" . urlencode($object_id));
@@ -22,7 +21,11 @@ if ($object) {
2221

2322
$packet_id = $object->getPacketId(true);
2423
$title = htmlspecialchars($object->getPacketDirectionTag(), ENT_HTML5, "UTF-8")
25-
. " " . $packet_id . " " . $title;
24+
. " " . $packet_id . " "
25+
. htmlspecialchars($object->getPacketName(), ENT_HTML5, "UTF-8");
26+
$description = Common::stripUpTo(trim(filter_var(
27+
$object->getPacketRemarks(true), FILTER_SANITIZE_STRING
28+
)), "\n", 300);
2629
} else {
2730
$this->opengraph->attach(new Pair("url", "/packet/" . urlencode($object_id)));
2831
}
@@ -35,7 +38,7 @@ require("./header.inc.phtml");
3538
<a href="https://plus.google.com/share?url=<?php echo urlencode($url); ?>" rel="external" data-popup="1"><img class="social-btn float-right" src="<?php echo Common::relativeUrlToAbsolute("/a/social-gplus-24px.png"); ?>"/></a>
3639
<a href="https://twitter.com/share?text=<?php echo urlencode($packet_id . " " . $object->getPacketName()); ?>&amp;url=<?php echo urlencode($url); ?>" rel="external" data-popup="1"><img class="social-btn float-right" src="<?php echo Common::relativeUrlToAbsolute("/a/social-twitter-24px.png"); ?>"/></a>
3740
<a href="https://facebook.com/sharer/sharer.php?u=<?php echo urlencode($url); ?>" rel="external" data-popup="1"><img class="social-btn float-right" src="<?php echo Common::relativeUrlToAbsolute("/a/social-facebook-24px.png"); ?>"/></a>
38-
<header><a href="<?php echo $url; ?>"><?php echo htmlspecialchars($packet_id . " " . $object->getPacketName(), ENT_HTML5, "UTF-8"); ?></a></header>
41+
<header><a href="<?php echo $url; ?>"><?php echo $title; ?></a></header>
3942
<section>
4043
<table class="info"><tbody>
4144
<tr><th style="width:20%;">Message Id:</th><td><?php echo $packet_id; ?></td></tr>

0 commit comments

Comments
 (0)