-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbody.php
234 lines (218 loc) · 6.15 KB
/
body.php
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
<?php
// prevent script from getting called directly
if (!defined("URLAUBE")) { die(""); }
?>
<!-- Empty Section so that no menu entry is active when scrolling to the top -->
<section id="empty" class="empty-section">
</section>
<?php
if (null !== value(Themes::class, PAGENAME)) {
?>
<div class="container">
<div class="row">
<!-- Blog Entries Column -->
<div class="col-lg-12">
<!-- Content Section containing the header text -->
<section id="header-text" class="header-section">
<h1 class="page-header">
<?= html(value(Themes::class, PAGENAME)) ?>
</h1>
</section>
</div>
</div>
</div>
<?php
}
?>
<!-- Page Content -->
<div class="container">
<div class="row">
<!-- Blog Entries Column -->
<div class="col-md-8">
<?php
// iterate through the content entries
$index = 0;
foreach (value(Main::class, CONTENT) as $content_item) {
$index++;
$author = value($content_item, AUTHOR);
$content = value($content_item, CONTENT).NL;
$sticky = value($content_item, StickyPlugin::STICKY);
$title = value($content_item, TITLE);
// get the category string and covert it into an array
$category = null;
$catvalue = value($content_item, CATEGORY);
if (is_string($catvalue)) {
$catvalue = explode(SP, $catvalue);
foreach ($catvalue as $catvalue_item) {
// make sure that only valid characters are contained
if (1 === preg_match("~^[0-9A-Za-z\_\-]+$~", $catvalue_item)) {
if (null === $category) {
$category = [];
}
// add category as lowercase string
$category[] = strtolower($catvalue_item);
}
}
if (null !== $category) {
// remove duplicates
$category = array_unique($category);
// sort the categories
sort($category);
}
}
// get the date and make sure that only parsable dates are displayed
$date = null;
$time = value($content_item, DATE);
if (is_string($time)) {
$time = strtotime($time);
if (false !== $time) {
$date = date(value(Themes::class, TIMEFORMAT), $time);
$time = getdate($time);
}
}
// link the headline only when it's not an error or a single page single page
$uri = null;
if ((ErrorHandler::class !== Handlers::getActive()) &&
(PageHandler::class !== Handlers::getActive())) {
$uri = value($content_item, URI);
}
?>
<!-- <?= html($title) ?> Section -->
<section id="section-<?= html($index) ?>" class="content-section">
<?php
if (null !== $title) {
?>
<h2>
<?php
if (null !== $uri) {
?>
<a href="<?= html($uri) ?>">
<?php
}
?>
<?= html($title.NL) ?>
<?php
if (null !== $uri) {
?>
</a>
<?php
}
?>
</h2>
<?php
}
if ((null !== $author) || (null !== $category) || (null !== $date)) {
?>
<p>
<?php
$metadata = new Content();
if (null !== $date) {
$metadata->set(ArchiveHandler::DAY, $time["mday"]);
$metadata->set(ArchiveHandler::MONTH, $time["mon"]);
$metadata->set(ArchiveHandler::YEAR, $time["year"]);
$link = ArchiveHandler::getUri($metadata);
?>
<span class="glyphicon glyphicon-time"></span>
<a href="<?= html($link) ?>"><?= html($date) ?></a>
<?php
}
if (null !== $author) {
$metadata->set(AUTHOR, $author);
$link = AuthorHandler::getUri($metadata);
?>
<span class="glyphicon glyphicon-user"></span>
<a href="<?= html($link) ?>"><?= html(str_replace("_", SP, $author)) ?></a>
<?php
}
if (null !== $category) {
?>
<span class="glyphicon glyphicon-tag"></span>
<?php
foreach ($category as $category_item) {
$metadata->set(CATEGORY, $category_item);
$link = CategoryHandler::getUri($metadata);
?>
<a href="<?= html($link) ?>"><?= html(str_replace("_", SP, $category_item)) ?></a>
<?php
}
}
if (istrue($sticky)) {
?>
<span class="glyphicon glyphicon-alert"></span>
<?php
}
?>
</p>
<?php
}
?>
<?= $content ?>
</section>
<hr>
<?php
}
// check if pagination is needed
if (1 < value(Main::class, PAGECOUNT)) {
$first = firstpage();
$last = lastpage();
$next = nextpage();
$prev = prevpage();
?>
<!-- Pager -->
<nav class="text-center">
<ul class="pagination pagination-lg">
<li class="<?= (null === $first) ? "disabled" : "" ?>">
<a href="<?= html($first) ?>">|«</a>
</li>
<li class="<?= (null === $prev) ? "disabled" : "" ?>">
<a href="<?= html($prev) ?>">«</a>
</li>
<li class="disabled">
<a href="<?= html(curpage()) ?>"><?= html(value(Main::class, PAGE)) ?></a>
</li>
<li class="<?= (null === $next) ? "disabled" : "" ?>">
<a href="<?= html($next) ?>">»</a>
</li>
<li class="<?= (null === $last) ? "disabled" : "" ?>">
<a href="<?= html($last) ?>">»|</a>
</li>
</ul>
</nav>
<?php
}
?>
</div>
<?php
Plugins::run(BEFORE_SIDEBAR);
// execute widget plugins and check that some have returned
$widgets = callwidgets();
if (is_array($widgets) && (0 < count($widgets))) {
?>
<!-- Sidebar Content -->
<div class="container">
<div class="row">
<div class="col-md-4">
<?php
// iterate through the content entries
foreach ($widgets as $widgets_item) {
if ($widgets_item instanceof Content) {
$title = value($widgets_item, TITLE);
$content = value($widgets_item, CONTENT).NL;
?>
<div class="well">
<h4><?= html($title) ?></h4>
<?= $content ?>
</div>
<?php
}
}
?>
</div>
</div>
</div>
<?php
}
Plugins::run(AFTER_SIDEBAR);
?>
</div>
</div>