@@ -53,6 +53,9 @@ discard block |
||
53 | 53 | $element->setStyle($value); |
54 | 54 | } |
55 | 55 | |
56 | + /** |
|
57 | + * @param HtmlDropdown $bt |
|
58 | + */ |
|
56 | 59 | private function dropdownAsButton($bt) { |
57 | 60 | $this->addExistingDropDown($bt); |
58 | 61 | $bt->setTagName("button"); |
@@ -81,6 +84,9 @@ discard block |
||
81 | 84 | return $result; |
82 | 85 | } |
83 | 86 | |
87 | + /** |
|
88 | + * @param integer $iid |
|
89 | + */ |
|
84 | 90 | private function _addArrayElement(array $element,$iid){ |
85 | 91 | if (array_key_exists("glyph", $element)) |
86 | 92 | $bt=new HtmlGlyphButton($this->identifier."-button-".$iid); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @return HtmlButtongroups default : "" |
40 | 40 | */ |
41 | 41 | public function setSize($size) { |
42 | - foreach ( $this->elements as $element ) { |
|
42 | + foreach ($this->elements as $element) { |
|
43 | 43 | $element->setSize($size); |
44 | 44 | } |
45 | 45 | if (is_int($size)) { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | public function setStyle($value) { |
52 | - foreach ( $this->elements as $element ) |
|
52 | + foreach ($this->elements as $element) |
|
53 | 53 | $element->setStyle($value); |
54 | 54 | } |
55 | 55 | |
@@ -69,29 +69,29 @@ discard block |
||
69 | 69 | public function addElement($element) { |
70 | 70 | $result=$element; |
71 | 71 | $iid=sizeof($this->elements)+1; |
72 | - if (($element instanceof HtmlDropdown)||($element instanceof HtmlSplitbutton)) { |
|
72 | + if (($element instanceof HtmlDropdown) || ($element instanceof HtmlSplitbutton)) { |
|
73 | 73 | $this->addExistingDropDown($element); |
74 | 74 | } elseif (\is_array($element)) { |
75 | - $result=$this->_addArrayElement($element,$iid); |
|
75 | + $result=$this->_addArrayElement($element, $iid); |
|
76 | 76 | } elseif (is_string($element)) { |
77 | - $result=new HtmlButton($this->identifier."-button-".$iid,$element); |
|
77 | + $result=new HtmlButton($this->identifier."-button-".$iid, $element); |
|
78 | 78 | } |
79 | - if($result instanceof HtmlButton) |
|
79 | + if ($result instanceof HtmlButton) |
|
80 | 80 | $this->elements[]=$result; |
81 | 81 | return $result; |
82 | 82 | } |
83 | 83 | |
84 | - private function _addArrayElement(array $element,$iid){ |
|
84 | + private function _addArrayElement(array $element, $iid) { |
|
85 | 85 | if (array_key_exists("glyph", $element)) |
86 | 86 | $bt=new HtmlGlyphButton($this->identifier."-button-".$iid); |
87 | 87 | elseif (array_key_exists("btnCaption", $element)) { |
88 | 88 | if (array_key_exists("split", $element)) |
89 | 89 | $bt=new HtmlSplitbutton($this->identifier."-dropdown-".$iid); |
90 | - else{ |
|
90 | + else { |
|
91 | 91 | $bt=new HtmlDropdown($this->identifier."-dropdown-".$iid); |
92 | 92 | $this->dropdownAsButton($bt); |
93 | 93 | } |
94 | - } else{ |
|
94 | + } else { |
|
95 | 95 | $bt=new HtmlButton($this->identifier."-button-".$iid); |
96 | 96 | $bt->fromArray($element); |
97 | 97 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | public function addElements($elements) { |
102 | - foreach ( $elements as $element ) { |
|
102 | + foreach ($elements as $element) { |
|
103 | 103 | $this->addElement($element); |
104 | 104 | } |
105 | 105 | return $this; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } else |
120 | 120 | $value="btn-group-".$value; |
121 | 121 | if (strstr($value, "justified")) { |
122 | - foreach ( $this->elements as $element ) { |
|
122 | + foreach ($this->elements as $element) { |
|
123 | 123 | $element->wrap('<div class="btn-group" role="group">', '</div>'); |
124 | 124 | } |
125 | 125 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
151 | 151 | */ |
152 | 152 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
153 | - foreach ( $this->elements as $element ) { |
|
153 | + foreach ($this->elements as $element) { |
|
154 | 154 | $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
155 | 155 | } |
156 | 156 | return $this; |
@@ -49,8 +49,9 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | public function setStyle($value) { |
52 | - foreach ( $this->elements as $element ) |
|
53 | - $element->setStyle($value); |
|
52 | + foreach ( $this->elements as $element ) { |
|
53 | + $element->setStyle($value); |
|
54 | + } |
|
54 | 55 | } |
55 | 56 | |
56 | 57 | private function dropdownAsButton($bt) { |
@@ -76,18 +77,19 @@ discard block |
||
76 | 77 | } elseif (is_string($element)) { |
77 | 78 | $result=new HtmlButton($this->identifier."-button-".$iid,$element); |
78 | 79 | } |
79 | - if($result instanceof HtmlButton) |
|
80 | - $this->elements[]=$result; |
|
80 | + if($result instanceof HtmlButton) { |
|
81 | + $this->elements[]=$result; |
|
82 | + } |
|
81 | 83 | return $result; |
82 | 84 | } |
83 | 85 | |
84 | 86 | private function _addArrayElement(array $element,$iid){ |
85 | - if (array_key_exists("glyph", $element)) |
|
86 | - $bt=new HtmlGlyphButton($this->identifier."-button-".$iid); |
|
87 | - elseif (array_key_exists("btnCaption", $element)) { |
|
88 | - if (array_key_exists("split", $element)) |
|
89 | - $bt=new HtmlSplitbutton($this->identifier."-dropdown-".$iid); |
|
90 | - else{ |
|
87 | + if (array_key_exists("glyph", $element)) { |
|
88 | + $bt=new HtmlGlyphButton($this->identifier."-button-".$iid); |
|
89 | + } elseif (array_key_exists("btnCaption", $element)) { |
|
90 | + if (array_key_exists("split", $element)) { |
|
91 | + $bt=new HtmlSplitbutton($this->identifier."-dropdown-".$iid); |
|
92 | + } else{ |
|
91 | 93 | $bt=new HtmlDropdown($this->identifier."-dropdown-".$iid); |
92 | 94 | $this->dropdownAsButton($bt); |
93 | 95 | } |
@@ -116,8 +118,9 @@ discard block |
||
116 | 118 | public function setAlignment($value) { |
117 | 119 | if (is_int($value)) { |
118 | 120 | $value=CssRef::alignment("btn-group")[$value]; |
119 | - } else |
|
120 | - $value="btn-group-".$value; |
|
121 | + } else { |
|
122 | + $value="btn-group-".$value; |
|
123 | + } |
|
121 | 124 | if (strstr($value, "justified")) { |
122 | 125 | foreach ( $this->elements as $element ) { |
123 | 126 | $element->wrap('<div class="btn-group" role="group">', '</div>'); |
@@ -132,9 +135,9 @@ discard block |
||
132 | 135 | * @return HtmlButton |
133 | 136 | */ |
134 | 137 | public function getElement($index) { |
135 | - if (is_int($index)) |
|
136 | - return $this->elements[$index]; |
|
137 | - else { |
|
138 | + if (is_int($index)) { |
|
139 | + return $this->elements[$index]; |
|
140 | + } else { |
|
138 | 141 | $elm=$this->getElementById($index, $this->elements); |
139 | 142 | return $elm; |
140 | 143 | } |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Ajax\service; |
3 | 3 | class JQueryAjaxEffect { |
4 | - public static function none($responseElement,$jqueryDone="html"){ |
|
4 | + public static function none($responseElement, $jqueryDone="html") { |
|
5 | 5 | return "\t$({$responseElement}).{$jqueryDone}( data );\n"; |
6 | 6 | } |
7 | 7 | |
8 | - public static function fade($responseElement,$jqueryDone="html"){ |
|
8 | + public static function fade($responseElement, $jqueryDone="html") { |
|
9 | 9 | return "\t$({$responseElement}).hide().{$jqueryDone}( data ).fadeIn();\n"; |
10 | 10 | } |
11 | 11 | |
12 | - public static function slide($responseElement,$jqueryDone="html"){ |
|
12 | + public static function slide($responseElement, $jqueryDone="html") { |
|
13 | 13 | return "\t$({$responseElement}).hide().{$jqueryDone}( data ).slideDown();\n"; |
14 | 14 | } |
15 | 15 | } |
16 | 16 | \ No newline at end of file |
@@ -58,8 +58,9 @@ discard block |
||
58 | 58 | */ |
59 | 59 | private function getFieldButton($caption,$visibleHover=true){ |
60 | 60 | $bt= new HtmlButton("",$caption); |
61 | - if($visibleHover) |
|
62 | - $this->_visibleOver($bt); |
|
61 | + if($visibleHover) { |
|
62 | + $this->_visibleOver($bt); |
|
63 | + } |
|
63 | 64 | return $bt; |
64 | 65 | } |
65 | 66 | |
@@ -76,8 +77,9 @@ discard block |
||
76 | 77 | return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){ |
77 | 78 | $button=new HtmlButton($id,$value,$cssStyle); |
78 | 79 | $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
79 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
80 | - $this->_visibleOver($button); |
|
80 | + if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) { |
|
81 | + $this->_visibleOver($button); |
|
82 | + } |
|
81 | 83 | return $button; |
82 | 84 | }, $index,$attributes); |
83 | 85 | } |
@@ -136,8 +138,9 @@ discard block |
||
136 | 138 | private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
137 | 139 | $bt=$this->getFieldButton("",$visibleHover); |
138 | 140 | $bt->asIcon($icon); |
139 | - if(isset($class)) |
|
140 | - $bt->addClass($class); |
|
141 | + if(isset($class)) { |
|
142 | + $bt->addClass($class); |
|
143 | + } |
|
141 | 144 | return $bt; |
142 | 145 | } |
143 | 146 |
@@ -13,15 +13,28 @@ discard block |
||
13 | 13 | * @property InstanceViewer $_instanceViewer |
14 | 14 | */ |
15 | 15 | trait DataTableFieldAsTrait{ |
16 | + |
|
17 | + /** |
|
18 | + * @param \Closure $field |
|
19 | + */ |
|
16 | 20 | abstract public function addField($field); |
21 | + |
|
22 | + /** |
|
23 | + * @param integer $index |
|
24 | + * @param \Closure $field |
|
25 | + */ |
|
17 | 26 | abstract public function insertField($index,$field); |
27 | + |
|
28 | + /** |
|
29 | + * @param \Closure $field |
|
30 | + */ |
|
18 | 31 | abstract public function insertInField($index,$field); |
19 | 32 | abstract public function fieldAs($index,$type,$attributes=NULL); |
20 | 33 | /** |
21 | 34 | * @param string $caption |
22 | 35 | * @param callable $callback |
23 | 36 | * @param boolean $visibleHover |
24 | - * @return callable |
|
37 | + * @return \Closure |
|
25 | 38 | */ |
26 | 39 | private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
27 | 40 | return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
@@ -31,7 +44,7 @@ discard block |
||
31 | 44 | * @param callable $thisCallback |
32 | 45 | * @param array $parameters |
33 | 46 | * @param callable $callback |
34 | - * @return callable |
|
47 | + * @return \Closure |
|
35 | 48 | */ |
36 | 49 | private function getCallable($thisCallback,$parameters,$callback=null){ |
37 | 50 | $result=function($instance) use($thisCallback,$parameters,$callback){ |
@@ -83,6 +96,9 @@ discard block |
||
83 | 96 | }, $index,$attributes); |
84 | 97 | } |
85 | 98 | |
99 | + /** |
|
100 | + * @param HtmlButton $element |
|
101 | + */ |
|
86 | 102 | protected function _visibleOver($element){ |
87 | 103 | $this->_visibleHover=true; |
88 | 104 | return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;"); |
@@ -93,7 +109,7 @@ discard block |
||
93 | 109 | * @param string $caption |
94 | 110 | * @param callable $callback |
95 | 111 | * @param boolean $visibleHover |
96 | - * @return \Ajax\semantic\widgets\datatable\DataTable |
|
112 | + * @return DataTableFieldAsTrait |
|
97 | 113 | */ |
98 | 114 | public function addFieldButton($caption,$visibleHover=true,$callback=null){ |
99 | 115 | $this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback)); |
@@ -105,7 +121,7 @@ discard block |
||
105 | 121 | * @param int $index |
106 | 122 | * @param string $caption |
107 | 123 | * @param callable $callback |
108 | - * @return \Ajax\semantic\widgets\datatable\DataTable |
|
124 | + * @return DataTableFieldAsTrait |
|
109 | 125 | */ |
110 | 126 | public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
111 | 127 | $this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
@@ -117,18 +133,26 @@ discard block |
||
117 | 133 | * @param int $index |
118 | 134 | * @param string $caption |
119 | 135 | * @param callable $callback |
120 | - * @return \Ajax\semantic\widgets\datatable\DataTable |
|
136 | + * @return DataTableFieldAsTrait |
|
121 | 137 | */ |
122 | 138 | public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
123 | 139 | $this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
124 | 140 | return $this; |
125 | 141 | } |
126 | 142 | |
143 | + /** |
|
144 | + * @param string $icon |
|
145 | + * @param string $class |
|
146 | + */ |
|
127 | 147 | private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){ |
128 | 148 | $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
129 | 149 | return $this; |
130 | 150 | } |
131 | 151 | |
152 | + /** |
|
153 | + * @param string $icon |
|
154 | + * @param string $class |
|
155 | + */ |
|
132 | 156 | private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){ |
133 | 157 | $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
134 | 158 | return $this; |
@@ -146,7 +170,7 @@ discard block |
||
146 | 170 | * @param boolean $visibleHover |
147 | 171 | * @param array $deleteBehavior |
148 | 172 | * @param callable $callback |
149 | - * @return DataTable |
|
173 | + * @return DataTableFieldAsTrait |
|
150 | 174 | */ |
151 | 175 | public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){ |
152 | 176 | $this->_deleteBehavior=$deleteBehavior; |
@@ -12,19 +12,19 @@ discard block |
||
12 | 12 | * @property boolean $_visibleHover |
13 | 13 | * @property InstanceViewer $_instanceViewer |
14 | 14 | */ |
15 | -trait DataTableFieldAsTrait{ |
|
15 | +trait DataTableFieldAsTrait { |
|
16 | 16 | abstract public function addField($field); |
17 | - abstract public function insertField($index,$field); |
|
18 | - abstract public function insertInField($index,$field); |
|
19 | - abstract public function fieldAs($index,$type,$attributes=NULL); |
|
17 | + abstract public function insertField($index, $field); |
|
18 | + abstract public function insertInField($index, $field); |
|
19 | + abstract public function fieldAs($index, $type, $attributes=NULL); |
|
20 | 20 | /** |
21 | 21 | * @param string $caption |
22 | 22 | * @param callable $callback |
23 | 23 | * @param boolean $visibleHover |
24 | 24 | * @return callable |
25 | 25 | */ |
26 | - private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
|
27 | - return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
|
26 | + private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) { |
|
27 | + return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -33,19 +33,19 @@ discard block |
||
33 | 33 | * @param callable $callback |
34 | 34 | * @return callable |
35 | 35 | */ |
36 | - private function getCallable($thisCallback,$parameters,$callback=null){ |
|
37 | - $result=function($instance) use($thisCallback,$parameters,$callback){ |
|
38 | - $object=call_user_func_array(array($this,$thisCallback), $parameters); |
|
39 | - if(isset($callback)){ |
|
40 | - if(\is_callable($callback)){ |
|
41 | - $callback($object,$instance); |
|
36 | + private function getCallable($thisCallback, $parameters, $callback=null) { |
|
37 | + $result=function($instance) use($thisCallback, $parameters, $callback){ |
|
38 | + $object=call_user_func_array(array($this, $thisCallback), $parameters); |
|
39 | + if (isset($callback)) { |
|
40 | + if (\is_callable($callback)) { |
|
41 | + $callback($object, $instance); |
|
42 | 42 | } |
43 | 43 | } |
44 | - if($object instanceof HtmlSemDoubleElement){ |
|
45 | - $object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier()); |
|
46 | - if($object->propertyContains("class","visibleover")){ |
|
44 | + if ($object instanceof HtmlSemDoubleElement) { |
|
45 | + $object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier()); |
|
46 | + if ($object->propertyContains("class", "visibleover")) { |
|
47 | 47 | $this->_visibleHover=true; |
48 | - $object->setProperty("style","visibility:hidden;"); |
|
48 | + $object->setProperty("style", "visibility:hidden;"); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | return $object; |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * @param string $caption |
58 | 58 | * @return HtmlButton |
59 | 59 | */ |
60 | - private function getFieldButton($caption,$visibleHover=true){ |
|
61 | - $bt= new HtmlButton("",$caption); |
|
62 | - if($visibleHover) |
|
60 | + private function getFieldButton($caption, $visibleHover=true) { |
|
61 | + $bt=new HtmlButton("", $caption); |
|
62 | + if ($visibleHover) |
|
63 | 63 | $this->_visibleOver($bt); |
64 | 64 | return $bt; |
65 | 65 | } |
@@ -73,19 +73,19 @@ discard block |
||
73 | 73 | * @param array $attributes associative array (<b>ajax</b> key is for ajax post) |
74 | 74 | * @return \Ajax\semantic\widgets\datatable\DataTable |
75 | 75 | */ |
76 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
77 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){ |
|
78 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
79 | - $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
|
80 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
76 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
77 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $index, $attributes){ |
|
78 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
79 | + $button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement, $attributes["ajax"]); |
|
80 | + if (!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
81 | 81 | $this->_visibleOver($button); |
82 | 82 | return $button; |
83 | - }, $index,$attributes); |
|
83 | + }, $index, $attributes); |
|
84 | 84 | } |
85 | 85 | |
86 | - protected function _visibleOver($element){ |
|
86 | + protected function _visibleOver($element) { |
|
87 | 87 | $this->_visibleHover=true; |
88 | - return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;"); |
|
88 | + return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;"); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | * @param boolean $visibleHover |
96 | 96 | * @return \Ajax\semantic\widgets\datatable\DataTable |
97 | 97 | */ |
98 | - public function addFieldButton($caption,$visibleHover=true,$callback=null){ |
|
99 | - $this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback)); |
|
98 | + public function addFieldButton($caption, $visibleHover=true, $callback=null) { |
|
99 | + $this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback)); |
|
100 | 100 | return $this; |
101 | 101 | } |
102 | 102 | |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | * @param callable $callback |
108 | 108 | * @return \Ajax\semantic\widgets\datatable\DataTable |
109 | 109 | */ |
110 | - public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
111 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
110 | + public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
111 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
112 | 112 | return $this; |
113 | 113 | } |
114 | 114 | |
@@ -119,25 +119,25 @@ discard block |
||
119 | 119 | * @param callable $callback |
120 | 120 | * @return \Ajax\semantic\widgets\datatable\DataTable |
121 | 121 | */ |
122 | - public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
123 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
122 | + public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
123 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
124 | 124 | return $this; |
125 | 125 | } |
126 | 126 | |
127 | - private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){ |
|
128 | - $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
|
127 | + private function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null) { |
|
128 | + $this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback)); |
|
129 | 129 | return $this; |
130 | 130 | } |
131 | 131 | |
132 | - private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){ |
|
133 | - $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
|
132 | + private function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null) { |
|
133 | + $this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback)); |
|
134 | 134 | return $this; |
135 | 135 | } |
136 | 136 | |
137 | - private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
|
138 | - $bt=$this->getFieldButton("",$visibleHover); |
|
137 | + private function getDefaultButton($icon, $class=null, $visibleHover=true) { |
|
138 | + $bt=$this->getFieldButton("", $visibleHover); |
|
139 | 139 | $bt->asIcon($icon); |
140 | - if(isset($class)) |
|
140 | + if (isset($class)) |
|
141 | 141 | $bt->addClass($class); |
142 | 142 | return $bt; |
143 | 143 | } |
@@ -148,30 +148,30 @@ discard block |
||
148 | 148 | * @param callable $callback |
149 | 149 | * @return DataTable |
150 | 150 | */ |
151 | - public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
151 | + public function addDeleteButton($visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
152 | 152 | $this->_deleteBehavior=$deleteBehavior; |
153 | - return $this->addDefaultButton("remove","_delete red basic",$visibleHover,$callback); |
|
153 | + return $this->addDefaultButton("remove", "_delete red basic", $visibleHover, $callback); |
|
154 | 154 | } |
155 | 155 | |
156 | - public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){ |
|
156 | + public function addEditButton($visibleHover=true, $editBehavior=[], $callback=null) { |
|
157 | 157 | $this->_editBehavior=$editBehavior; |
158 | - return $this->addDefaultButton("edit","_edit basic",$visibleHover,$callback); |
|
158 | + return $this->addDefaultButton("edit", "_edit basic", $visibleHover, $callback); |
|
159 | 159 | } |
160 | 160 | |
161 | - public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEdit=null,$callbackDelete=null){ |
|
162 | - $this->addEditButton($visibleHover,$behavior,$callbackEdit); |
|
161 | + public function addEditDeleteButtons($visibleHover=true, $behavior=[], $callbackEdit=null, $callbackDelete=null) { |
|
162 | + $this->addEditButton($visibleHover, $behavior, $callbackEdit); |
|
163 | 163 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
164 | - $this->insertDeleteButtonIn($index,$visibleHover,$behavior,$callbackDelete); |
|
164 | + $this->insertDeleteButtonIn($index, $visibleHover, $behavior, $callbackDelete); |
|
165 | 165 | return $this; |
166 | 166 | } |
167 | 167 | |
168 | - public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
168 | + public function insertDeleteButtonIn($index, $visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
169 | 169 | $this->_deleteBehavior=$deleteBehavior; |
170 | - return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback); |
|
170 | + return $this->insertDefaultButtonIn($index, "remove", "_delete red basic", $visibleHover, $callback); |
|
171 | 171 | } |
172 | 172 | |
173 | - public function insertEditButtonIn($index,$visibleHover=true,$editBehavior=[],$callback=null){ |
|
173 | + public function insertEditButtonIn($index, $visibleHover=true, $editBehavior=[], $callback=null) { |
|
174 | 174 | $this->_editBehavior=$editBehavior; |
175 | - return $this->insertDefaultButtonIn($index,"edit","_edit basic",$visibleHover,$callback); |
|
175 | + return $this->insertDefaultButtonIn($index, "edit", "_edit basic", $visibleHover, $callback); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | \ No newline at end of file |
@@ -3,26 +3,26 @@ |
||
3 | 3 | use Ajax\semantic\html\base\constants\Transition; |
4 | 4 | |
5 | 5 | class AjaxTransition { |
6 | - public static function none($responseElement,$jqueryDone="html"){ |
|
6 | + public static function none($responseElement, $jqueryDone="html") { |
|
7 | 7 | return "$({$responseElement}).{$jqueryDone}( data )"; |
8 | 8 | } |
9 | 9 | |
10 | - public static function jqFade($responseElement,$jqueryDone="html"){ |
|
10 | + public static function jqFade($responseElement, $jqueryDone="html") { |
|
11 | 11 | return "$({$responseElement}).hide().{$jqueryDone}( data ).fadeIn()"; |
12 | 12 | } |
13 | 13 | |
14 | - public static function jqSlide($responseElement,$jqueryDone="html"){ |
|
14 | + public static function jqSlide($responseElement, $jqueryDone="html") { |
|
15 | 15 | return "$({$responseElement}).hide().{$jqueryDone}( data ).slideDown()"; |
16 | 16 | } |
17 | 17 | |
18 | - public static function random($responseElement,$jqueryDone="html"){ |
|
18 | + public static function random($responseElement, $jqueryDone="html") { |
|
19 | 19 | $transitions=Transition::getConstantValues(); |
20 | - $transition=$transitions[\rand(0,\sizeof($transitions)-1)]; |
|
21 | - return self::__callStatic($transition, [$responseElement,$jqueryDone]); |
|
20 | + $transition=$transitions[\rand(0, \sizeof($transitions)-1)]; |
|
21 | + return self::__callStatic($transition, [$responseElement, $jqueryDone]); |
|
22 | 22 | } |
23 | 23 | |
24 | - public static function __callStatic($name, $arguments){ |
|
25 | - if(\sizeof($arguments)==2){ |
|
24 | + public static function __callStatic($name, $arguments) { |
|
25 | + if (\sizeof($arguments)==2) { |
|
26 | 26 | $responseElement=$arguments[0]; |
27 | 27 | $jqueryDone=$arguments[1]; |
28 | 28 | $name=JString::camelCaseToSeparated($name); |
@@ -3,12 +3,12 @@ |
||
3 | 3 | use Ajax\common\BaseEnum; |
4 | 4 | abstract class Transition extends BaseEnum { |
5 | 5 | const SCALE="scale", |
6 | - FADE="fade",FADE_UP="fadeUp",FADE_DOWN="fadeDown",FADE_LEFT="fadeLeft",FADE_RIGHT="fadeRight", |
|
7 | - HORIZONTAL_FLIP="horizontalFlip",VERTICAL_FLIP="verticalFlip", |
|
6 | + FADE="fade", FADE_UP="fadeUp", FADE_DOWN="fadeDown", FADE_LEFT="fadeLeft", FADE_RIGHT="fadeRight", |
|
7 | + HORIZONTAL_FLIP="horizontalFlip", VERTICAL_FLIP="verticalFlip", |
|
8 | 8 | DROP="drop", |
9 | - FLY_LEFT="flyLeft",FLY_RIGHT="flyRight",FLY_UP="flyUp",FLY_DOWN="flyDown", |
|
10 | - SWING_LEFT="swingLeft",SWING_RIGHT="swingRight",SWING_UP="swingUp",SWING_DOWN="swingDown", |
|
11 | - BROWSE="browse",BROWSE_RIGHT="browseRight", |
|
12 | - SLIDE_LEFT="slideLeft",SLIDE_RIGHT="slideRight",SLIDE_UP="slideUp",SLIDE_DOWN="slideDown", |
|
13 | - JIGGLE="jiggle",FLASH="flash",SHAKE="shake",PULSE="pulse",TADA="tada",BOUNCE="bounce"; |
|
9 | + FLY_LEFT="flyLeft", FLY_RIGHT="flyRight", FLY_UP="flyUp", FLY_DOWN="flyDown", |
|
10 | + SWING_LEFT="swingLeft", SWING_RIGHT="swingRight", SWING_UP="swingUp", SWING_DOWN="swingDown", |
|
11 | + BROWSE="browse", BROWSE_RIGHT="browseRight", |
|
12 | + SLIDE_LEFT="slideLeft", SLIDE_RIGHT="slideRight", SLIDE_UP="slideUp", SLIDE_DOWN="slideDown", |
|
13 | + JIGGLE="jiggle", FLASH="flash", SHAKE="shake", PULSE="pulse", TADA="tada", BOUNCE="bounce"; |
|
14 | 14 | } |
15 | 15 | \ No newline at end of file |
@@ -1,39 +1,39 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Ajax\php\ci; |
3 | 3 | |
4 | -class JsUtils extends \Ajax\JsUtils{ |
|
4 | +class JsUtils extends \Ajax\JsUtils { |
|
5 | 5 | protected $ci; |
6 | - protected $_my_controller_paths= array(); |
|
7 | - protected $_my_controllers= array(); |
|
6 | + protected $_my_controller_paths=array(); |
|
7 | + protected $_my_controllers=array(); |
|
8 | 8 | |
9 | - public function __construct($params=array(),$injected=NULL){ |
|
10 | - parent::__construct($params,$injected); |
|
11 | - $this->_my_controller_paths = array(APPPATH); |
|
9 | + public function __construct($params=array(), $injected=NULL) { |
|
10 | + parent::__construct($params, $injected); |
|
11 | + $this->_my_controller_paths=array(APPPATH); |
|
12 | 12 | } |
13 | - public function getUrl($url){ |
|
13 | + public function getUrl($url) { |
|
14 | 14 | return site_url($url); |
15 | 15 | } |
16 | 16 | |
17 | - public function getCi(){ |
|
18 | - if(isset($this->ci)===false){ |
|
19 | - $this->ci =& get_instance(); |
|
17 | + public function getCi() { |
|
18 | + if (isset($this->ci)===false) { |
|
19 | + $this->ci=& get_instance(); |
|
20 | 20 | $this->ci->load->helper('url'); |
21 | 21 | } |
22 | 22 | return $this->ci; |
23 | 23 | } |
24 | 24 | |
25 | - public function addViewElement($identifier,$content,&$view){ |
|
26 | - if(\array_key_exists("q", $view)===false){ |
|
25 | + public function addViewElement($identifier, $content, &$view) { |
|
26 | + if (\array_key_exists("q", $view)===false) { |
|
27 | 27 | $view["q"]=array(); |
28 | 28 | } |
29 | 29 | $view["q"][$identifier]=$content; |
30 | 30 | } |
31 | 31 | |
32 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
32 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
33 | 33 | $view[$view_var]=$output; |
34 | 34 | } |
35 | 35 | |
36 | - public function forward($initialControllerInstance,$controllerName,$actionName,$params=NULL){ |
|
36 | + public function forward($initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
37 | 37 | $ci=$this->getCi(); |
38 | 38 | $controllerName=strtolower($controllerName); |
39 | 39 | $this->controller($controllerName); |
@@ -44,64 +44,64 @@ discard block |
||
44 | 44 | return $result; |
45 | 45 | } |
46 | 46 | |
47 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
47 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
48 | 48 | return $initialControllerInstance->load->view($viewName, $params, true); |
49 | 49 | } |
50 | 50 | |
51 | - public function fromDispatcher($dispatcher){ |
|
51 | + public function fromDispatcher($dispatcher) { |
|
52 | 52 | return array_values($dispatcher->uri->segment_array()); |
53 | 53 | } |
54 | 54 | |
55 | - public function controller($controller, $name = '', $db_conn = FALSE){ |
|
56 | - if (\is_array($controller)){ |
|
57 | - foreach ($controller as $babe){ |
|
55 | + public function controller($controller, $name='', $db_conn=FALSE) { |
|
56 | + if (\is_array($controller)) { |
|
57 | + foreach ($controller as $babe) { |
|
58 | 58 | $this->controller($babe); |
59 | 59 | } |
60 | 60 | return; |
61 | 61 | } |
62 | - if ($controller == ''){ |
|
62 | + if ($controller=='') { |
|
63 | 63 | return; |
64 | 64 | } |
65 | - $path = ''; |
|
65 | + $path=''; |
|
66 | 66 | // Is the controller in a sub-folder? If so, parse out the filename and path. |
67 | - if (($last_slash = strrpos($controller, '/')) !== FALSE){ |
|
67 | + if (($last_slash=strrpos($controller, '/'))!==FALSE) { |
|
68 | 68 | // The path is in front of the last slash |
69 | - $path = substr($controller, 0, $last_slash + 1); |
|
69 | + $path=substr($controller, 0, $last_slash+1); |
|
70 | 70 | // And the controller name behind it |
71 | - $controller = substr($controller, $last_slash + 1); |
|
71 | + $controller=substr($controller, $last_slash+1); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ($name == ''){ |
|
75 | - $name = $controller; |
|
74 | + if ($name=='') { |
|
75 | + $name=$controller; |
|
76 | 76 | } |
77 | 77 | |
78 | - if (in_array($name, $this->_my_controllers, TRUE)){ |
|
78 | + if (in_array($name, $this->_my_controllers, TRUE)) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
82 | - $CI =$this->getCi(); |
|
83 | - if (isset($CI->$name)){ |
|
82 | + $CI=$this->getCi(); |
|
83 | + if (isset($CI->$name)) { |
|
84 | 84 | show_error('The controller name you are loading is the name of a resource that is already being used: '.$name); |
85 | 85 | } |
86 | - $controller = strtolower($controller); |
|
87 | - foreach ($this->_my_controller_paths as $mod_path){ |
|
88 | - if ( ! file_exists($mod_path.'controllers/'.$path.$controller.'.php')){ |
|
86 | + $controller=strtolower($controller); |
|
87 | + foreach ($this->_my_controller_paths as $mod_path) { |
|
88 | + if (!file_exists($mod_path.'controllers/'.$path.$controller.'.php')) { |
|
89 | 89 | continue; |
90 | 90 | } |
91 | - if ($db_conn !== FALSE && ! class_exists('CI_DB')){ |
|
92 | - if ($db_conn === TRUE){ |
|
93 | - $db_conn = ''; |
|
91 | + if ($db_conn!==FALSE && !class_exists('CI_DB')) { |
|
92 | + if ($db_conn===TRUE) { |
|
93 | + $db_conn=''; |
|
94 | 94 | } |
95 | 95 | $CI->load->database($db_conn, FALSE, TRUE); |
96 | 96 | } |
97 | - if ( ! class_exists('CI_Controller')){ |
|
97 | + if (!class_exists('CI_Controller')) { |
|
98 | 98 | load_class('Controller', 'core'); |
99 | 99 | } |
100 | 100 | require_once($mod_path.'controllers/'.$path.$controller.'.php'); |
101 | - $controller = ucfirst($controller); |
|
102 | - $CI->$name = new $controller(); |
|
101 | + $controller=ucfirst($controller); |
|
102 | + $CI->$name=new $controller(); |
|
103 | 103 | |
104 | - $this->_my_controllers[] = $name; |
|
104 | + $this->_my_controllers[]=$name; |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | show_error('Unable to locate the controller you have specified: '.$controller); |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | |
49 | 49 | public function setAttached($value=true){ |
50 | 50 | $form=$this->getForm(); |
51 | - if($value) |
|
52 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
51 | + if($value) { |
|
52 | + $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
53 | + } |
|
53 | 54 | return $form; |
54 | 55 | } |
55 | 56 | |
@@ -91,8 +92,9 @@ discard block |
||
91 | 92 | if(isset($url) && isset($responseElement)){ |
92 | 93 | $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true); |
93 | 94 | $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true]; |
94 | - if(\is_array($parameters)) |
|
95 | - $params=\array_merge($params,$parameters); |
|
95 | + if(\is_array($parameters)) { |
|
96 | + $params=\array_merge($params,$parameters); |
|
97 | + } |
|
96 | 98 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
97 | 99 | } |
98 | 100 | return $button; |
@@ -12,28 +12,28 @@ discard block |
||
12 | 12 | * @author jc |
13 | 13 | * |
14 | 14 | */ |
15 | -trait FormTrait{ |
|
15 | +trait FormTrait { |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @return HtmlForm |
19 | 19 | */ |
20 | 20 | abstract protected function getForm(); |
21 | 21 | |
22 | - protected function addCompoValidation($compo,$field){ |
|
22 | + protected function addCompoValidation($compo, $field) { |
|
23 | 23 | $validation=$field->getValidation(); |
24 | - if(isset($validation)){ |
|
24 | + if (isset($validation)) { |
|
25 | 25 | $validation->setIdentifier($field->getDataField()->getIdentifier()); |
26 | 26 | $compo->addFieldValidation($validation); |
27 | 27 | } |
28 | 28 | return $compo; |
29 | 29 | } |
30 | 30 | |
31 | - protected function _runValidationParams(&$compo,JsUtils $js=NULL){ |
|
31 | + protected function _runValidationParams(&$compo, JsUtils $js=NULL) { |
|
32 | 32 | $form=$this->getForm(); |
33 | 33 | $params=$form->getValidationParams(); |
34 | - if(isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall){ |
|
34 | + if (isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall) { |
|
35 | 35 | $compilation=$params["_ajaxSubmit"]->compile($js); |
36 | - $compilation=str_ireplace("\"","%quote%", $compilation); |
|
36 | + $compilation=str_ireplace("\"", "%quote%", $compilation); |
|
37 | 37 | $this->onSuccess($compilation); |
38 | 38 | $form->removeValidationParam("_ajaxSubmit"); |
39 | 39 | } |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | return $this; |
52 | 52 | } |
53 | 53 | |
54 | - public function setAttached($value=true){ |
|
54 | + public function setAttached($value=true) { |
|
55 | 55 | $form=$this->getForm(); |
56 | - if($value) |
|
57 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
56 | + if ($value) |
|
57 | + $form->addToPropertyCtrl("class", "attached", array("attached")); |
|
58 | 58 | return $form; |
59 | 59 | } |
60 | 60 | |
61 | - public function addErrorMessage(){ |
|
61 | + public function addErrorMessage() { |
|
62 | 62 | return $this->getForm()->addContent((new HtmlMessage(""))->setError()); |
63 | 63 | } |
64 | 64 | |
@@ -73,38 +73,38 @@ discard block |
||
73 | 73 | * @param string $responseElement |
74 | 74 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
75 | 75 | */ |
76 | - public function submitOn($event,$identifier,$url,$responseElement){ |
|
76 | + public function submitOn($event, $identifier, $url, $responseElement) { |
|
77 | 77 | $form=$this->getForm(); |
78 | 78 | $elem=$form->getElementById($identifier, $form->getContent()); |
79 | - if(isset($elem)){ |
|
80 | - $this->_buttonAsSubmit($elem, $event,$url,$responseElement); |
|
79 | + if (isset($elem)) { |
|
80 | + $this->_buttonAsSubmit($elem, $event, $url, $responseElement); |
|
81 | 81 | } |
82 | 82 | return $form; |
83 | 83 | } |
84 | 84 | |
85 | - public function submitOnClick($identifier,$url,$responseElement){ |
|
85 | + public function submitOnClick($identifier, $url, $responseElement) { |
|
86 | 86 | return $this->submitOn("click", $identifier, $url, $responseElement); |
87 | 87 | } |
88 | 88 | |
89 | - public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){ |
|
90 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
91 | - return $this->_buttonAsSubmit($bt, "click",$url,$responseElement); |
|
89 | + public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) { |
|
90 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
91 | + return $this->_buttonAsSubmit($bt, "click", $url, $responseElement); |
|
92 | 92 | } |
93 | 93 | |
94 | - protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL){ |
|
94 | + protected function _buttonAsSubmit(HtmlButton&$button, $event, $url, $responseElement=NULL, $parameters=NULL) { |
|
95 | 95 | $form=$this->getForm(); |
96 | - if(isset($url) && isset($responseElement)){ |
|
97 | - $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true); |
|
98 | - $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true]; |
|
99 | - if(\is_array($parameters)) |
|
100 | - $params=\array_merge($params,$parameters); |
|
96 | + if (isset($url) && isset($responseElement)) { |
|
97 | + $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');", true, true); |
|
98 | + $params=["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url, "stopPropagation"=>true]; |
|
99 | + if (\is_array($parameters)) |
|
100 | + $params=\array_merge($params, $parameters); |
|
101 | 101 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
102 | 102 | } |
103 | 103 | return $button; |
104 | 104 | } |
105 | 105 | |
106 | - public function addReset($identifier,$value,$cssStyle=NULL){ |
|
107 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
106 | + public function addReset($identifier, $value, $cssStyle=NULL) { |
|
107 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
108 | 108 | $bt->setProperty("type", "reset"); |
109 | 109 | return $bt; |
110 | 110 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param string $jsCode |
115 | 115 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
116 | 116 | */ |
117 | - public function onValid($jsCode){ |
|
117 | + public function onValid($jsCode) { |
|
118 | 118 | $form=$this->getForm(); |
119 | 119 | $form->addValidationParam("onValid", "%function(){".$jsCode."}%"); |
120 | 120 | return $form; |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @param string $jsCode can use event and fields parameters |
126 | 126 | * @return HtmlForm |
127 | 127 | */ |
128 | - public function onSuccess($jsCode){ |
|
128 | + public function onSuccess($jsCode) { |
|
129 | 129 | $form=$this->getForm(); |
130 | - $form->addValidationParam("onSuccess", $jsCode,"%function(event,fields){","}%"); |
|
130 | + $form->addValidationParam("onSuccess", $jsCode, "%function(event,fields){", "}%"); |
|
131 | 131 | return $form; |
132 | 132 | } |
133 | 133 | } |
134 | 134 | \ No newline at end of file |
@@ -28,9 +28,17 @@ discard block |
||
28 | 28 | trait FieldAsTrait{ |
29 | 29 | |
30 | 30 | abstract protected function _getFieldIdentifier($prefix,$name=""); |
31 | + |
|
32 | + /** |
|
33 | + * @param \Closure $callback |
|
34 | + */ |
|
31 | 35 | abstract public function setValueFunction($index,$callback); |
32 | 36 | abstract protected function _getFieldName($index); |
33 | 37 | abstract protected function _getFieldCaption($index); |
38 | + |
|
39 | + /** |
|
40 | + * @param string $event |
|
41 | + */ |
|
34 | 42 | abstract protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
35 | 43 | |
36 | 44 | /** |
@@ -70,6 +78,9 @@ discard block |
||
70 | 78 | } |
71 | 79 | } |
72 | 80 | |
81 | + /** |
|
82 | + * @param HtmlFormInput $field |
|
83 | + */ |
|
73 | 84 | protected function _prepareFormFields(&$field,$name,&$attributes){ |
74 | 85 | $field->setName($name); |
75 | 86 | $this->_addRules($field, $attributes); |
@@ -235,6 +246,9 @@ discard block |
||
235 | 246 | } |
236 | 247 | } |
237 | 248 | |
249 | + /** |
|
250 | + * @param integer $index |
|
251 | + */ |
|
238 | 252 | public function fieldAs($index,$type,$attributes=NULL){ |
239 | 253 | $method="fieldAs".\ucfirst($type); |
240 | 254 | if(\method_exists($this, $method)){ |
@@ -62,8 +62,7 @@ discard block |
||
62 | 62 | $rules=$attributes["rules"]; |
63 | 63 | if(\is_array($rules)){ |
64 | 64 | $element->addRules($rules); |
65 | - } |
|
66 | - else{ |
|
65 | + } else{ |
|
67 | 66 | $element->addRule($rules); |
68 | 67 | } |
69 | 68 | unset($attributes["rules"]); |
@@ -123,8 +122,9 @@ discard block |
||
123 | 122 | public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
124 | 123 | return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
125 | 124 | $header=new HtmlHeader($id,$niveau,$value); |
126 | - if(isset($icon)) |
|
127 | - $header->asIcon($icon, $value); |
|
125 | + if(isset($icon)) { |
|
126 | + $header->asIcon($icon, $value); |
|
127 | + } |
|
128 | 128 | return $header; |
129 | 129 | }, $index,$attributes,"header"); |
130 | 130 | } |
@@ -132,7 +132,9 @@ discard block |
||
132 | 132 | |
133 | 133 | public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
134 | 134 | $this->setValueFunction($index,function($img) use($size,$circular){ |
135 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
135 | + $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular) { |
|
136 | + $image->setCircular(); |
|
137 | + } |
|
136 | 138 | return $image; |
137 | 139 | }); |
138 | 140 | return $this; |
@@ -221,14 +223,14 @@ discard block |
||
221 | 223 | $i=0; |
222 | 224 | if(JArray::isAssociative($types)){ |
223 | 225 | foreach ($types as $type=>$attributes){ |
224 | - if(\is_int($type)) |
|
225 | - $this->fieldAs($i++,$attributes,[]); |
|
226 | - else{ |
|
226 | + if(\is_int($type)) { |
|
227 | + $this->fieldAs($i++,$attributes,[]); |
|
228 | + } else{ |
|
227 | 229 | $type=preg_replace('/\d/', '', $type ); |
228 | 230 | $this->fieldAs($i++,$type,$attributes); |
229 | 231 | } |
230 | 232 | } |
231 | - }else{ |
|
233 | + } else{ |
|
232 | 234 | foreach ($types as $type){ |
233 | 235 | $this->fieldAs($i++,$type); |
234 | 236 | } |
@@ -240,7 +242,7 @@ discard block |
||
240 | 242 | if(\method_exists($this, $method)){ |
241 | 243 | if(!\is_array($attributes)){ |
242 | 244 | $attributes=[$index]; |
243 | - }else{ |
|
245 | + } else{ |
|
244 | 246 | \array_unshift($attributes, $index); |
245 | 247 | } |
246 | 248 | \call_user_func_array([$this,$method], $attributes); |
@@ -26,23 +26,23 @@ discard block |
||
26 | 26 | * @property boolean $_edition |
27 | 27 | * @property mixed _modelInstance |
28 | 28 | */ |
29 | -trait FieldAsTrait{ |
|
29 | +trait FieldAsTrait { |
|
30 | 30 | |
31 | - abstract protected function _getFieldIdentifier($prefix,$name=""); |
|
32 | - abstract public function setValueFunction($index,$callback); |
|
31 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
32 | + abstract public function setValueFunction($index, $callback); |
|
33 | 33 | abstract protected function _getFieldName($index); |
34 | 34 | abstract protected function _getFieldCaption($index); |
35 | - abstract protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
|
35 | + abstract protected function _buttonAsSubmit(HtmlButton&$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @param HtmlFormField $element |
39 | 39 | * @param array $attributes |
40 | 40 | */ |
41 | - protected function _applyAttributes($element,&$attributes,$index){ |
|
42 | - if(isset($attributes["jsCallback"])){ |
|
41 | + protected function _applyAttributes($element, &$attributes, $index) { |
|
42 | + if (isset($attributes["jsCallback"])) { |
|
43 | 43 | $callback=$attributes["jsCallback"]; |
44 | - if(\is_callable($callback)){ |
|
45 | - $callback($element,$this->_modelInstance,$index); |
|
44 | + if (\is_callable($callback)) { |
|
45 | + $callback($element, $this->_modelInstance, $index); |
|
46 | 46 | unset($attributes["jsCallback"]); |
47 | 47 | } |
48 | 48 | } |
@@ -52,43 +52,43 @@ discard block |
||
52 | 52 | $element->fromArray($attributes); |
53 | 53 | } |
54 | 54 | |
55 | - private function _getLabelField($caption,$icon=NULL){ |
|
56 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
55 | + private function _getLabelField($caption, $icon=NULL) { |
|
56 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
57 | 57 | return $label; |
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | - protected function _addRules($element,&$attributes){ |
|
62 | - if(isset($attributes["rules"])){ |
|
61 | + protected function _addRules($element, &$attributes) { |
|
62 | + if (isset($attributes["rules"])) { |
|
63 | 63 | $rules=$attributes["rules"]; |
64 | - if(\is_array($rules)){ |
|
64 | + if (\is_array($rules)) { |
|
65 | 65 | $element->addRules($rules); |
66 | 66 | } |
67 | - else{ |
|
67 | + else { |
|
68 | 68 | $element->addRule($rules); |
69 | 69 | } |
70 | 70 | unset($attributes["rules"]); |
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | - protected function _prepareFormFields(&$field,$name,&$attributes){ |
|
74 | + protected function _prepareFormFields(&$field, $name, &$attributes) { |
|
75 | 75 | $field->setName($name); |
76 | 76 | $this->_addRules($field, $attributes); |
77 | 77 | return $field; |
78 | 78 | } |
79 | 79 | |
80 | - protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){ |
|
81 | - $this->setValueFunction($index,function($value,$instance,$index) use (&$attributes,$elementCallback,$prefix){ |
|
80 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
81 | + $this->setValueFunction($index, function($value, $instance, $index) use (&$attributes, $elementCallback, $prefix){ |
|
82 | 82 | $caption=$this->_getFieldCaption($index); |
83 | 83 | $name=$this->_getFieldName($index); |
84 | - $id=$this->_getFieldIdentifier($prefix,$name); |
|
85 | - if(isset($attributes["name"])){ |
|
84 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
85 | + if (isset($attributes["name"])) { |
|
86 | 86 | $name=$attributes["name"]; |
87 | 87 | unset($attributes["name"]); |
88 | 88 | } |
89 | - $element=$elementCallback($id,$name,$value,$caption); |
|
90 | - if(\is_array($attributes)){ |
|
91 | - $this->_applyAttributes($element, $attributes,$index); |
|
89 | + $element=$elementCallback($id, $name, $value, $caption); |
|
90 | + if (\is_array($attributes)) { |
|
91 | + $this->_applyAttributes($element, $attributes, $index); |
|
92 | 92 | } |
93 | 93 | $element->setDisabled(!$this->_edition); |
94 | 94 | return $element; |
@@ -97,177 +97,177 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | |
100 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
101 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
102 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
100 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
101 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
102 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
103 | 103 | return $pb; |
104 | 104 | }); |
105 | 105 | return $this; |
106 | 106 | } |
107 | 107 | |
108 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
109 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
110 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
108 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
109 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
110 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
111 | 111 | return $rating; |
112 | 112 | }); |
113 | 113 | return $this; |
114 | 114 | } |
115 | 115 | |
116 | - public function fieldAsLabel($index,$icon=NULL){ |
|
117 | - $this->setValueFunction($index,function($caption) use($icon){ |
|
118 | - $lbl=$this->_getLabelField($caption,$icon); |
|
116 | + public function fieldAsLabel($index, $icon=NULL) { |
|
117 | + $this->setValueFunction($index, function($caption) use($icon){ |
|
118 | + $lbl=$this->_getLabelField($caption, $icon); |
|
119 | 119 | return $lbl; |
120 | 120 | }); |
121 | 121 | return $this; |
122 | 122 | } |
123 | 123 | |
124 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
125 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
126 | - $header=new HtmlHeader($id,$niveau,$value); |
|
127 | - if(isset($icon)) |
|
124 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
125 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
126 | + $header=new HtmlHeader($id, $niveau, $value); |
|
127 | + if (isset($icon)) |
|
128 | 128 | $header->asIcon($icon, $value); |
129 | 129 | return $header; |
130 | - }, $index,$attributes,"header"); |
|
130 | + }, $index, $attributes, "header"); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
134 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
135 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
136 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
134 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
135 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
136 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
137 | 137 | return $image; |
138 | 138 | }); |
139 | 139 | return $this; |
140 | 140 | } |
141 | 141 | |
142 | - public function fieldAsFlag($index){ |
|
143 | - $this->setValueFunction($index,function($flag){ |
|
144 | - $flag=new HtmlFlag($this->_getFieldIdentifier("flag"),$flag); |
|
142 | + public function fieldAsFlag($index) { |
|
143 | + $this->setValueFunction($index, function($flag) { |
|
144 | + $flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
145 | 145 | return $flag; |
146 | 146 | }); |
147 | 147 | return $this; |
148 | 148 | } |
149 | 149 | |
150 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
151 | - return $this->_fieldAs(function($id,$name,$value){ |
|
152 | - $img=new HtmlImage($id,$value); |
|
150 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
151 | + return $this->_fieldAs(function($id, $name, $value) { |
|
152 | + $img=new HtmlImage($id, $value); |
|
153 | 153 | $img->asAvatar(); |
154 | 154 | return $img; |
155 | - }, $index,$attributes,"avatar"); |
|
155 | + }, $index, $attributes, "avatar"); |
|
156 | 156 | } |
157 | 157 | |
158 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
159 | - return $this->_fieldAs(function($id,$name,$value){ |
|
160 | - $input= new HtmlRadio($id,$name,$value,$value); |
|
158 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
159 | + return $this->_fieldAs(function($id, $name, $value) { |
|
160 | + $input=new HtmlRadio($id, $name, $value, $value); |
|
161 | 161 | return $input; |
162 | - }, $index,$attributes,"radio"); |
|
162 | + }, $index, $attributes, "radio"); |
|
163 | 163 | } |
164 | 164 | |
165 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
166 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){ |
|
167 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
168 | - }, $index,$attributes,"radios"); |
|
165 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
166 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){ |
|
167 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
168 | + }, $index, $attributes, "radios"); |
|
169 | 169 | } |
170 | 170 | |
171 | - public function fieldAsInput($index,$attributes=NULL){ |
|
172 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
173 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
171 | + public function fieldAsInput($index, $attributes=NULL) { |
|
172 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
173 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
174 | 174 | return $this->_prepareFormFields($input, $name, $attributes); |
175 | - }, $index,$attributes,"input"); |
|
175 | + }, $index, $attributes, "input"); |
|
176 | 176 | } |
177 | 177 | |
178 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
179 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
180 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
178 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
179 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
180 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
181 | 181 | $textarea->setName($name); |
182 | 182 | return $textarea; |
183 | - }, $index,$attributes,"textarea"); |
|
183 | + }, $index, $attributes, "textarea"); |
|
184 | 184 | } |
185 | 185 | |
186 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
187 | - if(!\is_array($attributes)){ |
|
186 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
187 | + if (!\is_array($attributes)) { |
|
188 | 188 | $attributes=[]; |
189 | 189 | } |
190 | 190 | $attributes["imputType"]="hidden"; |
191 | - return $this->fieldAsInput($index,$attributes); |
|
191 | + return $this->fieldAsInput($index, $attributes); |
|
192 | 192 | } |
193 | 193 | |
194 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
195 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
196 | - $input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier()); |
|
194 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
195 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
196 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
197 | 197 | $input->setChecked(JString::isBooleanTrue($value)); |
198 | 198 | $input->setName($name); |
199 | 199 | return $input; |
200 | - }, $index,$attributes,"ck"); |
|
200 | + }, $index, $attributes, "ck"); |
|
201 | 201 | } |
202 | 202 | |
203 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
204 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple){ |
|
205 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value); |
|
206 | - $dd->asSelect($name,$multiple); |
|
203 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
204 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple){ |
|
205 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value); |
|
206 | + $dd->asSelect($name, $multiple); |
|
207 | 207 | return $dd; |
208 | - }, $index,$attributes,"dd"); |
|
208 | + }, $index, $attributes, "dd"); |
|
209 | 209 | } |
210 | 210 | |
211 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
212 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
213 | - $mess= new HtmlMessage("message-".$id,$caption); |
|
211 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
212 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
213 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
214 | 214 | $mess->addHeader($value); |
215 | 215 | return $mess; |
216 | - }, $index,$attributes,"message"); |
|
216 | + }, $index, $attributes, "message"); |
|
217 | 217 | } |
218 | 218 | |
219 | - public function fieldAsLink($index,$attributes=NULL){ |
|
220 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
221 | - $lnk= new HtmlLink("message-".$id,"#",$caption); |
|
219 | + public function fieldAsLink($index, $attributes=NULL) { |
|
220 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
221 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
222 | 222 | return $lnk; |
223 | - }, $index,$attributes,"link"); |
|
223 | + }, $index, $attributes, "link"); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /**Change fields type |
227 | 227 | * @param array $types an array or associative array $type=>$attributes |
228 | 228 | */ |
229 | - public function fieldsAs(array $types){ |
|
229 | + public function fieldsAs(array $types) { |
|
230 | 230 | $i=0; |
231 | - if(JArray::isAssociative($types)){ |
|
232 | - foreach ($types as $type=>$attributes){ |
|
233 | - if(\is_int($type)) |
|
234 | - $this->fieldAs($i++,$attributes,[]); |
|
235 | - else{ |
|
236 | - $type=preg_replace('/\d/', '', $type ); |
|
237 | - $this->fieldAs($i++,$type,$attributes); |
|
231 | + if (JArray::isAssociative($types)) { |
|
232 | + foreach ($types as $type=>$attributes) { |
|
233 | + if (\is_int($type)) |
|
234 | + $this->fieldAs($i++, $attributes, []); |
|
235 | + else { |
|
236 | + $type=preg_replace('/\d/', '', $type); |
|
237 | + $this->fieldAs($i++, $type, $attributes); |
|
238 | 238 | } |
239 | 239 | } |
240 | - }else{ |
|
241 | - foreach ($types as $type){ |
|
242 | - $this->fieldAs($i++,$type); |
|
240 | + } else { |
|
241 | + foreach ($types as $type) { |
|
242 | + $this->fieldAs($i++, $type); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | - public function fieldAs($index,$type,$attributes=NULL){ |
|
247 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
248 | 248 | $method="fieldAs".\ucfirst($type); |
249 | - if(\method_exists($this, $method)){ |
|
250 | - if(!\is_array($attributes)){ |
|
249 | + if (\method_exists($this, $method)) { |
|
250 | + if (!\is_array($attributes)) { |
|
251 | 251 | $attributes=[$index]; |
252 | - }else{ |
|
252 | + } else { |
|
253 | 253 | \array_unshift($attributes, $index); |
254 | 254 | } |
255 | - \call_user_func_array([$this,$method], $attributes); |
|
255 | + \call_user_func_array([$this, $method], $attributes); |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
260 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
|
261 | - $button=new HtmlButton($id,$caption,$cssStyle); |
|
262 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]); |
|
259 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
260 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){ |
|
261 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
262 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]); |
|
263 | 263 | return $button; |
264 | - }, $index,$attributes,"submit"); |
|
264 | + }, $index, $attributes, "submit"); |
|
265 | 265 | } |
266 | 266 | |
267 | - public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){ |
|
268 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
269 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
267 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
268 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
269 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
270 | 270 | return $button; |
271 | - }, $index,$attributes,"button"); |
|
271 | + }, $index, $attributes, "button"); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | \ No newline at end of file |
@@ -12,10 +12,10 @@ |
||
12 | 12 | parent::__construct($identifier, $instance, $captions); |
13 | 13 | } |
14 | 14 | |
15 | - public function getValue($index){ |
|
15 | + public function getValue($index) { |
|
16 | 16 | $result=parent::getValue($index); |
17 | - if($result instanceof HtmlFormField){ |
|
18 | - $lbl=new HtmlSemDoubleElement("lbl-".$this->widgetIdentifier."-".$index,"label","",$this->getCaption($index)); |
|
17 | + if ($result instanceof HtmlFormField) { |
|
18 | + $lbl=new HtmlSemDoubleElement("lbl-".$this->widgetIdentifier."-".$index, "label", "", $this->getCaption($index)); |
|
19 | 19 | $lbl->setProperty("for", $result->getDataField()->getIdentifier()); |
20 | 20 | $this->captions[$index]=$lbl; |
21 | 21 | } |