1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Module: Soapbox |
4
|
|
|
* Author: hsalazar |
5
|
|
|
* Licence: GNU |
6
|
|
|
* @param $options |
7
|
|
|
* @return array |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
use XoopsModules\Soapbox; |
11
|
|
|
|
12
|
|
|
// defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
13
|
|
|
/** |
14
|
|
|
* @param $options |
15
|
|
|
* @return array|null |
16
|
|
|
*/ |
17
|
|
|
function b_arts_top_show($options) |
18
|
|
|
{ |
19
|
|
|
$myts = \MyTextSanitizer:: getInstance(); |
20
|
|
|
$helper = \XoopsModules\Soapbox\Helper::getInstance(); |
|
|
|
|
21
|
|
|
$block_outdata = []; |
22
|
|
|
$module_name = 'soapbox'; |
23
|
|
|
$moduleHandler = xoops_getHandler('module'); |
24
|
|
|
$soapModule = $moduleHandler->getByDirname($module_name); |
|
|
|
|
25
|
|
|
if (!is_object($soapModule)) { |
26
|
|
|
return null; |
27
|
|
|
} |
28
|
|
|
$hModConfig = xoops_getHandler('config'); |
29
|
|
|
$module_id = $soapModule->getVar('mid'); |
30
|
|
|
$soapConfig = $hModConfig->getConfigsByCat(0, $module_id); |
|
|
|
|
31
|
|
|
//------------------------------------- |
32
|
|
|
if (!in_array($options[0], ['datesub', 'weight', 'counter', 'rating', 'headline'], true)) { |
33
|
|
|
$options[0] = 'datesub'; |
34
|
|
|
} |
35
|
|
|
$sortorder = 'DESC'; |
36
|
|
|
if ('weight' === $options[0]) { |
37
|
|
|
$sortorder = 'ASC'; |
38
|
|
|
} |
39
|
|
|
/** @var \XoopsModules\Soapbox\EntrygetHandler $entrydataHandler */ |
40
|
|
|
$entrydataHandler = new \XoopsModules\Soapbox\EntrygetHandler(); |
41
|
|
|
$entryobArray = $entrydataHandler->getArticlesAllPermcheck((int)$options[1], 0, true, true, 0, 0, 1, $options[0], $sortorder, null, null, false, false); |
42
|
|
|
if (empty($entryobArray) || 0 === count($entryobArray)) { |
43
|
|
|
return $block_outdata; |
44
|
|
|
} |
45
|
|
|
//------------------------------------- |
46
|
|
|
foreach ($entryobArray as $_entryob) { |
47
|
|
|
if (is_object($_entryob)) { |
48
|
|
|
//----------- |
49
|
|
|
$newarts['linktext'] = xoops_substr($_entryob->getVar('headline'), 0, (int)$options[2]); |
50
|
|
|
$newarts['id'] = $_entryob->getVar('articleID'); |
51
|
|
|
$newarts['dir'] = $module_name; |
52
|
|
|
$newarts['date'] = $myts->htmlSpecialChars(formatTimestamp($_entryob->getVar('datesub'), $soapConfig['dateformat'])); |
53
|
|
|
if ('datesub' === $options[0]) { |
54
|
|
|
$newarts['new'] = $myts->htmlSpecialChars(formatTimestamp($_entryob->getVar('datesub'), $soapConfig['dateformat'])); |
55
|
|
|
} elseif ('counter' === $options[0]) { |
56
|
|
|
$newarts['new'] = $_entryob->getVar('counter'); |
57
|
|
|
} elseif ('weight' === $options[0]) { |
58
|
|
|
$newarts['new'] = $_entryob->getVar('weight'); |
59
|
|
|
} elseif ('rating' === $options[0]) { |
60
|
|
|
$newarts['new'] = number_format($_entryob->getVar('rating'), 2, '.', ''); |
61
|
|
|
$newarts['votes'] = $_entryob->getVar('votes'); |
62
|
|
|
} else { |
63
|
|
|
$newarts['new'] = $myts->htmlSpecialChars(formatTimestamp($_entryob->getVar('datesub'), $soapConfig['dateformat'])); |
64
|
|
|
} |
65
|
|
|
$block_outdata['toparticles'][] = $newarts; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
return $block_outdata; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param $options |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
function b_arts_top_edit($options) |
77
|
|
|
{ |
78
|
|
|
$myts = \MyTextSanitizer:: getInstance(); |
79
|
|
|
$form = '' . _MB_SOAPBOX_ORDER . " <select name='options[]'>"; |
80
|
|
|
|
81
|
|
|
$form .= "<option value='datesub'"; |
82
|
|
|
if ('datesub' === $options[0]) { |
83
|
|
|
$form .= ' selected'; |
84
|
|
|
} |
85
|
|
|
$form .= '>' . _MB_SOAPBOX_DATE . "</option>\n"; |
86
|
|
|
|
87
|
|
|
$form .= "<option value='counter'"; |
88
|
|
|
if ('counter' === $options[0]) { |
89
|
|
|
$form .= ' selected'; |
90
|
|
|
} |
91
|
|
|
$form .= '>' . _MB_SOAPBOX_HITS . "</option>\n"; |
92
|
|
|
|
93
|
|
|
$form .= "<option value='weight'"; |
94
|
|
|
if ('weight' === $options[0]) { |
95
|
|
|
$form .= ' selected'; |
96
|
|
|
} |
97
|
|
|
$form .= '>' . _MB_SOAPBOX_WEIGHT . "</option>\n"; |
98
|
|
|
|
99
|
|
|
$form .= "<option value='rating'"; |
100
|
|
|
if ('rating' === $options[0]) { |
101
|
|
|
$form .= ' selected'; |
102
|
|
|
} |
103
|
|
|
$form .= '>' . _MB_SOAPBOX_RATING . "</option>\n"; |
104
|
|
|
|
105
|
|
|
$form .= "</select>\n"; |
106
|
|
|
$form .= ' ' . _MB_SOAPBOX_DISP . " <input type='text' name='options[]' value='" . $myts->htmlSpecialChars($options[1]) . "'> " . _MB_SOAPBOX_ARTCLS . ''; |
107
|
|
|
$form .= ' <br>' . _MB_SOAPBOX_CHARS . " <input type='text' name='options[]' value='" . $myts->htmlSpecialChars($options[2]) . "'> " . _MB_SOAPBOX_LENGTH . ''; |
108
|
|
|
|
109
|
|
|
return $form; |
110
|
|
|
} |
111
|
|
|
|