6
6
use Ajax \semantic \html \content \HtmlListItem ;
7
7
use Ajax \semantic \html \collections \form \HtmlFormCheckbox ;
8
8
use Ajax \JsUtils ;
9
+ use Ajax \semantic \html \modules \checkbox \AbstractCheckbox ;
9
10
10
11
class HtmlList extends HtmlSemCollection {
11
12
protected $ _hasCheckedList ;
@@ -47,6 +48,13 @@ public function addList($items=array()) {
47
48
return $ this ->addItem ($ list );
48
49
}
49
50
51
+ protected function getItemToAdd ($ item ){
52
+ $ itemO =parent ::getItemToAdd ($ item );
53
+ if ($ itemO instanceof AbstractCheckbox)
54
+ $ itemO ->addClass ("item " );
55
+ return $ itemO ;
56
+ }
57
+
50
58
public function setCelled () {
51
59
return $ this ->addToProperty ("class " , "celled " );
52
60
}
@@ -84,11 +92,31 @@ public function setHorizontal() {
84
92
return $ this ->addToProperty ("class " , "horizontal " );
85
93
}
86
94
87
- public function addCheckedList ($ items =array (), $ masterItem =NULL , $ values =array ()) {
95
+ /**
96
+ * Adds a grouped checked box to the list
97
+ * @param array $items
98
+ * @param string|array|null $masterItem
99
+ * @param array|null $values
100
+ * @param string $notAllChecked
101
+ * @return HtmlList
102
+ */
103
+ public function addCheckedList ($ items =array (), $ masterItem =NULL , $ values =array (),$ notAllChecked =false ) {
88
104
$ count =$ this ->count ();
89
105
$ identifier =$ this ->identifier . "- " . $ count ;
90
106
if (isset ($ masterItem )) {
91
- $ masterO =new HtmlFormCheckbox ("master- " . $ identifier , $ masterItem );
107
+ if (\is_array ($ masterItem )){
108
+ $ masterO =new HtmlFormCheckbox ("master- " . $ identifier , @$ masterItem [0 ],@$ masterItem [1 ]);
109
+ if (isset ($ masterItem [1 ])){
110
+ if (\array_search ($ masterItem [1 ], $ values )!==false ){
111
+ $ masterO ->getDataField ()->setProperty ("checked " , "" );
112
+ }
113
+ }
114
+ }else {
115
+ $ masterO =new HtmlFormCheckbox ("master- " . $ identifier , $ masterItem );
116
+ }
117
+ if ($ notAllChecked ){
118
+ $ masterO ->getDataField ()->addClass ("_notAllChecked " );
119
+ }
92
120
$ masterO ->getHtmlCk ()->addToProperty ("class " , "master " );
93
121
$ masterO ->setClass ("item " );
94
122
$ this ->addItem ($ masterO );
@@ -98,7 +126,7 @@ public function addCheckedList($items=array(), $masterItem=NULL, $values=array()
98
126
foreach ( $ items as $ val => $ caption ) {
99
127
$ itemO =new HtmlFormCheckbox ($ identifier . "- " . $ i ++, $ caption , $ val , "child " );
100
128
if (\array_search ($ val , $ values ) !== false ) {
101
- $ itemO ->getField ()->setProperty ("checked " , "" );
129
+ $ itemO ->getDataField ()->setProperty ("checked " , "" );
102
130
}
103
131
$ itemO ->setClass ("item " );
104
132
$ fields []=$ itemO ;
0 commit comments