|
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 Xmf\Request; |
|
|
|
|
|
|
20
|
|
|
use XoopsModules\Suico\{ |
|
21
|
|
|
PhotosController |
|
22
|
|
|
}; |
|
23
|
|
|
|
|
24
|
|
|
const COUNTPHOTOS = 'countPhotos'; |
|
25
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'suico_album.tpl'; |
|
26
|
|
|
require __DIR__ . '/header.php'; |
|
27
|
|
|
$controller = new PhotosController($xoopsDB, $xoopsUser); |
|
28
|
|
|
/** |
|
29
|
|
|
* Fetching numbers of groups friends videos pictures etc... |
|
30
|
|
|
*/ |
|
31
|
|
|
$nbSections = $controller->getNumbersSections(); |
|
32
|
|
|
/** |
|
33
|
|
|
* This variable define the beggining of the navigation must b |
|
34
|
|
|
* setted here so all calls to database will take this into account |
|
35
|
|
|
*/ |
|
36
|
|
|
$start = Request::getInt( |
|
37
|
|
|
'start', |
|
38
|
|
|
0, |
|
39
|
|
|
'GET' |
|
40
|
|
|
); |
|
41
|
|
|
/** |
|
42
|
|
|
* Fetching numbers of groups friends videos pictures etc... |
|
43
|
|
|
*/ |
|
44
|
|
|
$nbSections = $controller->getNumbersSections(); |
|
45
|
|
|
/** |
|
46
|
|
|
* Filter for search pictures in database |
|
47
|
|
|
*/ |
|
48
|
|
|
if (1 === $controller->isOwner) { |
|
49
|
|
|
$criteriaUid = new Criteria('uid_owner', $controller->uidOwner); |
|
50
|
|
|
} else { |
|
51
|
|
|
$criteria_private = new Criteria('private', 0); |
|
52
|
|
|
$criteriaUid2 = new Criteria('uid_owner', (int)$controller->uidOwner); |
|
53
|
|
|
$criteriaUid = new CriteriaCompo($criteriaUid2); |
|
54
|
|
|
$criteriaUid->add($criteria_private); |
|
55
|
|
|
} |
|
56
|
|
|
$criteriaUid->setLimit($helper->getConfig('picturesperpage')); |
|
57
|
|
|
$criteriaUid->setStart($start); |
|
58
|
|
|
if (1 === $helper->getConfig('images_order')) { |
|
59
|
|
|
$criteriaUid->setOrder('DESC'); |
|
60
|
|
|
$criteriaUid->setSort('image_id'); |
|
61
|
|
|
} |
|
62
|
|
|
/** |
|
63
|
|
|
* Fetch pictures from factory |
|
64
|
|
|
*/ |
|
65
|
|
|
$pictures_object_array = $controller->albumFactory->getObjects($criteriaUid); |
|
66
|
|
|
$criteriaUid->setLimit(0); |
|
67
|
|
|
$criteriaUid->setStart(0); |
|
68
|
|
|
/** |
|
69
|
|
|
* If there is no pictures in the album show in template lang_nopicyet |
|
70
|
|
|
*/ |
|
71
|
|
|
if (isset($nbSections[COUNTPHOTOS]) && 0 === $nbSections[COUNTPHOTOS]) { |
|
72
|
|
|
$nopicturesyet = _MD_SUICO_NOTHINGYET; |
|
73
|
|
|
$xoopsTpl->assign('lang_nopicyet', $nopicturesyet); |
|
74
|
|
|
} else { |
|
75
|
|
|
/** |
|
76
|
|
|
* Lets populate an array with the data from the pictures |
|
77
|
|
|
*/ |
|
78
|
|
|
$i = 0; |
|
79
|
|
|
foreach ($pictures_object_array as $picture) { |
|
80
|
|
|
$pictures_array[$i]['filename'] = $picture->getVar('filename', 's'); |
|
81
|
|
|
$pictures_array[$i]['title'] = $picture->getVar('title', 's'); |
|
82
|
|
|
$pictures_array[$i]['caption'] = $picture->getVar('caption', 's'); |
|
83
|
|
|
$pictures_array[$i]['image_id'] = $picture->getVar('image_id', 's'); |
|
84
|
|
|
$pictures_array[$i]['private'] = $picture->getVar('private', 's'); |
|
85
|
|
|
$pictures_array[$i]['date_created'] = formatTimestamp($picture->getVar('date_created', 's')); |
|
86
|
|
|
$pictures_array[$i]['date_updated'] = formatTimestamp($picture->getVar('date_updated', 's')); |
|
87
|
|
|
$xoopsTpl->assign('pics_array', $pictures_array); |
|
88
|
|
|
$i++; |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
/** |
|
92
|
|
|
* Show the form if it is the owner and he can still upload pictures |
|
93
|
|
|
*/ |
|
94
|
|
|
$maxfilebytes = $helper->getConfig('maxfilesize'); |
|
95
|
|
|
if (!empty($xoopsUser)) { |
|
96
|
|
|
if ((isset($nbSections[COUNTPHOTOS]) && 1 === $controller->isOwner) && $helper->getConfig('countPicture') > $nbSections[COUNTPHOTOS]) { |
|
97
|
|
|
// $maxfilebytes = $helper->getConfig('maxfilesize'); |
|
98
|
|
|
$xoopsTpl->assign('maxfilebytes', $maxfilebytes); |
|
99
|
|
|
$xoopsTpl->assign('showForm', '1'); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
/** |
|
103
|
|
|
* Let's get the user name of the owner of the album |
|
104
|
|
|
*/ |
|
105
|
|
|
$owner = new \XoopsUser($controller->uidOwner); |
|
106
|
|
|
$identifier = $owner->getVar('uname'); |
|
107
|
|
|
$avatar = $owner->getVar('user_avatar'); |
|
108
|
|
|
/** |
|
109
|
|
|
* Creating the navigation bar if you have a lot of friends |
|
110
|
|
|
*/ |
|
111
|
|
|
$countPhotos = $nbSections[COUNTPHOTOS] ?? 0; |
|
112
|
|
|
$navigationBar = new \XoopsPageNav( |
|
113
|
|
|
$countPhotos, |
|
114
|
|
|
$helper->getConfig('picturesperpage'), |
|
115
|
|
|
$start, |
|
116
|
|
|
'start', |
|
117
|
|
|
'uid=' . (int)$controller->uidOwner |
|
118
|
|
|
); |
|
119
|
|
|
$navegacao = $navigationBar->renderImageNav(2); |
|
120
|
|
|
//form |
|
121
|
|
|
$xoopsTpl->assign('lang_formtitle', _MD_SUICO_SUBMIT_PIC_TITLE); |
|
122
|
|
|
$xoopsTpl->assign('lang_selectphoto', _MD_SUICO_SELECT_PHOTO); |
|
123
|
|
|
$xoopsTpl->assign('lang_phototitle', _MD_SUICO_PHOTOTITLE); |
|
124
|
|
|
$xoopsTpl->assign('lang_caption', _MD_SUICO_CAPTION); |
|
125
|
|
|
$xoopsTpl->assign('lang_uploadpicture', _MD_SUICO_UPLOADPICTURE); |
|
126
|
|
|
$xoopsTpl->assign('lang_youcanupload', sprintf(_MD_SUICO_YOU_CAN_UPLOAD, $maxfilebytes / 1024)); |
|
127
|
|
|
//$xoopsTpl->assign('path_suico_uploads',$helper->getConfig('link_path_upload')); |
|
128
|
|
|
$xoopsTpl->assign( |
|
129
|
|
|
'lang_max_countPicture', |
|
130
|
|
|
sprintf(_MD_SUICO_YOUCANHAVE, $helper->getConfig('countPicture')) |
|
131
|
|
|
); |
|
132
|
|
|
$xoopsTpl->assign('lang_delete', _MD_SUICO_DELETE); |
|
133
|
|
|
$xoopsTpl->assign('lang_editpicture', _MD_SUICO_EDIT_PICTURE); |
|
134
|
|
|
$xoopsTpl->assign('lang_countPicture', sprintf(_MD_SUICO_YOUHAVE, ($nbSections[COUNTPHOTOS] ?? ''))); |
|
135
|
|
|
$xoopsTpl->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML()); |
|
136
|
|
|
$xoopsTpl->assign('navegacao', $navegacao); |
|
137
|
|
|
$xoopsTpl->assign('lang_avatarchange', _MD_SUICO_AVATARCHANGE); |
|
138
|
|
|
$xoopsTpl->assign('avatar_url', $avatar); |
|
139
|
|
|
$xoopsTpl->assign('lang_setprivate', _MD_SUICO_PRIVATIZE); |
|
140
|
|
|
$xoopsTpl->assign('lang_unsetprivate', _MD_SUICO_UNPRIVATIZE); |
|
141
|
|
|
$xoopsTpl->assign('lang_privatephoto', _MD_SUICO_PRIVATEPHOTO); |
|
142
|
|
|
$xoopsTpl->assign('lang_mysection', _MD_SUICO_MYPHOTOS); |
|
143
|
|
|
$xoopsTpl->assign('section_name', _MD_SUICO_PHOTOS); |
|
144
|
|
|
require XOOPS_ROOT_PATH . '/include/comment_view.php'; |
|
145
|
|
|
require __DIR__ . '/footer.php'; |
|
146
|
|
|
require \dirname(__DIR__, 2) . '/footer.php'; |
|
147
|
|
|
|
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: