Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/private/TemplateLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function __construct(
private INavigationManager $navigationManager,
private ITemplateManager $templateManager,
private ServerVersion $serverVersion,
private IRequest $request,
) {
}

Expand All @@ -72,7 +73,8 @@ public function getPageTemplate(string $renderAs, string $appId): ITemplate {
switch ($renderAs) {
case TemplateResponse::RENDER_AS_USER:
$page = $this->templateManager->getTemplate('core', 'layout.user');
if (in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
$pathInfo = $this->request->getPathInfo();
if ($pathInfo !== false && str_starts_with($pathInfo, '/settings/')) {
$page->assign('bodyid', 'body-settings');
} else {
$page->assign('bodyid', 'body-user');
Expand Down Expand Up @@ -254,10 +256,8 @@ public function getPageTemplate(string $renderAs, string $appId): ITemplate {
$page->append('jsfiles', $web . '/' . $file . $this->getVersionHashSuffix());
}

$request = Server::get(IRequest::class);

try {
$pathInfo = $request->getPathInfo();
$pathInfo = $this->request->getPathInfo();
} catch (\Exception $e) {
$pathInfo = '';
}
Expand Down Expand Up @@ -298,7 +298,7 @@ public function getPageTemplate(string $renderAs, string $appId): ITemplate {
}
}

if ($request->isUserAgent([Request::USER_AGENT_CLIENT_IOS, Request::USER_AGENT_SAFARI, Request::USER_AGENT_SAFARI_MOBILE])) {
if ($this->request->isUserAgent([Request::USER_AGENT_CLIENT_IOS, Request::USER_AGENT_SAFARI, Request::USER_AGENT_SAFARI_MOBILE])) {
// Prevent auto zoom with iOS but still allow user zoom
// On chrome (and others) this does not work (will also disable user zoom)
$page->assign('viewport_maximum_scale', '1.0');
Expand Down
1 change: 1 addition & 0 deletions lib/private/legacy/OC_App.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ public static function getAppVersionByPath(string $path): string {

/**
* get the id of loaded app
* @deprecated 34.0.0 Don’t do that
*/
public static function getCurrentApp(): string {
if (\OC::$CLI) {
Expand Down
7 changes: 7 additions & 0 deletions tests/lib/TemplateLayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\INavigationManager;
use OCP\IRequest;
use OCP\ServerVersion;
use OCP\Template\ITemplateManager;
use PHPUnit\Framework\MockObject\MockObject;
Expand All @@ -28,6 +29,7 @@ class TemplateLayoutTest extends \Test\TestCase {
private INavigationManager&MockObject $navigationManager;
private ITemplateManager&MockObject $templateManager;
private ServerVersion&MockObject $serverVersion;
private IRequest&MockObject $request;

private TemplateLayout $templateLayout;

Expand All @@ -41,6 +43,7 @@ protected function setUp(): void {
$this->navigationManager = $this->createMock(INavigationManager::class);
$this->templateManager = $this->createMock(ITemplateManager::class);
$this->serverVersion = $this->createMock(ServerVersion::class);
$this->request = $this->createMock(IRequest::class);
}

#[\PHPUnit\Framework\Attributes\DataProvider('dataVersionHash')]
Expand Down Expand Up @@ -73,6 +76,9 @@ public function testVersionHash(
->with('theming', 'cachebuster', '0')
->willReturn('42');

$this->request->method('getPathInfo')
->willReturn('/' . $path);

$this->templateLayout = $this->getMockBuilder(TemplateLayout::class)
->onlyMethods(['getAppNamefromPath'])
->setConstructorArgs([
Expand All @@ -83,6 +89,7 @@ public function testVersionHash(
$this->navigationManager,
$this->templateManager,
$this->serverVersion,
$this->request,
])
->getMock();

Expand Down
Loading