Passed
Push — master ( 4761c2...696f77 )
by
unknown
05:50 queued 19s
created

audios.php (1 issue)

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