diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-05-30 14:19:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-30 14:19:51 +0200 |
commit | 99af78cd66cb489b52f985e9a5b7d165b60b0e82 (patch) | |
tree | e0ea396f5eefcd8a5a4b6f7ec35769d42cb32a7f /lib/private/TemplateLayout.php | |
parent | f80282a5ed1891224e3fa71c69ca2d60412c4c63 (diff) | |
parent | 31b0a44cf65b6625636ea0fa15fb1a1122b525e1 (diff) | |
download | nextcloud-server-99af78cd66cb489b52f985e9a5b7d165b60b0e82.tar.gz nextcloud-server-99af78cd66cb489b52f985e9a5b7d165b60b0e82.zip |
Merge branch 'master' into refactor/OC-Server-getL10NFactory
Signed-off-by: John Molakvoæ <skjnldsv@users.noreply.github.com>
Diffstat (limited to 'lib/private/TemplateLayout.php')
-rw-r--r-- | lib/private/TemplateLayout.php | 81 |
1 files changed, 35 insertions, 46 deletions
diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 6c3f97e66ff..2e688f161bb 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -1,44 +1,9 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Bart Visscher <bartv@thisnet.nl> - * @author Christopher Schäpers <kondou@ts.unde.re> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Clark Tomlinson <fallen013@gmail.com> - * @author Daniel Calviño Sánchez <danxuliu@gmail.com> - * @author Guillaume COMPAGNON <gcompagnon@outlook.com> - * @author Hendrik Leppelsack <hendrik@leppelsack.de> - * @author Joas Schilling <coding@schilljs.com> - * @author John Molakvoæ <skjnldsv@protonmail.com> - * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author Julius Haertl <jus@bitgrid.net> - * @author Julius Härtl <jus@bitgrid.net> - * @author Lukas Reschke <lukas@statuscode.ch> - * @author Michael Gapczynski <GapczynskiM@gmail.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Nils <git@to.nilsschnabel.de> - * @author Remco Brenninkmeijer <requist1@starmail.nl> - * @author Robin Appelman <robin@icewind.nl> - * @author Robin McCorkell <robin@mccorkell.me.uk> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Thomas Citharel <nextcloud@tcit.fr> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * 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, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OC; @@ -47,11 +12,13 @@ use OC\Search\SearchQuery; use OC\Template\CSSResourceLocator; use OC\Template\JSConfigHelper; use OC\Template\JSResourceLocator; +use OCP\App\IAppManager; use OCP\AppFramework\Http\TemplateResponse; use OCP\Defaults; use OCP\IConfig; use OCP\IInitialStateService; use OCP\INavigationManager; +use OCP\IURLGenerator; use OCP\IUserSession; use OCP\L10N\IFactory; use OCP\Support\Subscription\IRegistry; @@ -107,11 +74,15 @@ class TemplateLayout extends \OC_Template { $this->initialState->provideInitialState('core', 'active-app', $this->navigationManager->getActiveEntry()); $this->initialState->provideInitialState('core', 'apps', $this->navigationManager->getAll()); - $this->initialState->provideInitialState('unified-search', 'limit-default', (int)$this->config->getAppValue('core', 'unified-search.limit-default', (string)SearchQuery::LIMIT_DEFAULT)); - $this->initialState->provideInitialState('unified-search', 'min-search-length', (int)$this->config->getAppValue('core', 'unified-search.min-search-length', (string)1)); - $this->initialState->provideInitialState('unified-search', 'live-search', $this->config->getAppValue('core', 'unified-search.live-search', 'yes') === 'yes'); - Util::addScript('core', 'unified-search', 'core'); + if ($this->config->getSystemValueBool('unified_search.enabled', false) || !$this->config->getSystemValueBool('enable_non-accessible_features', true)) { + $this->initialState->provideInitialState('unified-search', 'limit-default', (int)$this->config->getAppValue('core', 'unified-search.limit-default', (string)SearchQuery::LIMIT_DEFAULT)); + $this->initialState->provideInitialState('unified-search', 'min-search-length', (int)$this->config->getAppValue('core', 'unified-search.min-search-length', (string)1)); + $this->initialState->provideInitialState('unified-search', 'live-search', $this->config->getAppValue('core', 'unified-search.live-search', 'yes') === 'yes'); + Util::addScript('core', 'legacy-unified-search', 'core'); + } else { + Util::addScript('core', 'unified-search', 'core'); + } // Set body data-theme $this->assign('enabledThemes', []); if (\OC::$server->getAppManager()->isEnabledForUser('theming') && class_exists('\OCA\Theming\Service\ThemesService')) { @@ -190,13 +161,31 @@ class TemplateLayout extends \OC_Template { $this->assign('appid', $appId); $this->assign('bodyid', 'body-public'); + // Set logo link target + $logoUrl = $this->config->getSystemValueString('logo_url', ''); + $this->assign('logoUrl', $logoUrl); + /** @var IRegistry $subscription */ $subscription = \OCP\Server::get(IRegistry::class); $showSimpleSignup = $this->config->getSystemValueBool('simpleSignUpLink.shown', true); if ($showSimpleSignup && $subscription->delegateHasValidSubscription()) { $showSimpleSignup = false; } + + $defaultSignUpLink = 'https://nextcloud.com/signup/'; + $signUpLink = $this->config->getSystemValueString('registration_link', $defaultSignUpLink); + if ($signUpLink !== $defaultSignUpLink) { + $showSimpleSignup = true; + } + + $appManager = \OCP\Server::get(IAppManager::class); + if ($appManager->isEnabledForUser('registration')) { + $urlGenerator = \OCP\Server::get(IURLGenerator::class); + $signUpLink = $urlGenerator->getAbsoluteURL('/index.php/apps/registration/'); + } + $this->assign('showSimpleSignUpLink', $showSimpleSignup); + $this->assign('signUpLink', $signUpLink); } else { parent::__construct('core', 'layout.base'); } @@ -226,7 +215,7 @@ class TemplateLayout extends \OC_Template { // this is on purpose outside of the if statement below so that the initial state is prefilled (done in the getConfig() call) // see https://github.com/nextcloud/server/pull/22636 for details $jsConfigHelper = new JSConfigHelper( - \OC::$server->getL10N('lib'), + \OCP\Util::getL10N('lib'), \OCP\Server::get(Defaults::class), \OC::$server->getAppManager(), \OC::$server->getSession(), @@ -235,7 +224,7 @@ class TemplateLayout extends \OC_Template { \OC::$server->getGroupManager(), \OC::$server->get(IniGetWrapper::class), \OC::$server->getURLGenerator(), - \OC::$server->getCapabilitiesManager(), + \OC::$server->get(CapabilitiesManager::class), \OCP\Server::get(IInitialStateService::class) ); $config = $jsConfigHelper->getConfig(); @@ -280,7 +269,7 @@ class TemplateLayout extends \OC_Template { $web = $info[1]; $file = $info[2]; - if (substr($file, -strlen('print.css')) === 'print.css') { + if (str_ends_with($file, 'print.css')) { $this->append('printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix()); } else { $suffix = $this->getVersionHashSuffix($web, $file); |