@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | } |
36 | 36 | if (isset($label)) |
37 | 37 | $this->setLabel($label); |
38 | - foreach ( $fields as $field ) { |
|
38 | + foreach ($fields as $field) { |
|
39 | 39 | $this->addItem($field); |
40 | 40 | } |
41 | 41 | return $this; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | public function addItem($item) { |
59 | 59 | $item=parent::addItem($item); |
60 | - if($item instanceof HtmlFormField) |
|
60 | + if ($item instanceof HtmlFormField) |
|
61 | 61 | $item->setContainer($this); |
62 | 62 | return $item; |
63 | 63 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | /** |
66 | 66 | * @return HtmlFormField |
67 | 67 | */ |
68 | - public function getItem($index){ |
|
68 | + public function getItem($index) { |
|
69 | 69 | return parent::getItem($index); |
70 | 70 | } |
71 | 71 | |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | |
107 | - public static function radios($identifier,$name, $items=array(), $label=NULL, $value=null, $type=NULL) { |
|
108 | - $fields=array (); |
|
107 | + public static function radios($identifier, $name, $items=array(), $label=NULL, $value=null, $type=NULL) { |
|
108 | + $fields=array(); |
|
109 | 109 | $i=0; |
110 | - foreach ( $items as $val => $caption ) { |
|
110 | + foreach ($items as $val => $caption) { |
|
111 | 111 | $itemO=new HtmlFormRadio($name."-".$i++, $name, $caption, $val, $type); |
112 | 112 | if ($val===$value) { |
113 | 113 | $itemO->getDataField()->setProperty("checked", ""); |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | return $radios; |
121 | 121 | } |
122 | 122 | |
123 | - public static function checkeds($identifier,$name, $items=array(), $label=NULL, $values=array(), $type=NULL) { |
|
124 | - $fields=array (); |
|
123 | + public static function checkeds($identifier, $name, $items=array(), $label=NULL, $values=array(), $type=NULL) { |
|
124 | + $fields=array(); |
|
125 | 125 | $i=0; |
126 | - foreach ( $items as $val => $caption ) { |
|
126 | + foreach ($items as $val => $caption) { |
|
127 | 127 | $itemO=new HtmlFormCheckbox($name."-".$i++, $caption, $val, $type); |
128 | 128 | $itemO->setName($name); |
129 | 129 | if (\array_search($val, $values)!==false) { |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | return $this; |
143 | 143 | } |
144 | 144 | |
145 | - public function run(JsUtils $js){ |
|
146 | - $result= parent::run($js); |
|
145 | + public function run(JsUtils $js) { |
|
146 | + $result=parent::run($js); |
|
147 | 147 | //return $result->setItemSelector("[data-value]"); |
148 | 148 | } |
149 | 149 | } |
@@ -29,12 +29,14 @@ discard block |
||
29 | 29 | if (\is_string($end)) { |
30 | 30 | $label=$end; |
31 | 31 | \array_pop($fields); |
32 | - } else |
|
33 | - $label=NULL; |
|
32 | + } else { |
|
33 | + $label=NULL; |
|
34 | + } |
|
34 | 35 | } |
35 | 36 | } |
36 | - if (isset($label)) |
|
37 | - $this->setLabel($label); |
|
37 | + if (isset($label)) { |
|
38 | + $this->setLabel($label); |
|
39 | + } |
|
38 | 40 | foreach ( $fields as $field ) { |
39 | 41 | $this->addItem($field); |
40 | 42 | } |
@@ -57,8 +59,9 @@ discard block |
||
57 | 59 | |
58 | 60 | public function addItem($item) { |
59 | 61 | $item=parent::addItem($item); |
60 | - if($item instanceof HtmlFormField) |
|
61 | - $item->setContainer($this); |
|
62 | + if($item instanceof HtmlFormField) { |
|
63 | + $item->setContainer($this); |
|
64 | + } |
|
62 | 65 | return $item; |
63 | 66 | } |
64 | 67 | |
@@ -73,8 +76,9 @@ discard block |
||
73 | 76 | if ($this->_equalWidth) { |
74 | 77 | $count=$this->count(); |
75 | 78 | $this->addToProperty("class", Wide::getConstants()["W".$count]." fields"); |
76 | - } else |
|
77 | - $this->addToProperty("class", "fields"); |
|
79 | + } else { |
|
80 | + $this->addToProperty("class", "fields"); |
|
81 | + } |
|
78 | 82 | return parent::compile($js, $view); |
79 | 83 | } |
80 | 84 | |
@@ -115,8 +119,9 @@ discard block |
||
115 | 119 | $fields[]=$itemO; |
116 | 120 | } |
117 | 121 | $radios=new HtmlFormFields($identifier, $fields); |
118 | - if (isset($label)) |
|
119 | - $radios->setLabel($label)->setProperty("for", $name); |
|
122 | + if (isset($label)) { |
|
123 | + $radios->setLabel($label)->setProperty("for", $name); |
|
124 | + } |
|
120 | 125 | return $radios; |
121 | 126 | } |
122 | 127 | |
@@ -132,8 +137,9 @@ discard block |
||
132 | 137 | $fields[]=$itemO; |
133 | 138 | } |
134 | 139 | $radios=new HtmlFormFields($identifier, $fields); |
135 | - if (isset($label)) |
|
136 | - $radios->setLabel($label)->setProperty("for", $name); |
|
140 | + if (isset($label)) { |
|
141 | + $radios->setLabel($label)->setProperty("for", $name); |
|
142 | + } |
|
137 | 143 | return $radios; |
138 | 144 | } |
139 | 145 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @return mixed |
38 | 38 | */ |
39 | 39 | public function getLibraryId() { |
40 | - if( isset($this->_libraryId)){ |
|
40 | + if (isset($this->_libraryId)) { |
|
41 | 41 | return $this->_libraryId; |
42 | 42 | } |
43 | 43 | return $this->identifier; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param mixed $_libraryId |
48 | 48 | */ |
49 | 49 | public function setLibraryId($_libraryId) { |
50 | - $this->_libraryId = $_libraryId; |
|
50 | + $this->_libraryId=$_libraryId; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | * @version 1.3 |
16 | 16 | */ |
17 | 17 | abstract class BaseHtml extends BaseWidget { |
18 | - use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait; |
|
18 | + use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait; |
|
19 | 19 | protected $_template; |
20 | 20 | protected $tagName; |
21 | - protected $_wrapBefore=array (); |
|
22 | - protected $_wrapAfter=array (); |
|
21 | + protected $_wrapBefore=array(); |
|
22 | + protected $_wrapAfter=array(); |
|
23 | 23 | protected $_bsComponent; |
24 | 24 | protected $_compiled=false; |
25 | 25 | protected $_runned=false; |
@@ -33,32 +33,32 @@ discard block |
||
33 | 33 | */ |
34 | 34 | abstract public function run(JsUtils $js); |
35 | 35 | |
36 | - private function _callSetter($setter,$key,$value,&$array){ |
|
36 | + private function _callSetter($setter, $key, $value, &$array) { |
|
37 | 37 | $result=false; |
38 | - if (method_exists($this, $setter) && substr($setter, 0, 1) !== "_") { |
|
38 | + if (method_exists($this, $setter) && substr($setter, 0, 1)!=="_") { |
|
39 | 39 | try { |
40 | 40 | $this->$setter($value); |
41 | 41 | unset($array[$key]); |
42 | 42 | $result=true; |
43 | - } catch ( \Exception $e ) { |
|
43 | + }catch (\Exception $e) { |
|
44 | 44 | $result=false; |
45 | 45 | } |
46 | 46 | } |
47 | 47 | return $result; |
48 | 48 | } |
49 | 49 | |
50 | - protected function getTemplate(JsUtils $js=NULL,$view=null) { |
|
51 | - return PropertyWrapper::wrap($this->_wrapBefore, $js,$view) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js,$view); |
|
50 | + protected function getTemplate(JsUtils $js=NULL, $view=null) { |
|
51 | + return PropertyWrapper::wrap($this->_wrapBefore, $js, $view).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js, $view); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | protected function ctrl($name, $value, $typeCtrl) { |
55 | 55 | if (\is_array($typeCtrl)) { |
56 | - if (array_search($value, $typeCtrl) === false) { |
|
57 | - throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}"); |
|
56 | + if (array_search($value, $typeCtrl)===false) { |
|
57 | + throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
58 | 58 | } |
59 | 59 | } else { |
60 | 60 | if (!$typeCtrl($value)) { |
61 | - throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name); |
|
61 | + throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | return true; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") { |
76 | 76 | if (\is_array($typeCtrl)) { |
77 | 77 | $this->removeOldValues($name, $typeCtrl); |
78 | - $name.=$separator . $value; |
|
78 | + $name.=$separator.$value; |
|
79 | 79 | } |
80 | 80 | return $this; |
81 | 81 | } |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | if (\is_array($typeCtrl)) { |
88 | 88 | $this->removeOldValues($name, $typeCtrl); |
89 | 89 | } |
90 | - $name.=$separator . $value; |
|
90 | + $name.=$separator.$value; |
|
91 | 91 | return $this; |
92 | 92 | } |
93 | 93 | |
94 | 94 | protected function addToMember(&$name, $value, $separator=" ") { |
95 | - $name=str_ireplace($value, "", $name) . $separator . $value; |
|
95 | + $name=str_ireplace($value, "", $name).$separator.$value; |
|
96 | 96 | return $this; |
97 | 97 | } |
98 | 98 | |
@@ -103,18 +103,18 @@ discard block |
||
103 | 103 | $oldValue=trim($oldValue); |
104 | 104 | } |
105 | 105 | |
106 | - protected function _getElementBy($callback,$elements){ |
|
106 | + protected function _getElementBy($callback, $elements) { |
|
107 | 107 | if (\is_array($elements)) { |
108 | 108 | $elements=\array_values($elements); |
109 | 109 | $flag=false; |
110 | 110 | $index=0; |
111 | - while ( !$flag && $index < sizeof($elements) ) { |
|
111 | + while (!$flag && $index<sizeof($elements)) { |
|
112 | 112 | if ($elements[$index] instanceof BaseHtml) |
113 | 113 | $flag=($callback($elements[$index])); |
114 | 114 | $index++; |
115 | 115 | } |
116 | - if ($flag === true) |
|
117 | - return $elements[$index - 1]; |
|
116 | + if ($flag===true) |
|
117 | + return $elements[$index-1]; |
|
118 | 118 | } elseif ($elements instanceof BaseHtml) { |
119 | 119 | if ($callback($elements)) |
120 | 120 | return $elements; |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | public function fromArray($array) { |
145 | - foreach ( $this as $key => $value ) { |
|
146 | - if(array_key_exists($key, $array)===true) |
|
147 | - $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
145 | + foreach ($this as $key => $value) { |
|
146 | + if (array_key_exists($key, $array)===true) |
|
147 | + $this->_callSetter("set".ucfirst($key), $key, $array[$key], $array); |
|
148 | 148 | } |
149 | - foreach ( $array as $key => $value ) { |
|
150 | - if($this->_callSetter($key, $key, $value, $array)===false){ |
|
151 | - $this->_callSetter("set" . ucfirst($key), $key, $value, $array); |
|
149 | + foreach ($array as $key => $value) { |
|
150 | + if ($this->_callSetter($key, $key, $value, $array)===false) { |
|
151 | + $this->_callSetter("set".ucfirst($key), $key, $value, $array); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | return $array; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | public function fromDatabaseObjects($objects, $function) { |
158 | 158 | if (isset($objects)) { |
159 | - foreach ( $objects as $object ) { |
|
159 | + foreach ($objects as $object) { |
|
160 | 160 | $this->fromDatabaseObject($object, $function); |
161 | 161 | } |
162 | 162 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | |
179 | 179 | public function getElementById($identifier, $elements) { |
180 | - return $this->_getElementBy(function(BaseWidget $element) use ($identifier){return $element->getIdentifier()===$identifier;}, $elements); |
|
180 | + return $this->_getElementBy(function(BaseWidget $element) use ($identifier){return $element->getIdentifier()===$identifier; }, $elements); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | public function getBsComponent() { |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
193 | - if(!$this->_compiled){ |
|
194 | - if(isset($js)){ |
|
193 | + if (!$this->_compiled) { |
|
194 | + if (isset($js)) { |
|
195 | 195 | $beforeCompile=$js->getParam("beforeCompileHtml"); |
196 | - if(\is_callable($beforeCompile)){ |
|
197 | - $beforeCompile($this,$js,$view); |
|
196 | + if (\is_callable($beforeCompile)) { |
|
197 | + $beforeCompile($this, $js, $view); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | $this->callCallback($this->_preCompile); |
@@ -204,17 +204,17 @@ discard block |
||
204 | 204 | } |
205 | 205 | |
206 | 206 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
207 | - $this->compile_once($js,$view); |
|
208 | - $result=$this->getTemplate($js,$view); |
|
209 | - foreach ( $this as $key => $value ) { |
|
210 | - if(\strstr($result, "%{$key}%")!==false){ |
|
207 | + $this->compile_once($js, $view); |
|
208 | + $result=$this->getTemplate($js, $view); |
|
209 | + foreach ($this as $key => $value) { |
|
210 | + if (\strstr($result, "%{$key}%")!==false) { |
|
211 | 211 | if (\is_array($value)) { |
212 | - $v=PropertyWrapper::wrap($value, $js,$view); |
|
213 | - }elseif($value instanceof \stdClass){ |
|
214 | - $v=\print_r($value,true); |
|
215 | - }elseif ($value instanceof BaseHtml){ |
|
216 | - $v=$value->compile($js,$view); |
|
217 | - }else{ |
|
212 | + $v=PropertyWrapper::wrap($value, $js, $view); |
|
213 | + }elseif ($value instanceof \stdClass) { |
|
214 | + $v=\print_r($value, true); |
|
215 | + }elseif ($value instanceof BaseHtml) { |
|
216 | + $v=$value->compile($js, $view); |
|
217 | + } else { |
|
218 | 218 | $v=$value; |
219 | 219 | } |
220 | 220 | $result=str_replace("%{$key}%", $v, $result); |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | } |
223 | 223 | if (isset($js)===true) { |
224 | 224 | $this->run($js); |
225 | - if (isset($view) === true) { |
|
225 | + if (isset($view)===true) { |
|
226 | 226 | $js->addViewElement($this->getLibraryId(), $result, $view); |
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
230 | - if(\is_callable($this->_postCompile)){ |
|
230 | + if (\is_callable($this->_postCompile)) { |
|
231 | 231 | $pc=$this->_postCompile; |
232 | 232 | $pc($this); |
233 | 233 | } |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | * @param array $parameters default: ["jsCallback"=>"","jqueryDone"=>"append"] |
242 | 242 | * @return \Ajax\common\html\BaseHtml |
243 | 243 | */ |
244 | - public function setDraggable($attr="id",$dropZone=null,$parameters=[]){ |
|
244 | + public function setDraggable($attr="id", $dropZone=null, $parameters=[]) { |
|
245 | 245 | $this->setProperty("draggable", "true"); |
246 | - $this->addEvent("dragstart",Javascript::draggable($attr)); |
|
247 | - if(isset($dropZone)&& $dropZone instanceof BaseHtml){ |
|
248 | - $jqueryDone="append";$jsCallback=""; |
|
246 | + $this->addEvent("dragstart", Javascript::draggable($attr)); |
|
247 | + if (isset($dropZone) && $dropZone instanceof BaseHtml) { |
|
248 | + $jqueryDone="append"; $jsCallback=""; |
|
249 | 249 | extract($parameters); |
250 | - $dropZone->asDropZone($jsCallback,$jqueryDone,$parameters); |
|
250 | + $dropZone->asDropZone($jsCallback, $jqueryDone, $parameters); |
|
251 | 251 | } |
252 | 252 | return $this; |
253 | 253 | } |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | * @param array $parameters |
260 | 260 | * @return \Ajax\common\html\BaseHtml |
261 | 261 | */ |
262 | - public function asDropZone($jsCallback="",$jqueryDone="append",$parameters=[]){ |
|
262 | + public function asDropZone($jsCallback="", $jqueryDone="append", $parameters=[]) { |
|
263 | 263 | $stopPropagation=false; |
264 | - $this->addEvent("dragover", '', $stopPropagation,true); |
|
264 | + $this->addEvent("dragover", '', $stopPropagation, true); |
|
265 | 265 | extract($parameters); |
266 | - $this->addEvent("drop",Javascript::dropZone($jqueryDone,$jsCallback),$stopPropagation,true); |
|
266 | + $this->addEvent("drop", Javascript::dropZone($jqueryDone, $jsCallback), $stopPropagation, true); |
|
267 | 267 | return $this; |
268 | 268 | } |
269 | 269 | |
@@ -271,17 +271,17 @@ discard block |
||
271 | 271 | return $this->compile(); |
272 | 272 | } |
273 | 273 | |
274 | - public function onPostCompile($callback){ |
|
274 | + public function onPostCompile($callback) { |
|
275 | 275 | $this->_postCompile=$callback; |
276 | 276 | } |
277 | 277 | |
278 | - public function onPreCompile($callback){ |
|
278 | + public function onPreCompile($callback) { |
|
279 | 279 | $this->_preCompile=$this->addCallback($this->_preCompile, $callback); |
280 | 280 | } |
281 | 281 | |
282 | - private function addCallback($originalValue,$callback){ |
|
283 | - if(isset($originalValue)){ |
|
284 | - if(!is_array($originalValue)){ |
|
282 | + private function addCallback($originalValue, $callback) { |
|
283 | + if (isset($originalValue)) { |
|
284 | + if (!is_array($originalValue)) { |
|
285 | 285 | $result=[$originalValue]; |
286 | 286 | } |
287 | 287 | $result[]=$callback; |
@@ -290,12 +290,12 @@ discard block |
||
290 | 290 | return $callback; |
291 | 291 | } |
292 | 292 | |
293 | - private function callCallback($callable){ |
|
294 | - if(\is_callable($callable)){ |
|
293 | + private function callCallback($callable) { |
|
294 | + if (\is_callable($callable)) { |
|
295 | 295 | return $callable($this); |
296 | 296 | } |
297 | - if(is_array($callable)){ |
|
298 | - foreach ($callable as $call){ |
|
297 | + if (is_array($callable)) { |
|
298 | + foreach ($callable as $call) { |
|
299 | 299 | $this->callCallback($call); |
300 | 300 | } |
301 | 301 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | use Ajax\semantic\html\modules\HtmlModal; |
21 | 21 | |
22 | 22 | abstract class Widget extends HtmlDoubleElement { |
23 | - use FieldAsTrait,FormTrait; |
|
23 | + use FieldAsTrait, FormTrait; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @var string classname |
@@ -53,17 +53,17 @@ discard block |
||
53 | 53 | protected $_generated; |
54 | 54 | |
55 | 55 | |
56 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
56 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
57 | 57 | parent::__construct($identifier); |
58 | 58 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
59 | 59 | $this->setModel($model); |
60 | - if(isset($modelInstance)){ |
|
60 | + if (isset($modelInstance)) { |
|
61 | 61 | $this->show($modelInstance); |
62 | 62 | } |
63 | 63 | $this->_generated=false; |
64 | 64 | } |
65 | 65 | |
66 | - protected function _init($instanceViewer,$contentKey,$content,$edition){ |
|
66 | + protected function _init($instanceViewer, $contentKey, $content, $edition) { |
|
67 | 67 | $this->_instanceViewer=$instanceViewer; |
68 | 68 | $this->content=[$contentKey=>$content]; |
69 | 69 | $this->_self=$content; |
@@ -75,31 +75,31 @@ discard block |
||
75 | 75 | * @param int|string $fieldName |
76 | 76 | * @return int|string|boolean |
77 | 77 | */ |
78 | - protected function _getIndex($fieldName){ |
|
78 | + protected function _getIndex($fieldName) { |
|
79 | 79 | $index=$fieldName; |
80 | - if(\is_string($fieldName)){ |
|
80 | + if (\is_string($fieldName)) { |
|
81 | 81 | $fields=$this->_instanceViewer->getVisibleProperties(); |
82 | 82 | $index=\array_search($fieldName, $fields); |
83 | 83 | } |
84 | 84 | return $index; |
85 | 85 | } |
86 | 86 | |
87 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
87 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
88 | 88 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
89 | 89 | } |
90 | 90 | |
91 | - protected function _getFieldName($index){ |
|
91 | + protected function _getFieldName($index) { |
|
92 | 92 | return $this->_instanceViewer->getFieldName($index); |
93 | 93 | } |
94 | 94 | |
95 | - protected function _getFieldCaption($index){ |
|
95 | + protected function _getFieldCaption($index) { |
|
96 | 96 | return $this->_instanceViewer->getCaption($index); |
97 | 97 | } |
98 | 98 | |
99 | - abstract protected function _setToolbarPosition($table,$captions=NULL); |
|
99 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
100 | 100 | |
101 | - public function show($modelInstance){ |
|
102 | - if(\is_array($modelInstance)){ |
|
101 | + public function show($modelInstance) { |
|
102 | + if (\is_array($modelInstance)) { |
|
103 | 103 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
104 | 104 | } |
105 | 105 | $this->_modelInstance=$modelInstance; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | abstract public function getHtmlComponent(); |
127 | 127 | |
128 | - public function setAttached($value=true){ |
|
128 | + public function setAttached($value=true) { |
|
129 | 129 | return $this->getHtmlComponent()->setAttached($value); |
130 | 130 | } |
131 | 131 | |
@@ -136,65 +136,65 @@ discard block |
||
136 | 136 | * @param callable $callback function called after the field compilation |
137 | 137 | * @return Widget |
138 | 138 | */ |
139 | - public function afterCompile($index,$callback){ |
|
139 | + public function afterCompile($index, $callback) { |
|
140 | 140 | $index=$this->_getIndex($index); |
141 | 141 | $this->_instanceViewer->afterCompile($index, $callback); |
142 | 142 | return $this; |
143 | 143 | } |
144 | 144 | |
145 | - public function setColor($color){ |
|
145 | + public function setColor($color) { |
|
146 | 146 | return $this->getHtmlComponent()->setColor($color); |
147 | 147 | } |
148 | 148 | |
149 | 149 | |
150 | - public function setCaptions($captions){ |
|
150 | + public function setCaptions($captions) { |
|
151 | 151 | $this->_instanceViewer->setCaptions($captions); |
152 | 152 | return $this; |
153 | 153 | } |
154 | 154 | |
155 | - public function setCaption($index,$caption){ |
|
155 | + public function setCaption($index, $caption) { |
|
156 | 156 | $this->_instanceViewer->setCaption($this->_getIndex($index), $caption); |
157 | 157 | return $this; |
158 | 158 | } |
159 | 159 | |
160 | - public function setFields($fields){ |
|
160 | + public function setFields($fields) { |
|
161 | 161 | $this->_instanceViewer->setVisibleProperties($fields); |
162 | 162 | return $this; |
163 | 163 | } |
164 | 164 | |
165 | - public function addField($field,$key=null){ |
|
166 | - $this->_instanceViewer->addField($field,$key); |
|
165 | + public function addField($field, $key=null) { |
|
166 | + $this->_instanceViewer->addField($field, $key); |
|
167 | 167 | return $this; |
168 | 168 | } |
169 | 169 | |
170 | - public function addFields($fields){ |
|
170 | + public function addFields($fields) { |
|
171 | 171 | $this->_instanceViewer->addFields($fields); |
172 | 172 | return $this; |
173 | 173 | } |
174 | 174 | |
175 | - public function countFields(){ |
|
175 | + public function countFields() { |
|
176 | 176 | return $this->_instanceViewer->visiblePropertiesCount(); |
177 | 177 | } |
178 | 178 | |
179 | - public function addMessage($attributes=NULL,$fieldName="message"){ |
|
179 | + public function addMessage($attributes=NULL, $fieldName="message") { |
|
180 | 180 | $this->_instanceViewer->addField($fieldName); |
181 | 181 | $count=$this->_instanceViewer->visiblePropertiesCount(); |
182 | - return $this->fieldAsMessage($count-1,$attributes); |
|
182 | + return $this->fieldAsMessage($count-1, $attributes); |
|
183 | 183 | } |
184 | 184 | |
185 | - public function addErrorMessage(){ |
|
186 | - return $this->addMessage(["error"=>true],"message"); |
|
185 | + public function addErrorMessage() { |
|
186 | + return $this->addMessage(["error"=>true], "message"); |
|
187 | 187 | } |
188 | 188 | |
189 | - public function insertField($index,$field,$key=null){ |
|
189 | + public function insertField($index, $field, $key=null) { |
|
190 | 190 | $index=$this->_getIndex($index); |
191 | - $this->_instanceViewer->insertField($index, $field,$key); |
|
191 | + $this->_instanceViewer->insertField($index, $field, $key); |
|
192 | 192 | return $this; |
193 | 193 | } |
194 | 194 | |
195 | - public function insertInField($index,$field,$key=null){ |
|
195 | + public function insertInField($index, $field, $key=null) { |
|
196 | 196 | $index=$this->_getIndex($index); |
197 | - $this->_instanceViewer->insertInField($index, $field,$key); |
|
197 | + $this->_instanceViewer->insertInField($index, $field, $key); |
|
198 | 198 | return $this; |
199 | 199 | } |
200 | 200 | |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | * @param callable $callback function parameters are : $value : the field value, $instance : the active instance of model, $fieldIndex : the field index, $rowIndex : the row index |
205 | 205 | * @return Widget |
206 | 206 | */ |
207 | - public function setValueFunction($index,$callback){ |
|
207 | + public function setValueFunction($index, $callback) { |
|
208 | 208 | $index=$this->_getIndex($index); |
209 | 209 | $this->_instanceViewer->setValueFunction($index, $callback); |
210 | 210 | return $this; |
211 | 211 | } |
212 | 212 | |
213 | - public function setIdentifierFunction($callback){ |
|
213 | + public function setIdentifierFunction($callback) { |
|
214 | 214 | $this->_instanceViewer->setIdentifierFunction($callback); |
215 | 215 | return $this; |
216 | 216 | } |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | /** |
219 | 219 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
220 | 220 | */ |
221 | - public function getToolbar(){ |
|
222 | - if(isset($this->_toolbar)===false){ |
|
221 | + public function getToolbar() { |
|
222 | + if (isset($this->_toolbar)===false) { |
|
223 | 223 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
224 | 224 | } |
225 | 225 | return $this->_toolbar; |
@@ -231,15 +231,15 @@ discard block |
||
231 | 231 | * @param callable $callback function to call on $element |
232 | 232 | * @return \Ajax\common\html\HtmlDoubleElement |
233 | 233 | */ |
234 | - public function addInToolbar($element,$callback=NULL){ |
|
234 | + public function addInToolbar($element, $callback=NULL) { |
|
235 | 235 | $tb=$this->getToolbar(); |
236 | - if($element instanceof BaseWidget){ |
|
237 | - if($element->getIdentifier()===""){ |
|
236 | + if ($element instanceof BaseWidget) { |
|
237 | + if ($element->getIdentifier()==="") { |
|
238 | 238 | $element->setIdentifier("tb-item-".$this->identifier."-".$tb->count()); |
239 | 239 | } |
240 | 240 | } |
241 | - if(isset($callback)){ |
|
242 | - if(\is_callable($callback)){ |
|
241 | + if (isset($callback)) { |
|
242 | + if (\is_callable($callback)) { |
|
243 | 243 | $callback($element); |
244 | 244 | } |
245 | 245 | } |
@@ -252,9 +252,9 @@ discard block |
||
252 | 252 | * @param callable $callback function($element) |
253 | 253 | * @return \Ajax\common\html\HtmlDoubleElement |
254 | 254 | */ |
255 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
256 | - $result=$this->addInToolbar($caption,$callback); |
|
257 | - if(isset($icon) && method_exists($result, "addIcon")) |
|
255 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
256 | + $result=$this->addInToolbar($caption, $callback); |
|
257 | + if (isset($icon) && method_exists($result, "addIcon")) |
|
258 | 258 | $result->addIcon($icon); |
259 | 259 | return $result; |
260 | 260 | } |
@@ -264,14 +264,14 @@ discard block |
||
264 | 264 | * @param callable $callback function($element) |
265 | 265 | * @return \Ajax\common\Widget |
266 | 266 | */ |
267 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
268 | - if(JArray::isAssociative($items)){ |
|
269 | - foreach ($items as $icon=>$item){ |
|
270 | - $this->addItemInToolbar($item,$icon,$callback); |
|
267 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
268 | + if (JArray::isAssociative($items)) { |
|
269 | + foreach ($items as $icon=>$item) { |
|
270 | + $this->addItemInToolbar($item, $icon, $callback); |
|
271 | 271 | } |
272 | - }else{ |
|
273 | - foreach ($items as $item){ |
|
274 | - $this->addItemInToolbar($item,null,$callback); |
|
272 | + } else { |
|
273 | + foreach ($items as $item) { |
|
274 | + $this->addItemInToolbar($item, null, $callback); |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | return $this; |
@@ -283,12 +283,12 @@ discard block |
||
283 | 283 | * @param callable $callback function($element) |
284 | 284 | * @return \Ajax\common\html\HtmlDoubleElement |
285 | 285 | */ |
286 | - public function addDropdownInToolbar($value,$items,$callback=NULL){ |
|
286 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
287 | 287 | $dd=$value; |
288 | 288 | if (\is_string($value)) { |
289 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
289 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
290 | 290 | } |
291 | - return $this->addInToolbar($dd,$callback); |
|
291 | + return $this->addInToolbar($dd, $callback); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | * @param callable $callback function($element) |
298 | 298 | * @return \Ajax\common\html\HtmlDoubleElement |
299 | 299 | */ |
300 | - public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){ |
|
301 | - $bt=new HtmlButton("bt-".$caption,$caption,$cssStyle); |
|
302 | - return $this->addInToolbar($bt,$callback); |
|
300 | + public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) { |
|
301 | + $bt=new HtmlButton("bt-".$caption, $caption, $cssStyle); |
|
302 | + return $this->addInToolbar($bt, $callback); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -308,9 +308,9 @@ discard block |
||
308 | 308 | * @param callable $callback function($element) |
309 | 309 | * @return \Ajax\common\html\HtmlDoubleElement |
310 | 310 | */ |
311 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
312 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
313 | - return $this->addInToolbar($bts,$callback); |
|
311 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
312 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
313 | + return $this->addInToolbar($bts, $callback); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -320,15 +320,15 @@ discard block |
||
320 | 320 | * @param boolean $labeled |
321 | 321 | * @return \Ajax\common\html\HtmlDoubleElement |
322 | 322 | */ |
323 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
324 | - $bt=new HtmlButton("",$caption); |
|
325 | - $bt->addIcon($icon,$before,$labeled); |
|
323 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
324 | + $bt=new HtmlButton("", $caption); |
|
325 | + $bt->addIcon($icon, $before, $labeled); |
|
326 | 326 | return $this->addInToolbar($bt); |
327 | 327 | } |
328 | 328 | |
329 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
330 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
331 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters); |
|
329 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
330 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
331 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters); |
|
332 | 332 | return $this->addInToolbar($button); |
333 | 333 | } |
334 | 334 | |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model |
359 | 359 | * @return \Ajax\common\Widget |
360 | 360 | */ |
361 | - public function setDefaultValueFunction($defaultValueFunction){ |
|
361 | + public function setDefaultValueFunction($defaultValueFunction) { |
|
362 | 362 | $this->_instanceViewer->setDefaultValueFunction($defaultValueFunction); |
363 | 363 | return $this; |
364 | 364 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | /** |
367 | 367 | * @return callable |
368 | 368 | */ |
369 | - public function getDefaultValueFunction(){ |
|
369 | + public function getDefaultValueFunction() { |
|
370 | 370 | return $this->_instanceViewer->getDefaultValueFunction(); |
371 | 371 | } |
372 | 372 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | * @param string|boolean $disable |
375 | 375 | * @return string |
376 | 376 | */ |
377 | - public function jsDisabled($disable=true){ |
|
377 | + public function jsDisabled($disable=true) { |
|
378 | 378 | return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
379 | 379 | } |
380 | 380 | |
@@ -383,12 +383,12 @@ discard block |
||
383 | 383 | * @param callable $callback function($element) |
384 | 384 | * @return \Ajax\common\html\HtmlDoubleElement |
385 | 385 | */ |
386 | - public function addEditButtonInToolbar($caption,$callback=NULL){ |
|
387 | - $bt=new HtmlButton($this->identifier."-editBtn",$caption); |
|
386 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
387 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
388 | 388 | $bt->setToggle(); |
389 | 389 | $bt->setActive($this->_edition); |
390 | 390 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
391 | - return $this->addInToolbar($bt,$callback); |
|
391 | + return $this->addInToolbar($bt, $callback); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | public function setToolbar(HtmlMenu $_toolbar) { |
@@ -402,34 +402,34 @@ discard block |
||
402 | 402 | } |
403 | 403 | |
404 | 404 | public function getForm() { |
405 | - if(!isset($this->_form)){ |
|
405 | + if (!isset($this->_form)) { |
|
406 | 406 | $this->_form=new HtmlForm("frm-".$this->identifier); |
407 | 407 | $this->setEdition(true); |
408 | 408 | } |
409 | 409 | return $this->_form; |
410 | 410 | } |
411 | 411 | |
412 | - public function run(JsUtils $js){ |
|
412 | + public function run(JsUtils $js) { |
|
413 | 413 | parent::run($js); |
414 | - if(isset($this->_form)){ |
|
414 | + if (isset($this->_form)) { |
|
415 | 415 | $this->runForm($js); |
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
419 | - protected function runForm(JsUtils $js){ |
|
419 | + protected function runForm(JsUtils $js) { |
|
420 | 420 | $fields=$this->getContentInstances(HtmlFormField::class); |
421 | - foreach ($fields as $field){ |
|
421 | + foreach ($fields as $field) { |
|
422 | 422 | $this->_form->addField($field); |
423 | 423 | } |
424 | 424 | return $this->_form->run($js); |
425 | 425 | } |
426 | 426 | |
427 | - protected function _compileForm(){ |
|
428 | - if(isset($this->_form)){ |
|
427 | + protected function _compileForm() { |
|
428 | + if (isset($this->_form)) { |
|
429 | 429 | $noValidate=""; |
430 | - if(\sizeof($this->_form->getValidationParams())>0) |
|
430 | + if (\sizeof($this->_form->getValidationParams())>0) |
|
431 | 431 | $noValidate="novalidate"; |
432 | - $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>"); |
|
432 | + $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>"); |
|
433 | 433 | } |
434 | 434 | } |
435 | 435 | |
@@ -444,33 +444,33 @@ discard block |
||
444 | 444 | return $this; |
445 | 445 | } |
446 | 446 | |
447 | - public function moveFieldTo($from,$to){ |
|
447 | + public function moveFieldTo($from, $to) { |
|
448 | 448 | return $this->_instanceViewer->moveFieldTo($from, $to); |
449 | 449 | } |
450 | 450 | |
451 | - public function swapFields($index1,$index2){ |
|
451 | + public function swapFields($index1, $index2) { |
|
452 | 452 | $index1=$this->_getIndex($index1); |
453 | 453 | $index2=$this->_getIndex($index2); |
454 | 454 | return $this->_instanceViewer->swapFields($index1, $index2); |
455 | 455 | } |
456 | 456 | |
457 | - public function removeField($index){ |
|
457 | + public function removeField($index) { |
|
458 | 458 | $index=$this->_getIndex($index); |
459 | 459 | $this->_instanceViewer->removeField($index); |
460 | 460 | return $this; |
461 | 461 | } |
462 | 462 | |
463 | - public function asModal($header=null){ |
|
464 | - $modal=new HtmlModal("modal-".$this->identifier,$header); |
|
463 | + public function asModal($header=null) { |
|
464 | + $modal=new HtmlModal("modal-".$this->identifier, $header); |
|
465 | 465 | $modal->setContent($this); |
466 | - if(isset($this->_form)){ |
|
466 | + if (isset($this->_form)) { |
|
467 | 467 | $this->_form->onSuccess($modal->jsHide()); |
468 | 468 | } |
469 | 469 | return $modal; |
470 | 470 | } |
471 | 471 | |
472 | 472 | public function addToProperty($name, $value, $separator=" ") { |
473 | - return $this->getHtmlComponent()->addToProperty($name,$value,$separator); |
|
473 | + return $this->getHtmlComponent()->addToProperty($name, $value, $separator); |
|
474 | 474 | } |
475 | 475 | /** |
476 | 476 | * @return mixed |