summaryrefslogtreecommitdiffstats
path: root/app/view/stdpage.php
blob: 46f89ec6de25ae1487e4e7d81ed3aaa35f712df3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php

/*
 * SCROTT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * For more information, please refer to UNLICENSE
 */

namespace stdpage;

require_once "class/globals.php";
require_once "class/user.class.php";
require_once "view/datamods.php";
require_once "view/settings.php";

?>
<?php function head(?string $title = NULL) : void { ?>

    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />

    <title>Scrott<?=($title ? " - ".$title : "")?></title>

    <link rel="stylesheet" type="text/css" href="<?=ar()?>/static/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="<?=ar()?>/static/css/bootstrap-select.min.css" />

    <style type="text/css">
        body
        {
            padding-top: 70px;

            <?php if (getPageObj() && ($pagebg = getPageObj()->getBgImg())) { ?>
                background: url(<?=$pagebg?>) no-repeat center center fixed;
                -webkit-background-size: cover;
                -moz-background-size: cover;
                -o-background-size: cover;
                background-size: cover;
            <?php } ?>
        }
    </style>

<?php } ?>
<?php function top() : void { ?>

    <?php require "model/noticemodal.php"; ?>

    <?php if (isError(ERROR) || isError(WARNING) || isError(NOTICE)) { ?>
        <div id="noticeModal" class="modal fade" tabindex="-1" role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-body alert <?=$noticeModalAlertClass?>" style="margin: 0;">
                        <h1 class="text-center"><span class="glyphicon <?=$noticeModalGlyphicon?>"></span></h1>
                        <h5 class="text-center">Something Happened</h5>

                        <?php if (isError(ERROR)) { ?>
                            <p>
                                <?php foreach (getErrors(ERROR) as $err) { ?>
                                    <span class="label label-danger">Error</span> <?=$err?><br />
                                <?php } ?>
                            </p>
                        <?php } ?>

                        <?php if (isError(WARNING)) { ?>
                            <p>
                                <?php foreach (getErrors(WARNING) as $err) { ?>
                                    <span class="label label-warning">Warning</span> <?=$err?><br />
                                <?php } ?>
                            </p>
                        <?php } ?>

                        <?php if (isError(NOTICE)) { ?>
                            <p>
                                <?php foreach (getErrors(NOTICE) as $err) { ?>
                                    <span class="label label-info">Notice</span> <?=$err?><br />
                                <?php } ?>
                            </p>
                        <?php } ?>

                        <div class="text-center">
                            <button type="button" class="btn btn-default" data-dismiss="modal">
                                <span class="glyphicon glyphicon-ok"></span> Got it
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    <?php } ?>

<?php } ?>
<?php function foot() : void { ?>

    <script type="text/javascript" src="<?=ar()?>/static/js/jquery.min.js"></script>
    <script type="text/javascript" src="<?=ar()?>/static/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="<?=ar()?>/static/js/bootstrap-select.min.js"></script>

    <?php if (isError(ERROR) || isError(WARNING) || isError(NOTICE)) { ?>
        <script type="text/javascript">
            $(window).on('load', function () {
                $("#noticeModal").modal("show");
            });
        </script>
    <?php } else if (getAutoModal() != "") { ?>
        <script type="text/javascript">
            $(window).on('load', function () {
                $("<?=getAutoModal()?>").modal("show");
                $("<?=getAutoModal()?>").animate({ scrollTop: $("<?=getAutoModal()?> .modal-dialog").height() }, 0);
            });
        </script>
    <?php } ?>

    <script type="text/javascript">
        $(".issueListItem").click(function () {
            $("#issueModal-"+$(this).data("guid")).modal("show");
        });

        function assertconfirm() {
            return confirm("Are you sure?");
        }
    </script>

<?php } ?>
<?php function about() : void { ?>

    <div id="aboutModal" class="modal fade" tabindex="-1" role="dialog">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-body text-center" style="margin: 0;">
                    <h1><span class="glyphicon glyphicon-pencil"></span> Scrott</h1>
                    <h3><span class="label label-primary"><?=__VERSION__?></span></h3>
                    <br />
                    Scrott is free, <a href="http://unlicense.org/">public domain</a> software.<br />
                    Scrott is provided "as is", without warranty of any kind.
                </div>
            </div>
        </div>
    </div>

<?php } ?>
<?php function nav() : void { ?>

    <?=about()?>

    <?php if (\user::getCurrent()) { ?>
        <?=\settings\settings()?>
        <?=\datamods\newGroup()?>
        <?=\datamods\newPad()?>

        <?php if (getPageObj()->objtype == "pad") { ?>
            <?=\datamods\newIssue()?>
        <?php } ?>
    <?php } ?>

    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#scrottnav" aria-expanded="false">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>

                <a href="<?=ar()?>/" class="navbar-brand" title="Dashboard">
                    <span class="glyphicon glyphicon-pencil"></span> Scrott
                </a>
            </div>

            <div class="collapse navbar-collapse" id="scrottnav">
                <?php if (!\user::getCurrent()) { ?>
                    <p class="navbar-text navbar-right"><i>Not Logged In&nbsp;&nbsp;&nbsp;</i></p>
                <?php } else { ?>
                    <ul class="nav navbar-nav">
                        <li><a href="<?=ap()?>" title="Reload Content"><span class="glyphicon glyphicon-refresh"></span></a></li>
                        <li><a href="<?=ar()?>/groups" title="My Groups"><span class="glyphicon glyphicon-th"></span></a></li>
                        <li><a href="<?=ar()?>/pads" title="My Pads"><span class="glyphicon glyphicon-edit"></span></a></li>

                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" title="Quickjump" data-toggle="dropdown" aria-expanded="false">
                                <?=getPageName()?> <span class="caret"></span>
                            </a>

                            <ul class="dropdown-menu">
                                <li><a href="#">TODO</a></li>
                                <li><a href="#">TODO</a></li>
                                <li><a href="#">TODO</a></li>
                            </ul>
                        </li>

                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" title="Create Something" data-toggle="dropdown" aria-expanded="false">
                                <span class="glyphicon glyphicon-plus"></span> <span class="caret"></span>
                            </a>

                            <ul class="dropdown-menu">
                                <li><a href="#" data-toggle="modal" data-target="#newGroupModal">New Group</a></li>
                                <li><a href="#" data-toggle="modal" data-target="#newPadModal">New Pad</a></li>

                                <?php if (getPageObj()->objtype == "pad") { ?>
                                    <li class="divider"></li>
                                    <li><a href="#" data-toggle="modal" data-target="#newIssueModal">New Issue</a></li>
                                <?php } ?>
                            </ul>
                        </li>
                    </ul>

                    <ul class="nav navbar-nav navbar-right">
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" title="Options" data-toggle="dropdown" aria-expanded="false">
                                <?php if (\user::getCurrent()->admin == 1) { ?>
                                    <span class="glyphicon glyphicon-sunglasses"></span>
                                <?php } ?>

                                <span class="glyphicon glyphicon-user"></span>
                                &nbsp;
                                <?=\user::getCurrent()->getDisplayName()?>
                                <span class="caret"></span>
                            </a>

                            <ul class="dropdown-menu">
                                <li><a href="#" data-toggle="modal" data-target="#aboutModal">About Scrott</a></li>
                                <li><a href="#" data-toggle="modal" data-target="#settingsModal">Settings</a></li>
                                <li><a href="<?=ar()?>/logout">Log out</a></li>
                            </ul>
                        </li>
                    </ul>
                <?php } ?>
            </div>
        </div>
    </nav>

<?php } ?>