|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ajax\bootstrap\html; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Twitter Bootstrap HTML Button toolbar |
|
7
|
|
|
* @see http://getbootstrap.com/components/#btn-groups-toolbar |
|
8
|
|
|
* @author jc |
|
9
|
|
|
* @version 1.001 |
|
10
|
|
|
*/ |
|
11
|
|
|
use Ajax\bootstrap\html\HtmlButtongroups; |
|
12
|
|
|
|
|
13
|
|
|
class HtmlButtontoolbar extends HtmlButtongroups { |
|
14
|
|
|
|
|
15
|
|
|
public function __construct($identifier, $elements=array(), $cssStyle=NULL, $size=NULL, $tagName="div") { |
|
16
|
|
|
parent::__construct($identifier, $elements, $cssStyle, $size, $tagName); |
|
17
|
|
|
$this->setClass("btn-toolbar"); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
/* |
|
21
|
|
|
* (non-PHPdoc) |
|
22
|
|
|
* @see \Ajax\bootstrap\html\HtmlButtongroups::addElement() |
|
23
|
|
|
*/ |
|
24
|
|
|
public function addElement($element) { |
|
25
|
|
|
if ($element instanceof HtmlButtongroups) { |
|
26
|
|
|
$this->elements []=$element; |
|
27
|
|
|
} else { |
|
28
|
|
|
$this->getLastButtonGroup()->addElement($element); |
|
29
|
|
|
} |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Add and return a new buttongroup |
|
34
|
|
|
* @return \Ajax\bootstrap\html\HtmlButtongroups |
|
35
|
|
|
*/ |
|
36
|
|
|
public function addGroup() { |
|
37
|
|
|
$nb=sizeof($this->elements); |
|
38
|
|
|
$bg=new HtmlButtongroups($this->identifier."-buttongroups-".$nb); |
|
39
|
|
|
$this->elements []=$bg; |
|
40
|
|
|
return $bg; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* |
|
45
|
|
|
* @return HtmlButtongroups |
|
46
|
|
|
*/ |
|
47
|
|
|
private function getLastButtonGroup() { |
|
48
|
|
|
$nb=sizeof($this->elements); |
|
49
|
|
|
if ($nb>0) |
|
50
|
|
|
$bg=$this->elements [$nb-1]; |
|
|
|
|
|
|
51
|
|
|
else { |
|
52
|
|
|
$bg=new HtmlButtongroups($this->identifier."-buttongroups-".$nb); |
|
53
|
|
|
$this->elements []=$bg; |
|
54
|
|
|
} |
|
55
|
|
|
return $bg; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* return the Buttongroups at position $index |
|
60
|
|
|
* @return \Ajax\bootstrap\html\HtmlButtongroups |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getGroup($index) { |
|
63
|
|
|
return parent::getElement($index); |
|
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function getLastGroup() { |
|
67
|
|
|
$bg=null; |
|
68
|
|
|
$nb=sizeof($this->elements); |
|
69
|
|
|
if ($nb>0) |
|
70
|
|
|
$bg=$this->elements [$nb-1]; |
|
71
|
|
|
return $bg; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/* |
|
75
|
|
|
* (non-PHPdoc) |
|
76
|
|
|
* @see \Ajax\bootstrap\html\HtmlButtongroups::getElement() |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getElement($index) { |
|
79
|
|
|
$element=null; |
|
80
|
|
|
$i=0; |
|
81
|
|
|
if (is_int($index)) { |
|
82
|
|
|
$elements=array (); |
|
83
|
|
|
foreach ( $this->elements as $group ) { |
|
84
|
|
|
$elements=array_merge($elements, $group->getElements()); |
|
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
if ($index<sizeof($elements)) { |
|
87
|
|
|
$element=$elements [$index]; |
|
88
|
|
|
} |
|
89
|
|
|
} else { |
|
90
|
|
|
while ( $element==null&&$i<sizeof($this->elements) ) { |
|
91
|
|
|
$element=$this->elements [$i]->getElement($index); |
|
|
|
|
|
|
92
|
|
|
$i++; |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
return $element; |
|
96
|
|
|
} |
|
97
|
|
|
} |