@@ -20,6 +20,10 @@ discard block |
||
20 | 20 | protected $attr; |
21 | 21 | |
22 | 22 | |
23 | + /** |
|
24 | + * @param string $identifier |
|
25 | + * @param string $tagName |
|
26 | + */ |
|
23 | 27 | public function __construct($identifier,$tagName){ |
24 | 28 | parent::__construct($identifier,$tagName); |
25 | 29 | $this->root=""; |
@@ -30,7 +34,6 @@ discard block |
||
30 | 34 | * Associate an ajax get to the elements, displayed in $targetSelector |
31 | 35 | * $attr member is used to build each element url |
32 | 36 | * @param string $targetSelector the target of the get |
33 | - * @param string $attr the html attribute used to build the elements url |
|
34 | 37 | * @return HtmlNavElement |
35 | 38 | */ |
36 | 39 | public function autoGetOnClick($targetSelector){ |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | protected $attr; |
21 | 21 | |
22 | 22 | |
23 | - public function __construct($identifier,$tagName){ |
|
24 | - parent::__construct($identifier,$tagName); |
|
23 | + public function __construct($identifier, $tagName) { |
|
24 | + parent::__construct($identifier, $tagName); |
|
25 | 25 | $this->root=""; |
26 | 26 | $this->attr="data-ajax"; |
27 | 27 | } |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | * @param string $attr the html attribute used to build the elements url |
34 | 34 | * @return HtmlNavElement |
35 | 35 | */ |
36 | - public function autoGetOnClick($targetSelector){ |
|
37 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
36 | + public function autoGetOnClick($targetSelector) { |
|
37 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
38 | 38 | } |
39 | 39 | |
40 | - public function contentAsString(){ |
|
40 | + public function contentAsString() { |
|
41 | 41 | return implode("", $this->content); |
42 | 42 | } |
43 | 43 | |
@@ -45,15 +45,15 @@ discard block |
||
45 | 45 | * Generate the jquery script to set the elements to the HtmlNavElement |
46 | 46 | * @param JsUtils $jsUtils |
47 | 47 | */ |
48 | - public function jsSetContent(JsUtils $jsUtils){ |
|
49 | - $jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true); |
|
48 | + public function jsSetContent(JsUtils $jsUtils) { |
|
49 | + $jsUtils->html("#".$this->identifier, str_replace("\"", "'", $this->contentAsString()), true); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | public function getRoot() { |
53 | 53 | return $this->root; |
54 | 54 | } |
55 | 55 | public function setRoot($root) { |
56 | - $this->root = $root; |
|
56 | + $this->root=$root; |
|
57 | 57 | return $this; |
58 | 58 | } |
59 | 59 | public function getAttr() { |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | * @return HtmlNavElement |
67 | 67 | */ |
68 | 68 | public function setAttr($attr) { |
69 | - $this->attr = $attr; |
|
69 | + $this->attr=$attr; |
|
70 | 70 | return $this; |
71 | 71 | } |
72 | 72 | |
73 | 73 | public function __call($method, $args) { |
74 | - if(isset($this->$method) && is_callable($this->$method)) { |
|
74 | + if (isset($this->$method) && is_callable($this->$method)) { |
|
75 | 75 | return call_user_func_array( |
76 | 76 | $this->$method, |
77 | 77 | $args |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | * @param string $tagName container tagName |
269 | 269 | * @return HtmlListgroup |
270 | 270 | */ |
271 | - public function htmlListgroup($identifier,$items=array(),$tagName="ul"){ |
|
272 | - $listGroup=new HtmlListgroup($identifier,$tagName); |
|
271 | + public function htmlListgroup($identifier, $items=array(), $tagName="ul") { |
|
272 | + $listGroup=new HtmlListgroup($identifier, $tagName); |
|
273 | 273 | $listGroup->addItems($items); |
274 | 274 | return $this->addHtmlComponent($listGroup); |
275 | 275 | } |
@@ -294,8 +294,8 @@ discard block |
||
294 | 294 | * @param string $onClick |
295 | 295 | * @return HtmlSplitbutton |
296 | 296 | */ |
297 | - public function htmlSplitbutton($identifier,$value="", $items=array(), $cssStyle="btn-default", $onClick=NULL) { |
|
298 | - return $this->addHtmlComponent(new HtmlSplitbutton($identifier, $value, $items, $cssStyle,$onClick)); |
|
297 | + public function htmlSplitbutton($identifier, $value="", $items=array(), $cssStyle="btn-default", $onClick=NULL) { |
|
298 | + return $this->addHtmlComponent(new HtmlSplitbutton($identifier, $value, $items, $cssStyle, $onClick)); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * @param string $identifier |
304 | 304 | * @return HtmlInputgroup |
305 | 305 | */ |
306 | - public function htmlInputgroup($identifier){ |
|
306 | + public function htmlInputgroup($identifier) { |
|
307 | 307 | return $this->addHtmlComponent(new HtmlInputgroup($identifier)); |
308 | 308 | } |
309 | 309 | |
@@ -315,8 +315,8 @@ discard block |
||
315 | 315 | * @param function $hrefFunction the function who generates the href elements. default : function($e){return $e->getContent()} |
316 | 316 | * @return HtmlBreadcrumbs |
317 | 317 | */ |
318 | - public function htmlBreadcrumbs($identifier,$elements=array(),$autoActive=true,$hrefFunction=NULL){ |
|
319 | - return $this->addHtmlComponent(new HtmlBreadcrumbs($identifier,$elements,$autoActive,$hrefFunction)); |
|
318 | + public function htmlBreadcrumbs($identifier, $elements=array(), $autoActive=true, $hrefFunction=NULL) { |
|
319 | + return $this->addHtmlComponent(new HtmlBreadcrumbs($identifier, $elements, $autoActive, $hrefFunction)); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @param int $active The active page |
329 | 329 | * @return HtmlPagination |
330 | 330 | */ |
331 | - public function htmlPagination($identifier,$from=1,$to=1,$active=NULL,$countVisible=NULL){ |
|
332 | - return $this->addHtmlComponent(new HtmlPagination($identifier,$from,$to,$active,$countVisible)); |
|
331 | + public function htmlPagination($identifier, $from=1, $to=1, $active=NULL, $countVisible=NULL) { |
|
332 | + return $this->addHtmlComponent(new HtmlPagination($identifier, $from, $to, $active, $countVisible)); |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 | \ No newline at end of file |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | protected $_bootstrap; |
22 | 22 | protected $libraryFile; |
23 | 23 | protected $_javascript_folder='js'; |
24 | - protected $jquery_code_for_load=array (); |
|
25 | - protected $jquery_code_for_compile=array (); |
|
24 | + protected $jquery_code_for_load=array(); |
|
25 | + protected $jquery_code_for_compile=array(); |
|
26 | 26 | protected $jquery_corner_active=FALSE; |
27 | 27 | protected $jquery_table_sorter_active=FALSE; |
28 | 28 | protected $jquery_table_sorter_pager_active=FALSE; |
29 | 29 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
30 | - protected $jquery_events=array ( |
|
31 | - "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" |
|
30 | + protected $jquery_events=array( |
|
31 | + "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" |
|
32 | 32 | ); |
33 | 33 | |
34 | 34 | public function setDi($di) { |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function _click($element='this', $js=array(), $ret_false=TRUE) { |
163 | 163 | if (!is_array($js)) { |
164 | - $js=array ( |
|
164 | + $js=array( |
|
165 | 165 | $js |
166 | 166 | ); |
167 | 167 | } |
@@ -356,12 +356,12 @@ discard block |
||
356 | 356 | */ |
357 | 357 | public function _output($array_js='') { |
358 | 358 | if (!is_array($array_js)) { |
359 | - $array_js=array ( |
|
359 | + $array_js=array( |
|
360 | 360 | $array_js |
361 | 361 | ); |
362 | 362 | } |
363 | 363 | |
364 | - foreach ( $array_js as $js ) { |
|
364 | + foreach ($array_js as $js) { |
|
365 | 365 | $this->jquery_code_for_compile[]="\t$js\n"; |
366 | 366 | } |
367 | 367 | } |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @param boolean $immediatly defers the execution if set to false |
417 | 417 | * @return string |
418 | 418 | */ |
419 | - public function after($element='this', $value='', $immediatly=false){ |
|
419 | + public function after($element='this', $value='', $immediatly=false) { |
|
420 | 420 | $element=$this->_prep_element($element); |
421 | 421 | $value=$this->_prep_value($value); |
422 | 422 | $str="$({$element}).after({$value});"; |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | if (isset($value)) { |
438 | 438 | $value=$this->_prep_value($value); |
439 | 439 | $str="$({$element}).attr(\"$attributeName\",{$value});"; |
440 | - } else |
|
440 | + }else |
|
441 | 441 | $str="$({$element}).attr(\"$attributeName\");"; |
442 | 442 | if ($immediatly) |
443 | 443 | $this->jquery_code_for_compile[]=$str; |
@@ -451,12 +451,12 @@ discard block |
||
451 | 451 | * @param string $param |
452 | 452 | * @param boolean $immediatly delayed if false |
453 | 453 | */ |
454 | - public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) { |
|
454 | + public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) { |
|
455 | 455 | $element=$this->_prep_element($element); |
456 | 456 | if (isset($param)) { |
457 | 457 | $param=$this->_prep_value($param); |
458 | 458 | $str="$({$element}).{$jQueryCall}({$param});"; |
459 | - } else |
|
459 | + }else |
|
460 | 460 | $str="$({$element}).{$jQueryCall}();"; |
461 | 461 | if ($immediatly) |
462 | 462 | $this->jquery_code_for_compile[]=$str; |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * @param boolean $immediatly delayed if false |
471 | 471 | * @return string |
472 | 472 | */ |
473 | - public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) { |
|
473 | + public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) { |
|
474 | 474 | $to=$this->_prep_element($to); |
475 | 475 | $element=$this->_prep_element($element); |
476 | 476 | $str="$({$to}).{$jQueryCall}({$element});"; |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | |
497 | 497 | $animations="\t\t\t"; |
498 | 498 | if (is_array($params)) { |
499 | - foreach ( $params as $param => $value ) { |
|
499 | + foreach ($params as $param => $value) { |
|
500 | 500 | $animations.=$param.': \''.$value.'\', '; |
501 | 501 | } |
502 | 502 | } |
@@ -768,12 +768,12 @@ discard block |
||
768 | 768 | */ |
769 | 769 | public function sortable($element, $options=array()) { |
770 | 770 | if (count($options)>0) { |
771 | - $sort_options=array (); |
|
772 | - foreach ( $options as $k => $v ) { |
|
771 | + $sort_options=array(); |
|
772 | + foreach ($options as $k => $v) { |
|
773 | 773 | $sort_options[]="\n\t\t".$k.': '.$v.""; |
774 | 774 | } |
775 | 775 | $sort_options=implode(",", $sort_options); |
776 | - } else { |
|
776 | + }else { |
|
777 | 777 | $sort_options=''; |
778 | 778 | } |
779 | 779 | |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | |
855 | 855 | // External references |
856 | 856 | $external_scripts=implode('', $this->jquery_code_for_load); |
857 | - extract(array ( |
|
857 | + extract(array( |
|
858 | 858 | 'library_src' => $external_scripts |
859 | 859 | )); |
860 | 860 | |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | * @return void |
888 | 888 | */ |
889 | 889 | public function _clear_compile() { |
890 | - $this->jquery_code_for_compile=array (); |
|
890 | + $this->jquery_code_for_compile=array(); |
|
891 | 891 | } |
892 | 892 | |
893 | 893 | // -------------------------------------------------------------------- |
@@ -899,12 +899,12 @@ discard block |
||
899 | 899 | */ |
900 | 900 | public function _document_ready($js) { |
901 | 901 | if (!is_array($js)) { |
902 | - $js=array ( |
|
902 | + $js=array( |
|
903 | 903 | $js |
904 | 904 | ); |
905 | 905 | } |
906 | 906 | |
907 | - foreach ( $js as $script ) { |
|
907 | + foreach ($js as $script) { |
|
908 | 908 | $this->jquery_code_for_compile[]=$script; |
909 | 909 | } |
910 | 910 | } |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | * @return string |
921 | 921 | */ |
922 | 922 | public function _prep_element($element) { |
923 | - if (strrpos($element, 'this')===false&&strrpos($element, 'event')===false) { |
|
923 | + if (strrpos($element, 'this')===false && strrpos($element, 'event')===false) { |
|
924 | 924 | $element='"'.addslashes($element).'"'; |
925 | 925 | } |
926 | 926 | return $element; |
@@ -938,7 +938,7 @@ discard block |
||
938 | 938 | if (is_array($value)) { |
939 | 939 | $value=implode(",", $value); |
940 | 940 | } |
941 | - if (strrpos($value, 'this')===false&&strrpos($value, 'event')===false) { |
|
941 | + if (strrpos($value, 'this')===false && strrpos($value, 'event')===false) { |
|
942 | 942 | $value='"'.$value.'"'; |
943 | 943 | } |
944 | 944 | return $value; |
@@ -953,8 +953,8 @@ discard block |
||
953 | 953 | * @return string |
954 | 954 | */ |
955 | 955 | private function _validate_speed($speed) { |
956 | - if (in_array($speed, array ( |
|
957 | - 'slow','normal','fast' |
|
956 | + if (in_array($speed, array( |
|
957 | + 'slow', 'normal', 'fast' |
|
958 | 958 | ))) { |
959 | 959 | $speed='"'.$speed.'"'; |
960 | 960 | } elseif (preg_match("/[^0-9]/", $speed)) { |
@@ -968,7 +968,7 @@ discard block |
||
968 | 968 | $loading_notifier='<div class="ajax-loader">'; |
969 | 969 | if ($this->ajaxLoader=='') { |
970 | 970 | $loading_notifier.="Loading..."; |
971 | - } else { |
|
971 | + }else { |
|
972 | 972 | $loading_notifier.=$this->ajaxLoader; |
973 | 973 | } |
974 | 974 | $loading_notifier.='</div>'; |
@@ -976,18 +976,18 @@ discard block |
||
976 | 976 | $retour.="\t\t$(\"{$responseElement}\").prepend('{$loading_notifier}');\n"; |
977 | 977 | } |
978 | 978 | |
979 | - public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
980 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
979 | + public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
980 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
981 | 981 | } |
982 | - public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
983 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
982 | + public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
983 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
984 | 984 | } |
985 | 985 | |
986 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
987 | - if(JString::isNull($params)){$params="{}";} |
|
986 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
987 | + if (JString::isNull($params)) {$params="{}"; } |
|
988 | 988 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
989 | 989 | $retour=$this->_getAjaxUrl($url, $attr); |
990 | - if($hasLoader===true){ |
|
990 | + if ($hasLoader===true) { |
|
991 | 991 | $this->addLoading($retour, $responseElement); |
992 | 992 | } |
993 | 993 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
@@ -997,19 +997,19 @@ discard block |
||
997 | 997 | return $retour; |
998 | 998 | } |
999 | 999 | |
1000 | - protected function _getAjaxUrl($url,$attr){ |
|
1000 | + protected function _getAjaxUrl($url, $attr) { |
|
1001 | 1001 | $url=$this->_correctAjaxUrl($url); |
1002 | 1002 | $retour="url='".$url."';\n"; |
1003 | - if(JString::isNotNull($attr)){ |
|
1003 | + if (JString::isNotNull($attr)) { |
|
1004 | 1004 | if ($attr=="value") |
1005 | 1005 | $retour.="url=url+'/'+$(this).val();\n"; |
1006 | - else if($attr!=null && $attr!=="") |
|
1006 | + else if ($attr!=null && $attr!=="") |
|
1007 | 1007 | $retour.="url=url+'/'+$(this).attr('".$attr."');\n"; |
1008 | 1008 | } |
1009 | 1009 | return $retour; |
1010 | 1010 | } |
1011 | 1011 | |
1012 | - protected function _getOnAjaxDone($responseElement,$jsCallback){ |
|
1012 | + protected function _getOnAjaxDone($responseElement, $jsCallback) { |
|
1013 | 1013 | $retour=""; |
1014 | 1014 | if ($responseElement!=="") { |
1015 | 1015 | $responseElement=$this->_prep_value($responseElement); |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | protected function _correctAjaxUrl($url) { |
1023 | 1023 | if (PhalconUtils::endsWith($url, "/")) |
1024 | 1024 | $url=substr($url, 0, strlen($url)-1); |
1025 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
1025 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
1026 | 1026 | $url=$this->_di->get("url")->get($url); |
1027 | 1027 | } |
1028 | 1028 | return $url; |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | * @param string $method Method use |
1036 | 1036 | * @param string $jsCallback javascript code to execute after the request |
1037 | 1037 | */ |
1038 | - public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
1038 | + public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
1039 | 1039 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
1040 | 1040 | $retour=$this->_getAjaxUrl($url, $attr); |
1041 | 1041 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -1054,7 +1054,7 @@ discard block |
||
1054 | 1054 | * @param string $url the request address |
1055 | 1055 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get") |
1056 | 1056 | */ |
1057 | - public function _jsonOn($event,$element, $url,$parameters=array()) { |
|
1057 | + public function _jsonOn($event, $element, $url, $parameters=array()) { |
|
1058 | 1058 | $preventDefault=true; |
1059 | 1059 | $stopPropagation=true; |
1060 | 1060 | $jsCallback=null; |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | $context="document"; |
1064 | 1064 | $params="{}"; |
1065 | 1065 | extract($parameters); |
1066 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation); |
|
1066 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation); |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | /** |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | * @param string $method Method use |
1074 | 1074 | * @param string $jsCallback javascript code to execute after the request |
1075 | 1075 | */ |
1076 | - public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id",$immediatly=false) { |
|
1076 | + public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $immediatly=false) { |
|
1077 | 1077 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
1078 | 1078 | $retour=$this->_getAjaxUrl($url, $attr); |
1079 | 1079 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | * @param string $url the request address |
1092 | 1092 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get") |
1093 | 1093 | */ |
1094 | - public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) { |
|
1094 | + public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
1095 | 1095 | $preventDefault=true; |
1096 | 1096 | $stopPropagation=true; |
1097 | 1097 | $jsCallback=null; |
@@ -1099,14 +1099,14 @@ discard block |
||
1099 | 1099 | $method="get"; |
1100 | 1100 | $params="{}"; |
1101 | 1101 | extract($parameters); |
1102 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr), $event, $preventDefault, $stopPropagation); |
|
1102 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr), $event, $preventDefault, $stopPropagation); |
|
1103 | 1103 | } |
1104 | 1104 | |
1105 | - public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
1105 | + public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
1106 | 1106 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
1107 | 1107 | $retour=$this->_getAjaxUrl($url, $attr); |
1108 | 1108 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
1109 | - if($hasLoader===true){ |
|
1109 | + if ($hasLoader===true) { |
|
1110 | 1110 | $this->addLoading($retour, $responseElement); |
1111 | 1111 | } |
1112 | 1112 | $retour.="$.post(url,params).done(function( data ) {\n"; |
@@ -1133,14 +1133,14 @@ discard block |
||
1133 | 1133 | * @param string $responseElement |
1134 | 1134 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
1135 | 1135 | */ |
1136 | - public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
1136 | + public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
1137 | 1137 | $preventDefault=true; |
1138 | 1138 | $stopPropagation=true; |
1139 | 1139 | $jsCallback=null; |
1140 | 1140 | $attr="id"; |
1141 | 1141 | $hasLoader=true; |
1142 | 1142 | extract($parameters); |
1143 | - return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation); |
|
1143 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation); |
|
1144 | 1144 | } |
1145 | 1145 | |
1146 | 1146 | /** |
@@ -1153,14 +1153,14 @@ discard block |
||
1153 | 1153 | * @param string $responseElement |
1154 | 1154 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
1155 | 1155 | */ |
1156 | - public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
1156 | + public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
1157 | 1157 | $preventDefault=true; |
1158 | 1158 | $stopPropagation=true; |
1159 | 1159 | $jsCallback=null; |
1160 | 1160 | $attr="id"; |
1161 | 1161 | $hasLoader=true; |
1162 | 1162 | extract($parameters); |
1163 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation); |
|
1163 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | /** |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | * @param string $responseElement |
1174 | 1174 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
1175 | 1175 | */ |
1176 | - public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
1176 | + public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
1177 | 1177 | $preventDefault=true; |
1178 | 1178 | $stopPropagation=true; |
1179 | 1179 | $validation=false; |
@@ -1181,7 +1181,7 @@ discard block |
||
1181 | 1181 | $attr="id"; |
1182 | 1182 | $hasLoader=true; |
1183 | 1183 | extract($parameters); |
1184 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation); |
|
1184 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation); |
|
1185 | 1185 | } |
1186 | 1186 | |
1187 | 1187 | /** |
@@ -420,8 +420,9 @@ discard block |
||
420 | 420 | $element=$this->_prep_element($element); |
421 | 421 | $value=$this->_prep_value($value); |
422 | 422 | $str="$({$element}).after({$value});"; |
423 | - if ($immediatly) |
|
424 | - $this->jquery_code_for_compile[]=$str; |
|
423 | + if ($immediatly) { |
|
424 | + $this->jquery_code_for_compile[]=$str; |
|
425 | + } |
|
425 | 426 | return $str; |
426 | 427 | } |
427 | 428 | |
@@ -437,10 +438,12 @@ discard block |
||
437 | 438 | if (isset($value)) { |
438 | 439 | $value=$this->_prep_value($value); |
439 | 440 | $str="$({$element}).attr(\"$attributeName\",{$value});"; |
440 | - } else |
|
441 | - $str="$({$element}).attr(\"$attributeName\");"; |
|
442 | - if ($immediatly) |
|
443 | - $this->jquery_code_for_compile[]=$str; |
|
441 | + } else { |
|
442 | + $str="$({$element}).attr(\"$attributeName\");"; |
|
443 | + } |
|
444 | + if ($immediatly) { |
|
445 | + $this->jquery_code_for_compile[]=$str; |
|
446 | + } |
|
444 | 447 | return $str; |
445 | 448 | } |
446 | 449 | |
@@ -456,10 +459,12 @@ discard block |
||
456 | 459 | if (isset($param)) { |
457 | 460 | $param=$this->_prep_value($param); |
458 | 461 | $str="$({$element}).{$jQueryCall}({$param});"; |
459 | - } else |
|
460 | - $str="$({$element}).{$jQueryCall}();"; |
|
461 | - if ($immediatly) |
|
462 | - $this->jquery_code_for_compile[]=$str; |
|
462 | + } else { |
|
463 | + $str="$({$element}).{$jQueryCall}();"; |
|
464 | + } |
|
465 | + if ($immediatly) { |
|
466 | + $this->jquery_code_for_compile[]=$str; |
|
467 | + } |
|
463 | 468 | return $str; |
464 | 469 | } |
465 | 470 | /** |
@@ -474,8 +479,9 @@ discard block |
||
474 | 479 | $to=$this->_prep_element($to); |
475 | 480 | $element=$this->_prep_element($element); |
476 | 481 | $str="$({$to}).{$jQueryCall}({$element});"; |
477 | - if ($immediatly) |
|
478 | - $this->jquery_code_for_compile[]=$str; |
|
482 | + if ($immediatly) { |
|
483 | + $this->jquery_code_for_compile[]=$str; |
|
484 | + } |
|
479 | 485 | return $str; |
480 | 486 | } |
481 | 487 | // -------------------------------------------------------------------- |
@@ -512,8 +518,9 @@ discard block |
||
512 | 518 | |
513 | 519 | $str="$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");"; |
514 | 520 | |
515 | - if ($immediatly) |
|
516 | - $this->jquery_code_for_compile[]=$str; |
|
521 | + if ($immediatly) { |
|
522 | + $this->jquery_code_for_compile[]=$str; |
|
523 | + } |
|
517 | 524 | return $str; |
518 | 525 | } |
519 | 526 | |
@@ -538,8 +545,9 @@ discard block |
||
538 | 545 | |
539 | 546 | $str="$({$element}).fadeIn({$speed}{$callback});"; |
540 | 547 | |
541 | - if ($immediatly) |
|
542 | - $this->jquery_code_for_compile[]=$str; |
|
548 | + if ($immediatly) { |
|
549 | + $this->jquery_code_for_compile[]=$str; |
|
550 | + } |
|
543 | 551 | return $str; |
544 | 552 | } |
545 | 553 | |
@@ -564,8 +572,9 @@ discard block |
||
564 | 572 | |
565 | 573 | $str="$({$element}).fadeOut({$speed}{$callback});"; |
566 | 574 | |
567 | - if ($immediatly) |
|
568 | - $this->jquery_code_for_compile[]=$str; |
|
575 | + if ($immediatly) { |
|
576 | + $this->jquery_code_for_compile[]=$str; |
|
577 | + } |
|
569 | 578 | return $str; |
570 | 579 | } |
571 | 580 | |
@@ -590,8 +599,9 @@ discard block |
||
590 | 599 | |
591 | 600 | $str="$({$element}).hide({$speed}{$callback});"; |
592 | 601 | |
593 | - if ($immediatly) |
|
594 | - $this->jquery_code_for_compile[]=$str; |
|
602 | + if ($immediatly) { |
|
603 | + $this->jquery_code_for_compile[]=$str; |
|
604 | + } |
|
595 | 605 | return $str; |
596 | 606 | } |
597 | 607 | |
@@ -618,8 +628,9 @@ discard block |
||
618 | 628 | |
619 | 629 | $str="$({$element}).slideUp({$speed}{$callback});"; |
620 | 630 | |
621 | - if ($immediatly) |
|
622 | - $this->jquery_code_for_compile[]=$str; |
|
631 | + if ($immediatly) { |
|
632 | + $this->jquery_code_for_compile[]=$str; |
|
633 | + } |
|
623 | 634 | return $str; |
624 | 635 | } |
625 | 636 | |
@@ -644,8 +655,9 @@ discard block |
||
644 | 655 | |
645 | 656 | $str="$({$element}).slideDown({$speed}{$callback});"; |
646 | 657 | |
647 | - if ($immediatly) |
|
648 | - $this->jquery_code_for_compile[]=$str; |
|
658 | + if ($immediatly) { |
|
659 | + $this->jquery_code_for_compile[]=$str; |
|
660 | + } |
|
649 | 661 | return $str; |
650 | 662 | } |
651 | 663 | |
@@ -670,8 +682,9 @@ discard block |
||
670 | 682 | |
671 | 683 | $str="$({$element}).slideToggle({$speed}{$callback});"; |
672 | 684 | |
673 | - if ($immediatly) |
|
674 | - $this->jquery_code_for_compile[]=$str; |
|
685 | + if ($immediatly) { |
|
686 | + $this->jquery_code_for_compile[]=$str; |
|
687 | + } |
|
675 | 688 | return $str; |
676 | 689 | } |
677 | 690 | |
@@ -688,8 +701,9 @@ discard block |
||
688 | 701 | $element=$this->_prep_element($element); |
689 | 702 | $str="$({$element}).toggle();"; |
690 | 703 | |
691 | - if ($immediatly) |
|
692 | - $this->jquery_code_for_compile[]=$str; |
|
704 | + if ($immediatly) { |
|
705 | + $this->jquery_code_for_compile[]=$str; |
|
706 | + } |
|
693 | 707 | return $str; |
694 | 708 | } |
695 | 709 | |
@@ -705,8 +719,9 @@ discard block |
||
705 | 719 | $element=$this->_prep_element($element); |
706 | 720 | $str="$({$element}).trigger(\"$event\");"; |
707 | 721 | |
708 | - if ($immediatly) |
|
709 | - $this->jquery_code_for_compile[]=$str; |
|
722 | + if ($immediatly) { |
|
723 | + $this->jquery_code_for_compile[]=$str; |
|
724 | + } |
|
710 | 725 | return $str; |
711 | 726 | } |
712 | 727 | |
@@ -731,8 +746,9 @@ discard block |
||
731 | 746 | |
732 | 747 | $str="$({$element}).show({$speed}{$callback});"; |
733 | 748 | |
734 | - if ($immediatly) |
|
735 | - $this->jquery_code_for_compile[]=$str; |
|
749 | + if ($immediatly) { |
|
750 | + $this->jquery_code_for_compile[]=$str; |
|
751 | + } |
|
736 | 752 | return $str; |
737 | 753 | } |
738 | 754 | |
@@ -750,8 +766,9 @@ discard block |
||
750 | 766 | $str.="else{".$jsCodeIfFalse."}"; |
751 | 767 | } |
752 | 768 | |
753 | - if ($immediatly) |
|
754 | - $this->jquery_code_for_compile[]=$str; |
|
769 | + if ($immediatly) { |
|
770 | + $this->jquery_code_for_compile[]=$str; |
|
771 | + } |
|
755 | 772 | return $str; |
756 | 773 | } |
757 | 774 | |
@@ -817,10 +834,11 @@ discard block |
||
817 | 834 | if ($stopPropagation===true) { |
818 | 835 | $js="event.stopPropagation();\n".$js; |
819 | 836 | } |
820 | - if (array_search($event, $this->jquery_events)===false) |
|
821 | - $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
822 | - else |
|
823 | - $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
837 | + if (array_search($event, $this->jquery_events)===false) { |
|
838 | + $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
839 | + } else { |
|
840 | + $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
841 | + } |
|
824 | 842 | $this->jquery_code_for_compile[]=$event; |
825 | 843 | return $event; |
826 | 844 | } |
@@ -870,8 +888,9 @@ discard block |
||
870 | 888 | |
871 | 889 | $output=($script_tags===FALSE) ? $script : $this->inline($script); |
872 | 890 | |
873 | - if ($view!=NULL) |
|
874 | - $view->setVar($view_var, $output); |
|
891 | + if ($view!=NULL) { |
|
892 | + $view->setVar($view_var, $output); |
|
893 | + } |
|
875 | 894 | return $output; |
876 | 895 | } |
877 | 896 | |
@@ -992,8 +1011,9 @@ discard block |
||
992 | 1011 | } |
993 | 1012 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
994 | 1013 | $retour.=$this->_getOnAjaxDone($responseElement, $jsCallback)."});\n"; |
995 | - if ($immediatly) |
|
996 | - $this->jquery_code_for_compile[]=$retour; |
|
1014 | + if ($immediatly) { |
|
1015 | + $this->jquery_code_for_compile[]=$retour; |
|
1016 | + } |
|
997 | 1017 | return $retour; |
998 | 1018 | } |
999 | 1019 | |
@@ -1001,10 +1021,11 @@ discard block |
||
1001 | 1021 | $url=$this->_correctAjaxUrl($url); |
1002 | 1022 | $retour="url='".$url."';\n"; |
1003 | 1023 | if(JString::isNotNull($attr)){ |
1004 | - if ($attr=="value") |
|
1005 | - $retour.="url=url+'/'+$(this).val();\n"; |
|
1006 | - else if($attr!=null && $attr!=="") |
|
1007 | - $retour.="url=url+'/'+$(this).attr('".$attr."');\n"; |
|
1024 | + if ($attr=="value") { |
|
1025 | + $retour.="url=url+'/'+$(this).val();\n"; |
|
1026 | + } else if($attr!=null && $attr!=="") { |
|
1027 | + $retour.="url=url+'/'+$(this).attr('".$attr."');\n"; |
|
1028 | + } |
|
1008 | 1029 | } |
1009 | 1030 | return $retour; |
1010 | 1031 | } |
@@ -1020,8 +1041,9 @@ discard block |
||
1020 | 1041 | } |
1021 | 1042 | |
1022 | 1043 | protected function _correctAjaxUrl($url) { |
1023 | - if (PhalconUtils::endsWith($url, "/")) |
|
1024 | - $url=substr($url, 0, strlen($url)-1); |
|
1044 | + if (PhalconUtils::endsWith($url, "/")) { |
|
1045 | + $url=substr($url, 0, strlen($url)-1); |
|
1046 | + } |
|
1025 | 1047 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
1026 | 1048 | $url=$this->_di->get("url")->get($url); |
1027 | 1049 | } |
@@ -1042,8 +1064,9 @@ discard block |
||
1042 | 1064 | $retour.="\tdata=$.parseJSON(data);for(var key in data){if($('#'+key,".$context.").length){ if($('#'+key,".$context.").is('[value]')) { $('#'+key,".$context.").val(data[key]);} else { $('#'+key,".$context.").html(data[key]); }}};\n"; |
1043 | 1065 | $retour.="\t".$jsCallback."\n |
1044 | 1066 | });\n"; |
1045 | - if ($immediatly) |
|
1046 | - $this->jquery_code_for_compile[]=$retour; |
|
1067 | + if ($immediatly) { |
|
1068 | + $this->jquery_code_for_compile[]=$retour; |
|
1069 | + } |
|
1047 | 1070 | return $retour; |
1048 | 1071 | } |
1049 | 1072 | |
@@ -1080,8 +1103,9 @@ discard block |
||
1080 | 1103 | $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=$('#'+newId);\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone();newElm.attr('id',newId);\n"."\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"."\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"; |
1081 | 1104 | |
1082 | 1105 | $retour.="\t".$jsCallback."\n"."});\n"; |
1083 | - if ($immediatly) |
|
1084 | - $this->jquery_code_for_compile[]=$retour; |
|
1106 | + if ($immediatly) { |
|
1107 | + $this->jquery_code_for_compile[]=$retour; |
|
1108 | + } |
|
1085 | 1109 | return $retour; |
1086 | 1110 | } |
1087 | 1111 | /** |
@@ -1118,8 +1142,9 @@ discard block |
||
1118 | 1142 | }});\n"; |
1119 | 1143 | $retour.="$('#".$form."').submit();\n"; |
1120 | 1144 | } |
1121 | - if ($immediatly) |
|
1122 | - $this->jquery_code_for_compile[]=$retour; |
|
1145 | + if ($immediatly) { |
|
1146 | + $this->jquery_code_for_compile[]=$retour; |
|
1147 | + } |
|
1123 | 1148 | return $retour; |
1124 | 1149 | } |
1125 | 1150 | |
@@ -1195,11 +1220,13 @@ discard block |
||
1195 | 1220 | public function _doJQuery($element, $jqueryCall, $param="", $jsCallback="", $immediatly=false) { |
1196 | 1221 | $param=$this->_prep_value($param); |
1197 | 1222 | $callback=""; |
1198 | - if ($jsCallback!="") |
|
1199 | - $callback=", function(event){\n{$jsCallback}\n}"; |
|
1223 | + if ($jsCallback!="") { |
|
1224 | + $callback=", function(event){\n{$jsCallback}\n}"; |
|
1225 | + } |
|
1200 | 1226 | $script="$(".$this->_prep_element($element).").".$jqueryCall."(".$param.$callback.");\n"; |
1201 | - if ($immediatly) |
|
1202 | - $this->jquery_code_for_compile[]=$script; |
|
1227 | + if ($immediatly) { |
|
1228 | + $this->jquery_code_for_compile[]=$script; |
|
1229 | + } |
|
1203 | 1230 | return $script; |
1204 | 1231 | } |
1205 | 1232 | |
@@ -1227,8 +1254,9 @@ discard block |
||
1227 | 1254 | */ |
1228 | 1255 | public function _exec($js, $immediatly=false) { |
1229 | 1256 | $script=$js."\n"; |
1230 | - if ($immediatly) |
|
1231 | - $this->jquery_code_for_compile[]=$script; |
|
1257 | + if ($immediatly) { |
|
1258 | + $this->jquery_code_for_compile[]=$script; |
|
1259 | + } |
|
1232 | 1260 | return $script; |
1233 | 1261 | } |
1234 | 1262 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | protected function _setDi($di) { |
47 | 47 | $this->_di=$di; |
48 | - if ($this->js!=null&&$di!=null) |
|
48 | + if ($this->js!=null && $di!=null) |
|
49 | 49 | $this->js->setDi($di); |
50 | 50 | } |
51 | 51 | |
@@ -120,17 +120,17 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | public function __construct($params=array()) { |
123 | - $defaults=array ( |
|
123 | + $defaults=array( |
|
124 | 124 | 'driver' => 'Jquery' |
125 | 125 | ); |
126 | - foreach ( $defaults as $key => $val ) { |
|
127 | - if (isset($params[$key])&&$params[$key]!=="") { |
|
126 | + foreach ($defaults as $key => $val) { |
|
127 | + if (isset($params[$key]) && $params[$key]!=="") { |
|
128 | 128 | $defaults[$key]=$params[$key]; |
129 | 129 | } |
130 | 130 | } |
131 | 131 | extract($defaults); |
132 | 132 | $this->js=new Jquery(); |
133 | - $this->cdns=array (); |
|
133 | + $this->cdns=array(); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | public function addToCompile($jsScript) { |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * @return string |
383 | 383 | */ |
384 | 384 | public function addClass($element='this', $class='', $immediatly=false) { |
385 | - return $this->js->_genericCallValue('addClass',$element, $class, $immediatly); |
|
385 | + return $this->js->_genericCallValue('addClass', $element, $class, $immediatly); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | * @param boolean $immediatly defers the execution if set to false |
393 | 393 | * @return string |
394 | 394 | */ |
395 | - public function after($to, $element, $immediatly=false){ |
|
396 | - return $this->js->_genericCallElement('after',$to, $element, $immediatly); |
|
395 | + public function after($to, $element, $immediatly=false) { |
|
396 | + return $this->js->_genericCallElement('after', $to, $element, $immediatly); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
@@ -403,8 +403,8 @@ discard block |
||
403 | 403 | * @param boolean $immediatly defers the execution if set to false |
404 | 404 | * @return string |
405 | 405 | */ |
406 | - public function before($to, $element, $immediatly=false){ |
|
407 | - return $this->js->_genericCallElement('before',$to, $element, $immediatly); |
|
406 | + public function before($to, $element, $immediatly=false) { |
|
407 | + return $this->js->_genericCallElement('before', $to, $element, $immediatly); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | /** |
@@ -424,8 +424,8 @@ discard block |
||
424 | 424 | * @param string $value |
425 | 425 | * @param boolean $immediatly defers the execution if set to false |
426 | 426 | */ |
427 | - public function val($element='this',$value='',$immediatly=false){ |
|
428 | - return $this->js->_genericCallValue('val',$element,$value,$immediatly); |
|
427 | + public function val($element='this', $value='', $immediatly=false) { |
|
428 | + return $this->js->_genericCallValue('val', $element, $value, $immediatly); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * @param boolean $immediatly defers the execution if set to false |
436 | 436 | */ |
437 | 437 | public function html($element='this', $value='', $immediatly=false) { |
438 | - return $this->js->_genericCallValue('html',$element, $value, $immediatly); |
|
438 | + return $this->js->_genericCallValue('html', $element, $value, $immediatly); |
|
439 | 439 | } |
440 | 440 | // -------------------------------------------------------------------- |
441 | 441 | /** |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @return string |
461 | 461 | */ |
462 | 462 | public function append($to, $element, $immediatly=false) { |
463 | - return $this->js->_genericCallElement('append',$to, $element, $immediatly); |
|
463 | + return $this->js->_genericCallElement('append', $to, $element, $immediatly); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | * @return string |
472 | 472 | */ |
473 | 473 | public function prepend($to, $element, $immediatly=false) { |
474 | - return $this->js->_genericCallElement('prepend',$to, $element, $immediatly); |
|
474 | + return $this->js->_genericCallElement('prepend', $to, $element, $immediatly); |
|
475 | 475 | } |
476 | 476 | // -------------------------------------------------------------------- |
477 | 477 | /** |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | * @return string |
523 | 523 | */ |
524 | 524 | public function removeClass($element='this', $class='', $immediatly=false) { |
525 | - return $this->js->_genericCall('removeClass',$element, $class, $immediatly); |
|
525 | + return $this->js->_genericCall('removeClass', $element, $class, $immediatly); |
|
526 | 526 | } |
527 | 527 | // -------------------------------------------------------------------- |
528 | 528 | /** |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | * @return string |
584 | 584 | */ |
585 | 585 | public function toggleClass($element='this', $class='', $immediatly=false) { |
586 | - return $this->js->_genericCallValue('toggleClass',$element, $class, $immediatly); |
|
586 | + return $this->js->_genericCallValue('toggleClass', $element, $class, $immediatly); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | */ |
631 | 631 | public function compile($view=NULL, $view_var='script_foot', $script_tags=TRUE) { |
632 | 632 | $bs=$this->_bootstrap; |
633 | - if (isset($bs)&&isset($view)) { |
|
633 | + if (isset($bs) && isset($view)) { |
|
634 | 634 | $bs->compileHtml($this, $view); |
635 | 635 | } |
636 | 636 | return $this->js->_compile($view, $view_var, $script_tags); |
@@ -710,27 +710,27 @@ discard block |
||
710 | 710 | $json_result=$result->result_array(); |
711 | 711 | } elseif (is_array($result)) { |
712 | 712 | $json_result=$result; |
713 | - } else { |
|
713 | + }else { |
|
714 | 714 | return $this->_prep_args($result); |
715 | 715 | } |
716 | - } else { |
|
716 | + }else { |
|
717 | 717 | return 'null'; |
718 | 718 | } |
719 | 719 | return $this->_create_json($json_result, $match_array_type); |
720 | 720 | } |
721 | 721 | |
722 | 722 | private function _create_json($json_result, $match_array_type) { |
723 | - $json=array (); |
|
723 | + $json=array(); |
|
724 | 724 | $_is_assoc=TRUE; |
725 | - if (!is_array($json_result)&&empty($json_result)) { |
|
725 | + if (!is_array($json_result) && empty($json_result)) { |
|
726 | 726 | show_error("Generate JSON Failed - Illegal key, value pair."); |
727 | 727 | } elseif ($match_array_type) { |
728 | 728 | $_is_assoc=$this->_is_associative_array($json_result); |
729 | 729 | } |
730 | - foreach ( $json_result as $k => $v ) { |
|
730 | + foreach ($json_result as $k => $v) { |
|
731 | 731 | if ($_is_assoc) { |
732 | 732 | $json[]=$this->_prep_args($k, TRUE).':'.$this->generate_json($v, $match_array_type); |
733 | - } else { |
|
733 | + }else { |
|
734 | 734 | $json[]=$this->generate_json($v, $match_array_type); |
735 | 735 | } |
736 | 736 | } |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | * @return type |
746 | 746 | */ |
747 | 747 | public function _is_associative_array($arr) { |
748 | - foreach ( array_keys($arr) as $key => $val ) { |
|
748 | + foreach (array_keys($arr) as $key => $val) { |
|
749 | 749 | if ($key!==$val) { |
750 | 750 | return TRUE; |
751 | 751 | } |
@@ -764,11 +764,11 @@ discard block |
||
764 | 764 | return 'null'; |
765 | 765 | } elseif (is_bool($result)) { |
766 | 766 | return ($result===TRUE) ? 'true' : 'false'; |
767 | - } elseif (is_string($result)||$is_key) { |
|
768 | - return '"'.str_replace(array ( |
|
769 | - '\\',"\t","\n","\r",'"','/' |
|
770 | - ), array ( |
|
771 | - '\\\\','\\t','\\n',"\\r",'\"','\/' |
|
767 | + } elseif (is_string($result) || $is_key) { |
|
768 | + return '"'.str_replace(array( |
|
769 | + '\\', "\t", "\n", "\r", '"', '/' |
|
770 | + ), array( |
|
771 | + '\\\\', '\\t', '\\n', "\\r", '\"', '\/' |
|
772 | 772 | ), $result).'"'; |
773 | 773 | } elseif (is_scalar($result)) { |
774 | 774 | return $result; |
@@ -783,8 +783,8 @@ discard block |
||
783 | 783 | * @param string $jsCallback javascript code to execute after the request |
784 | 784 | * @param boolean $hasLoader true for showing ajax loader. default : true |
785 | 785 | */ |
786 | - public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true) { |
|
787 | - return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,true); |
|
786 | + public function get($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true) { |
|
787 | + return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, true); |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | /** |
@@ -794,8 +794,8 @@ discard block |
||
794 | 794 | * @param string $method Method used |
795 | 795 | * @param string $jsCallback javascript code to execute after the request |
796 | 796 | */ |
797 | - public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
798 | - return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context,$immediatly); |
|
797 | + public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
798 | + return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context, $immediatly); |
|
799 | 799 | } |
800 | 800 | |
801 | 801 | /** |
@@ -805,8 +805,8 @@ discard block |
||
805 | 805 | * @param string $url the request address |
806 | 806 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get") |
807 | 807 | */ |
808 | - public function jsonOn($event,$element, $url,$parameters=array()) { |
|
809 | - return $this->js->_jsonOn($event, $element, $url,$parameters); |
|
808 | + public function jsonOn($event, $element, $url, $parameters=array()) { |
|
809 | + return $this->js->_jsonOn($event, $element, $url, $parameters); |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | /** |
@@ -850,8 +850,8 @@ discard block |
||
850 | 850 | * @param string $url the request url |
851 | 851 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get") |
852 | 852 | */ |
853 | - public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) { |
|
854 | - return $this->js->_jsonArrayOn($event,$element,$maskSelector, $url, $parameters); |
|
853 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
854 | + return $this->js->_jsonArrayOn($event, $element, $maskSelector, $url, $parameters); |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | /** |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | * @param string $jsCallback javascript code to execute after the request |
864 | 864 | * @param string $attr the html attribute added to the request |
865 | 865 | */ |
866 | - public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id") { |
|
866 | + public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id") { |
|
867 | 867 | return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false); |
868 | 868 | } |
869 | 869 | |
@@ -901,8 +901,8 @@ discard block |
||
901 | 901 | * @param string $jsCallback javascript code to execute after the request |
902 | 902 | * @param boolean $hasLoader true for showing ajax loader. default : true |
903 | 903 | */ |
904 | - public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true) { |
|
905 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,true); |
|
904 | + public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true) { |
|
905 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, true); |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | /** |
@@ -915,8 +915,8 @@ discard block |
||
915 | 915 | * @param string $jsCallback javascript code to execute after the request |
916 | 916 | * @param boolean $hasLoader true for showing ajax loader. default : true |
917 | 917 | */ |
918 | - public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true) { |
|
919 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,false); |
|
918 | + public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true) { |
|
919 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, false); |
|
920 | 920 | } |
921 | 921 | |
922 | 922 | /** |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
931 | 931 | */ |
932 | 932 | public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
933 | - return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
933 | + return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
934 | 934 | } |
935 | 935 | |
936 | 936 | /** |
@@ -954,8 +954,8 @@ discard block |
||
954 | 954 | * @param string $jsCallback javascript code to execute after the request |
955 | 955 | * @param boolean $hasLoader true for showing ajax loader. default : true |
956 | 956 | */ |
957 | - public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$hasLoader=true) { |
|
958 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader,true); |
|
957 | + public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $hasLoader=true) { |
|
958 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader, true); |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | /** |
@@ -968,8 +968,8 @@ discard block |
||
968 | 968 | * @param string $attr the html attribute added to the request |
969 | 969 | * @param boolean $hasLoader true for showing ajax loader. default : true |
970 | 970 | */ |
971 | - public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true) { |
|
972 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader,false); |
|
971 | + public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true) { |
|
972 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, false); |
|
973 | 973 | } |
974 | 974 | |
975 | 975 | /** |
@@ -983,7 +983,7 @@ discard block |
||
983 | 983 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
984 | 984 | */ |
985 | 985 | public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
986 | - return $this->js->_postFormOn($event,$element, $url, $form, $responseElement, $parameters); |
|
986 | + return $this->js->_postFormOn($event, $element, $url, $form, $responseElement, $parameters); |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | /** |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | |
1074 | 1074 | public function setCDNs($cdns) { |
1075 | 1075 | if (is_array($cdns)===false) { |
1076 | - $cdns=array ( |
|
1076 | + $cdns=array( |
|
1077 | 1077 | $cdns |
1078 | 1078 | ); |
1079 | 1079 | } |
@@ -1084,9 +1084,9 @@ discard block |
||
1084 | 1084 | $hasJQuery=false; |
1085 | 1085 | $hasJQueryUI=false; |
1086 | 1086 | $hasBootstrap=false; |
1087 | - $result=array (); |
|
1088 | - foreach ( $this->cdns as $cdn ) { |
|
1089 | - switch(get_class($cdn)) { |
|
1087 | + $result=array(); |
|
1088 | + foreach ($this->cdns as $cdn) { |
|
1089 | + switch (get_class($cdn)) { |
|
1090 | 1090 | case "Ajax\lib\CDNJQuery": |
1091 | 1091 | $hasJQuery=true; |
1092 | 1092 | $result[0]=$cdn; |
@@ -1104,10 +1104,10 @@ discard block |
||
1104 | 1104 | if ($hasJQuery===false) { |
1105 | 1105 | $result[0]=new CDNJQuery("x"); |
1106 | 1106 | } |
1107 | - if ($hasJQueryUI===false&&isset($this->_ui)) { |
|
1107 | + if ($hasJQueryUI===false && isset($this->_ui)) { |
|
1108 | 1108 | $result[1]=new CDNGuiGen("x", $template); |
1109 | 1109 | } |
1110 | - if ($hasBootstrap===false&&isset($this->_bootstrap)) { |
|
1110 | + if ($hasBootstrap===false && isset($this->_bootstrap)) { |
|
1111 | 1111 | $result[2]=new CDNBootstrap("x"); |
1112 | 1112 | } |
1113 | 1113 | ksort($result); |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | $this->_setDi($di); |
1122 | 1122 | } |
1123 | 1123 | } |
1124 | -} else { |
|
1124 | +}else { |
|
1125 | 1125 | class JsUtils extends _JsUtils { |
1126 | 1126 | |
1127 | 1127 | public function setDi(DiInterface $di) { |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | * @param boolean $autoActive sets the last element's class to <b>active</b> if true |
36 | 36 | * @param function $hrefFunction the function who generates the href elements. default : function($e){return $e->getContent()} |
37 | 37 | */ |
38 | - public function __construct($identifier,$elements=array(),$autoActive=true,$hrefFunction=NULL){ |
|
39 | - parent::__construct($identifier,"ol"); |
|
38 | + public function __construct($identifier, $elements=array(), $autoActive=true, $hrefFunction=NULL) { |
|
39 | + parent::__construct($identifier, "ol"); |
|
40 | 40 | $this->setProperty("class", "breadcrumb"); |
41 | 41 | $this->content=array(); |
42 | 42 | $this->autoActive=$autoActive; |
43 | 43 | $this->absolutePaths; |
44 | - $this->_hrefFunction=function ($e){return $e->getContent();}; |
|
45 | - if(isset($hrefFunction)){ |
|
44 | + $this->_hrefFunction=function($e) {return $e->getContent(); }; |
|
45 | + if (isset($hrefFunction)) { |
|
46 | 46 | $this->_hrefFunction=$hrefFunction; |
47 | 47 | } |
48 | 48 | $this->addElements($elements); |
@@ -53,43 +53,43 @@ discard block |
||
53 | 53 | * @param string $href |
54 | 54 | * @return \Ajax\bootstrap\html\HtmlLink |
55 | 55 | */ |
56 | - public function addElement($element,$href="",$glyph=NULL){ |
|
56 | + public function addElement($element, $href="", $glyph=NULL) { |
|
57 | 57 | $size=sizeof($this->content); |
58 | - if(is_array($element)){ |
|
58 | + if (is_array($element)) { |
|
59 | 59 | $elm=new HtmlLink("lnk-".$this->identifier."-".$size); |
60 | 60 | $elm->fromArray($element); |
61 | - }else if($element instanceof HtmlLink){ |
|
61 | + }else if ($element instanceof HtmlLink) { |
|
62 | 62 | $elm=$element; |
63 | - }else{ |
|
64 | - $elm=new HtmlLink("lnk-".$this->identifier."-".$size,$href,$element); |
|
65 | - if(isset($glyph)){ |
|
63 | + }else { |
|
64 | + $elm=new HtmlLink("lnk-".$this->identifier."-".$size, $href, $element); |
|
65 | + if (isset($glyph)) { |
|
66 | 66 | $elm->wrapContentWithGlyph($glyph); |
67 | 67 | } |
68 | 68 | } |
69 | - $elm->wrap("<li>","</li>"); |
|
69 | + $elm->wrap("<li>", "</li>"); |
|
70 | 70 | $this->content[]=$elm; |
71 | 71 | $elm->setProperty($this->attr, $this->getHref($size)); |
72 | 72 | return $elm; |
73 | 73 | } |
74 | 74 | |
75 | - public function setActive($index=null){ |
|
76 | - if(!isset($index)){ |
|
75 | + public function setActive($index=null) { |
|
76 | + if (!isset($index)) { |
|
77 | 77 | $index=sizeof($this->content)-1; |
78 | 78 | } |
79 | - $li=new HtmlDoubleElement("","li"); |
|
79 | + $li=new HtmlDoubleElement("", "li"); |
|
80 | 80 | $li->setClass("active"); |
81 | 81 | $li->setContent($this->content[$index]->getContent()); |
82 | 82 | $this->content[$index]=$li; |
83 | 83 | } |
84 | 84 | |
85 | - public function addElements($elements){ |
|
86 | - foreach ( $elements as $element ) { |
|
85 | + public function addElements($elements) { |
|
86 | + foreach ($elements as $element) { |
|
87 | 87 | $this->addElement($element); |
88 | 88 | } |
89 | 89 | return $this; |
90 | 90 | } |
91 | 91 | |
92 | - public function fromArray($array){ |
|
92 | + public function fromArray($array) { |
|
93 | 93 | $array=parent::fromArray($array); |
94 | 94 | $this->addElements($array); |
95 | 95 | return $array; |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | * @param string $separator |
102 | 102 | * @return string |
103 | 103 | */ |
104 | - public function getHref($index=null,$separator="/"){ |
|
105 | - if(!isset($index)){ |
|
104 | + public function getHref($index=null, $separator="/") { |
|
105 | + if (!isset($index)) { |
|
106 | 106 | $index=sizeof($this->content); |
107 | 107 | } |
108 | - if($this->absolutePaths===true){ |
|
108 | + if ($this->absolutePaths===true) { |
|
109 | 109 | return $this->_hrefFunction($this->content[$index]); |
110 | - }else{ |
|
111 | - return $this->root.implode($separator, array_slice(array_map(function($e){return $this->_hrefFunction($e);}, $this->content),0,$index+1)); |
|
110 | + }else { |
|
111 | + return $this->root.implode($separator, array_slice(array_map(function($e) {return $this->_hrefFunction($e); }, $this->content), 0, $index+1)); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @see \Ajax\bootstrap\html\BaseHtml::compile() |
118 | 118 | */ |
119 | 119 | public function compile(JsUtils $js=NULL, View $view=NULL) { |
120 | - if($this->autoActive){ |
|
120 | + if ($this->autoActive) { |
|
121 | 121 | $this->setActive(); |
122 | 122 | } |
123 | 123 | return parent::compile($js, $view); |
@@ -135,19 +135,19 @@ discard block |
||
135 | 135 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
136 | 136 | */ |
137 | 137 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
138 | - foreach ($this->content as $element){ |
|
139 | - $element->on($event,$jsCode,$stopPropagation,$preventDefault); |
|
138 | + foreach ($this->content as $element) { |
|
139 | + $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
|
140 | 140 | } |
141 | 141 | return $this; |
142 | 142 | } |
143 | 143 | |
144 | 144 | public function setAutoActive($autoActive) { |
145 | - $this->autoActive = $autoActive; |
|
145 | + $this->autoActive=$autoActive; |
|
146 | 146 | return $this; |
147 | 147 | } |
148 | 148 | |
149 | 149 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
150 | - foreach ($this->content as $element){ |
|
150 | + foreach ($this->content as $element) { |
|
151 | 151 | $element->_ajaxOn($operation, $event, $url, $responseElement, $parameters); |
152 | 152 | } |
153 | 153 | return $this; |
@@ -160,18 +160,18 @@ discard block |
||
160 | 160 | * @param string $attr the html attribute used to build the elements url |
161 | 161 | * @return HtmlBreadcrumbs |
162 | 162 | */ |
163 | - public function autoGetOnClick($targetSelector){ |
|
164 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
163 | + public function autoGetOnClick($targetSelector) { |
|
164 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
165 | 165 | } |
166 | 166 | |
167 | - public function contentAsString(){ |
|
168 | - if($this->autoActive){ |
|
167 | + public function contentAsString() { |
|
168 | + if ($this->autoActive) { |
|
169 | 169 | $this->setActive(); |
170 | 170 | } |
171 | 171 | return parent::contentAsString(); |
172 | 172 | } |
173 | 173 | |
174 | - public function getElement($index){ |
|
174 | + public function getElement($index) { |
|
175 | 175 | return $this->content[$index]; |
176 | 176 | } |
177 | 177 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param mixed $glyph |
181 | 181 | * @param int $index |
182 | 182 | */ |
183 | - public function addGlyph($glyph,$index){ |
|
183 | + public function addGlyph($glyph, $index) { |
|
184 | 184 | $elm=$this->getElement($index); |
185 | 185 | return $elm->wrapContentWithGlyph($glyph); |
186 | 186 | } |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | * @param Dispatcher $dispatcher the request dispatcher |
191 | 191 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
192 | 192 | */ |
193 | - public function fromDispatcher($dispatcher){ |
|
194 | - $items=array($dispatcher->getControllerName(),$dispatcher->getActionName()); |
|
195 | - $items=array_merge($items,$dispatcher->getParams()); |
|
193 | + public function fromDispatcher($dispatcher) { |
|
194 | + $items=array($dispatcher->getControllerName(), $dispatcher->getActionName()); |
|
195 | + $items=array_merge($items, $dispatcher->getParams()); |
|
196 | 196 | return $this->addElements($items); |
197 | 197 | } |
198 | 198 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
204 | 204 | */ |
205 | 205 | public function setHrefFunction($_hrefFunction) { |
206 | - $this->_hrefFunction = $_hrefFunction; |
|
206 | + $this->_hrefFunction=$_hrefFunction; |
|
207 | 207 | return $this; |
208 | 208 | } |
209 | 209 |
@@ -45,70 +45,70 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * @param string $identifier |
47 | 47 | */ |
48 | - public function __construct($identifier,$from=1,$to=1,$active=NULL,$countVisible=NULL){ |
|
49 | - parent::__construct($identifier,"ul"); |
|
48 | + public function __construct($identifier, $from=1, $to=1, $active=NULL, $countVisible=NULL) { |
|
49 | + parent::__construct($identifier, "ul"); |
|
50 | 50 | $this->setProperty("class", "pagination"); |
51 | 51 | $this->active=$active; |
52 | 52 | $this->from=$from; |
53 | 53 | $this->to=$to; |
54 | 54 | $this->urlMask="%page%"; |
55 | - if(!isset($countVisible)) |
|
55 | + if (!isset($countVisible)) |
|
56 | 56 | $this->countVisible=$to-$from+1; |
57 | 57 | else |
58 | 58 | $this->countVisible=$countVisible; |
59 | 59 | $this->createContent(); |
60 | 60 | } |
61 | 61 | |
62 | - private function createElement($num,$content,$disabled=false,$current=false){ |
|
62 | + private function createElement($num, $content, $disabled=false, $current=false) { |
|
63 | 63 | $count=sizeof($this->content)+1; |
64 | - $elem=new HtmlDoubleElement("li-".$this->identifier."-".$count,"li"); |
|
65 | - if($disabled){ |
|
64 | + $elem=new HtmlDoubleElement("li-".$this->identifier."-".$count, "li"); |
|
65 | + if ($disabled) { |
|
66 | 66 | $elem->setProperty("class", "disabled"); |
67 | 67 | } |
68 | - if($current){ |
|
68 | + if ($current) { |
|
69 | 69 | $content.="<span class='sr-only'>(current)</span>"; |
70 | 70 | $elem->setProperty("class", "active"); |
71 | 71 | } |
72 | - if(!$disabled){ |
|
72 | + if (!$disabled) { |
|
73 | 73 | $url=$this->getUrl($num); |
74 | - $href=new HtmlLink("a-".$this->identifier."-".$count,$url,$content); |
|
74 | + $href=new HtmlLink("a-".$this->identifier."-".$count, $url, $content); |
|
75 | 75 | $href->setProperty($this->attr, $url); |
76 | 76 | $elem->setContent($href); |
77 | - }else{ |
|
77 | + }else { |
|
78 | 78 | $elem->setContent($content); |
79 | 79 | } |
80 | 80 | $this->content[]=$elem; |
81 | 81 | return $this; |
82 | 82 | } |
83 | 83 | |
84 | - protected function createContent(){ |
|
84 | + protected function createContent() { |
|
85 | 85 | $this->content=array(); |
86 | - $this->createElement($this->active-1,"<span aria-hidden='true'>«</span>",$this->active===1); |
|
86 | + $this->createElement($this->active-1, "<span aria-hidden='true'>«</span>", $this->active===1); |
|
87 | 87 | $start=$this->getStart(); |
88 | - $end=min($start+$this->countVisible-1,$this->to); |
|
89 | - for($index=$start;$index<=$end;$index++){ |
|
90 | - $this->createElement($index,$index,false,$index===$this->active); |
|
88 | + $end=min($start+$this->countVisible-1, $this->to); |
|
89 | + for ($index=$start; $index<=$end; $index++) { |
|
90 | + $this->createElement($index, $index, false, $index===$this->active); |
|
91 | 91 | } |
92 | - $this->createElement($this->active+1,"<span aria-hidden='true'>»</span>",$this->active===$this->to); |
|
92 | + $this->createElement($this->active+1, "<span aria-hidden='true'>»</span>", $this->active===$this->to); |
|
93 | 93 | } |
94 | 94 | |
95 | - protected function half(){ |
|
96 | - return (int)($this->countVisible/2); |
|
95 | + protected function half() { |
|
96 | + return (int) ($this->countVisible / 2); |
|
97 | 97 | } |
98 | 98 | |
99 | - protected function getStart(){ |
|
99 | + protected function getStart() { |
|
100 | 100 | $result=1; |
101 | - if($this->countVisible!==$this->to-$this->from+1){ |
|
102 | - $result=max($this->active-$this->half(),$result); |
|
101 | + if ($this->countVisible!==$this->to-$this->from+1) { |
|
102 | + $result=max($this->active-$this->half(), $result); |
|
103 | 103 | } |
104 | 104 | return $result; |
105 | 105 | } |
106 | 106 | |
107 | 107 | public function _addEvent($event, $jsCode) { |
108 | - foreach ($this->content as $li){ |
|
108 | + foreach ($this->content as $li) { |
|
109 | 109 | $content=$li->getContent(); |
110 | - if($content instanceof BaseHtml) |
|
111 | - $content->_addEvent($event,$jsCode); |
|
110 | + if ($content instanceof BaseHtml) |
|
111 | + $content->_addEvent($event, $jsCode); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | /** |
@@ -116,15 +116,15 @@ discard block |
||
116 | 116 | * @param Dispatcher $dispatcher the request dispatcher |
117 | 117 | * @return \Ajax\bootstrap\html\HtmlPagination |
118 | 118 | */ |
119 | - public function fromDispatcher($dispatcher){ |
|
120 | - $items=array($dispatcher->getControllerName(),$dispatcher->getActionName()); |
|
121 | - $items=array_merge($items,$dispatcher->getParams()); |
|
119 | + public function fromDispatcher($dispatcher) { |
|
120 | + $items=array($dispatcher->getControllerName(), $dispatcher->getActionName()); |
|
121 | + $items=array_merge($items, $dispatcher->getParams()); |
|
122 | 122 | $url=implode("/", $items); |
123 | - if($this->urlMask==="%page%"){ |
|
123 | + if ($this->urlMask==="%page%") { |
|
124 | 124 | $this->urlMask=preg_replace("/[0-9]/", "%page%", $url); |
125 | 125 | } |
126 | - for($index=$this->from;$index<=$this->to;$index++){ |
|
127 | - if($this->getUrl($index)==$url){ |
|
126 | + for ($index=$this->from; $index<=$this->to; $index++) { |
|
127 | + if ($this->getUrl($index)==$url) { |
|
128 | 128 | $this->setActive($index); |
129 | 129 | break; |
130 | 130 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | return $this; |
133 | 133 | } |
134 | 134 | |
135 | - public function getUrl($index){ |
|
135 | + public function getUrl($index) { |
|
136 | 136 | return str_ireplace("%page%", $index, $this->urlMask); |
137 | 137 | } |
138 | 138 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | if (is_int($size)) { |
147 | 147 | return $this->addToPropertyUnique("class", CssRef::sizes("pagination")[$size], CssRef::sizes("pagination")); |
148 | 148 | } |
149 | - if(!PhalconUtils::startsWith($size, "pagination-") && $size!=="") |
|
149 | + if (!PhalconUtils::startsWith($size, "pagination-") && $size!=="") |
|
150 | 150 | $size="pagination-".$size; |
151 | 151 | return $this->addToPropertyCtrl("class", $size, CssRef::sizes("pagination")); |
152 | 152 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | return $this->from; |
156 | 156 | } |
157 | 157 | public function setFrom($from) { |
158 | - $this->from = $from; |
|
158 | + $this->from=$from; |
|
159 | 159 | $this->createContent(); |
160 | 160 | return $this; |
161 | 161 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | return $this->to; |
164 | 164 | } |
165 | 165 | public function setTo($to) { |
166 | - $this->to = $to; |
|
166 | + $this->to=$to; |
|
167 | 167 | $this->createContent(); |
168 | 168 | return $this; |
169 | 169 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | return $this->active; |
172 | 172 | } |
173 | 173 | public function setActive($active) { |
174 | - $this->active = $active; |
|
174 | + $this->active=$active; |
|
175 | 175 | $this->createContent(); |
176 | 176 | return $this; |
177 | 177 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | return $this->urlMask; |
180 | 180 | } |
181 | 181 | public function setUrlMask($urlMask) { |
182 | - $this->urlMask = $urlMask; |
|
182 | + $this->urlMask=$urlMask; |
|
183 | 183 | $this->createContent(); |
184 | 184 | return $this; |
185 | 185 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | return $this->countVisible; |
188 | 188 | } |
189 | 189 | public function setCountVisible($countVisible) { |
190 | - $this->countVisible = $countVisible; |
|
190 | + $this->countVisible=$countVisible; |
|
191 | 191 | $this->createContent(); |
192 | 192 | return $this; |
193 | 193 | } |
@@ -52,10 +52,11 @@ discard block |
||
52 | 52 | $this->from=$from; |
53 | 53 | $this->to=$to; |
54 | 54 | $this->urlMask="%page%"; |
55 | - if(!isset($countVisible)) |
|
56 | - $this->countVisible=$to-$from+1; |
|
57 | - else |
|
58 | - $this->countVisible=$countVisible; |
|
55 | + if(!isset($countVisible)) { |
|
56 | + $this->countVisible=$to-$from+1; |
|
57 | + } else { |
|
58 | + $this->countVisible=$countVisible; |
|
59 | + } |
|
59 | 60 | $this->createContent(); |
60 | 61 | } |
61 | 62 | |
@@ -74,7 +75,7 @@ discard block |
||
74 | 75 | $href=new HtmlLink("a-".$this->identifier."-".$count,$url,$content); |
75 | 76 | $href->setProperty($this->attr, $url); |
76 | 77 | $elem->setContent($href); |
77 | - }else{ |
|
78 | + } else{ |
|
78 | 79 | $elem->setContent($content); |
79 | 80 | } |
80 | 81 | $this->content[]=$elem; |
@@ -107,8 +108,9 @@ discard block |
||
107 | 108 | public function _addEvent($event, $jsCode) { |
108 | 109 | foreach ($this->content as $li){ |
109 | 110 | $content=$li->getContent(); |
110 | - if($content instanceof BaseHtml) |
|
111 | - $content->_addEvent($event,$jsCode); |
|
111 | + if($content instanceof BaseHtml) { |
|
112 | + $content->_addEvent($event,$jsCode); |
|
113 | + } |
|
112 | 114 | } |
113 | 115 | } |
114 | 116 | /** |
@@ -146,8 +148,9 @@ discard block |
||
146 | 148 | if (is_int($size)) { |
147 | 149 | return $this->addToPropertyUnique("class", CssRef::sizes("pagination")[$size], CssRef::sizes("pagination")); |
148 | 150 | } |
149 | - if(!PhalconUtils::startsWith($size, "pagination-") && $size!=="") |
|
150 | - $size="pagination-".$size; |
|
151 | + if(!PhalconUtils::startsWith($size, "pagination-") && $size!=="") { |
|
152 | + $size="pagination-".$size; |
|
153 | + } |
|
151 | 154 | return $this->addToPropertyCtrl("class", $size, CssRef::sizes("pagination")); |
152 | 155 | } |
153 | 156 |