Skip to content

Commit 1f100cf

Browse files
committed
Remove tokens attribute
1 parent c2efc6c commit 1f100cf

File tree

7 files changed

+14
-42
lines changed

7 files changed

+14
-42
lines changed

src/Controllers/Templates.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function index(): string
9797
*/
9898
public function show($templateId = null): string
9999
{
100-
return $this->getTemplate($templateId)->render();
100+
return $this->getTemplate($templateId)->renderBody();
101101
}
102102

103103
/**
@@ -114,7 +114,7 @@ public function edit($templateId = null): string
114114
return view('Tatter\Outbox\Views\Templates\form', [
115115
'method' => 'Edit',
116116
'template' => $this->getTemplate($templateId),
117-
'templates' => $this->model->orderBy('name')->findAll(),
117+
'templates' => $this->model->where('id !=', $templateId)->orderBy('name')->findAll(),
118118
]);
119119
}
120120

src/Database/Migrations/2020-10-17-195118_create_outbox_templates.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public function up()
1010
'name' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
1111
'subject' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
1212
'body' => ['type' => 'text', 'null' => true],
13-
'tokens' => ['type' => 'text', 'null' => true],
1413
'created_at' => ['type' => 'datetime', 'null' => true],
1514
'updated_at' => ['type' => 'datetime', 'null' => true],
1615
'deleted_at' => ['type' => 'datetime', 'null' => true],

src/Database/Seeds/TemplateSeeder.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,11 @@ public function run()
1212
return;
1313
}
1414

15-
// Prep the parser tokens
16-
$tokens = ['subject', 'title', 'preview', 'body', 'contact', 'unsubscribe'];
17-
$data = [];
18-
foreach ($tokens as $token)
19-
{
20-
$data[$token] = '{' . $token . '}';
21-
}
22-
23-
// Render the view into a parsable version and add it to the database
15+
// Add the Default Template to the database
2416
model(TemplateModel::class)->insert([
2517
'name' => 'Default',
2618
'subject' => '{subject}',
27-
'body' => view(config('Outbox')->template, $data, ['debug' => false]),
28-
'tokens' => implode(',', $tokens),
19+
'body' => view('Tatter\Outbox\Views\Defaults\template'),
2920
]);
3021
}
3122
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta name="viewport" content="width=device-width" />
55
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6-
<title><?= $title ?? '' ?></title>
6+
<title>{title}</title>
77
<style>
88
/* -------------------------------------
99
RESPONSIVE AND MOBILE FRIENDLY STYLES
@@ -100,7 +100,7 @@
100100
</style>
101101
</head>
102102
<body class="">
103-
<span class="preheader"><?= $preview ?? '' ?></span>
103+
<span class="preheader">{preview}</span>
104104
<table role="presentation" border="0" cellpadding="0" cellspacing="0" class="body">
105105
<tr>
106106
<td>&nbsp;</td>
@@ -115,9 +115,9 @@
115115
<td class="wrapper">
116116
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
117117
<tr>
118-
119-
<?= $body ?? '' ?>
120-
118+
<td>
119+
{body}
120+
</td>
121121
</tr>
122122
</table>
123123
</td>
@@ -132,8 +132,8 @@
132132
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
133133
<tr>
134134
<td class="content-block">
135-
<span class="apple-link"><?= $contact ?? '' ?></span>
136-
<br> Don't like these emails? <?= $unsubscribe ?? '' ?>.
135+
<span class="apple-link">{contact}</span>
136+
<br> Don't like these emails? {unsubscribe}.
137137
</td>
138138
</tr>
139139
</table>

src/Views/Templates/form.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,13 @@
77
<h2 class="mb-3"><?= $template->name ?></h2>
88

99
<form name="email-template-form" action="<?= site_url('emails/templates/' . ($method === 'Edit' ? 'update/' . $template->id : 'create')) ?>" method="post">
10-
<div class="form-group">
11-
<label for="tokens">Available Tokens</label>
12-
<br />
13-
<?php if ($method === 'Edit'): ?>
14-
<?php foreach ($template->tokens as $token): ?>
15-
<span class="badge badge-secondary"><?= $token ?></span>
16-
<?php endforeach; ?>
17-
<?php endif; ?>
18-
19-
<input type="<?= $method === 'Edit' ? 'hidden' : 'text' ?>"
20-
class="form-control"
21-
name="tokens"
22-
id="tokens"
23-
placeholder="token1,token2,token3,..."
24-
value="<?= implode(',', $template->tokens) ?>"
25-
/>
26-
</div>
2710
<div class="form-group">
2811
<label for="parent_id">Parent Template</label>
2912
<select name="parent_id">
3013
<option value="">NONE</option>
3114

32-
<?php foreach ($templates as $temp): ?>
33-
<?php if ($temp->id == $template->id): continue; endif; ?>
34-
<option value="<?= $temp->id ?>" <?= $temp->id == $template->parent_id ? 'selected' : '' ?>><?= $temp->name ?></option>
15+
<?php foreach ($templates as $option): ?>
16+
<option value="<?= $option->id ?>" <?= $option->id == $template->parent_id ? 'selected' : '' ?>><?= $option->name ?></option>
3517
<?php endforeach; ?>
3618

3719
</select>

src/Views/Templates/send.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class="form-control"
5555
<hr />
5656
<h5>Tokens</h5>
5757

58-
<?php foreach ($template->tokens as $token): ?>
58+
<?php foreach ($template->getTokens() as $token): ?>
5959
<div class="form-group row">
6060
<label for="<?= $token ?>" class="col-sm-2 col-form-label">
6161
<span class="badge badge-secondary"><?= $token ?></span>

0 commit comments

Comments
 (0)