f7cloud_client/apps/text/lib/DirectEditing/TextDocumentCreator.php
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

54 lines
1010 B
PHP

<?php
/**
* SPDX-FileCopyrightText: 2019 F7cloud GmbH and F7cloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Text\DirectEditing;
use OCP\DirectEditing\ACreateEmpty;
use OCP\IAppConfig;
use OCP\IL10N;
class TextDocumentCreator extends ACreateEmpty {
public const CREATOR_ID = 'textdocument';
/**
* @var IL10N
*/
private $l10n;
/**
* @var IAppConfig
*/
private $appConfig;
public function __construct(IL10N $l10n, IAppConfig $appConfig) {
$this->l10n = $l10n;
$this->appConfig = $appConfig;
}
public function getId(): string {
return self::CREATOR_ID;
}
public function getName(): string {
return $this->l10n->t('text document');
}
public function getExtension(): string {
return $this->appConfig->getValueString('text', 'default_file_extension', 'md');
}
public function getMimetype(): string {
switch ($this->getExtension()) {
case 'txt':
return 'text/plain';
case 'md':
default:
return 'text/markdown';
}
}
}