/
avatar_gallery.inc.php
91 lines (73 loc) · 2.76 KB
/
avatar_gallery.inc.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
<?php
/**
* This file is part of "PCPIN Chat 6".
*
* "PCPIN Chat 6" is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* "PCPIN Chat 6" 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if (!is_object($session) || empty($session->_s_user_id)) {
header('Location: '.PCPIN_FORMLINK.'?'.md5(microtime()));
die();
}
if (empty($session->_conf_all['avatar_gallery'])) {
// Avatar gallery is disabled
die('access denied');
}
if (empty($profile_user_id) || $current_user->is_admin!=='y') {
$profile_user_id=$current_user->id;
}
// Get avatars
_pcpin_loadClass('avatar'); $avatar=new PCPIN_Avatar($session);
$avatars=$avatar->getGalleryAvatars();
// JS files
$_js_files[]='./js/avatar_gallery.js';
$_js_lng[]='avatar';
$_body_onload[]='initAvatarGallery('.addslashes(htmlspecialchars($profile_user_id)).')';
$_window_title.=' '.PCPIN_WINDOW_TITLE_SEPARATOR.' '.$l->g('avatar_gallery');
// Init template
_pcpin_loadClass('pcpintpl'); $tpl=new PcpinTpl();
$tpl->setBasedir('./tpl');
$tpl->readTemplatesFromFile('./avatar_gallery.tpl');
// Add language expressions to template
foreach ($tpl->tpl_vars_plain as $var) {
if (0===strpos($var, 'LNG_')) {
$var=strtolower($var);
$tpl->addGlobalVar($var, htmlspecialchars($l->g(substr($var, 4))));
}
}
// Add global vars to template
foreach ($global_tpl_vars as $key=>$val) {
$tpl->addGlobalVar($key, htmlspecialchars($val));
}
// Add avatars
$tpl->addVar('main', 'header_colspan', htmlspecialchars($session->_conf_all['gallery_avatars_per_row']));
while (count($avatars)%$session->_conf_all['gallery_avatars_per_row']>0) {
$avatars[]=array('id'=>0,
'binaryfile_id'=>0,
'width'=>0,
'height'=>0,
);
}
$col=0;
foreach ($avatars as $avatar_data) {
$tpl->addVars('avatar_gallery_col', array('id'=>htmlspecialchars($avatar_data['id']),
'binaryfile_id'=>htmlspecialchars($avatar_data['binaryfile_id']),
));
$tpl->parseTemplate('avatar_gallery_col', 'a');
if (++$col==$session->_conf_all['gallery_avatars_per_row']) {
$tpl->parseTemplate('avatar_gallery_row', 'a');
$tpl->clearTemplate('avatar_gallery_col');
$col=0;
}
}
?>