77use Ajax \semantic \widgets \datatable \PositionInTable ;
88use Ajax \semantic \html \collections \menus \HtmlMenu ;
99use Ajax \semantic \widgets \base \FieldAsTrait ;
10+ use Ajax \semantic \html \elements \HtmlButtonGroups ;
1011
1112abstract class Widget extends HtmlDoubleElement {
1213 use FieldAsTrait;
@@ -114,7 +115,7 @@ public function setIdentifierFunction($callback){
114115 public function getToolbar (){
115116 if (isset ($ this ->_toolbar )===false ){
116117 $ this ->_toolbar =new HtmlMenu ("toolbar- " .$ this ->identifier );
117- $ this ->_toolbar ->setSecondary ();
118+ // $this->_toolbar->setSecondary();
118119 }
119120 return $ this ->_toolbar ;
120121 }
@@ -135,8 +136,8 @@ public function addInToolbar($element,$callback=NULL){
135136 return $ tb ->addItem ($ element );
136137 }
137138
138- public function addItemInToolbar ($ caption ,$ icon =NULL ){
139- $ result =$ this ->addInToolbar ($ caption );
139+ public function addItemInToolbar ($ caption ,$ icon =NULL , $ callback = NULL ){
140+ $ result =$ this ->addInToolbar ($ caption, $ callback );
140141 $ result ->addIcon ($ icon );
141142 return $ result ;
142143 }
@@ -146,9 +147,25 @@ public function addButtonInToolbar($caption,$callback=NULL){
146147 return $ this ->addInToolbar ($ bt ,$ callback );
147148 }
148149
150+ public function addButtonsInToolbar (array $ captions ,$ asIcon =false ,$ callback =NULL ){
151+ $ bts =new HtmlButtonGroups ("" ,$ captions ,$ asIcon );
152+ return $ this ->addInToolbar ($ bts ,$ callback );
153+ }
154+
149155 public function addLabelledIconButtonInToolbar ($ caption ,$ icon ,$ before =true ,$ labeled =false ){
150156 $ bt =new HtmlButton ("" ,$ caption );
151157 $ bt ->addIcon ($ icon ,$ before ,$ labeled );
152158 return $ this ->addInToolbar ($ bt );
153159 }
160+
161+ /**
162+ * Defines a callback function to call for modifying captions
163+ * function parameters are $captions: the captions to modify and $instance: the active model instance
164+ * @param callable $captionCallback
165+ * @return Widget
166+ */
167+ public function setCaptionCallback ($ captionCallback ) {
168+ $ this ->_instanceViewer ->setCaptionCallback ($ captionCallback );
169+ return $ this ;
170+ }
154171}
0 commit comments