1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ajax\bootstrap\html\base; |
4
|
|
|
|
5
|
|
|
use Ajax\JsUtils; |
6
|
|
|
use Ajax\bootstrap\html\HtmlBadge; |
7
|
|
|
use Ajax\bootstrap\html\HtmlLabel; |
8
|
|
|
use Ajax\bootstrap\html\HtmlGlyphicon; |
9
|
|
|
|
10
|
|
|
class HtmlDoubleElement extends HtmlSingleElement { |
11
|
|
|
/** |
12
|
|
|
* |
13
|
|
|
* @var mixed |
14
|
|
|
*/ |
15
|
|
|
protected $content; |
16
|
|
|
protected $wrapContentBefore=""; |
17
|
|
|
protected $wrapContentAfter=""; |
18
|
|
|
|
19
|
|
|
public function __construct($identifier, $tagName="p") { |
20
|
|
|
parent::__construct($identifier, $tagName); |
21
|
|
|
$this->_template="<%tagName% id='%identifier%' %properties%>%wrapContentBefore%%content%%wrapContentAfter%</%tagName%>"; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function setContent($content) { |
25
|
|
|
$this->content=$content; |
26
|
|
|
return $this; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function getContent() { |
30
|
|
|
return $this->content; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function addContent($content) { |
34
|
|
|
if (is_array($this->content)===false) { |
35
|
|
|
$newContent=array (); |
36
|
|
|
if (isset($this->content)) |
37
|
|
|
$newContent []=$this->content; |
38
|
|
|
$newContent []=$content; |
39
|
|
|
$this->content=$newContent; |
40
|
|
|
} else { |
41
|
|
|
$this->content []=$content; |
42
|
|
|
} |
43
|
|
|
return $this; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/* |
47
|
|
|
* (non-PHPdoc) |
48
|
|
|
* @see \Ajax\bootstrap\html\HtmlSingleElement::run() |
49
|
|
|
*/ |
50
|
|
|
public function run(JsUtils $js) { |
51
|
|
|
parent::run($js); |
52
|
|
|
if ($this->content instanceof HtmlDoubleElement) { |
53
|
|
|
$this->content->run($js); |
54
|
|
|
} else if (is_array($this->content)) { |
55
|
|
|
foreach ( $this->content as $itemContent ) { |
56
|
|
|
if ($itemContent instanceof HtmlDoubleElement) { |
57
|
|
|
$itemContent->run($js); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function addBadge($caption, $leftSeparator=" ") { |
64
|
|
|
$badge=new HtmlBadge("badge-".$this->identifier, $caption); |
65
|
|
|
$badge->wrap($leftSeparator); |
66
|
|
|
$this->addContent($badge); |
67
|
|
|
return $this; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function addLabel($caption, $style="label-default", $leftSeparator=" ") { |
71
|
|
|
$label=new HtmlLabel("label-".$this->identifier, $caption, $style); |
72
|
|
|
$label->wrap($leftSeparator); |
73
|
|
|
$this->addContent($label); |
74
|
|
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function addGlyph($glyphicon,$index=0){ |
78
|
|
|
$glyph=new HtmlGlyphicon(""); |
79
|
|
|
$glyph->setGlyphicon($glyphicon); |
80
|
|
|
$this->addContent($glyph); |
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function setValue($value) { |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function wrapContent($before, $after="") { |
88
|
|
|
$this->wrapContentBefore.=$before; |
89
|
|
|
$this->wrapContentAfter=$after.$this->wrapContentAfter; |
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function wrapContentWithGlyph($glyphBefore,$glyphAfter=""){ |
94
|
|
|
$before=HtmlGlyphicon::getGlyphicon($glyphBefore)." "; |
95
|
|
|
$after=""; |
96
|
|
|
if($glyphAfter!==""){ |
97
|
|
|
$after=" ".HtmlGlyphicon::getGlyphicon($glyphAfter); |
98
|
|
|
} |
99
|
|
|
return $this->wrapContent($before,$after); |
100
|
|
|
} |
101
|
|
|
} |