Passed
Pull Request — master (#81)
by Michael
02:31
created

audios.php (2 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
*/
14
15
/**
16
 * Module: Yogurt
17
 *
18
 * @category        Module
19
 * @package         yogurt
20
 * @author          Marcello Brandão aka  Suico, Mamba, LioMJ  <https://xoops.org>
21
 * @copyright       {@link https://xoops.org/ XOOPS Project}
22
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
23
 */
24
25
use XoopsModules\Yogurt;
26
use Xmf\Request;
27
28
const NBAUDIO = 'nbAudio';
29
30
$GLOBALS['xoopsOption']['template_main'] = 'yogurt_audios.tpl';
31
require __DIR__ . '/header.php';
32
33
$controller = new Yogurt\AudioController($xoopsDB, $xoopsUser);
34
35
/**
36
 * Fetching numbers of groups friends videos pictures etc...
37
 */
38
$nbSections = $controller->getNumbersSections();
39
40
$start = Request::getInt('start', 0, 'GET');
41
42
/**
43
 * Fetching numbers of groups friends videos pictures etc...
44
 */
45
$nbSections = $controller->getNumbersSections();
46
47
/**
48
 * Criteria for Audio
49
 */
50
$criteriaUidAudio = new Criteria('uid_owner', $controller->uidOwner);
51
$criteriaUidAudio->setStart($start);
52
$criteriaUidAudio->setLimit($helper->getConfig('audiosperpage'));
53
54
/**
55
 * Get all audios of this user and assign them to template
56
 */
57
$audios       = $controller->getAudio($criteriaUidAudio);
58
$nbAudio = $nbSections[NBAUDIO] ?? 0;
59
try {
60
    $audiosArray = $controller->assignAudioContent($nbAudio, $audios);
61
} catch (\RuntimeException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
62
}
63
64
if (is_array($audiosArray)) {
0 ignored issues
show
The condition is_array($audiosArray) is always false.
Loading history...
65
    $xoopsTpl->assign('audios', $audiosArray);
66
    $audio_list = [];
67
    foreach ($audiosArray as $audio_item) {
68
        $audio_list[] = XOOPS_UPLOAD_URL . '/yogurt/audio/' . $audio_item['filename']; // . ' | ';
69
    }
70
    //$audio_list = substr($audio_list,-2);
71
    $xoopsTpl->assign('audio_list', $audio_list);
72
} else {
73
    $xoopsTpl->assign('lang_noaudioyet', _MD_YOGURT_NOAUDIOYET);
74
}
75
$pageNav = '';
76
if (isset($nbSections[NBAUDIO]) && $nbSections[NBAUDIO] > 0) {
77
    $pageNav = $controller->getAudiosNavBar($nbSections[NBAUDIO], $helper->getConfig('audiosperpage'), $start, 2);
78
}
79
$xoTheme->addScript('https://unpkg.com/wavesurfer.js');
80
81
//meta language names
82
$xoopsTpl->assign('lang_meta', _MD_YOGURT_META);
83
$xoopsTpl->assign('lang_title', _MD_YOGURT_META_TITLE);
84
$xoopsTpl->assign('lang_album', _MD_YOGURT_META_ALBUM);
85
$xoopsTpl->assign('lang_artist', _MD_YOGURT_META_ARTIST);
86
$xoopsTpl->assign('lang_year', _MD_YOGURT_META_YEAR);
87
88
//form actions
89
$xoopsTpl->assign('lang_delete', _MD_YOGURT_DELETE);
90
$xoopsTpl->assign('lang_editdesc', _MD_YOGURT_EDIT_DESC);
91
$xoopsTpl->assign('lang_makemain', _MD_YOGURT_MAKEMAIN);
92
93
//Form Submit
94
$xoopsTpl->assign('lang_selectaudio', _MD_YOGURT_AUDIO_SELECT);
95
$xoopsTpl->assign('lang_authorLabel', _MD_YOGURT_AUDIO_AUTHOR);
96
$xoopsTpl->assign('lang_titleLabel', _MD_YOGURT_AUDIO_TITLE);
97
$xoopsTpl->assign('lang_submitValue', _MD_YOGURT_AUDIO_SUBMIT);
98
$xoopsTpl->assign('lang_addaudios', _MD_YOGURT_AUDIO_ADD);
99
100
$xoopsTpl->assign('width', $helper->getConfig('width_tube'));
101
$xoopsTpl->assign('height', $helper->getConfig('height_tube'));
102
$xoopsTpl->assign('player_from_list', _MD_YOGURT_PLAYER);
103
$xoopsTpl->assign('lang_audiohelp', sprintf(_MD_YOGURT_AUDIO_ADD_HELP, $helper->getConfig('maxfilesize')));
104
$xoopsTpl->assign('max_youcanupload', $helper->getConfig('maxfilesize'));
105
106
$xoopsTpl->assign('lang_mysection', _MD_YOGURT_MYAUDIOS);
107
$xoopsTpl->assign('section_name', _MD_YOGURT_AUDIOS);
108
109
//Page Navigation
110
$xoopsTpl->assign('pageNav', $pageNav);
111
112
113
require __DIR__ . '/footer.php';
114
require dirname(__DIR__, 2) . '/footer.php';
115