-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessage-edit.html
More file actions
400 lines (325 loc) · 25.1 KB
/
Copy pathmessage-edit.html
File metadata and controls
400 lines (325 loc) · 25.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
{extends file="admin-layout.tpl"}
{block name="no-return-functions"}
{$admin_current_location = 'configuration'}
{/block}
{block name="page-title"}{intl l='Edit a mailing template'}{/block}
{block name="check-resource"}admin.configuration.message{/block}
{block name="check-access"}update{/block}
{block name="main-content"}
<div class="messages edit-message">
<div id="wrapper" class="container">
{loop name="message_edit" type="message" secured="*" id="$message_id" backend_context="1" lang="$edit_language_id"}
<ul class="breadcrumb">
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
<li><a href="{url path='/admin/configuration'}">{intl l="Configuration"}</a></li>
<li><a href="{url path='/admin/configuration/messages'}">{intl l="Mailing templates"}</a></li>
<li>{intl l='Editing mailing template "%name"' name={$NAME}}</li>
</ul>
{hook name="message-edit.top" message_id=$message_id}
<div class="row">
<div class="col-md-12 general-block-decorator">
<div class="row">
<div class="col-md-12 ">
<div class="title">
{intl l='Edit mailing template "%name"' name={$NAME}}
</div>
<ul class="nav nav-tabs" id="tabbed-menu">
<li class="active"><a href="#data" data-toggle="tab">{intl l="Message data"}</a></li>
<li><a href="#preview" data-toggle="tab">{intl l="Preview"}</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="data">
<div class="form-container">
<div class="col-md-12">
{form name="thelia.admin.message.modification"}
<form method="POST" action="{url path='/admin/configuration/messages/save'}" {form_enctype}>
{* Be sure to get the message ID, even if the form could not be validated *}
<input type="hidden" name="message_id" value="{$message_id}" />
{include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/configuration/messages'}"}
{form_hidden_fields exclude="success_url,locale"}
{render_form_field field='success_url' value="{url path='/admin/configuration/messages'}"}
{render_form_field field='locale' value="{$edit_language_locale}"}
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
{render_form_field field='name'}
{render_form_field field='secured'}
{render_form_field field='title'}
{render_form_field field='subject'}
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{intl l="HTML version of this message"}</h3></div>
<div class="panel-body">
<div class="row">
<div class="col-md-6">
{custom_render_form_field field='html_layout_file_name'}
<select {form_field_attributes field='html_layout_file_name'}>
<option value="">{intl l='Use default layout'}</option>
{foreach $layout_list as $layout}
<option value="{$layout}" {if $layout == $value}selected="selected"{/if}>{$layout}</option>
{/foreach}
</select>
{/custom_render_form_field}
</div>
<div class="col-md-6">
{custom_render_form_field field='html_template_file_name'}
<select data-toggle-textarea="html_message" {form_field_attributes field='html_template_file_name' extra_class="textarea-toggle"}>
<option value="">{intl l='Use HTML message defined below'}</option>
{foreach $html_template_list as $template}
<option value="{$template}" {if $template == $value}selected="selected"{/if}>{$template}</option>
{/foreach}
</select>
{if ! empty($value)}{$disable_html='readonly="true"'}{/if}
{/custom_render_form_field}
</div>
</div>
<div class="row">
<div class="col-md-12">
{custom_render_form_field field='html_message'}
<textarea {$disable_html} {form_field_attributes field='html_message' extra_class="fixedfont"}>{$value nofilter}</textarea>
<div id="{$name}" style="height: 500px;"></div>
{/custom_render_form_field}
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{intl l="Text version of this message"}</h3></div>
<div class="panel-body">
<div class="row">
<div class="col-md-6">
{custom_render_form_field field='text_layout_file_name'}
<select {form_field_attributes field='text_layout_file_name'}>
<option value="">{intl l='Use default layout'}</option>
{foreach $layout_list as $layout}
<option value="{$layout}" {if $layout == $value}selected="selected"{/if}>{$layout}</option>
{/foreach}
</select>
{/custom_render_form_field}
</div>
<div class="col-md-6">
{custom_render_form_field field='text_template_file_name'}
<select data-toggle-textarea="text_message" {form_field_attributes field='text_template_file_name' extra_class='textarea-toggle'}>
<option value="">{intl l='Use Text message defined below'}</option>
{foreach $text_template_list as $template}
<option value="{$template}" {if $template == $value}selected="selected"{/if}>{$template}</option>
{/foreach}
</select>
{if ! empty($value)}{$disable_text='readonly="true"'}{/if}
{/custom_render_form_field}
</div>
</div>
<div class="row">
<div class="col-md-12">
{custom_render_form_field field='text_message'}
<textarea {$disable_html} {form_field_attributes field='text_message' extra_class="fixedfont"}>{$value nofilter}</textarea>
<div id="{$name}" style="height: 500px;"></div>
</div>
{/custom_render_form_field}
</div>
</div>
</div>
<div class="form-group">
<p>{intl l='Message created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}</p>
</div>
</form>
{/form}
</div>
</div>
</div>
<div class="tab-pane fade" id="preview">
<br/>
<div class="row">
<div class="col-md-12">
<button class="btn btn-default btn-primary preview-button" data-url="{url path='/admin/message/preview/%id' id=$ID}">
{intl l="Preview HTML"}
</button>
<button class="btn btn-default preview-button" data-url="{url path='/admin/message/preview/text/%id' id=$ID}">
{intl l="Preview text"}
</button>
{form name="thelia.admin.message.send-sample"}
<form class="form-inline pull-right send-test-mail-form" action="{url path='/admin/message/send/%id' id=$ID}" method="POST">
{form_field field="recipient_email"}
<div class="form-group">
<label for="recipient-test-email">{$label} *</label>
<input type="email" required name="{$name}" class="form-control" id="recipient-test-email" {$attr nofilter}>
</div>
{/form_field}
<button type="submit" class="btn btn-primary">{intl l="Send"}</button>
</form>
{/form}
</div>
</div>
<div class="table-responsive">
<table class="table table-striped" id="url-variable-table">
<caption class="clearfix">
{intl l="Variables to inject"}
</caption>
<thead>
<tr>
<th>
{intl l='Name'}
</th>
<th>
{intl l='Value'}
</th>
</tr>
</thead>
<tbody>
<tr class='url-variable'>
<td>
<input type='text' class='url-variable-key form-control' />
</td>
<td>
<input type='text' class='url-variable-value form-control' />
</td>
</tr>
<tr class='url-variable'>
<td>
<input type='text' class='url-variable-key form-control' />
</td>
<td>
<input type='text' class='url-variable-value form-control' />
</td>
</tr>
<tr class='url-variable'>
<td>
<input type='text' class='url-variable-key form-control' />
</td>
<td>
<input type='text' class='url-variable-value form-control' />
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>
<a href="#" class="url-variable-table-add">
<i class="glyphicon glyphicon-plus"></i> {intl l="Add a variable"}
</a>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div><!--/tab-content-->
</div>
</div>
</div>
</div>
{hook name="message-edit.bottom" message_id=$message_id}
{/loop}
{elseloop rel="message_edit"}
<div class="row">
<div class="col-md-12">
<div class="alert alert-error">
{intl l="Sorry, message ID=%id was not found." id={$message_id}}
</div>
</div>
</div>
{/elseloop}
</div>
</div>
<div id="preview-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="test-email-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>{intl l="Test email result"}</h3>
</div>
<div class="modal-body">
<p id="test-email-body"></p>
</div>
</div>
</div>
</div>
{/block}
{block name="javascript-initialization"}
<script src="//cdnjs.cloudflare.com/ajax/libs/ace/1.1.9/ace.js"></script>
<script>
(function($) {
var editor = {
"text_message": null,
"html_message": null
};
$('select.textarea-toggle').change(function(ev) {
var aceEditor = editor[$(this).data('toggle-textarea')];
if ($(this).val() != '') {
aceEditor.setReadOnly(true);
$(this).parents(".row").next().slideUp()
} else {
aceEditor.setReadOnly(false);
$(this).parents(".row").next().slideDown()
}
});
var elems = ["html_message", "text_message"];
$.each(elems, function(index, value){
editor[value] = ace.edit('thelia_message_modification[' + value + ']');
var textarea = $('textarea[name="thelia_message_modification[' + value + ']"]').hide();
editor[value].setTheme("ace/theme/monokai");
editor[value].getSession().setMode("ace/mode/smarty");
editor[value].setValue(textarea.text());
editor[value].getSelection().clearSelection();
editor[value].getSession().on("change", function () {
textarea.text(editor[value].getSession().getValue());
});
});
$('select.textarea-toggle').change();
function buildUrlParameters() {
var url = '';
$('.url-variable').each(function(){
var key = $('.url-variable-key', $(this)).val();
var value = $('.url-variable-value', $(this)).val();
if (key != '' && value != '') {
url += key + '=' + value + '&';
}
});
return url;
}
$('.send-test-mail-form').submit(function(ev) {
var $zis = $(this);
var data = $zis.serialize() + '&' + buildUrlParameters();
$('body').append('<div class="modal-backdrop fade in" id="loading-event"><div class="loading"></div></div>');
$.ajax({
url: $zis.attr('action'),
method: 'post',
data: data,
success: function (data) {
$('#test-email-body').html(data);
$('#test-email-modal').modal("show");
}
}).always(function() {
$("#loading-event").remove();
});
ev.preventDefault();
});
$('.preview-button').click(function(){
var url = $(this).data("url");
url += "?" + buildUrlParameters();
$(".modal-body", "#preview-modal").html(
$("<iframe frameborder=0 height='"+$(window).innerHeight()+"px' width='100%' src='"+url+"'/>")
);
$("#preview-modal").modal("show");
});
$('.url-variable-table-add').click(function() {
var $line = $("<tr class='url-variable'><td><input type='text' class='url-variable-key form-control' /></td>" +
"<td><input type='text' class='url-variable-value form-control' /></td></tr>");
$("tbody", '#url-variable-table').prepend($line);
});
})(jQuery);
</script>
{/block}
{block name="javascript-last-call"}
{hook name="message.edit-js" location="message-edit-js" message_id={$message_id} }
{/block}