Passed
Push — master ( 4f5633...f52f94 )
by Michael
01:52
created

public-album.php (8 issues)

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 65 and the first side effect is on line 21.

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.

Loading history...
2
/**
3
 * ExtGallery User area
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright   {@link https://xoops.org/ XOOPS Project}
13
 * @license     GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
14
 * @author      Zoullou (http://www.zoullou.net)
15
 * @package     ExtGallery
16
 */
17
18
19
use XoopsModules\Extgallery;
20
21
include __DIR__ . '/header.php';
22
require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
0 ignored issues
show
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
23
//require_once XOOPS_ROOT_PATH . '/modules/extgallery/class/publicPerm.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
24
25
$GLOBALS['xoopsOption']['template_main'] = 'extgallery_public-album.tpl';
26
include XOOPS_ROOT_PATH . '/header.php';
27
28
if (!isset($_GET['id'])) {
29
    $catId = 0;
30
} else {
31
    $catId = (int)$_GET['id'];
32
}
33
if (!isset($_GET['start'])) {
34
    $start = 0;
35
} else {
36
    $start = (int)$_GET['start'];
37
}
38
39
// HACK BLUETEEN TO SORT PHOTO BY USERS
40
//photo_date - photo_title - photo_hits - photo_rating
41
if (isset($_GET['sortby'])
42
    && ('photo_date' === $_GET['sortby']
43
        || 'photo_title' === $_GET['sortby']
44
        || 'photo_hits' === $_GET['sortby']
45
        || 'photo_rating' === $_GET['sortby'])) {
46
    $sortby = $_GET['sortby'];
47
} else {
48
    $sortby = 'photo_date';
49
}
50
51
//ASC ou DESC
52
if (isset($_GET['orderby']) && ('DESC' === $_GET['orderby'] || 'ASC' === $_GET['orderby'])) {
53
    $orderby = $_GET['orderby'];
54
} else {
55
    $orderby = $GLOBALS['xoopsModuleConfig']['display_set_order'];
56
}
57
58
$SortbyOrderby = $sortby . ' ' . $orderby;
59
60
/**
61
 * @param $SortbyOrderby
62
 *
63
 * @return array|string
64
 */
65
function convertorderbytrans($SortbyOrderby)
66
{
67
    $orderbyTrans = [];
68
    if ('photo_date DESC' === $SortbyOrderby) {
69
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DATEASC;
70
    }
71
    if ('photo_date ASC' === $SortbyOrderby) {
72
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DATEDESC;
73
    }
74
    if ('photo_title ASC' === $SortbyOrderby) {
75
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_TITREASC;
76
    }
77
    if ('photo_title DESC' === $SortbyOrderby) {
78
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_TITREDESC;
79
    }
80
    if ('uid ASC' === $SortbyOrderby) {
81
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DESIGNERASC;
82
    }
83
    if ('uid DESC' === $SortbyOrderby) {
84
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DESIGNERDESC;
85
    }
86
    if ('photo_hits DESC' === $SortbyOrderby) {
87
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_HITSASC;
88
    }
89
    if ('photo_hits ASC' === $SortbyOrderby) {
90
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_HITSDESC;
91
    }
92
    if ('photo_rating DESC' === $SortbyOrderby) {
93
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_NOTEASC;
94
    }
95
    if ('photo_rating ASC' === $SortbyOrderby) {
96
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_NOTEDESC;
97
    }
98
99
    return $orderbyTrans;
100
}
101
102
// Check the access permission
103
$permHandler = Extgallery\PublicPermHandler::getInstance();
104
if ((null === $GLOBALS['xoopsUser'] || !is_object($GLOBALS['xoopsUser'])) || !$permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_access', $catId)) {
105
    redirect_header('index.php', 3, _NOPERM);
0 ignored issues
show
The constant _NOPERM was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
The function redirect_header was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

105
    /** @scrutinizer ignore-call */ 
106
    redirect_header('index.php', 3, _NOPERM);
Loading history...
106
}
107
/** @var Extgallery\PublicCategoryHandler $catHandler */
108
$catHandler = Extgallery\Helper::getInstance()->getHandler('PublicCategory');
109
/** @var Extgallery\PublicPhotoHandler $photoHandler */
110
$photoHandler = Extgallery\Helper::getInstance()->getHandler('PublicPhoto');
111
112
$catObj = $catHandler->getCat($catId);
113
114
if (null === $catObj) {
115
    include XOOPS_ROOT_PATH . '/footer.php';
116
    exit;
117
}
118
119
$ajaxeffect = $xoopsModuleConfig['use_ajax_effects'];
120
$xoopsTpl->assign('use_ajax_effects', $ajaxeffect);
121
122
$cat = $catHandler->objectToArray($catObj);
123
$xoopsTpl->assign('cat', $cat);
124
125
$catPath = $photoHandler->objectToArray($catHandler->getPath($catId));
126
$xoopsTpl->assign('catPath', $catPath);
127
128
$photos = $photoHandler->objectToArray($photoHandler->getAlbumPhotoPage($catId, $start, $sortby, $orderby), ['uid']); //xoops - blueteen - tri de l'affichage
129
130
// Plugin traitement
131
$plugin  = Extgallery\Helper::getInstance()->getHandler('Plugin');
132
$nbPhoto = count($photos);
133
foreach ($photos as $i => $iValue) {
134
    $params = ['catId' => $catId, 'photoId' => $photos[$i]['photo_id'], 'link' => []];
135
    $plugin->triggerEvent('photoAlbumLink', $params);
136
    $photos[$i]['link'] = $params['link'];
137
}
138
139
$k = $xoopsModuleConfig['nb_column'] - (count($photos) % $xoopsModuleConfig['nb_column']);
140
if ($k != $xoopsModuleConfig['nb_column']) {
141
    for ($i = 0; $i < $k; ++$i) {
142
        $photos[] = [];
143
    }
144
}
145
146
// HACK DATE BY MAGE : DISPLAY PUBLICATION DATE
147
foreach (array_keys($photos) as $i) {
148
    if (isset($photos[$i]['photo_date'])) {
149
        $photos[$i]['photo_date'] = date(_SHORTDATESTRING, $photos[$i]['photo_date']);
0 ignored issues
show
The constant _SHORTDATESTRING was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
150
    }
151
}
152
// END HACK DATE BY MAGE : DISPLAY PUBLICATION DATE
153
154
$xoopsTpl->assign('photos', $photos);
155
/** @var xos_opal_Theme $xoTheme */
156
157
$pageNav = new \XoopsPageNav($photoHandler->getAlbumCount($catId), $xoopsModuleConfig['nb_column'] * $xoopsModuleConfig['nb_line'], $start, 'start', 'id=' . $catId . '&orderby=' . $orderby . '&sortby=' . $sortby); //xoops - blueteen - tri de l'affichage
0 ignored issues
show
The type XoopsPageNav was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
158
$xoopsTpl->assign('pageNav', $pageNav->renderNav());
159
if (isset($catObj)) {
160
    $xoopsTpl->assign('xoops_pagetitle', $catObj->getVar('cat_name'));
161
    $xoTheme->addMeta('meta', 'description', $catObj->getVar('cat_desc'));
162
}
163
164
$jquery = $xoopsModuleConfig['enable_jquery'];
165
$xoopsTpl->assign('jquery', $jquery);
166
if (1 == $jquery && 'none' !== $ajaxeffect) {
167
    $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js');
168
    switch ($ajaxeffect) {
169
        case 'lightbox':
170
            $xoTheme->addScript('browse.php?Frameworks/jquery/plugins/jquery.lightbox.js');
171
            $xoTheme->addStylesheet('browse.php?modules/system/css/lightbox.css');
172
            break;
173
174
        case 'tooltip':
175
            $xoTheme->addScript('browse.php?modules/extgallery/assets/js/tooltip/image.tooltip.js');
176
            $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/tooltip/image.tooltip.css');
177
            break;
178
179
        case 'overlay':
180
            $xoTheme->addScript('browse.php?modules/extgallery/assets/js/overlay/overlay.jquery.tools.min.js');
181
            $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/overlay/overlay.css');
182
            break;
183
184
        case 'fancybox':
185
            $xoTheme->addScript('browse.php?modules/extgallery/assets/js/fancybox/mousewheel.js');
186
            $xoTheme->addScript('browse.php?modules/extgallery/assets/js/fancybox/fancybox.pack.js');
187
            $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/fancybox/fancybox.css');
188
            break;
189
190
        case 'prettyphoto':
191
            $xoTheme->addScript('browse.php?modules/extgallery/assets/js/prettyphoto/jquery.prettyPhoto.js');
192
            $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/prettyphoto/prettyPhoto.css');
193
            break;
194
    }
195
}
196
197
$rel                 = 'alternate';
198
$attributes['rel']   = $rel;
199
$attributes['type']  = 'application/rss+xml';
200
$attributes['title'] = _MD_EXTGALLERY_RSS;
201
$attributes['href']  = XOOPS_URL . '/modules/extgallery/public-rss.php';
0 ignored issues
show
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
202
$xoTheme->addMeta('link', $rel, $attributes);
203
$xoTheme->addStylesheet('modules/extgallery/assets/css/style.css');
204
205
$lang = [
206
    'hits'       => _MD_EXTGALLERY_HITS,
207
    'comments'   => _MD_EXTGALLERY_COMMENTS,
208
    'rate_score' => _MD_EXTGALLERY_RATING_SCORE
209
];
210
$xoopsTpl->assign('lang', $lang);
211
212
$xoopsTpl->assign('enableExtra', $xoopsModuleConfig['display_extra_field']);
213
$xoopsTpl->assign('enableRating', $xoopsModuleConfig['enable_rating']);
214
$xoopsTpl->assign('nbColumn', $xoopsModuleConfig['nb_column']);
215
$xoopsTpl->assign('extgalleryName', $xoopsModule->getVar('name'));
216
$xoopsTpl->assign('disp_ph_title', $xoopsModuleConfig['disp_ph_title']);
217
218
$xoopsTpl->assign('extgalleryID', $catId); //xoops - blueteen - tri de l'affichage
219
$xoopsTpl->assign('extgalleryStart', $start); //xoops -blueteen - tri de l'affichage
220
$xoopsTpl->assign('extgallerySortbyOrderby', _MD_EXTGALLERY_ORDERBY . convertorderbytrans($SortbyOrderby)); //xoops - blueteen - tri de l'affichage
221
222
//DNPROSSI - VOLTAN - added preferences option
223
//  enable_info, enable_submitter_lnk, enable_photo_hits
224
if ('album' === $xoopsModuleConfig['info_view'] || 'both' === $xoopsModuleConfig['info_view']) {
225
    if ('public' === $xoopsModuleConfig['pubusr_info_view'] || 'both' === $xoopsModuleConfig['pubusr_info_view']) {
226
        if (0 == $xoopsModuleConfig['enable_info']) {
227
            $enable_info = $xoopsModuleConfig['enable_info'];
228
        } else {
229
            $enable_info = 1;
230
        }
231
    } else {
232
        $enable_info = 1;
233
    }
234
} else {
235
    $enable_info = 1;
236
}
237
$xoopsTpl->assign('enable_info', $enable_info);
238
$xoopsTpl->assign('enable_photo_hits', $xoopsModuleConfig['enable_photo_hits']);
239
$xoopsTpl->assign('enable_submitter_lnk', $xoopsModuleConfig['enable_submitter_lnk']);
240
$xoopsTpl->assign('enable_show_comments', $xoopsModuleConfig['enable_show_comments']);
241
$xoopsTpl->assign('enable_date', $xoopsModuleConfig['enable_date']);
242
$xoopsTpl->assign('show_rss', $xoopsModuleConfig['show_rss']);
243
244
//for tooltip
245
$xoopsTpl->assign('album_tooltip_borderwidth', $xoopsModuleConfig['album_tooltip_borderwidth']);
246
$xoopsTpl->assign('album_tooltip_bordercolor', $xoopsModuleConfig['album_tooltip_bordercolor']);
247
$xoopsTpl->assign('album_tooltip_width', $xoopsModuleConfig['album_tooltip_width']);
248
249
//for overlay
250
$xoopsTpl->assign('album_overlay_bg', $xoopsModuleConfig['album_overlay_bg']);
251
$xoopsTpl->assign('album_overlay_width', $xoopsModuleConfig['album_overlay_width']);
252
$xoopsTpl->assign('album_overlay_height', $xoopsModuleConfig['album_overlay_height']);
253
254
//for fancybox
255
$xoopsTpl->assign('album_fancybox_color', $xoopsModuleConfig['album_fancybox_color']);
256
$xoopsTpl->assign('album_fancybox_opacity', $xoopsModuleConfig['album_fancybox_opacity']);
257
$xoopsTpl->assign('album_fancybox_tin', $xoopsModuleConfig['album_fancybox_tin']);
258
$xoopsTpl->assign('album_fancybox_tout', $xoopsModuleConfig['album_fancybox_tout']);
259
$xoopsTpl->assign('album_fancybox_title', $xoopsModuleConfig['album_fancybox_title']);
260
$xoopsTpl->assign('album_fancybox_showtype', $xoopsModuleConfig['album_fancybox_showtype']);
261
262
//for prettyphoto
263
$xoopsTpl->assign('album_prettyphoto_speed', $xoopsModuleConfig['album_prettyphoto_speed']);
264
$xoopsTpl->assign('album_prettyphoto_theme', $xoopsModuleConfig['album_prettyphoto_theme']);
265
$xoopsTpl->assign('album_prettyphoto_slidspeed', $xoopsModuleConfig['album_prettyphoto_slidspe']);
266
$xoopsTpl->assign('album_prettyphoto_autoplay', $xoopsModuleConfig['album_prettyphoto_autopla']);
267
268
include XOOPS_ROOT_PATH . '/footer.php';
269