@@ -52,7 +52,7 @@ |
||
52 | 52 | * @return $this |
53 | 53 | */ |
54 | 54 | public function setSource($source) { |
55 | - $source=str_ireplace(array ( |
|
55 | + $source=str_ireplace(array( |
|
56 | 56 | "\"", |
57 | 57 | "'" |
58 | 58 | ), "%quote%", $source); |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class Dialog extends SimpleComponent { |
14 | 14 | protected $attachTo; |
15 | - protected $buttons=array (); |
|
15 | + protected $buttons=array(); |
|
16 | 16 | |
17 | 17 | public function __construct(JsUtils $js) { |
18 | 18 | parent::__construct($js); |
19 | - $this->params=array ( |
|
19 | + $this->params=array( |
|
20 | 20 | "dialogClass" => "no-close" |
21 | 21 | ); |
22 | 22 | $this->addCancelBtn("Annuler"); |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | |
25 | 25 | public function getScript() { |
26 | 26 | $allParams=$this->params; |
27 | - $jsonButtons=array (); |
|
28 | - foreach ( $this->buttons as $button ) { |
|
27 | + $jsonButtons=array(); |
|
28 | + foreach ($this->buttons as $button) { |
|
29 | 29 | $jsonButtons []=$button->getParams(); |
30 | 30 | } |
31 | 31 | $allParams ["buttons"]=$jsonButtons; |
32 | - $this->jquery_code_for_compile []="$( '" . $this->attachTo . "' ).dialog(" . $this->getParamsAsJSON($allParams) . ");"; |
|
32 | + $this->jquery_code_for_compile []="$( '".$this->attachTo."' ).dialog(".$this->getParamsAsJSON($allParams).");"; |
|
33 | 33 | $result=implode("", $this->jquery_code_for_compile); |
34 | 34 | $result=str_ireplace("\"%", "", $result); |
35 | 35 | $result=str_ireplace("%\"", "", $result); |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | private function insertBtn($insert, $position=NULL) { |
62 | - if ($position != NULL) { |
|
62 | + if ($position!=NULL) { |
|
63 | 63 | $this->buttons=array_splice($this->buttons, $position, 0, $insert); |
64 | - } else { |
|
64 | + }else { |
|
65 | 65 | $this->buttons []=$insert; |
66 | 66 | } |
67 | 67 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | private function addFunction($jsCode) { |
18 | 18 | if (!Text::startsWith($jsCode, "function")) |
19 | - $jsCode="%function(){" . $jsCode . "}%"; |
|
19 | + $jsCode="%function(){".$jsCode."}%"; |
|
20 | 20 | return $jsCode; |
21 | 21 | } |
22 | 22 | |
@@ -43,6 +43,6 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | public static function submitButton(JsUtils $js, $url, $form, $responseElement, $caption="Okay") { |
46 | - return new DialogButton($caption, $js->postForm($url, $form, $responseElement) . ";$( this ).dialog( 'close' );"); |
|
46 | + return new DialogButton($caption, $js->postForm($url, $form, $responseElement).";$( this ).dialog( 'close' );"); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | \ No newline at end of file |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | public function __construct(JsUtils $js) { |
16 | 16 | parent::__construct($js); |
17 | - $this->params=array ( |
|
17 | + $this->params=array( |
|
18 | 18 | "value" => 50 |
19 | 19 | ); |
20 | 20 | $this->uiName="progressbar"; |
@@ -30,7 +30,7 @@ |
||
30 | 30 | * @param string $value default : swing |
31 | 31 | */ |
32 | 32 | public function setEasing($value) { |
33 | - $this->setParamCtrl("easing", $value, array ( |
|
33 | + $this->setParamCtrl("easing", $value, array( |
|
34 | 34 | "linear", |
35 | 35 | "swing", |
36 | 36 | "easeInQuad", |
@@ -74,7 +74,7 @@ |
||
74 | 74 | protected function setParamCtrl($key, $value, $typeCtrl) { |
75 | 75 | if (!$typeCtrl($value)) { |
76 | 76 | throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key." à la position"); |
77 | - } else |
|
77 | + }else |
|
78 | 78 | $this->setParam($key, $value); |
79 | 79 | } |
80 | 80 |
@@ -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 |
@@ -149,7 +149,7 @@ |
||
149 | 149 | $glyph->setGlyphicon($glyphicon); |
150 | 150 | if ($left) { |
151 | 151 | $this->content=$glyph->compile().$separator.$this->content; |
152 | - } else { |
|
152 | + }else { |
|
153 | 153 | $this->content.=$separator.$glyph->compile(); |
154 | 154 | } |
155 | 155 | return $this; |