Completed
Push — master ( 72613d...069c91 )
by Michael
02:16
created

public-useralbum.php (3 issues)

Upgrade to new PHP Analysis Engine

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-useralbum.tpl';
23
include XOOPS_ROOT_PATH . '/header.php';
24
25
if (!isset($_GET['id'])) {
26
    $userId = 0;
27
} else {
28
    $userId = (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
$ajaxeffect = $xoopsModuleConfig['use_ajax_effects'];
37
$xoopsTpl->assign('use_ajax_effects', $ajaxeffect);
38
39
//HACK BLUETEEN TO SORT PHOTOS BY USERS
40
//photo_date - photo_title - photo_hits - photo_rating
41 View Code Duplication
if (isset($_GET['sortby'])
42
    && ($_GET['sortby'] === 'photo_date'
43
        || $_GET['sortby'] === 'photo_title'
44
        || $_GET['sortby'] === 'photo_hits'
45
        || $_GET['sortby'] === 'photo_rating')) {
46
    $sortby = $_GET['sortby'];
47
} else {
48
    $sortby = 'photo_date';
49
}
50
51
//ASC ou DESC
52 View Code Duplication
if (isset($_GET['orderby']) && ($_GET['orderby'] === 'DESC' || $_GET['orderby'] === 'ASC')) {
0 ignored issues
show
This code seems to be duplicated across your project.

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.

Loading history...
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 View Code Duplication
function convertorderbytrans($SortbyOrderby)
66
{
67
    $orderbyTrans = [];
68
    if ($SortbyOrderby === 'photo_date DESC') {
69
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DATEASC;
70
    }
71
    if ($SortbyOrderby === 'photo_date ASC') {
72
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DATEDESC;
73
    }
74
    if ($SortbyOrderby === 'photo_title ASC') {
75
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_TITREASC;
76
    }
77
    if ($SortbyOrderby === 'photo_title DESC') {
78
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_TITREDESC;
79
    }
80
    if ($SortbyOrderby === 'uid ASC') {
81
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DESIGNERASC;
82
    }
83
    if ($SortbyOrderby === 'uid DESC') {
84
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_DESIGNERDESC;
85
    }
86
    if ($SortbyOrderby === 'photo_hits DESC') {
87
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_HITSASC;
88
    }
89
    if ($SortbyOrderby === 'photo_hits ASC') {
90
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_HITSDESC;
91
    }
92
    if ($SortbyOrderby === 'photo_rating DESC') {
93
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_NOTEASC;
94
    }
95
    if ($SortbyOrderby === 'photo_rating ASC') {
96
        $orderbyTrans = _MD_EXTGALLERY_ORDERBY_NOTEDESC;
97
    }
98
99
    return $orderbyTrans;
100
}
101
102
/** @var ExtgalleryPublicPhotoHandler $photoHandler */
103
$photoHandler = xoops_getModuleHandler('publicphoto', 'extgallery');
104
105
$photos = $photoHandler->objectToArray($photoHandler->getUserAlbumPhotoPage($userId, $start, $sortby, $orderby), ['uid']);
106
$k      = $xoopsModuleConfig['nb_column'] - (count($photos) % $xoopsModuleConfig['nb_column']);
107 View Code Duplication
if ($k != $xoopsModuleConfig['nb_column']) {
108
    for ($i = 0; $i < $k; ++$i) {
109
        $photos[] = [];
110
    }
111
}
112
113
// HACK DATE BY MAGE : DISPLAY PUBLICATION DATE
114 View Code Duplication
foreach (array_keys($photos) as $i) {
115
    if (isset($photos[$i]['photo_date'])) {
116
        $photos[$i]['photo_date'] = date(_SHORTDATESTRING, $photos[$i]['photo_date']);
117
    }
118
}
119
// END HACK DATE BY MAGE : DISPLAY PUBLICATION DATE
120
121
$xoopsTpl->assign('photos', $photos);
122
123
$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
124
$xoopsTpl->assign('pageNav', $pageNav->renderNav());
125
126
$albumName = '';
127
if (count($photos) > 0) {
128
    $albumName = $photos[0]['user']['uname'] . _MD_EXTGALLERY_USERS_SUB_PHOTO_ALBUM;
129
    $xoopsTpl->assign('xoops_pagetitle', $albumName);
130
    $xoTheme->addMeta('meta', 'description', $albumName);
131
}
132
133
$jquery = $xoopsModuleConfig['enable_jquery'];
134
$xoopsTpl->assign('jquery', $jquery);
135 View Code Duplication
if ($jquery == 1 && $ajaxeffect !== 'none') {
0 ignored issues
show
This code seems to be duplicated across your project.

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.

Loading history...
136
    $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js');
137
    switch ($ajaxeffect) {
138
        case 'lightbox':
139
            $xoTheme->addScript('browse.php?Frameworks/jquery/plugins/jquery.lightbox.js');
140
            $xoTheme->addStylesheet('browse.php?modules/system/css/lightbox.css');
141
            break;
142
143
        case 'tooltip':
144
            $xoTheme->addScript('browse.php?modules/extgallery/assets/js/tooltip/image.tooltip.js');
145
            $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/tooltip/image.tooltip.css');
146
            break;
147
148
        case 'overlay':
149
            $xoTheme->addScript('browse.php?modules/extgallery/assets/js/overlay/overlay.jquery.tools.min.js');
150
            $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/overlay/overlay.css');
151
            break;
152
153
        case 'fancybox':
154
            $xoTheme->addScript('browse.php?modules/extgallery/assets/js/fancybox/mousewheel.js');
155
            $xoTheme->addScript('browse.php?modules/extgallery/assets/js/fancybox/fancybox.pack.js');
156
            $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/fancybox/fancybox.css');
157
            break;
158
159
        case 'prettyphoto':
160
            $xoTheme->addScript('browse.php?modules/extgallery/assets/js/prettyphoto/jquery.prettyPhoto.js');
161
            $xoTheme->addStylesheet('browse.php?modules/extgallery/assets/js/prettyphoto/prettyPhoto.css');
162
            break;
163
    }
164
}
165
166
$rel                 = 'alternate';
167
$attributes['rel']   = $rel;
168
$attributes['type']  = 'application/rss+xml';
169
$attributes['title'] = _MD_EXTGALLERY_RSS;
170
$attributes['href']  = XOOPS_URL . '/modules/extgallery/public-rss.php';
171
$xoTheme->addMeta('link', $rel, $attributes);
172
$xoTheme->addStylesheet('modules/extgallery/assets/css/style.css');
173
174
$lang = ['hits' => _MD_EXTGALLERY_HITS, 'comments' => _MD_EXTGALLERY_COMMENTS, 'albumName' => $albumName];
175
$xoopsTpl->assign('lang', $lang);
176
177
$xoopsTpl->assign('enableExtra', $xoopsModuleConfig['display_extra_field']);
178
$xoopsTpl->assign('enableRating', $xoopsModuleConfig['enable_rating']);
179
$xoopsTpl->assign('nbColumn', $xoopsModuleConfig['nb_column']);
180
$xoopsTpl->assign('extgalleryName', $xoopsModule->getVar('name'));
181
$xoopsTpl->assign('disp_ph_title', $xoopsModuleConfig['disp_ph_title']);
182
183
$xoopsTpl->assign('extgalleryUID', $userId);//xoops - blueteen - tri de l'affichage
184
$xoopsTpl->assign('extgalleryStart', $start);//xoops -blueteen - tri de l'affichage
185
$xoopsTpl->assign('extgallerySortbyOrderby', _MD_EXTGALLERY_ORDERBY . convertorderbytrans($SortbyOrderby));//xoops - blueteen - tri de l'affichage
186
187
//DNPROSSI - VOLTAN - added preferences option
188
//  enable_info, enable_submitter_lnk, enable_photo_hits
189 View Code Duplication
if ($xoopsModuleConfig['info_view'] === 'album' || $xoopsModuleConfig['info_view'] === 'both') {
0 ignored issues
show
This code seems to be duplicated across your project.

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.

Loading history...
190
    if ($xoopsModuleConfig['pubusr_info_view'] === 'user' || $xoopsModuleConfig['pubusr_info_view'] === 'both') {
191
        if ($xoopsModuleConfig['enable_info'] == 0) {
192
            $enable_info = $xoopsModuleConfig['enable_info'];
193
        } else {
194
            $enable_info = 1;
195
        }
196
    } else {
197
        $enable_info = 1;
198
    }
199
} else {
200
    $enable_info = 1;
201
}
202
$xoopsTpl->assign('enable_info', $enable_info);
203
$xoopsTpl->assign('enable_photo_hits', $xoopsModuleConfig['enable_photo_hits']);
204
$xoopsTpl->assign('enable_submitter_lnk', $xoopsModuleConfig['enable_submitter_lnk']);
205
$xoopsTpl->assign('enable_show_comments', $xoopsModuleConfig['enable_show_comments']);
206
$xoopsTpl->assign('enable_date', $xoopsModuleConfig['enable_date']);
207
$xoopsTpl->assign('show_rss', $xoopsModuleConfig['show_rss']);
208
209
//for tooltip
210
$xoopsTpl->assign('album_tooltip_borderwidth', $xoopsModuleConfig['album_tooltip_borderwidth']);
211
$xoopsTpl->assign('album_tooltip_bordercolor', $xoopsModuleConfig['album_tooltip_bordercolor']);
212
$xoopsTpl->assign('album_tooltip_width', $xoopsModuleConfig['album_tooltip_width']);
213
214
//for overlay
215
$xoopsTpl->assign('album_overlay_bg', $xoopsModuleConfig['album_overlay_bg']);
216
$xoopsTpl->assign('album_overlay_width', $xoopsModuleConfig['album_overlay_width']);
217
$xoopsTpl->assign('album_overlay_height', $xoopsModuleConfig['album_overlay_height']);
218
219
//for fancybox
220
$xoopsTpl->assign('album_fancybox_color', $xoopsModuleConfig['album_fancybox_color']);
221
$xoopsTpl->assign('album_fancybox_opacity', $xoopsModuleConfig['album_fancybox_opacity']);
222
$xoopsTpl->assign('album_fancybox_tin', $xoopsModuleConfig['album_fancybox_tin']);
223
$xoopsTpl->assign('album_fancybox_tout', $xoopsModuleConfig['album_fancybox_tout']);
224
$xoopsTpl->assign('album_fancybox_title', $xoopsModuleConfig['album_fancybox_title']);
225
$xoopsTpl->assign('album_fancybox_showtype', $xoopsModuleConfig['album_fancybox_showtype']);
226
227
//for prettyphoto
228
$xoopsTpl->assign('album_prettyphoto_speed', $xoopsModuleConfig['album_prettyphoto_speed']);
229
$xoopsTpl->assign('album_prettyphoto_theme', $xoopsModuleConfig['album_prettyphoto_theme']);
230
$xoopsTpl->assign('album_prettyphoto_slidspeed', $xoopsModuleConfig['album_prettyphoto_slidspe']);
231
$xoopsTpl->assign('album_prettyphoto_autoplay', $xoopsModuleConfig['album_prettyphoto_autopla']);
232
233
include XOOPS_ROOT_PATH . '/footer.php';
234