2020-04-09 09:55:45 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\SideMenu\Settings;
|
|
|
|
|
|
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
|
|
|
use OCP\IL10N;
|
|
|
|
use OCP\ILogger;
|
|
|
|
use OCP\Settings\ISettings;
|
|
|
|
use OCP\IConfig;
|
2020-08-12 10:51:49 +02:00
|
|
|
use OCA\SideMenu\Service\AppRepository;
|
2020-04-09 09:55:45 +02:00
|
|
|
|
|
|
|
class Admin implements ISettings
|
|
|
|
{
|
2020-05-11 22:51:27 +02:00
|
|
|
/**
|
|
|
|
* @var IL10N
|
|
|
|
*/
|
2020-04-09 09:55:45 +02:00
|
|
|
private $l;
|
|
|
|
|
2020-05-11 22:51:27 +02:00
|
|
|
/**
|
|
|
|
* @var ILogger
|
|
|
|
*/
|
2020-04-09 09:55:45 +02:00
|
|
|
private $logger;
|
|
|
|
|
2020-05-11 22:51:27 +02:00
|
|
|
/**
|
|
|
|
* @var IConfig
|
|
|
|
*/
|
2020-04-09 09:55:45 +02:00
|
|
|
private $config;
|
|
|
|
|
2020-08-12 10:51:49 +02:00
|
|
|
/**
|
|
|
|
* @var AppRepository
|
|
|
|
*/
|
|
|
|
private $appRepository;
|
|
|
|
|
|
|
|
public function __construct(IL10N $l, ILogger $logger, IConfig $config, AppRepository $appRepository)
|
2020-04-09 14:16:40 +02:00
|
|
|
{
|
2020-04-09 09:55:45 +02:00
|
|
|
$this->l = $l;
|
|
|
|
$this->logger = $logger;
|
|
|
|
$this->config = $config;
|
2020-08-12 10:51:49 +02:00
|
|
|
$this->appRepository = $appRepository;
|
2020-04-09 09:55:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return TemplateResponse
|
|
|
|
*/
|
|
|
|
public function getForm()
|
|
|
|
{
|
2020-04-25 13:05:01 +02:00
|
|
|
$backgroundColor = $this->config->getAppValue('side_menu', 'background-color', '#333333');
|
|
|
|
$backgroundColorTo = $this->config->getAppValue('side_menu', 'background-color-to', $backgroundColor);
|
|
|
|
|
2020-04-09 09:55:45 +02:00
|
|
|
$parameters = [
|
2020-04-25 13:05:01 +02:00
|
|
|
'background-color' => $backgroundColor,
|
|
|
|
'background-color-to' => $backgroundColorTo,
|
2020-04-09 09:55:45 +02:00
|
|
|
'current-app-background-color' => $this->config->getAppValue('side_menu', 'current-app-background-color', '#444444'),
|
2020-05-19 15:17:54 +02:00
|
|
|
'loader-color' => $this->config->getAppValue('side_menu', 'loader-color', '#0e75ac'),
|
|
|
|
'loader-enabled' => $this->config->getAppValue('side_menu', 'loader-enabled', '1'),
|
2020-04-09 09:55:45 +02:00
|
|
|
'text-color' => $this->config->getAppValue('side_menu', 'text-color', '#FFFFFF'),
|
2020-05-09 14:30:24 +02:00
|
|
|
'force-light-icon' => $this->config->getAppValue('side_menu', 'force-light-icon', '0'),
|
2020-04-09 09:55:45 +02:00
|
|
|
'cache' => $this->config->getAppValue('side_menu', 'cache', '0'),
|
|
|
|
'opener' => $this->config->getAppValue('side_menu', 'opener', 'side-menu-opener'),
|
2020-08-06 15:00:59 +02:00
|
|
|
'big-menu' => $this->config->getAppValue('side_menu', 'big-menu', '0'),
|
2020-04-15 12:17:17 +02:00
|
|
|
'display-logo' => $this->config->getAppValue('side_menu', 'display-logo', '1'),
|
2020-04-20 14:04:06 +02:00
|
|
|
'opener-position' => $this->config->getAppValue('side_menu', 'opener-position', 'before'),
|
2020-04-17 13:58:01 +02:00
|
|
|
'opener-hover' => $this->config->getAppValue('side_menu', 'opener-hover', '0'),
|
2020-04-26 23:45:33 +02:00
|
|
|
'opener-only' => $this->config->getAppValue('side_menu', 'opener-only', '0'),
|
2020-04-29 09:03:03 +02:00
|
|
|
'hide-when-no-apps' => $this->config->getAppValue('side_menu', 'hide-when-no-apps', '0'),
|
2020-04-25 14:25:51 +02:00
|
|
|
'size-icon' => $this->config->getAppValue('side_menu', 'size-icon', 'normal'),
|
|
|
|
'size-text' => $this->config->getAppValue('side_menu', 'size-text', 'normal'),
|
2020-08-12 10:51:49 +02:00
|
|
|
'top-menu-apps' => (array) json_decode($this->config->getAppValue('side_menu', 'top-menu-apps', '[]'), true),
|
|
|
|
'apps' => $this->appRepository->getVisibleApps(),
|
2020-04-09 09:55:45 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
return new TemplateResponse('side_menu', 'settings/admin-form', $parameters, '');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string the section ID, e.g. 'sharing'
|
|
|
|
*/
|
|
|
|
public function getSection()
|
|
|
|
{
|
|
|
|
return 'side_menu';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return int whether the form should be rather on the top or bottom of
|
|
|
|
* the admin section. The forms are arranged in ascending order of the
|
|
|
|
* priority values. It is required to return a value between 0 and 100.
|
|
|
|
*
|
|
|
|
* E.g.: 70
|
|
|
|
*/
|
|
|
|
public function getPriority()
|
|
|
|
{
|
|
|
|
return 70;
|
|
|
|
}
|
|
|
|
}
|