1
|
|
|
<?php |
|
|
|
|
2
|
|
|
// |
3
|
|
|
// ------------------------------------------------------------------------ // |
4
|
|
|
// XOOPS - PHP Content Management System // |
5
|
|
|
// Copyright (c) 2000-2016 XOOPS.org // |
6
|
|
|
// <http://xoops.org/> // |
7
|
|
|
// ------------------------------------------------------------------------ // |
8
|
|
|
// This program is free software; you can redistribute it and/or modify // |
9
|
|
|
// it under the terms of the GNU General Public License as published by // |
10
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
11
|
|
|
// (at your option) any later version. // |
12
|
|
|
// // |
13
|
|
|
// You may not change or alter any portion of this comment or credits // |
14
|
|
|
// of supporting developers from this source code or any supporting // |
15
|
|
|
// source code which is considered copyrighted (c) material of the // |
16
|
|
|
// original comment or credit authors. // |
17
|
|
|
// // |
18
|
|
|
// This program is distributed in the hope that it will be useful, // |
19
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
20
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
21
|
|
|
// GNU General Public License for more details. // |
22
|
|
|
// // |
23
|
|
|
// You should have received a copy of the GNU General Public License // |
24
|
|
|
// along with this program; if not, write to the Free Software // |
25
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
26
|
|
|
// ------------------------------------------------------------------------ // |
27
|
|
|
include_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php'; |
28
|
|
|
include_once __DIR__ . '/admin_header.php'; |
29
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/class/xoopstopic.php'; |
30
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
31
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/config.php'; |
32
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php'; |
33
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php'; |
34
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/class/class.sfiles.php'; |
35
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/class/blacklist.php'; |
36
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/class/registryfile.php'; |
37
|
|
|
include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
38
|
|
|
include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
39
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/admin/functions.php'; |
40
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/include/functions.php'; |
41
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/class/tree.php'; |
42
|
|
|
$dateformat = news_getmoduleoption('dateformat'); |
43
|
|
|
$myts = MyTextSanitizer::getInstance(); |
44
|
|
|
$topicscount = 0; |
45
|
|
|
|
46
|
|
|
$storiesTableName = $xoopsDB->prefix('news_stories'); |
47
|
|
|
if (!news_FieldExists('picture', $storiesTableName)) { |
48
|
|
|
news_AddField('`picture` VARCHAR( 50 ) NOT NULL', $storiesTableName); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Show new submissions |
53
|
|
|
* |
54
|
|
|
* This list can be view in the module's admin when you click on the tab named "Post/Edit News" |
55
|
|
|
* Submissions are news that was submit by users but who are not approved, so you need to edit |
56
|
|
|
* them to approve them. |
57
|
|
|
* Actually you can see the the story's title, the topic, the posted date, the author and a |
58
|
|
|
* link to delete the story. If you click on the story's title, you will be able to edit the news. |
59
|
|
|
* The table contains the last x new submissions. |
60
|
|
|
* The system's block called "Waiting Contents" is listing the number of those news. |
61
|
|
|
*/ |
62
|
|
|
function newSubmissions() |
|
|
|
|
63
|
|
|
{ |
64
|
|
|
global $dateformat, $pathIcon16; |
|
|
|
|
65
|
|
|
$start = isset($_GET['startnew']) ? (int)$_GET['startnew'] : 0; |
66
|
|
|
$newsubcount = NewsStory:: getAllStoriesCount(3, false); |
67
|
|
|
$storyarray = NewsStory:: getAllSubmitted(news_getmoduleoption('storycountadmin'), true, news_getmoduleoption('restrictindex'), $start); |
68
|
|
|
if (count($storyarray) > 0) { |
69
|
|
|
$pagenav = new XoopsPageNav($newsubcount, news_getmoduleoption('storycountadmin'), $start, 'startnew', 'op=newarticle'); |
70
|
|
|
news_collapsableBar('newsub', 'topnewsubicon'); |
71
|
|
|
echo "<img onclick=\"toggle('toptable'); toggleIcon('toptableicon');\" id='topnewsubicon' name='topnewsubicon' src='" |
72
|
|
|
. $pathIcon16 |
73
|
|
|
. "/close12.gif' alt='' /></a> " |
74
|
|
|
. _AM_NEWSUB |
75
|
|
|
. '</h4>'; |
76
|
|
|
echo "<div id='newsub'>"; |
77
|
|
|
echo '<br>'; |
78
|
|
|
echo "<div style='text-align: center;'><table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'><tr class='bg3'><th align='center'>" |
79
|
|
|
. _AM_TITLE |
80
|
|
|
. "</th><th align='center'>" |
81
|
|
|
. _AM_TOPIC |
82
|
|
|
. "</th><th align='center'>" |
83
|
|
|
. _AM_POSTED |
84
|
|
|
. "</th><th align='center'>" |
85
|
|
|
. _AM_POSTER |
86
|
|
|
. "</th><th align='center'>" |
87
|
|
|
. _AM_NEWS_ACTION |
88
|
|
|
. "</th></tr>\n"; |
89
|
|
|
$class = ''; |
90
|
|
|
foreach ($storyarray as $newstory) { |
91
|
|
|
$class = ($class === 'even') ? 'odd' : 'even'; |
92
|
|
|
echo "<tr class='" . $class . "'><td align='left'>\n"; |
93
|
|
|
$title = $newstory->title(); |
94
|
|
|
if (!isset($title) || ($title === '')) { |
95
|
|
|
echo "<a href='" . XOOPS_URL . '/modules/news/admin/index.php?op=edit&returnside=1&storyid=' . $newstory->storyid() . "'>" . _MD_NEWS_NOSUBJECT . "</a>\n"; |
96
|
|
|
} else { |
97
|
|
|
echo " <a href='" . XOOPS_URL . '/modules/news/submit.php?returnside=1&op=edit&storyid=' . $newstory->storyid() . "'>" . $title . "</a>\n"; |
98
|
|
|
} |
99
|
|
|
echo '</td><td>' |
100
|
|
|
. $newstory->topic_title() |
101
|
|
|
. "</td><td align='center' class='nw'>" |
102
|
|
|
. formatTimestamp($newstory->created(), $dateformat) |
103
|
|
|
. "</td><td align='center'><a href='" |
104
|
|
|
. XOOPS_URL |
105
|
|
|
. '/userinfo.php?uid=' |
106
|
|
|
. $newstory->uid() |
107
|
|
|
. "'>" |
108
|
|
|
. $newstory->uname() |
109
|
|
|
. "</a></td><td align='center'><a href='" |
110
|
|
|
. XOOPS_URL |
111
|
|
|
. '/modules/news/submit.php?returnside=1&op=edit&storyid=' |
112
|
|
|
. $newstory->storyid() |
113
|
|
|
. "'><img src='" |
114
|
|
|
. $pathIcon16 |
115
|
|
|
. "/edit.png' title='" |
116
|
|
|
. _AM_EDIT |
117
|
|
|
. "'></a><a href='" |
118
|
|
|
. XOOPS_URL |
119
|
|
|
. '/modules/news/admin/index.php?op=delete&storyid=' |
120
|
|
|
. $newstory->storyid() |
121
|
|
|
. "'><img src='" |
122
|
|
|
. $pathIcon16 |
123
|
|
|
. "/delete.png' title='" |
124
|
|
|
. _AM_DELETE |
125
|
|
|
. "'></a></td></tr>\n"; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
echo '</table></div>'; |
129
|
|
|
echo "<div align='right'>" . $pagenav->renderNav() . '</div><br>'; |
130
|
|
|
echo '<br></div><br>'; |
131
|
|
|
} |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Shows all automated stories |
136
|
|
|
* |
137
|
|
|
* Automated stories are stories that have a publication's date greater than "now" |
138
|
|
|
* This list can be view in the module's admin when you click on the tab named "Post/Edit News" |
139
|
|
|
* Actually you can see the story's ID, its title, the topic, the author, the |
140
|
|
|
* programmed date and time, the expiration's date and two links. The first link is |
141
|
|
|
* used to edit the story while the second is used to remove the story. |
142
|
|
|
* The list only contains the last (x) automated news |
143
|
|
|
*/ |
144
|
|
|
function autoStories() |
|
|
|
|
145
|
|
|
{ |
146
|
|
|
global $dateformat, $pathIcon16; |
|
|
|
|
147
|
|
|
|
148
|
|
|
$start = isset($_GET['startauto']) ? (int)$_GET['startauto'] : 0; |
149
|
|
|
$storiescount = NewsStory:: getAllStoriesCount(2, false); |
150
|
|
|
$storyarray = NewsStory:: getAllAutoStory(news_getmoduleoption('storycountadmin'), true, $start); |
151
|
|
|
$class = ''; |
152
|
|
|
if (count($storyarray) > 0) { |
153
|
|
|
$pagenav = new XoopsPageNav($storiescount, news_getmoduleoption('storycountadmin'), $start, 'startauto', 'op=newarticle'); |
154
|
|
|
news_collapsableBar('autostories', 'topautostories'); |
155
|
|
|
echo "<img onclick=\"toggle('toptable'); toggleIcon('toptableicon');\" id='topautostories' name='topautostories' src='" |
156
|
|
|
. $pathIcon16 |
157
|
|
|
. "/close12.gif' alt='' /></a> " |
158
|
|
|
. _AM_AUTOARTICLES |
159
|
|
|
. '</h4>'; |
160
|
|
|
echo "<div id='autostories'>"; |
161
|
|
|
echo '<br>'; |
162
|
|
|
echo "<div style='text-align: center;'>\n"; |
163
|
|
|
echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'><tr class='bg3'><th align='center'>" |
164
|
|
|
. _AM_STORYID |
165
|
|
|
. "</th><th align='center'>" |
166
|
|
|
. _AM_TITLE |
167
|
|
|
. "</th><th align='center'>" |
168
|
|
|
. _AM_TOPIC |
169
|
|
|
. "</th><th align='center'>" |
170
|
|
|
. _AM_POSTER |
171
|
|
|
. "</th><th align='center' class='nw'>" |
172
|
|
|
. _AM_PROGRAMMED |
173
|
|
|
. "</th><th align='center' class='nw'>" |
174
|
|
|
. _AM_EXPIRED |
175
|
|
|
. "</th><th align='center'>" |
176
|
|
|
. _AM_NEWS_ACTION |
177
|
|
|
. '</th></tr>'; |
178
|
|
View Code Duplication |
foreach ($storyarray as $autostory) { |
|
|
|
|
179
|
|
|
$topic = $autostory->topic(); |
180
|
|
|
$expire = ($autostory->expired() > 0) ? formatTimestamp($autostory->expired(), $dateformat) : ''; |
181
|
|
|
$class = ($class === 'even') ? 'odd' : 'even'; |
182
|
|
|
echo "<tr class='" . $class . "'>"; |
183
|
|
|
echo "<td align='center'><b>" |
184
|
|
|
. $autostory->storyid() |
185
|
|
|
. "</b> |
186
|
|
|
</td><td align='left'><a href='" |
187
|
|
|
. XOOPS_URL |
188
|
|
|
. '/modules/news/article.php?storyid=' |
189
|
|
|
. $autostory->storyid() |
190
|
|
|
. "'>" |
191
|
|
|
. $autostory->title() |
192
|
|
|
. "</a> |
193
|
|
|
</td><td align='center'>" |
194
|
|
|
. $topic->topic_title() |
195
|
|
|
. " |
196
|
|
|
</td><td align='center'><a href='" |
197
|
|
|
. XOOPS_URL |
198
|
|
|
. '/userinfo.php?uid=' |
199
|
|
|
. $autostory->uid() |
200
|
|
|
. "'>" |
201
|
|
|
. $autostory->uname() |
202
|
|
|
. "</a></td><td align='center' class='nw'>" |
203
|
|
|
. formatTimestamp($autostory->published(), $dateformat) |
204
|
|
|
. "</td><td align='center'>" |
205
|
|
|
. $expire |
206
|
|
|
. "</td><td align='center'><a href='" |
207
|
|
|
. XOOPS_URL |
208
|
|
|
. '/modules/news/submit.php?returnside=1&op=edit&storyid=' |
209
|
|
|
. $autostory->storyid() |
210
|
|
|
. "'><img src='" |
211
|
|
|
. $pathIcon16 |
212
|
|
|
. "/edit.png' title=" |
213
|
|
|
. _AM_EDIT |
214
|
|
|
. "> </a> <a href='" |
215
|
|
|
. XOOPS_URL |
216
|
|
|
. '/modules/news/admin/index.php?op=delete&storyid=' |
217
|
|
|
. $autostory->storyid() |
218
|
|
|
. "'><img src='" |
219
|
|
|
. $pathIcon16 |
220
|
|
|
. "/delete.png' title='" |
221
|
|
|
. _AM_DELETE |
222
|
|
|
. "'></a>"; |
223
|
|
|
|
224
|
|
|
echo "</td></tr>\n"; |
225
|
|
|
} |
226
|
|
|
echo '</table></div>'; |
227
|
|
|
echo "<div align='right'>" . $pagenav->renderNav() . '</div><br>'; |
228
|
|
|
echo '</div><br>'; |
229
|
|
|
} |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* Shows last x published stories |
234
|
|
|
* |
235
|
|
|
* This list can be view in the module's admin when you click on the tab named "Post/Edit News" |
236
|
|
|
* Actually you can see the the story's ID, its title, the topic, the author, the number of hits |
237
|
|
|
* and two links. The first link is used to edit the story while the second is used to remove the story. |
238
|
|
|
* The table only contains the last X published stories. |
239
|
|
|
* You can modify the number of visible stories with the module's option named |
240
|
|
|
* "Number of new articles to display in admin area". |
241
|
|
|
* As the number of displayed stories is limited, below this list you can find a text box |
242
|
|
|
* that you can use to enter a story's Id, then with the scrolling list you can select |
243
|
|
|
* if you want to edit or delete the story. |
244
|
|
|
*/ |
245
|
|
|
function lastStories() |
|
|
|
|
246
|
|
|
{ |
247
|
|
|
global $dateformat, $pathIcon16; |
|
|
|
|
248
|
|
|
news_collapsableBar('laststories', 'toplaststories'); |
249
|
|
|
echo "<img onclick=\"toggle('toptable'); toggleIcon('toptableicon');\" id='toplaststories' name='toplaststories' src='" |
250
|
|
|
. $pathIcon16 |
251
|
|
|
. "/close12.gif' alt='' /></a> " |
252
|
|
|
. sprintf(_AM_LAST10ARTS, news_getmoduleoption('storycountadmin')) |
253
|
|
|
. '</h4>'; |
254
|
|
|
echo "<div id='laststories'>"; |
255
|
|
|
echo '<br>'; |
256
|
|
|
echo "<div style='text-align: center;'>"; |
257
|
|
|
$start = isset($_GET['start']) ? (int)$_GET['start'] : 0; |
258
|
|
|
$storyarray = NewsStory:: getAllPublished(news_getmoduleoption('storycountadmin'), $start, false, 0, 1); |
259
|
|
|
$storiescount = NewsStory:: getAllStoriesCount(4, false); |
260
|
|
|
$pagenav = new XoopsPageNav($storiescount, news_getmoduleoption('storycountadmin'), $start, 'start', 'op=newarticle'); |
261
|
|
|
$class = ''; |
262
|
|
|
echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'><tr class='bg3'><th align='center'>" |
263
|
|
|
. _AM_STORYID |
264
|
|
|
. "</th><th align='center'>" |
265
|
|
|
. _AM_TITLE |
266
|
|
|
. "</th><th align='center'>" |
267
|
|
|
. _AM_TOPIC |
268
|
|
|
. "</th><th align='center'>" |
269
|
|
|
. _AM_POSTER |
270
|
|
|
. "</th><th align='center' class='nw'>" |
271
|
|
|
. _AM_PUBLISHED |
272
|
|
|
. "</th><th align='center' class='nw'>" |
273
|
|
|
. _AM_HITS |
274
|
|
|
. "</th><th align='center'>" |
275
|
|
|
. _AM_NEWS_ACTION |
276
|
|
|
. '</th></tr>'; |
277
|
|
|
foreach ($storyarray as $eachstory) { |
|
|
|
|
278
|
|
|
$published = formatTimestamp($eachstory->published(), $dateformat); |
279
|
|
|
// $expired = ( $eachstory -> expired() > 0 ) ? formatTimestamp($eachstory->expired(),$dateformat) : '---'; |
|
|
|
|
280
|
|
|
$topic = $eachstory->topic(); |
281
|
|
|
$class = ($class === 'even') ? 'odd' : 'even'; |
282
|
|
|
echo "<tr class='" . $class . "'>"; |
283
|
|
|
echo "<td align='center'><b>" |
284
|
|
|
. $eachstory->storyid() |
285
|
|
|
. "</b> |
286
|
|
|
</td><td align='left'><a href='" |
287
|
|
|
. XOOPS_URL |
288
|
|
|
. '/modules/news/article.php?storyid=' |
289
|
|
|
. $eachstory->storyid() |
290
|
|
|
. "'>" |
291
|
|
|
. $eachstory->title() |
292
|
|
|
. "</a> |
293
|
|
|
</td><td align='center'>" |
294
|
|
|
. $topic->topic_title() |
295
|
|
|
. " |
296
|
|
|
</td><td align='center'><a href='" |
297
|
|
|
. XOOPS_URL |
298
|
|
|
. '/userinfo.php?uid=' |
299
|
|
|
. $eachstory->uid() |
300
|
|
|
. "'>" |
301
|
|
|
. $eachstory->uname() |
302
|
|
|
. "</a></td><td align='center' class='nw'>" |
303
|
|
|
. $published |
304
|
|
|
. "</td><td align='center'>" |
305
|
|
|
. $eachstory->counter() |
306
|
|
|
. "</td><td align='center'> |
307
|
|
|
<a href='" |
308
|
|
|
. XOOPS_URL |
309
|
|
|
. '/modules/news/submit.php?returnside=1&op=edit&storyid=' |
310
|
|
|
. $eachstory->storyid() |
311
|
|
|
. "'> <img src='" |
312
|
|
|
. $pathIcon16 |
313
|
|
|
. "/edit.png' title=" |
314
|
|
|
. _AM_EDIT |
315
|
|
|
. "> </a> |
316
|
|
|
<a href='" |
317
|
|
|
. XOOPS_URL |
318
|
|
|
. '/modules/news/admin/index.php?op=delete&storyid=' |
319
|
|
|
. $eachstory->storyid() |
320
|
|
|
. "'><img src='" |
321
|
|
|
. $pathIcon16 |
322
|
|
|
. "/delete.png' title='" |
323
|
|
|
. _AM_DELETE |
324
|
|
|
. "'></a>"; |
325
|
|
|
|
326
|
|
|
echo "</td></tr>\n"; |
327
|
|
|
} |
328
|
|
|
echo '</table><br>'; |
329
|
|
|
echo "<div align='right'>" . $pagenav->renderNav() . '</div><br>'; |
330
|
|
|
|
331
|
|
|
echo "<form action='index.php' method='get'>" . _AM_STORYID . " <input type='text' name='storyid' size='10' /> |
332
|
|
|
<select name='op'> |
333
|
|
|
<option value='edit' selected='selected'>" . _AM_EDIT . "</option> |
334
|
|
|
<option value='delete'>" . _AM_DELETE . "</option> |
335
|
|
|
</select> |
336
|
|
|
<input type='hidden' name='returnside' value='1'> |
337
|
|
|
<input type='submit' value='" . _AM_GO . "' /> |
338
|
|
|
</form> |
339
|
|
|
</div>"; |
340
|
|
|
echo '</div><br>'; |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
/** |
344
|
|
|
* Display a list of the expired stories |
345
|
|
|
* |
346
|
|
|
* This list can be view in the module's admin when you click on the tab named "Post/Edit News" |
347
|
|
|
* Actually you can see the story's ID, the title, the topic, the author, |
348
|
|
|
* the creation and expiration's date and you have two links, one to delete |
349
|
|
|
* the story and the other to edit the story. |
350
|
|
|
* The table only contains the last X expired stories. |
351
|
|
|
* You can modify the number of visible stories with the module's option named |
352
|
|
|
* "Number of new articles to display in admin area". |
353
|
|
|
* As the number of displayed stories is limited, below this list you can find a text box |
354
|
|
|
* that you can use to enter a story's Id, then with the scrolling list you can select |
355
|
|
|
* if you want to edit or delete the story. |
356
|
|
|
*/ |
357
|
|
|
function expStories() |
|
|
|
|
358
|
|
|
{ |
359
|
|
|
global $dateformat, $pathIcon16; |
|
|
|
|
360
|
|
|
$start = isset($_GET['startexp']) ? (int)$_GET['startexp'] : 0; |
361
|
|
|
$expiredcount = NewsStory:: getAllStoriesCount(1, false); |
362
|
|
|
$storyarray = NewsStory:: getAllExpired(news_getmoduleoption('storycountadmin'), $start, 0, 1); |
363
|
|
|
$pagenav = new XoopsPageNav($expiredcount, news_getmoduleoption('storycountadmin'), $start, 'startexp', 'op=newarticle'); |
364
|
|
|
|
365
|
|
|
if (count($storyarray) > 0) { |
366
|
|
|
$class = ''; |
367
|
|
|
news_collapsableBar('expstories', 'topexpstories'); |
368
|
|
|
echo "<img onclick=\"toggle('toptable'); toggleIcon('toptableicon');\" id='topexpstories' name='topexpstories' src='" |
369
|
|
|
. $pathIcon16 |
370
|
|
|
. "/close12.gif' alt='' /></a> " |
371
|
|
|
. _AM_EXPARTS |
372
|
|
|
. '</h4>'; |
373
|
|
|
echo "<div id='expstories'>"; |
374
|
|
|
echo '<br>'; |
375
|
|
|
echo "<div style='text-align: center;'>"; |
376
|
|
|
echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'><tr class='bg3'><th align='center'>" |
377
|
|
|
. _AM_STORYID |
378
|
|
|
. "</th><th align='center'>" |
379
|
|
|
. _AM_TITLE |
380
|
|
|
. "</th><th align='center'>" |
381
|
|
|
. _AM_TOPIC |
382
|
|
|
. "</th><th align='center'>" |
383
|
|
|
. _AM_POSTER |
384
|
|
|
. "</th><th align='center' class='nw'>" |
385
|
|
|
. _AM_CREATED |
386
|
|
|
. "</th><th align='center' class='nw'>" |
387
|
|
|
. _AM_EXPIRED |
388
|
|
|
. "</th><th align='center'>" |
389
|
|
|
. _AM_NEWS_ACTION |
390
|
|
|
. '</th></tr>'; |
391
|
|
View Code Duplication |
foreach ($storyarray as $eachstory) { |
|
|
|
|
392
|
|
|
$created = formatTimestamp($eachstory->created(), $dateformat); |
393
|
|
|
$expired = formatTimestamp($eachstory->expired(), $dateformat); |
394
|
|
|
$topic = $eachstory->topic(); |
395
|
|
|
// added exired value field to table |
396
|
|
|
$class = ($class === 'even') ? 'odd' : 'even'; |
397
|
|
|
echo "<tr class='" . $class . "'>"; |
398
|
|
|
echo "<td align='center'><b>" |
399
|
|
|
. $eachstory->storyid() |
400
|
|
|
. "</b> |
401
|
|
|
</td><td align='left'><a href='" |
402
|
|
|
. XOOPS_URL |
403
|
|
|
. '/modules/news/article.php?returnside=1&storyid=' |
404
|
|
|
. $eachstory->storyid() |
405
|
|
|
. "'>" |
406
|
|
|
. $eachstory->title() |
407
|
|
|
. "</a> |
408
|
|
|
</td><td align='center'>" |
409
|
|
|
. $topic->topic_title() |
410
|
|
|
. " |
411
|
|
|
</td><td align='center'><a href='" |
412
|
|
|
. XOOPS_URL |
413
|
|
|
. '/userinfo.php?uid=' |
414
|
|
|
. $eachstory->uid() |
415
|
|
|
. "'>" |
416
|
|
|
. $eachstory->uname() |
417
|
|
|
. "</a></td><td align='center' class='nw'>" |
418
|
|
|
. $created |
419
|
|
|
. "</td><td align='center' class='nw'>" |
420
|
|
|
. $expired |
421
|
|
|
. "</td><td align='center'> |
422
|
|
|
<a href='" |
423
|
|
|
. XOOPS_URL |
424
|
|
|
. '/modules/news/submit.php?returnside=1&op=edit&storyid=' |
425
|
|
|
. $eachstory->storyid() |
426
|
|
|
. "'> <img src='" |
427
|
|
|
. $pathIcon16 |
428
|
|
|
. "/edit.png' title=" |
429
|
|
|
. _AM_EDIT |
430
|
|
|
. "></a> |
431
|
|
|
<a href='" |
432
|
|
|
. XOOPS_URL |
433
|
|
|
. '/modules/news/admin/index.php?op=delete&storyid=' |
434
|
|
|
. $eachstory->storyid() |
435
|
|
|
. "'><img src='" |
436
|
|
|
. $pathIcon16 |
437
|
|
|
. "/delete.png' title='" |
438
|
|
|
. _AM_DELETE |
439
|
|
|
. "'></a>"; |
440
|
|
|
|
441
|
|
|
echo "</td></tr>\n"; |
442
|
|
|
} |
443
|
|
|
echo '</table><br>'; |
444
|
|
|
echo "<div align='right'>" . $pagenav->renderNav() . '</div><br>'; |
445
|
|
|
echo "<form action='index.php' method='get'> |
446
|
|
|
" . _AM_STORYID . " <input type='text' name='storyid' size='10' /> |
447
|
|
|
<select name='op'> |
448
|
|
|
<option value='edit' selected='selected'>" . _AM_EDIT . "</option> |
449
|
|
|
<option value='delete'>" . _AM_DELETE . "</option> |
450
|
|
|
</select> |
451
|
|
|
<input type='hidden' name='returnside' value='1'> |
452
|
|
|
<input type='submit' value='" . _AM_GO . "' /> |
453
|
|
|
</form> |
454
|
|
|
</div>"; |
455
|
|
|
echo '</div><br>'; |
456
|
|
|
} |
457
|
|
|
} |
458
|
|
|
|
459
|
|
|
/** |
460
|
|
|
* Delete (purge/prune) old stories |
461
|
|
|
* |
462
|
|
|
* You can use this function in the module's admin when you click on the tab named "Prune News" |
463
|
|
|
* It's useful to remove old stories. It is, of course, recommended |
464
|
|
|
* to backup (or export) your news before to purge news. |
465
|
|
|
* You must first specify a date. This date will be used as a reference, everything |
466
|
|
|
* that was published before this date will be deleted. |
467
|
|
|
* The option "Only remove stories who have expired" will enable you to only remove |
468
|
|
|
* expired stories published before the given date. |
469
|
|
|
* Finally, you can select the topics inside wich you will remove news. |
470
|
|
|
* Once you have set all the parameters, the script will first show you a confirmation's |
471
|
|
|
* message with the number of news that will be removed. |
472
|
|
|
* Note, the topics are not deleted (even if there are no more news inside them). |
473
|
|
|
*/ |
474
|
|
|
function PruneManager() |
475
|
|
|
{ |
476
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
477
|
|
|
xoops_cp_header(); |
478
|
|
|
$pruneAdmin = new ModuleAdmin(); |
479
|
|
|
echo $pruneAdmin->addNavigation('index.php?op=prune'); |
480
|
|
|
echo '<br><br><br>'; |
481
|
|
|
$sform = new XoopsThemeForm(_AM_NEWS_PRUNENEWS, 'pruneform', XOOPS_URL . '/modules/news/admin/index.php', 'post'); |
482
|
|
|
$sform->addElement(new XoopsFormTextDateSelect(_AM_NEWS_PRUNE_BEFORE, 'prune_date', 15, time()), true); |
483
|
|
|
$onlyexpired = new xoopsFormCheckBox('', 'onlyexpired'); |
484
|
|
|
$onlyexpired->addOption(1, _AM_NEWS_PRUNE_EXPIREDONLY); |
485
|
|
|
$sform->addElement($onlyexpired, false); |
486
|
|
|
$sform->addElement(new XoopsFormHidden('op', 'confirmbeforetoprune'), false); |
487
|
|
|
$topiclist = new XoopsFormSelect(_AM_NEWS_PRUNE_TOPICS, 'pruned_topics', '', 5, true); |
488
|
|
|
$topics_arr = array(); |
|
|
|
|
489
|
|
|
$xt = new NewsTopic(); |
490
|
|
|
$allTopics = $xt->getAllTopics(false); // The webmaster can see everything |
491
|
|
|
$topic_tree = new MyXoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); |
492
|
|
|
$topics_arr = $topic_tree->getAllChild(0); |
493
|
|
|
if (count($topics_arr)) { |
494
|
|
|
foreach ($topics_arr as $onetopic) { |
495
|
|
|
$topiclist->addOption($onetopic->topic_id(), $onetopic->topic_title()); |
496
|
|
|
} |
497
|
|
|
} |
498
|
|
|
$topiclist->setDescription(_AM_NEWS_EXPORT_PRUNE_DSC); |
499
|
|
|
$sform->addElement($topiclist, false); |
500
|
|
|
$button_tray = new XoopsFormElementTray('', ''); |
501
|
|
|
$submit_btn = new XoopsFormButton('', 'post', _SUBMIT, 'submit'); |
502
|
|
|
$button_tray->addElement($submit_btn); |
503
|
|
|
$sform->addElement($button_tray); |
504
|
|
|
$sform->display(); |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
// A confirmation is asked before to prune stories |
508
|
|
|
function ConfirmBeforeToPrune() |
|
|
|
|
509
|
|
|
{ |
510
|
|
|
global $dateformat; |
|
|
|
|
511
|
|
|
$story = new NewsStory(); |
512
|
|
|
xoops_cp_header(); |
513
|
|
|
$topiclist = ''; |
514
|
|
|
if (isset($_POST['pruned_topics'])) { |
515
|
|
|
$topiclist = implode(',', $_POST['pruned_topics']); |
516
|
|
|
} |
517
|
|
|
echo '<h4>' . _AM_NEWS_PRUNENEWS . '</h4>'; |
518
|
|
|
$expired = 0; |
519
|
|
|
if (isset($_POST['onlyexpired'])) { |
520
|
|
|
$expired = (int)$_POST['onlyexpired']; |
521
|
|
|
} |
522
|
|
|
$date = $_POST['prune_date']; |
523
|
|
|
$timestamp = mktime(0, 0, 0, (int)substr($date, 5, 2), (int)substr($date, 8, 2), (int)substr($date, 0, 4)); |
524
|
|
|
$count = $story->GetCountStoriesPublishedBefore($timestamp, $expired, $topiclist); |
525
|
|
|
if ($count) { |
526
|
|
|
$displaydate = formatTimestamp($timestamp, $dateformat); |
527
|
|
|
$msg = sprintf(_AM_NEWS_PRUNE_CONFIRM, $displaydate, $count); |
528
|
|
|
xoops_confirm(array('op' => 'prunenews', 'expired' => $expired, 'pruned_topics' => $topiclist, 'prune_date' => $timestamp, 'ok' => 1), 'index.php', $msg); |
529
|
|
|
} else { |
530
|
|
|
printf(_AM_NEWS_NOTHING_PRUNE); |
531
|
|
|
} |
532
|
|
|
unset($story); |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
// Effectively delete stories (published before a date), no more confirmation |
536
|
|
|
function PruneNews() |
|
|
|
|
537
|
|
|
{ |
538
|
|
|
$story = new NewsStory(); |
|
|
|
|
539
|
|
|
$timestamp = (int)$_POST['prune_date']; |
540
|
|
|
$expired = (int)$_POST['expired']; |
541
|
|
|
$topiclist = ''; |
542
|
|
|
if (isset($_POST['pruned_topics'])) { |
543
|
|
|
$topiclist = $_POST['pruned_topics']; |
544
|
|
|
} |
545
|
|
|
|
546
|
|
|
if ((int)$_POST['ok'] == 1) { |
547
|
|
|
$story = new NewsStory(); |
548
|
|
|
xoops_cp_header(); |
549
|
|
|
$count = $story->GetCountStoriesPublishedBefore($timestamp, $expired, $topiclist); |
550
|
|
|
$msg = sprintf(_AM_NEWS_PRUNE_DELETED, $count); |
551
|
|
|
$story->DeleteBeforeDate($timestamp, $expired, $topiclist); |
552
|
|
|
unset($story); |
553
|
|
|
news_updateCache(); |
554
|
|
|
redirect_header('index.php', 3, $msg); |
555
|
|
|
} |
556
|
|
|
} |
557
|
|
|
|
558
|
|
|
/** |
559
|
|
|
* Newsletter's configuration |
560
|
|
|
* |
561
|
|
|
* You can create a newsletter's content from the admin part of the News module when you click on the tab named "Newsletter" |
562
|
|
|
* First, let be clear, this module'functionality will not send the newsletter but it will prepare its content for you. |
563
|
|
|
* To send the newsletter, you can use many specialized modules like evennews. |
564
|
|
|
* You first select a range of dates and if you want, a selection of topics to use for the search. |
565
|
|
|
* Once it's done, the script will use the file named /xoops/modules/language/yourlanguage/newsletter.php to create |
566
|
|
|
* the newsletter's content. When it's finished, the script generates a file in the upload folder. |
567
|
|
|
*/ |
568
|
|
|
function Newsletter() |
569
|
|
|
{ |
570
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
571
|
|
|
xoops_cp_header(); |
572
|
|
|
$newsletterAdmin = new ModuleAdmin(); |
573
|
|
|
echo $newsletterAdmin->addNavigation('index.php?op=configurenewsletter'); |
574
|
|
|
echo '<br><br><br>'; |
575
|
|
|
$sform = new XoopsThemeForm(_AM_NEWS_NEWSLETTER, 'newsletterform', XOOPS_URL . '/modules/news/admin/index.php', 'post'); |
576
|
|
|
$dates_tray = new XoopsFormElementTray(_AM_NEWS_NEWSLETTER_BETWEEN); |
577
|
|
|
$date1 = new XoopsFormTextDateSelect('', 'date1', 15, time()); |
578
|
|
|
$date2 = new XoopsFormTextDateSelect(_AM_NEWS_EXPORT_AND, 'date2', 15, time()); |
579
|
|
|
$dates_tray->addElement($date1); |
580
|
|
|
$dates_tray->addElement($date2); |
581
|
|
|
$sform->addElement($dates_tray); |
582
|
|
|
|
583
|
|
|
$topiclist = new XoopsFormSelect(_AM_NEWS_PRUNE_TOPICS, 'export_topics', '', 5, true); |
584
|
|
|
$topics_arr = array(); |
|
|
|
|
585
|
|
|
$xt = new NewsTopic(); |
586
|
|
|
$allTopics = $xt->getAllTopics(false); // The webmaster can see everything |
587
|
|
|
$topic_tree = new MyXoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); |
588
|
|
|
$topics_arr = $topic_tree->getAllChild(0); |
589
|
|
|
if (count($topics_arr)) { |
590
|
|
|
foreach ($topics_arr as $onetopic) { |
591
|
|
|
$topiclist->addOption($onetopic->topic_id(), $onetopic->topic_title()); |
592
|
|
|
} |
593
|
|
|
} |
594
|
|
|
$topiclist->setDescription(_AM_NEWS_EXPORT_PRUNE_DSC); |
595
|
|
|
$sform->addElement($topiclist, false); |
596
|
|
|
$sform->addElement(new XoopsFormHidden('op', 'launchnewsletter'), false); |
597
|
|
|
$sform->addElement(new XoopsFormRadioYN(_AM_NEWS_REMOVE_BR, 'removebr', 1), false); |
598
|
|
|
$sform->addElement(new XoopsFormRadioYN(_AM_NEWS_NEWSLETTER_HTML_TAGS, 'removehtml', 0), false); |
599
|
|
|
$sform->addElement(new XoopsFormTextArea(_AM_NEWS_NEWSLETTER_HEADER, 'header', '', 4, 70), false); |
600
|
|
|
$sform->addElement(new XoopsFormTextArea(_AM_NEWS_NEWSLETTER_FOOTER, 'footer', '', 4, 70), false); |
601
|
|
|
$button_tray = new XoopsFormElementTray('', ''); |
602
|
|
|
$submit_btn = new XoopsFormButton('', 'post', _SUBMIT, 'submit'); |
603
|
|
|
$button_tray->addElement($submit_btn); |
604
|
|
|
$sform->addElement($button_tray); |
605
|
|
|
$sform->display(); |
606
|
|
|
} |
607
|
|
|
|
608
|
|
|
/** |
609
|
|
|
* Launch the creation of the newsletter's content |
610
|
|
|
*/ |
611
|
|
|
function LaunchNewsletter() |
|
|
|
|
612
|
|
|
{ |
613
|
|
|
global $xoopsConfig, $dateformat; |
|
|
|
|
614
|
|
|
xoops_cp_header(); |
615
|
|
|
$newsletterAdmin = new ModuleAdmin(); |
616
|
|
|
echo $newsletterAdmin->addNavigation('index.php?op=configurenewsletter'); |
617
|
|
|
$newslettertemplate = ''; |
618
|
|
View Code Duplication |
if (file_exists(XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/newsletter.php')) { |
|
|
|
|
619
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/newsletter.php'; |
620
|
|
|
} else { |
621
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/language/english/newsletter.php'; |
622
|
|
|
} |
623
|
|
|
echo '<br>'; |
624
|
|
|
$story = new NewsStory(); |
625
|
|
|
$exportedstories = array(); |
|
|
|
|
626
|
|
|
$topiclist = ''; |
627
|
|
|
$removebr = $removehtml = false; |
|
|
|
|
628
|
|
|
$removebr = isset($_POST['removebr']) ? (int)$_POST['removebr'] : 0; |
629
|
|
|
$removehtml = isset($_POST['removehtml']) ? (int)$_POST['removehtml'] : 0; |
630
|
|
|
$header = isset($_POST['header']) ? $_POST['header'] : ''; |
631
|
|
|
$footer = isset($_POST['footer']) ? $_POST['footer'] : ''; |
632
|
|
|
$date1 = $_POST['date1']; |
633
|
|
|
$date2 = $_POST['date2']; |
634
|
|
|
$timestamp1 = mktime(0, 0, 0, (int)substr($date1, 5, 2), (int)substr($date1, 8, 2), (int)substr($date1, 0, 4)); |
635
|
|
|
$timestamp2 = mktime(23, 59, 59, (int)substr($date2, 5, 2), (int)substr($date2, 8, 2), (int)substr($date2, 0, 4)); |
636
|
|
|
if (isset($_POST['export_topics'])) { |
637
|
|
|
$topiclist = implode(',', $_POST['export_topics']); |
638
|
|
|
} |
639
|
|
|
$tbltopics = array(); |
640
|
|
|
$exportedstories = $story->NewsExport($timestamp1, $timestamp2, $topiclist, 0, $tbltopics); |
641
|
|
|
$newsfile = XOOPS_ROOT_PATH . '/uploads/news/letter.txt'; |
642
|
|
|
if (count($exportedstories)) { |
643
|
|
|
$fp = fopen($newsfile, 'w'); |
644
|
|
|
if (!$fp) { |
645
|
|
|
redirect_header('index.php', 4, sprintf(_AM_NEWS_EXPORT_ERROR, $newsfile)); |
646
|
|
|
} |
647
|
|
|
if (xoops_trim($header) !== '') { |
648
|
|
|
fwrite($fp, $header); |
649
|
|
|
} |
650
|
|
|
foreach ($exportedstories as $onestory) { |
651
|
|
|
$content = $newslettertemplate; |
652
|
|
|
$search_pattern = array( |
653
|
|
|
'%title%', |
654
|
|
|
'%uname%', |
655
|
|
|
'%created%', |
656
|
|
|
'%published%', |
657
|
|
|
'%expired%', |
658
|
|
|
'%hometext%', |
659
|
|
|
'%bodytext%', |
660
|
|
|
'%description%', |
661
|
|
|
'%keywords%', |
662
|
|
|
'%reads%', |
663
|
|
|
'%topicid%', |
664
|
|
|
'%topic_title%', |
665
|
|
|
'%comments%', |
666
|
|
|
'%rating%', |
667
|
|
|
'%votes%', |
668
|
|
|
'%publisher%', |
669
|
|
|
'%publisher_id%', |
670
|
|
|
'%link%' |
671
|
|
|
); |
672
|
|
|
$replace_pattern = array( |
673
|
|
|
$onestory->title(), |
674
|
|
|
$onestory->uname(), |
675
|
|
|
formatTimestamp($onestory->created(), $dateformat), |
676
|
|
|
formatTimestamp($onestory->published(), $dateformat), |
677
|
|
|
formatTimestamp($onestory->expired(), $dateformat), |
678
|
|
|
$onestory->hometext(), |
679
|
|
|
$onestory->bodytext(), |
680
|
|
|
$onestory->description(), |
681
|
|
|
$onestory->keywords(), |
682
|
|
|
$onestory->counter(), |
683
|
|
|
$onestory->topicid(), |
684
|
|
|
$onestory->topic_title(), |
685
|
|
|
$onestory->comments(), |
686
|
|
|
$onestory->rating(), |
687
|
|
|
$onestory->votes(), |
688
|
|
|
$onestory->uname(), |
689
|
|
|
$onestory->uid(), |
690
|
|
|
XOOPS_URL . '/modules/news/article.php?storyid=' . $onestory->storyid() |
691
|
|
|
); |
692
|
|
|
$content = str_replace($search_pattern, $replace_pattern, $content); |
693
|
|
|
if ($removebr) { |
694
|
|
|
$content = str_replace('<br>', "\r\n", $content); |
695
|
|
|
} |
696
|
|
|
if ($removehtml) { |
697
|
|
|
$content = strip_tags($content); |
698
|
|
|
} |
699
|
|
|
fwrite($fp, $content); |
700
|
|
|
} |
701
|
|
|
if (xoops_trim($footer) !== '') { |
702
|
|
|
fwrite($fp, $footer); |
703
|
|
|
} |
704
|
|
|
fclose($fp); |
705
|
|
|
$newsfile = XOOPS_URL . '/uploads/news/newsletter.txt'; |
706
|
|
|
printf(_AM_NEWS_NEWSLETTER_READY, $newsfile, XOOPS_URL . '/modules/news/admin/index.php?op=deletefile&type=newsletter'); |
707
|
|
|
} else { |
708
|
|
|
printf(_AM_NEWS_NOTHING); |
709
|
|
|
} |
710
|
|
|
} |
711
|
|
|
|
712
|
|
|
/** |
713
|
|
|
* News export |
714
|
|
|
* |
715
|
|
|
* You can use this function in the module's admin when you click on the tab named "News Export" |
716
|
|
|
* First select a range of date, possibly a range of topics and if you want, check the option "Include Topics Definitions" |
717
|
|
|
* to also export the topics. |
718
|
|
|
* News, and topics, will be exported to the XML format. |
719
|
|
|
*/ |
720
|
|
|
function NewsExport() |
721
|
|
|
{ |
722
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
723
|
|
|
xoops_cp_header(); |
724
|
|
|
$exportAdmin = new ModuleAdmin(); |
725
|
|
|
echo $exportAdmin->addNavigation('index.php?op=export'); |
726
|
|
|
echo '<br><br><br>'; |
727
|
|
|
$sform = new XoopsThemeForm(_AM_NEWS_EXPORT_NEWS, 'exportform', XOOPS_URL . '/modules/news/admin/index.php', 'post'); |
728
|
|
|
$dates_tray = new XoopsFormElementTray(_AM_NEWS_EXPORT_BETWEEN); |
729
|
|
|
$date1 = new XoopsFormTextDateSelect('', 'date1', 15, time()); |
730
|
|
|
$date2 = new XoopsFormTextDateSelect(_AM_NEWS_EXPORT_AND, 'date2', 15, time()); |
731
|
|
|
$dates_tray->addElement($date1); |
732
|
|
|
$dates_tray->addElement($date2); |
733
|
|
|
$sform->addElement($dates_tray); |
734
|
|
|
|
735
|
|
|
$topiclist = new XoopsFormSelect(_AM_NEWS_PRUNE_TOPICS, 'export_topics', '', 5, true); |
736
|
|
|
$topics_arr = array(); |
|
|
|
|
737
|
|
|
$xt = new NewsTopic(); |
738
|
|
|
$allTopics = $xt->getAllTopics(false); // The webmaster can see everything |
739
|
|
|
$topic_tree = new MyXoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); |
740
|
|
|
$topics_arr = $topic_tree->getAllChild(0); |
741
|
|
|
if (count($topics_arr)) { |
742
|
|
|
foreach ($topics_arr as $onetopic) { |
743
|
|
|
$topiclist->addOption($onetopic->topic_id(), $onetopic->topic_title()); |
744
|
|
|
} |
745
|
|
|
} |
746
|
|
|
$topiclist->setDescription(_AM_NEWS_EXPORT_PRUNE_DSC); |
747
|
|
|
$sform->addElement($topiclist, false); |
748
|
|
|
$sform->addElement(new XoopsFormRadioYN(_AM_NEWS_EXPORT_INCTOPICS, 'includetopics', 0), false); |
749
|
|
|
$sform->addElement(new XoopsFormHidden('op', 'launchexport'), false); |
750
|
|
|
$button_tray = new XoopsFormElementTray('', ''); |
751
|
|
|
$submit_btn = new XoopsFormButton('', 'post', _SUBMIT, 'submit'); |
752
|
|
|
$button_tray->addElement($submit_btn); |
753
|
|
|
$sform->addElement($button_tray); |
754
|
|
|
$sform->display(); |
755
|
|
|
} |
756
|
|
|
|
757
|
|
|
/** |
758
|
|
|
* @param $text |
759
|
|
|
* |
760
|
|
|
* @return string |
761
|
|
|
*/ |
762
|
|
|
function news_utf8_encode($text) |
763
|
|
|
{ |
764
|
|
|
return xoops_utf8_encode($text); |
765
|
|
|
} |
766
|
|
|
|
767
|
|
|
// Launch stories export (to the xml's format) |
768
|
|
|
function LaunchExport() |
|
|
|
|
769
|
|
|
{ |
770
|
|
|
xoops_cp_header(); |
771
|
|
|
$exportAdmin = new ModuleAdmin(); |
772
|
|
|
echo $exportAdmin->addNavigation('index.php?op=export'); |
773
|
|
|
echo '<br>'; |
774
|
|
|
$story = new NewsStory(); |
775
|
|
|
$topic = new NewsTopic(); |
776
|
|
|
$exportedstories = array(); |
|
|
|
|
777
|
|
|
$date1 = $_POST['date1']; |
778
|
|
|
$date2 = $_POST['date2']; |
779
|
|
|
$timestamp1 = mktime(0, 0, 0, (int)substr($date1, 5, 2), (int)substr($date1, 8, 2), (int)substr($date1, 0, 4)); |
780
|
|
|
$timestamp2 = mktime(23, 59, 59, (int)substr($date2, 5, 2), (int)substr($date2, 8, 2), (int)substr($date2, 0, 4)); |
781
|
|
|
$topiclist = ''; |
782
|
|
|
if (isset($_POST['export_topics'])) { |
783
|
|
|
$topiclist = implode(',', $_POST['export_topics']); |
784
|
|
|
} |
785
|
|
|
$topicsexport = (int)$_POST['includetopics']; |
786
|
|
|
$tbltopics = array(); |
787
|
|
|
$exportedstories = $story->NewsExport($timestamp1, $timestamp2, $topiclist, $topicsexport, $tbltopics); |
788
|
|
|
if (count($exportedstories)) { |
789
|
|
|
$xmlfile = XOOPS_ROOT_PATH . '/uploads/news/stories.xml'; |
790
|
|
|
$fp = fopen($xmlfile, 'w'); |
791
|
|
|
if (!$fp) { |
792
|
|
|
redirect_header('index.php', 4, sprintf(_AM_NEWS_EXPORT_ERROR, $xmlfile)); |
793
|
|
|
} |
794
|
|
|
|
795
|
|
|
fwrite($fp, news_utf8_encode("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n")); |
796
|
|
|
fwrite($fp, news_utf8_encode("<news_stories>\n")); |
797
|
|
|
if ($topicsexport) { |
798
|
|
|
foreach ($tbltopics as $onetopic) { |
799
|
|
|
$topic->NewsTopic($onetopic); |
|
|
|
|
800
|
|
|
$content = "<news_topic>\n"; |
801
|
|
|
$content .= sprintf("\t<topic_id>%u</topic_id>\n", $topic->topic_id()); |
802
|
|
|
$content .= sprintf("\t<topic_pid>%u</topic_pid>\n", $topic->topic_pid()); |
803
|
|
|
$content .= sprintf("\t<topic_imgurl>%s</topic_imgurl>\n", $topic->topic_imgurl()); |
804
|
|
|
$content .= sprintf("\t<topic_title>%s</topic_title>\n", $topic->topic_title('F')); |
805
|
|
|
$content .= sprintf("\t<menu>%d</menu>\n", $topic->menu()); |
806
|
|
|
$content .= sprintf("\t<topic_frontpage>%d</topic_frontpage>\n", $topic->topic_frontpage()); |
807
|
|
|
$content .= sprintf("\t<topic_rssurl>%s</topic_rssurl>\n", $topic->topic_rssurl('E')); |
808
|
|
|
$content .= sprintf("\t<topic_description>%s</topic_description>\n", $topic->topic_description()); |
809
|
|
|
$content .= sprintf("</news_topic>\n"); |
810
|
|
|
$content = news_utf8_encode($content); |
811
|
|
|
fwrite($fp, $content); |
812
|
|
|
} |
813
|
|
|
} |
814
|
|
|
|
815
|
|
|
foreach ($exportedstories as $onestory) { |
816
|
|
|
$content = "<xoops_story>\n"; |
817
|
|
|
$content .= sprintf("\t<storyid>%u</storyid>\n", $onestory->storyid()); |
818
|
|
|
$content .= sprintf("\t<uid>%u</uid>\n", $onestory->uid()); |
819
|
|
|
$content .= sprintf("\t<uname>%s</uname>\n", $onestory->uname()); |
820
|
|
|
$content .= sprintf("\t<title>%s</title>\n", $onestory->title()); |
821
|
|
|
$content .= sprintf("\t<created>%u</created>\n", $onestory->created()); |
822
|
|
|
$content .= sprintf("\t<published>%u</published>\n", $onestory->published()); |
823
|
|
|
$content .= sprintf("\t<expired>%u</expired>\n", $onestory->expired()); |
824
|
|
|
$content .= sprintf("\t<hostname>%s</hostname>\n", $onestory->hostname()); |
825
|
|
|
$content .= sprintf("\t<nohtml>%d</nohtml>\n", $onestory->nohtml()); |
826
|
|
|
$content .= sprintf("\t<nosmiley>%d</nosmiley>\n", $onestory->nosmiley()); |
827
|
|
|
$content .= sprintf("\t<hometext>%s</hometext>\n", $onestory->hometext()); |
828
|
|
|
$content .= sprintf("\t<bodytext>%s</bodytext>\n", $onestory->bodytext()); |
829
|
|
|
$content .= sprintf("\t<description>%s</description>\n", $onestory->description()); |
830
|
|
|
$content .= sprintf("\t<keywords>%s</keywords>\n", $onestory->keywords()); |
831
|
|
|
$content .= sprintf("\t<counter>%u</counter>\n", $onestory->counter()); |
832
|
|
|
$content .= sprintf("\t<topicid>%u</topicid>\n", $onestory->topicid()); |
833
|
|
|
$content .= sprintf("\t<ihome>%d</ihome>\n", $onestory->ihome()); |
834
|
|
|
$content .= sprintf("\t<notifypub>%d</notifypub>\n", $onestory->notifypub()); |
835
|
|
|
$content .= sprintf("\t<story_type>%s</story_type>\n", $onestory->type()); |
836
|
|
|
$content .= sprintf("\t<topicdisplay>%d</topicdisplay>\n", $onestory->topicdisplay()); |
837
|
|
|
$content .= sprintf("\t<topicalign>%s</topicalign>\n", $onestory->topicalign()); |
838
|
|
|
$content .= sprintf("\t<comments>%u</comments>\n", $onestory->comments()); |
839
|
|
|
$content .= sprintf("\t<rating>%f</rating>\n", $onestory->rating()); |
840
|
|
|
$content .= sprintf("\t<votes>%u</votes>\n", $onestory->votes()); |
841
|
|
|
$content .= sprintf("</xoops_story>\n"); |
842
|
|
|
$content = news_utf8_encode($content); |
843
|
|
|
fwrite($fp, $content); |
844
|
|
|
} |
845
|
|
|
fwrite($fp, news_utf8_encode("</news_stories>\n")); |
846
|
|
|
fclose($fp); |
847
|
|
|
$xmlfile = XOOPS_URL . '/uploads/news/stories.xml'; |
848
|
|
|
printf(_AM_NEWS_EXPORT_READY, $xmlfile, XOOPS_URL . '/modules/news/admin/index.php?op=deletefile&type=xml'); |
849
|
|
|
} else { |
850
|
|
|
printf(_AM_NEWS_EXPORT_NOTHING); |
851
|
|
|
} |
852
|
|
|
} |
853
|
|
|
|
854
|
|
|
/* |
855
|
|
|
* Topics manager |
856
|
|
|
* |
857
|
|
|
* It's from here that you can list, add, modify an delete topics |
858
|
|
|
* At first, you can see a list of all the topics in your databases. This list contains the topic's ID, its name, |
859
|
|
|
* its parent topic, if it should be visible in the Xoops main menu and an action (Edit or Delete topic) |
860
|
|
|
* Below this list you find the form used to create and edit the topics. |
861
|
|
|
* use this form to : |
862
|
|
|
* - Type the topic's title |
863
|
|
|
* - Enter its description |
864
|
|
|
* - Select its parent topic |
865
|
|
|
* - Choose a color |
866
|
|
|
* - Select if it must appear in the Xoops main menu |
867
|
|
|
* - Choose if you want to see in the front page. If it's not the case, visitors will have to use the navigation box to see it |
868
|
|
|
* - And finally you ca select an image to represent the topic |
869
|
|
|
* The text box called "URL of RSS feed" is, for this moment, not used. |
870
|
|
|
*/ |
871
|
|
|
function topicsmanager() |
|
|
|
|
872
|
|
|
{ |
873
|
|
|
global $xoopsDB, $xoopsConfig, $xoopsModule, $myts; |
|
|
|
|
874
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
875
|
|
|
xoops_cp_header(); |
876
|
|
|
$topicAdmin = new ModuleAdmin(); |
877
|
|
|
echo $topicAdmin->addNavigation('index.php?op=topicsmanager'); |
878
|
|
|
|
879
|
|
|
global $pathIcon16; |
|
|
|
|
880
|
|
|
|
881
|
|
|
$uploadfolder = sprintf(_AM_UPLOAD_WARNING, XOOPS_URL . '/uploads/news/image'); |
|
|
|
|
882
|
|
|
$uploadirectory = '/uploads/news/image'; |
883
|
|
|
$start = isset($_GET['start']) ? (int)$_GET['start'] : 0; |
884
|
|
|
|
885
|
|
|
$xt = new NewsTopic($xoopsDB->prefix('news_topics'), 'topic_id', 'topic_pid'); |
|
|
|
|
886
|
|
|
$topics_arr = $xt->getChildTreeArray(0, 'topic_title'); |
887
|
|
|
$totaltopics = count($topics_arr); |
888
|
|
|
$class = ''; |
889
|
|
|
|
890
|
|
|
//echo '<h4>' . _AM_CONFIG . '</h4>'; |
891
|
|
|
//news_collapsableBar('topicsmanager', 'toptopicsmanager'); |
|
|
|
|
892
|
|
|
|
893
|
|
|
//echo "<img onclick=\"toggle('toptable'); toggleIcon('toptableicon');\" id='toptopicsmanager' name='toptopicsmanager' src='" . $pathIcon16."/close12.gif' alt='' /></a> "._AM_TOPICSMNGR . ' (' . $totaltopics . ')'."</h4>"; |
|
|
|
|
894
|
|
|
|
895
|
|
|
echo "<div id='topicsmanager'>"; |
896
|
|
|
echo '<br>'; |
897
|
|
|
echo "<div style='text-align: center;'>"; |
898
|
|
|
echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'><tr class='bg3'><th align='center'>" |
899
|
|
|
. _AM_TOPIC |
900
|
|
|
. "</th><th align='left'>" |
901
|
|
|
. _AM_TOPICNAME |
902
|
|
|
. "</th><th align='center'>" |
903
|
|
|
. _AM_PARENTTOPIC |
904
|
|
|
. "</th><th align='center'>" |
905
|
|
|
. _AM_SUB_MENU_YESNO |
906
|
|
|
. "</th><th align='center'>" |
907
|
|
|
. _AM_NEWS_ACTION |
908
|
|
|
. '</th></tr>'; |
909
|
|
|
if (is_array($topics_arr) && $totaltopics) { |
910
|
|
|
$cpt = 1; |
911
|
|
|
$tmpcpt = $start; |
912
|
|
|
$ok = true; |
913
|
|
|
$output = ''; |
914
|
|
|
while ($ok) { |
915
|
|
|
if ($tmpcpt < $totaltopics) { |
916
|
|
|
$action_edit = '<a href=index.php?op=topicsmanager&topic_id=' . $topics_arr[$tmpcpt]['topic_id'] . '><img src=' . $pathIcon16 . '/edit.png title=' . _AM_EDIT . '></a>'; |
917
|
|
|
$action_delete = '<a href=index.php?op=delTopic&topic_id=' . $topics_arr[$tmpcpt]['topic_id'] . '><img src=' . $pathIcon16 . '/delete.png title=' . _AM_DELETE . "'></a>"; |
918
|
|
|
|
919
|
|
|
$parent = ' '; |
920
|
|
|
if ($topics_arr[$tmpcpt]['topic_pid'] > 0) { |
921
|
|
|
$xttmp = new MyXoopsTopic($xoopsDB->prefix('news_topics'), $topics_arr[$tmpcpt]['topic_pid']); |
922
|
|
|
$parent = $xttmp->topic_title(); |
923
|
|
|
unset($xttmp); |
924
|
|
|
} |
925
|
|
|
if ($topics_arr[$tmpcpt]['topic_pid'] != 0) { |
926
|
|
|
$topics_arr[$tmpcpt]['prefix'] = str_replace('.', '-', $topics_arr[$tmpcpt]['prefix']) . ' '; |
927
|
|
|
} else { |
928
|
|
|
$topics_arr[$tmpcpt]['prefix'] = str_replace('.', '', $topics_arr[$tmpcpt]['prefix']); |
929
|
|
|
} |
930
|
|
|
$submenu = $topics_arr[$tmpcpt]['menu'] ? _YES : _NO; |
931
|
|
|
$class = ($class === 'even') ? 'odd' : 'even'; |
932
|
|
|
|
933
|
|
|
$output = $output |
934
|
|
|
. "<tr class='" |
935
|
|
|
. $class |
936
|
|
|
. "'><td>" |
937
|
|
|
. $topics_arr[$tmpcpt]['topic_id'] |
938
|
|
|
. "</td><td align='left'>" |
939
|
|
|
. $topics_arr[$tmpcpt]['prefix'] |
940
|
|
|
. $myts->displayTarea($topics_arr[$tmpcpt]['topic_title']) |
941
|
|
|
. "</td><td align='left'>" |
942
|
|
|
. $parent |
943
|
|
|
. "</td><td align='center'>" |
944
|
|
|
. $submenu |
945
|
|
|
. "</td><td align='center'>" |
946
|
|
|
. $action_edit |
947
|
|
|
. $action_delete |
948
|
|
|
. '</td></tr>'; |
949
|
|
|
} else { |
950
|
|
|
$ok = false; |
951
|
|
|
} |
952
|
|
|
if ($cpt >= news_getmoduleoption('storycountadmin')) { |
953
|
|
|
$ok = false; |
954
|
|
|
} |
955
|
|
|
++$tmpcpt; |
956
|
|
|
++$cpt; |
957
|
|
|
} |
958
|
|
|
echo $output; |
959
|
|
|
} |
960
|
|
|
$pagenav = new XoopsPageNav($totaltopics, news_getmoduleoption('storycountadmin'), $start, 'start', 'op=topicsmanager'); |
961
|
|
|
echo "</table><div align='right'>" . $pagenav->renderNav() . '</div><br>'; |
962
|
|
|
echo "</div></div><br>\n"; |
963
|
|
|
|
964
|
|
|
$topic_id = isset($_GET['topic_id']) ? (int)$_GET['topic_id'] : 0; |
965
|
|
|
if ($topic_id > 0) { |
966
|
|
|
$xtmod = new NewsTopic($topic_id); |
967
|
|
|
$topic_title = $xtmod->topic_title('E'); |
968
|
|
|
$topic_description = $xtmod->topic_description('E'); |
969
|
|
|
$topic_rssfeed = $xtmod->topic_rssurl('E'); |
|
|
|
|
970
|
|
|
$op = 'modTopicS'; |
971
|
|
|
if (xoops_trim($xtmod->topic_imgurl()) !== '') { |
972
|
|
|
$topicimage = $xtmod->topic_imgurl(); |
973
|
|
|
} else { |
974
|
|
|
$topicimage = 'blank.png'; |
975
|
|
|
} |
976
|
|
|
$btnlabel = _AM_MODIFY; |
977
|
|
|
$parent = $xtmod->topic_pid(); |
978
|
|
|
$formlabel = _AM_MODIFYTOPIC; |
979
|
|
|
$submenu = $xtmod->menu(); |
980
|
|
|
$topic_frontpage = $xtmod->topic_frontpage(); |
981
|
|
|
$topic_color = $xtmod->topic_color(); |
982
|
|
|
unset($xtmod); |
983
|
|
|
} else { |
984
|
|
|
$topic_title = ''; |
985
|
|
|
$topic_frontpage = 1; |
986
|
|
|
$topic_description = ''; |
987
|
|
|
$op = 'addTopic'; |
988
|
|
|
$topicimage = 'xoops.gif'; |
989
|
|
|
$btnlabel = _AM_ADD; |
990
|
|
|
$parent = -1; |
991
|
|
|
$submenu = 0; |
992
|
|
|
$topic_rssfeed = ''; |
|
|
|
|
993
|
|
|
$formlabel = _AM_ADD_TOPIC; |
994
|
|
|
$topic_color = '000000'; |
995
|
|
|
} |
996
|
|
|
|
997
|
|
|
$sform = new XoopsThemeForm($formlabel, 'topicform', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php', 'post'); |
998
|
|
|
$sform->setExtra('enctype="multipart/form-data"'); |
999
|
|
|
$sform->addElement(new XoopsFormText(_AM_TOPICNAME, 'topic_title', 50, 255, $topic_title), true); |
1000
|
|
|
$editor = news_getWysiwygForm(_AM_TOPIC_DESCR, 'topic_description', $topic_description, 15, 60, 'hometext_hidden'); |
1001
|
|
|
if ($editor) { |
1002
|
|
|
$sform->addElement($editor, false); |
1003
|
|
|
} |
1004
|
|
|
|
1005
|
|
|
$sform->addElement(new XoopsFormHidden('op', $op), false); |
1006
|
|
|
$sform->addElement(new XoopsFormHidden('topic_id', $topic_id), false); |
1007
|
|
|
|
1008
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php'; |
1009
|
|
|
$xt = new NewsTopic(); |
1010
|
|
|
$sform->addElement(new XoopsFormLabel(_AM_PARENTTOPIC, $xt->MakeMyTopicSelBox(1, $parent, 'topic_pid', '', false))); |
1011
|
|
|
// Topic's color |
1012
|
|
|
// Code stolen to Zoullou, thank you Zoullou ;-) |
1013
|
|
|
$select_color = |
1014
|
|
|
"\n<select name='topic_color' onchange='xoopsGetElementById(\"NewsColorSelect\").style.backgroundColor = \"#\" + this.options[this.selectedIndex].value;'>\n<option value='000000'>" |
1015
|
|
|
. _AM_NEWS_COLOR |
1016
|
|
|
. "</option>\n"; |
1017
|
|
|
$color_values = array( |
1018
|
|
|
'000000', |
1019
|
|
|
'000033', |
1020
|
|
|
'000066', |
1021
|
|
|
'000099', |
1022
|
|
|
'0000CC', |
1023
|
|
|
'0000FF', |
1024
|
|
|
'003300', |
1025
|
|
|
'003333', |
1026
|
|
|
'003366', |
1027
|
|
|
'0033CC', |
1028
|
|
|
'0033FF', |
1029
|
|
|
'006600', |
1030
|
|
|
'006633', |
1031
|
|
|
'006666', |
1032
|
|
|
'006699', |
1033
|
|
|
'0066CC', |
1034
|
|
|
'0066FF', |
1035
|
|
|
'009900', |
1036
|
|
|
'009933', |
1037
|
|
|
'009966', |
1038
|
|
|
'009999', |
1039
|
|
|
'0099CC', |
1040
|
|
|
'0099FF', |
1041
|
|
|
'00CC00', |
1042
|
|
|
'00CC33', |
1043
|
|
|
'00CC66', |
1044
|
|
|
'00CC99', |
1045
|
|
|
'00CCCC', |
1046
|
|
|
'00CCFF', |
1047
|
|
|
'00FF00', |
1048
|
|
|
'00FF33', |
1049
|
|
|
'00FF66', |
1050
|
|
|
'00FF99', |
1051
|
|
|
'00FFCC', |
1052
|
|
|
'00FFFF', |
1053
|
|
|
'330000', |
1054
|
|
|
'330033', |
1055
|
|
|
'330066', |
1056
|
|
|
'330099', |
1057
|
|
|
'3300CC', |
1058
|
|
|
'3300FF', |
1059
|
|
|
'333300', |
1060
|
|
|
'333333', |
1061
|
|
|
'333366', |
1062
|
|
|
'333399', |
1063
|
|
|
'3333CC', |
1064
|
|
|
'3333FF', |
1065
|
|
|
'336600', |
1066
|
|
|
'336633', |
1067
|
|
|
'336666', |
1068
|
|
|
'336699', |
1069
|
|
|
'3366CC', |
1070
|
|
|
'3366FF', |
1071
|
|
|
'339900', |
1072
|
|
|
'339933', |
1073
|
|
|
'339966', |
1074
|
|
|
'339999', |
1075
|
|
|
'3399CC', |
1076
|
|
|
'3399FF', |
1077
|
|
|
'33CC00', |
1078
|
|
|
'33CC33', |
1079
|
|
|
'33CC66', |
1080
|
|
|
'33CC99', |
1081
|
|
|
'33CCCC', |
1082
|
|
|
'33CCFF', |
1083
|
|
|
'33FF00', |
1084
|
|
|
'33FF33', |
1085
|
|
|
'33FF66', |
1086
|
|
|
'33FF99', |
1087
|
|
|
'33FFCC', |
1088
|
|
|
'33FFFF', |
1089
|
|
|
'660000', |
1090
|
|
|
'660033', |
1091
|
|
|
'660066', |
1092
|
|
|
'660099', |
1093
|
|
|
'6600CC', |
1094
|
|
|
'6600FF', |
1095
|
|
|
'663300', |
1096
|
|
|
'663333', |
1097
|
|
|
'663366', |
1098
|
|
|
'663399', |
1099
|
|
|
'6633CC', |
1100
|
|
|
'6633FF', |
1101
|
|
|
'666600', |
1102
|
|
|
'666633', |
1103
|
|
|
'666666', |
1104
|
|
|
'666699', |
1105
|
|
|
'6666CC', |
1106
|
|
|
'6666FF', |
1107
|
|
|
'669900', |
1108
|
|
|
'669933', |
1109
|
|
|
'669966', |
1110
|
|
|
'669999', |
1111
|
|
|
'6699CC', |
1112
|
|
|
'6699FF', |
1113
|
|
|
'66CC00', |
1114
|
|
|
'66CC33', |
1115
|
|
|
'66CC66', |
1116
|
|
|
'66CC99', |
1117
|
|
|
'66CCCC', |
1118
|
|
|
'66CCFF', |
1119
|
|
|
'66FF00', |
1120
|
|
|
'66FF33', |
1121
|
|
|
'66FF66', |
1122
|
|
|
'66FF99', |
1123
|
|
|
'66FFCC', |
1124
|
|
|
'66FFFF', |
1125
|
|
|
'990000', |
1126
|
|
|
'990033', |
1127
|
|
|
'990066', |
1128
|
|
|
'990099', |
1129
|
|
|
'9900CC', |
1130
|
|
|
'9900FF', |
1131
|
|
|
'993300', |
1132
|
|
|
'993333', |
1133
|
|
|
'993366', |
1134
|
|
|
'993399', |
1135
|
|
|
'9933CC', |
1136
|
|
|
'9933FF', |
1137
|
|
|
'996600', |
1138
|
|
|
'996633', |
1139
|
|
|
'996666', |
1140
|
|
|
'996699', |
1141
|
|
|
'9966CC', |
1142
|
|
|
'9966FF', |
1143
|
|
|
'999900', |
1144
|
|
|
'999933', |
1145
|
|
|
'999966', |
1146
|
|
|
'999999', |
1147
|
|
|
'9999CC', |
1148
|
|
|
'9999FF', |
1149
|
|
|
'99CC00', |
1150
|
|
|
'99CC33', |
1151
|
|
|
'99CC66', |
1152
|
|
|
'99CC99', |
1153
|
|
|
'99CCCC', |
1154
|
|
|
'99CCFF', |
1155
|
|
|
'99FF00', |
1156
|
|
|
'99FF33', |
1157
|
|
|
'99FF66', |
1158
|
|
|
'99FF99', |
1159
|
|
|
'99FFCC', |
1160
|
|
|
'99FFFF', |
1161
|
|
|
'CC0000', |
1162
|
|
|
'CC0033', |
1163
|
|
|
'CC0066', |
1164
|
|
|
'CC0099', |
1165
|
|
|
'CC00CC', |
1166
|
|
|
'CC00FF', |
1167
|
|
|
'CC3300', |
1168
|
|
|
'CC3333', |
1169
|
|
|
'CC3366', |
1170
|
|
|
'CC3399', |
1171
|
|
|
'CC33CC', |
1172
|
|
|
'CC33FF', |
1173
|
|
|
'CC6600', |
1174
|
|
|
'CC6633', |
1175
|
|
|
'CC6666', |
1176
|
|
|
'CC6699', |
1177
|
|
|
'CC66CC', |
1178
|
|
|
'CC66FF', |
1179
|
|
|
'CC9900', |
1180
|
|
|
'CC9933', |
1181
|
|
|
'CC9966', |
1182
|
|
|
'CC9999', |
1183
|
|
|
'CC99CC', |
1184
|
|
|
'CC99FF', |
1185
|
|
|
'CCCC00', |
1186
|
|
|
'CCCC33', |
1187
|
|
|
'CCCC66', |
1188
|
|
|
'CCCC99', |
1189
|
|
|
'CCCCCC', |
1190
|
|
|
'CCCCFF', |
1191
|
|
|
'CCFF00', |
1192
|
|
|
'CCFF33', |
1193
|
|
|
'CCFF66', |
1194
|
|
|
'CCFF99', |
1195
|
|
|
'CCFFCC', |
1196
|
|
|
'CCFFFF', |
1197
|
|
|
'FF0000', |
1198
|
|
|
'FF0033', |
1199
|
|
|
'FF0066', |
1200
|
|
|
'FF0099', |
1201
|
|
|
'FF00CC', |
1202
|
|
|
'FF00FF', |
1203
|
|
|
'FF3300', |
1204
|
|
|
'FF3333', |
1205
|
|
|
'FF3366', |
1206
|
|
|
'FF3399', |
1207
|
|
|
'FF33CC', |
1208
|
|
|
'FF33FF', |
1209
|
|
|
'FF6600', |
1210
|
|
|
'FF6633', |
1211
|
|
|
'FF6666', |
1212
|
|
|
'FF6699', |
1213
|
|
|
'FF66CC', |
1214
|
|
|
'FF66FF', |
1215
|
|
|
'FF9900', |
1216
|
|
|
'FF9933', |
1217
|
|
|
'FF9966', |
1218
|
|
|
'FF9999', |
1219
|
|
|
'FF99CC', |
1220
|
|
|
'FF99FF', |
1221
|
|
|
'FFCC00', |
1222
|
|
|
'FFCC33', |
1223
|
|
|
'FFCC66', |
1224
|
|
|
'FFCC99', |
1225
|
|
|
'FFCCCC', |
1226
|
|
|
'FFCCFF', |
1227
|
|
|
'FFFF00', |
1228
|
|
|
'FFFF33', |
1229
|
|
|
'FFFF66', |
1230
|
|
|
'FFFF99', |
1231
|
|
|
'FFFFCC', |
1232
|
|
|
'FFFFFF' |
1233
|
|
|
); |
1234
|
|
|
|
1235
|
|
|
foreach ($color_values as $color_value) { |
1236
|
|
|
if ($topic_color == $color_value) { |
1237
|
|
|
$selected = " selected='selected'"; |
1238
|
|
|
} else { |
1239
|
|
|
$selected = ''; |
1240
|
|
|
} |
1241
|
|
|
$select_color .= '<option' . $selected . " value='" . $color_value . "' style='background-color:#" . $color_value . ';color:#' . $color_value . ";'>#" . $color_value . "</option>\n"; |
1242
|
|
|
} |
1243
|
|
|
|
1244
|
|
|
$select_color .= "</select> \n<span id='NewsColorSelect'> </span>"; |
1245
|
|
|
$sform->addElement(new XoopsFormLabel(_AM_NEWS_TOPIC_COLOR, $select_color)); |
1246
|
|
|
// Sub menu ? |
1247
|
|
|
$sform->addElement(new XoopsFormRadioYN(_AM_SUB_MENU, 'submenu', $submenu, _YES, _NO)); |
1248
|
|
|
$sform->addElement(new XoopsFormRadioYN(_AM_PUBLISH_FRONTPAGE, 'topic_frontpage', $topic_frontpage, _YES, _NO)); |
1249
|
|
|
// Unused for this moment... sorry |
1250
|
|
|
//$sform->addElement(new XoopsFormText(_AM_NEWS_RSS_URL, 'topic_rssfeed', 50, 255, $topic_rssfeed), false); |
|
|
|
|
1251
|
|
|
// ********** Picture |
1252
|
|
|
$imgtray = new XoopsFormElementTray(_AM_TOPICIMG, '<br>'); |
1253
|
|
|
|
1254
|
|
|
$imgpath = sprintf(_AM_IMGNAEXLOC, 'uploads/news/image/'); |
1255
|
|
|
$imageselect = new XoopsFormSelect($imgpath, 'topic_imgurl', $topicimage); |
1256
|
|
|
$topics_array = XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . '/uploads/news/image/'); |
1257
|
|
|
foreach ($topics_array as $image) { |
1258
|
|
|
$imageselect->addOption("$image", $image); |
1259
|
|
|
} |
1260
|
|
|
$imageselect->setExtra("onchange='showImgSelected(\"image3\", \"topic_imgurl\", \"" . $uploadirectory . "\", \"\", \"" . XOOPS_URL . "\")'"); |
1261
|
|
|
$imgtray->addElement($imageselect, false); |
1262
|
|
|
$imgtray->addElement(new XoopsFormLabel('', "<br><img src='" . XOOPS_URL . '/' . $uploadirectory . '/' . $topicimage . "' name='image3' id='image3' alt='' />")); |
1263
|
|
|
|
1264
|
|
|
$uploadfolder = sprintf(_AM_UPLOAD_WARNING, XOOPS_URL . '/uploads/news/image'); |
1265
|
|
|
$fileseltray = new XoopsFormElementTray('', '<br>'); |
1266
|
|
|
$fileseltray->addElement(new XoopsFormFile(_AM_TOPIC_PICTURE, 'attachedfile', news_getmoduleoption('maxuploadsize')), false); |
1267
|
|
|
$fileseltray->addElement(new XoopsFormLabel($uploadfolder), false); |
1268
|
|
|
$imgtray->addElement($fileseltray); |
1269
|
|
|
$sform->addElement($imgtray); |
1270
|
|
|
|
1271
|
|
|
// Permissions |
1272
|
|
|
$member_handler = xoops_getHandler('member'); |
1273
|
|
|
$group_list = $member_handler->getGroupList(); |
1274
|
|
|
$gperm_handler = xoops_getHandler('groupperm'); |
1275
|
|
|
$full_list = array_keys($group_list); |
1276
|
|
|
|
1277
|
|
|
$groups_ids = array(); |
|
|
|
|
1278
|
|
View Code Duplication |
if ($topic_id > 0) { // Edit mode |
|
|
|
|
1279
|
|
|
$groups_ids = $gperm_handler->getGroupIds('news_approve', $topic_id, $xoopsModule->getVar('mid')); |
1280
|
|
|
$groups_ids = array_values($groups_ids); |
1281
|
|
|
$groups_news_can_approve_checkbox = new XoopsFormCheckBox(_AM_APPROVEFORM, 'groups_news_can_approve[]', $groups_ids); |
1282
|
|
|
} else { // Creation mode |
1283
|
|
|
$groups_news_can_approve_checkbox = new XoopsFormCheckBox(_AM_APPROVEFORM, 'groups_news_can_approve[]', $full_list); |
1284
|
|
|
} |
1285
|
|
|
$groups_news_can_approve_checkbox->addOptionArray($group_list); |
1286
|
|
|
$sform->addElement($groups_news_can_approve_checkbox); |
1287
|
|
|
|
1288
|
|
|
$groups_ids = array(); |
|
|
|
|
1289
|
|
View Code Duplication |
if ($topic_id > 0) { // Edit mode |
|
|
|
|
1290
|
|
|
$groups_ids = $gperm_handler->getGroupIds('news_submit', $topic_id, $xoopsModule->getVar('mid')); |
1291
|
|
|
$groups_ids = array_values($groups_ids); |
1292
|
|
|
$groups_news_can_submit_checkbox = new XoopsFormCheckBox(_AM_SUBMITFORM, 'groups_news_can_submit[]', $groups_ids); |
1293
|
|
|
} else { // Creation mode |
1294
|
|
|
$groups_news_can_submit_checkbox = new XoopsFormCheckBox(_AM_SUBMITFORM, 'groups_news_can_submit[]', $full_list); |
1295
|
|
|
} |
1296
|
|
|
$groups_news_can_submit_checkbox->addOptionArray($group_list); |
1297
|
|
|
$sform->addElement($groups_news_can_submit_checkbox); |
1298
|
|
|
|
1299
|
|
|
$groups_ids = array(); |
|
|
|
|
1300
|
|
View Code Duplication |
if ($topic_id > 0) { // Edit mode |
|
|
|
|
1301
|
|
|
$groups_ids = $gperm_handler->getGroupIds('news_view', $topic_id, $xoopsModule->getVar('mid')); |
1302
|
|
|
$groups_ids = array_values($groups_ids); |
1303
|
|
|
$groups_news_can_view_checkbox = new XoopsFormCheckBox(_AM_VIEWFORM, 'groups_news_can_view[]', $groups_ids); |
1304
|
|
|
} else { // Creation mode |
1305
|
|
|
$groups_news_can_view_checkbox = new XoopsFormCheckBox(_AM_VIEWFORM, 'groups_news_can_view[]', $full_list); |
1306
|
|
|
} |
1307
|
|
|
$groups_news_can_view_checkbox->addOptionArray($group_list); |
1308
|
|
|
$sform->addElement($groups_news_can_view_checkbox); |
1309
|
|
|
|
1310
|
|
|
// Submit buttons |
1311
|
|
|
$button_tray = new XoopsFormElementTray('', ''); |
1312
|
|
|
$submit_btn = new XoopsFormButton('', 'post', $btnlabel, 'submit'); |
1313
|
|
|
$button_tray->addElement($submit_btn); |
1314
|
|
|
$sform->addElement($button_tray); |
1315
|
|
|
$sform->display(); |
1316
|
|
|
echo "<script type='text/javascript'>\n"; |
1317
|
|
|
echo 'xoopsGetElementById("NewsColorSelect").style.backgroundColor = "#' . $topic_color . '";'; |
1318
|
|
|
echo "</script>\n"; |
1319
|
|
|
} |
1320
|
|
|
|
1321
|
|
|
// Save a topic after it has been modified |
1322
|
|
|
function modTopicS() |
|
|
|
|
1323
|
|
|
{ |
1324
|
|
|
global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
|
|
|
|
1325
|
|
|
|
1326
|
|
|
$xt = new NewsTopic((int)$_POST['topic_id']); |
1327
|
|
|
if ((int)$_POST['topic_pid'] == (int)$_POST['topic_id']) { |
1328
|
|
|
redirect_header('index.php?op=topicsmanager', 2, _AM_ADD_TOPIC_ERROR1); |
1329
|
|
|
} |
1330
|
|
|
$xt->setTopicPid((int)$_POST['topic_pid']); |
1331
|
|
|
if (empty($_POST['topic_title'])) { |
1332
|
|
|
redirect_header('index.php?op=topicsmanager', 2, _AM_ERRORTOPICNAME); |
1333
|
|
|
} |
1334
|
|
|
if (isset($_SESSION['items_count'])) { |
1335
|
|
|
$_SESSION['items_count'] = -1; |
1336
|
|
|
} |
1337
|
|
|
$xt->setTopicTitle($_POST['topic_title']); |
1338
|
|
View Code Duplication |
if (isset($_POST['topic_imgurl']) && $_POST['topic_imgurl'] !== '') { |
|
|
|
|
1339
|
|
|
$xt->setTopicImgurl($_POST['topic_imgurl']); |
1340
|
|
|
} |
1341
|
|
|
$xt->setMenu((int)$_POST['submenu']); |
1342
|
|
|
$xt->setTopicFrontpage((int)$_POST['topic_frontpage']); |
1343
|
|
|
if (isset($_POST['topic_description'])) { |
1344
|
|
|
$xt->setTopicDescription($_POST['topic_description']); |
1345
|
|
|
} else { |
1346
|
|
|
$xt->setTopicDescription(''); |
1347
|
|
|
} |
1348
|
|
|
//$xt->Settopic_rssurl($_POST['topic_rssfeed']); |
|
|
|
|
1349
|
|
|
$xt->setTopic_color($_POST['topic_color']); |
1350
|
|
|
|
1351
|
|
View Code Duplication |
if (isset($_POST['xoops_upload_file'])) { |
|
|
|
|
1352
|
|
|
$fldname = $_FILES[$_POST['xoops_upload_file'][0]]; |
1353
|
|
|
$fldname = $fldname['name']; |
1354
|
|
|
if (xoops_trim($fldname !== '')) { |
1355
|
|
|
$sfiles = new sFiles(); |
1356
|
|
|
$dstpath = XOOPS_ROOT_PATH . '/uploads/news/image'; |
1357
|
|
|
$destname = $sfiles->createUploadName($dstpath, $fldname, true); |
1358
|
|
|
$permittedtypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'); |
1359
|
|
|
$uploader = new XoopsMediaUploader($dstpath, $permittedtypes, $xoopsModuleConfig['maxuploadsize']); |
1360
|
|
|
$uploader->setTargetFileName($destname); |
1361
|
|
|
if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
1362
|
|
|
if ($uploader->upload()) { |
1363
|
|
|
$xt->setTopicImgurl(basename($destname)); |
1364
|
|
|
} else { |
1365
|
|
|
echo _AM_UPLOAD_ERROR . ' ' . $uploader->getErrors(); |
1366
|
|
|
} |
1367
|
|
|
} else { |
1368
|
|
|
echo $uploader->getErrors(); |
1369
|
|
|
} |
1370
|
|
|
} |
1371
|
|
|
} |
1372
|
|
|
$xt->store(); |
1373
|
|
|
|
1374
|
|
|
// Permissions |
1375
|
|
|
$gperm_handler = xoops_getHandler('groupperm'); |
1376
|
|
|
$criteria = new CriteriaCompo(); |
1377
|
|
|
$criteria->add(new Criteria('gperm_itemid', $xt->topic_id(), '=')); |
1378
|
|
|
$criteria->add(new Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); |
1379
|
|
|
$criteria->add(new Criteria('gperm_name', 'news_approve', '=')); |
1380
|
|
|
$gperm_handler->deleteAll($criteria); |
1381
|
|
|
|
1382
|
|
|
$criteria = new CriteriaCompo(); |
1383
|
|
|
$criteria->add(new Criteria('gperm_itemid', $xt->topic_id(), '=')); |
1384
|
|
|
$criteria->add(new Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); |
1385
|
|
|
$criteria->add(new Criteria('gperm_name', 'news_submit', '=')); |
1386
|
|
|
$gperm_handler->deleteAll($criteria); |
1387
|
|
|
|
1388
|
|
|
$criteria = new CriteriaCompo(); |
1389
|
|
|
$criteria->add(new Criteria('gperm_itemid', $xt->topic_id(), '=')); |
1390
|
|
|
$criteria->add(new Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); |
1391
|
|
|
$criteria->add(new Criteria('gperm_name', 'news_view', '=')); |
1392
|
|
|
$gperm_handler->deleteAll($criteria); |
1393
|
|
|
|
1394
|
|
View Code Duplication |
if (isset($_POST['groups_news_can_approve'])) { |
|
|
|
|
1395
|
|
|
foreach ($_POST['groups_news_can_approve'] as $onegroup_id) { |
1396
|
|
|
$gperm_handler->addRight('news_approve', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid')); |
1397
|
|
|
} |
1398
|
|
|
} |
1399
|
|
|
|
1400
|
|
View Code Duplication |
if (isset($_POST['groups_news_can_submit'])) { |
|
|
|
|
1401
|
|
|
foreach ($_POST['groups_news_can_submit'] as $onegroup_id) { |
1402
|
|
|
$gperm_handler->addRight('news_submit', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid')); |
1403
|
|
|
} |
1404
|
|
|
} |
1405
|
|
|
|
1406
|
|
View Code Duplication |
if (isset($_POST['groups_news_can_view'])) { |
|
|
|
|
1407
|
|
|
foreach ($_POST['groups_news_can_view'] as $onegroup_id) { |
1408
|
|
|
$gperm_handler->addRight('news_view', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid')); |
1409
|
|
|
} |
1410
|
|
|
} |
1411
|
|
|
|
1412
|
|
|
news_updateCache(); |
1413
|
|
|
redirect_header('index.php?op=topicsmanager', 1, _AM_DBUPDATED); |
1414
|
|
|
} |
1415
|
|
|
|
1416
|
|
|
// Delete a topic and its subtopics and its stories and the related stories |
1417
|
|
|
function delTopic() |
|
|
|
|
1418
|
|
|
{ |
1419
|
|
|
global $xoopsDB, $xoopsModule; |
|
|
|
|
1420
|
|
|
if (!isset($_POST['ok'])) { |
1421
|
|
|
xoops_cp_header(); |
1422
|
|
|
echo '<h4>' . _AM_CONFIG . '</h4>'; |
1423
|
|
|
$xt = new MyXoopsTopic($xoopsDB->prefix('news_topics'), (int)$_GET['topic_id']); |
1424
|
|
|
xoops_confirm(array('op' => 'delTopic', 'topic_id' => (int)$_GET['topic_id'], 'ok' => 1), 'index.php', _AM_WAYSYWTDTTAL . '<br>' . $xt->topic_title('S')); |
1425
|
|
|
} else { |
1426
|
|
|
xoops_cp_header(); |
1427
|
|
|
$xt = new MyXoopsTopic($xoopsDB->prefix('news_topics'), (int)$_POST['topic_id']); |
1428
|
|
|
if (isset($_SESSION['items_count'])) { |
1429
|
|
|
$_SESSION['items_count'] = -1; |
1430
|
|
|
} |
1431
|
|
|
// get all subtopics under the specified topic |
1432
|
|
|
$topic_arr = $xt->getAllChildTopics(); |
1433
|
|
|
array_push($topic_arr, $xt); |
1434
|
|
|
foreach ($topic_arr as $eachtopic) { |
1435
|
|
|
// get all stories in each topic |
1436
|
|
|
$story_arr = NewsStory:: getByTopic($eachtopic->topic_id()); |
1437
|
|
|
foreach ($story_arr as $eachstory) { |
1438
|
|
|
if (false != $eachstory->delete()) { |
1439
|
|
|
xoops_comment_delete($xoopsModule->getVar('mid'), $eachstory->storyid()); |
1440
|
|
|
xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'story', $eachstory->storyid()); |
1441
|
|
|
} |
1442
|
|
|
} |
1443
|
|
|
// all stories for each topic is deleted, now delete the topic data |
1444
|
|
|
$eachtopic->delete(); |
1445
|
|
|
// Delete also the notifications and permissions |
1446
|
|
|
xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'category', $eachtopic->topic_id); |
1447
|
|
|
xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'news_approve', $eachtopic->topic_id); |
1448
|
|
|
xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'news_submit', $eachtopic->topic_id); |
1449
|
|
|
xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'news_view', $eachtopic->topic_id); |
1450
|
|
|
} |
1451
|
|
|
news_updateCache(); |
1452
|
|
|
redirect_header('index.php?op=topicsmanager', 1, _AM_DBUPDATED); |
1453
|
|
|
} |
1454
|
|
|
} |
1455
|
|
|
|
1456
|
|
|
// Add a new topic |
1457
|
|
|
function addTopic() |
|
|
|
|
1458
|
|
|
{ |
1459
|
|
|
global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
|
|
|
|
1460
|
|
|
$topicpid = isset($_POST['topic_pid']) ? (int)$_POST['topic_pid'] : 0; |
1461
|
|
|
$xt = new NewsTopic(); |
1462
|
|
|
if (!$xt->topicExists($topicpid, $_POST['topic_title'])) { |
1463
|
|
|
$xt->setTopicPid($topicpid); |
1464
|
|
|
if (empty($_POST['topic_title']) || xoops_trim($_POST['topic_title']) == '') { |
1465
|
|
|
redirect_header('index.php?op=topicsmanager', 2, _AM_ERRORTOPICNAME); |
1466
|
|
|
} |
1467
|
|
|
$xt->setTopicTitle($_POST['topic_title']); |
1468
|
|
|
//$xt->Settopic_rssurl($_POST['topic_rssfeed']); |
|
|
|
|
1469
|
|
|
$xt->setTopic_color($_POST['topic_color']); |
1470
|
|
View Code Duplication |
if (isset($_POST['topic_imgurl']) && $_POST['topic_imgurl'] !== '') { |
|
|
|
|
1471
|
|
|
$xt->setTopicImgurl($_POST['topic_imgurl']); |
1472
|
|
|
} |
1473
|
|
|
$xt->setMenu((int)$_POST['submenu']); |
1474
|
|
|
$xt->setTopicFrontpage((int)$_POST['topic_frontpage']); |
1475
|
|
|
if (isset($_SESSION['items_count'])) { |
1476
|
|
|
$_SESSION['items_count'] = -1; |
1477
|
|
|
} |
1478
|
|
View Code Duplication |
if (isset($_POST['xoops_upload_file'])) { |
|
|
|
|
1479
|
|
|
$fldname = $_FILES[$_POST['xoops_upload_file'][0]]; |
1480
|
|
|
$fldname = $fldname['name']; |
1481
|
|
|
if (xoops_trim($fldname !== '')) { |
1482
|
|
|
$sfiles = new sFiles(); |
1483
|
|
|
$dstpath = XOOPS_ROOT_PATH . '/uploads/news/image'; |
1484
|
|
|
$destname = $sfiles->createUploadName($dstpath, $fldname, true); |
1485
|
|
|
$permittedtypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'); |
1486
|
|
|
$uploader = new XoopsMediaUploader($dstpath, $permittedtypes, $xoopsModuleConfig['maxuploadsize']); |
1487
|
|
|
$uploader->setTargetFileName($destname); |
1488
|
|
|
if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
1489
|
|
|
if ($uploader->upload()) { |
1490
|
|
|
$xt->setTopicImgurl(basename($destname)); |
1491
|
|
|
} else { |
1492
|
|
|
echo _AM_UPLOAD_ERROR . ' ' . $uploader->getErrors(); |
1493
|
|
|
} |
1494
|
|
|
} else { |
1495
|
|
|
echo $uploader->getErrors(); |
1496
|
|
|
} |
1497
|
|
|
} |
1498
|
|
|
} |
1499
|
|
|
if (isset($_POST['topic_description'])) { |
1500
|
|
|
$xt->setTopicDescription($_POST['topic_description']); |
1501
|
|
|
} else { |
1502
|
|
|
$xt->setTopicDescription(''); |
1503
|
|
|
} |
1504
|
|
|
$xt->store(); |
1505
|
|
|
// Permissions |
1506
|
|
|
$gperm_handler = xoops_getHandler('groupperm'); |
1507
|
|
View Code Duplication |
if (isset($_POST['groups_news_can_approve'])) { |
|
|
|
|
1508
|
|
|
foreach ($_POST['groups_news_can_approve'] as $onegroup_id) { |
1509
|
|
|
$gperm_handler->addRight('news_approve', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid')); |
1510
|
|
|
} |
1511
|
|
|
} |
1512
|
|
|
|
1513
|
|
View Code Duplication |
if (isset($_POST['groups_news_can_submit'])) { |
|
|
|
|
1514
|
|
|
foreach ($_POST['groups_news_can_submit'] as $onegroup_id) { |
1515
|
|
|
$gperm_handler->addRight('news_submit', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid')); |
1516
|
|
|
} |
1517
|
|
|
} |
1518
|
|
|
|
1519
|
|
View Code Duplication |
if (isset($_POST['groups_news_can_view'])) { |
|
|
|
|
1520
|
|
|
foreach ($_POST['groups_news_can_view'] as $onegroup_id) { |
1521
|
|
|
$gperm_handler->addRight('news_view', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid')); |
1522
|
|
|
} |
1523
|
|
|
} |
1524
|
|
|
news_updateCache(); |
1525
|
|
|
|
1526
|
|
|
$notification_handler = xoops_getHandler('notification'); |
1527
|
|
|
$tags = array(); |
1528
|
|
|
$tags['TOPIC_NAME'] = $_POST['topic_title']; |
1529
|
|
|
$notification_handler->triggerEvent('global', 0, 'new_category', $tags); |
1530
|
|
|
redirect_header('index.php?op=topicsmanager', 1, _AM_DBUPDATED); |
1531
|
|
|
} else { |
1532
|
|
|
redirect_header('index.php?op=topicsmanager', 2, _AM_ADD_TOPIC_ERROR); |
1533
|
|
|
} |
1534
|
|
|
} |
1535
|
|
|
|
1536
|
|
|
/** |
1537
|
|
|
* Statistics about stories, topics and authors |
1538
|
|
|
* |
1539
|
|
|
* You can reach the statistics from the admin part of the news module by clicking on the "Statistics" tabs |
1540
|
|
|
* The number of visible elements in each table is equal to the module's option called "storycountadmin" |
1541
|
|
|
* There are 3 kind of different statistics : |
1542
|
|
|
* - Topics statistics |
1543
|
|
|
* For each topic you can see its number of articles, the number of time each topics was viewed, the number |
1544
|
|
|
* of attached files, the number of expired articles and the number of unique authors. |
1545
|
|
|
* - Articles statistics |
1546
|
|
|
* This part is decomposed in 3 tables : |
1547
|
|
|
* a) Most readed articles |
1548
|
|
|
* This table resumes, for all the news in your database, the most readed articles. |
1549
|
|
|
* The table contains, for each news, its topic, its title, the author and the number of views. |
1550
|
|
|
* b) Less readed articles |
1551
|
|
|
* That's the opposite action of the previous table and its content is the same |
1552
|
|
|
* c) Best rated articles |
1553
|
|
|
* You will find here the best rated articles, the content is the same that the previous tables, the last column is just changing and contains the article's rating |
1554
|
|
|
* - Authors statistics |
1555
|
|
|
* This part is also decomposed in 3 tables |
1556
|
|
|
* a) Most readed authors |
1557
|
|
|
* To create this table, the program compute the total number of reads per author and displays the most readed author and the number of views |
1558
|
|
|
* b) Best rated authors |
1559
|
|
|
* To created this table's content, the program compute the rating's average of each author and create a table |
1560
|
|
|
* c) Biggest contributors |
1561
|
|
|
* The goal of this table is to know who is creating the biggest number of articles. |
1562
|
|
|
*/ |
1563
|
|
|
function Stats() |
1564
|
|
|
{ |
1565
|
|
|
global $xoopsModule, $xoopsConfig; |
|
|
|
|
1566
|
|
|
xoops_cp_header(); |
1567
|
|
|
$myts = MyTextSanitizer::getInstance(); |
1568
|
|
View Code Duplication |
if (file_exists(XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/main.php')) { |
|
|
|
|
1569
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/main.php'; |
1570
|
|
|
} else { |
1571
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/language/english/main.php'; |
1572
|
|
|
} |
1573
|
|
|
$statsAdmin = new ModuleAdmin(); |
1574
|
|
|
echo $statsAdmin->addNavigation('index.php?op=stats'); |
1575
|
|
|
$news = new NewsStory(); |
1576
|
|
|
$stats = array(); |
|
|
|
|
1577
|
|
|
$stats = $news->GetStats(news_getmoduleoption('storycountadmin')); |
1578
|
|
|
$totals = array(0, 0, 0, 0, 0); |
1579
|
|
|
//printf("<h1>%s</h1>\n",_AM_NEWS_STATS); |
|
|
|
|
1580
|
|
|
|
1581
|
|
|
// First part of the stats, everything about topics |
1582
|
|
|
$storiespertopic = $stats['storiespertopic']; |
1583
|
|
|
$readspertopic = $stats['readspertopic']; |
1584
|
|
|
$filespertopic = $stats['filespertopic']; |
1585
|
|
|
$expiredpertopic = $stats['expiredpertopic']; |
1586
|
|
|
$authorspertopic = $stats['authorspertopic']; |
1587
|
|
|
$class = ''; |
1588
|
|
|
|
1589
|
|
|
echo "<div style='text-align: center;'><b>" . _AM_NEWS_STATS0 . "</b><br>\n"; |
1590
|
|
|
echo "<table border='0' width='100%'><tr class='bg3'><th align='center'>" |
1591
|
|
|
. _AM_TOPIC |
1592
|
|
|
. "</th><th align='center'>" |
1593
|
|
|
. _NW_ARTICLES |
1594
|
|
|
. '</th><th>' |
1595
|
|
|
. _NW_VIEWS |
1596
|
|
|
. '</th><th>' |
1597
|
|
|
. _AM_UPLOAD_ATTACHFILE |
1598
|
|
|
. '</th><th>' |
1599
|
|
|
. _AM_EXPARTS |
1600
|
|
|
. '</th><th>' |
1601
|
|
|
. _AM_NEWS_STATS1 |
1602
|
|
|
. '</th></tr>'; |
1603
|
|
|
foreach ($storiespertopic as $topicid => $data) { |
1604
|
|
|
$url = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/index.php?storytopic=' . $topicid; |
1605
|
|
|
$views = 0; |
1606
|
|
|
if (array_key_exists($topicid, $readspertopic)) { |
1607
|
|
|
$views = $readspertopic[$topicid]; |
1608
|
|
|
} |
1609
|
|
|
$attachedfiles = 0; |
1610
|
|
|
if (array_key_exists($topicid, $filespertopic)) { |
1611
|
|
|
$attachedfiles = $filespertopic[$topicid]; |
1612
|
|
|
} |
1613
|
|
|
$expired = 0; |
1614
|
|
|
if (array_key_exists($topicid, $expiredpertopic)) { |
1615
|
|
|
$expired = $expiredpertopic[$topicid]; |
1616
|
|
|
} |
1617
|
|
|
$authors = 0; |
1618
|
|
|
if (array_key_exists($topicid, $authorspertopic)) { |
1619
|
|
|
$authors = $authorspertopic[$topicid]; |
1620
|
|
|
} |
1621
|
|
|
$articles = $data['cpt']; |
1622
|
|
|
|
1623
|
|
|
$totals[0] += $articles; |
1624
|
|
|
$totals[1] += $views; |
1625
|
|
|
$totals[2] += $attachedfiles; |
1626
|
|
|
$totals[3] += $expired; |
1627
|
|
|
$class = ($class === 'even') ? 'odd' : 'even'; |
1628
|
|
|
printf("<tr class='" |
1629
|
|
|
. $class |
1630
|
|
|
. "'><td align='left'><a href='%s' target ='_blank'>%s</a></td><td align='right'>%u</td><td align='right'>%u</td><td align='right'>%u</td><td align='right'>%u</td><td align='right'>%u</td></tr>\n", |
1631
|
|
|
$url, $myts->displayTarea($data['topic_title']), $articles, $views, $attachedfiles, $expired, $authors); |
1632
|
|
|
} |
1633
|
|
|
$class = ($class === 'even') ? 'odd' : 'even'; |
1634
|
|
|
printf("<tr class='" |
1635
|
|
|
. $class |
1636
|
|
|
. "'><td align='center'><b>%s</b></td><td align='right'><b>%u</b></td><td align='right'><b>%u</b></td><td align='right'><b>%u</b></td><td align='right'><b>%u</b></td><td> </td>\n", |
1637
|
|
|
_AM_NEWS_STATS2, $totals[0], $totals[1], $totals[2], $totals[3]); |
1638
|
|
|
echo '</table></div><br><br><br>'; |
1639
|
|
|
|
1640
|
|
|
// Second part of the stats, everything about stories |
1641
|
|
|
// a) Most readed articles |
1642
|
|
|
$mostreadednews = $stats['mostreadednews']; |
1643
|
|
|
echo "<div style='text-align: center;'><b>" . _AM_NEWS_STATS3 . '</b><br><br>' . _AM_NEWS_STATS4 . "<br>\n"; |
1644
|
|
|
echo "<table border='0' width='100%'><tr class='bg3'><th align='center'>" |
1645
|
|
|
. _AM_TOPIC |
1646
|
|
|
. "</th><th align='center'>" |
1647
|
|
|
. _AM_TITLE |
1648
|
|
|
. '</th><th>' |
1649
|
|
|
. _AM_POSTER |
1650
|
|
|
. '</th><th>' |
1651
|
|
|
. _NW_VIEWS |
1652
|
|
|
. "</th></tr>\n"; |
1653
|
|
View Code Duplication |
foreach ($mostreadednews as $storyid => $data) { |
|
|
|
|
1654
|
|
|
$url1 = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/index.php?storytopic=' . $data['topicid']; |
1655
|
|
|
$url2 = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/article.php?storyid=' . $storyid; |
1656
|
|
|
$url3 = XOOPS_URL . '/userinfo.php?uid=' . $data['uid']; |
1657
|
|
|
$class = ($class === 'even') ? 'odd' : 'even'; |
1658
|
|
|
printf("<tr class='" |
1659
|
|
|
. $class |
1660
|
|
|
. "'><td align='left'><a href='%s' target ='_blank'>%s</a></td><td align='left'><a href='%s' target='_blank'>%s</a></td><td><a href='%s' target='_blank'>%s</a></td><td align='right'>%u</td></tr>\n", |
1661
|
|
|
$url1, $myts->displayTarea($data['topic_title']), $url2, $myts->displayTarea($data['title']), $url3, $myts->htmlSpecialChars($news->uname($data['uid'])), $data['counter']); |
1662
|
|
|
} |
1663
|
|
|
echo '</table>'; |
1664
|
|
|
|
1665
|
|
|
// b) Less readed articles |
1666
|
|
|
$lessreadednews = $stats['lessreadednews']; |
1667
|
|
|
echo '<br><br>' . _AM_NEWS_STATS5; |
1668
|
|
|
echo "<table border='0' width='100%'><tr class='bg3'><th align='center'>" |
1669
|
|
|
. _AM_TOPIC |
1670
|
|
|
. "</th><th align='center'>" |
1671
|
|
|
. _AM_TITLE |
1672
|
|
|
. '</th><th>' |
1673
|
|
|
. _AM_POSTER |
1674
|
|
|
. '</th><th>' |
1675
|
|
|
. _NW_VIEWS |
1676
|
|
|
. "</th></tr>\n"; |
1677
|
|
View Code Duplication |
foreach ($lessreadednews as $storyid => $data) { |
|
|
|
|
1678
|
|
|
$url1 = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/index.php?storytopic=' . $data['topicid']; |
1679
|
|
|
$url2 = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/article.php?storyid=' . $storyid; |
1680
|
|
|
$url3 = XOOPS_URL . '/userinfo.php?uid=' . $data['uid']; |
1681
|
|
|
$class = ($class === 'even') ? 'odd' : 'even'; |
1682
|
|
|
printf("<tr class='" |
1683
|
|
|
. $class |
1684
|
|
|
. "'><td align='left'><a href='%s' target ='_blank'>%s</a></td><td align='left'><a href='%s' target='_blank'>%s</a></td><td><a href='%s' target='_blank'>%s</a></td><td align='right'>%u</td></tr>\n", |
1685
|
|
|
$url1, $myts->displayTarea($data['topic_title']), $url2, $myts->displayTarea($data['title']), $url3, $myts->htmlSpecialChars($news->uname($data['uid'])), $data['counter']); |
1686
|
|
|
} |
1687
|
|
|
echo '</table>'; |
1688
|
|
|
|
1689
|
|
|
// c) Best rated articles (this is an average) |
1690
|
|
|
$besratednews = $stats['besratednews']; |
1691
|
|
|
echo '<br><br>' . _AM_NEWS_STATS6; |
1692
|
|
|
echo "<table border='0' width='100%'><tr class='bg3'><th align='center'>" |
1693
|
|
|
. _AM_TOPIC |
1694
|
|
|
. "</th><th align='center'>" |
1695
|
|
|
. _AM_TITLE |
1696
|
|
|
. '</th><th>' |
1697
|
|
|
. _AM_POSTER |
1698
|
|
|
. '</th><th>' |
1699
|
|
|
. _NW_RATING |
1700
|
|
|
. "</th></tr>\n"; |
1701
|
|
View Code Duplication |
foreach ($besratednews as $storyid => $data) { |
|
|
|
|
1702
|
|
|
$url1 = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/index.php?storytopic=' . $data['topicid']; |
1703
|
|
|
$url2 = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/article.php?storyid=' . $storyid; |
1704
|
|
|
$url3 = XOOPS_URL . '/userinfo.php?uid=' . $data['uid']; |
1705
|
|
|
$class = ($class === 'even') ? 'odd' : 'even'; |
1706
|
|
|
printf("<tr class='" |
1707
|
|
|
. $class |
1708
|
|
|
. "'><td align='left'><a href='%s' target ='_blank'>%s</a></td><td align='left'><a href='%s' target='_blank'>%s</a></td><td><a href='%s' target='_blank'>%s</a></td><td align='right'>%s</td></tr>\n", |
1709
|
|
|
$url1, $myts->displayTarea($data['topic_title']), $url2, $myts->displayTarea($data['title']), $url3, $myts->htmlSpecialChars($news->uname($data['uid'])), |
1710
|
|
|
number_format($data['rating'], 2)); |
1711
|
|
|
} |
1712
|
|
|
echo '</table></div><br><br><br>'; |
1713
|
|
|
|
1714
|
|
|
// Last part of the stats, everything about authors |
1715
|
|
|
// a) Most readed authors |
1716
|
|
|
$mostreadedauthors = $stats['mostreadedauthors']; |
1717
|
|
|
echo "<div style='text-align: center;'><b>" . _AM_NEWS_STATS10 . '</b><br><br>' . _AM_NEWS_STATS7 . "<br>\n"; |
1718
|
|
|
echo "<table border='0' width='100%'><tr class='bg3'><th>" . _AM_POSTER . '</th><th>' . _NW_VIEWS . "</th></tr>\n"; |
1719
|
|
View Code Duplication |
foreach ($mostreadedauthors as $uid => $reads) { |
|
|
|
|
1720
|
|
|
$url = XOOPS_URL . '/userinfo.php?uid=' . $uid; |
1721
|
|
|
$class = ($class === 'even') ? 'odd' : 'even'; |
1722
|
|
|
printf("<tr class='" . $class . "'><td align='left'><a href='%s' target ='_blank'>%s</a></td><td align='right'>%u</td></tr>\n", $url, $myts->htmlSpecialChars($news->uname($uid)), $reads); |
1723
|
|
|
} |
1724
|
|
|
echo '</table>'; |
1725
|
|
|
|
1726
|
|
|
// b) Best rated authors |
1727
|
|
|
$bestratedauthors = $stats['bestratedauthors']; |
1728
|
|
|
echo '<br><br>' . _AM_NEWS_STATS8; |
1729
|
|
|
echo "<table border='0' width='100%'><tr class='bg3'><th>" . _AM_POSTER . '</th><th>' . _NW_RATING . "</th></tr>\n"; |
1730
|
|
View Code Duplication |
foreach ($bestratedauthors as $uid => $rating) { |
|
|
|
|
1731
|
|
|
$url = XOOPS_URL . '/userinfo.php?uid=' . $uid; |
1732
|
|
|
$class = ($class === 'even') ? 'odd' : 'even'; |
1733
|
|
|
printf("<tr class='" . $class . "'><td align='left'><a href='%s' target ='_blank'>%s</a></td><td align='right'>%u</td></tr>\n", $url, $myts->htmlSpecialChars($news->uname($uid)), $rating); |
1734
|
|
|
} |
1735
|
|
|
echo '</table>'; |
1736
|
|
|
|
1737
|
|
|
// c) Biggest contributors |
1738
|
|
|
$biggestcontributors = $stats['biggestcontributors']; |
1739
|
|
|
echo '<br><br>' . _AM_NEWS_STATS9; |
1740
|
|
|
echo "<table border='0' width='100%'><tr class='bg3'><th>" . _AM_POSTER . '</th><th>' . _AM_NEWS_STATS11 . "</th></tr>\n"; |
1741
|
|
View Code Duplication |
foreach ($biggestcontributors as $uid => $count) { |
|
|
|
|
1742
|
|
|
$url = XOOPS_URL . '/userinfo.php?uid=' . $uid; |
1743
|
|
|
$class = ($class === 'even') ? 'odd' : 'even'; |
1744
|
|
|
printf("<tr class='" . $class . "'><td align='left'><a href='%s' target ='_blank'>%s</a></td><td align='right'>%u</td></tr>\n", $url, $myts->htmlSpecialChars($news->uname($uid)), $count); |
1745
|
|
|
} |
1746
|
|
|
echo '</table></div><br>'; |
1747
|
|
|
} |
1748
|
|
|
|
1749
|
|
|
/** |
1750
|
|
|
* Metagen |
1751
|
|
|
* |
1752
|
|
|
* Metagen is a system that can help you to have your page best indexed by search engines. |
1753
|
|
|
* Except if you type meta keywords and meta descriptions yourself, the module will automatically create them. |
1754
|
|
|
* From here you can also manage some other options like the maximum number of meta keywords to create and |
1755
|
|
|
* the keywords apparition's order. |
1756
|
|
|
*/ |
1757
|
|
|
function Metagen() |
1758
|
|
|
{ |
1759
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
1760
|
|
|
global $xoopsModule, $xoopsConfig, $xoopsModuleConfig, $cfg; |
|
|
|
|
1761
|
|
|
xoops_cp_header(); |
1762
|
|
|
$myts = MyTextSanitizer::getInstance(); |
|
|
|
|
1763
|
|
View Code Duplication |
if (file_exists(XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/main.php')) { |
|
|
|
|
1764
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/main.php'; |
1765
|
|
|
} else { |
1766
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/language/english/main.php'; |
1767
|
|
|
} |
1768
|
|
|
$metagenAdmin = new ModuleAdmin(); |
1769
|
|
|
echo $metagenAdmin->addNavigation('index.php?op=metagen'); |
1770
|
|
|
//echo "<h1>"._AM_NEWS_METAGEN."</h1>"; |
|
|
|
|
1771
|
|
|
echo _AM_NEWS_METAGEN_DESC . '<br><br>'; |
1772
|
|
|
|
1773
|
|
|
// Metagen Options |
1774
|
|
|
$registry = new news_registryfile('news_metagen_options.txt'); |
1775
|
|
|
$content = ''; |
|
|
|
|
1776
|
|
|
$content = $registry->getfile(); |
1777
|
|
View Code Duplication |
if (xoops_trim($content) !== '') { |
|
|
|
|
1778
|
|
|
list($keywordscount, $keywordsorder) = explode(',', $content); |
1779
|
|
|
} else { |
1780
|
|
|
$keywordscount = $cfg['meta_keywords_count']; |
1781
|
|
|
$keywordsorder = $cfg['meta_keywords_order']; |
1782
|
|
|
} |
1783
|
|
|
$sform = new XoopsThemeForm(_OPTIONS, 'metagenoptions', XOOPS_URL . '/modules/news/admin/index.php', 'post'); |
1784
|
|
|
$sform->addElement(new XoopsFormHidden('op', 'metagenoptions'), false); |
1785
|
|
|
$sform->addElement(new XoopsFormText(_AM_NEWS_META_KEYWORDS_CNT, 'keywordscount', 4, 6, $keywordscount), true); |
1786
|
|
|
$keywordsorder = new XoopsFormRadio(_AM_NEWS_META_KEYWORDS_ORDER, 'keywordsorder', $keywordsorder); |
1787
|
|
|
$keywordsorder->addOption(0, _AM_NEWS_META_KEYWORDS_INTEXT); |
1788
|
|
|
$keywordsorder->addOption(1, _AM_NEWS_META_KEYWORDS_FREQ1); |
1789
|
|
|
$keywordsorder->addOption(2, _AM_NEWS_META_KEYWORDS_FREQ2); |
1790
|
|
|
$sform->addElement($keywordsorder, false); |
1791
|
|
|
$button_tray = new XoopsFormElementTray('', ''); |
1792
|
|
|
$submit_btn = new XoopsFormButton('', 'post', _AM_MODIFY, 'submit'); |
1793
|
|
|
$button_tray->addElement($submit_btn); |
1794
|
|
|
$sform->addElement($button_tray); |
1795
|
|
|
$sform->display(); |
1796
|
|
|
|
1797
|
|
|
// Blacklist |
1798
|
|
|
$sform = new XoopsThemeForm(_AM_NEWS_BLACKLIST, 'metagenblacklist', XOOPS_URL . '/modules/news/admin/index.php', 'post'); |
1799
|
|
|
$sform->addElement(new XoopsFormHidden('op', 'metagenblacklist'), false); |
1800
|
|
|
|
1801
|
|
|
// Remove words |
1802
|
|
|
$remove_tray = new XoopsFormElementTray(_AM_NEWS_BLACKLIST); |
1803
|
|
|
$remove_tray->setDescription(_AM_NEWS_BLACKLIST_DESC); |
1804
|
|
|
$blacklist = new XoopsFormSelect('', 'blacklist', '', 5, true); |
1805
|
|
|
$words = array(); |
|
|
|
|
1806
|
|
|
|
1807
|
|
|
$metablack = new news_blacklist(); |
1808
|
|
|
$words = $metablack->getAllKeywords(); |
1809
|
|
|
if (is_array($words) && count($words) > 0) { |
1810
|
|
|
foreach ($words as $key => $value) { |
1811
|
|
|
$blacklist->addOption($key, $value); |
1812
|
|
|
} |
1813
|
|
|
} |
1814
|
|
|
|
1815
|
|
|
$blacklist->setDescription(_AM_NEWS_BLACKLIST_DESC); |
1816
|
|
|
$remove_tray->addElement($blacklist, false); |
1817
|
|
|
$remove_btn = new XoopsFormButton('', 'go', _AM_DELETE, 'submit'); |
1818
|
|
|
$remove_tray->addElement($remove_btn, false); |
1819
|
|
|
$sform->addElement($remove_tray); |
1820
|
|
|
|
1821
|
|
|
// Add some words |
1822
|
|
|
$add_tray = new XoopsFormElementTray(_AM_NEWS_BLACKLIST_ADD); |
1823
|
|
|
$add_tray->setDescription(_AM_NEWS_BLACKLIST_ADD_DSC); |
1824
|
|
|
$add_field = new XoopsFormTextArea('', 'keywords', '', 5, 70); |
1825
|
|
|
$add_tray->addElement($add_field, false); |
1826
|
|
|
$add_btn = new XoopsFormButton('', 'go', _AM_ADD, 'submit'); |
1827
|
|
|
$add_tray->addElement($add_btn, false); |
1828
|
|
|
$sform->addElement($add_tray); |
1829
|
|
|
$sform->display(); |
1830
|
|
|
} |
1831
|
|
|
|
1832
|
|
|
/** |
1833
|
|
|
* Save metagen's blacklist words |
1834
|
|
|
*/ |
1835
|
|
|
function MetagenBlackList() |
|
|
|
|
1836
|
|
|
{ |
1837
|
|
|
$blacklist = new news_blacklist(); |
1838
|
|
|
$words = $blacklist->getAllKeywords(); |
|
|
|
|
1839
|
|
|
|
1840
|
|
|
if (isset($_POST['go']) && $_POST['go'] == _AM_DELETE) { |
1841
|
|
|
foreach ($_POST['blacklist'] as $black_id) { |
1842
|
|
|
$blacklist->delete($black_id); |
1843
|
|
|
} |
1844
|
|
|
$blacklist->store(); |
1845
|
|
|
} else { |
1846
|
|
|
if (isset($_POST['go']) && $_POST['go'] == _AM_ADD) { |
1847
|
|
|
$p_keywords = $_POST['keywords']; |
1848
|
|
|
$keywords = explode("\n", $p_keywords); |
1849
|
|
|
foreach ($keywords as $keyword) { |
1850
|
|
|
if (xoops_trim($keyword) !== '') { |
1851
|
|
|
$blacklist->addkeywords(xoops_trim($keyword)); |
1852
|
|
|
} |
1853
|
|
|
} |
1854
|
|
|
$blacklist->store(); |
1855
|
|
|
} |
1856
|
|
|
} |
1857
|
|
|
redirect_header('index.php?op=metagen', 0, _AM_DBUPDATED); |
1858
|
|
|
} |
1859
|
|
|
|
1860
|
|
|
/** |
1861
|
|
|
* Save Metagen Options |
1862
|
|
|
*/ |
1863
|
|
|
function MetagenSaveOptions() |
|
|
|
|
1864
|
|
|
{ |
1865
|
|
|
$registry = new news_registryfile('news_metagen_options.txt'); |
1866
|
|
|
$registry->savefile((int)$_POST['keywordscount'] . ',' . (int)$_POST['keywordsorder']); |
1867
|
|
|
redirect_header('index.php?op=metagen', 0, _AM_DBUPDATED); |
1868
|
|
|
} |
1869
|
|
|
|
1870
|
|
|
// ********************************************************************************************************************************************** |
1871
|
|
|
// **** Main |
1872
|
|
|
// ********************************************************************************************************************************************** |
1873
|
|
|
$op = 'default'; |
1874
|
|
|
if (isset($_POST['op'])) { |
1875
|
|
|
$op = $_POST['op']; |
1876
|
|
|
} elseif (isset($_GET['op'])) { |
1877
|
|
|
$op = $_GET['op']; |
1878
|
|
|
} |
1879
|
|
|
$indexAdmin = new ModuleAdmin(); |
1880
|
|
|
switch ($op) { |
1881
|
|
|
case 'deletefile': |
1882
|
|
|
xoops_cp_header(); |
1883
|
|
|
if ($_GET['type'] === 'newsletter') { |
1884
|
|
|
$newsfile = XOOPS_ROOT_PATH . '/uploads/news/newsletter.txt'; |
1885
|
|
View Code Duplication |
if (unlink($newsfile)) { |
|
|
|
|
1886
|
|
|
redirect_header('index.php', 2, _AM_NEWS_DELETED_OK); |
1887
|
|
|
} else { |
1888
|
|
|
redirect_header('index.php', 2, _AM_NEWS_DELETED_PB); |
1889
|
|
|
} |
1890
|
|
|
} else { |
1891
|
|
|
if ($_GET['type'] === 'xml') { |
1892
|
|
|
$xmlfile = XOOPS_ROOT_PATH . '/uploads/news/stories.xml'; |
1893
|
|
View Code Duplication |
if (unlink($xmlfile)) { |
|
|
|
|
1894
|
|
|
redirect_header('index.php', 2, _AM_NEWS_DELETED_OK); |
1895
|
|
|
} else { |
1896
|
|
|
redirect_header('index.php', 2, _AM_NEWS_DELETED_PB); |
1897
|
|
|
} |
1898
|
|
|
} |
1899
|
|
|
} |
1900
|
|
|
break; |
1901
|
|
|
|
1902
|
|
|
case 'newarticle': |
1903
|
|
|
xoops_cp_header(); |
1904
|
|
|
echo $indexAdmin->addNavigation('index.php?op=newarticle'); |
1905
|
|
|
echo '<h4>' . _AM_CONFIG . '</h4>'; |
1906
|
|
|
include_once XOOPS_ROOT_PATH . '/class/module.textsanitizer.php'; |
1907
|
|
|
newSubmissions(); |
1908
|
|
|
autoStories(); |
1909
|
|
|
lastStories(); |
1910
|
|
|
expStories(); |
1911
|
|
|
echo '<br>'; |
1912
|
|
|
echo '<h4>' . _AM_POSTNEWARTICLE . '</h4>'; |
1913
|
|
|
$type = 'admin'; |
1914
|
|
|
$title = ''; |
1915
|
|
|
$topicdisplay = 0; |
1916
|
|
|
$topicalign = 'R'; |
1917
|
|
|
$ihome = 0; |
1918
|
|
|
$hometext = ''; |
1919
|
|
|
$bodytext = ''; |
1920
|
|
|
$notifypub = 1; |
1921
|
|
|
$nohtml = 0; |
1922
|
|
|
$approve = 0; |
1923
|
|
|
$nosmiley = 0; |
1924
|
|
|
$autodate = ''; |
1925
|
|
|
$expired = ''; |
1926
|
|
|
$topicid = 0; |
1927
|
|
|
$returnside = 1; |
1928
|
|
|
$published = 0; |
1929
|
|
|
$description = ''; |
1930
|
|
|
$keywords = ''; |
1931
|
|
View Code Duplication |
if (file_exists(XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/main.php')) { |
|
|
|
|
1932
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/main.php'; |
1933
|
|
|
} else { |
1934
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/language/english/main.php'; |
1935
|
|
|
} |
1936
|
|
|
|
1937
|
|
|
if ($xoopsModuleConfig['autoapprove'] == 1) { |
1938
|
|
|
$approve = 1; |
1939
|
|
|
} |
1940
|
|
|
$approveprivilege = 1; |
1941
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/include/storyform.original.php'; |
1942
|
|
|
break; |
1943
|
|
|
|
1944
|
|
|
case 'delete': |
1945
|
|
|
$storyid = 0; |
1946
|
|
View Code Duplication |
if (isset($_GET['storyid'])) { |
|
|
|
|
1947
|
|
|
$storyid = (int)$_GET['storyid']; |
1948
|
|
|
} elseif (isset($_POST['storyid'])) { |
1949
|
|
|
$storyid = (int)$_POST['storyid']; |
1950
|
|
|
} |
1951
|
|
|
|
1952
|
|
|
if (!empty($_POST['ok'])) { |
1953
|
|
|
if (empty($storyid)) { |
1954
|
|
|
redirect_header('index.php?op=newarticle', 2, _AM_EMPTYNODELETE); |
1955
|
|
|
} |
1956
|
|
|
$story = new NewsStory($storyid); |
1957
|
|
|
$story->delete(); |
1958
|
|
|
$sfiles = new sFiles(); |
1959
|
|
|
$filesarr = array(); |
1960
|
|
|
$filesarr = $sfiles->getAllbyStory($storyid); |
1961
|
|
|
if (count($filesarr) > 0) { |
1962
|
|
|
foreach ($filesarr as $onefile) { |
1963
|
|
|
$onefile->delete(); |
1964
|
|
|
} |
1965
|
|
|
} |
1966
|
|
|
xoops_comment_delete($xoopsModule->getVar('mid'), $storyid); |
1967
|
|
|
xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'story', $storyid); |
1968
|
|
|
news_updateCache(); |
1969
|
|
|
redirect_header('index.php?op=newarticle', 1, _AM_DBUPDATED); |
1970
|
|
|
} else { |
1971
|
|
|
$story = new NewsStory($storyid); |
1972
|
|
|
xoops_cp_header(); |
1973
|
|
|
echo '<h4>' . _AM_CONFIG . '</h4>'; |
1974
|
|
|
xoops_confirm(array('op' => 'delete', 'storyid' => $storyid, 'ok' => 1), 'index.php', _AM_RUSUREDEL . '<br>' . $story->title()); |
1975
|
|
|
} |
1976
|
|
|
break; |
1977
|
|
|
|
1978
|
|
|
case 'topicsmanager': |
1979
|
|
|
topicsmanager(); |
1980
|
|
|
break; |
1981
|
|
|
|
1982
|
|
|
case 'addTopic': |
1983
|
|
|
addTopic(); |
1984
|
|
|
break; |
1985
|
|
|
|
1986
|
|
|
case 'delTopic': |
1987
|
|
|
delTopic(); |
1988
|
|
|
break; |
1989
|
|
|
|
1990
|
|
|
case 'modTopicS': |
1991
|
|
|
modTopicS(); |
1992
|
|
|
break; |
1993
|
|
|
|
1994
|
|
|
case 'edit': |
1995
|
|
View Code Duplication |
if (file_exists(XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/main.php')) { |
|
|
|
|
1996
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/main.php'; |
1997
|
|
|
} else { |
1998
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/language/english/main.php'; |
1999
|
|
|
} |
2000
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/submit.php'; |
2001
|
|
|
break; |
2002
|
|
|
|
2003
|
|
|
case 'prune': |
2004
|
|
|
PruneManager(); |
2005
|
|
|
break; |
2006
|
|
|
|
2007
|
|
|
case 'confirmbeforetoprune': |
2008
|
|
|
ConfirmBeforeToPrune(); |
2009
|
|
|
break; |
2010
|
|
|
|
2011
|
|
|
case 'prunenews'; |
|
|
|
|
2012
|
|
|
PruneNews(); |
2013
|
|
|
break; |
2014
|
|
|
|
2015
|
|
|
case 'export': |
2016
|
|
|
NewsExport(); |
2017
|
|
|
break; |
2018
|
|
|
|
2019
|
|
|
case 'launchexport': |
2020
|
|
|
LaunchExport(); |
2021
|
|
|
break; |
2022
|
|
|
|
2023
|
|
|
case 'configurenewsletter': |
2024
|
|
|
Newsletter(); |
2025
|
|
|
break; |
2026
|
|
|
|
2027
|
|
|
case 'launchnewsletter': |
2028
|
|
|
LaunchNewsletter(); |
2029
|
|
|
break; |
2030
|
|
|
|
2031
|
|
|
case 'stats': |
2032
|
|
|
Stats(); |
2033
|
|
|
break; |
2034
|
|
|
|
2035
|
|
|
case 'metagen': |
2036
|
|
|
Metagen(); |
2037
|
|
|
break; |
2038
|
|
|
|
2039
|
|
|
case 'metagenoptions': |
2040
|
|
|
MetagenSaveOptions(); |
2041
|
|
|
break; |
2042
|
|
|
|
2043
|
|
|
case 'metagenblacklist': |
2044
|
|
|
MetagenBlackList(); |
2045
|
|
|
break; |
2046
|
|
|
|
2047
|
|
|
case 'verifydb': |
2048
|
|
|
xoops_cp_header(); |
2049
|
|
|
//news_adminmenu(); |
2050
|
|
|
$tbllist = $xoopsDB->prefix('news_stories') . ',' . $xoopsDB->prefix('news_topics') . ',' . $xoopsDB->prefix('news_stories_files') . ',' . $xoopsDB->prefix('news_stories_votedata'); |
2051
|
|
|
$xoopsDB->queryF('OPTIMIZE TABLE ' . $tbllist); |
2052
|
|
|
$xoopsDB->queryF('CHECK TABLE ' . $tbllist); |
2053
|
|
|
$xoopsDB->queryF('ANALYZE TABLE ' . $tbllist); |
2054
|
|
|
redirect_header('index.php', 3, _AM_DBUPDATED); |
2055
|
|
|
exit; |
2056
|
|
|
break; |
2057
|
|
|
|
2058
|
|
|
case 'default': |
2059
|
|
|
default: |
2060
|
|
|
xoops_cp_header(); |
2061
|
|
|
|
2062
|
|
|
$folder = array( |
2063
|
|
|
XOOPS_ROOT_PATH . '/uploads/news/', |
2064
|
|
|
XOOPS_ROOT_PATH . '/uploads/news/file', |
2065
|
|
|
XOOPS_ROOT_PATH . '/uploads/news/image' |
2066
|
|
|
); |
2067
|
|
|
|
2068
|
|
|
$topicsHandler = xoops_getModuleHandler('news_topics', 'news'); |
2069
|
|
|
$storiesHandler = xoops_getModuleHandler('news_stories', 'news'); |
2070
|
|
|
|
2071
|
|
|
//compte "total" |
2072
|
|
|
$count_stories = $storiesHandler->getCount(); |
2073
|
|
|
//compte "attente" |
2074
|
|
|
$criteria = new CriteriaCompo(); |
2075
|
|
|
$criteria->add(new Criteria('ihome', 1)); |
2076
|
|
|
$stories_ihome = $storiesHandler->getCount($criteria); |
2077
|
|
|
|
2078
|
|
|
$criteria = new CriteriaCompo(); |
2079
|
|
|
$criteria->add(new Criteria('published', 0, '>')); |
2080
|
|
|
$stories_published = $storiesHandler->getCount($criteria); |
2081
|
|
|
|
2082
|
|
|
$stories_need_approval = $count_stories - $stories_published; |
2083
|
|
|
|
2084
|
|
|
$criteria = new CriteriaCompo(); |
2085
|
|
|
$criteria->add(new Criteria('expired', 0, '>')); |
2086
|
|
|
$criteria->add(new Criteria('expired', time(), '<')); |
2087
|
|
|
$stories_expired = $storiesHandler->getCount($criteria); |
2088
|
|
|
|
2089
|
|
|
$criteria = new CriteriaCompo(); |
2090
|
|
|
$criteria->add(new Criteria('expired', 0, '>')); |
2091
|
|
|
$criteria->add(new Criteria('expired', time(), '>')); |
2092
|
|
|
$stories_expired_soon = $storiesHandler->getCount($criteria); |
2093
|
|
|
|
2094
|
|
|
//compte "total" |
2095
|
|
|
$count_topics = $topicsHandler->getCount(); |
2096
|
|
|
//compte "attente" |
2097
|
|
|
$criteria = new CriteriaCompo(); |
2098
|
|
|
$criteria->add(new Criteria('menu', 1)); |
2099
|
|
|
$topics_menu = $topicsHandler->getCount($criteria); |
2100
|
|
|
|
2101
|
|
|
$clr_count_stories = ($count_stories == 0) ? 'red' : 'green'; |
2102
|
|
|
$clr_count_topics = ($count_topics == 0) ? 'red' : 'green'; |
2103
|
|
|
$clr_ihome_stories = ($stories_ihome == 0) ? 'red' : 'green'; |
2104
|
|
|
$clr_menu_topics = ($topics_menu == 0) ? 'red' : 'green'; |
2105
|
|
|
|
2106
|
|
|
$clr_published_stories = ($stories_published == 0) ? 'red' : 'green'; |
2107
|
|
|
$clr_need_approval_stories = ($stories_need_approval == 0) ? 'green' : 'red'; |
2108
|
|
|
$clr_expired_stories = ($stories_expired == 0) ? 'red' : 'green'; |
2109
|
|
|
$clr_need_expired_soon_stories = ($stories_expired_soon == 0) ? 'red' : 'green'; |
2110
|
|
|
|
2111
|
|
|
$indexAdmin->addInfoBox(_AM_NEWS_STATISTICS); |
2112
|
|
|
$indexAdmin->addInfoBoxLine(_AM_NEWS_STATISTICS, _AM_NEWS_THEREARE_TOPICS, $count_topics, $clr_count_topics); |
2113
|
|
|
$indexAdmin->addInfoBoxLine(_AM_NEWS_STATISTICS, _AM_NEWS_THEREARE_TOPICS_ONLINE, $topics_menu, $clr_menu_topics); |
2114
|
|
|
$indexAdmin->addInfoBoxLine(_AM_NEWS_STATISTICS, _AM_NEWS_THEREARE_STORIES, $count_stories, $clr_count_stories); |
2115
|
|
|
$indexAdmin->addInfoBoxLine(_AM_NEWS_STATISTICS, _AM_NEWS_THEREARE_STORIES_ONLINE, $stories_ihome, $clr_ihome_stories); |
2116
|
|
|
|
2117
|
|
|
$indexAdmin->addInfoBoxLine(_AM_NEWS_STATISTICS, _AM_NEWS_THEREARE_STORIES_APPROVED, $stories_published, $clr_ihome_stories); |
2118
|
|
|
$indexAdmin->addInfoBoxLine(_AM_NEWS_STATISTICS, _AM_NEWS_THEREARE_STORIES_NEED_APPROVAL, $stories_need_approval, $clr_need_approval_stories); |
2119
|
|
|
$indexAdmin->addInfoBoxLine(_AM_NEWS_STATISTICS, _AM_NEWS_THEREARE_STORIES_EXPIRED, $stories_expired, $clr_expired_stories); |
2120
|
|
|
$indexAdmin->addInfoBoxLine(_AM_NEWS_STATISTICS, _AM_NEWS_THEREARE_STORIES_EXPIRED_SOON, $stories_expired_soon, $clr_need_expired_soon_stories); |
2121
|
|
|
|
2122
|
|
|
foreach (array_keys($folder) as $i) { |
2123
|
|
|
$indexAdmin->addConfigBoxLine($folder[$i], 'folder'); |
2124
|
|
|
$indexAdmin->addConfigBoxLine(array($folder[$i], '777'), 'chmod'); |
2125
|
|
|
} |
2126
|
|
|
|
2127
|
|
|
echo $indexAdmin->addNavigation(basename(__FILE__)); |
2128
|
|
|
echo $indexAdmin->renderIndex(); |
2129
|
|
|
|
2130
|
|
|
break; |
2131
|
|
|
|
2132
|
|
|
} |
2133
|
|
|
include_once __DIR__ . '/admin_footer.php'; |
2134
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.