11<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */
22namespace BNETDocs \Templates \Packet ;
3- use \BNETDocs \Libraries \Comment ;
4- use \CarlBennett \MVC \Libraries \Common ;
53use \CarlBennett \MVC \Libraries \Pair ;
64$ title = 'Edit Packet ' ;
75$ description = 'This form allows an individual to edit a packet. ' ;
@@ -26,75 +24,24 @@ $packet_name = filter_var($this->getContext()->name, FILTER_SANITIZE_FULL_SPECIA
2624$ packet_remarks = filter_var ($ this ->getContext ()->remarks , FILTER_SANITIZE_FULL_SPECIAL_CHARS );
2725$ packet_used_by = $ this ->getContext ()->used_by ;
2826$ products = $ this ->getContext ()->products ;
29- require ('./header.inc.phtml ' ); ?>
30- <div class="container">
31- <? if ($ error !== false ) { ?>
32- <h1>Edit Packet</h1>
33- <? if (!empty ($ message )) { ?>
34- <div class="alert alert-danger"><p class="mb-0"><?= $ message?> </p></div>
35- <? } ?>
36- <? if ($ error != 'NOT_FOUND ' ) { ?>
37- <form method="POST" action="?id=<?= $ packet_id?> ">
38- <div class="row">
39- <div class="col-md-3">
40- <div class="form-group">
41- <label class="font-weight-bold" for="id">Id:</label>
42- <input class="bg-dark border border-primary form-control text-light" type="text" name="id" id="id" placeholder="Enter the message id here" tabindex="1" required autofocus="autofocus" value="<?= $ id?> "/>
43- </div>
44- </div><div class="col-md-6">
45- <div class="form-group">
46- <label class="font-weight-bold" for="name">Name:</label>
47- <input class="bg-dark border border-primary form-control text-light" type="text" name="name" id="name" placeholder="Enter the message name here" tabindex="2" required value="<?= $ packet_name?> "/>
48- </div>
49- </div><div class="col-md-3">
50- <div class="form-group">
51- <label class="font-weight-bold">Options:</label>
52- <div class="custom-control custom-switch"><input class="custom-control-input" type="checkbox" id="deprecated" name="deprecated" value="1"<?= ($ this ->getContext ()->deprecated ?' checked="checked" ' :'' )?> tabindex="6"/><label class="custom-control-label text-danger" for="deprecated">Deprecated</label></div>
53- <div class="custom-control custom-switch"><input class="custom-control-input" type="checkbox" id="research" name="research" value="1"<?= ($ this ->getContext ()->research ?' checked="checked" ' :'' )?> tabindex="7"/> <label class="custom-control-label text-warning" for="research">In Research</label></div>
54- <div class="custom-control custom-switch"><input class="custom-control-input" type="checkbox" id="published" name="published" value="1"<?= ($ this ->getContext ()->published ?' checked="checked" ' :'' )?> tabindex="8"/> <label class="custom-control-label text-success" for="published">Published</label></div>
55- </div>
56- </div>
57- </div>
58- <div class="form-group">
59- <label class="font-weight-bold" for="format">Format:</label>
60- <textarea class="bg-dark border border-primary form-control language-objectivec text-light text-monospace" style="height:120px;" name="format" id="format" placeholder="Enter the message format here" tabindex="3" required><?= $ packet_format?> </textarea>
61- </div>
62- <div class="form-group">
63- <label class="font-weight-bold">Used by:</label>
64- <table class="table table-borderless table-sm">
65- <thead></thead><tbody>
66- <? $ product_ubound = count ($ products );
67- for ($ product_i = 0 ; $ product_i < $ product_ubound ; ++$ product_i )
68- {
69- if ($ product_i % 2 === 0 ) echo '<tr> ' ;
70- $ p = $ products [$ product_i ];
71- $ p_id = $ p ->getBnetProductId ();
72- $ p_label = $ p ->getLabel ();
73- printf ('<td><div class="custom-control custom-switch"><input class="custom-control-input" type="checkbox" id="used_by_%s" name="used_by[]" value="%s"%s/><label class="custom-control-label" for="used_by_%s">%s</label></div></td> ' , $ p_id , $ p_id , (in_array ($ p , $ packet_used_by ) ? ' checked="checked" ' : '' ), $ p_id , $ p_label );
74- if ($ product_i % 2 === 1 ) echo '</tr> ' ;
75- } ?>
76- </tbody>
77- </table>
78- </div>
79- <div class="form-group">
80- <label class="font-weight-bold" for="remarks">Remarks:</label>
81- <span class="float-right">
82- <div class="custom-control custom-switch">
83- <input class="custom-control-input" type="checkbox" name="markdown" id="markdown" tabindex="5"
84- title="Use markdown or use raw HTML" value="1"<?= ($ this ->getContext ()->markdown ?' checked="checked" ' :'' )?> />
85- <label class="custom-control-label" for="markdown" title="Use markdown or use raw HTML">Markdown</label>
86- </div>
87- </span>
88- <textarea class="bg-dark border border-primary form-control text-light" style="height:200px;" name="remarks" id="remarks" placeholder="Enter the message remarks here" tabindex="4" required><?= $ packet_remarks?> </textarea>
89- </div>
90- <div class="form-group text-center">
91- <input class="btn btn-success" type="submit" value="Save" tabindex="9"/>
92- </div>
93- </form>
94- <? $ comment_parent_type = Comment::PARENT_TYPE_PACKET ; $ comment_parent_id = $ packet_id ; require ('./Comment/Section.inc.phtml ' ); } ?>
95- <? } else { ?>
96- <h1 class="text-success">Edit Packet</h1>
97- <div class="alert alert-success"><p class="mb-0">Your packet has been edited.</p></div>
98- <? } ?>
99- </div>
100- <? require ('./footer.inc.phtml ' ); ?>
27+ require ('./header.inc.phtml ' );
28+ echo '<div class="container"> ' . PHP_EOL ;
29+ if ($ error !== false )
30+ {
31+ printf ('<h1>%s</h1>%s ' , $ title , PHP_EOL );
32+ if (!empty ($ message ))
33+ {
34+ printf ('<div class="alert alert-danger"><p class="mb-0">%s</p></div>%s ' , $ message , PHP_EOL );
35+ }
36+ if ($ error != 'NOT_FOUND ' )
37+ {
38+ require ('./Packet/Form.inc.phtml ' );
39+ }
40+ }
41+ else
42+ {
43+ printf ('<h1 class="text-success">%s</h1>%s ' , $ title , PHP_EOL );
44+ printf ('<div class="alert alert-success"><p class="mb-0">The packet has been edited successfully!</p></div>%s ' , PHP_EOL );
45+ }
46+ echo '</div> ' . PHP_EOL ;
47+ require ('./footer.inc.phtml ' );
0 commit comments