1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @category Module |
14
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
15
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
16
|
|
|
* @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org> |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use XoopsModules\Suico\{ |
20
|
|
|
Helper, |
21
|
|
|
ImageHandler |
22
|
|
|
}; |
23
|
|
|
/** @var Helper $helper */ |
24
|
|
|
|
25
|
|
|
if (!defined('XOOPS_ROOT_PATH')) { |
26
|
|
|
exit(); |
27
|
|
|
} |
28
|
|
|
//require_once XOOPS_ROOT_PATH."/class/criteria.php"; |
29
|
|
|
//require_once XOOPS_ROOT_PATH . '/modules/suico/class/Image.php'; |
30
|
|
|
/** |
31
|
|
|
* @param $options |
32
|
|
|
* @return array|false |
33
|
|
|
*/ |
34
|
|
|
function b_suico_lastpictures_show($options) |
35
|
|
|
{ |
36
|
|
|
global $xoopsDB; |
37
|
|
|
|
38
|
|
|
/** @var Helper $helper */ |
39
|
|
|
if (!class_exists(Helper::class)) { |
40
|
|
|
return false; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$helper = Helper::getInstance(); |
44
|
|
|
$helper->loadLanguage('main'); |
45
|
|
|
|
46
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
|
|
|
47
|
|
|
$block = []; |
48
|
|
|
/** |
49
|
|
|
* Criteria for Pictures Block |
50
|
|
|
*/ |
51
|
|
|
$criteria = new Criteria('image_id', 0, '>'); |
52
|
|
|
$criteria->setSort('image_id'); |
53
|
|
|
$criteria->setOrder('DESC'); |
54
|
|
|
$criteria->setLimit($options[4]); |
55
|
|
|
/** |
56
|
|
|
* Creating factories of pictures |
57
|
|
|
*/ |
58
|
|
|
$imageFactory = new ImageHandler($xoopsDB); |
59
|
|
|
$block['picture'] = $imageFactory->getLastPicturesForBlock($options[4]); |
60
|
|
|
$block['showtitle'] = $options[0]; |
61
|
|
|
$block['showcaption'] = $options[1]; |
62
|
|
|
$block['showdate'] = $options[2]; |
63
|
|
|
$block['showowner'] = $options[3]; |
64
|
|
|
|
65
|
|
|
return $block; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param $options |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
|
|
function b_suico_lastpictures_edit($options) |
73
|
|
|
{ |
74
|
|
|
$form = _MB_SUICO_SHOWPICTURETITLE . ' '; |
75
|
|
|
$chk = ''; |
76
|
|
|
if (isset($options[0]) && 0 != $options[0]) { |
77
|
|
|
$chk = ' checked'; |
78
|
|
|
} |
79
|
|
|
$form .= "<input type='radio' name='options[0]' value='1'" . $chk . ' > ' . _YES . ''; |
80
|
|
|
$chk = ''; |
81
|
|
|
if (!isset($options[0]) || 0 == $options[0]) { |
82
|
|
|
$chk = ' checked'; |
83
|
|
|
} |
84
|
|
|
$form .= " <input type='radio' name='options[0]' value='0'" . $chk . ' >' . _NO . '<br>'; |
85
|
|
|
$form .= _MB_SUICO_SHOWPICTURECAPTION . ' '; |
86
|
|
|
if (isset($options[1]) && 1 == $options[1]) { |
87
|
|
|
$chk = ' checked'; |
88
|
|
|
} |
89
|
|
|
$form .= "<input type='radio' name='options[1]' value='1'" . $chk . ' > ' . _YES . ''; |
90
|
|
|
$chk = ''; |
91
|
|
|
if (!isset($options[1]) || 0 == $options[1]) { |
92
|
|
|
$chk = ' checked'; |
93
|
|
|
} |
94
|
|
|
$form .= " <input type='radio' name='options[1]' value='0'" . $chk . ' >' . _NO . '<br>'; |
95
|
|
|
$form .= _MB_SUICO_SHOWPICTUREDATE . ' '; |
96
|
|
|
if (isset($options[2]) && 1 == $options[2]) { |
97
|
|
|
$chk = ' checked'; |
98
|
|
|
} |
99
|
|
|
$form .= "<input type='radio' name='options[2]' value='1'" . $chk . ' > ' . _YES . ''; |
100
|
|
|
$chk = ''; |
101
|
|
|
if (!isset($options[2]) || 0 == $options[2]) { |
102
|
|
|
$chk = ' checked'; |
103
|
|
|
} |
104
|
|
|
$form .= " <input type='radio' name='options[2]' value='0'" . $chk . ' >' . _NO . '<br>'; |
105
|
|
|
$form .= _MB_SUICO_SHOWPICTUREOWNER . ' '; |
106
|
|
|
if (isset($options[3]) && 1 == $options[3]) { |
107
|
|
|
$chk = ' checked'; |
108
|
|
|
} |
109
|
|
|
$form .= "<input type='radio' name='options[3]' value='1'" . $chk . ' > ' . _YES . ''; |
110
|
|
|
$chk = ''; |
111
|
|
|
if (!isset($options[3]) || 0 == $options[3]) { |
112
|
|
|
$chk = ' checked'; |
113
|
|
|
} |
114
|
|
|
$form .= " <input type='radio' name='options[3]' value='0'" . $chk . ' >' . _NO . '<br>'; |
115
|
|
|
$form .= _MB_SUICO_TOTALPICTUREDISPLAY . ' '; |
116
|
|
|
$form .= "<input type='text' name='options[4]' value='" . ($options[4] ?? 0) . "'>"; |
117
|
|
|
|
118
|
|
|
return $form; |
119
|
|
|
} |
120
|
|
|
|