Skip to content

Commit 8807891

Browse files
committed
Use more bootstrap UI in Packet View template
1 parent c497386 commit 8807891

File tree

1 file changed

+64
-38
lines changed

1 file changed

+64
-38
lines changed

src/Templates/Packet/View.phtml

Lines changed: 64 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ if ($object)
2020
$brief = $object->getBrief(true);
2121
$edited_dt = $object->getEditedDateTime();
2222
$packet_id = $object->getPacketId(true);
23-
$published = $object->isPublished();
23+
$draft = !$object->isPublished();
24+
$format = $object->getFormat();
2425
$remarks = $object->getRemarks(true);
2526
$research = $object->isInResearch();
2627
$tags = $object->getTags();
@@ -29,6 +30,8 @@ if ($object)
2930
$url = $object->getURI();
3031
$user = $object->getUser();
3132

33+
$format = filter_var($format, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
34+
3235
$description = filter_var($brief, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
3336
if (empty($description))
3437
{
@@ -53,51 +56,74 @@ require_once('./Includes/MarkdownBootstrapFix.inc.php');
5356
require('./Includes/header.inc.phtml'); ?>
5457
<div class="container">
5558
<? if ($object) { ?>
59+
5660
<? if ($delete_visible) { ?>
5761
<a class="btn btn-sm btn-danger float-right mr-1" href="<?=$delete_url?>" title="Delete">❌</a>
5862
<? } if ($edit_visible) { ?>
5963
<a class="btn btn-sm btn-secondary float-right mr-1" href="<?=$edit_url?>" title="Edit">📝</a>
6064
<? } ?>
6165

6266
<h1><a href="<?=$url?>"><?=filter_var($title, FILTER_SANITIZE_FULL_SPECIAL_CHARS)?></a></h1>
63-
<table class="table table-striped"><tbody>
64-
<tr><th class="text-right">Transport Layer:</th><td><?=sprintf('%s (%s)', $transport_layer->getLabel(), $transport_layer->getTag())?></td></tr>
65-
<tr><th class="text-right">Application Layer:</th><td><?=sprintf('%s (%s)', $application_layer->getLabel(), $application_layer->getTag())?></td></tr>
66-
<tr><th class="text-right">Message Id:</th><td><code><?=$packet_id?></code></td></tr>
67-
<tr><th class="text-right">Message Name:</th><td><code><?=filter_var($object->getName(), FILTER_SANITIZE_FULL_SPECIAL_CHARS)?></code></td></tr>
68-
<tr><th class="text-right">Direction:</th><td><?=filter_var($object->getDirectionLabel(), FILTER_SANITIZE_FULL_SPECIAL_CHARS)?></td></tr>
69-
<? if ($deprecated || $research || !$published) { ?>
70-
<tr><th class="text-right">Options:</th><td>
71-
<? if ($deprecated) require('./Includes/Deprecated.inc.phtml'); ?>
72-
<? if ($research) require('./Includes/InResearch.inc.phtml'); ?>
73-
<? if (!$published) require('./Includes/Draft.inc.phtml'); ?>
74-
</td></tr>
67+
68+
<div class="card mb-3">
69+
<div class="card-body">
70+
<div class="row">
71+
<div class="col-md-6 mb-2">
72+
<strong>Transport Layer:</strong>
73+
<?=sprintf('%s (%s)', $transport_layer->getLabel(), $transport_layer->getTag())?>
74+
</div>
75+
<div class="col-md-6 mb-2">
76+
<strong>Application Layer:</strong>
77+
<?=sprintf('%s (%s)', $application_layer->getLabel(), $application_layer->getTag())?>
78+
</div>
79+
<div class="col-md-6 mb-2">
80+
<strong>Message Id:</strong>
81+
<code><?=$packet_id?></code>
82+
</div>
83+
<div class="col-md-6 mb-2">
84+
<strong>Message Name:</strong>
85+
<code><?=filter_var($object->getName(), FILTER_SANITIZE_FULL_SPECIAL_CHARS)?></code>
86+
</div>
87+
<div class="col-md-6 mb-2">
88+
<strong>Direction:</strong>
89+
<?=$object->getDirectionLabel()?>
90+
</div>
91+
<? if ($deprecated || $research || $draft) { ?>
92+
<div class="col-md-6 mb-2">
93+
<strong>Options:</strong><br/>
94+
<? if ($deprecated) require('./Includes/Deprecated.inc.phtml'); ?>
95+
<? if ($research) require('./Includes/InResearch.inc.phtml'); ?>
96+
<? if ($draft) require('./Includes/Draft.inc.phtml'); ?>
97+
</div>
98+
<? } ?>
99+
<div class="col-12 mb-2">
100+
<strong>Used By:</strong><br/>
101+
<div class="d-flex flex-wrap mt-1"><?
102+
$products = $this->getContext()->used_by;
103+
if (empty($products)) {
104+
echo '<em>(nothing or unknown)</em>';
105+
} else {
106+
foreach ($products as $product) {
107+
$label = $product->getLabel();
108+
echo '<span class="badge badge-primary mr-2 mb-2">' . $label . '</span>';
109+
}
110+
}
111+
?></div>
112+
</div>
113+
<div class="col-12">
114+
<strong>Message Format:</strong><br/>
115+
<small class="text-muted">(does not include <a rel="external" href="https://bnetdocs.org/document/16/protocol-headers">protocol header</a>)</small>
116+
<pre class="border border-primary overflow-auto rounded bg-dark text-light"><code class="language-objectivec"><?=$format?></code></pre>
117+
</div>
118+
<? if (!empty($brief)) { ?>
119+
<div class="col-12">
120+
<strong>Brief:</strong><br/>
121+
<?=\BNETDocs\Templates\Includes\MarkdownBootstrapFix($brief, true, true)?>
122+
</div>
75123
<? } ?>
76-
<tr><th class="text-right">Used By:</th><td><?
77-
$products = $this->getContext()->used_by;
78-
if (count($products) == 0) {
79-
echo '<em>(nothing or unknown)</em>';
80-
} else if (count($products) == 1) {
81-
echo filter_var($products[0]->getLabel(), FILTER_SANITIZE_FULL_SPECIAL_CHARS);
82-
} else {
83-
$j = count($this->getContext()->used_by);
84-
for ($i = 0; $i < $j; ++$i) {
85-
echo filter_var($this->getContext()->used_by[$i]->getLabel(), FILTER_SANITIZE_FULL_SPECIAL_CHARS);
86-
if ($i + 1 < $j) {
87-
++$i;
88-
echo ', ';
89-
echo filter_var($this->getContext()->used_by[$i]->getLabel(), FILTER_SANITIZE_FULL_SPECIAL_CHARS) . "<br/>";
90-
} else {
91-
echo "<br/>";
92-
}
93-
}
94-
}
95-
?></td></tr>
96-
<tr><th class="text-right">Message Format:<br/><sup class="text-muted">(does not include <a rel="external" href="https://bnetdocs.org/document/16/protocol-headers">protocol header</a>)</sup></th><td>
97-
<pre class="border border-primary overflow-auto rounded bg-dark text-light"><code class="language-objectivec"><?=$object->getFormat()?></code></pre>
98-
</td></tr>
99-
<?=(!empty($brief) ? sprintf('<tr><th class="text-right">Brief:</th><td>%s</td></tr>', \BNETDocs\Templates\Includes\MarkdownBootstrapFix($brief, true, true)) : '')?>
100-
</tbody></table>
124+
</div>
125+
</div>
126+
</div>
101127

102128
<h1>Remarks</h1>
103129
<div class="container"><?=\BNETDocs\Templates\Includes\MarkdownBootstrapFix($remarks, true, false)?></div>

0 commit comments

Comments
 (0)