1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Starkerxp\CampagneBundle\Render; |
4
|
|
|
|
5
|
|
|
class OctosendTxtRender extends OctosendHtmlRender |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var AbstractRender |
9
|
|
|
*/ |
10
|
|
|
private $htmlToTxtService; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* OctosendTxtRender constructor. |
14
|
|
|
* |
15
|
|
|
* @param AbstractRender $htmlToTxtService |
16
|
|
|
*/ |
17
|
|
|
public function __construct(AbstractRender $htmlToTxtService) |
18
|
|
|
{ |
19
|
|
|
$this->htmlToTxtService = $htmlToTxtService; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function render() |
23
|
|
|
{ |
24
|
|
|
// Gestion des liens de desinscriptions. |
25
|
|
|
$contenu = $this->renderLien("unsub", $this->contenu); |
26
|
|
|
// Gestion des liens click:http:// |
27
|
|
|
$contenu = $this->renderLien("click", $contenu); |
28
|
|
|
|
29
|
|
|
$this->htmlToTxtService->setContenu($contenu); |
30
|
|
|
$contenu = $this->htmlToTxtService->render(); |
31
|
|
|
|
32
|
|
|
// Gestion des liens mirror |
33
|
|
|
$contenu = $this->renderMirror($contenu); |
34
|
|
|
// Gestion des liens pixels |
35
|
|
|
$contenu = $this->renderPixel($contenu); |
36
|
|
|
|
37
|
|
|
$contenu = str_replace(' ', ' ', str_replace(' ', ' ', $contenu)); |
38
|
|
|
|
39
|
|
|
return $contenu; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function getSupport($api, $version) |
43
|
|
|
{ |
44
|
|
|
return strtolower($api) == 'octosend' && $version == 'txt'; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
protected function renderClick($contenu, $arrayContenu) |
48
|
|
|
{ |
49
|
|
|
foreach ($arrayContenu[0] as $key => $chaineARemplacer) { |
50
|
|
|
$chaineOctoSend = (!empty($arrayContenu[3][$key]) && $arrayContenu[3][$key] != 'Lien' ? '['.$arrayContenu[3][$key].']' : '').' {{click:'.$arrayContenu[1][$key].'}}'; |
51
|
|
|
$contenu = str_replace($chaineARemplacer, $chaineOctoSend, $contenu); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return $contenu; |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|