add config proxy
This commit is contained in:
parent
7b5e92f83e
commit
40e883841e
|
@ -6,6 +6,7 @@ use OC;
|
||||||
use OC\Security\CSP\ContentSecurityPolicyNonceManager;
|
use OC\Security\CSP\ContentSecurityPolicyNonceManager;
|
||||||
use OC\User\User;
|
use OC\User\User;
|
||||||
use OCA\SideMenu\Service\AppRepository;
|
use OCA\SideMenu\Service\AppRepository;
|
||||||
|
use OCA\SideMenu\Service\ConfigProxy;
|
||||||
use OCP\AppFramework\App;
|
use OCP\AppFramework\App;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use OCP\Util;
|
use OCP\Util;
|
||||||
|
@ -73,6 +74,10 @@ class Application extends App
|
||||||
$container->registerService('AppRepository', function (ContainerInterface $c) {
|
$container->registerService('AppRepository', function (ContainerInterface $c) {
|
||||||
return new AppRepository(new OC_App());
|
return new AppRepository(new OC_App());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$container->registerService('ConfigProxy', function (ContainerInterface $c) {
|
||||||
|
return new ConfigProxy($this->config);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,11 +27,12 @@ use OCP\IConfig;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use OCA\SideMenu\AppInfo\Application;
|
use OCA\SideMenu\AppInfo\Application;
|
||||||
|
use OCA\SideMenu\Service\ConfigProxy;
|
||||||
|
|
||||||
class CssController extends Controller
|
class CssController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \OCP\IConfig
|
* @var ConfigProxy
|
||||||
*/
|
*/
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ class CssController extends Controller
|
||||||
* @param IRequest $request
|
* @param IRequest $request
|
||||||
* @param IConfig $config
|
* @param IConfig $config
|
||||||
*/
|
*/
|
||||||
public function __construct($appName, IRequest $request, IConfig $config)
|
public function __construct($appName, IRequest $request, ConfigProxy $config)
|
||||||
{
|
{
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
|
|
||||||
|
@ -70,13 +71,13 @@ class CssController extends Controller
|
||||||
|
|
||||||
protected function getConfig(): array
|
protected function getConfig(): array
|
||||||
{
|
{
|
||||||
$backgroundColor = $this->config->getAppValue(Application::APP_ID, 'background-color', '#333333');
|
$backgroundColor = $this->config->getAppValue('background-color', '#333333');
|
||||||
$backgroundColorTo = $this->config->getAppValue(Application::APP_ID, 'background-color-to', $backgroundColor);
|
$backgroundColorTo = $this->config->getAppValue('background-color-to', $backgroundColor);
|
||||||
|
|
||||||
$topMenuApps = (array) json_decode($this->config->getAppValue(Application::APP_ID, 'top-menu-apps', '[]'), true);
|
$topMenuApps = $this->config->getAppValueArray('top-menu-apps', '[]');
|
||||||
|
|
||||||
if ($this->user) {
|
if ($this->user) {
|
||||||
$userTopMenuApps = (array) json_decode($this->config->getUserValue($this->user->getUid(), Application::APP_ID, 'top-menu-apps', '[]'), true);
|
$userTopMenuApps = $this->config->getUserValueArray($this->user, 'top-menu-apps', '[]');
|
||||||
|
|
||||||
if (!empty($userTopMenuApps)) {
|
if (!empty($userTopMenuApps)) {
|
||||||
$topMenuApps = $userTopMenuApps;
|
$topMenuApps = $userTopMenuApps;
|
||||||
|
@ -87,20 +88,20 @@ class CssController extends Controller
|
||||||
'vars' => [
|
'vars' => [
|
||||||
'background-color' => $backgroundColor,
|
'background-color' => $backgroundColor,
|
||||||
'background-color-to' => $backgroundColorTo,
|
'background-color-to' => $backgroundColorTo,
|
||||||
'current-app-background-color' => $this->config->getAppValue(Application::APP_ID, 'current-app-background-color', '#444444'),
|
'current-app-background-color' => $this->config->getAppValue('current-app-background-color', '#444444'),
|
||||||
'loader-color' => $this->config->getAppValue(Application::APP_ID, 'loader-color', '#0e75ac'),
|
'loader-color' => $this->config->getAppValue('loader-color', '#0e75ac'),
|
||||||
'text-color' => $this->config->getAppValue(Application::APP_ID, 'text-color', '#FFFFFF'),
|
'text-color' => $this->config->getAppValue('text-color', '#FFFFFF'),
|
||||||
'opener' => $this->config->getAppValue(Application::APP_ID, 'opener', 'side-menu-opener'),
|
'opener' => $this->config->getAppValue('opener', 'side-menu-opener'),
|
||||||
'icon-invert-filter' => abs((int) $this->config->getAppValue(Application::APP_ID, 'icon-invert-filter', '0')).'%',
|
'icon-invert-filter' => abs($this->config->getAppValueInt('icon-invert-filter', '0')).'%',
|
||||||
'icon-opacity' => abs((int) $this->config->getAppValue(Application::APP_ID, 'icon-opacity', '100') / 100),
|
'icon-opacity' => abs($this->config->getAppValueInt('icon-opacity', '100') / 100),
|
||||||
],
|
],
|
||||||
'display-logo' => (bool) $this->config->getAppValue(Application::APP_ID, 'display-logo', 1),
|
'display-logo' => $this->config->getAppValueBool('display-logo', 1),
|
||||||
'opener-only' => (bool) $this->config->getAppValue(Application::APP_ID, 'opener-only', 0),
|
'opener-only' => $this->config->getAppValueBool('opener-only', 0),
|
||||||
'external-sites-in-top-menu' => (bool) $this->config->getAppValue(Application::APP_ID, 'external-sites-in-top-menu', 0),
|
'external-sites-in-top-menu' => $this->config->getAppValueBool('external-sites-in-top-menu', 0),
|
||||||
'size-icon' => $this->config->getAppValue(Application::APP_ID, 'size-icon', 'normal'),
|
'size-icon' => $this->config->getAppValue('size-icon', 'normal'),
|
||||||
'size-text' => $this->config->getAppValue(Application::APP_ID, 'size-text', 'normal'),
|
'size-text' => $this->config->getAppValue('size-text', 'normal'),
|
||||||
'always-displayed' => (bool) $this->config->getAppValue(Application::APP_ID, 'always-displayed', '0'),
|
'always-displayed' => $this->config->getAppValueBool('always-displayed', '0'),
|
||||||
'big-menu' => (bool) $this->config->getAppValue(Application::APP_ID, 'big-menu', '0'),
|
'big-menu' => $this->config->getAppValueBool('big-menu', '0'),
|
||||||
'top-menu-apps' => $topMenuApps,
|
'top-menu-apps' => $topMenuApps,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,12 @@ use OCP\IConfig;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use OCA\SideMenu\AppInfo\Application;
|
use OCA\SideMenu\AppInfo\Application;
|
||||||
|
use OCA\SideMenu\Service\ConfigProxy;
|
||||||
|
|
||||||
class JsController extends Controller
|
class JsController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \OCP\IConfig
|
* @var ConfigProxy
|
||||||
*/
|
*/
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
|
@ -49,10 +50,10 @@ class JsController extends Controller
|
||||||
/**
|
/**
|
||||||
* @param string $appName
|
* @param string $appName
|
||||||
* @param IRequest $request
|
* @param IRequest $request
|
||||||
* @param IConfig $config
|
* @param ConfigProxy $config
|
||||||
* @param ThemingDefaults $themingDefaults
|
* @param ThemingDefaults $themingDefaults
|
||||||
*/
|
*/
|
||||||
public function __construct($appName, IRequest $request, IConfig $config, ThemingDefaults $themingDefaults)
|
public function __construct($appName, IRequest $request, ConfigProxy $config, ThemingDefaults $themingDefaults)
|
||||||
{
|
{
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
|
|
||||||
|
@ -87,20 +88,20 @@ class JsController extends Controller
|
||||||
|
|
||||||
protected function getConfig(): array
|
protected function getConfig(): array
|
||||||
{
|
{
|
||||||
$topMenuApps = (array) json_decode($this->config->getAppValue(Application::APP_ID, 'top-menu-apps', '[]'), true);
|
$topMenuApps = $this->config->getAppValueArray('top-menu-apps', '[]');
|
||||||
$targetBlankApps = (array) json_decode($this->config->getAppValue(Application::APP_ID, 'target-blank-apps', '[]'), true);
|
$targetBlankApps = $this->config->getAppValueArray('target-blank-apps', '[]');
|
||||||
$useAvatar = (bool) $this->config->getAppValue(Application::APP_ID, 'use-avatar', '0');
|
$useAvatar = $this->config->getAppValueBool('use-avatar', '0');
|
||||||
$avatar = null;
|
$avatar = null;
|
||||||
|
|
||||||
if ($this->user) {
|
if ($this->user) {
|
||||||
$userTopMenuApps = (array) json_decode($this->config->getUserValue($this->user->getUid(), Application::APP_ID, 'top-menu-apps', '[]'), true);
|
$userTopMenuApps = $this->config->getUserValueArray($this->user, 'top-menu-apps', '[]');
|
||||||
|
|
||||||
if (!empty($userTopMenuApps)) {
|
if (!empty($userTopMenuApps)) {
|
||||||
$topMenuApps = $userTopMenuApps;
|
$topMenuApps = $userTopMenuApps;
|
||||||
}
|
}
|
||||||
|
|
||||||
$userTargetBlankMode = (int) $this->config->getUserValue($this->user->getUid(), Application::APP_ID, 'target-blank-mode', '1');
|
$userTargetBlankMode = $this->config->getUserValueInt($this->user, 'target-blank-mode', '1');
|
||||||
$userTargetBlankApps = (array) json_decode($this->config->getUserValue($this->user->getUid(), Application::APP_ID, 'target-blank-apps', '[]'), true);
|
$userTargetBlankApps = $this->config->getUserValueArray($this->user, 'target-blank-apps', '[]');
|
||||||
|
|
||||||
if (2 === $userTargetBlankMode) {
|
if (2 === $userTargetBlankMode) {
|
||||||
$targetBlankApps = $userTargetBlankApps;
|
$targetBlankApps = $userTargetBlankApps;
|
||||||
|
@ -113,21 +114,21 @@ class JsController extends Controller
|
||||||
'core.avatar.getAvatar', [
|
'core.avatar.getAvatar', [
|
||||||
'userId' => $this->user->getUid(),
|
'userId' => $this->user->getUid(),
|
||||||
'size' => 128,
|
'size' => 128,
|
||||||
'v' => $this->config->getUserValue($this->user, 'avatar', 'version', 0),
|
'v' => $this->config->getUserValueInt($this->user, 'avatar', 'version', 0),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'opener-position' => $this->config->getAppValue(Application::APP_ID, 'opener-position', 'before'),
|
'opener-position' => $this->config->getAppValue('opener-position', 'before'),
|
||||||
'opener-hover' => (bool) $this->config->getAppValue(Application::APP_ID, 'opener-hover', '0'),
|
'opener-hover' => $this->config->getAppValueBool('opener-hover', '0'),
|
||||||
'external-sites-in-top-menu' => (bool) $this->config->getAppValue(Application::APP_ID, 'external-sites-in-top-menu', 0),
|
'external-sites-in-top-menu' => $this->config->getAppValueBool('external-sites-in-top-menu', 0),
|
||||||
'force-light-icon' => (bool) $this->config->getAppValue(Application::APP_ID, 'force-light-icon', '0'),
|
'force-light-icon' => $this->config->getAppValueBool('force-light-icon', '0'),
|
||||||
'hide-when-no-apps' => (bool) $this->config->getAppValue(Application::APP_ID, 'hide-when-no-apps', '0'),
|
'hide-when-no-apps' => $this->config->getAppValueBool('hide-when-no-apps', '0'),
|
||||||
'loader-enabled' => (bool) $this->config->getAppValue(Application::APP_ID, 'loader-enabled', '1'),
|
'loader-enabled' => $this->config->getAppValueBool('loader-enabled', '1'),
|
||||||
'always-displayed' => (bool) $this->config->getAppValue(Application::APP_ID, 'always-displayed', '0'),
|
'always-displayed' => $this->config->getAppValueBool('always-displayed', '0'),
|
||||||
'big-menu' => (bool) $this->config->getAppValue(Application::APP_ID, 'big-menu', '0'),
|
'big-menu' => $this->config->getAppValueBool('big-menu', '0'),
|
||||||
'avatar' => $avatar,
|
'avatar' => $avatar,
|
||||||
'top-menu-apps' => $topMenuApps,
|
'top-menu-apps' => $topMenuApps,
|
||||||
'target-blank-apps' => $targetBlankApps,
|
'target-blank-apps' => $targetBlankApps,
|
||||||
|
|
|
@ -21,20 +21,20 @@ namespace OCA\SideMenu\Controller;
|
||||||
use OC;
|
use OC;
|
||||||
use OC\App\AppStore\Fetcher\CategoryFetcher;
|
use OC\App\AppStore\Fetcher\CategoryFetcher;
|
||||||
use OC\URLGenerator;
|
use OC\URLGenerator;
|
||||||
|
use OCA\SideMenu\AppInfo\Application;
|
||||||
use OCA\SideMenu\Service\AppRepository;
|
use OCA\SideMenu\Service\AppRepository;
|
||||||
|
use OCA\SideMenu\Service\ConfigProxy;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
use OCP\AppFramework\Http\JSONResponse;
|
use OCP\AppFramework\Http\JSONResponse;
|
||||||
use OCP\IConfig;
|
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use OCP\L10N\IFactory;
|
use OCP\L10N\IFactory;
|
||||||
use OCA\SideMenu\AppInfo\Application;
|
|
||||||
|
|
||||||
class NavController extends Controller
|
class NavController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var IConfig
|
* @var ConfigProxy
|
||||||
*/
|
*/
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
|
@ -59,19 +59,13 @@ class NavController extends Controller
|
||||||
protected $router;
|
protected $router;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $appName
|
* @param string $appName
|
||||||
* @param IRequest $request
|
|
||||||
* @param IConfig $config
|
* @param IConfig $config
|
||||||
* @param AppRepository $appRepository
|
|
||||||
* @param CategoryFetcher $categoryFetcher
|
|
||||||
* @param URLGenerator $router
|
|
||||||
* @param IL10N $trans
|
|
||||||
* @param IFactory $l10nFactory
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$appName,
|
$appName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
IConfig $config,
|
ConfigProxy $config,
|
||||||
AppRepository $appRepository,
|
AppRepository $appRepository,
|
||||||
CategoryFetcher $categoryFetcher,
|
CategoryFetcher $categoryFetcher,
|
||||||
URLGenerator $router,
|
URLGenerator $router,
|
||||||
|
@ -99,7 +93,7 @@ class NavController extends Controller
|
||||||
$apps = $this->appRepository->getVisibleApps();
|
$apps = $this->appRepository->getVisibleApps();
|
||||||
$currentLanguage = substr($this->l10nFactory->findLanguage(), 0, 2);
|
$currentLanguage = substr($this->l10nFactory->findLanguage(), 0, 2);
|
||||||
$categoriesLabels = $this->categoryFetcher->get();
|
$categoriesLabels = $this->categoryFetcher->get();
|
||||||
$externalSitesInTopMenu = (bool) $this->config->getAppValue(Application::APP_ID, 'external-sites-in-top-menu', 0);
|
$externalSitesInTopMenu = $this->config->getAppValueBool('external-sites-in-top-menu', 0);
|
||||||
$user = OC::$server[IUserSession::class]->getUser();
|
$user = OC::$server[IUserSession::class]->getUser();
|
||||||
$appsCategories = [];
|
$appsCategories = [];
|
||||||
$categoriesAppsCount = [];
|
$categoriesAppsCount = [];
|
||||||
|
@ -111,8 +105,8 @@ class NavController extends Controller
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$topMenuApps = (array) json_decode($this->config->getAppValue(Application::APP_ID, 'top-menu-apps', '[]'), true);
|
$topMenuApps = $this->config->getAppValueArray('top-menu-apps', '[]');
|
||||||
$userTopMenuApps = (array) json_decode($this->config->getUserValue($user->getUid(), Application::APP_ID, 'top-menu-apps', '[]'), true);
|
$userTopMenuApps = $this->config->getUserValueArray($user, 'top-menu-apps', '[]');
|
||||||
|
|
||||||
if (!empty($userTopMenuApps)) {
|
if (!empty($userTopMenuApps)) {
|
||||||
$topMenuApps = $userTopMenuApps;
|
$topMenuApps = $userTopMenuApps;
|
||||||
|
|
Loading…
Reference in a new issue