1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* The main start page with the Top10 and the latest messages. |
5
|
|
|
* |
6
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public License, |
7
|
|
|
* v. 2.0. If a copy of the MPL was not distributed with this file, You can |
8
|
|
|
* obtain one at http://mozilla.org/MPL/2.0/. |
9
|
|
|
* |
10
|
|
|
* @package phpMyFAQ |
11
|
|
|
* @author Thorsten Rinne <[email protected]> |
12
|
|
|
* @copyright 2002-2019 phpMyFAQ Team |
13
|
|
|
* @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 |
14
|
|
|
* @link https://www.phpmyfaq.de |
15
|
|
|
* @since 2002-08-23 |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
use phpMyFAQ\Filter; |
19
|
|
|
use phpMyFAQ\News; |
20
|
|
|
use phpMyFAQ\Strings; |
21
|
|
|
|
22
|
|
View Code Duplication |
if (!defined('IS_VALID_PHPMYFAQ')) { |
23
|
|
|
$protocol = 'http'; |
24
|
|
|
if (isset($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) === 'ON') { |
25
|
|
|
$protocol = 'https'; |
26
|
|
|
} |
27
|
|
|
header('Location: '.$protocol.'://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])); |
28
|
|
|
exit(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
$news = new News($faqConfig); |
32
|
|
|
|
33
|
|
|
$archived = Filter::filterInput(INPUT_GET, 'newsid', FILTER_VALIDATE_INT); |
34
|
|
|
$writeNewsRSS = ''; |
35
|
|
|
|
36
|
|
|
if (!is_null($archived)) { |
37
|
|
|
$writeNewsHeader = $PMF_LANG['newsArchive']; |
38
|
|
|
$showAllNews = sprintf('<a href="?%s">%s</a>', $sids, $PMF_LANG['newsShowCurrent']); |
39
|
|
|
$archived = true; |
40
|
|
|
} else { |
41
|
|
|
$writeNewsHeader = ' '.$PMF_LANG['msgNews']; |
42
|
|
|
if ($faqConfig->get('main.enableRssFeeds')) { |
43
|
|
|
$writeNewsRSS = ' <a href="feed/news/rss.php" target="_blank">'. |
44
|
|
|
'<i class="fas fa-rss-square"></i></a>'; |
45
|
|
|
} |
46
|
|
|
$showAllNews = sprintf('<a href="?%snewsid=0">%s</a>', $sids, $PMF_LANG['newsShowArchive']); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$startPageCategories = $category->getHomeCategories(); |
50
|
|
|
if (count($startPageCategories) > 0) { |
51
|
|
|
$template->parseBlock( |
52
|
|
|
'writeContent', |
53
|
|
|
'startPageCategories', |
54
|
|
|
[ |
55
|
|
|
'categoryUrl' => $startPageCategories['url'], |
56
|
|
|
'categoryName' => $startPageCategories['name'], |
57
|
|
|
'categoryDescription' => $startPageCategories['description'], |
58
|
|
|
'categoryImage' => $startPageCategories['image'] |
59
|
|
|
] |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$stickyRecordsParams = $faq->getStickyRecords(); |
64
|
|
|
if (!isset($stickyRecordsParams['error'])) { |
65
|
|
|
$template->parseBlock( |
66
|
|
|
'writeContent', |
67
|
|
|
'stickyRecordsList', |
68
|
|
|
[ |
69
|
|
|
'stickyTitle' => $stickyRecordsParams['title'], |
70
|
|
|
'stickyUrl' => $stickyRecordsParams['url'], |
71
|
|
|
'stickyPreview' => $stickyRecordsParams['preview'] |
72
|
|
|
] |
73
|
|
|
); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
// generate top ten list |
77
|
|
|
if ($faqConfig->get('records.orderingPopularFaqs') == 'visits') { |
78
|
|
|
$param = 'visits'; |
79
|
|
|
} else { |
80
|
|
|
$param = 'voted'; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
$toptenParams = $faq->getTopTen($param); |
84
|
|
View Code Duplication |
if (!isset($toptenParams['error'])) { |
85
|
|
|
$template->parseBlock( |
86
|
|
|
'writeContent', |
87
|
|
|
'toptenList', |
88
|
|
|
array( |
89
|
|
|
'toptenUrl' => $toptenParams['url'], |
90
|
|
|
'toptenTitle' => $toptenParams['title'], |
91
|
|
|
'toptenPreview' => $toptenParams['preview'], |
92
|
|
|
'toptenVisits' => $toptenParams[$param], |
93
|
|
|
) |
94
|
|
|
); |
95
|
|
|
} else { |
96
|
|
|
$template->parseBlock( |
97
|
|
|
'writeContent', |
98
|
|
|
'toptenListError', |
99
|
|
|
array( |
100
|
|
|
'errorMsgTopTen' => $toptenParams['error'], |
101
|
|
|
) |
102
|
|
|
); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
$latestEntriesParams = $faq->getLatest(); |
106
|
|
View Code Duplication |
if (!isset($latestEntriesParams['error'])) { |
107
|
|
|
$template->parseBlock( |
108
|
|
|
'writeContent', |
109
|
|
|
'latestEntriesList', |
110
|
|
|
array( |
111
|
|
|
'latestEntriesUrl' => $latestEntriesParams['url'], |
112
|
|
|
'latestEntriesTitle' => $latestEntriesParams['title'], |
113
|
|
|
'latestEntriesPreview' => $latestEntriesParams['preview'], |
114
|
|
|
'latestEntriesDate' => $latestEntriesParams['date'], |
115
|
|
|
) |
116
|
|
|
); |
117
|
|
|
} else { |
118
|
|
|
$template->parseBlock( |
119
|
|
|
'writeContent', |
120
|
|
|
'latestEntriesListError', |
121
|
|
|
[ |
122
|
|
|
'errorMsgLatest' => $latestEntriesParams['error'] |
123
|
|
|
] |
124
|
|
|
); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
$template->parseBlock( |
128
|
|
|
'writeContent', |
129
|
|
|
'tagListSection', |
130
|
|
|
[ |
131
|
|
|
'msgTags' => $PMF_LANG['msgPopularTags'], |
132
|
|
|
'tagList' => $oTag->renderPopularTags(12) |
133
|
|
|
] |
134
|
|
|
); |
135
|
|
|
|
136
|
|
|
$template->parse( |
137
|
|
|
'writeContent', |
138
|
|
|
[ |
139
|
|
|
'baseHref' => $faqSystem->getSystemUri($faqConfig), |
140
|
|
|
'stickyRecordsHeader' => $PMF_LANG['stickyRecordsHeader'], |
141
|
|
|
'writeTopTenHeader' => $PMF_LANG['msgTopTen'], |
142
|
|
|
'rssFeedTopTen' => $rssFeedTopTen, |
143
|
|
|
'writeNewestHeader' => $PMF_LANG['msgLatestArticles'], |
144
|
|
|
'rssFeedLatest' => $rssFeedLatest, |
145
|
|
|
'writeNewsHeader' => $writeNewsHeader, |
146
|
|
|
'writeNewsRSS' => $writeNewsRSS, |
147
|
|
|
'writeNews' => $news->getNews($archived), |
|
|
|
|
148
|
|
|
'showAllNews' => $showAllNews, |
149
|
|
|
'writeNumberOfArticles' => $plr->getMsg('plmsgHomeArticlesOnline', $faq->getNumberOfRecords($LANGCODE)), |
150
|
|
|
'writeSendAdress' => '?'.$sids.'action=search', |
151
|
|
|
'searchBox' => $PMF_LANG['msgSearch'], |
152
|
|
|
'categoryId' => ($cat === 0) ? '%' : (int)$cat, |
153
|
|
|
'msgSearch' => sprintf( |
154
|
|
|
'<a class="help" href="%sindex.php?action=search">%s</a>', |
155
|
|
|
$faqSystem->getSystemUri($faqConfig), |
156
|
|
|
$PMF_LANG['msgAdvancedSearch'] |
157
|
|
|
) |
158
|
|
|
] |
159
|
|
|
); |
160
|
|
|
|
161
|
|
|
$template->parseBlock( |
162
|
|
|
'index', |
163
|
|
|
'breadcrumb', |
164
|
|
|
[ |
165
|
|
|
'breadcrumbHeadline' => Strings::htmlspecialchars($faqConfig->get('main.titleFAQ')) |
166
|
|
|
] |
167
|
|
|
); |
168
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.