|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the LineMob package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Ishmael Doss <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace LineMob\Core\Template\ImageMap; |
|
13
|
|
|
|
|
14
|
|
|
use LINE\LINEBot\ImagemapActionBuilder\ImagemapMessageActionBuilder; |
|
15
|
|
|
use LINE\LINEBot\ImagemapActionBuilder\ImagemapUriActionBuilder; |
|
16
|
|
|
use LINE\LINEBot\MessageBuilder\Imagemap\BaseSizeBuilder; |
|
17
|
|
|
use LINE\LINEBot\MessageBuilder\ImagemapMessageBuilder; |
|
18
|
|
|
use LineMob\Core\Template\AbstractTemplate; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @author WATCHDOGS <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class ImageMapTemplate extends AbstractTemplate |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var string |
|
27
|
|
|
*/ |
|
28
|
|
|
public $baseUrl; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
public $altText = 'this is an imagemap'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var int |
|
37
|
|
|
*/ |
|
38
|
|
|
public $width; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var int |
|
42
|
|
|
*/ |
|
43
|
|
|
public $height; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var Action[] |
|
47
|
|
|
*/ |
|
48
|
|
|
public $actions; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* {@inheritdoc} |
|
52
|
|
|
*/ |
|
53
|
|
|
public function getTemplate() |
|
54
|
|
|
{ |
|
55
|
|
|
$baseSize = new BaseSizeBuilder($this->height, $this->width); |
|
56
|
|
|
$actions = []; |
|
57
|
|
|
|
|
58
|
|
|
foreach ($this->actions as $action) { |
|
59
|
|
|
switch ($action->type) { |
|
60
|
|
|
case Action::TYPE_URI: |
|
61
|
|
|
$actions[] = new ImagemapUriActionBuilder($action->link, $action->area->getArea()); |
|
62
|
|
|
break; |
|
63
|
|
|
case Action::TYPE_MESSAGE: |
|
64
|
|
|
$actions[] = new ImagemapMessageActionBuilder($action->text, $action->area->getArea()); |
|
65
|
|
|
break; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
return new ImagemapMessageBuilder($this->baseUrl, $this->altText, $baseSize, $actions); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @param ActionArea $area |
|
74
|
|
|
* @param string $link |
|
75
|
|
|
*/ |
|
76
|
|
|
public function addLinkAction($link, ActionArea $area) |
|
77
|
|
|
{ |
|
78
|
|
|
$this->actions[] = new Action($area, Action::TYPE_URI, null, $link); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @param ActionArea $area |
|
83
|
|
|
* @param string $text |
|
84
|
|
|
*/ |
|
85
|
|
|
public function addMessageAction($text, ActionArea $area) |
|
86
|
|
|
{ |
|
87
|
|
|
$this->actions[] = new Action($area, Action::TYPE_MESSAGE, $text, null); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|