return $this->config->getAppValue('theming', 'url', $this->url);
}
- public function getSlogan() {
- return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', parent::getSlogan()));
+ public function getSlogan(?string $lang = null) {
+ return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', parent::getSlogan($lang)));
}
public function getImprintUrl() {
namespace OC\Mail;
use OCP\Defaults;
-use OCP\IL10N;
use OCP\IURLGenerator;
+use OCP\L10N\IFactory;
use OCP\Mail\IEMailTemplate;
/**
protected $themingDefaults;
/** @var IURLGenerator */
protected $urlGenerator;
- /** @var IL10N */
- protected $l10n;
+ /** @var IFactory */
+ protected $l10nFactory;
/** @var string */
protected $emailId;
/** @var array */
</table>
EOF;
- /**
- * @param Defaults $themingDefaults
- * @param IURLGenerator $urlGenerator
- * @param IL10N $l10n
- * @param string $emailId
- * @param array $data
- */
public function __construct(Defaults $themingDefaults,
IURLGenerator $urlGenerator,
- IL10N $l10n,
+ IFactory $l10nFactory,
$emailId,
array $data) {
$this->themingDefaults = $themingDefaults;
$this->urlGenerator = $urlGenerator;
- $this->l10n = $l10n;
+ $this->l10nFactory = $l10nFactory;
$this->htmlBody .= $this->head;
$this->emailId = $emailId;
$this->data = $data;
*
* @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used
*/
- public function addFooter(string $text = '') {
+ public function addFooter(string $text = '', ?string $lang = null) {
if($text === '') {
- $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.');
+ $l10n = $this->l10nFactory->get('lib', $lang);
+ $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan($lang) . '<br>' . $l10n->t('This is an automatically sent email, please do not reply.');
}
if ($this->footerAdded) {
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
+use OCP\L10N\IFactory;
use OCP\Mail\IAttachment;
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMailer;
private $urlGenerator;
/** @var IL10N */
private $l10n;
+ /** @var IFactory */
+ private $l10nFactory;
/**
* @param IConfig $config
ILogger $logger,
Defaults $defaults,
IURLGenerator $urlGenerator,
- IL10N $l10n) {
+ IL10N $l10n,
+ IFactory $l10nFactory) {
$this->config = $config;
$this->logger = $logger;
$this->defaults = $defaults;
$this->urlGenerator = $urlGenerator;
$this->l10n = $l10n;
+ $this->l10nFactory = $l10nFactory;
}
/**
return new EMailTemplate(
$this->defaults,
$this->urlGenerator,
- $this->l10n,
+ $this->l10nFactory,
$emailId,
$data
);
use OCP\IServerContainer;
use OCP\ITempManager;
use OCP\IUser;
+use OCP\L10N\IFactory;
use OCP\Lock\ILockingProvider;
use OCP\Log\ILogFactory;
use OCP\Remote\Api\IApiFactory;
$c->getLogger(),
$c->query(Defaults::class),
$c->getURLGenerator(),
- $c->getL10N('lib')
+ $c->getL10N('lib'),
+ $c->query(IFactory::class)
);
});
$this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
$initiatorEmail = $initiatorUser->getEMailAddress();
if($initiatorEmail !== null) {
$message->setReplyTo([$initiatorEmail => $initiatorDisplayName]);
- $emailTemplate->addFooter($instanceName . ($this->defaults->getSlogan() !== '' ? ' - ' . $this->defaults->getSlogan() : ''));
+ $emailTemplate->addFooter($instanceName . ($this->defaults->getSlogan($l->getLanguageCode()) !== '' ? ' - ' . $this->defaults->getSlogan($l->getLanguageCode()) : ''));
} else {
- $emailTemplate->addFooter();
+ $emailTemplate->addFooter('', $l->getLanguageCode());
}
$message->useTemplate($emailTemplate);
* Returns slogan
* @return string slogan
*/
- public function getSlogan() {
+ public function getSlogan(?string $lang = null) {
if ($this->themeExist('getSlogan')) {
- return $this->theme->getSlogan();
+ return $this->theme->getSlogan($lang);
} else {
if ($this->defaultSlogan === null) {
- $l10n = \OC::$server->getL10N('lib');
+ $l10n = \OC::$server->getL10N('lib', $lang);
$this->defaultSlogan = $l10n->t('a safe home for all your data');
}
return $this->defaultSlogan;
* @return string
* @since 6.0.0
*/
- public function getSlogan() {
- return $this->defaults->getSlogan();
+ public function getSlogan(?string $lang = null) {
+ return $this->defaults->getSlogan($lang);
}
/**
* Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email
*
* @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used
+ * @param string $lang Optional language to set the default footer in
*
* @since 12.0.0
*/
- public function addFooter(string $text = '');
+ public function addFooter(string $text = '', ?string $lang = null);
/**
* Returns the rendered email subject as string
$template = new EMailTemplate(
$this->defaults,
$this->urlGenerator,
- $this->l10n,
+ $this->l10nFactory,
'test.TestTemplate',
[]
);
use OCP\Defaults;
use OCP\IL10N;
use OCP\IURLGenerator;
+use OCP\L10N\IFactory;
use Test\TestCase;
class EMailTemplateTest extends TestCase {
private $defaults;
/** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */
private $urlGenerator;
- /** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var IFactory|\PHPUnit_Framework_MockObject_MockObject */
private $l10n;
/** @var EMailTemplate */
private $emailTemplate;
$this->defaults = $this->createMock(Defaults::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
- $this->l10n = $this->createMock(IL10N::class);
+ $this->l10n = $this->createMock(IFactory::class);
+
+ $this->l10n->method('get')
+ ->with('lib', '')
+ ->willReturn($this->createMock(IL10N::class));
$this->emailTemplate = new EMailTemplate(
$this->defaults,
use OCP\IL10N;
use OCP\ILogger;
use OCP\IURLGenerator;
+use OCP\L10N\IFactory;
use Test\TestCase;
class MailerTest extends TestCase {
$this->logger,
$this->defaults,
$this->urlGenerator,
- $this->l10n
+ $this->l10n,
+ $this->createMock(IFactory::class)
);
}