@@ -6,31 +6,31 @@ discard block |
||
6 | 6 | use Ajax\semantic\html\content\HtmlAccordionItem; |
7 | 7 | use Ajax\JsUtils; |
8 | 8 | |
9 | -class HtmlAccordion extends HtmlSemCollection{ |
|
9 | +class HtmlAccordion extends HtmlSemCollection { |
|
10 | 10 | |
11 | 11 | protected $params=array(); |
12 | 12 | |
13 | - public function __construct( $identifier, $tagName="div", $baseClass="ui"){ |
|
14 | - parent::__construct( $identifier, "div", "ui accordion"); |
|
13 | + public function __construct($identifier, $tagName="div", $baseClass="ui") { |
|
14 | + parent::__construct($identifier, "div", "ui accordion"); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | |
18 | - protected function createItem($value){ |
|
18 | + protected function createItem($value) { |
|
19 | 19 | $count=$this->count(); |
20 | 20 | $title=$value; |
21 | 21 | $content=NULL; |
22 | - if(\is_array($value)){ |
|
23 | - $title=@$value[0];$content=@$value[1]; |
|
22 | + if (\is_array($value)) { |
|
23 | + $title=@$value[0]; $content=@$value[1]; |
|
24 | 24 | } |
25 | - return new HtmlAccordionItem("item-".$this->identifier."-".$count, $title,$content); |
|
25 | + return new HtmlAccordionItem("item-".$this->identifier."-".$count, $title, $content); |
|
26 | 26 | } |
27 | 27 | |
28 | - protected function createCondition($value){ |
|
28 | + protected function createCondition($value) { |
|
29 | 29 | return ($value instanceof HtmlAccordionItem)===false; |
30 | 30 | } |
31 | 31 | |
32 | - public function addPanel($title,$content){ |
|
33 | - return $this->addItem([$title,$content]); |
|
32 | + public function addPanel($title, $content) { |
|
33 | + return $this->addItem([$title, $content]); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @param string $action a Phalcon action |
43 | 43 | * @param array $params |
44 | 44 | */ |
45 | - public function forwardPanel(JsUtils $js,$title,$initialController,$controller,$action,$params=array()){ |
|
46 | - return $this->addPanel($title, $js->forward($initialController, $controller, $action,$params)); |
|
45 | + public function forwardPanel(JsUtils $js, $title, $initialController, $controller, $action, $params=array()) { |
|
46 | + return $this->addPanel($title, $js->forward($initialController, $controller, $action, $params)); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -54,30 +54,30 @@ discard block |
||
54 | 54 | * @param string $viewName |
55 | 55 | * @param $params The parameters to pass to the view |
56 | 56 | */ |
57 | - public function renderViewPanel(JsUtils $js,$title,$initialController, $viewName, $params=array()) { |
|
58 | - return $this->addPanel($title, $js->renderContent($initialController, $viewName,$params)); |
|
57 | + public function renderViewPanel(JsUtils $js, $title, $initialController, $viewName, $params=array()) { |
|
58 | + return $this->addPanel($title, $js->renderContent($initialController, $viewName, $params)); |
|
59 | 59 | } |
60 | 60 | /* |
61 | 61 | * (non-PHPdoc) |
62 | 62 | * @see BaseHtml::run() |
63 | 63 | */ |
64 | 64 | public function run(JsUtils $js) { |
65 | - if(isset($this->_bsComponent)===false) |
|
66 | - $this->_bsComponent=$js->semantic()->accordion("#".$this->identifier,$this->params); |
|
65 | + if (isset($this->_bsComponent)===false) |
|
66 | + $this->_bsComponent=$js->semantic()->accordion("#".$this->identifier, $this->params); |
|
67 | 67 | $this->addEventsOnRun($js); |
68 | 68 | return $this->_bsComponent; |
69 | 69 | } |
70 | 70 | |
71 | - public function setStyled(){ |
|
71 | + public function setStyled() { |
|
72 | 72 | return $this->addToProperty("class", "styled"); |
73 | 73 | } |
74 | 74 | |
75 | - public function setActive($index){ |
|
75 | + public function setActive($index) { |
|
76 | 76 | $this->getItem($index)->setActive(true); |
77 | 77 | return $this; |
78 | 78 | } |
79 | 79 | |
80 | - public function setExclusive($value){ |
|
80 | + public function setExclusive($value) { |
|
81 | 81 | $this->params["exclusive"]=$value; |
82 | 82 | } |
83 | 83 | } |
84 | 84 | \ No newline at end of file |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $this->startIndex=$startIndex; |
52 | 52 | $this->autoActive=$autoActive; |
53 | 53 | $this->_contentSeparator="<div class='divider'> / </div>"; |
54 | - $this->_hrefFunction=function ($e) { |
|
54 | + $this->_hrefFunction=function($e) { |
|
55 | 55 | return $e->getContent(); |
56 | 56 | }; |
57 | 57 | if (isset($hrefFunction)) { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return HtmlBreadcrumbs |
69 | 69 | */ |
70 | 70 | public function autoGetOnClick($targetSelector) { |
71 | - return $this->getOnClick($this->root, $targetSelector, array ("attr" => $this->attr )); |
|
71 | + return $this->getOnClick($this->root, $targetSelector, array("attr" => $this->attr)); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | public function contentAsString() { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | public function setActive($index=null) { |
82 | 82 | if (!isset($index)) { |
83 | - $index=sizeof($this->content) - 1; |
|
83 | + $index=sizeof($this->content)-1; |
|
84 | 84 | } |
85 | 85 | $activeItem=$this->content[$index]; |
86 | 86 | $activeItem->addToProperty("class", "active"); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param Dispatcher $dispatcher the request dispatcher |
94 | 94 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
95 | 95 | */ |
96 | - public function fromDispatcher(JsUtils $js,$dispatcher, $startIndex=0) { |
|
96 | + public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0) { |
|
97 | 97 | return $this->addItems($js->fromDispatcher($dispatcher)); |
98 | 98 | } |
99 | 99 | |
@@ -107,12 +107,12 @@ discard block |
||
107 | 107 | if (!isset($index)) { |
108 | 108 | $index=sizeof($this->content); |
109 | 109 | } |
110 | - if ($this->absolutePaths === true) { |
|
110 | + if ($this->absolutePaths===true) { |
|
111 | 111 | return $this->_hrefFunction($this->content[$index]); |
112 | - } else { |
|
113 | - return $this->root . implode($separator, array_slice(array_map(function ($e) { |
|
112 | + }else { |
|
113 | + return $this->root.implode($separator, array_slice(array_map(function($e) { |
|
114 | 114 | return $this->_hrefFunction($e); |
115 | - }, $this->content), $this->startIndex, $index + 1)); |
|
115 | + }, $this->content), $this->startIndex, $index+1)); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | $this->setActive(); |
147 | 147 | } |
148 | 148 | $count=$this->count(); |
149 | - for($i=1; $i < $count; $i++) { |
|
150 | - $this->content[$i]->wrap($this->getContentDivider($i - 1)); |
|
149 | + for ($i=1; $i<$count; $i++) { |
|
150 | + $this->content[$i]->wrap($this->getContentDivider($i-1)); |
|
151 | 151 | } |
152 | 152 | return parent::compile($js, $view); |
153 | 153 | } |
@@ -157,15 +157,15 @@ discard block |
||
157 | 157 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
158 | 158 | */ |
159 | 159 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
160 | - foreach ( $this->content as $element ) { |
|
160 | + foreach ($this->content as $element) { |
|
161 | 161 | $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
162 | 162 | } |
163 | 163 | return $this; |
164 | 164 | } |
165 | 165 | |
166 | 166 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
167 | - foreach ( $this->content as $element ) { |
|
168 | - if ($element->getProperty($this->attr) != NULL){ |
|
167 | + foreach ($this->content as $element) { |
|
168 | + if ($element->getProperty($this->attr)!=NULL) { |
|
169 | 169 | $element->_ajaxOn($operation, $event, $url, $responseElement, $parameters); |
170 | 170 | } |
171 | 171 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | */ |
181 | 181 | protected function createItem($value) { |
182 | 182 | $count=$this->count(); |
183 | - $itemO=new HtmlSemDoubleElement("item-" . $this->identifier . "-" . $count, "a", "section"); |
|
183 | + $itemO=new HtmlSemDoubleElement("item-".$this->identifier."-".$count, "a", "section"); |
|
184 | 184 | if (\is_array($value)) |
185 | 185 | $itemO->fromArray($value); |
186 | 186 | else { |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | public function addIconAt($icon, $index) { |
193 | 193 | $item=$this->getItem($index); |
194 | 194 | if (isset($item)) { |
195 | - $icon=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
195 | + $icon=new HtmlIcon("icon-".$this->identifier, $icon); |
|
196 | 196 | $item->wrapContent($icon); |
197 | 197 | } |
198 | 198 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | public function addItem($item) { |
201 | 201 | $count=$this->count(); |
202 | 202 | $itemO=parent::addItem($item); |
203 | - $this->addToPropertyCtrl("class", "section", array ("section" )); |
|
203 | + $this->addToPropertyCtrl("class", "section", array("section")); |
|
204 | 204 | $itemO->setProperty($this->attr, $this->getHref($count)); |
205 | 205 | return $itemO; |
206 | 206 | } |
@@ -17,21 +17,21 @@ discard block |
||
17 | 17 | * jQuery Class |
18 | 18 | */ |
19 | 19 | class Jquery { |
20 | - use JqueryEventsTrait,JqueryAjaxTrait,JqueryActionsTrait; |
|
20 | + use JqueryEventsTrait, JqueryAjaxTrait, JqueryActionsTrait; |
|
21 | 21 | protected $_ui; |
22 | 22 | protected $_bootstrap; |
23 | 23 | protected $_semantic; |
24 | 24 | protected $libraryFile; |
25 | 25 | protected $_javascript_folder='js'; |
26 | - protected $jquery_code_for_load=array (); |
|
27 | - protected $jquery_code_for_compile=array (); |
|
26 | + protected $jquery_code_for_load=array(); |
|
27 | + protected $jquery_code_for_compile=array(); |
|
28 | 28 | protected $jquery_corner_active=FALSE; |
29 | 29 | protected $jquery_table_sorter_active=FALSE; |
30 | 30 | protected $jquery_table_sorter_pager_active=FALSE; |
31 | 31 | protected $jsUtils; |
32 | 32 | |
33 | - protected $jquery_events=array ( |
|
34 | - "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" |
|
33 | + protected $jquery_events=array( |
|
34 | + "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" |
|
35 | 35 | ); |
36 | 36 | |
37 | 37 | public function ui($ui=NULL) { |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | return $this->_semantic; |
56 | 56 | } |
57 | 57 | |
58 | - public function __construct($params,$jsUtils) { |
|
58 | + public function __construct($params, $jsUtils) { |
|
59 | 59 | $this->params=array(); |
60 | - foreach ( $params as $key => $val ) { |
|
60 | + foreach ($params as $key => $val) { |
|
61 | 61 | $this->params[$key]=$params[$key]; |
62 | 62 | } |
63 | 63 | $this->jsUtils=$jsUtils; |
@@ -125,12 +125,12 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function _output($array_js='') { |
127 | 127 | if (!is_array($array_js)) { |
128 | - $array_js=array ( |
|
128 | + $array_js=array( |
|
129 | 129 | $array_js |
130 | 130 | ); |
131 | 131 | } |
132 | 132 | |
133 | - foreach ( $array_js as $js ) { |
|
133 | + foreach ($array_js as $js) { |
|
134 | 134 | $this->jquery_code_for_compile[]="\t$js\n"; |
135 | 135 | } |
136 | 136 | } |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | * @param string $param |
143 | 143 | * @param boolean $immediatly delayed if false |
144 | 144 | */ |
145 | - public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) { |
|
145 | + public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) { |
|
146 | 146 | $element=$this->_prep_element($element); |
147 | 147 | if (isset($param)) { |
148 | 148 | $param=$this->_prep_value($param); |
149 | 149 | $str="$({$element}).{$jQueryCall}({$param});"; |
150 | - } else |
|
150 | + }else |
|
151 | 151 | $str="$({$element}).{$jQueryCall}();"; |
152 | 152 | if ($immediatly) |
153 | 153 | $this->jquery_code_for_compile[]=$str; |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @param boolean $immediatly delayed if false |
162 | 162 | * @return string |
163 | 163 | */ |
164 | - public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) { |
|
164 | + public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) { |
|
165 | 165 | $to=$this->_prep_element($to); |
166 | 166 | $element=$this->_prep_element($element); |
167 | 167 | $str="$({$to}).{$jQueryCall}({$element});"; |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function sortable($element, $options=array()) { |
181 | 181 | if (count($options)>0) { |
182 | - $sort_options=array (); |
|
183 | - foreach ( $options as $k => $v ) { |
|
182 | + $sort_options=array(); |
|
183 | + foreach ($options as $k => $v) { |
|
184 | 184 | $sort_options[]="\n\t\t".$k.': '.$v.""; |
185 | 185 | } |
186 | 186 | $sort_options=implode(",", $sort_options); |
187 | - } else { |
|
187 | + }else { |
|
188 | 188 | $sort_options=''; |
189 | 189 | } |
190 | 190 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @param boolean $stopPropagation Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. |
213 | 213 | * @return string |
214 | 214 | */ |
215 | - public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true) { |
|
215 | + public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true) { |
|
216 | 216 | if (is_array($js)) { |
217 | 217 | $js=implode("\n\t\t", $js); |
218 | 218 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
227 | 227 | else |
228 | 228 | $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
229 | - if($immediatly) |
|
229 | + if ($immediatly) |
|
230 | 230 | $this->jquery_code_for_compile[]=$event; |
231 | 231 | return $event; |
232 | 232 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | |
267 | 267 | // External references |
268 | 268 | $external_scripts=implode('', $this->jquery_code_for_load); |
269 | - extract(array ( |
|
269 | + extract(array( |
|
270 | 270 | 'library_src' => $external_scripts |
271 | 271 | )); |
272 | 272 | |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | $script.='});'; |
282 | 282 | |
283 | 283 | $this->jquery_code_for_compile=array(); |
284 | - if($this->params["debug"]==false){ |
|
284 | + if ($this->params["debug"]==false) { |
|
285 | 285 | $script=$this->minify($script); |
286 | 286 | } |
287 | 287 | $output=($script_tags===FALSE) ? $script : $this->inline($script); |
288 | 288 | |
289 | - if ($view!==NULL){ |
|
290 | - $this->jsUtils->createScriptVariable($view,$view_var, $output); |
|
289 | + if ($view!==NULL) { |
|
290 | + $this->jsUtils->createScriptVariable($view, $view_var, $output); |
|
291 | 291 | } |
292 | 292 | return $output; |
293 | 293 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @return void |
303 | 303 | */ |
304 | 304 | public function _clear_compile() { |
305 | - $this->jquery_code_for_compile=array (); |
|
305 | + $this->jquery_code_for_compile=array(); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -311,12 +311,12 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function _document_ready($js) { |
313 | 313 | if (!is_array($js)) { |
314 | - $js=array ( |
|
314 | + $js=array( |
|
315 | 315 | $js |
316 | 316 | ); |
317 | 317 | } |
318 | 318 | |
319 | - foreach ( $js as $script ) { |
|
319 | + foreach ($js as $script) { |
|
320 | 320 | $this->jquery_code_for_compile[]=$script; |
321 | 321 | } |
322 | 322 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @return string |
331 | 331 | */ |
332 | 332 | public function _prep_element($element) { |
333 | - if (strrpos($element, 'this')===false&&strrpos($element, 'event')===false&&strrpos($element, 'self')===false) { |
|
333 | + if (strrpos($element, 'this')===false && strrpos($element, 'event')===false && strrpos($element, 'self')===false) { |
|
334 | 334 | $element='"'.addslashes($element).'"'; |
335 | 335 | } |
336 | 336 | return $element; |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | if (is_array($value)) { |
349 | 349 | $value=implode(",", $value); |
350 | 350 | } |
351 | - if (strrpos($value, 'this')===false&&strrpos($value, 'event')===false&&strrpos($value, 'self')===false) { |
|
351 | + if (strrpos($value, 'this')===false && strrpos($value, 'event')===false && strrpos($value, 'self')===false) { |
|
352 | 352 | $value='"'.$value.'"'; |
353 | 353 | } |
354 | 354 | return $value; |
355 | 355 | } |
356 | 356 | |
357 | 357 | private function minify($input) { |
358 | - if(trim($input) === "") return $input; |
|
358 | + if (trim($input)==="") return $input; |
|
359 | 359 | return preg_replace( |
360 | 360 | array( |
361 | 361 | // Remove comment(s) |
@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
11 | 11 | |
12 | 12 | public abstract function _prep_value($value); |
13 | - public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
13 | + public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
14 | 14 | protected function addLoading(&$retour, $responseElement) { |
15 | 15 | $loading_notifier='<div class="ajax-loader">'; |
16 | 16 | if ($this->ajaxLoader=='') { |
17 | 17 | $loading_notifier.="Loading..."; |
18 | - } else { |
|
18 | + }else { |
|
19 | 19 | $loading_notifier.=$this->ajaxLoader; |
20 | 20 | } |
21 | 21 | $loading_notifier.='</div>'; |
@@ -23,20 +23,20 @@ discard block |
||
23 | 23 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
24 | 24 | } |
25 | 25 | |
26 | - public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
27 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
26 | + public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
27 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
28 | 28 | } |
29 | - public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
30 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
29 | + public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
30 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
31 | 31 | } |
32 | 32 | |
33 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
34 | - if(JString::isNull($params)){$params="{}";} |
|
33 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
34 | + if (JString::isNull($params)) {$params="{}"; } |
|
35 | 35 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
36 | 36 | $retour=$this->_getAjaxUrl($url, $attr); |
37 | 37 | $responseElement=$this->_getResponseElement($responseElement); |
38 | 38 | $retour.="var self=this;\n"; |
39 | - if($hasLoader===true){ |
|
39 | + if ($hasLoader===true) { |
|
40 | 40 | $this->addLoading($retour, $responseElement); |
41 | 41 | } |
42 | 42 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | return $retour; |
47 | 47 | } |
48 | 48 | |
49 | - protected function _getAjaxUrl($url,$attr){ |
|
49 | + protected function _getAjaxUrl($url, $attr) { |
|
50 | 50 | $url=$this->_correctAjaxUrl($url); |
51 | 51 | $retour="url='".$url."';\n"; |
52 | 52 | $slash="/"; |
53 | - if(JString::endswith($url, "/")===true) |
|
53 | + if (JString::endswith($url, "/")===true) |
|
54 | 54 | $slash=""; |
55 | - if(JString::isNotNull($attr)){ |
|
55 | + if (JString::isNotNull($attr)) { |
|
56 | 56 | if ($attr=="value") |
57 | 57 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
58 | - else if($attr!=null && $attr!=="") |
|
58 | + else if ($attr!=null && $attr!=="") |
|
59 | 59 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
60 | 60 | } |
61 | 61 | return $retour; |
62 | 62 | } |
63 | 63 | |
64 | - protected function _getOnAjaxDone($responseElement,$jsCallback){ |
|
64 | + protected function _getOnAjaxDone($responseElement, $jsCallback) { |
|
65 | 65 | $retour=""; |
66 | 66 | if ($responseElement!=="") { |
67 | 67 | $retour="\t$({$responseElement}).html( data );\n"; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | return $retour; |
71 | 71 | } |
72 | 72 | |
73 | - protected function _getResponseElement($responseElement){ |
|
73 | + protected function _getResponseElement($responseElement) { |
|
74 | 74 | if ($responseElement!=="") { |
75 | 75 | $responseElement=$this->_prep_value($responseElement); |
76 | 76 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | protected function _correctAjaxUrl($url) { |
81 | 81 | if ($url!=="/" && JString::endsWith($url, "/")===true) |
82 | 82 | $url=substr($url, 0, strlen($url)-1); |
83 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
83 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
84 | 84 | $url=$this->jsUtils->getUrl($url); |
85 | 85 | } |
86 | 86 | return $url; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param string $jsCallback javascript code to execute after the request |
95 | 95 | * @param boolean $immediatly |
96 | 96 | */ |
97 | - public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
97 | + public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
98 | 98 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
99 | 99 | $retour=$this->_getAjaxUrl($url, $attr); |
100 | 100 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param string $url the request address |
116 | 116 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
117 | 117 | */ |
118 | - public function _jsonOn($event,$element, $url,$parameters=array()) { |
|
118 | + public function _jsonOn($event, $element, $url, $parameters=array()) { |
|
119 | 119 | $preventDefault=true; |
120 | 120 | $stopPropagation=true; |
121 | 121 | $jsCallback=null; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $params="{}"; |
126 | 126 | $immediatly=true; |
127 | 127 | extract($parameters); |
128 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
128 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -137,19 +137,19 @@ discard block |
||
137 | 137 | * @param string $context jquery DOM element, array container. |
138 | 138 | * @param boolean $immediatly |
139 | 139 | */ |
140 | - public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$immediatly=false) { |
|
140 | + public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $immediatly=false) { |
|
141 | 141 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
142 | 142 | $retour=$this->_getAjaxUrl($url, $attr); |
143 | - if($context===null){ |
|
143 | + if ($context===null) { |
|
144 | 144 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
145 | - $newElm = "$('#'+newId)"; |
|
146 | - }else{ |
|
145 | + $newElm="$('#'+newId)"; |
|
146 | + }else { |
|
147 | 147 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
148 | - $newElm = $context.".find('#'+newId)"; |
|
148 | + $newElm=$context.".find('#'+newId)"; |
|
149 | 149 | } |
150 | 150 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
151 | 151 | $retour.="\tdata=$.parseJSON(data);$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone();newElm.attr('id',newId);\n"; |
152 | - $retour.= $appendTo; |
|
152 | + $retour.=$appendTo; |
|
153 | 153 | $retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('[['+key+']]')>-1){\n"."\t\t\t\tcontent=$(html.split('[['+key+']]').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n"; |
154 | 154 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
155 | 155 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -164,26 +164,26 @@ discard block |
||
164 | 164 | * @param string $url the request address |
165 | 165 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null) |
166 | 166 | */ |
167 | - public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) { |
|
167 | + public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
168 | 168 | $preventDefault=true; |
169 | 169 | $stopPropagation=true; |
170 | 170 | $jsCallback=null; |
171 | 171 | $attr="id"; |
172 | 172 | $method="get"; |
173 | - $context = null; |
|
173 | + $context=null; |
|
174 | 174 | $params="{}"; |
175 | 175 | $immediatly=true; |
176 | 176 | extract($parameters); |
177 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
177 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
178 | 178 | } |
179 | 179 | |
180 | - public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
180 | + public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
181 | 181 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
182 | 182 | $retour=$this->_getAjaxUrl($url, $attr); |
183 | 183 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
184 | 184 | $responseElement=$this->_getResponseElement($responseElement); |
185 | 185 | $retour.="var self=this;\n"; |
186 | - if($hasLoader===true){ |
|
186 | + if ($hasLoader===true) { |
|
187 | 187 | $this->addLoading($retour, $responseElement); |
188 | 188 | } |
189 | 189 | $retour.="$.post(url,params).done(function( data ) {\n"; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @param string $responseElement |
211 | 211 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
212 | 212 | */ |
213 | - public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
213 | + public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
214 | 214 | $preventDefault=true; |
215 | 215 | $stopPropagation=true; |
216 | 216 | $jsCallback=null; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $hasLoader=true; |
219 | 219 | $immediatly=true; |
220 | 220 | extract($parameters); |
221 | - return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
221 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param string $responseElement |
232 | 232 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
233 | 233 | */ |
234 | - public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
234 | + public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
235 | 235 | $preventDefault=true; |
236 | 236 | $stopPropagation=true; |
237 | 237 | $jsCallback=null; |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $hasLoader=true; |
240 | 240 | $immediatly=true; |
241 | 241 | extract($parameters); |
242 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
242 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @param string $responseElement |
253 | 253 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true) |
254 | 254 | */ |
255 | - public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
255 | + public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
256 | 256 | $preventDefault=true; |
257 | 257 | $stopPropagation=true; |
258 | 258 | $validation=false; |
@@ -261,6 +261,6 @@ discard block |
||
261 | 261 | $hasLoader=true; |
262 | 262 | $immediatly=true; |
263 | 263 | extract($parameters); |
264 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
264 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | \ No newline at end of file |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * JsUtils Class : Service to be injected |
23 | 23 | */ |
24 | -abstract class JsUtils{ |
|
25 | - use JsUtilsEventsTrait,JsUtilsActionsTrait,JsUtilsAjaxTrait; |
|
24 | +abstract class JsUtils { |
|
25 | + use JsUtilsEventsTrait, JsUtilsActionsTrait, JsUtilsAjaxTrait; |
|
26 | 26 | |
27 | 27 | protected $js; |
28 | 28 | protected $cdns; |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | protected $config; |
52 | 52 | |
53 | 53 | protected function _setDi($di) { |
54 | - if ($this->js!=null&&$di!=null) |
|
54 | + if ($this->js!=null && $di!=null) |
|
55 | 55 | $this->js->setDi($di); |
56 | 56 | } |
57 | 57 | |
58 | 58 | public abstract function getUrl($url); |
59 | - public abstract function addViewElement($identifier,$content,&$view); |
|
60 | - public abstract function createScriptVariable(&$view,$view_var, $output); |
|
59 | + public abstract function addViewElement($identifier, $content, &$view); |
|
60 | + public abstract function createScriptVariable(&$view, $view_var, $output); |
|
61 | 61 | /** |
62 | 62 | * render the content of $controller::$action and set the response to the modal content |
63 | 63 | * @param Controller $initialController |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | * @param string $action a Phalcon action |
66 | 66 | * @param array $params |
67 | 67 | */ |
68 | - public abstract function forward($initialController,$controller,$action,$params); |
|
68 | + public abstract function forward($initialController, $controller, $action, $params); |
|
69 | 69 | /** |
70 | 70 | * render the content of an existing view : $viewName and set the response to the modal content |
71 | 71 | * @param Controller $initialControllerInstance |
72 | 72 | * @param View $viewName |
73 | 73 | * @param $params The parameters to pass to the view |
74 | 74 | */ |
75 | - public abstract function renderContent($initialControllerInstance,$viewName, $params=NULL); |
|
75 | + public abstract function renderContent($initialControllerInstance, $viewName, $params=NULL); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * Collect url parts from the request dispatcher : controllerName, actionName, parameters |
@@ -163,28 +163,28 @@ discard block |
||
163 | 163 | return $this->config; |
164 | 164 | } |
165 | 165 | |
166 | - public function __construct($params=array(),$injected=NULL) { |
|
167 | - $defaults=array ( |
|
166 | + public function __construct($params=array(), $injected=NULL) { |
|
167 | + $defaults=array( |
|
168 | 168 | 'driver' => 'Jquery', |
169 | 169 | 'debug' => true |
170 | 170 | ); |
171 | - foreach ( $defaults as $key => $val ) { |
|
171 | + foreach ($defaults as $key => $val) { |
|
172 | 172 | if (isset($params[$key])===false || $params[$key]==="") { |
173 | 173 | $params[$key]=$defaults[$key]; |
174 | 174 | } |
175 | 175 | } |
176 | - $this->js=new Jquery($params,$this); |
|
176 | + $this->js=new Jquery($params, $this); |
|
177 | 177 | |
178 | - if(\array_key_exists("semantic", $params)){ |
|
178 | + if (\array_key_exists("semantic", $params)) { |
|
179 | 179 | $this->semantic(new Semantic()); |
180 | 180 | } |
181 | - $this->cdns=array (); |
|
181 | + $this->cdns=array(); |
|
182 | 182 | $this->params=$params; |
183 | 183 | $this->injected=$injected; |
184 | 184 | } |
185 | 185 | |
186 | - public function __set($property, $value){ |
|
187 | - switch ($property){ |
|
186 | + public function __set($property, $value) { |
|
187 | + switch ($property) { |
|
188 | 188 | case "bootstrap": |
189 | 189 | $this->bootstrap($value); |
190 | 190 | break; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | - public function getParam($key){ |
|
202 | + public function getParam($key) { |
|
203 | 203 | return $this->params[$key]; |
204 | 204 | } |
205 | 205 | |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function compile(&$view=NULL, $view_var='script_foot', $script_tags=TRUE) { |
239 | 239 | $bs=$this->_bootstrap; |
240 | - if (isset($bs)&&isset($view)) { |
|
240 | + if (isset($bs) && isset($view)) { |
|
241 | 241 | $bs->compileHtml($this, $view); |
242 | 242 | } |
243 | 243 | $sem=$this->_semantic; |
244 | - if (isset($sem)&&isset($view)) { |
|
244 | + if (isset($sem) && isset($view)) { |
|
245 | 245 | $sem->compileHtml($this, $view); |
246 | 246 | } |
247 | 247 | return $this->js->_compile($view, $view_var, $script_tags); |
@@ -308,27 +308,27 @@ discard block |
||
308 | 308 | $json_result=$result->result_array(); |
309 | 309 | } elseif (is_array($result)) { |
310 | 310 | $json_result=$result; |
311 | - } else { |
|
311 | + }else { |
|
312 | 312 | return $this->_prep_args($result); |
313 | 313 | } |
314 | - } else { |
|
314 | + }else { |
|
315 | 315 | return 'null'; |
316 | 316 | } |
317 | 317 | return $this->_create_json($json_result, $match_array_type); |
318 | 318 | } |
319 | 319 | |
320 | 320 | private function _create_json($json_result, $match_array_type) { |
321 | - $json=array (); |
|
321 | + $json=array(); |
|
322 | 322 | $_is_assoc=TRUE; |
323 | - if (!is_array($json_result)&&empty($json_result)) { |
|
323 | + if (!is_array($json_result) && empty($json_result)) { |
|
324 | 324 | show_error("Generate JSON Failed - Illegal key, value pair."); |
325 | 325 | } elseif ($match_array_type) { |
326 | 326 | $_is_assoc=$this->_is_associative_array($json_result); |
327 | 327 | } |
328 | - foreach ( $json_result as $k => $v ) { |
|
328 | + foreach ($json_result as $k => $v) { |
|
329 | 329 | if ($_is_assoc) { |
330 | 330 | $json[]=$this->_prep_args($k, TRUE).':'.$this->generate_json($v, $match_array_type); |
331 | - } else { |
|
331 | + }else { |
|
332 | 332 | $json[]=$this->generate_json($v, $match_array_type); |
333 | 333 | } |
334 | 334 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @return type |
344 | 344 | */ |
345 | 345 | public function _is_associative_array($arr) { |
346 | - foreach ( array_keys($arr) as $key => $val ) { |
|
346 | + foreach (array_keys($arr) as $key => $val) { |
|
347 | 347 | if ($key!==$val) { |
348 | 348 | return TRUE; |
349 | 349 | } |
@@ -362,11 +362,11 @@ discard block |
||
362 | 362 | return 'null'; |
363 | 363 | } elseif (is_bool($result)) { |
364 | 364 | return ($result===TRUE) ? 'true' : 'false'; |
365 | - } elseif (is_string($result)||$is_key) { |
|
366 | - return '"'.str_replace(array ( |
|
367 | - '\\',"\t","\n","\r",'"','/' |
|
368 | - ), array ( |
|
369 | - '\\\\','\\t','\\n',"\\r",'\"','\/' |
|
365 | + } elseif (is_string($result) || $is_key) { |
|
366 | + return '"'.str_replace(array( |
|
367 | + '\\', "\t", "\n", "\r", '"', '/' |
|
368 | + ), array( |
|
369 | + '\\\\', '\\t', '\\n', "\\r", '\"', '\/' |
|
370 | 370 | ), $result).'"'; |
371 | 371 | } elseif (is_scalar($result)) { |
372 | 372 | return $result; |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | |
380 | 380 | public function setCDNs($cdns) { |
381 | 381 | if (is_array($cdns)===false) { |
382 | - $cdns=array ( |
|
382 | + $cdns=array( |
|
383 | 383 | $cdns |
384 | 384 | ); |
385 | 385 | } |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | $hasJQueryUI=false; |
392 | 392 | $hasBootstrap=false; |
393 | 393 | $hasSemantic=false; |
394 | - $result=array (); |
|
395 | - foreach ( $this->cdns as $cdn ) { |
|
396 | - switch(get_class($cdn)) { |
|
394 | + $result=array(); |
|
395 | + foreach ($this->cdns as $cdn) { |
|
396 | + switch (get_class($cdn)) { |
|
397 | 397 | case "Ajax\lib\CDNJQuery": |
398 | 398 | $hasJQuery=true; |
399 | 399 | $result[0]=$cdn; |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | $result[1]=$cdn; |
404 | 404 | break; |
405 | 405 | case "Ajax\lib\CDNCoreCss": |
406 | - if($cdn->getFramework()==="Bootstrap") |
|
406 | + if ($cdn->getFramework()==="Bootstrap") |
|
407 | 407 | $hasBootstrap=true; |
408 | - elseif($cdn->getFramework()==="Semantic") |
|
408 | + elseif ($cdn->getFramework()==="Semantic") |
|
409 | 409 | $hasSemantic=true; |
410 | - if($hasSemantic || $hasBootstrap) |
|
410 | + if ($hasSemantic || $hasBootstrap) |
|
411 | 411 | $result[2]=$cdn; |
412 | 412 | break; |
413 | 413 | } |
@@ -415,14 +415,14 @@ discard block |
||
415 | 415 | if ($hasJQuery===false) { |
416 | 416 | $result[0]=new CDNJQuery("x"); |
417 | 417 | } |
418 | - if ($hasJQueryUI===false&&isset($this->_ui)) { |
|
418 | + if ($hasJQueryUI===false && isset($this->_ui)) { |
|
419 | 419 | $result[1]=new CDNGuiGen("x", $template); |
420 | 420 | } |
421 | - if ($hasBootstrap===false&&isset($this->_bootstrap)) { |
|
422 | - $result[2]=new CDNCoreCss("Bootstrap","x"); |
|
421 | + if ($hasBootstrap===false && isset($this->_bootstrap)) { |
|
422 | + $result[2]=new CDNCoreCss("Bootstrap", "x"); |
|
423 | 423 | } |
424 | - if ($hasSemantic===false&&isset($this->_semantic)) { |
|
425 | - $result[2]=new CDNCoreCss("Semantic","x"); |
|
424 | + if ($hasSemantic===false && isset($this->_semantic)) { |
|
425 | + $result[2]=new CDNCoreCss("Semantic", "x"); |
|
426 | 426 | } |
427 | 427 | ksort($result); |
428 | 428 | return implode("\n", $result); |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use Phalcon\Mvc\View; |
8 | 8 | use Phalcon\Mvc\Controller; |
9 | 9 | |
10 | -class JsUtils extends \Ajax\JsUtils implements InjectionAwareInterface{ |
|
10 | +class JsUtils extends \Ajax\JsUtils implements InjectionAwareInterface { |
|
11 | 11 | protected $_di; |
12 | 12 | public function setDi(DiInterface $di) { |
13 | 13 | $this->_di=$di; |
@@ -18,50 +18,50 @@ discard block |
||
18 | 18 | return $this->_di; |
19 | 19 | } |
20 | 20 | |
21 | - public function getUrl($url){ |
|
21 | + public function getUrl($url) { |
|
22 | 22 | return $this->_di->get("url")->get($url); |
23 | 23 | } |
24 | 24 | |
25 | - public function addViewElement($identifier,$content,&$view){ |
|
25 | + public function addViewElement($identifier, $content, &$view) { |
|
26 | 26 | $controls=$view->getVar("q"); |
27 | - if (isset($controls) === false) { |
|
28 | - $controls=array (); |
|
27 | + if (isset($controls)===false) { |
|
28 | + $controls=array(); |
|
29 | 29 | } |
30 | 30 | $controls[$identifier]=$content; |
31 | 31 | $view->setVar("q", $controls); |
32 | 32 | } |
33 | 33 | |
34 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
35 | - $view->setVar($view_var,$output); |
|
34 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
35 | + $view->setVar($view_var, $output); |
|
36 | 36 | } |
37 | 37 | |
38 | - public function forward($initialController,$controller,$action,$params=array()){ |
|
39 | - $dispatcher = $initialController->dispatcher; |
|
38 | + public function forward($initialController, $controller, $action, $params=array()) { |
|
39 | + $dispatcher=$initialController->dispatcher; |
|
40 | 40 | $dispatcher->setControllerName($controller); |
41 | 41 | $dispatcher->setActionName($action); |
42 | 42 | $dispatcher->dispatch(); |
43 | - $template=$initialController->view->getRender($dispatcher->getControllerName(), $dispatcher->getActionName(),$dispatcher->getParams(), function ($view) { |
|
43 | + $template=$initialController->view->getRender($dispatcher->getControllerName(), $dispatcher->getActionName(), $dispatcher->getParams(), function($view) { |
|
44 | 44 | $view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
45 | 45 | }); |
46 | 46 | return $template; |
47 | 47 | } |
48 | 48 | |
49 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
50 | - list($controller,$action)=\explode("@", $viewName); |
|
51 | - $template=$initialControllerInstance->view->getRender($controller, $action, $params, function ($view) { |
|
49 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
50 | + list($controller, $action)=\explode("@", $viewName); |
|
51 | + $template=$initialControllerInstance->view->getRender($controller, $action, $params, function($view) { |
|
52 | 52 | $view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
53 | 53 | }); |
54 | 54 | return $template; |
55 | 55 | } |
56 | 56 | |
57 | - public function fromDispatcher($dispatcher){ |
|
57 | + public function fromDispatcher($dispatcher) { |
|
58 | 58 | $params=$dispatcher->getParams(); |
59 | 59 | $action=$dispatcher->getActionName(); |
60 | 60 | $items=array($dispatcher->getControllerName()); |
61 | - if(\sizeof($params)>0 || \strtolower($action)!="index" ){ |
|
61 | + if (\sizeof($params)>0 || \strtolower($action)!="index") { |
|
62 | 62 | $items[]=$action; |
63 | - foreach ($params as $p){ |
|
64 | - if(\is_object($p)===false) |
|
63 | + foreach ($params as $p) { |
|
64 | + if (\is_object($p)===false) |
|
65 | 65 | $items[]=$p; |
66 | 66 | } |
67 | 67 | } |
@@ -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 | } |
@@ -4,24 +4,24 @@ discard block |
||
4 | 4 | |
5 | 5 | use Illuminate\Support\Facades\App; |
6 | 6 | |
7 | -class JsUtils extends \Ajax\JsUtils{ |
|
8 | - public function getUrl($url){ |
|
7 | +class JsUtils extends \Ajax\JsUtils { |
|
8 | + public function getUrl($url) { |
|
9 | 9 | return \url($url); |
10 | 10 | } |
11 | - public function addViewElement($identifier,$content,&$view){ |
|
11 | + public function addViewElement($identifier, $content, &$view) { |
|
12 | 12 | $controls=$view->__get("q"); |
13 | - if (isset($controls) === false) { |
|
14 | - $controls=array (); |
|
13 | + if (isset($controls)===false) { |
|
14 | + $controls=array(); |
|
15 | 15 | } |
16 | 16 | $controls[$identifier]=$content; |
17 | 17 | $view->__set("q", $controls); |
18 | 18 | } |
19 | 19 | |
20 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
21 | - $view->__set($view_var,$output); |
|
20 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
21 | + $view->__set($view_var, $output); |
|
22 | 22 | } |
23 | 23 | |
24 | - public function forward($initialControllerInstance,$controllerName,$actionName,$params=NULL){ |
|
24 | + public function forward($initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
25 | 25 | \ob_start(); |
26 | 26 | App::make($controllerName)->{$actionName}($params); |
27 | 27 | $result=\ob_get_contents(); |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | return $result; |
30 | 30 | } |
31 | 31 | |
32 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
33 | - return \view()->make($viewName,$params)->render(); |
|
32 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
33 | + return \view()->make($viewName, $params)->render(); |
|
34 | 34 | } |
35 | 35 | |
36 | - public function fromDispatcher($dispatcher){ |
|
36 | + public function fromDispatcher($dispatcher) { |
|
37 | 37 | return $dispatcher->segments(); |
38 | 38 | } |
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -6,27 +6,27 @@ discard block |
||
6 | 6 | use Symfony\Component\HttpFoundation\Request; |
7 | 7 | use Symfony\Component\HttpKernel\HttpKernelInterface; |
8 | 8 | use Ajax\service\JString; |
9 | -class JsUtils extends \Ajax\JsUtils{ |
|
10 | - public function getUrl($url){ |
|
9 | +class JsUtils extends \Ajax\JsUtils { |
|
10 | + public function getUrl($url) { |
|
11 | 11 | //$request = Request::createFromGlobals(); |
12 | 12 | $router=$this->getInjected(); |
13 | - if(isset($router)===true){ |
|
13 | + if (isset($router)===true) { |
|
14 | 14 | try { |
15 | 15 | $url=$router->generate($url); |
16 | - }catch (\Exception $e){ |
|
16 | + } catch (\Exception $e) { |
|
17 | 17 | return $router->getContext()->getBaseUrl(); |
18 | 18 | } |
19 | 19 | } |
20 | 20 | return $url; |
21 | 21 | } |
22 | - public function addViewElement($identifier,$content,&$view){ |
|
23 | - if(\array_key_exists("q", $view)===false){ |
|
22 | + public function addViewElement($identifier, $content, &$view) { |
|
23 | + if (\array_key_exists("q", $view)===false) { |
|
24 | 24 | $view["q"]=array(); |
25 | 25 | } |
26 | 26 | $view["q"][$identifier]=$content; |
27 | 27 | } |
28 | 28 | |
29 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
29 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
30 | 30 | $view[$view_var]=$output; |
31 | 31 | } |
32 | 32 | |
@@ -37,17 +37,17 @@ discard block |
||
37 | 37 | * @param array $params |
38 | 38 | * @see \Ajax\JsUtils::forward() |
39 | 39 | */ |
40 | - public function forward($initialControllerInstance,$controllerName,$actionName,$params=array()){ |
|
40 | + public function forward($initialControllerInstance, $controllerName, $actionName, $params=array()) { |
|
41 | 41 | $path=$params; |
42 | - $request = $initialControllerInstance->get('request_stack')->getCurrentRequest(); |
|
43 | - $path['_forwarded'] = $request->attributes; |
|
44 | - $path['_controller'] = $controllerName.":".$actionName; |
|
45 | - $subRequest = $request->duplicate([], null, $path); |
|
46 | - $response= $initialControllerInstance->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST); |
|
42 | + $request=$initialControllerInstance->get('request_stack')->getCurrentRequest(); |
|
43 | + $path['_forwarded']=$request->attributes; |
|
44 | + $path['_controller']=$controllerName.":".$actionName; |
|
45 | + $subRequest=$request->duplicate([], null, $path); |
|
46 | + $response=$initialControllerInstance->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST); |
|
47 | 47 | return $response->getContent(); |
48 | 48 | } |
49 | 49 | |
50 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
50 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
51 | 51 | if ($initialControllerInstance->has('templating')) { |
52 | 52 | return $initialControllerInstance->get('templating')->render($viewName, $params); |
53 | 53 | } |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | return $initialControllerInstance->get('twig')->render($viewName, $params); |
60 | 60 | } |
61 | 61 | |
62 | - public function fromDispatcher($dispatcher){ |
|
63 | - $request = $dispatcher->get('request_stack')->getCurrentRequest(); |
|
62 | + public function fromDispatcher($dispatcher) { |
|
63 | + $request=$dispatcher->get('request_stack')->getCurrentRequest(); |
|
64 | 64 | $uri=$request->getPathInfo(); |
65 | - if(JString::startswith($uri, "/")){ |
|
65 | + if (JString::startswith($uri, "/")) { |
|
66 | 66 | $uri=\substr($uri, 1); |
67 | 67 | } |
68 | 68 | return \explode("/", $uri); |