1 | <?php |
||
0 ignored issues
–
show
|
|||
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 | use XoopsModules\Extgallery; |
||
19 | |||
20 | include __DIR__ . '/header.php'; |
||
21 | require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
0 ignored issues
–
show
|
|||
22 | //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. ![]() |
|||
23 | |||
24 | $GLOBALS['xoopsOption']['template_main'] = 'extgallery_public-useralbum.tpl'; |
||
25 | include XOOPS_ROOT_PATH . '/header.php'; |
||
26 | |||
27 | if (!isset($_GET['id'])) { |
||
28 | $userId = 0; |
||
29 | } else { |
||
30 | $userId = (int)$_GET['id']; |
||
31 | } |
||
32 | if (!isset($_GET['start'])) { |
||
33 | $start = 0; |
||
34 | } else { |
||
35 | $start = (int)$_GET['start']; |
||
36 | } |
||
37 | |||
38 | $ajaxeffect = $xoopsModuleConfig['use_ajax_effects']; |
||
39 | $xoopsTpl->assign('use_ajax_effects', $ajaxeffect); |
||
40 | |||
41 | //HACK BLUETEEN TO SORT PHOTOS BY USERS |
||
42 | //photo_date - photo_title - photo_hits - photo_rating |
||
43 | if (isset($_GET['sortby']) |
||
44 | && ('photo_date' === $_GET['sortby'] |
||
45 | || 'photo_title' === $_GET['sortby'] |
||
46 | || 'photo_hits' === $_GET['sortby'] |
||
47 | || 'photo_rating' === $_GET['sortby'])) { |
||
48 | $sortby = $_GET['sortby']; |
||
49 | } else { |
||
50 | $sortby = 'photo_date'; |
||
51 | } |
||
52 | |||
53 | //ASC ou DESC |
||
54 | if (isset($_GET['orderby']) && ('DESC' === $_GET['orderby'] || 'ASC' === $_GET['orderby'])) { |
||
55 | $orderby = $_GET['orderby']; |
||
56 | } else { |
||
57 | $orderby = $GLOBALS['xoopsModuleConfig']['display_set_order']; |
||
58 | } |
||
59 | |||
60 | $SortbyOrderby = $sortby . ' ' . $orderby; |
||
61 | |||
62 | /** |
||
63 | * @param $SortbyOrderby |
||
64 | * |
||
65 | * @return array|string |
||
66 | */ |
||
67 | function convertorderbytrans($SortbyOrderby) |
||
68 | { |
||
69 | $orderbyTrans = []; |
||
70 | if ('photo_date DESC' === $SortbyOrderby) { |
||
71 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DATEASC; |
||
72 | } |
||
73 | if ('photo_date ASC' === $SortbyOrderby) { |
||
74 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DATEDESC; |
||
75 | } |
||
76 | if ('photo_title ASC' === $SortbyOrderby) { |
||
77 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_TITREASC; |
||
78 | } |
||
79 | if ('photo_title DESC' === $SortbyOrderby) { |
||
80 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_TITREDESC; |
||
81 | } |
||
82 | if ('uid ASC' === $SortbyOrderby) { |
||
83 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DESIGNERASC; |
||
84 | } |
||
85 | if ('uid DESC' === $SortbyOrderby) { |
||
86 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DESIGNERDESC; |
||
87 | } |
||
88 | if ('photo_hits DESC' === $SortbyOrderby) { |
||
89 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_HITSASC; |
||
90 | } |
||
91 | if ('photo_hits ASC' === $SortbyOrderby) { |
||
92 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_HITSDESC; |
||
93 | } |
||
94 | if ('photo_rating DESC' === $SortbyOrderby) { |
||
95 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_NOTEASC; |
||
96 | } |
||
97 | if ('photo_rating ASC' === $SortbyOrderby) { |
||
98 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_NOTEDESC; |
||
99 | } |
||
100 | |||
101 | return $orderbyTrans; |
||
102 | } |
||
103 | |||
104 | /** @var Extgallery\PublicPhotoHandler $photoHandler */ |
||
105 | $photoHandler = Extgallery\Helper::getInstance()->getHandler('PublicPhoto'); |
||
106 | |||
107 | $photos = $photoHandler->objectToArray($photoHandler->getUserAlbumPhotoPage($userId, $start, $sortby, $orderby), ['uid']); |
||
108 | $k = $xoopsModuleConfig['nb_column'] - (count($photos) % $xoopsModuleConfig['nb_column']); |
||
109 | if ($k != $xoopsModuleConfig['nb_column']) { |
||
110 | for ($i = 0; $i < $k; ++$i) { |
||
111 | $photos[] = []; |
||
112 | } |
||
113 | } |
||
114 | |||
115 | // HACK DATE BY MAGE : DISPLAY PUBLICATION DATE |
||
116 | foreach (array_keys($photos) as $i) { |
||
117 | if (isset($photos[$i]['photo_date'])) { |
||
118 | $photos[$i]['photo_date'] = date(_SHORTDATESTRING, $photos[$i]['photo_date']); |
||
0 ignored issues
–
show
|
|||
119 | } |
||
120 | } |
||
121 | // END HACK DATE BY MAGE : DISPLAY PUBLICATION DATE |
||
122 | |||
123 | $xoopsTpl->assign('photos', $photos); |
||
124 | |||
125 | $pageNav = new \XoopsPageNav($photoHandler->getUserAlbumCount($userId), $xoopsModuleConfig['nb_column'] * $xoopsModuleConfig['nb_line'], $start, 'start', 'id=' . $userId . '&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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
126 | $xoopsTpl->assign('pageNav', $pageNav->renderNav()); |
||
127 | |||
128 | $albumName = ''; |
||
129 | if (count($photos) > 0) { |
||
130 | $albumName = $photos[0]['user']['uname'] . _MD_EXTGALLERY_USERS_SUB_PHOTO_ALBUM; |
||
131 | $xoopsTpl->assign('xoops_pagetitle', $albumName); |
||
132 | $xoTheme->addMeta('meta', 'description', $albumName); |
||
133 | } |
||
134 | |||
135 | $jquery = $xoopsModuleConfig['enable_jquery']; |
||
136 | $xoopsTpl->assign('jquery', $jquery); |
||
137 | if (1 == $jquery && 'none' !== $ajaxeffect) { |
||
138 | $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js'); |
||
139 | switch ($ajaxeffect) { |
||
140 | case 'lightbox': |
||
141 | $xoTheme->addScript('browse.php?Frameworks/jquery/plugins/jquery.lightbox.js'); |
||
142 | $xoTheme->addStylesheet('browse.php?modules/system/css/lightbox.css'); |
||
143 | break; |
||
144 | |||
145 | case 'tooltip': |
||
146 | $xoTheme->addScript('browse.php?modules/extgallery/assets/js/tooltip/image.tooltip.js'); |
||
147 | $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/tooltip/image.tooltip.css'); |
||
148 | break; |
||
149 | |||
150 | case 'overlay': |
||
151 | $xoTheme->addScript('browse.php?modules/extgallery/assets/js/overlay/overlay.jquery.tools.min.js'); |
||
152 | $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/overlay/overlay.css'); |
||
153 | break; |
||
154 | |||
155 | case 'fancybox': |
||
156 | $xoTheme->addScript('browse.php?modules/extgallery/assets/js/fancybox/mousewheel.js'); |
||
157 | $xoTheme->addScript('browse.php?modules/extgallery/assets/js/fancybox/fancybox.pack.js'); |
||
158 | $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/fancybox/fancybox.css'); |
||
159 | break; |
||
160 | |||
161 | case 'prettyphoto': |
||
162 | $xoTheme->addScript('browse.php?modules/extgallery/assets/js/prettyphoto/jquery.prettyPhoto.js'); |
||
163 | $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/prettyphoto/prettyPhoto.css'); |
||
164 | break; |
||
165 | } |
||
166 | } |
||
167 | |||
168 | $rel = 'alternate'; |
||
169 | $attributes['rel'] = $rel; |
||
170 | $attributes['type'] = 'application/rss+xml'; |
||
171 | $attributes['title'] = _MD_EXTGALLERY_RSS; |
||
172 | $attributes['href'] = XOOPS_URL . '/modules/extgallery/public-rss.php'; |
||
0 ignored issues
–
show
|
|||
173 | $xoTheme->addMeta('link', $rel, $attributes); |
||
174 | $xoTheme->addStylesheet('modules/extgallery/assets/css/style.css'); |
||
175 | |||
176 | $lang = ['hits' => _MD_EXTGALLERY_HITS, 'comments' => _MD_EXTGALLERY_COMMENTS, 'albumName' => $albumName]; |
||
177 | $xoopsTpl->assign('lang', $lang); |
||
178 | |||
179 | $xoopsTpl->assign('enableExtra', $xoopsModuleConfig['display_extra_field']); |
||
180 | $xoopsTpl->assign('enableRating', $xoopsModuleConfig['enable_rating']); |
||
181 | $xoopsTpl->assign('nbColumn', $xoopsModuleConfig['nb_column']); |
||
182 | $xoopsTpl->assign('extgalleryName', $xoopsModule->getVar('name')); |
||
183 | $xoopsTpl->assign('disp_ph_title', $xoopsModuleConfig['disp_ph_title']); |
||
184 | |||
185 | $xoopsTpl->assign('extgalleryUID', $userId);//xoops - blueteen - tri de l'affichage |
||
186 | $xoopsTpl->assign('extgalleryStart', $start);//xoops -blueteen - tri de l'affichage |
||
187 | $xoopsTpl->assign('extgallerySortbyOrderby', _MD_EXTGALLERY_ORDERBY . convertorderbytrans($SortbyOrderby));//xoops - blueteen - tri de l'affichage |
||
188 | |||
189 | //DNPROSSI - VOLTAN - added preferences option |
||
190 | // enable_info, enable_submitter_lnk, enable_photo_hits |
||
191 | if ('album' === $xoopsModuleConfig['info_view'] || 'both' === $xoopsModuleConfig['info_view']) { |
||
192 | if ('user' === $xoopsModuleConfig['pubusr_info_view'] || 'both' === $xoopsModuleConfig['pubusr_info_view']) { |
||
193 | if (0 == $xoopsModuleConfig['enable_info']) { |
||
194 | $enable_info = $xoopsModuleConfig['enable_info']; |
||
195 | } else { |
||
196 | $enable_info = 1; |
||
197 | } |
||
198 | } else { |
||
199 | $enable_info = 1; |
||
200 | } |
||
201 | } else { |
||
202 | $enable_info = 1; |
||
203 | } |
||
204 | $xoopsTpl->assign('enable_info', $enable_info); |
||
205 | $xoopsTpl->assign('enable_photo_hits', $xoopsModuleConfig['enable_photo_hits']); |
||
206 | $xoopsTpl->assign('enable_submitter_lnk', $xoopsModuleConfig['enable_submitter_lnk']); |
||
207 | $xoopsTpl->assign('enable_show_comments', $xoopsModuleConfig['enable_show_comments']); |
||
208 | $xoopsTpl->assign('enable_date', $xoopsModuleConfig['enable_date']); |
||
209 | $xoopsTpl->assign('show_rss', $xoopsModuleConfig['show_rss']); |
||
210 | |||
211 | //for tooltip |
||
212 | $xoopsTpl->assign('album_tooltip_borderwidth', $xoopsModuleConfig['album_tooltip_borderwidth']); |
||
213 | $xoopsTpl->assign('album_tooltip_bordercolor', $xoopsModuleConfig['album_tooltip_bordercolor']); |
||
214 | $xoopsTpl->assign('album_tooltip_width', $xoopsModuleConfig['album_tooltip_width']); |
||
215 | |||
216 | //for overlay |
||
217 | $xoopsTpl->assign('album_overlay_bg', $xoopsModuleConfig['album_overlay_bg']); |
||
218 | $xoopsTpl->assign('album_overlay_width', $xoopsModuleConfig['album_overlay_width']); |
||
219 | $xoopsTpl->assign('album_overlay_height', $xoopsModuleConfig['album_overlay_height']); |
||
220 | |||
221 | //for fancybox |
||
222 | $xoopsTpl->assign('album_fancybox_color', $xoopsModuleConfig['album_fancybox_color']); |
||
223 | $xoopsTpl->assign('album_fancybox_opacity', $xoopsModuleConfig['album_fancybox_opacity']); |
||
224 | $xoopsTpl->assign('album_fancybox_tin', $xoopsModuleConfig['album_fancybox_tin']); |
||
225 | $xoopsTpl->assign('album_fancybox_tout', $xoopsModuleConfig['album_fancybox_tout']); |
||
226 | $xoopsTpl->assign('album_fancybox_title', $xoopsModuleConfig['album_fancybox_title']); |
||
227 | $xoopsTpl->assign('album_fancybox_showtype', $xoopsModuleConfig['album_fancybox_showtype']); |
||
228 | |||
229 | //for prettyphoto |
||
230 | $xoopsTpl->assign('album_prettyphoto_speed', $xoopsModuleConfig['album_prettyphoto_speed']); |
||
231 | $xoopsTpl->assign('album_prettyphoto_theme', $xoopsModuleConfig['album_prettyphoto_theme']); |
||
232 | $xoopsTpl->assign('album_prettyphoto_slidspeed', $xoopsModuleConfig['album_prettyphoto_slidspe']); |
||
233 | $xoopsTpl->assign('album_prettyphoto_autoplay', $xoopsModuleConfig['album_prettyphoto_autopla']); |
||
234 | |||
235 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
236 |
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.