summaryrefslogtreecommitdiff
path: root/html/app/views/simple/post.php
blob: 9e37cd92448817c537692e34a1e66d4bd3a50b02 (plain)
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
<?php
// init app
// -----------------------------------------------------------------------------
include 'pythia.php';

// read request parameters
// -----------------------------------------------------------------------------
$post_id = intval($_GET['id']);


// Get all data needed
// (so you don't have to make multiple requests to the wiki-database)
// -----------------------------------------------------------------------------

$post = $wiki->get_post($post_id);
$categories = $wiki->category_tree();
$breadcrumbs = Render::all_breadcrumbs($categories);

if ($post == false) {   // when post not found
    $post = [           // create a virtual record with error messages
        'id' => 0,
        'title' => 'Το άρθρο που αναζητήσατε δεν υπάρχει',
        'category_id' => 0,
        'intro' => 'Για να βρειτε το άρθρο που ψάχνετε χρησιμοποιήστε την αναζήτηση
            του wiki ή πλοηγηθείτε στο δέντρο των κατηγοριών.',
        'body' => ""
    ];

} else {    // post found; prepare article's data to render

    $category_id = $post['category_id'];

    // find parent_ids of current category (to open the menu tree)
    $category_path = [];
    foreach($breadcrumbs[$category_id]['parents'] as $parent) {
        $category_path[] = intval($parent['id']);
    }
    $category_path[] = intval($category_id);

}


// format special parts of post
$parsedown = new Parsedown();
$body_html = $parsedown->text($post['body']); // body: markdown to html

// decode json output (tags + medias)
if ($post['tags_json'] != null)     { $tags = json_decode($post['tags_json']); }
if ($post['medias_json'] != null)   { $medias = json_decode($post['medias_json']); }


// then render the page ...
// -----------------------------------------------------------------------------
?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Wiki</title>

    <?php Render::template("sections/common_libs.php", [ 'admin' => false ]); ?>

<body>
    <?php include HEAD; ?>

    <div class="container-fluid main-content wiki">

        <div class="top-bar">
            <div class="breadcrumb">

                <?php if($post['id'] != 0) : ?>
                <?php    // breadcrumbs
                    ////////////////////////////////////////////////////////////
                    Render::template("sections/breadcrumbs.php", [
                        'id' => $post['category_id'],
                        'title' => $breadcrumbs[ $post['category_id'] ]['rec']['title'],
                        'parents' => $breadcrumbs[ $post['category_id'] ]['parents']
                    ]);     ////////////////////////////////////////////////////
                ?>
                <?php endif ?>

            </div>

            <div class="admin">
                <?php include "sections/admin-dropdown.php"; ?>
            </div>

        </div><!-- /top-bar -->

        <div class="row">

            <div class="col-xl-2 col-lg-3 col-sm-4 side-bar">

                <!-- <h3>Κατηγορίες</h3> -->
                <?php    // categories hierarchical menu
                    ////////////////////////////////////////////////////////////
                    Render::template("sections/categories_menu.php", [
                        'categories' => $categories,
                        'open_path' => (($post['id'] == 0)
                            ? [1,2,3]           // post not exist; open main categories
                            : $category_path)   // post exists: open category path
                    ]);     ////////////////////////////////////////////////////
                ?>

            </div>

            <div class="col-xl-10 col-lg-9 col-sm-8 content">
                
                <!-- THE POST -->
                <div class="content--wrapper post">

                    <!-- title -->
                    <h2>
                        <?=$post['title']?>
                        <?php if (UGMC(array(61,63), $user_id)) : ?>
                            <span>
                                <a href="/wiki/admin?action=editpost&id=<?=$post_id?>" class="btn btn-xs btn-warning">
                                    <i class="fas fa-pencil-alt"></i>
                                </a>
                            </span>
                        <?php endif; ?>
                    </h2>

                    <!-- date -->
                    <p class="post--date">
                        Δημοσίευση: <?=Render::date_friendly($post['creation_date'])?>
                        <?php if ($post['update_date'] != $post['creation_date']) : ?>
                        — Τελευταία Ενημέρωση: <?=Render::date_friendly($post['update_date'])?>
                        <?php endif; ?>
                    </p>

                    <!-- intro -->
                    <?php if ($post['intro'] != "") : ?>
                        <p class="intro"><?=$post['intro']?></p>
                    <?php endif; ?>

                    <!-- body -->
                    <div class="article-body">
                        <?=$body_html?>
                    </div>

                    <?php if(isset($medias)) : ?>
                    <!-- medias / attachments -->
                    <div class="medias">
                        <h4>Συνημμένα:</h4>
                        <ol>
                            <?php foreach($medias as $file) : ?>
                                <?php if ($file->reference == 1) : ?>
                                    <li>
                                        <a  href="<?=CDN?><?=$file->path?>"
                                            data-type="<?=$file->type?>"
                                            target="_blank">
                                            <?=$file->title?>
                                        </a>
                                    </li>
                                <?php endif; ?>
                            <?php endforeach; ?>
                        </ol>
                    </div>
                    <?php endif; ?>

                    <?php if(isset($tags)) : ?>
                    <!-- tags -->
                    <div class="tags">
                        Επικέτες:
                        <?php foreach($tags as $tag) : ?>
                        <a href="/wiki/tag?id=<?=$tag->id?>"><?=$tag->name?></a>
                        <?php endforeach; ?>
                    </div>
                    <?php endif; ?>

                </div>
                
            </div><!-- /content (post) -->

        </div>
    </div><!-- /main-content -->


    <!-- MODALS -->

    <!-- product-modal -->
    <div id="view-product" class="modal" tabindex="-1" >
    <div class="modal-dialog modal-lg"> 
        <div class="modal-content"> 

            <div class="modal-header"> 
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> 
                <h4 class="modal-title">
                    <i class="glyphicon glyphicon-tag"></i> Στοιχεία Προϊόντος
                </h4> 
            </div> 
            <div class="modal-body"> 

                <div id="modal-loader" style="display: none; text-align: center;">
                    <img src="<?php echo RP ?>img/ajax-loader.gif">
                </div>

                <div id="dynamic-product"></div>

            </div> 
            <div class="modal-footer"> 
                <button type="button" class="btn btn-default" data-dismiss="modal">Κλείσιμο</button>  
            </div> 

        </div> 
    </div>
    </div><!-- /product-modal -->

    <!-- store-modal -->
    <div id="view-store" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="store-title"  aria-hidden="true" style="display: none; z-index: 2000;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> 
                    <h4 class="modal-title">
                    <i class="glyphicon glyphicon-shopping-cart"></i> Πληροφορίες Καταστήματος
                    </h4>
                </div>
                <div class="modal-body">
                    <div id="mapCanvas" style="height: 300px"></div>
                    <div id="modal-loader-store" style="display: none; text-align: center;">
                    <img src="<?php echo RP ?>img/ajax-loader.gif">
                    </div>
                    <div id="dynamic-content"></div>
                </div>
                <div class="modal-footer"> 
                    <button type="button" class="btn btn-default" data-dismiss="modal">Κλείσιμο</button>  
                </div>
            </div>
        </div>
    </div><!-- /store-modal -->

    <script src="/wiki/js/wiki.js"></script>
    <script src="/wiki/js/post-features.js"></script>
</body>
</html>