/
mikopbx
/
ModulePolishLanguagePack
Обзор
Документация
Войти
/
mikopbx
/
ModulePolishLanguagePack
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
master
App/Controllers/ModulePolishLanguagePackController.php
122 строки
5 KB
Nikolai Beketov
feat(ui): add sound files browser with conversion progress
04 май 2026, 13:05
04 май 2026, 13:05
75db8c5
Код
Авторство
О чём код?
<?php declare(strict_types=1); /* * MikoPBX - free phone system for small business * Copyright © 2017-2026 Alexey Portnov and Nikolay Beketov * * This program 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. * * This program 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 <https://www.gnu.org/licenses/>. */ namespace Modules\ModulePolishLanguagePack\App\Controllers; use MikoPBX\AdminCabinet\Controllers\BaseController; use MikoPBX\Modules\PbxExtensionUtils; /** * ModulePolishLanguagePackController * * Controller for Polish Language Pack module information page */ class ModulePolishLanguagePackController extends BaseController { private string $moduleUniqueID = 'ModulePolishLanguagePack'; private string $moduleDir; /** * Basic initialization */ public function initialize(): void { $this->moduleDir = PbxExtensionUtils::getModuleDir($this->moduleUniqueID); parent::initialize(); } /** * Renders the information page for the module * * @return void */ public function indexAction(): void { $this->view->moduleUniqueID = $this->moduleUniqueID; $this->view->moduleDir = $this->moduleDir; // Count sound files $soundsDir = $this->moduleDir . '/Sounds/pl-pl'; $soundFileCount = 0; if (is_dir($soundsDir)) { $files = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($soundsDir, \RecursiveDirectoryIterator::SKIP_DOTS) ); foreach ($files as $file) { if ($file->isFile()) { $soundFileCount++; } } } $this->view->soundFileCount = $soundFileCount; // Count translation files and strings $messagesDir = $this->moduleDir . '/Messages/pl'; $translationFileCount = 0; $translationStringCount = 0; if (is_dir($messagesDir)) { $files = scandir($messagesDir); foreach ($files as $file) { if (is_file($messagesDir . '/' . $file) && pathinfo($file, PATHINFO_EXTENSION) === 'php') { $translationFileCount++; $translations = include $messagesDir . '/' . $file; if (is_array($translations)) { $translationStringCount += count($translations); } } } } $this->view->translationFileCount = $translationFileCount; $this->view->translationStringCount = $translationStringCount; // Conversion-progress widget on the overview page so the user sees // it before navigating to General Settings to switch language. $footer = $this->assets->collection('footerJS'); $footer->addJs("js/cache/{$this->moduleUniqueID}/module-polish-language-pack-sounds-api.js", true); $footer->addJs("js/cache/{$this->moduleUniqueID}/module-polish-language-pack-progress.js", true); $this->view->pick('Modules/' . $this->moduleUniqueID . '/' . $this->moduleUniqueID . '/index'); } /** * Renders the sound files browser page (DataTable + conversion progress). */ public function soundsAction(): void { $this->view->moduleUniqueID = $this->moduleUniqueID; $footer = $this->assets->collection('footerJS'); $footer->addJs('js/vendor/datatable/dataTables.semanticui.js', true); $footer->addJs('js/vendor/range/range.min.js', true); $footer->addJs('js/pbx/main/pbx-data-table-index.js', true); $footer->addJs('js/pbx/SoundFiles/sound-files-index-player.js', true); $footer->addJs("js/cache/{$this->moduleUniqueID}/module-polish-language-pack-sounds-api.js", true); $footer->addJs("js/cache/{$this->moduleUniqueID}/module-polish-language-pack-sounds-index.js", true); $headerCss = $this->assets->collection('headerCSS'); $headerCss->addCss('css/vendor/datatable/dataTables.semanticui.min.css', true); $headerCss->addCss('css/vendor/range/range.css', true); $this->view->pick('Modules/' . $this->moduleUniqueID . '/' . $this->moduleUniqueID . '/sounds'); } }