index.php

main 90 lines · 2.8 KB Raw
Alex Alex Commit Initial commit 01/10/2026 09:20
1<?php
2/**
3 * Front page.
4 *
5 * Prepared by index.php:
6 * $changelogs changelog ticker entries, or false
7 * $news news articles, or false
8 * $page, $view pagination state
9 */
10
11 if ($config['allowSubPages'] && ($f = theme_file('sub/index.php')) !== null) include $f;
12 else {
13 if ($config['UseChangelogTicker']) {
14 theme_include('parts/changelog-ticker.php', array('changelogs' => $changelogs ?? false));
15 }
16
17 // Design and present the list
18 if ($news) {
19
20 $total_news = count($news);
21 $row_news = $total_news / $config['news_per_page'];
22 $page_amount = ceil($total_news / $config['news_per_page']);
23 $current = $config['news_per_page'] * $page;
24
25
26 if ($view !== "") { // We want to view a specific news post
27 $si = false;
28 if (ctype_digit($view) === false) {
29 for ($i = 0; $i < count($news); $i++) if ($view === urlencode($news[$i]['title'])) $si = $i;
30 } else {
31 for ($i = 0; $i < count($news); $i++) if ((int)$view === (int)$news[$i]['id']) $si = $i;
32 }
33
34 if ($si !== false) {
35 ?>
36 <table id="news">
37 <tr class="yellow">
38 <td class="zheadline"><?php echo '<a href="?view='.$news[$si]['id'].'">[#'.$news[$si]['id'].']</a> '. getClock($news[$si]['date'], true) .' '. t('news.by') .' <a href="characterprofile.php?name='. $news[$si]['name'] .'">'. $news[$si]['name'] .'</a> - <b>'. znote_bbcode_raw($news[$si]['title']) .'</b>'; ?></td>
39 </tr>
40 <tr>
41 <td>
42 <p><?php echo znote_bbcode_raw($news[$si]['text']); ?></p>
43 </td>
44 </tr>
45 </table>
46 <?php
47 } else {
48 ?>
49 <table id="news">
50 <tr class="yellow">
51 <td class="zheadline"><?= t('news.not_found') ?></td>
52 </tr>
53 <tr>
54 <td>
55 <p><?= t('news.not_found_text') ?></p>
56 </td>
57 </tr>
58 </table>
59 <?php
60 }
61
62 } else { // We want to view latest news or a page of news.
63
64 echo '<div class="znx-section-head">' . h(t_default('news.section_title', 'Latest News')) . '</div>';
65 for ($i = $current; $i < $current + $config['news_per_page']; $i++) {
66 if (isset($news[$i])) {
67 ?>
68 <table id="news">
69 <tr class="yellow">
70 <td class="zheadline"><?php echo '<a href="?view='.urlencode($news[$i]['title']).'">'.getClock($news[$i]['date'], true).'</a> '. t('news.by') .' <a href="characterprofile.php?name='. $news[$i]['name'] .'">'. $news[$i]['name'] .'</a> - <b>'. znote_bbcode_raw($news[$i]['title']) .'</b>'; ?></td>
71 </tr>
72 <tr>
73 <td>
74 <p><?php echo znote_bbcode_raw($news[$i]['text']); ?></p>
75 </td>
76 </tr>
77 </table>
78 <?php
79 }
80 }
81
82 theme_include('parts/pagination.php', array('page' => $page, 'page_amount' => $page_amount, 'baseUrl' => 'index.php'));
83
84 }
85
86 } else {
87 echo '<div class="znx-empty-box">'. h(t('news.none')) .'</div>';
88 }
89 }
90
Top