Skip to content

Commit

Permalink
feat: Use new svgs in New file menu
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <[email protected]>
  • Loading branch information
Pytal committed Mar 20, 2024
1 parent eb70681 commit 9fd86c6
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ public function register(IRegistrationContext $context): void {
}

public function boot(IBootContext $context): void {
$context->injectFn(function (ITemplateManager $templateManager, IL10N $l10n, IConfig $config, CapabilitiesService $capabilitiesService, PermissionManager $permissionManager) {
$context->injectFn(function (ITemplateManager $templateManager, IL10N $l10n, IConfig $config, CapabilitiesService $capabilitiesService, PermissionManager $permissionManager, IAppManager $appManager) {
if (!$permissionManager->isEnabledForUser() || empty($capabilitiesService->getCapabilities())) {
return;
}
$ooxml = $config->getAppValue(self::APPNAME, 'doc_format', '') === 'ooxml';
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml) {
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml, $appManager) {
$odtType = new TemplateFileCreator('richdocuments', $l10n->t('New document'), ($ooxml ? '.docx' : '.odt'));
if ($ooxml) {
$odtType->addMimetype('application/msword');
Expand All @@ -115,11 +115,11 @@ public function boot(IBootContext $context): void {
$odtType->addMimetype('application/vnd.oasis.opendocument.text');
$odtType->addMimetype('application/vnd.oasis.opendocument.text-template');
}
$odtType->setIconClass('icon-filetype-document');
$odtType->setIconSvgInline(file_get_contents($appManager->getAppPath('richdocuments') . '/img/x-office-document.svg'));

Check failure on line 118 in lib/AppInfo/Application.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedMethod

lib/AppInfo/Application.php:118:15: UndefinedMethod: Method OCP\Files\Template\TemplateFileCreator::setIconSvgInline does not exist (see https://psalm.dev/022)
$odtType->setRatio(21 / 29.7);
return $odtType;
});
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml) {
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml, $appManager) {
$odsType = new TemplateFileCreator('richdocuments', $l10n->t('New spreadsheet'), ($ooxml ? '.xlsx' : '.ods'));
if ($ooxml) {
$odsType->addMimetype('application/vnd.ms-excel');
Expand All @@ -128,11 +128,11 @@ public function boot(IBootContext $context): void {
$odsType->addMimetype('application/vnd.oasis.opendocument.spreadsheet');
$odsType->addMimetype('application/vnd.oasis.opendocument.spreadsheet-template');
}
$odsType->setIconClass('icon-filetype-spreadsheet');
$odsType->setIconSvgInline(file_get_contents($appManager->getAppPath('richdocuments') . '/img/x-office-spreadsheet.svg'));

Check failure on line 131 in lib/AppInfo/Application.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedMethod

lib/AppInfo/Application.php:131:15: UndefinedMethod: Method OCP\Files\Template\TemplateFileCreator::setIconSvgInline does not exist (see https://psalm.dev/022)
$odsType->setRatio(16 / 9);
return $odsType;
});
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml) {
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml, $appManager) {
$odpType = new TemplateFileCreator('richdocuments', $l10n->t('New presentation'), ($ooxml ? '.pptx' : '.odp'));
if ($ooxml) {
$odpType->addMimetype('application/vnd.ms-powerpoint');
Expand All @@ -141,19 +141,19 @@ public function boot(IBootContext $context): void {
$odpType->addMimetype('application/vnd.oasis.opendocument.presentation');
$odpType->addMimetype('application/vnd.oasis.opendocument.presentation-template');
}
$odpType->setIconClass('icon-filetype-presentation');
$odpType->setIconSvgInline(file_get_contents($appManager->getAppPath('richdocuments') . '/img/x-office-presentation.svg'));

Check failure on line 144 in lib/AppInfo/Application.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedMethod

lib/AppInfo/Application.php:144:15: UndefinedMethod: Method OCP\Files\Template\TemplateFileCreator::setIconSvgInline does not exist (see https://psalm.dev/022)
$odpType->setRatio(16 / 9);
return $odpType;
});

if (!$capabilitiesService->hasDrawSupport()) {
return;
}
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml) {
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml, $appManager) {
$odpType = new TemplateFileCreator('richdocuments', $l10n->t('New diagram'), '.odg');
$odpType->addMimetype('application/vnd.oasis.opendocument.graphics');
$odpType->addMimetype('application/vnd.oasis.opendocument.graphics-template');
$odpType->setIconClass('icon-filetype-draw');
$odpType->setIconSvgInline(file_get_contents($appManager->getAppPath('richdocuments') . '/img/x-office-drawing.svg'));

Check failure on line 156 in lib/AppInfo/Application.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedMethod

lib/AppInfo/Application.php:156:15: UndefinedMethod: Method OCP\Files\Template\TemplateFileCreator::setIconSvgInline does not exist (see https://psalm.dev/022)
$odpType->setRatio(1);
return $odpType;
});
Expand Down

0 comments on commit 9fd86c6

Please sign in to comment.