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
|
|
|
class InternalPopup { |
9
|
|
|
protected $title; |
10
|
|
|
protected $content; |
11
|
|
|
protected $html; |
12
|
|
|
protected $variation; |
13
|
|
|
protected $params; |
14
|
|
|
protected $semElement; |
15
|
|
|
public function __construct($semElement,$title="",$content="",$variation=NULL,$params=array()){ |
16
|
|
|
$this->semElement=$semElement; |
17
|
|
|
$this->title=$title; |
18
|
|
|
$this->content=$content; |
19
|
|
|
$this->setAttributes($variation,$params); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function setHtml($html) { |
23
|
|
|
$this->html= $html; |
24
|
|
|
return $this; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function setAttributes($variation=NULL,$params=array()){ |
28
|
|
|
$this->variation=$variation; |
29
|
|
|
$this->params=$params; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function onShow($jsCode){ |
33
|
|
|
$this->params["onShow"]=$jsCode; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function compile(JsUtils $js=NULL){ |
37
|
|
|
if(JString::isNotNull($this->title)){ |
38
|
|
|
$this->semElement->addToProperty("data-title", $this->title); |
39
|
|
|
} |
40
|
|
|
if(JString::isNotNull($this->content)){ |
41
|
|
|
$this->semElement->addToProperty("data-content", $this->content); |
42
|
|
|
} |
43
|
|
|
if(JString::isNotNull($this->html)){ |
44
|
|
|
$html=$this->html; |
45
|
|
|
if(\is_array($html)){ |
46
|
|
|
\array_walk($html, function(&$item) use($js){ |
47
|
|
|
if($item instanceof HtmlSemDoubleElement){ |
48
|
|
|
$comp=$item->compile($js); |
49
|
|
|
$bs=$item->run($js); |
|
|
|
|
50
|
|
|
if(isset($bs)) |
51
|
|
|
$this->params['onShow']=$bs->getScript(); |
52
|
|
|
$item=$comp; |
53
|
|
|
} |
54
|
|
|
}); |
55
|
|
|
$html=\implode("",$html); |
56
|
|
|
} |
57
|
|
|
$html=\str_replace("\"", "'", $html); |
58
|
|
|
$this->semElement->addToProperty("data-html", $html); |
59
|
|
|
} |
60
|
|
|
if(JString::isNotNull($this->variation)){ |
61
|
|
|
$this->semElement->addToProperty("data-variation", $this->variation); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function run(JsUtils $js){ |
66
|
|
|
$js->semantic()->popup("#".$this->semElement->getIdentifier(),$this->params); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
} |
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):