These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
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 | include __DIR__ . '/header.php'; |
||
19 | require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
20 | require_once XOOPS_ROOT_PATH . '/modules/extgallery/class/publicPerm.php'; |
||
21 | |||
22 | $GLOBALS['xoopsOption']['template_main'] = 'extgallery_public-album.tpl'; |
||
23 | //mbinclude XOOPS_ROOT_PATH . '/header.php'; |
||
24 | |||
25 | View Code Duplication | if (!isset($_GET['id'])) { |
|
0 ignored issues
–
show
|
|||
26 | $catId = 0; |
||
27 | } else { |
||
28 | $catId = (int)$_GET['id']; |
||
29 | } |
||
30 | View Code Duplication | if (!isset($_GET['start'])) { |
|
31 | $start = 0; |
||
32 | } else { |
||
33 | $start = (int)$_GET['start']; |
||
34 | } |
||
35 | |||
36 | // HACK BLUETEEN TO SORT PHOTO BY USERS |
||
37 | //photo_date - photo_title - photo_hits - photo_rating |
||
38 | View Code Duplication | if (isset($_GET['sortby']) |
|
39 | && ($_GET['sortby'] === 'photo_date' |
||
40 | || $_GET['sortby'] === 'photo_title' |
||
41 | || $_GET['sortby'] === 'photo_hits' |
||
42 | || $_GET['sortby'] === 'photo_rating')) { |
||
43 | $sortby = $_GET['sortby']; |
||
44 | } else { |
||
45 | $sortby = 'photo_date'; |
||
46 | } |
||
47 | |||
48 | //ASC ou DESC |
||
49 | View Code Duplication | if (isset($_GET['orderby']) && ($_GET['orderby'] === 'DESC' || $_GET['orderby'] === 'ASC')) { |
|
50 | $orderby = $_GET['orderby']; |
||
51 | } else { |
||
52 | $orderby = $GLOBALS['xoopsModuleConfig']['display_set_order']; |
||
53 | } |
||
54 | |||
55 | $SortbyOrderby = $sortby . ' ' . $orderby; |
||
56 | |||
57 | /** |
||
58 | * @param $SortbyOrderby |
||
59 | * |
||
60 | * @return array|string |
||
61 | */ |
||
62 | View Code Duplication | function convertorderbytrans($SortbyOrderby) |
|
63 | { |
||
64 | $orderbyTrans = []; |
||
65 | if ($SortbyOrderby === 'photo_date DESC') { |
||
66 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DATEASC; |
||
67 | } |
||
68 | if ($SortbyOrderby === 'photo_date ASC') { |
||
69 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DATEDESC; |
||
70 | } |
||
71 | if ($SortbyOrderby === 'photo_title ASC') { |
||
72 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_TITREASC; |
||
73 | } |
||
74 | if ($SortbyOrderby === 'photo_title DESC') { |
||
75 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_TITREDESC; |
||
76 | } |
||
77 | if ($SortbyOrderby === 'uid ASC') { |
||
78 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DESIGNERASC; |
||
79 | } |
||
80 | if ($SortbyOrderby === 'uid DESC') { |
||
81 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DESIGNERDESC; |
||
82 | } |
||
83 | if ($SortbyOrderby === 'photo_hits DESC') { |
||
84 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_HITSASC; |
||
85 | } |
||
86 | if ($SortbyOrderby === 'photo_hits ASC') { |
||
87 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_HITSDESC; |
||
88 | } |
||
89 | if ($SortbyOrderby === 'photo_rating DESC') { |
||
90 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_NOTEASC; |
||
91 | } |
||
92 | if ($SortbyOrderby === 'photo_rating ASC') { |
||
93 | $orderbyTrans = _MD_EXTGALLERY_ORDERBY_NOTEDESC; |
||
94 | } |
||
95 | |||
96 | return $orderbyTrans; |
||
97 | } |
||
98 | |||
99 | // Check the access permission |
||
100 | $permHandler = ExtgalleryPublicPermHandler::getInstance(); |
||
101 | if ((null === $GLOBALS['xoopsUser'] || !is_object($GLOBALS['xoopsUser'])) || !$permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_access', $catId)) { |
||
102 | redirect_header('index.php', 3, _NOPERM); |
||
103 | } |
||
104 | /** @var ExtgalleryPublicCatHandler $catHandler */ |
||
105 | $catHandler = xoops_getModuleHandler('publiccat', 'extgallery'); |
||
106 | /** @var ExtgalleryPublicPhotoHandler $photoHandler */ |
||
107 | $photoHandler = xoops_getModuleHandler('publicphoto', 'extgallery'); |
||
108 | |||
109 | $catObj = $catHandler->getCat($catId); |
||
110 | |||
111 | if (null === $catObj) { |
||
112 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
113 | exit; |
||
114 | } |
||
115 | |||
116 | $ajaxeffect = $xoopsModuleConfig['use_ajax_effects']; |
||
117 | $xoopsTpl->assign('use_ajax_effects', $ajaxeffect); |
||
118 | |||
119 | $cat = $catHandler->objectToArray($catObj); |
||
120 | $xoopsTpl->assign('cat', $cat); |
||
121 | |||
122 | $catPath = $photoHandler->objectToArray($catHandler->getPath($catId)); |
||
123 | $xoopsTpl->assign('catPath', $catPath); |
||
124 | |||
125 | $photos = $photoHandler->objectToArray($photoHandler->getAlbumPhotoPage($catId, $start, $sortby, $orderby), ['uid']); //xoops - blueteen - tri de l'affichage |
||
126 | |||
127 | // Plugin traitement |
||
128 | $plugin = xoops_getModuleHandler('plugin', 'extgallery'); |
||
129 | $nbPhoto = count($photos); |
||
130 | for ($i = 0; $i < $nbPhoto; ++$i) { |
||
131 | $params = ['catId' => $catId, 'photoId' => $photos[$i]['photo_id'], 'link' => []]; |
||
132 | $plugin->triggerEvent('photoAlbumLink', $params); |
||
133 | $photos[$i]['link'] = $params['link']; |
||
134 | } |
||
135 | |||
136 | $k = $xoopsModuleConfig['nb_column'] - (count($photos) % $xoopsModuleConfig['nb_column']); |
||
137 | View Code Duplication | if ($k != $xoopsModuleConfig['nb_column']) { |
|
138 | for ($i = 0; $i < $k; ++$i) { |
||
139 | $photos[] = []; |
||
140 | } |
||
141 | } |
||
142 | |||
143 | // HACK DATE BY MAGE : DISPLAY PUBLICATION DATE |
||
144 | View Code Duplication | foreach (array_keys($photos) as $i) { |
|
145 | if (isset($photos[$i]['photo_date'])) { |
||
146 | $photos[$i]['photo_date'] = date(_SHORTDATESTRING, $photos[$i]['photo_date']); |
||
147 | } |
||
148 | } |
||
149 | // END HACK DATE BY MAGE : DISPLAY PUBLICATION DATE |
||
150 | |||
151 | $xoopsTpl->assign('photos', $photos); |
||
152 | /** @var xos_opal_Theme $xoTheme */ |
||
153 | |||
154 | $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 |
||
155 | $xoopsTpl->assign('pageNav', $pageNav->renderNav()); |
||
156 | View Code Duplication | if (isset($catObj)) { |
|
157 | $xoopsTpl->assign('xoops_pagetitle', $catObj->getVar('cat_name')); |
||
158 | $xoTheme->addMeta('meta', 'description', $catObj->getVar('cat_desc')); |
||
159 | } |
||
160 | |||
161 | $jquery = $xoopsModuleConfig['enable_jquery']; |
||
162 | $xoopsTpl->assign('jquery', $jquery); |
||
163 | View Code Duplication | if ($jquery == 1 && $ajaxeffect !== 'none') { |
|
164 | $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js'); |
||
165 | switch ($ajaxeffect) { |
||
166 | case 'lightbox': |
||
167 | $xoTheme->addScript('browse.php?Frameworks/jquery/plugins/jquery.lightbox.js'); |
||
168 | $xoTheme->addStylesheet('browse.php?modules/system/css/lightbox.css'); |
||
169 | break; |
||
170 | |||
171 | case 'tooltip': |
||
172 | $xoTheme->addScript('browse.php?modules/extgallery/assets/js/tooltip/image.tooltip.js'); |
||
173 | $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/tooltip/image.tooltip.css'); |
||
174 | break; |
||
175 | |||
176 | case 'overlay': |
||
177 | $xoTheme->addScript('browse.php?modules/extgallery/assets/js/overlay/overlay.jquery.tools.min.js'); |
||
178 | $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/overlay/overlay.css'); |
||
179 | break; |
||
180 | |||
181 | case 'fancybox': |
||
182 | $xoTheme->addScript('browse.php?modules/extgallery/assets/js/fancybox/mousewheel.js'); |
||
183 | $xoTheme->addScript('browse.php?modules/extgallery/assets/js/fancybox/fancybox.pack.js'); |
||
184 | $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/fancybox/fancybox.css'); |
||
185 | break; |
||
186 | |||
187 | case 'prettyphoto': |
||
188 | $xoTheme->addScript('browse.php?modules/extgallery/assets/js/prettyphoto/jquery.prettyPhoto.js'); |
||
189 | $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/prettyphoto/prettyPhoto.css'); |
||
190 | break; |
||
191 | } |
||
192 | } |
||
193 | |||
194 | $rel = 'alternate'; |
||
195 | $attributes['rel'] = $rel; |
||
196 | $attributes['type'] = 'application/rss+xml'; |
||
197 | $attributes['title'] = _MD_EXTGALLERY_RSS; |
||
198 | $attributes['href'] = XOOPS_URL . '/modules/extgallery/public-rss.php'; |
||
199 | $xoTheme->addMeta('link', $rel, $attributes); |
||
200 | $xoTheme->addStylesheet('modules/extgallery/assets/css/style.css'); |
||
201 | |||
202 | $lang = [ |
||
203 | 'hits' => _MD_EXTGALLERY_HITS, |
||
204 | 'comments' => _MD_EXTGALLERY_COMMENTS, |
||
205 | 'rate_score' => _MD_EXTGALLERY_RATING_SCORE |
||
206 | ]; |
||
207 | $xoopsTpl->assign('lang', $lang); |
||
208 | |||
209 | $xoopsTpl->assign('enableExtra', $xoopsModuleConfig['display_extra_field']); |
||
210 | $xoopsTpl->assign('enableRating', $xoopsModuleConfig['enable_rating']); |
||
211 | $xoopsTpl->assign('nbColumn', $xoopsModuleConfig['nb_column']); |
||
212 | $xoopsTpl->assign('extgalleryName', $xoopsModule->getVar('name')); |
||
213 | $xoopsTpl->assign('disp_ph_title', $xoopsModuleConfig['disp_ph_title']); |
||
214 | |||
215 | $xoopsTpl->assign('extgalleryID', $catId); //xoops - blueteen - tri de l'affichage |
||
216 | $xoopsTpl->assign('extgalleryStart', $start); //xoops -blueteen - tri de l'affichage |
||
217 | $xoopsTpl->assign('extgallerySortbyOrderby', _MD_EXTGALLERY_ORDERBY . convertorderbytrans($SortbyOrderby)); //xoops - blueteen - tri de l'affichage |
||
218 | |||
219 | //DNPROSSI - VOLTAN - added preferences option |
||
220 | // enable_info, enable_submitter_lnk, enable_photo_hits |
||
221 | View Code Duplication | if ($xoopsModuleConfig['info_view'] === 'album' || $xoopsModuleConfig['info_view'] === 'both') { |
|
222 | if ($xoopsModuleConfig['pubusr_info_view'] === 'public' || $xoopsModuleConfig['pubusr_info_view'] === 'both') { |
||
223 | if ($xoopsModuleConfig['enable_info'] == 0) { |
||
224 | $enable_info = $xoopsModuleConfig['enable_info']; |
||
225 | } else { |
||
226 | $enable_info = 1; |
||
227 | } |
||
228 | } else { |
||
229 | $enable_info = 1; |
||
230 | } |
||
231 | } else { |
||
232 | $enable_info = 1; |
||
233 | } |
||
234 | $xoopsTpl->assign('enable_info', $enable_info); |
||
235 | $xoopsTpl->assign('enable_photo_hits', $xoopsModuleConfig['enable_photo_hits']); |
||
236 | $xoopsTpl->assign('enable_submitter_lnk', $xoopsModuleConfig['enable_submitter_lnk']); |
||
237 | $xoopsTpl->assign('enable_show_comments', $xoopsModuleConfig['enable_show_comments']); |
||
238 | $xoopsTpl->assign('enable_date', $xoopsModuleConfig['enable_date']); |
||
239 | $xoopsTpl->assign('show_rss', $xoopsModuleConfig['show_rss']); |
||
240 | |||
241 | //for tooltip |
||
242 | $xoopsTpl->assign('album_tooltip_borderwidth', $xoopsModuleConfig['album_tooltip_borderwidth']); |
||
243 | $xoopsTpl->assign('album_tooltip_bordercolor', $xoopsModuleConfig['album_tooltip_bordercolor']); |
||
244 | $xoopsTpl->assign('album_tooltip_width', $xoopsModuleConfig['album_tooltip_width']); |
||
245 | |||
246 | //for overlay |
||
247 | $xoopsTpl->assign('album_overlay_bg', $xoopsModuleConfig['album_overlay_bg']); |
||
248 | $xoopsTpl->assign('album_overlay_width', $xoopsModuleConfig['album_overlay_width']); |
||
249 | $xoopsTpl->assign('album_overlay_height', $xoopsModuleConfig['album_overlay_height']); |
||
250 | |||
251 | //for fancybox |
||
252 | $xoopsTpl->assign('album_fancybox_color', $xoopsModuleConfig['album_fancybox_color']); |
||
253 | $xoopsTpl->assign('album_fancybox_opacity', $xoopsModuleConfig['album_fancybox_opacity']); |
||
254 | $xoopsTpl->assign('album_fancybox_tin', $xoopsModuleConfig['album_fancybox_tin']); |
||
255 | $xoopsTpl->assign('album_fancybox_tout', $xoopsModuleConfig['album_fancybox_tout']); |
||
256 | $xoopsTpl->assign('album_fancybox_title', $xoopsModuleConfig['album_fancybox_title']); |
||
257 | $xoopsTpl->assign('album_fancybox_showtype', $xoopsModuleConfig['album_fancybox_showtype']); |
||
258 | |||
259 | //for prettyphoto |
||
260 | $xoopsTpl->assign('album_prettyphoto_speed', $xoopsModuleConfig['album_prettyphoto_speed']); |
||
261 | $xoopsTpl->assign('album_prettyphoto_theme', $xoopsModuleConfig['album_prettyphoto_theme']); |
||
262 | $xoopsTpl->assign('album_prettyphoto_slidspeed', $xoopsModuleConfig['album_prettyphoto_slidspe']); |
||
263 | $xoopsTpl->assign('album_prettyphoto_autoplay', $xoopsModuleConfig['album_prettyphoto_autopla']); |
||
264 | |||
265 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
266 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.