forked from deblan/side_menu
94 lines
3.6 KiB
PHP
94 lines
3.6 KiB
PHP
<?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;
|
|
|
|
use OC;
|
|
use OCP\AppFramework\Controller;
|
|
use OCP\AppFramework\Http\Response;
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
|
use OCP\IConfig;
|
|
use OCP\IRequest;
|
|
use OCP\IUserSession;
|
|
|
|
class CssController extends Controller
|
|
{
|
|
/**
|
|
* @var \OCP\IConfig
|
|
*/
|
|
protected $config;
|
|
|
|
/**
|
|
* @param string $appName
|
|
*/
|
|
public function __construct($appName, IRequest $request, IConfig $config)
|
|
{
|
|
parent::__construct($appName, $request);
|
|
|
|
$this->config = $config;
|
|
}
|
|
|
|
/**
|
|
* @NoAdminRequired
|
|
* @NoCSRFRequired
|
|
* @PublicPage
|
|
*
|
|
* @return Response
|
|
*/
|
|
public function stylesheet()
|
|
{
|
|
$backgroundColor = $this->config->getAppValue('side_menu', 'background-color', '#333333');
|
|
$backgroundColorTo = $this->config->getAppValue('side_menu', 'background-color-to', $backgroundColor);
|
|
|
|
$user = OC::$server[IUserSession::class]->getUser();
|
|
$topMenuApps = (array) json_decode($this->config->getAppValue('side_menu', 'top-menu-apps', '[]'), true);
|
|
|
|
if ($user) {
|
|
$userTopMenuApps = (array) json_decode($this->config->getUserValue($user->getUid(), 'side_menu', 'top-menu-apps', '[]'), true);
|
|
|
|
if (!empty($userTopMenuApps)) {
|
|
$topMenuApps = $userTopMenuApps;
|
|
}
|
|
}
|
|
|
|
$parameters = [
|
|
'vars' => [
|
|
'background-color' => $backgroundColor,
|
|
'background-color-to' => $backgroundColorTo,
|
|
'current-app-background-color' => $this->config->getAppValue('side_menu', 'current-app-background-color', '#444444'),
|
|
'loader-color' => $this->config->getAppValue('side_menu', 'loader-color', '#0e75ac'),
|
|
'text-color' => $this->config->getAppValue('side_menu', 'text-color', '#FFFFFF'),
|
|
'opener' => $this->config->getAppValue('side_menu', 'opener', 'side-menu-opener'),
|
|
'icon-invert-filter' => abs((int) $this->config->getAppValue('side_menu', 'icon-invert-filter', '0')).'%',
|
|
],
|
|
'display-logo' => (bool) $this->config->getAppValue('side_menu', 'display-logo', 1),
|
|
'opener-only' => (bool) $this->config->getAppValue('side_menu', 'opener-only', 0),
|
|
'external-sites-in-top-menu' => (bool) $this->config->getAppValue('side_menu', 'external-sites-in-top-menu', 0),
|
|
'size-icon' => $this->config->getAppValue('side_menu', 'size-icon', 'normal'),
|
|
'size-text' => $this->config->getAppValue('side_menu', 'size-text', 'normal'),
|
|
'big-menu' => (bool) $this->config->getAppValue('side_menu', 'big-menu', '0'),
|
|
'top-menu-apps' => $topMenuApps,
|
|
];
|
|
|
|
$response = new TemplateResponse('side_menu', 'css/stylesheet', $parameters, 'blank');
|
|
$response->addHeader('Content-Type', 'text/css');
|
|
|
|
return $response;
|
|
}
|
|
}
|