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\Controller;
|
|
|
|
|
2020-08-13 11:21:59 +02:00
|
|
|
use OC;
|
2020-09-20 20:53:03 +02:00
|
|
|
use OC\User\User;
|
2020-09-22 14:35:09 +02:00
|
|
|
use OCA\SideMenu\AppInfo\Application;
|
|
|
|
use OCA\SideMenu\Service\ConfigProxy;
|
2020-04-09 09:55:45 +02:00
|
|
|
use OCP\AppFramework\Controller;
|
|
|
|
use OCP\AppFramework\Http\Response;
|
2020-08-13 11:21:59 +02:00
|
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
2020-04-09 09:55:45 +02:00
|
|
|
use OCP\IRequest;
|
2020-08-12 16:16:50 +02:00
|
|
|
use OCP\IUserSession;
|
2020-04-09 09:55:45 +02:00
|
|
|
|
|
|
|
class CssController extends Controller
|
|
|
|
{
|
2020-05-11 22:51:27 +02:00
|
|
|
/**
|
2020-09-22 14:24:53 +02:00
|
|
|
* @var ConfigProxy
|
2020-05-11 22:51:27 +02:00
|
|
|
*/
|
2020-04-09 09:55:45 +02:00
|
|
|
protected $config;
|
|
|
|
|
2020-09-20 20:53:03 +02:00
|
|
|
/**
|
|
|
|
* @var User
|
|
|
|
*/
|
|
|
|
protected $user;
|
|
|
|
|
2020-09-22 14:35:09 +02:00
|
|
|
public function __construct(string $appName, IRequest $request, ConfigProxy $config)
|
2020-04-09 09:55:45 +02:00
|
|
|
{
|
|
|
|
parent::__construct($appName, $request);
|
2020-04-16 12:18:10 +02:00
|
|
|
|
2020-09-20 20:53:03 +02:00
|
|
|
$this->user = OC::$server[IUserSession::class]->getUser();
|
2020-04-09 09:55:45 +02:00
|
|
|
$this->config = $config;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @NoAdminRequired
|
|
|
|
* @NoCSRFRequired
|
|
|
|
* @PublicPage
|
|
|
|
*
|
|
|
|
* @return Response
|
|
|
|
*/
|
|
|
|
public function stylesheet()
|
2020-09-20 20:53:03 +02:00
|
|
|
{
|
2020-09-21 11:28:55 +02:00
|
|
|
$response = new TemplateResponse(Application::APP_ID, 'css/stylesheet', $this->getConfig(), 'blank');
|
2020-09-20 20:53:03 +02:00
|
|
|
$response->addHeader('Content-Type', 'text/css');
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getConfig(): array
|
2020-04-09 09:55:45 +02:00
|
|
|
{
|
2020-09-22 14:24:53 +02:00
|
|
|
$backgroundColor = $this->config->getAppValue('background-color', '#333333');
|
|
|
|
$backgroundColorTo = $this->config->getAppValue('background-color-to', $backgroundColor);
|
2020-04-25 13:05:01 +02:00
|
|
|
|
2020-09-22 14:24:53 +02:00
|
|
|
$topMenuApps = $this->config->getAppValueArray('top-menu-apps', '[]');
|
2020-08-12 16:16:50 +02:00
|
|
|
|
2020-09-20 20:53:03 +02:00
|
|
|
if ($this->user) {
|
2020-09-22 14:24:53 +02:00
|
|
|
$userTopMenuApps = $this->config->getUserValueArray($this->user, 'top-menu-apps', '[]');
|
2020-08-12 16:16:50 +02:00
|
|
|
|
|
|
|
if (!empty($userTopMenuApps)) {
|
|
|
|
$topMenuApps = $userTopMenuApps;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-20 20:53:03 +02:00
|
|
|
return [
|
2020-04-15 12:17:17 +02:00
|
|
|
'vars' => [
|
2020-04-25 13:05:01 +02:00
|
|
|
'background-color' => $backgroundColor,
|
|
|
|
'background-color-to' => $backgroundColorTo,
|
2020-09-22 14:24:53 +02:00
|
|
|
'current-app-background-color' => $this->config->getAppValue('current-app-background-color', '#444444'),
|
|
|
|
'loader-color' => $this->config->getAppValue('loader-color', '#0e75ac'),
|
|
|
|
'text-color' => $this->config->getAppValue('text-color', '#FFFFFF'),
|
|
|
|
'opener' => $this->config->getAppValue('opener', 'side-menu-opener'),
|
|
|
|
'icon-invert-filter' => abs($this->config->getAppValueInt('icon-invert-filter', '0')).'%',
|
|
|
|
'icon-opacity' => abs($this->config->getAppValueInt('icon-opacity', '100') / 100),
|
2020-04-15 12:17:17 +02:00
|
|
|
],
|
2020-09-22 14:24:53 +02:00
|
|
|
'display-logo' => $this->config->getAppValueBool('display-logo', 1),
|
|
|
|
'opener-only' => $this->config->getAppValueBool('opener-only', 0),
|
|
|
|
'external-sites-in-top-menu' => $this->config->getAppValueBool('external-sites-in-top-menu', 0),
|
|
|
|
'size-icon' => $this->config->getAppValue('size-icon', 'normal'),
|
|
|
|
'size-text' => $this->config->getAppValue('size-text', 'normal'),
|
|
|
|
'always-displayed' => $this->config->getAppValueBool('always-displayed', '0'),
|
|
|
|
'big-menu' => $this->config->getAppValueBool('big-menu', '0'),
|
2020-08-12 16:16:50 +02:00
|
|
|
'top-menu-apps' => $topMenuApps,
|
2020-04-09 09:55:45 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|