aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/TemplateLayout.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/TemplateLayout.php')
-rw-r--r--lib/private/TemplateLayout.php54
1 files changed, 24 insertions, 30 deletions
diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php
index d041db2a7c2..178bec9c8dc 100644
--- a/lib/private/TemplateLayout.php
+++ b/lib/private/TemplateLayout.php
@@ -44,8 +44,9 @@ namespace OC;
use bantu\IniGetWrapper\IniGetWrapper;
use OC\Search\SearchQuery;
-use OC\Template\JSCombiner;
+use OC\Template\CSSResourceLocator;
use OC\Template\JSConfigHelper;
+use OC\Template\JSResourceLocator;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Defaults;
use OCP\IConfig;
@@ -54,11 +55,16 @@ use OCP\INavigationManager;
use OCP\IUserSession;
use OCP\Support\Subscription\IRegistry;
use OCP\Util;
-use Psr\Log\LoggerInterface;
class TemplateLayout extends \OC_Template {
private static $versionHash = '';
+ /** @var CSSResourceLocator|null */
+ public static $cssLocator = null;
+
+ /** @var JSResourceLocator|null */
+ public static $jsLocator = null;
+
/** @var IConfig */
private $config;
@@ -102,7 +108,7 @@ 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)2));
+ $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');
@@ -114,10 +120,6 @@ class TemplateLayout extends \OC_Template {
$this->assign('enabledThemes', $themesService->getEnabledThemes());
}
- // set logo link target
- $logoUrl = $this->config->getSystemValueString('logo_url', '');
- $this->assign('logoUrl', $logoUrl);
-
// Add navigation entry
$this->assign('application', '');
$this->assign('appid', $appId);
@@ -188,6 +190,11 @@ class TemplateLayout extends \OC_Template {
} else {
parent::__construct('core', 'layout.base');
}
+
+ // set logo link target
+ $logoUrl = $this->config->getSystemValueString('logo_url', '');
+ $this->assign('logoUrl', $logoUrl);
+
// Send the language and the locale to our layouts
$lang = \OC::$server->getL10NFactory()->findLanguage();
$locale = \OC::$server->getL10NFactory()->findLocale($lang);
@@ -332,17 +339,11 @@ class TemplateLayout extends \OC_Template {
* @return array
*/
public static function findStylesheetFiles($styles, $compileScss = true) {
- // Read the selected theme from the config file
- $theme = \OC_Util::getTheme();
-
- $locator = new \OC\Template\CSSResourceLocator(
- \OC::$server->get(LoggerInterface::class),
- $theme,
- [ \OC::$SERVERROOT => \OC::$WEBROOT ],
- [ \OC::$SERVERROOT => \OC::$WEBROOT ],
- );
- $locator->find($styles);
- return $locator->getResources();
+ if (!self::$cssLocator) {
+ self::$cssLocator = \OCP\Server::get(CSSResourceLocator::class);
+ }
+ self::$cssLocator->find($styles);
+ return self::$cssLocator->getResources();
}
/**
@@ -366,18 +367,11 @@ class TemplateLayout extends \OC_Template {
* @return array
*/
public static function findJavascriptFiles($scripts) {
- // Read the selected theme from the config file
- $theme = \OC_Util::getTheme();
-
- $locator = new \OC\Template\JSResourceLocator(
- \OC::$server->get(LoggerInterface::class),
- $theme,
- [ \OC::$SERVERROOT => \OC::$WEBROOT ],
- [ \OC::$SERVERROOT => \OC::$WEBROOT ],
- \OC::$server->query(JSCombiner::class)
- );
- $locator->find($scripts);
- return $locator->getResources();
+ if (!self::$jsLocator) {
+ self::$jsLocator = \OCP\Server::get(JSResourceLocator::class);
+ }
+ self::$jsLocator->find($scripts);
+ return self::$jsLocator->getResources();
}
/**