add constante for the app id and the app name
This commit is contained in:
parent
78c95c58ff
commit
9a67c165bd
9 changed files with 89 additions and 77 deletions
|
|
@ -27,6 +27,7 @@ use OCP\AppFramework\Http\TemplateResponse;
|
|||
use OCP\IConfig;
|
||||
use OCP\IRequest;
|
||||
use OCP\IUserSession;
|
||||
use OCA\SideMenu\AppInfo\Application;
|
||||
|
||||
class JsController extends Controller
|
||||
{
|
||||
|
|
@ -68,7 +69,7 @@ class JsController extends Controller
|
|||
*/
|
||||
public function script(): TemplateResponse
|
||||
{
|
||||
$response = new TemplateResponse('side_menu', 'js/script', $this->getConfig(), 'blank');
|
||||
$response = new TemplateResponse(Application::APP_ID, 'js/script', $this->getConfig(), 'blank');
|
||||
$response->addHeader('Content-Type', 'text/javascript');
|
||||
|
||||
return $response;
|
||||
|
|
@ -86,20 +87,20 @@ class JsController extends Controller
|
|||
|
||||
protected function getConfig(): array
|
||||
{
|
||||
$topMenuApps = (array) json_decode($this->config->getAppValue('side_menu', 'top-menu-apps', '[]'), true);
|
||||
$targetBlankApps = (array) json_decode($this->config->getAppValue('side_menu', 'target-blank-apps', '[]'), true);
|
||||
$useAvatar = (bool) $this->config->getAppValue('side_menu', 'use-avatar', '0');
|
||||
$topMenuApps = (array) json_decode($this->config->getAppValue(Application::APP_ID, 'top-menu-apps', '[]'), true);
|
||||
$targetBlankApps = (array) json_decode($this->config->getAppValue(Application::APP_ID, 'target-blank-apps', '[]'), true);
|
||||
$useAvatar = (bool) $this->config->getAppValue(Application::APP_ID, 'use-avatar', '0');
|
||||
$avatar = null;
|
||||
|
||||
if ($this->user) {
|
||||
$userTopMenuApps = (array) json_decode($this->config->getUserValue($this->user->getUid(), 'side_menu', 'top-menu-apps', '[]'), true);
|
||||
$userTopMenuApps = (array) json_decode($this->config->getUserValue($this->user->getUid(), Application::APP_ID, 'top-menu-apps', '[]'), true);
|
||||
|
||||
if (!empty($userTopMenuApps)) {
|
||||
$topMenuApps = $userTopMenuApps;
|
||||
}
|
||||
|
||||
$userTargetBlankMode = (int) $this->config->getUserValue($this->user->getUid(), 'side_menu', 'target-blank-mode', '1');
|
||||
$userTargetBlankApps = (array) json_decode($this->config->getUserValue($this->user->getUid(), 'side_menu', 'target-blank-apps', '[]'), true);
|
||||
$userTargetBlankMode = (int) $this->config->getUserValue($this->user->getUid(), Application::APP_ID, 'target-blank-mode', '1');
|
||||
$userTargetBlankApps = (array) json_decode($this->config->getUserValue($this->user->getUid(), Application::APP_ID, 'target-blank-apps', '[]'), true);
|
||||
|
||||
if (2 === $userTargetBlankMode) {
|
||||
$targetBlankApps = $userTargetBlankApps;
|
||||
|
|
@ -119,14 +120,14 @@ class JsController extends Controller
|
|||
}
|
||||
|
||||
return [
|
||||
'opener-position' => $this->config->getAppValue('side_menu', 'opener-position', 'before'),
|
||||
'opener-hover' => (bool) $this->config->getAppValue('side_menu', 'opener-hover', '0'),
|
||||
'external-sites-in-top-menu' => (bool) $this->config->getAppValue('side_menu', 'external-sites-in-top-menu', 0),
|
||||
'force-light-icon' => (bool) $this->config->getAppValue('side_menu', 'force-light-icon', '0'),
|
||||
'hide-when-no-apps' => (bool) $this->config->getAppValue('side_menu', 'hide-when-no-apps', '0'),
|
||||
'loader-enabled' => (bool) $this->config->getAppValue('side_menu', 'loader-enabled', '1'),
|
||||
'always-displayed' => (bool) $this->config->getAppValue('side_menu', 'always-displayed', '0'),
|
||||
'big-menu' => (bool) $this->config->getAppValue('side_menu', 'big-menu', '0'),
|
||||
'opener-position' => $this->config->getAppValue(Application::APP_ID, 'opener-position', 'before'),
|
||||
'opener-hover' => (bool) $this->config->getAppValue(Application::APP_ID, 'opener-hover', '0'),
|
||||
'external-sites-in-top-menu' => (bool) $this->config->getAppValue(Application::APP_ID, 'external-sites-in-top-menu', 0),
|
||||
'force-light-icon' => (bool) $this->config->getAppValue(Application::APP_ID, 'force-light-icon', '0'),
|
||||
'hide-when-no-apps' => (bool) $this->config->getAppValue(Application::APP_ID, 'hide-when-no-apps', '0'),
|
||||
'loader-enabled' => (bool) $this->config->getAppValue(Application::APP_ID, 'loader-enabled', '1'),
|
||||
'always-displayed' => (bool) $this->config->getAppValue(Application::APP_ID, 'always-displayed', '0'),
|
||||
'big-menu' => (bool) $this->config->getAppValue(Application::APP_ID, 'big-menu', '0'),
|
||||
'avatar' => $avatar,
|
||||
'top-menu-apps' => $topMenuApps,
|
||||
'target-blank-apps' => $targetBlankApps,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue