OfflineEvent.php
1.14 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
<?php
namespace MyMailer;
class OfflineEvent extends Event{
private $props = array();
private static $instance;
public static function getInstance(){
if(empty(self::$instance)){
self::$instance = new OfflineEvent();
}
return self::$instance;
}
public function replaceData($target, $replacement, $str)
{
$text = str_replace($target, $replacement, $str);
return $text;
}
public function itemDynamicSet($template, $data){
$num = count($data);
$contentText = '';
for($i=0; $i<$num; $i++){
$contentTextOneBlock = $template['dynamic_content'];
foreach($data[$i] as $k => $v){
$target = '{{'.$k.'}}';
print "target = '{{'.$k.'}}'" ;
$replacement = $v;
print "replacement = $v" ;
$contentTextOneBlock = $this->replaceData($target, $replacement, $contentTextOneBlock);
}
$contentText .= $contentTextOneBlock;
}
$template = $template['header']. $contentText .$template['footer'];
return $template;
}
}