Source of file ProfilsController.php
Size: 6,479 Bytes - Last Modified: 2020-10-24T02:46:31+00:00
/home/travis/build/NextDom/nextdom-core/src/Controller/Params/ProfilsController.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 | <?php /* This file is part of NextDom Software. * * NextDom 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. * * NextDom Software 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 NextDom Software. If not, see <http://www.gnu.org/licenses/>. * * @Support <https://www.nextdom.org> * @Email <admin@nextdom.org> * @Authors/Contributors: Sylvaner, Byackee, cyrilphoenix71, ColonelMoutarde, edgd1er, slobberbone, Astral0, DanoneKiD */ namespace NextDom\Controller\Params; use NextDom\Controller\BaseController; use NextDom\Enums\ControllerData; use NextDom\Helpers\FileSystemHelper; use NextDom\Helpers\NextDomHelper; use NextDom\Helpers\Render; use NextDom\Managers\ConfigManager; use NextDom\Managers\JeeObjectManager; use NextDom\Managers\PlanHeaderManager; use NextDom\Managers\PluginManager; use NextDom\Managers\ThemeManager; use NextDom\Managers\UserManager; use NextDom\Managers\ViewManager; /** * Class ProfilsController * @package NextDom\Controller\Params */ class ProfilsController extends BaseController { /** * Render profils page * * @param array $pageData Page data * * @return string Content of profils page * * @throws \Exception */ public static function get(&$pageData): string { @session_start(); UserManager::getStoredUser()->refresh(); $pageData['profilsUser'] = UserManager::getStoredUser(); @session_write_close(); $pageData['profilsHomePageDesktop'] = [ 'core::dashboard' => __('Dashboard'), 'core::view' => __('Vue'), 'core::plan' => __('Design'), ]; $pluginManagerList = PluginManager::listPlugin(); foreach ($pluginManagerList as $pluginList) { if ($pluginList->isActive() == 1 && $pluginList->getDisplay() != '' && ConfigManager::byKey('displayDesktopPanel', $pluginList->getId(), 0) != 0) { $pageData['profilsHomePageDesktop'][$pluginList->getId() . '::' . $pluginList->getDisplay()] = $pluginList->getName(); } } $lsCssThemes = FileSystemHelper::ls(NEXTDOM_ROOT . '/public/themes/'); $pageData['profilsAvatar'] = ConfigManager::byKey('avatar'); if (isset($_SESSION) && is_object(UserManager::getStoredUser()) && UserManager::getStoredUser()->getOptions('avatar', null) !== null) { $pageData['profilsAvatar'] = UserManager::getStoredUser()->getOptions('avatar'); } else { @session_start(); UserManager::getStoredUser()->setOptions('avatar', $pageData['profilsAvatar']); UserManager::getStoredUser()->save(); @session_write_close(); } $pageData['profilsAvatars'] = []; $profilRootURL = "/public/img/profils"; $profilRootDir = sprintf("%s/public/img/profils/", NEXTDOM_ROOT); $lsAvatars = FileSystemHelper::ls($profilRootDir); foreach ($lsAvatars as $avatarFile) { $path = sprintf("%s/%s", $profilRootDir, $avatarFile); $url = sprintf("%s/%s", $profilRootURL, $avatarFile); if (true == is_file($path)) { $pageData['profilsAvatars'][] = $url; } } $pageData['profilsWidgetTheme'] = ConfigManager::byKey('widget::theme'); if (isset($_SESSION) && is_object(UserManager::getStoredUser()) && UserManager::getStoredUser()->getOptions('widget::theme', null) !== null) { $pageData['profilsWidgetTheme'] = UserManager::getStoredUser()->getOptions('widget::theme'); } else { @session_start(); UserManager::getStoredUser()->setOptions('widget::theme', $pageData['profilsWidgetTheme']); UserManager::getStoredUser()->save(); @session_write_close(); } $pageData['profilsWidgetThemes'] = ThemeManager::getWidgetThemes(); $pageData['profilsDisplayTypes'] = NextDomHelper::getConfiguration('eqLogic:displayType'); foreach ($pageData['profilsDisplayTypes'] as $key => $value) { if (isset($_SESSION) && is_object(UserManager::getStoredUser()) && UserManager::getStoredUser()->getOptions('widget::background-opacity::' . $key, null) == null) { @session_start(); UserManager::getStoredUser()->setOptions('widget::background-opacity::' . $key, 1); UserManager::getStoredUser()->save(); @session_write_close(); } } $pageData['profilsJeeObjects'] = JeeObjectManager::all(); $pageData['profilsViews'] = ViewManager::all(); $pageData['profilsPlans'] = PlanHeaderManager::all(); $pageData['profilsAllowRemoteUsers'] = ConfigManager::byKey('sso:allowRemoteUser'); $themesBases = FileSystemHelper::ls('public/css/themes/', '*nextdom.css'); $pageData['profilsThemesBases'] = []; foreach ($themesBases as $themeBase) { $pageData['profilsThemesBases'][] = substr($themeBase, 0, -12); } $themesIdentities = FileSystemHelper::ls('public/css/themes/', 'dark*.css'); $pageData['profilsThemesIdentities'] = []; foreach ($themesIdentities as $themeIdentity) { $pageData['profilsThemesIdentities'][] = substr($themeIdentity, 5, -4); } $themesIcons = FileSystemHelper::ls('public/img/NextDom/', 'NextDom_Square_*.png'); $pageData['profilsThemesIcons'] = []; foreach ($themesIcons as $themesIcon) { $pageData['profilsThemesIcons'][] = substr($themesIcon, 15, -4); } $pageData['profilsThemeChoice'] = ConfigManager::byKey('nextdom::user-theme'); $pageData['profilsIconChoice'] = ConfigManager::byKey('nextdom::user-icon'); $pageData['adminCategories'] = NextDomHelper::getConfiguration('eqLogic:category'); $pageData[ControllerData::JS_END_POOL][] = self::PATH_TO_JS . '/desktop/params/profils.js'; return Render::getInstance()->get('/desktop/params/profils.html.twig', $pageData); } } |