@@ -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 | /** |
@@ -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 | } |
@@ -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 |