|
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
|
|
|
This program is distributed in the hope that it will be useful, |
|
7
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
8
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @category Module |
|
13
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
14
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
15
|
|
|
* @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org> |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
use Xmf\Request; |
|
19
|
|
|
use XoopsModules\Suico\{ |
|
20
|
|
|
AudioController |
|
21
|
|
|
}; |
|
22
|
|
|
|
|
23
|
|
|
const COUNTAUDIOS = 'countAudios'; |
|
24
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'suico_audios.tpl'; |
|
25
|
|
|
require __DIR__ . '/header.php'; |
|
26
|
|
|
$controller = new AudioController($xoopsDB, $xoopsUser); |
|
27
|
|
|
/** |
|
28
|
|
|
* Fetching numbers of groups friends videos pictures etc... |
|
29
|
|
|
*/ |
|
30
|
|
|
$nbSections = $controller->getNumbersSections(); |
|
31
|
|
|
$start = Request::getInt('start', 0, 'GET'); |
|
32
|
|
|
/** |
|
33
|
|
|
* Fetching numbers of groups friends videos pictures etc... |
|
34
|
|
|
*/ |
|
35
|
|
|
$nbSections = $controller->getNumbersSections(); |
|
36
|
|
|
/** |
|
37
|
|
|
* Criteria for Audio |
|
38
|
|
|
*/ |
|
39
|
|
|
$criteriaUidAudio = new Criteria('uid_owner', $controller->uidOwner); |
|
40
|
|
|
$criteriaUidAudio->setStart($start); |
|
41
|
|
|
$criteriaUidAudio->setLimit($helper->getConfig('audiosperpage')); |
|
42
|
|
|
/** |
|
43
|
|
|
* Get all audios of this user and assign them to template |
|
44
|
|
|
*/ |
|
45
|
|
|
$audiosArray = []; |
|
46
|
|
|
$audios = $controller->getAudio($criteriaUidAudio); |
|
47
|
|
|
/** |
|
48
|
|
|
* If there is no audio files show in template lang_noaudioyet |
|
49
|
|
|
*/ |
|
50
|
|
|
if (isset($nbSections[COUNTAUDIOS]) && 0 === $nbSections[COUNTAUDIOS]) { |
|
51
|
|
|
$lang_noaudioyet = _MD_SUICO_NOTHINGYET; |
|
52
|
|
|
$xoopsTpl->assign('lang_nopicyet', $lang_noaudioyet); |
|
53
|
|
|
// echo '<script>alert("Please add some audio files here")</script>'; |
|
54
|
|
|
} else { |
|
55
|
|
|
/** |
|
56
|
|
|
* Lets populate an array with the data from the pictures |
|
57
|
|
|
*/ |
|
58
|
|
|
$i = 0; |
|
59
|
|
|
foreach ($audios as $audio) { |
|
60
|
|
|
$audiosArray[$i]['audio_id'] = $audio->getVar('audio_id', 's'); |
|
61
|
|
|
$audiosArray[$i]['title'] = $audio->getVar('title', 's'); |
|
62
|
|
|
$audiosArray[$i]['author'] = $audio->getVar('author', 's'); |
|
63
|
|
|
$audiosArray[$i]['description'] = $audio->getVar('description', 's'); |
|
64
|
|
|
$audiosArray[$i]['filename'] = $audio->getVar('filename', 's'); |
|
65
|
|
|
$audiosArray[$i]['uid_owner'] = $audio->getVar('uid_owner', 's'); |
|
66
|
|
|
$audiosArray[$i]['date_created'] = formatTimestamp($audio->getVar('date_created', 's')); |
|
67
|
|
|
$audiosArray[$i]['date_updated'] = formatTimestamp($audio->getVar('date_updated', 's')); |
|
68
|
|
|
$xoopsTpl->assign('audios', $audiosArray); |
|
69
|
|
|
$i++; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
$xoopsTpl->assign('audios', $audios); |
|
73
|
|
|
$countAudio = $nbSections[COUNTAUDIOS] ?? 0; |
|
74
|
|
|
|
|
75
|
|
|
try { |
|
76
|
|
|
$audiosArray = $controller->assignAudioContent($countAudio, $audios); |
|
77
|
|
|
} catch (\RuntimeException $e) { |
|
78
|
|
|
echo 'Caught exception: ', $e->getMessage(), "\n"; |
|
79
|
|
|
} |
|
80
|
|
|
if (is_array($audiosArray) && count($audiosArray) > 0) { |
|
|
|
|
|
|
81
|
|
|
$xoopsTpl->assign('audios', $audiosArray); |
|
82
|
|
|
$audio_list = []; |
|
83
|
|
|
foreach ($audiosArray as $audio_item) { |
|
84
|
|
|
$audio_list[] = XOOPS_UPLOAD_URL . '/suico/audio/' . $audio_item['filename']; // . ' | '; |
|
85
|
|
|
} |
|
86
|
|
|
//$audio_list = substr($audio_list,-2); |
|
87
|
|
|
$xoopsTpl->assign('audio_list', $audio_list); |
|
88
|
|
|
} else { |
|
89
|
|
|
$xoopsTpl->assign('lang_noaudioyet', _MD_SUICO_NOAUDIOYET); |
|
90
|
|
|
} |
|
91
|
|
|
$pageNav = ''; |
|
92
|
|
|
if (isset($nbSections[COUNTAUDIOS]) && $nbSections[COUNTAUDIOS] > 0) { |
|
93
|
|
|
$pageNav = $controller->getAudiosNavBar($nbSections[COUNTAUDIOS], $helper->getConfig('audiosperpage'), $start, 2); |
|
94
|
|
|
} |
|
95
|
|
|
$xoTheme->addScript('https://unpkg.com/wavesurfer.js'); |
|
96
|
|
|
//meta language names |
|
97
|
|
|
$xoopsTpl->assign('lang_meta', _MD_SUICO_META); |
|
98
|
|
|
$xoopsTpl->assign('lang_title', _MD_SUICO_META_TITLE); |
|
99
|
|
|
$xoopsTpl->assign('lang_album', _MD_SUICO_META_ALBUM); |
|
100
|
|
|
$xoopsTpl->assign('lang_artist', _MD_SUICO_META_ARTIST); |
|
101
|
|
|
$xoopsTpl->assign('lang_year', _MD_SUICO_META_YEAR); |
|
102
|
|
|
//form actions |
|
103
|
|
|
$xoopsTpl->assign('lang_delete', _MD_SUICO_DELETE); |
|
104
|
|
|
$xoopsTpl->assign('lang_editaudio', _MD_SUICO_EDIT_AUDIO); |
|
105
|
|
|
$xoopsTpl->assign('lang_featurethisvideo', _MD_SUICO_FEATURETHISVIDEO); |
|
106
|
|
|
//Form Submit |
|
107
|
|
|
$xoopsTpl->assign('lang_selectaudio', _MD_SUICO_AUDIO_SELECT); |
|
108
|
|
|
$xoopsTpl->assign('lang_authorLabel', _MD_SUICO_AUDIO_AUTHOR); |
|
109
|
|
|
$xoopsTpl->assign('lang_titleLabel', _MD_SUICO_AUDIO_TITLE); |
|
110
|
|
|
$xoopsTpl->assign('lang_submitValue', _MD_SUICO_AUDIO_SUBMIT); |
|
111
|
|
|
$xoopsTpl->assign('lang_addaudios', _MD_SUICO_AUDIO_ADD); |
|
112
|
|
|
$xoopsTpl->assign('width', $helper->getConfig('width_tube')); |
|
113
|
|
|
$xoopsTpl->assign('height', $helper->getConfig('height_tube')); |
|
114
|
|
|
$xoopsTpl->assign('player_from_list', _MD_SUICO_PLAYER); |
|
115
|
|
|
$xoopsTpl->assign('lang_audiohelp', sprintf(_MD_SUICO_AUDIO_ADD_HELP, $helper->getConfig('maxfilesize'))); |
|
116
|
|
|
$xoopsTpl->assign('max_youcanupload', $helper->getConfig('maxfilesize')); |
|
117
|
|
|
$xoopsTpl->assign('lang_mysection', _MD_SUICO_MYAUDIOS); |
|
118
|
|
|
$xoopsTpl->assign('section_name', _MD_SUICO_AUDIOS); |
|
119
|
|
|
//Page Navigation |
|
120
|
|
|
$xoopsTpl->assign('pageNav', $pageNav); |
|
121
|
|
|
require __DIR__ . '/footer.php'; |
|
122
|
|
|
require \dirname(__DIR__, 2) . '/footer.php'; |
|
123
|
|
|
|