phpMv  -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
InternalPopup.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use Ajax\JsUtils;
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;
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->setProperty("data-title", $this->title);
41  }
42  if(JString::isNotNull($this->content)){
43  $this->semElement->setProperty("data-content", $this->content);
44  }
45  $this->_compileHtml($js);
46  if(JString::isNotNull($this->variation)){
47  $this->semElement->setProperty("data-variation", $this->variation);
48  }
49  }
50 
51  private function _compileHtml(JsUtils $js=NULL){
52  if(JString::isNotNull($this->html)){
54  if(\is_array($html)){
55  \array_walk($html, function(&$item) use($js){
56  if($item instanceof HtmlSemDoubleElement){
57  $comp=$item->compile($js);
58  if(isset($js)){
59  $bs=$item->run($js);
60  if(isset($bs))
61  $this->params['onShow']=$bs->getScript();
62  }
63  $item=$comp;
64  }
65  });
66  $html=\implode("",$html);
67  }
68  $html=\str_replace("\"", "'", $html);
69  $this->semElement->addToProperty("data-html", $html);
70  }
71  }
72 
73  public function run(JsUtils $js){
74  $js->semantic()->popup("#".$this->semElement->getIdentifier(),$this->params);
75  }
76 
77 }
static isNotNull($s)
Definition: JString.php:22
semantic(Semantic $semantic=NULL)
getter or setter of the Semantic-UI variable
Definition: JsUtils.php:159
__construct($semElement, $title="", $content="", $variation=NULL, $params=array())
Base class for Semantic double elements.
JQuery PHP library.
Definition: JsUtils.php:23
html($element='this', $value='', $immediatly=false)
Get or set the html of an attribute for the first element in the set of matched elements.
setAttributes($variation=NULL, $params=array())