XoopsModules25x /
suico
| 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 | * @category Module |
||
| 17 | * @package yogurt |
||
| 18 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 19 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
| 20 | * @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org> |
||
| 21 | */ |
||
| 22 | |||
| 23 | use Xmf\Request; |
||
| 24 | use XoopsModules\Yogurt; |
||
| 25 | |||
| 26 | const COUNTAUDIOS = 'countAudios'; |
||
| 27 | |||
| 28 | $GLOBALS['xoopsOption']['template_main'] = 'yogurt_audios.tpl'; |
||
| 29 | require __DIR__ . '/header.php'; |
||
| 30 | |||
| 31 | $controller = new Yogurt\AudioController($xoopsDB, $xoopsUser); |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Fetching numbers of groups friends videos pictures etc... |
||
| 35 | */ |
||
| 36 | $nbSections = $controller->getNumbersSections(); |
||
| 37 | |||
| 38 | $start = Request::getInt('start', 0, 'GET'); |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Fetching numbers of groups friends videos pictures etc... |
||
| 42 | */ |
||
| 43 | $nbSections = $controller->getNumbersSections(); |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Criteria for Audio |
||
| 47 | */ |
||
| 48 | $criteriaUidAudio = new Criteria('uid_owner', $controller->uidOwner); |
||
| 49 | $criteriaUidAudio->setStart($start); |
||
| 50 | $criteriaUidAudio->setLimit($helper->getConfig('audiosperpage')); |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Get all audios of this user and assign them to template |
||
| 54 | */ |
||
| 55 | $audiosArray = []; |
||
| 56 | $audios = $controller->getAudio($criteriaUidAudio); |
||
| 57 | |||
| 58 | /** |
||
| 59 | * If there is no audio files show in template lang_noaudioyet |
||
| 60 | */ |
||
| 61 | if (isset($nbSections[COUNTAUDIOS]) && 0 === $nbSections[COUNTAUDIOS]) { |
||
| 62 | // $lang_noaudioyet = _MD_YOGURT_NOTHINGYET; |
||
| 63 | |||
| 64 | // $xoopsTpl->assign('lang_nopicyet', $lang_noaudioyet); |
||
| 65 | |||
| 66 | echo '<script>alert("Please add some audio files here")</script>'; |
||
| 67 | } else { |
||
| 68 | /** |
||
| 69 | * Lets populate an array with the data from the pictures |
||
| 70 | */ |
||
| 71 | |||
| 72 | $i = 0; |
||
| 73 | |||
| 74 | foreach ($audios as $audio) { |
||
| 75 | $audiosArray[$i]['audio_id'] = $audio->getVar('audio_id', 's'); |
||
| 76 | |||
| 77 | $audiosArray[$i]['title'] = $audio->getVar('title', 's'); |
||
| 78 | |||
| 79 | $audiosArray[$i]['author'] = $audio->getVar('author', 's'); |
||
| 80 | |||
| 81 | $audiosArray[$i]['description'] = $audio->getVar('description', 's'); |
||
| 82 | |||
| 83 | $audiosArray[$i]['filename'] = $audio->getVar('filename', 's'); |
||
| 84 | |||
| 85 | $audiosArray[$i]['uid_owner'] = $audio->getVar('uid_owner', 's'); |
||
| 86 | |||
| 87 | $audiosArray[$i]['date_created'] = formatTimestamp($audio->getVar('date_created', 's')); |
||
| 88 | |||
| 89 | $audiosArray[$i]['date_updated'] = formatTimestamp($audio->getVar('date_updated', 's')); |
||
| 90 | |||
| 91 | $xoopsTpl->assign('audios', $audiosArray); |
||
| 92 | |||
| 93 | $i++; |
||
| 94 | } |
||
| 95 | } |
||
| 96 | |||
| 97 | $xoopsTpl->assign('audios', $audios); |
||
| 98 | $countAudio = $nbSections[COUNTAUDIOS] ?? 0; |
||
| 99 | |||
| 100 | try { |
||
| 101 | $audiosArray = $controller->assignAudioContent($countAudio, $audios); |
||
| 102 | } catch (\RuntimeException $e) { |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
Loading history...
|
|||
| 103 | } |
||
| 104 | |||
| 105 | if (is_array($audiosArray) && count($audiosArray) > 0) { |
||
|
0 ignored issues
–
show
|
|||
| 106 | $xoopsTpl->assign('audios', $audiosArray); |
||
| 107 | |||
| 108 | $audio_list = []; |
||
| 109 | |||
| 110 | foreach ($audiosArray as $audio_item) { |
||
| 111 | $audio_list[] = XOOPS_UPLOAD_URL . '/yogurt/audio/' . $audio_item['filename']; // . ' | '; |
||
| 112 | } |
||
| 113 | |||
| 114 | //$audio_list = substr($audio_list,-2); |
||
| 115 | |||
| 116 | $xoopsTpl->assign('audio_list', $audio_list); |
||
| 117 | } else { |
||
| 118 | $xoopsTpl->assign('lang_noaudioyet', _MD_YOGURT_NOAUDIOYET); |
||
| 119 | } |
||
| 120 | $pageNav = ''; |
||
| 121 | if (isset($nbSections[COUNTAUDIOS]) && $nbSections[COUNTAUDIOS] > 0) { |
||
| 122 | $pageNav = $controller->getAudiosNavBar($nbSections[COUNTAUDIOS], $helper->getConfig('audiosperpage'), $start, 2); |
||
| 123 | } |
||
| 124 | $xoTheme->addScript('https://unpkg.com/wavesurfer.js'); |
||
| 125 | |||
| 126 | //meta language names |
||
| 127 | $xoopsTpl->assign('lang_meta', _MD_YOGURT_META); |
||
| 128 | $xoopsTpl->assign('lang_title', _MD_YOGURT_META_TITLE); |
||
| 129 | $xoopsTpl->assign('lang_album', _MD_YOGURT_META_ALBUM); |
||
| 130 | $xoopsTpl->assign('lang_artist', _MD_YOGURT_META_ARTIST); |
||
| 131 | $xoopsTpl->assign('lang_year', _MD_YOGURT_META_YEAR); |
||
| 132 | |||
| 133 | //form actions |
||
| 134 | $xoopsTpl->assign('lang_delete', _MD_YOGURT_DELETE); |
||
| 135 | $xoopsTpl->assign('lang_editdesc', _MD_YOGURT_EDIT_DESC); |
||
| 136 | $xoopsTpl->assign('lang_makemain', _MD_YOGURT_MAKEMAIN); |
||
| 137 | |||
| 138 | //Form Submit |
||
| 139 | $xoopsTpl->assign('lang_selectaudio', _MD_YOGURT_AUDIO_SELECT); |
||
| 140 | $xoopsTpl->assign('lang_authorLabel', _MD_YOGURT_AUDIO_AUTHOR); |
||
| 141 | $xoopsTpl->assign('lang_titleLabel', _MD_YOGURT_AUDIO_TITLE); |
||
| 142 | $xoopsTpl->assign('lang_submitValue', _MD_YOGURT_AUDIO_SUBMIT); |
||
| 143 | $xoopsTpl->assign('lang_addaudios', _MD_YOGURT_AUDIO_ADD); |
||
| 144 | |||
| 145 | $xoopsTpl->assign('width', $helper->getConfig('width_tube')); |
||
| 146 | $xoopsTpl->assign('height', $helper->getConfig('height_tube')); |
||
| 147 | $xoopsTpl->assign('player_from_list', _MD_YOGURT_PLAYER); |
||
| 148 | $xoopsTpl->assign('lang_audiohelp', sprintf(_MD_YOGURT_AUDIO_ADD_HELP, $helper->getConfig('maxfilesize'))); |
||
| 149 | $xoopsTpl->assign('max_youcanupload', $helper->getConfig('maxfilesize')); |
||
| 150 | |||
| 151 | $xoopsTpl->assign('lang_mysection', _MD_YOGURT_MYAUDIOS); |
||
| 152 | $xoopsTpl->assign('section_name', _MD_YOGURT_AUDIOS); |
||
| 153 | |||
| 154 | //Page Navigation |
||
| 155 | $xoopsTpl->assign('pageNav', $pageNav); |
||
| 156 | |||
| 157 | require __DIR__ . '/footer.php'; |
||
| 158 | require dirname(__DIR__, 2) . '/footer.php'; |
||
| 159 |