1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Modulebuilder\Files\Language; |
4
|
|
|
|
5
|
|
|
use XoopsModules\Modulebuilder; |
6
|
|
|
use XoopsModules\Modulebuilder\Files; |
7
|
|
|
|
8
|
|
|
/* |
9
|
|
|
You may not change or alter any portion of this comment or credits |
10
|
|
|
of supporting developers from this source code or any supporting source code |
11
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
12
|
|
|
|
13
|
|
|
This program is distributed in the hope that it will be useful, |
14
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16
|
|
|
*/ |
17
|
|
|
/** |
18
|
|
|
* modulebuilder module. |
19
|
|
|
* |
20
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
21
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
22
|
|
|
* |
23
|
|
|
* @since 2.5.0 |
24
|
|
|
* |
25
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
26
|
|
|
* |
27
|
|
|
*/ |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Class LanguageMailTpl. |
31
|
|
|
*/ |
32
|
|
|
class LanguageMailTpl extends Files\CreateFile |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @public function constructor |
36
|
|
|
* @param null |
37
|
|
|
*/ |
38
|
|
|
public function __construct() |
39
|
|
|
{ |
40
|
|
|
parent::__construct(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @static function getInstance |
45
|
|
|
* @param null |
46
|
|
|
* @return LanguageMailTpl |
47
|
|
|
*/ |
48
|
|
|
public static function getInstance() |
49
|
|
|
{ |
50
|
|
|
static $instance = false; |
51
|
|
|
if (!$instance) { |
52
|
|
|
$instance = new self(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return $instance; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @public function write |
60
|
|
|
* |
61
|
|
|
* @param $module |
62
|
|
|
* @param $table |
63
|
|
|
* @param $filename |
64
|
|
|
*/ |
65
|
|
|
public function write($module, $table, $filename) |
66
|
|
|
{ |
67
|
|
|
$this->setModule($module); |
68
|
|
|
$this->setTable($table); |
69
|
|
|
$this->setFileName($filename); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @public function getTemplateDummy |
74
|
|
|
* @param $tableSoleName |
75
|
|
|
* @param $stuTableSoleName |
76
|
|
|
* @param $stuFieldMain |
77
|
|
|
* @param $line |
78
|
|
|
* @return string |
79
|
|
|
*/ |
80
|
|
|
public function getTemplateDummy($tableSoleName, $stuTableSoleName, $stuFieldMain, $line) |
81
|
|
|
{ |
82
|
|
|
|
83
|
|
|
$ret = $this->getSimpleString('Hello {X_UNAME},'); |
84
|
|
|
$ret .= $this->getSimpleString(''); |
85
|
|
|
$ret .= $this->getSimpleString('A new ' . $tableSoleName . ' "{' . $stuFieldMain . '}" has been added at {X_SITENAME}.'); |
86
|
|
|
$ret .= $this->getSimpleString(''); |
87
|
|
|
$ret .= $this->getSimpleString('You can view this ' . $tableSoleName . ' here:'); |
88
|
|
|
$ret .= $this->getSimpleString('{' . $stuTableSoleName . '_URL}'); |
89
|
|
|
$ret .= $this->getSimpleString(''); |
90
|
|
|
$ret .= $this->getSimpleString($line); |
91
|
|
|
$ret .= $this->getSimpleString(''); |
92
|
|
|
$ret .= $this->getSimpleString('You are receiving this message because you selected to be notified when a new ' . $tableSoleName . ' is added to our site.'); |
93
|
|
|
$ret .= $this->getSimpleString(''); |
94
|
|
|
|
95
|
|
|
return $ret; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @public function getTemplateTableNew |
100
|
|
|
* @param $tableSoleName |
101
|
|
|
* @param $stuTableSoleName |
102
|
|
|
* @param $stuFieldMain |
103
|
|
|
* @param $line |
104
|
|
|
* @return string |
105
|
|
|
*/ |
106
|
|
|
public function getTemplateTableNew($tableSoleName, $stuTableSoleName, $stuFieldMain, $line) |
107
|
|
|
{ |
108
|
|
|
|
109
|
|
|
$ret = $this->getSimpleString('Hello {X_UNAME},'); |
110
|
|
|
$ret .= $this->getSimpleString(''); |
111
|
|
|
$ret .= $this->getSimpleString('A new ' . $tableSoleName . ' "{' . $stuFieldMain . '}" has been added at {X_SITENAME}.'); |
112
|
|
|
$ret .= $this->getSimpleString(''); |
113
|
|
|
$ret .= $this->getSimpleString('You can view this ' . $tableSoleName . ' here:'); |
114
|
|
|
$ret .= $this->getSimpleString('{' . $stuTableSoleName . '_URL}'); |
115
|
|
|
$ret .= $this->getSimpleString(''); |
116
|
|
|
$ret .= $this->getSimpleString($line); |
117
|
|
|
$ret .= $this->getSimpleString(''); |
118
|
|
|
$ret .= $this->getSimpleString('You are receiving this message because you selected to be notified when a new ' . $tableSoleName . ' is added to our site.'); |
119
|
|
|
|
120
|
|
|
return $ret; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @public function getTemplateTableModify |
125
|
|
|
* @param $tableSoleName |
126
|
|
|
* @param $stuTableSoleName |
127
|
|
|
* @param $stuFieldMain |
128
|
|
|
* @param $line |
129
|
|
|
* @return string |
130
|
|
|
*/ |
131
|
|
|
public function getTemplateTableModify($tableSoleName, $stuTableSoleName, $stuFieldMain, $line) |
132
|
|
|
{ |
133
|
|
|
|
134
|
|
|
$ret = $this->getSimpleString('Hello {X_UNAME},'); |
135
|
|
|
$ret .= $this->getSimpleString(''); |
136
|
|
|
$ret .= $this->getSimpleString('The ' . $tableSoleName . ' "{' . $stuFieldMain . '}" has been modified at {X_SITENAME}.'); |
137
|
|
|
$ret .= $this->getSimpleString(''); |
138
|
|
|
$ret .= $this->getSimpleString('You can view this ' . $tableSoleName . ' here:'); |
139
|
|
|
$ret .= $this->getSimpleString('{' . $stuTableSoleName . '_URL}'); |
140
|
|
|
$ret .= $this->getSimpleString(''); |
141
|
|
|
$ret .= $this->getSimpleString($line); |
142
|
|
|
$ret .= $this->getSimpleString(''); |
143
|
|
|
$ret .= $this->getSimpleString('You are receiving this message because you selected to be notified when a ' . $tableSoleName . ' is modified on our site.'); |
144
|
|
|
|
145
|
|
|
return $ret; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @public function getTemplateTableDelete |
150
|
|
|
* @param $tableSoleName |
151
|
|
|
* @param $stuFieldMain |
152
|
|
|
* @param $line |
153
|
|
|
* @return string |
154
|
|
|
*/ |
155
|
|
|
public function getTemplateTableDelete($tableSoleName, $stuFieldMain, $line) |
156
|
|
|
{ |
157
|
|
|
|
158
|
|
|
$ret = $this->getSimpleString('Hello {X_UNAME},'); |
159
|
|
|
$ret .= $this->getSimpleString(''); |
160
|
|
|
$ret .= $this->getSimpleString('The ' . $tableSoleName . ' "{' . $stuFieldMain . '}" has been deleted from {X_SITENAME}.'); |
161
|
|
|
$ret .= $this->getSimpleString(''); |
162
|
|
|
$ret .= $this->getSimpleString($line); |
163
|
|
|
$ret .= $this->getSimpleString(''); |
164
|
|
|
$ret .= $this->getSimpleString('You are receiving this message because you selected to be notified when a ' . $tableSoleName . ' is deleted from our site.'); |
165
|
|
|
|
166
|
|
|
return $ret; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @public function getTemplateTableApprove |
171
|
|
|
* @param $tableSoleName |
172
|
|
|
* @param $stuTableSoleName |
173
|
|
|
* @param $stuFieldMain |
174
|
|
|
* @param $line |
175
|
|
|
* @return string |
176
|
|
|
*/ |
177
|
|
|
public function getTemplateTableApprove($tableSoleName, $stuTableSoleName, $stuFieldMain, $line) |
178
|
|
|
{ |
179
|
|
|
|
180
|
|
|
$ret = $this->getSimpleString('Hello {X_UNAME},'); |
181
|
|
|
$ret .= $this->getSimpleString(''); |
182
|
|
|
$ret .= $this->getSimpleString('A new ' . $tableSoleName . ' "{' . $stuFieldMain . '}" is waiting for approval at {X_SITENAME}.'); |
183
|
|
|
$ret .= $this->getSimpleString(''); |
184
|
|
|
$ret .= $this->getSimpleString('You can view this ' . $tableSoleName . ' here:'); |
185
|
|
|
$ret .= $this->getSimpleString('{' . $stuTableSoleName . '_URL}'); |
186
|
|
|
$ret .= $this->getSimpleString(''); |
187
|
|
|
$ret .= $this->getSimpleString($line); |
188
|
|
|
$ret .= $this->getSimpleString(''); |
189
|
|
|
$ret .= $this->getSimpleString('You are receiving this message because you selected to be notified when a ' . $tableSoleName . ' is waitung for approval on our site.'); |
190
|
|
|
|
191
|
|
|
return $ret; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @public function getTemplateTableApprove |
196
|
|
|
* @param $tableSoleName |
197
|
|
|
* @param $stuTableSoleName |
198
|
|
|
* @param $stuFieldMain |
199
|
|
|
* @param $line |
200
|
|
|
* @return string |
201
|
|
|
*/ |
202
|
|
|
public function getTemplateTableBroken($tableSoleName, $stuTableSoleName, $stuFieldMain, $line) |
203
|
|
|
{ |
204
|
|
|
|
205
|
|
|
$ret = $this->getSimpleString('Hello {X_UNAME},'); |
206
|
|
|
$ret .= $this->getSimpleString(''); |
207
|
|
|
$ret .= $this->getSimpleString('The ' . $tableSoleName . ' "{' . $stuFieldMain . '}" has been notified as broken at {X_SITENAME}.'); |
208
|
|
|
$ret .= $this->getSimpleString(''); |
209
|
|
|
$ret .= $this->getSimpleString('You can view this ' . $tableSoleName . ' here:'); |
210
|
|
|
$ret .= $this->getSimpleString('{' . $stuTableSoleName . '_URL}'); |
211
|
|
|
$ret .= $this->getSimpleString(''); |
212
|
|
|
$ret .= $this->getSimpleString($line); |
213
|
|
|
$ret .= $this->getSimpleString(''); |
214
|
|
|
$ret .= $this->getSimpleString('You are receiving this message because you selected to be notified when a ' . $tableSoleName . ' is notified as broken on our site.'); |
215
|
|
|
|
216
|
|
|
return $ret; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @public function getTemplateGlobalNew |
221
|
|
|
* @param $line |
222
|
|
|
* @return string |
223
|
|
|
*/ |
224
|
|
|
public function getTemplateGlobalNew($line) |
225
|
|
|
{ |
226
|
|
|
|
227
|
|
|
$ret = $this->getSimpleString('Hello {X_UNAME},'); |
228
|
|
|
$ret .= $this->getSimpleString(''); |
229
|
|
|
$ret .= $this->getSimpleString('A new item "{ITEM_NAME}" has been added at {X_SITENAME}.'); |
230
|
|
|
$ret .= $this->getSimpleString(''); |
231
|
|
|
$ret .= $this->getSimpleString('You can view this item here:'); |
232
|
|
|
$ret .= $this->getSimpleString('{ITEM_URL}'); |
233
|
|
|
$ret .= $this->getSimpleString(''); |
234
|
|
|
$ret .= $this->getSimpleString($line); |
235
|
|
|
$ret .= $this->getSimpleString(''); |
236
|
|
|
$ret .= $this->getSimpleString('You are receiving this message because you selected to be notified when a new item is added to our site.'); |
237
|
|
|
|
238
|
|
|
return $ret; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* @public function getTemplateGlobalModify |
243
|
|
|
* @param $line |
244
|
|
|
* @return string |
245
|
|
|
*/ |
246
|
|
|
public function getTemplateGlobalModify($line) |
247
|
|
|
{ |
248
|
|
|
|
249
|
|
|
$ret = $this->getSimpleString('Hello {X_UNAME},'); |
250
|
|
|
$ret .= $this->getSimpleString(''); |
251
|
|
|
$ret .= $this->getSimpleString('The item "{ITEM_NAME}" has been modified at {X_SITENAME}.'); |
252
|
|
|
$ret .= $this->getSimpleString(''); |
253
|
|
|
$ret .= $this->getSimpleString('You can view this item here:'); |
254
|
|
|
$ret .= $this->getSimpleString('{ITEM_URL}'); |
255
|
|
|
$ret .= $this->getSimpleString(''); |
256
|
|
|
$ret .= $this->getSimpleString($line); |
257
|
|
|
$ret .= $this->getSimpleString(''); |
258
|
|
|
$ret .= $this->getSimpleString('You are receiving this message because you selected to be notified when an item is modified on our site.'); |
259
|
|
|
|
260
|
|
|
return $ret; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* @public function getTemplateGlobalDelete |
265
|
|
|
* @param $line |
266
|
|
|
* @return string |
267
|
|
|
*/ |
268
|
|
|
public function getTemplateGlobalDelete($line) |
269
|
|
|
{ |
270
|
|
|
|
271
|
|
|
$ret = $this->getSimpleString('Hello {X_UNAME},'); |
272
|
|
|
$ret .= $this->getSimpleString(''); |
273
|
|
|
$ret .= $this->getSimpleString('The item "{ITEM_NAME}" has been deleted from {X_SITENAME}.'); |
274
|
|
|
$ret .= $this->getSimpleString(''); |
275
|
|
|
$ret .= $this->getSimpleString($line); |
276
|
|
|
$ret .= $this->getSimpleString(''); |
277
|
|
|
$ret .= $this->getSimpleString('You are receiving this message because you selected to be notified when an item is deleted from our site.'); |
278
|
|
|
|
279
|
|
|
return $ret; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
/** |
283
|
|
|
* @public function getTemplateGlobalApprove |
284
|
|
|
* @param $line |
285
|
|
|
* @return string |
286
|
|
|
*/ |
287
|
|
|
public function getTemplateGlobalApprove($line) |
288
|
|
|
{ |
289
|
|
|
|
290
|
|
|
$ret = $this->getSimpleString('Hello {X_UNAME},'); |
291
|
|
|
$ret .= $this->getSimpleString(''); |
292
|
|
|
$ret .= $this->getSimpleString('The item "{ITEM_NAME}" is waiting for approval at {X_SITENAME}.'); |
293
|
|
|
$ret .= $this->getSimpleString(''); |
294
|
|
|
$ret .= $this->getSimpleString('You can view this item here:'); |
295
|
|
|
$ret .= $this->getSimpleString('{ITEM_URL}'); |
296
|
|
|
$ret .= $this->getSimpleString(''); |
297
|
|
|
$ret .= $this->getSimpleString($line); |
298
|
|
|
$ret .= $this->getSimpleString(''); |
299
|
|
|
$ret .= $this->getSimpleString('You are receiving this message because you selected to be notified when an item is waitung for approval on our site.'); |
300
|
|
|
|
301
|
|
|
return $ret; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
/** |
305
|
|
|
* @public function getTemplateGlobalBroken |
306
|
|
|
* @param $line |
307
|
|
|
* @return string |
308
|
|
|
*/ |
309
|
|
|
public function getTemplateGlobalBroken($line) |
310
|
|
|
{ |
311
|
|
|
|
312
|
|
|
$ret = $this->getSimpleString('Hello {X_UNAME},'); |
313
|
|
|
$ret .= $this->getSimpleString(''); |
314
|
|
|
$ret .= $this->getSimpleString('The item "{ITEM_NAME}" has been notified as broken at {X_SITENAME}.'); |
315
|
|
|
$ret .= $this->getSimpleString(''); |
316
|
|
|
$ret .= $this->getSimpleString('You can view this item here:'); |
317
|
|
|
$ret .= $this->getSimpleString('{ITEM_URL}'); |
318
|
|
|
$ret .= $this->getSimpleString(''); |
319
|
|
|
$ret .= $this->getSimpleString($line); |
320
|
|
|
$ret .= $this->getSimpleString(''); |
321
|
|
|
$ret .= $this->getSimpleString('You are receiving this message because you selected to be notified when an item is notified as broken on our site.'); |
322
|
|
|
|
323
|
|
|
return $ret; |
324
|
|
|
} |
325
|
|
|
/** |
326
|
|
|
* @public function getTemplateTableApprove |
327
|
|
|
* @param $line |
328
|
|
|
* @return string |
329
|
|
|
*/ |
330
|
|
|
public function getTemplateTableFooter($line) |
331
|
|
|
{ |
332
|
|
|
|
333
|
|
|
$ret = $this->getSimpleString(''); |
334
|
|
|
$ret .= $this->getSimpleString('If this is an error or you wish not to receive further such notifications, please update your subscriptions by visiting the link below:'); |
335
|
|
|
$ret .= $this->getSimpleString('{X_UNSUBSCRIBE_URL}'); |
336
|
|
|
$ret .= $this->getSimpleString(''); |
337
|
|
|
$ret .= $this->getSimpleString('Please do not reply to this message.'); |
338
|
|
|
$ret .= $this->getSimpleString(''); |
339
|
|
|
$ret .= $this->getSimpleString($line); |
340
|
|
|
$ret .= $this->getSimpleString(''); |
341
|
|
|
$ret .= $this->getSimpleString('{X_SITENAME} ({X_SITEURL})'); |
342
|
|
|
$ret .= $this->getSimpleString('webmaster'); |
343
|
|
|
$ret .= $this->getSimpleString('{X_ADMINMAIL}'); |
344
|
|
|
$ret .= $this->getSimpleString(''); |
345
|
|
|
$ret .= $this->getSimpleString($line); |
346
|
|
|
|
347
|
|
|
return $ret; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
|
351
|
|
|
/** |
352
|
|
|
* @public function renderFile |
353
|
|
|
* @return bool|string |
354
|
|
|
*/ |
355
|
|
|
public function render() |
356
|
|
|
{ |
357
|
|
|
$module = $this->getModule(); |
358
|
|
|
$filename = $this->getFileName(); |
359
|
|
|
$table = $this->getTable(); |
360
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
361
|
|
|
$tableName = $table->getVar('table_name'); |
|
|
|
|
362
|
|
|
$tableSoleName = $table->getVar('table_solename'); |
363
|
|
|
$stuTableSoleName = mb_strtoupper($tableSoleName); |
364
|
|
|
$fieldMain = ''; |
365
|
|
|
$fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); |
366
|
|
|
foreach (array_keys($fields) as $f) { |
367
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
368
|
|
|
if (1 == $fields[$f]->getVar('field_main')) { |
369
|
|
|
$fieldMain = $fieldName; // fieldMain = fields parameters main field |
370
|
|
|
} |
371
|
|
|
} |
372
|
|
|
$stuFieldMain = mb_strtoupper($fieldMain); |
373
|
|
|
|
374
|
|
|
$line = '------------------------------------------------------------------'; |
375
|
|
|
$content = ''; |
376
|
|
|
switch ($filename) { |
377
|
|
|
case 'category_new_notify.tpl': |
378
|
|
|
//$content .= $this->getTemplateCategoryNew('categories', 'CATEGORY', 'CATEGORY', $line); |
379
|
|
|
//break; |
380
|
|
|
case 'default': |
381
|
|
|
default: |
382
|
|
|
$content .= $this->getTemplateDummy('story', 'STORY', 'STORY_NAME', $line); |
383
|
|
|
break; |
384
|
|
|
case 'global_new_notify.tpl': |
385
|
|
|
$content .= $this->getTemplateGlobalNew($line); |
386
|
|
|
break; |
387
|
|
|
case'global_modify_notify.tpl': |
388
|
|
|
$content .= $this->getTemplateGlobalModify($line); |
389
|
|
|
break; |
390
|
|
|
case 'global_delete_notify.tpl': |
391
|
|
|
$content .= $this->getTemplateGlobalDelete($line); |
392
|
|
|
break; |
393
|
|
|
case 'global_approve_notify.tpl': |
394
|
|
|
$content .= $this->getTemplateGlobalApprove($line); |
395
|
|
|
break; |
396
|
|
|
case 'global_broken_notify.tpl': |
397
|
|
|
$content .= $this->getTemplateGlobalBroken($line); |
398
|
|
|
break; |
399
|
|
|
case $tableSoleName . '_new_notify.tpl': |
400
|
|
|
$content .= $this->getTemplateTableNew($tableSoleName, $stuTableSoleName, $stuFieldMain, $line); |
401
|
|
|
break; |
402
|
|
|
case $tableSoleName . '_modify_notify.tpl': |
403
|
|
|
$content .= $this->getTemplateTableModify($tableSoleName, $stuTableSoleName, $stuFieldMain, $line); |
404
|
|
|
break; |
405
|
|
|
case $tableSoleName . '_delete_notify.tpl': |
406
|
|
|
$content .= $this->getTemplateTableDelete($tableSoleName, $stuFieldMain, $line); |
407
|
|
|
break; |
408
|
|
|
case $tableSoleName . '_approve_notify.tpl': |
409
|
|
|
$content .= $this->getTemplateTableApprove($tableSoleName, $stuTableSoleName, $stuFieldMain, $line); |
410
|
|
|
break; |
411
|
|
|
case $tableSoleName . '_broken_notify.tpl': |
412
|
|
|
$content .= $this->getTemplateTableBroken($tableSoleName, $stuTableSoleName, $stuFieldMain, $line); |
413
|
|
|
break; |
414
|
|
|
} |
415
|
|
|
$content .= $this->getTemplateTableFooter($line); |
416
|
|
|
|
417
|
|
|
$this->create($moduleDirname, 'language/' . $GLOBALS['xoopsConfig']['language'] . '/mail_template', $filename, $content, _AM_MODULEBUILDER_FILE_CREATED, _AM_MODULEBUILDER_FILE_NOTCREATED); |
418
|
|
|
|
419
|
|
|
return $this->renderFile(); |
420
|
|
|
} |
421
|
|
|
} |
422
|
|
|
|