@@ -15,16 +15,16 @@ discard block |
||
15 | 15 | * @license Apache 2 http://www.apache.org/licenses/ |
16 | 16 | **/ |
17 | 17 | class Jquery { |
18 | - use JqueryEventsTrait,JqueryAjaxTrait,JqueryActionsTrait; |
|
18 | + use JqueryEventsTrait, JqueryAjaxTrait, JqueryActionsTrait; |
|
19 | 19 | protected $_ui; |
20 | 20 | protected $_bootstrap; |
21 | 21 | protected $_semantic; |
22 | - protected $jquery_code_for_compile=array (); |
|
22 | + protected $jquery_code_for_compile=array(); |
|
23 | 23 | protected $jsUtils; |
24 | 24 | protected $params; |
25 | 25 | |
26 | - protected $jquery_events=array ( |
|
27 | - "bind","blur","change","click","dblclick","delegate","die","error","focus","focusin","focusout","hover","keydown","keypress","keyup","live","load","mousedown","mousseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","off","on","one","ready","resize","scroll","select","submit","toggle","trigger","triggerHandler","undind","undelegate","unload" |
|
26 | + protected $jquery_events=array( |
|
27 | + "bind", "blur", "change", "click", "dblclick", "delegate", "die", "error", "focus", "focusin", "focusout", "hover", "keydown", "keypress", "keyup", "live", "load", "mousedown", "mousseenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "off", "on", "one", "ready", "resize", "scroll", "select", "submit", "toggle", "trigger", "triggerHandler", "undind", "undelegate", "unload" |
|
28 | 28 | ); |
29 | 29 | |
30 | 30 | public function ui($ui=NULL) { |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | return $this->_semantic; |
49 | 49 | } |
50 | 50 | |
51 | - public function __construct($params,$jsUtils) { |
|
51 | + public function __construct($params, $jsUtils) { |
|
52 | 52 | $this->params=array(); |
53 | - foreach ( $params as $key => $val ) { |
|
53 | + foreach ($params as $key => $val) { |
|
54 | 54 | $this->params[$key]=$params[$key]; |
55 | 55 | } |
56 | 56 | $this->jsUtils=$jsUtils; |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function _output($array_js='') { |
116 | 116 | if (!is_array($array_js)) { |
117 | - $array_js=array ( |
|
117 | + $array_js=array( |
|
118 | 118 | $array_js |
119 | 119 | ); |
120 | 120 | } |
121 | 121 | |
122 | - foreach ( $array_js as $js ) { |
|
122 | + foreach ($array_js as $js) { |
|
123 | 123 | $this->jquery_code_for_compile[]="\t$js\n"; |
124 | 124 | } |
125 | 125 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param string $param |
132 | 132 | * @param boolean $immediatly delayed if false |
133 | 133 | */ |
134 | - public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) { |
|
134 | + public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) { |
|
135 | 135 | $element=Javascript::prep_element($element); |
136 | 136 | if (isset($param)) { |
137 | 137 | $param=Javascript::prep_value($param); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @param boolean $immediatly delayed if false |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) { |
|
153 | + public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) { |
|
154 | 154 | $to=Javascript::prep_element($to); |
155 | 155 | $element=Javascript::prep_element($element); |
156 | 156 | $str="$({$to}).{$jQueryCall}({$element});"; |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function sortable($element, $options=array()) { |
170 | 170 | if (count($options)>0) { |
171 | - $sort_options=array (); |
|
172 | - foreach ( $options as $k => $v ) { |
|
171 | + $sort_options=array(); |
|
172 | + foreach ($options as $k => $v) { |
|
173 | 173 | $sort_options[]="\n\t\t".$k.': '.$v.""; |
174 | 174 | } |
175 | 175 | $sort_options=implode(",", $sort_options); |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @param boolean $stopPropagation Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true) { |
|
204 | + public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true) { |
|
205 | 205 | if (\is_array($js)) { |
206 | 206 | $js=implode("\n\t\t", $js); |
207 | 207 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
216 | 216 | else |
217 | 217 | $event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
218 | - if($immediatly) |
|
218 | + if ($immediatly) |
|
219 | 219 | $this->jquery_code_for_compile[]=$event; |
220 | 220 | return $event; |
221 | 221 | } |
@@ -247,18 +247,18 @@ discard block |
||
247 | 247 | $script.='});'; |
248 | 248 | |
249 | 249 | $this->jquery_code_for_compile=array(); |
250 | - if($this->params["debug"]===false){ |
|
250 | + if ($this->params["debug"]===false) { |
|
251 | 251 | $script=$this->minify($script); |
252 | 252 | } |
253 | 253 | $output=($script_tags===FALSE) ? $script : $this->inline($script); |
254 | 254 | |
255 | - if ($view!==NULL){ |
|
256 | - $this->jsUtils->createScriptVariable($view,$view_var, $output); |
|
255 | + if ($view!==NULL) { |
|
256 | + $this->jsUtils->createScriptVariable($view, $view_var, $output); |
|
257 | 257 | } |
258 | 258 | return $output; |
259 | 259 | } |
260 | 260 | |
261 | - private function _compileLibrary($library){ |
|
261 | + private function _compileLibrary($library) { |
|
262 | 262 | if ($library!=NULL) { |
263 | 263 | if ($library->isAutoCompile()) { |
264 | 264 | $library->compile(true); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @return void |
277 | 277 | */ |
278 | 278 | public function _clear_compile() { |
279 | - $this->jquery_code_for_compile=array (); |
|
279 | + $this->jquery_code_for_compile=array(); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -285,18 +285,18 @@ discard block |
||
285 | 285 | */ |
286 | 286 | public function _document_ready($js) { |
287 | 287 | if (!is_array($js)) { |
288 | - $js=array ( |
|
288 | + $js=array( |
|
289 | 289 | $js |
290 | 290 | ); |
291 | 291 | } |
292 | 292 | |
293 | - foreach ( $js as $script ) { |
|
293 | + foreach ($js as $script) { |
|
294 | 294 | $this->jquery_code_for_compile[]=$script; |
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
298 | 298 | private function minify($input) { |
299 | - if(trim($input) === "") return $input; |
|
299 | + if (trim($input)==="") return $input; |
|
300 | 300 | return preg_replace( |
301 | 301 | array( |
302 | 302 | // Remove comment(s) |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | protected $class="dropdown-toggle"; |
18 | 18 | protected $mClass="dropdown"; |
19 | 19 | protected $mTagName="div"; |
20 | - protected $items=array (); |
|
20 | + protected $items=array(); |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @return HtmlDropdownItem |
88 | 88 | */ |
89 | 89 | public function addItem($caption, $href="#") { |
90 | - if($caption instanceof HtmlDropdownItem){ |
|
90 | + if ($caption instanceof HtmlDropdownItem) { |
|
91 | 91 | $item=$caption; |
92 | - }else{ |
|
92 | + } else { |
|
93 | 93 | $iid=$this->getItemsCount()+1; |
94 | 94 | $item=new HtmlDropdownItem($this->identifier."-dropdown-item-".$iid); |
95 | 95 | $item->setCaption($caption)->setHref($href); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | public function addItems($items) { |
110 | 110 | $iid=$this->getItemsCount()+1; |
111 | 111 | if (\is_array($items)) { |
112 | - foreach ( $items as $item ) { |
|
112 | + foreach ($items as $item) { |
|
113 | 113 | if (is_string($item)) { |
114 | 114 | $this->addItem($item); |
115 | 115 | } else if (\is_array($item)) { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | } |
137 | 137 | |
138 | 138 | public function setItems($items) { |
139 | - $this->items=array (); |
|
139 | + $this->items=array(); |
|
140 | 140 | $this->addItems($items); |
141 | 141 | } |
142 | 142 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function run(JsUtils $js) { |
173 | 173 | if ($this->getProperty("role")==="nav") { |
174 | - foreach ( $this->items as $dropdownItem ) { |
|
174 | + foreach ($this->items as $dropdownItem) { |
|
175 | 175 | $dropdownItem->runNav($js); |
176 | 176 | } |
177 | 177 | } |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | /* (non-PHPdoc) |
264 | 264 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
265 | 265 | */ |
266 | - public function on($event, $jsCode, $stopPropagation = false, $preventDefault = false) { |
|
267 | - foreach ($this->items as $item){ |
|
268 | - $item->on($event, $jsCode,$stopPropagation,$preventDefault); |
|
266 | + public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
|
267 | + foreach ($this->items as $item) { |
|
268 | + $item->on($event, $jsCode, $stopPropagation, $preventDefault); |
|
269 | 269 | } |
270 | 270 | } |
271 | 271 |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public function __construct($identifier, $brand="Brand", $brandHref="#") { |
33 | 33 | parent::__construct($identifier); |
34 | 34 | $this->_template=include 'templates/tplNavbar.php'; |
35 | - $this->navZones=array (); |
|
35 | + $this->navZones=array(); |
|
36 | 36 | $this->class="navbar-default"; |
37 | 37 | $this->brand=$brand; |
38 | 38 | $this->brandHref=$brandHref; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | public function setBrandImage($imageSrc) { |
63 | - $this->brandImage=PhalconUtils::image(array ( |
|
63 | + $this->brandImage=PhalconUtils::image(array( |
|
64 | 64 | $imageSrc, |
65 | 65 | "alt" => $this->brand |
66 | 66 | )); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | public function setNavZones($navZones) { |
109 | 109 | if (\is_array($navZones)) { |
110 | - foreach ( $navZones as $zoneType => $zoneArray ) { |
|
110 | + foreach ($navZones as $zoneType => $zoneArray) { |
|
111 | 111 | if (is_string($zoneType)) { |
112 | 112 | $zone=$this->addZone($zoneType); |
113 | 113 | $zone->fromArray($zoneArray); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | if ($index<$nb) |
148 | 148 | $zone=$this->navZones [$index]; |
149 | 149 | } else { |
150 | - for($i=0; $i<$nb; $i++) { |
|
150 | + for ($i=0; $i<$nb; $i++) { |
|
151 | 151 | if ($this->navZones [$i]->getIdentifier()===$index) { |
152 | 152 | $zone=$this->navZones [$i]; |
153 | 153 | break; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | public function run(JsUtils $js) { |
161 | - foreach ( $this->navZones as $zone ) { |
|
161 | + foreach ($this->navZones as $zone) { |
|
162 | 162 | $zone->run($js); |
163 | 163 | } |
164 | 164 | if ($this->hasScrollspy) { |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | public function setFluid($fluid) { |
183 | - if($fluid===true){ |
|
183 | + if ($fluid===true) { |
|
184 | 184 | $this->fluid="container-fluid"; |
185 | - }else{ |
|
185 | + } else { |
|
186 | 186 | $this->fluid="container"; |
187 | 187 | } |
188 | 188 | return $this; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | class HtmlModal extends BaseHtml { |
15 | 15 | protected $title="Titre de ma boîte"; |
16 | 16 | protected $content=""; |
17 | - protected $buttons=array (); |
|
17 | + protected $buttons=array(); |
|
18 | 18 | protected $showOnStartup=false; |
19 | 19 | protected $draggable=false; |
20 | 20 | protected $validCondition=NULL; |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | public function __construct($identifier, $title="", $content="", $buttonCaptions=array()) { |
28 | 28 | parent::__construct($identifier); |
29 | 29 | $this->_template=include 'templates/tplModal.php'; |
30 | - $this->buttons=array (); |
|
30 | + $this->buttons=array(); |
|
31 | 31 | $this->title=$title; |
32 | 32 | $this->content=$content; |
33 | - foreach ( $buttonCaptions as $button ) { |
|
33 | + foreach ($buttonCaptions as $button) { |
|
34 | 34 | $this->addButton($button); |
35 | 35 | } |
36 | 36 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param string $value |
66 | 66 | * @return HtmlButton |
67 | 67 | */ |
68 | - public function addOkayButton($value="Okay",$jsCode="") { |
|
68 | + public function addOkayButton($value="Okay", $jsCode="") { |
|
69 | 69 | $btn=$this->addButton($value, "btn-primary"); |
70 | 70 | $btn->onClick("if(".$this->getValidCondition()."){ ".$jsCode."$('#".$this->identifier."').modal('hide');}"); |
71 | 71 | return $btn; |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * @param string $viewName |
115 | 115 | * @param $params The parameters to pass to the view |
116 | 116 | */ |
117 | - public function renderView(JsUtils $js,$initialController,$viewName, $params=array()) { |
|
118 | - $this->content=$js->renderContent($initialController, $viewName,$params); |
|
117 | + public function renderView(JsUtils $js, $initialController, $viewName, $params=array()) { |
|
118 | + $this->content=$js->renderContent($initialController, $viewName, $params); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @param string $actionName the action name |
127 | 127 | * @param array $params |
128 | 128 | */ |
129 | - public function forward(JsUtils $js,$initialControllerInstance,$controllerName,$actionName,$params=NULL){ |
|
130 | - $this->content=$js->forward($initialControllerInstance, $controllerName, $actionName,$params); |
|
129 | + public function forward(JsUtils $js, $initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
130 | + $this->content=$js->forward($initialControllerInstance, $controllerName, $actionName, $params); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /* |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | * @see BaseHtml::run() |
136 | 136 | */ |
137 | 137 | public function run(JsUtils $js) { |
138 | - if($this->content instanceof BaseHtml){ |
|
138 | + if ($this->content instanceof BaseHtml) { |
|
139 | 139 | $this->content->run($js); |
140 | 140 | } |
141 | - $this->_bsComponent=$js->bootstrap()->modal("#".$this->identifier, array ( |
|
141 | + $this->_bsComponent=$js->bootstrap()->modal("#".$this->identifier, array( |
|
142 | 142 | "show" => $this->showOnStartup |
143 | 143 | )); |
144 | 144 | if ($this->draggable) |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | parent::__construct($identifier); |
28 | 28 | $this->tagName="ul"; |
29 | 29 | $this->_template='<%tagName% id="%identifier%" class="nav navbar-nav %class%">%elements%</%tagName%>'; |
30 | - $this->elements=array (); |
|
30 | + $this->elements=array(); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function setClass($value) { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | public function addElement($element) { |
42 | - if($element instanceof HtmlLink){ |
|
42 | + if ($element instanceof HtmlLink) { |
|
43 | 43 | $this->addLink($element); |
44 | 44 | } else if (is_object($element)) { |
45 | 45 | $this->elements []=$element; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | public function addElements($elements) { |
61 | 61 | if (\is_array($elements)) { |
62 | - foreach ( $elements as $key => $element ) { |
|
62 | + foreach ($elements as $key => $element) { |
|
63 | 63 | $iid=$this->getElementsCount()+1; |
64 | 64 | if ($element instanceof HtmlDropdownItem) |
65 | 65 | $this->elements []=$element; |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | public function addLink($caption, $href="#") { |
88 | 88 | $iid=$this->getElementsCount()+1; |
89 | 89 | $li=new HtmlBsDoubleElement($this->identifier."-li-".$iid, "li"); |
90 | - if($caption instanceof HtmlLink){ |
|
90 | + if ($caption instanceof HtmlLink) { |
|
91 | 91 | $link=$caption; |
92 | - }else{ |
|
92 | + } else { |
|
93 | 93 | $link=new HtmlLink($this->identifier."-link-".$iid, $href, $caption); |
94 | 94 | } |
95 | 95 | $li->setContent($link); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | public function run(JsUtils $js) { |
125 | - foreach ( $this->elements as $element ) { |
|
125 | + foreach ($this->elements as $element) { |
|
126 | 126 | $element->run($js); |
127 | 127 | } |
128 | 128 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param int $index |
144 | 144 | * @return BaseHtml |
145 | 145 | */ |
146 | - public function getElement($index){ |
|
146 | + public function getElement($index) { |
|
147 | 147 | return $this->elements[$index]; |
148 | 148 | } |
149 | 149 | } |
150 | 150 | \ No newline at end of file |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | protected $attr; |
20 | 20 | |
21 | 21 | |
22 | - public function __construct($identifier,$tagName){ |
|
23 | - parent::__construct($identifier,$tagName); |
|
22 | + public function __construct($identifier, $tagName) { |
|
23 | + parent::__construct($identifier, $tagName); |
|
24 | 24 | $this->root=""; |
25 | 25 | $this->attr="data-ajax"; |
26 | 26 | } |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | * @param string $targetSelector the target of the get |
32 | 32 | * @return HtmlNavElement |
33 | 33 | */ |
34 | - public function autoGetOnClick($targetSelector){ |
|
35 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
34 | + public function autoGetOnClick($targetSelector) { |
|
35 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
36 | 36 | } |
37 | 37 | |
38 | - public function contentAsString(){ |
|
38 | + public function contentAsString() { |
|
39 | 39 | return implode("", $this->content); |
40 | 40 | } |
41 | 41 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | * Generate the jquery script to set the elements to the HtmlNavElement |
44 | 44 | * @param JsUtils $jsUtils |
45 | 45 | */ |
46 | - public function jsSetContent(JsUtils $jsUtils){ |
|
47 | - $jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true); |
|
46 | + public function jsSetContent(JsUtils $jsUtils) { |
|
47 | + $jsUtils->html("#".$this->identifier, str_replace("\"", "'", $this->contentAsString()), true); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function getRoot() { |
51 | 51 | return $this->root; |
52 | 52 | } |
53 | 53 | public function setRoot($root) { |
54 | - $this->root = $root; |
|
54 | + $this->root=$root; |
|
55 | 55 | return $this; |
56 | 56 | } |
57 | 57 | public function getAttr() { |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | * @return HtmlNavElement |
65 | 65 | */ |
66 | 66 | public function setAttr($attr) { |
67 | - $this->attr = $attr; |
|
67 | + $this->attr=$attr; |
|
68 | 68 | return $this; |
69 | 69 | } |
70 | 70 | |
71 | 71 | public function __call($method, $args) { |
72 | - if(isset($this->$method) && is_callable($this->$method)) { |
|
72 | + if (isset($this->$method) && is_callable($this->$method)) { |
|
73 | 73 | return call_user_func_array( |
74 | 74 | $this->$method, |
75 | 75 | $args |
@@ -77,6 +77,6 @@ discard block |
||
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | - abstract public function fromDispatcher(JsUtils $js,$dispatcher,$startIndex=0); |
|
80 | + abstract public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0); |
|
81 | 81 | |
82 | 82 | } |
83 | 83 | \ No newline at end of file |
@@ -4,14 +4,14 @@ discard block |
||
4 | 4 | |
5 | 5 | use yii\helpers\Url; |
6 | 6 | |
7 | -class JsUtils extends \Ajax\JsUtils{ |
|
8 | - public function getUrl($url){ |
|
9 | - if($url==="") |
|
7 | +class JsUtils extends \Ajax\JsUtils { |
|
8 | + public function getUrl($url) { |
|
9 | + if ($url==="") |
|
10 | 10 | $url="/"; |
11 | 11 | return Url::toRoute($url); |
12 | 12 | } |
13 | 13 | |
14 | - public function addViewElement($identifier,$content,&$view){ |
|
14 | + public function addViewElement($identifier, $content, &$view) { |
|
15 | 15 | $params=$view->params; |
16 | 16 | if (\array_key_exists("q", $params)===false) { |
17 | 17 | $view->params["q"]=array(); |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | $view->params["q"][$identifier]=$content; |
20 | 20 | } |
21 | 21 | |
22 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
22 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
23 | 23 | $view->params[$view_var]=$output; |
24 | 24 | } |
25 | 25 | |
26 | - public function forward($initialControllerInstance,$controllerName,$actionName,$params=array()){ |
|
26 | + public function forward($initialControllerInstance, $controllerName, $actionName, $params=array()) { |
|
27 | 27 | \ob_start(); |
28 | 28 | $ctrInfo=\yii::$app->createController($controllerName."/".$actionName); |
29 | 29 | $ctrInfo[0]->{$ctrInfo[1]}($params); |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | return $result; |
33 | 33 | } |
34 | 34 | |
35 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
36 | - return \yii::$app->view->render($viewName,$params); |
|
35 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
36 | + return \yii::$app->view->render($viewName, $params); |
|
37 | 37 | } |
38 | 38 | |
39 | - public function fromDispatcher($dispatcher){ |
|
39 | + public function fromDispatcher($dispatcher) { |
|
40 | 40 | $uri=new \Ajax\php\yii\URI(); |
41 | 41 | return $uri->segment_array(); |
42 | 42 | } |
@@ -18,46 +18,46 @@ discard block |
||
18 | 18 | * @property FormInstanceViewer $_instanceViewer |
19 | 19 | */ |
20 | 20 | class DataForm extends Widget { |
21 | - use FormFieldAsTrait,FormTrait; |
|
21 | + use FormFieldAsTrait, FormTrait; |
|
22 | 22 | |
23 | 23 | public function __construct($identifier, $modelInstance=NULL) { |
24 | - parent::__construct($identifier, null,$modelInstance); |
|
24 | + parent::__construct($identifier, null, $modelInstance); |
|
25 | 25 | $this->_init(new FormInstanceViewer($identifier), "form", new HtmlForm($identifier), true); |
26 | 26 | } |
27 | 27 | |
28 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
28 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
29 | 29 | $this->_instanceViewer->setInstance($this->_modelInstance); |
30 | 30 | |
31 | 31 | $form=$this->content["form"]; |
32 | 32 | $this->_generateContent($form); |
33 | 33 | |
34 | - if(isset($this->_toolbar)){ |
|
34 | + if (isset($this->_toolbar)) { |
|
35 | 35 | $this->_setToolbarPosition($form); |
36 | 36 | } |
37 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]); |
|
38 | - return parent::compile($js,$view); |
|
37 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]); |
|
38 | + return parent::compile($js, $view); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @param HtmlForm $form |
43 | 43 | */ |
44 | - protected function _generateContent($form){ |
|
45 | - $values= $this->_instanceViewer->getValues(); |
|
44 | + protected function _generateContent($form) { |
|
45 | + $values=$this->_instanceViewer->getValues(); |
|
46 | 46 | $count=$this->_instanceViewer->count(); |
47 | 47 | |
48 | 48 | $separators=$this->_instanceViewer->getSeparators(); |
49 | 49 | $size=\sizeof($separators); |
50 | - if($size===1){ |
|
51 | - foreach ($values as $v){ |
|
50 | + if ($size===1) { |
|
51 | + foreach ($values as $v) { |
|
52 | 52 | $form->addField($v); |
53 | 53 | } |
54 | - }else{ |
|
54 | + } else { |
|
55 | 55 | $separators[]=$count; |
56 | - for($i=0;$i<$size;$i++){ |
|
57 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
58 | - if(\sizeof($fields)===1){ |
|
56 | + for ($i=0; $i<$size; $i++) { |
|
57 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
58 | + if (\sizeof($fields)===1) { |
|
59 | 59 | $form->addField($fields[0]); |
60 | - }else |
|
60 | + } else |
|
61 | 61 | $form->addFields($fields); |
62 | 62 | } |
63 | 63 | } |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | /** |
67 | 67 | * @return HtmlForm |
68 | 68 | */ |
69 | - protected function getForm(){ |
|
69 | + protected function getForm() { |
|
70 | 70 | return $this->content["form"]; |
71 | 71 | } |
72 | 72 | |
73 | - public function addSeparatorAfter($fieldNum){ |
|
73 | + public function addSeparatorAfter($fieldNum) { |
|
74 | 74 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
75 | 75 | return $this; |
76 | 76 | } |
@@ -84,26 +84,26 @@ discard block |
||
84 | 84 | return $this; |
85 | 85 | } |
86 | 86 | |
87 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){ |
|
88 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
89 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement); |
|
87 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) { |
|
88 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
89 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement); |
|
90 | 90 | return $this->addInToolbar($button); |
91 | 91 | } |
92 | 92 | |
93 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
94 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle){ |
|
95 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
96 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement); |
|
93 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
94 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle){ |
|
95 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
96 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement); |
|
97 | 97 | return $button; |
98 | - }, $index,$attributes); |
|
98 | + }, $index, $attributes); |
|
99 | 99 | } |
100 | 100 | |
101 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
102 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
103 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
101 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
102 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
103 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
104 | 104 | $button->setProperty("type", "reset"); |
105 | 105 | return $button; |
106 | - }, $index,$attributes); |
|
106 | + }, $index, $attributes); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -15,22 +15,22 @@ discard block |
||
15 | 15 | * @property object $_modelInstance |
16 | 16 | */ |
17 | 17 | |
18 | -trait FormFieldAsTrait{ |
|
18 | +trait FormFieldAsTrait { |
|
19 | 19 | |
20 | 20 | abstract protected function _getFieldIdentifier($prefix); |
21 | - abstract public function setValueFunction($index,$callback); |
|
22 | - abstract protected function _applyAttributes($element,&$attributes,$index); |
|
21 | + abstract public function setValueFunction($index, $callback); |
|
22 | + abstract protected function _applyAttributes($element, &$attributes, $index); |
|
23 | 23 | abstract public function getIdentifier(); |
24 | 24 | |
25 | - private function _getLabelField($caption,$icon=NULL){ |
|
26 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
25 | + private function _getLabelField($caption, $icon=NULL) { |
|
26 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
27 | 27 | return $label; |
28 | 28 | } |
29 | 29 | |
30 | - protected function _addRules($element,&$attributes){ |
|
31 | - if(isset($attributes["rules"])){ |
|
30 | + protected function _addRules($element, &$attributes) { |
|
31 | + if (isset($attributes["rules"])) { |
|
32 | 32 | $rules=$attributes["rules"]; |
33 | - if(\is_array($rules)){ |
|
33 | + if (\is_array($rules)) { |
|
34 | 34 | $element->addRules($rules); |
35 | 35 | } |
36 | 36 | else |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | - protected function _fieldAs($elementCallback,$index,$attributes=NULL,$identifier=null){ |
|
43 | - $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback){ |
|
42 | + protected function _fieldAs($elementCallback, $index, $attributes=NULL, $identifier=null) { |
|
43 | + $this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback){ |
|
44 | 44 | $caption=$this->_instanceViewer->getCaption($index); |
45 | 45 | $name=$this->_instanceViewer->getFieldName($index); |
46 | - $element=$elementCallback($this->getIdentifier()."-".$name,$name,$value,$caption); |
|
47 | - if(\is_array($attributes)){ |
|
48 | - $this->_applyAttributes($element, $attributes,$index); |
|
46 | + $element=$elementCallback($this->getIdentifier()."-".$name, $name, $value, $caption); |
|
47 | + if (\is_array($attributes)) { |
|
48 | + $this->_applyAttributes($element, $attributes, $index); |
|
49 | 49 | } |
50 | 50 | return $element; |
51 | 51 | }); |
@@ -53,53 +53,53 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
57 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
58 | - return new HtmlFormRadio($id,$name,$caption,$value); |
|
59 | - }, $index,$attributes); |
|
56 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
57 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
58 | + return new HtmlFormRadio($id, $name, $caption, $value); |
|
59 | + }, $index, $attributes); |
|
60 | 60 | } |
61 | 61 | |
62 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
63 | - return $this->_fieldAs(function($id,$name,$value,$caption,$elements){ |
|
64 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
65 | - }, $index,$attributes); |
|
62 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
63 | + return $this->_fieldAs(function($id, $name, $value, $caption, $elements) { |
|
64 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
65 | + }, $index, $attributes); |
|
66 | 66 | } |
67 | 67 | |
68 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
69 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
70 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
68 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
69 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
70 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
71 | 71 | $textarea->setName($name); |
72 | 72 | return $textarea; |
73 | - }, $index,$attributes); |
|
73 | + }, $index, $attributes); |
|
74 | 74 | } |
75 | 75 | |
76 | - public function fieldAsInput($index,$attributes=NULL){ |
|
77 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
78 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
76 | + public function fieldAsInput($index, $attributes=NULL) { |
|
77 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
78 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
79 | 79 | $input->setName($name); |
80 | 80 | return $input; |
81 | - }, $index,$attributes); |
|
81 | + }, $index, $attributes); |
|
82 | 82 | } |
83 | 83 | |
84 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
85 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
86 | - return new HtmlFormCheckbox($id,$caption,$value); |
|
87 | - }, $index,$attributes); |
|
84 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
85 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
86 | + return new HtmlFormCheckbox($id, $caption, $value); |
|
87 | + }, $index, $attributes); |
|
88 | 88 | } |
89 | 89 | |
90 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
91 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements,$multiple){ |
|
92 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value,$multiple); |
|
90 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
91 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements, $multiple){ |
|
92 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value, $multiple); |
|
93 | 93 | $dd->setName($name); |
94 | 94 | return $dd; |
95 | - }, $index,$attributes); |
|
95 | + }, $index, $attributes); |
|
96 | 96 | } |
97 | 97 | |
98 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
99 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
100 | - $mess= new HtmlMessage("message-".$id,$value); |
|
98 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
99 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
100 | + $mess=new HtmlMessage("message-".$id, $value); |
|
101 | 101 | $mess->addHeader($caption); |
102 | 102 | return $mess; |
103 | - }, $index,$attributes,"message"); |
|
103 | + }, $index, $attributes, "message"); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | \ No newline at end of file |