-
Notifications
You must be signed in to change notification settings - Fork 4
/
album.php
145 lines (140 loc) · 5.64 KB
/
album.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
declare(strict_types=1);
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* @category Module
* @package suico
* @copyright {@link https://xoops.org/ XOOPS Project}
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org>
*/
use Xmf\Request;
use XoopsModules\Suico\{
PhotosController
};
const COUNTPHOTOS = 'countPhotos';
$GLOBALS['xoopsOption']['template_main'] = 'suico_album.tpl';
require __DIR__ . '/header.php';
$controller = new PhotosController($xoopsDB, $xoopsUser);
/**
* Fetching numbers of groups friends videos pictures etc...
*/
$nbSections = $controller->getNumbersSections();
/**
* This variable define the beggining of the navigation must b
* setted here so all calls to database will take this into account
*/
$start = Request::getInt(
'start',
0,
'GET'
);
/**
* Fetching numbers of groups friends videos pictures etc...
*/
$nbSections = $controller->getNumbersSections();
/**
* Filter for search pictures in database
*/
if (1 === $controller->isOwner) {
$criteriaUid = new Criteria('uid_owner', $controller->uidOwner);
} else {
$criteria_private = new Criteria('private', 0);
$criteriaUid2 = new Criteria('uid_owner', (int)$controller->uidOwner);
$criteriaUid = new CriteriaCompo($criteriaUid2);
$criteriaUid->add($criteria_private);
}
$criteriaUid->setLimit($helper->getConfig('picturesperpage'));
$criteriaUid->setStart($start);
if (1 === $helper->getConfig('images_order')) {
$criteriaUid->setOrder('DESC');
$criteriaUid->setSort('image_id');
}
/**
* Fetch pictures from factory
*/
$pictures_object_array = $controller->albumFactory->getObjects($criteriaUid);
$criteriaUid->setLimit(0);
$criteriaUid->setStart(0);
/**
* If there is no pictures in the album show in template lang_nopicyet
*/
if (isset($nbSections[COUNTPHOTOS]) && 0 === $nbSections[COUNTPHOTOS]) {
$nopicturesyet = _MD_SUICO_NOTHINGYET;
$xoopsTpl->assign('lang_nopicyet', $nopicturesyet);
} else {
/**
* Lets populate an array with the data from the pictures
*/
$i = 0;
foreach ($pictures_object_array as $picture) {
$pictures_array[$i]['filename'] = $picture->getVar('filename', 's');
$pictures_array[$i]['title'] = $picture->getVar('title', 's');
$pictures_array[$i]['caption'] = $picture->getVar('caption', 's');
$pictures_array[$i]['image_id'] = $picture->getVar('image_id', 's');
$pictures_array[$i]['private'] = $picture->getVar('private', 's');
$pictures_array[$i]['date_created'] = formatTimestamp($picture->getVar('date_created', 's'));
$pictures_array[$i]['date_updated'] = formatTimestamp($picture->getVar('date_updated', 's'));
$xoopsTpl->assign('pics_array', $pictures_array);
$i++;
}
}
/**
* Show the form if it is the owner and he can still upload pictures
*/
$maxfilebytes = $helper->getConfig('maxfilesize');
if (!empty($xoopsUser)) {
if ((isset($nbSections[COUNTPHOTOS]) && 1 === $controller->isOwner) && $helper->getConfig('countPicture') > $nbSections[COUNTPHOTOS]) {
// $maxfilebytes = $helper->getConfig('maxfilesize');
$xoopsTpl->assign('maxfilebytes', $maxfilebytes);
$xoopsTpl->assign('showForm', '1');
}
}
/**
* Let's get the user name of the owner of the album
*/
$owner = new \XoopsUser($controller->uidOwner);
$identifier = $owner->getVar('uname');
$avatar = $owner->getVar('user_avatar');
/**
* Creating the navigation bar if you have a lot of friends
*/
$countPhotos = $nbSections[COUNTPHOTOS] ?? 0;
$navigationBar = new \XoopsPageNav(
$countPhotos, $helper->getConfig('picturesperpage'), $start, 'start', 'uid=' . (int)$controller->uidOwner
);
$navegacao = $navigationBar->renderImageNav(2);
//form
$xoopsTpl->assign('lang_formtitle', _MD_SUICO_SUBMIT_PIC_TITLE);
$xoopsTpl->assign('lang_selectphoto', _MD_SUICO_SELECT_PHOTO);
$xoopsTpl->assign('lang_phototitle', _MD_SUICO_PHOTOTITLE);
$xoopsTpl->assign('lang_caption', _MD_SUICO_CAPTION);
$xoopsTpl->assign('lang_uploadpicture', _MD_SUICO_UPLOADPICTURE);
$xoopsTpl->assign('lang_youcanupload', sprintf(_MD_SUICO_YOU_CAN_UPLOAD, $maxfilebytes / 1024));
//$xoopsTpl->assign('path_suico_uploads',$helper->getConfig('link_path_upload'));
$xoopsTpl->assign(
'lang_max_countPicture',
sprintf(_MD_SUICO_YOUCANHAVE, $helper->getConfig('countPicture'))
);
$xoopsTpl->assign('lang_delete', _MD_SUICO_DELETE);
$xoopsTpl->assign('lang_editpicture', _MD_SUICO_EDIT_PICTURE);
$xoopsTpl->assign('lang_countPicture', sprintf(_MD_SUICO_YOUHAVE, ($nbSections[COUNTPHOTOS] ?? '')));
$xoopsTpl->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML());
$xoopsTpl->assign('navegacao', $navegacao);
$xoopsTpl->assign('lang_avatarchange', _MD_SUICO_AVATARCHANGE);
$xoopsTpl->assign('avatar_url', $avatar);
$xoopsTpl->assign('lang_setprivate', _MD_SUICO_PRIVATIZE);
$xoopsTpl->assign('lang_unsetprivate', _MD_SUICO_UNPRIVATIZE);
$xoopsTpl->assign('lang_privatephoto', _MD_SUICO_PRIVATEPHOTO);
$xoopsTpl->assign('lang_mysection', _MD_SUICO_MYPHOTOS);
$xoopsTpl->assign('section_name', _MD_SUICO_PHOTOS);
require XOOPS_ROOT_PATH . '/include/comment_view.php';
require __DIR__ . '/footer.php';
require dirname(__DIR__, 2) . '/footer.php';