1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ajax\semantic\html\content; |
4
|
|
|
|
5
|
|
|
use Ajax\JsUtils; |
6
|
|
|
use Ajax\service\JString; |
7
|
|
|
use Ajax\semantic\html\base\HtmlSemDoubleElement; |
8
|
|
|
|
9
|
|
|
class InternalPopup { |
10
|
|
|
protected $title; |
11
|
|
|
protected $content; |
12
|
|
|
protected $html; |
13
|
|
|
protected $variation; |
14
|
|
|
protected $params; |
15
|
|
|
protected $semElement; |
16
|
|
|
|
17
|
|
|
public function __construct($semElement,$title="",$content="",$variation=NULL,$params=array()){ |
18
|
|
|
$this->semElement=$semElement; |
19
|
|
|
$this->title=$title; |
20
|
|
|
$this->content=$content; |
21
|
|
|
$this->setAttributes($variation,$params); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function setHtml($html) { |
25
|
|
|
$this->html= $html; |
26
|
|
|
return $this; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function setAttributes($variation=NULL,$params=array()){ |
30
|
|
|
$this->variation=$variation; |
31
|
|
|
$this->params=$params; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function onShow($jsCode){ |
35
|
|
|
$this->params["onShow"]=$jsCode; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function compile(JsUtils $js=NULL){ |
39
|
|
|
if(JString::isNotNull($this->title)){ |
40
|
|
|
$this->semElement->addToProperty("data-title", $this->title); |
41
|
|
|
} |
42
|
|
|
if(JString::isNotNull($this->content)){ |
43
|
|
|
$this->semElement->addToProperty("data-content", $this->content); |
44
|
|
|
} |
45
|
|
|
if(JString::isNotNull($this->html)){ |
46
|
|
|
$html=$this->html; |
47
|
|
|
if(\is_array($html)){ |
48
|
|
|
\array_walk($html, function(&$item) use($js){ |
49
|
|
|
if($item instanceof HtmlSemDoubleElement){ |
50
|
|
|
$comp=$item->compile($js); |
51
|
|
|
if(isset($js)){ |
52
|
|
|
$bs=$item->run($js); |
53
|
|
|
if(isset($bs)) |
54
|
|
|
$this->params['onShow']=$bs->getScript(); |
55
|
|
|
} |
56
|
|
|
$item=$comp; |
57
|
|
|
} |
58
|
|
|
}); |
59
|
|
|
$html=\implode("",$html); |
60
|
|
|
} |
61
|
|
|
$html=\str_replace("\"", "'", $html); |
62
|
|
|
$this->semElement->addToProperty("data-html", $html); |
63
|
|
|
} |
64
|
|
|
if(JString::isNotNull($this->variation)){ |
65
|
|
|
$this->semElement->addToProperty("data-variation", $this->variation); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function run(JsUtils $js){ |
70
|
|
|
$js->semantic()->popup("#".$this->semElement->getIdentifier(),$this->params); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
} |