Skip to content

Commit e864ca5

Browse files
committed
fixed php code
1 parent 9739769 commit e864ca5

18 files changed

Lines changed: 302 additions & 198 deletions

.php-cs-fixer.dist.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
require_once './vendor/autoload.php';
6+
7+
use Nextcloud\CodingStandard\Config;
8+
9+
$config = new Config();
10+
$config
11+
->getFinder()
12+
->notPath('node_modules')
13+
->notPath('l10n')
14+
->notPath('src')
15+
->notPath('vendor')
16+
->in(__DIR__);
17+
return $config;

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
"optimize-autoloader": true,
1313
"classmap-authoritative": true
1414
},
15-
"require": {},
1615
"require-dev": {
17-
"nextcloud/coding-standard": "^1.0.0",
16+
"nextcloud/coding-standard": "^1.1",
1817
"phpunit/phpunit": "^9.6"
1918
},
2019
"scripts": {

composer.lock

Lines changed: 94 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/EMailTemplate.php

Lines changed: 55 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@
2323

2424
namespace OCA\EmailTemplateExample;
2525

26-
use Exception;
2726
use OC\Mail\EMailTemplate as ParentTemplate;
28-
use OCP\IL10N;
2927
use OCP\IConfig;
3028

3129
class EMailTemplate extends ParentTemplate {
3230
protected $urlPath = "";
33-
protected $bodyText ='%s';
31+
protected $bodyText = '%s';
3432
protected $heading = <<<EOF
3533
<table align="center" class="container main-heading float-center" style="Margin:0 auto;background:0 0!important;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:580px">
3634
<tbody>
@@ -165,7 +163,7 @@ class EMailTemplate extends ParentTemplate {
165163
EOF;
166164

167165

168-
protected $tail = <<<EOF
166+
protected $tail = <<<EOF
169167
</div>
170168
</td>
171169
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;">&nbsp;</td>
@@ -175,7 +173,7 @@ class EMailTemplate extends ParentTemplate {
175173
</html>
176174
EOF;
177175

178-
protected $header = <<<EOF
176+
protected $header = <<<EOF
179177
<!-- START Header -->
180178
<div class="header" style="clear: both;text-align: center; width: 100%;border-bottom:2px solid #e5e5e5;">
181179
<table role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;">
@@ -201,25 +199,25 @@ class EMailTemplate extends ParentTemplate {
201199
<!-- END Header -->
202200
EOF;
203201

204-
protected $bodyBegin = <<<EOF
202+
protected $bodyBegin = <<<EOF
205203
<div class="content" style="box-sizing: border-box; display: block; Margin: 0 auto; max-width: 600px;">
206204
EOF;
207205

208206

209-
protected $bodyEnd = <<<EOF
207+
protected $bodyEnd = <<<EOF
210208
</div>
211209
EOF;
212-
protected $l10n = null;
210+
protected $l10n = null;
213211

214-
// protected $button = "";
212+
// protected $button = "";
215213

216-
// protected $buttonGroup = "";
214+
// protected $buttonGroup = "";
217215

218-
// protected $listEnd = "";
216+
// protected $listEnd = "";
219217

220-
// protected $listItem = "";
218+
// protected $listItem = "";
221219

222-
// protected $listBegin = "";
220+
// protected $listBegin = "";
223221

224222
/**
225223
* the following method overwrites the add button group method and
@@ -252,7 +250,7 @@ public function addHeader(?string $lang = null) {
252250
$this->urlPath = $this->urlGenerator->getAbsoluteURL('/');
253251
$sloganTranslated = $this->l10n->t('Life is for sharing');
254252

255-
$this->header = str_replace('host_name',$this->urlPath, $this->header);
253+
$this->header = str_replace('host_name', $this->urlPath, $this->header);
256254

257255
$this->headerAdded = true;
258256
$this->htmlBody .= $this->header;
@@ -320,7 +318,7 @@ public function addHeading(string $title, $plainTitle = '') {
320318
$this->button = "";
321319
$this->buttonGroup = "";
322320
$this->subject = $this->l10n->t('Activity notification for MagentaCLOUD');
323-
if(isset($this->data['dialyActivity'])){
321+
if(isset($this->data['dialyActivity'])) {
324322
$this->subject = $this->l10n->t('Daily activity summary for MagentaCLOUD');
325323
}
326324
$this->heading = '<table role="presentation" class="main" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; background: #ffffff; border-radius: 3px;min-height: 50px;">
@@ -344,11 +342,11 @@ public function addHeading(string $title, $plainTitle = '') {
344342
$this->button = "";
345343
$this->buttonGroup = "";
346344
$this->subject = $this->l10n->t('MagentaCLOUD email verification');
347-
$this->heading = '';
345+
$this->heading = '';
348346
break;
349347
default:
350348
$this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]);
351-
}
349+
}
352350

353351
if ($plainTitle !== false) {
354352
$this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL;
@@ -380,41 +378,41 @@ public function addBodyText(string $text, $plainText = '') {
380378

381379

382380
switch ($this->emailId) {
383-
case "settings.Welcome":
384-
$this->bodyText = include_once 'nmc_email_template/template/welcome_mail.php';
385-
$this->htmlBody .= rtrim($this->bodyText,"1");
386-
break;
387-
case "sharebymail.RecipientNotification":
388-
if($this->data['note'] == null || $this->data['note']== ""){
389-
$text = "";
390-
}
391-
$this->bodyText = include_once 'nmc_email_template/template/sharebymail_recipientNotification.php';
392-
$this->htmlBody .= rtrim($this->bodyText,"1");
393-
break;
394-
case "files_sharing.RecipientNotification":
395-
$this->bodyText = include_once 'nmc_email_template/template/files_sharing_recipient_notification.php';
396-
$this->htmlBody .= rtrim($this->bodyText,"1");
397-
break;
398-
case "settings.TestEmail":
399-
$this->htmlBody .= vsprintf($this->bodyText, [$text]);
400-
break;
401-
case "quote.notification":
402-
$this->htmlBody .= vsprintf($this->bodyText, [$text]);
403-
break;
404-
case "quota_warning.Notification":
405-
$this->bodyText = include_once 'nmc_email_template/template/quota_warning.php';
406-
$this->htmlBody .= rtrim($this->bodyText,"1");
407-
break;
408-
case "activity.Notification":
409-
$this->bodyText = "";
410-
$this->htmlBody .= vsprintf($this->bodyText, [$text]);
411-
break;
412-
case "core.EmailVerification":
413-
$this->bodyText = include_once 'nmc_email_template/template/email_verification.php';
414-
$this->htmlBody .= rtrim($this->bodyText,"1");
415-
break;
416-
default:
417-
$this->htmlBody .= vsprintf($this->bodyText, [$text]);
381+
case "settings.Welcome":
382+
$this->bodyText = include_once 'nmc_email_template/template/welcome_mail.php';
383+
$this->htmlBody .= rtrim($this->bodyText, "1");
384+
break;
385+
case "sharebymail.RecipientNotification":
386+
if($this->data['note'] == null || $this->data['note'] == "") {
387+
$text = "";
388+
}
389+
$this->bodyText = include_once 'nmc_email_template/template/sharebymail_recipientNotification.php';
390+
$this->htmlBody .= rtrim($this->bodyText, "1");
391+
break;
392+
case "files_sharing.RecipientNotification":
393+
$this->bodyText = include_once 'nmc_email_template/template/files_sharing_recipient_notification.php';
394+
$this->htmlBody .= rtrim($this->bodyText, "1");
395+
break;
396+
case "settings.TestEmail":
397+
$this->htmlBody .= vsprintf($this->bodyText, [$text]);
398+
break;
399+
case "quote.notification":
400+
$this->htmlBody .= vsprintf($this->bodyText, [$text]);
401+
break;
402+
case "quota_warning.Notification":
403+
$this->bodyText = include_once 'nmc_email_template/template/quota_warning.php';
404+
$this->htmlBody .= rtrim($this->bodyText, "1");
405+
break;
406+
case "activity.Notification":
407+
$this->bodyText = "";
408+
$this->htmlBody .= vsprintf($this->bodyText, [$text]);
409+
break;
410+
case "core.EmailVerification":
411+
$this->bodyText = include_once 'nmc_email_template/template/email_verification.php';
412+
$this->htmlBody .= rtrim($this->bodyText, "1");
413+
break;
414+
default:
415+
$this->htmlBody .= vsprintf($this->bodyText, [$text]);
418416
}
419417
// $this->htmlBody .= vsprintf($this->bodyText, [$text]);
420418
if ($plainText !== false) {
@@ -475,15 +473,15 @@ public function addFooter(string $text = '', ?string $lang = null) {
475473
}
476474
$this->footerAdded = true;
477475
$this->ensureBodyIsClosed();
478-
if($this->emailId == "defaultShareProvider.sendNote" || $this->emailId == "shareByMail.sendNote"){
476+
if($this->emailId == "defaultShareProvider.sendNote" || $this->emailId == "shareByMail.sendNote") {
479477
$this->htmlBody = str_replace('style="Margin:0 auto;background:0 0!important;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:580px"', 'style="font-size:16px;font-family: TeleNeo, sans-serif;color:#191919;float:left !important"', $this->htmlBody);
480478
$this->htmlBody = str_replace("'Segoe UI'", '', $this->htmlBody);
481479
$this->htmlBody = str_replace("'Helvetica Neue'", "", $this->htmlBody);
482480
$this->htmlBody = str_replace('style="Margin:0;margin-top:20px !important;Margin-bottom:10px;color:inherit;font-family:-apple-system,BlinkMacSystemFont,,Roboto,Oxygen-Sans,Ubuntu,Cantarell,,Arial,sans-serif;font-size:24px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:center;word-wrap:normal"', 'style="Margin:0;margin-top:20px !important;Margin-bottom:10px;color:inherit;font-family:TeleNeo, sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding: 0 0 0 24px !important;text-align:left;word-wrap:normal;color:#191919"', $this->htmlBody);
483481
$this->htmlBody = str_replace('style="box-sizing: border-box; display: block; Margin: 0 auto; max-width: 600px;"', 'style="font-size:16px;font-family: TeleNeo, sans-serif;color:#191919;padding: 0 0 0 24px !important;margin-bottom:80px"', $this->htmlBody);
484482
$this->htmlBody = str_replace("</h1>", ":</h1>", $this->htmlBody);
485483
}
486-
$this->htmlBody .= $this->footer.$this->tail;
484+
$this->htmlBody .= $this->footer.$this->tail;
487485
}
488486

489487
public function setLanguage() {
@@ -494,11 +492,11 @@ public function setLanguage() {
494492
$config = \OC::$server->get(IConfig::class);
495493

496494
$langCurrent = $config->getSystemValue('default_language', 'en');
497-
if(isset($this->data['userId'])){
495+
if(isset($this->data['userId'])) {
498496
$langCurrent = $config->getUserValue($this->data['userId'], 'core', 'lang', null);
499-
}elseif(isset($this->data['userid'])){ // Welcome email
497+
} elseif(isset($this->data['userid'])) { // Welcome email
500498
$langCurrent = $config->getUserValue($this->data['userid'], 'core', 'lang', null);
501-
}elseif ($userSession->getUser() !== null) {
499+
} elseif ($userSession->getUser() !== null) {
502500
$langCurrent = $config->getUserValue($userSession->getUser()->getUID(), 'core', 'lang', null);
503501
}
504502
$this->l10n = $this->l10nFactory->get('nmc_email_template', $langCurrent);

0 commit comments

Comments
 (0)