Files
skjnldsv ae4c1065d0 feat(viewer): keep the legacy viewer API in apps/viewer until 39
Dropping the bundled app takes the OCA.Viewer global and the LoadViewer
event with it, and apps in the wild still use both: text and
recommendations ask the global what it can open, photos opens and closes
it, files_pdfviewer re-opens the current file with another handler, and
photos, maps and collectives construct the event without checking that
it exists, so their pages would fail on the missing class.

The global goes back on the page, backed by the package rather than by
the app. open() takes the paths and the loose file info apps passed
before and turns them into nodes, the getters answer from what the last
open() was given, and mimetypes answers by asking the handlers about a
file of that type. registerHandler is deliberately not here: it was
deprecated in the viewer app in August 2025 and this is where it stops.
The event stays as an empty class nobody dispatches.

Both live in apps/viewer, which is not an app: it has no appinfo, the
server autoloads the event from it and the core viewer init script
imports the bridge. The checkers that take every folder in apps/ for an
app are told so: .noopenapi, the untranslated list, and a skip in the
autoloader checker and in tests/enable_all.php for folders without an
appinfo/info.xml. psalm lints it like the others.

Every use of the global logs a warning naming the replacement and
Nextcloud 39, where the folder and those exceptions go.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
2026-10-01 15:21:14 +02:00

36 lines
876 B
PHP

<?php
/**
* SPDX-FileCopyrightText: 2016-2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2012-2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
use OC\Installer;
use OCP\App\IAppManager;
use OCP\Server;
require_once __DIR__ . '/../lib/base.php';
function enableApp($app) {
$installer = Server::get(Installer::class);
$appManager = Server::get(IAppManager::class);
$installer->installApp($app);
$appManager->enableApp($app);
echo "Enabled application {$app}\n";
}
foreach (new \DirectoryIterator(__DIR__ . '/../apps/') as $file) {
if ($file->isDot()) {
continue;
}
// apps/viewer is not an app, only the legacy viewer API until Nextcloud 39
if (!file_exists($file->getPathname() . '/appinfo/info.xml')) {
continue;
}
if (!file_exists($file->getPathname() . '/.git')) {
enableApp($file->getFilename());
}
}