@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | use BaseTrait; |
| 24 | 24 | protected $_popup=NULL; |
| 25 | 25 | protected $_dimmer=NULL; |
| 26 | - protected $_params=array (); |
|
| 26 | + protected $_params=array(); |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | public function __construct($identifier, $tagName="p", $baseClass="ui", $content=NULL) { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * @return HtmlDimmer |
| 80 | 80 | */ |
| 81 | 81 | public function addDimmer($params=array(), $content=NULL) { |
| 82 | - $dimmer=new HtmlDimmer("dimmer-" . $this->identifier, $content); |
|
| 82 | + $dimmer=new HtmlDimmer("dimmer-".$this->identifier, $content); |
|
| 83 | 83 | $dimmer->setParams($params); |
| 84 | 84 | $dimmer->setContainer($this); |
| 85 | 85 | $this->addContent($dimmer); |
@@ -95,12 +95,12 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function addLabel($label, $before=false, $icon=NULL) { |
| 97 | 97 | $labelO=$label; |
| 98 | - if (\is_object($label) === false) { |
|
| 99 | - $labelO=new HtmlLabel("label-" . $this->identifier, $label); |
|
| 98 | + if (\is_object($label)===false) { |
|
| 99 | + $labelO=new HtmlLabel("label-".$this->identifier, $label); |
|
| 100 | 100 | if (isset($icon)) |
| 101 | 101 | $labelO->addIcon($icon); |
| 102 | 102 | } else { |
| 103 | - $labelO->addToPropertyCtrl("class", "label", array ("label" )); |
|
| 103 | + $labelO->addToPropertyCtrl("class", "label", array("label")); |
|
| 104 | 104 | } |
| 105 | 105 | $this->addContent($labelO, $before); |
| 106 | 106 | return $labelO; |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | * @param string $icon |
| 115 | 115 | * @return HtmlSemDoubleElement |
| 116 | 116 | */ |
| 117 | - public function attachLabel($label,$side=Side::TOP,$direction=Direction::NONE,$icon=NULL){ |
|
| 118 | - $label=$this->addLabel($label,true,$icon); |
|
| 119 | - $label->setAttached($side,$direction); |
|
| 117 | + public function attachLabel($label, $side=Side::TOP, $direction=Direction::NONE, $icon=NULL) { |
|
| 118 | + $label=$this->addLabel($label, true, $icon); |
|
| 119 | + $label->setAttached($side, $direction); |
|
| 120 | 120 | return $this; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -124,10 +124,10 @@ discard block |
||
| 124 | 124 | * Transforms the element into a link |
| 125 | 125 | * @return HtmlSemDoubleElement |
| 126 | 126 | */ |
| 127 | - public function asLink($href=NULL,$target=NULL) { |
|
| 127 | + public function asLink($href=NULL, $target=NULL) { |
|
| 128 | 128 | if (isset($href)) |
| 129 | 129 | $this->setProperty("href", $href); |
| 130 | - if(isset($target)) |
|
| 130 | + if (isset($target)) |
|
| 131 | 131 | $this->setProperty("target", $target); |
| 132 | 132 | return $this->setTagName("a"); |
| 133 | 133 | } |
@@ -139,9 +139,9 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public function jsShowDimmer($show=true) { |
| 141 | 141 | $status="hide"; |
| 142 | - if ($show === true) |
|
| 142 | + if ($show===true) |
|
| 143 | 143 | $status="show"; |
| 144 | - return '$("#.' . $this->identifier . ').dimmer("' . $status . '");'; |
|
| 144 | + return '$("#.'.$this->identifier.').dimmer("'.$status.'");'; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @see BaseHtml::compile() |
| 150 | 150 | */ |
| 151 | 151 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 152 | - if (isset($this->_popup)){ |
|
| 152 | + if (isset($this->_popup)) { |
|
| 153 | 153 | $this->_popup->compile($js); |
| 154 | 154 | } |
| 155 | 155 | return parent::compile($js, $view); |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | * @see HtmlDoubleElement::run() |
| 161 | 161 | */ |
| 162 | 162 | public function run(JsUtils $js) { |
| 163 | - $this->_bsComponent=$js->semantic()->generic("#" . $this->identifier); |
|
| 163 | + $this->_bsComponent=$js->semantic()->generic("#".$this->identifier); |
|
| 164 | 164 | parent::run($js); |
| 165 | 165 | $this->addEventsOnRun($js); |
| 166 | 166 | if (isset($this->_popup)) { |
@@ -169,8 +169,8 @@ discard block |
||
| 169 | 169 | return $this->_bsComponent; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - public function addList($items,$ordered=false){ |
|
| 173 | - $list=new HtmlList("list-".$this->identifier,$items); |
|
| 172 | + public function addList($items, $ordered=false) { |
|
| 173 | + $list=new HtmlList("list-".$this->identifier, $items); |
|
| 174 | 174 | $list->setOrdered($ordered); |
| 175 | 175 | $list->setClass("ui list"); |
| 176 | 176 | $this->addContent($list); |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @version 1.001 |
| 8 | 8 | * Generates a JSON field validator |
| 9 | 9 | */ |
| 10 | -class FieldValidation implements \JsonSerializable{ |
|
| 10 | +class FieldValidation implements \JsonSerializable { |
|
| 11 | 11 | /** |
| 12 | 12 | * @var string |
| 13 | 13 | */ |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | protected $optional; |
| 26 | 26 | |
| 27 | - public function __construct($identifier){ |
|
| 27 | + public function __construct($identifier) { |
|
| 28 | 28 | $this->identifier=$identifier; |
| 29 | 29 | $this->rules=[]; |
| 30 | 30 | } |
@@ -48,26 +48,26 @@ discard block |
||
| 48 | 48 | * @param string $value |
| 49 | 49 | * @return Rule |
| 50 | 50 | */ |
| 51 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
| 52 | - if($type instanceof Rule) |
|
| 51 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
| 52 | + if ($type instanceof Rule) |
|
| 53 | 53 | $rule=$type; |
| 54 | - else if(\is_array($type)){ |
|
| 54 | + else if (\is_array($type)) { |
|
| 55 | 55 | $value=JArray::getValue($type, "value", 2); |
| 56 | 56 | $prompt=JArray::getValue($type, "prompt", 1); |
| 57 | 57 | $type=JArray::getValue($type, "type", 0); |
| 58 | - $rule=new Rule($type,$prompt,$value); |
|
| 59 | - }else |
|
| 60 | - $rule=new Rule($type,$prompt,$value); |
|
| 58 | + $rule=new Rule($type, $prompt, $value); |
|
| 59 | + } else |
|
| 60 | + $rule=new Rule($type, $prompt, $value); |
|
| 61 | 61 | $this->rules[]=$rule; |
| 62 | 62 | return $rule; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public function jsonSerialize(){ |
|
| 66 | - $result=["identifier"=>$this->identifier,"rules"=>$this->rules]; |
|
| 67 | - if($this->optional){ |
|
| 65 | + public function jsonSerialize() { |
|
| 66 | + $result=["identifier"=>$this->identifier, "rules"=>$this->rules]; |
|
| 67 | + if ($this->optional) { |
|
| 68 | 68 | $result["optional"]=true; |
| 69 | 69 | } |
| 70 | - if(isset($this->depends)){ |
|
| 70 | + if (isset($this->depends)) { |
|
| 71 | 71 | $result["depends"]=$this->depends; |
| 72 | 72 | } |
| 73 | 73 | return $result; |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @version 1.001 |
| 9 | 9 | * Generates a JSON Rule for the validation of a field |
| 10 | 10 | */ |
| 11 | -class Rule implements \JsonSerializable{ |
|
| 11 | +class Rule implements \JsonSerializable { |
|
| 12 | 12 | /** |
| 13 | 13 | * @var string |
| 14 | 14 | */ |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | private $value; |
| 25 | 25 | |
| 26 | - public function __construct($type,$prompt=NULL,$value=NULL){ |
|
| 26 | + public function __construct($type, $prompt=NULL, $value=NULL) { |
|
| 27 | 27 | $this->type=$type; |
| 28 | 28 | $this->prompt=$prompt; |
| 29 | 29 | $this->value=$value; |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function jsonSerialize() { |
| 60 | - $result= ["type"=>$this->type]; |
|
| 61 | - if(isset($this->prompt)) |
|
| 60 | + $result=["type"=>$this->type]; |
|
| 61 | + if (isset($this->prompt)) |
|
| 62 | 62 | $result["prompt"]=$this->prompt; |
| 63 | - if(isset($this->value)) |
|
| 63 | + if (isset($this->value)) |
|
| 64 | 64 | $result["value"]=$this->value; |
| 65 | 65 | return $result; |
| 66 | 66 | } |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | * @param string $prompt |
| 72 | 72 | * @return \Ajax\semantic\components\validation\Rule |
| 73 | 73 | */ |
| 74 | - public static function match($name,$prompt=NULL){ |
|
| 75 | - return new Rule("match[".$name."]",$prompt); |
|
| 74 | + public static function match($name, $prompt=NULL) { |
|
| 75 | + return new Rule("match[".$name."]", $prompt); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | * @param string $prompt |
| 82 | 82 | * @return \Ajax\semantic\components\validation\Rule |
| 83 | 83 | */ |
| 84 | - public static function different($name,$prompt=NULL){ |
|
| 85 | - return new Rule("different[".$name."]",$prompt); |
|
| 84 | + public static function different($name, $prompt=NULL) { |
|
| 85 | + return new Rule("different[".$name."]", $prompt); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -92,82 +92,82 @@ discard block |
||
| 92 | 92 | * @param string $prompt |
| 93 | 93 | * @return \Ajax\semantic\components\validation\Rule |
| 94 | 94 | */ |
| 95 | - public static function integer($min=NULL,$max=NULL,$prompt=NULL){ |
|
| 96 | - if(\is_int($min) && \is_int($max)) |
|
| 97 | - return new Rule("integer[{$min}..{$max}]",$prompt); |
|
| 98 | - return new Rule("integer",$prompt); |
|
| 95 | + public static function integer($min=NULL, $max=NULL, $prompt=NULL) { |
|
| 96 | + if (\is_int($min) && \is_int($max)) |
|
| 97 | + return new Rule("integer[{$min}..{$max}]", $prompt); |
|
| 98 | + return new Rule("integer", $prompt); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - public static function decimal($prompt=NULL){ |
|
| 102 | - return new Rule("decimal",$prompt); |
|
| 101 | + public static function decimal($prompt=NULL) { |
|
| 102 | + return new Rule("decimal", $prompt); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - public static function number($prompt=NULL){ |
|
| 106 | - return new Rule("number",$prompt); |
|
| 105 | + public static function number($prompt=NULL) { |
|
| 106 | + return new Rule("number", $prompt); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - public static function is($value,$prompt=NULL){ |
|
| 110 | - return new Rule("is[".$value."]",$prompt); |
|
| 109 | + public static function is($value, $prompt=NULL) { |
|
| 110 | + return new Rule("is[".$value."]", $prompt); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - public static function isExactly($value,$prompt=NULL){ |
|
| 114 | - return new Rule("isExactly[".$value."]",$prompt); |
|
| 113 | + public static function isExactly($value, $prompt=NULL) { |
|
| 114 | + return new Rule("isExactly[".$value."]", $prompt); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - public static function not($value,$prompt=NULL){ |
|
| 118 | - return new Rule("not[".$value."]",$prompt); |
|
| 117 | + public static function not($value, $prompt=NULL) { |
|
| 118 | + return new Rule("not[".$value."]", $prompt); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - public static function notExactly($value,$prompt=NULL){ |
|
| 122 | - return new Rule("notExactly[".$value."]",$prompt); |
|
| 121 | + public static function notExactly($value, $prompt=NULL) { |
|
| 122 | + return new Rule("notExactly[".$value."]", $prompt); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - public static function contains($value,$prompt=NULL){ |
|
| 126 | - return new Rule("contains[".$value."]",$prompt); |
|
| 125 | + public static function contains($value, $prompt=NULL) { |
|
| 126 | + return new Rule("contains[".$value."]", $prompt); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - public static function containsExactly($value,$prompt=NULL){ |
|
| 130 | - return new Rule("containsExactly[".$value."]",$prompt); |
|
| 129 | + public static function containsExactly($value, $prompt=NULL) { |
|
| 130 | + return new Rule("containsExactly[".$value."]", $prompt); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - public static function doesntContain($value,$prompt=NULL){ |
|
| 134 | - return new Rule("doesntContain[".$value."]",$prompt); |
|
| 133 | + public static function doesntContain($value, $prompt=NULL) { |
|
| 134 | + return new Rule("doesntContain[".$value."]", $prompt); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - public static function doesntContainExactly($value,$prompt=NULL){ |
|
| 138 | - return new Rule("doesntContainExactly[".$value."]",$prompt); |
|
| 137 | + public static function doesntContainExactly($value, $prompt=NULL) { |
|
| 138 | + return new Rule("doesntContainExactly[".$value."]", $prompt); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - public static function minCount($value,$prompt=NULL){ |
|
| 142 | - return new Rule("minCount[".$value."]",$prompt); |
|
| 141 | + public static function minCount($value, $prompt=NULL) { |
|
| 142 | + return new Rule("minCount[".$value."]", $prompt); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - public static function maxCount($value,$prompt=NULL){ |
|
| 146 | - return new Rule("maxCount[".$value."]",$prompt); |
|
| 145 | + public static function maxCount($value, $prompt=NULL) { |
|
| 146 | + return new Rule("maxCount[".$value."]", $prompt); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - public static function exactCount($value,$prompt=NULL){ |
|
| 150 | - return new Rule("exactCount[".$value."]",$prompt); |
|
| 149 | + public static function exactCount($value, $prompt=NULL) { |
|
| 150 | + return new Rule("exactCount[".$value."]", $prompt); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - public static function email($prompt=NULL){ |
|
| 154 | - return new Rule("email",$prompt); |
|
| 153 | + public static function email($prompt=NULL) { |
|
| 154 | + return new Rule("email", $prompt); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - public static function url($prompt=NULL){ |
|
| 158 | - return new Rule("url",$prompt); |
|
| 157 | + public static function url($prompt=NULL) { |
|
| 158 | + return new Rule("url", $prompt); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - public static function regExp($value,$prompt=NULL){ |
|
| 162 | - return new Rule("regExp",$prompt,$value); |
|
| 161 | + public static function regExp($value, $prompt=NULL) { |
|
| 162 | + return new Rule("regExp", $prompt, $value); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - public static function custom($name,$jsFunction){ |
|
| 166 | - return "$.fn.form.settings.rules.".$name." =".$jsFunction ; |
|
| 165 | + public static function custom($name, $jsFunction) { |
|
| 166 | + return "$.fn.form.settings.rules.".$name." =".$jsFunction; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - public static function ajax(JsUtils $js,$name,$url,$params,$jsCallback,$method="post",$parameters=[]){ |
|
| 170 | - $parameters=\array_merge(["async"=>false,"url"=>$url,"params"=>$params,"hasLoader"=>false,"jsCallback"=>$jsCallback,"dataType"=>"json","stopPropagation"=>false,"preventDefault"=>false,"responseElement"=>null],$parameters); |
|
| 169 | + public static function ajax(JsUtils $js, $name, $url, $params, $jsCallback, $method="post", $parameters=[]) { |
|
| 170 | + $parameters=\array_merge(["async"=>false, "url"=>$url, "params"=>$params, "hasLoader"=>false, "jsCallback"=>$jsCallback, "dataType"=>"json", "stopPropagation"=>false, "preventDefault"=>false, "responseElement"=>null], $parameters); |
|
| 171 | 171 | $ajax=new AjaxCall($method, $parameters); |
| 172 | 172 | return self::custom($name, "function(value,ruleValue){var result=true;".$ajax->compile($js)."return result;}"); |
| 173 | 173 | } |
@@ -2,10 +2,10 @@ discard block |
||
| 2 | 2 | namespace Ajax\common\traits; |
| 3 | 3 | use Ajax\common\BaseGui; |
| 4 | 4 | |
| 5 | -trait JsUtilsInternalTrait{ |
|
| 5 | +trait JsUtilsInternalTrait { |
|
| 6 | 6 | |
| 7 | - protected $jquery_code_for_compile=array (); |
|
| 8 | - protected $jquery_code_for_compile_at_last=array (); |
|
| 7 | + protected $jquery_code_for_compile=array(); |
|
| 8 | + protected $jquery_code_for_compile_at_last=array(); |
|
| 9 | 9 | |
| 10 | 10 | protected function _addToCompile($jsScript) { |
| 11 | 11 | $this->jquery_code_for_compile[]=$jsScript; |
@@ -15,29 +15,29 @@ discard block |
||
| 15 | 15 | * @param BaseGui $library |
| 16 | 16 | * @param mixed $view |
| 17 | 17 | */ |
| 18 | - protected function _compileLibrary(BaseGui $library, &$view=NULL){ |
|
| 19 | - if(isset($view)) |
|
| 18 | + protected function _compileLibrary(BaseGui $library, &$view=NULL) { |
|
| 19 | + if (isset($view)) |
|
| 20 | 20 | $library->compileHtml($this, $view); |
| 21 | 21 | if ($library->isAutoCompile()) { |
| 22 | 22 | $library->compile(true); |
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - protected function defer($script){ |
|
| 26 | + protected function defer($script) { |
|
| 27 | 27 | $result="window.defer=function (method) {if (window.jQuery) method(); else setTimeout(function() { defer(method) }, 50);};"; |
| 28 | 28 | $result.="window.defer(function(){".$script."})"; |
| 29 | 29 | return $result; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - protected function ready($script){ |
|
| 32 | + protected function ready($script) { |
|
| 33 | 33 | $result='$(document).ready(function() {'."\n"; |
| 34 | 34 | $result.=$script.'})'; |
| 35 | 35 | return $result; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | protected function minify($input) { |
| 39 | - if(trim($input) === "") return $input; |
|
| 40 | - $input= preg_replace( |
|
| 39 | + if (trim($input)==="") return $input; |
|
| 40 | + $input=preg_replace( |
|
| 41 | 41 | array( |
| 42 | 42 | // Remove comment(s) |
| 43 | 43 | '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
@@ -6,16 +6,16 @@ discard block |
||
| 6 | 6 | public static $preventDefault="\nif(event && event.preventDefault) event.preventDefault();\n"; |
| 7 | 7 | public static $stopPropagation="\nif(event && event.stopPropagation) event.stopPropagation();\n"; |
| 8 | 8 | |
| 9 | - public static function draggable($attr="id"){ |
|
| 9 | + public static function draggable($attr="id") { |
|
| 10 | 10 | return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;dt.setData("text/plain",JSON.stringify({id:$(event.target).attr("id"),data:$(event.target).attr("'.$attr.'")}));'; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | - public static function dropZone($jqueryDone,$jsCallback=""){ |
|
| 13 | + public static function dropZone($jqueryDone, $jsCallback="") { |
|
| 14 | 14 | return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;var _data=JSON.parse(dt.getData("text/plain"));$(event.target).'.$jqueryDone.'($("#"+_data.id));var data=_data.data;'.$jsCallback; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - public static function containsCode($expression){ |
|
| 18 | - return strrpos($expression, 'this')!==false||strrpos($expression, 'event')!==false||strrpos($expression, 'self')!==false; |
|
| 17 | + public static function containsCode($expression) { |
|
| 18 | + return strrpos($expression, 'this')!==false || strrpos($expression, 'event')!==false || strrpos($expression, 'self')!==false; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | $value=implode(",", $value); |
| 47 | 47 | } |
| 48 | 48 | if (self::containsCode($value)===false) { |
| 49 | - $value=\str_replace(["\\","\""], ["\\\\","\\\""], $value); |
|
| 49 | + $value=\str_replace(["\\", "\""], ["\\\\", "\\\""], $value); |
|
| 50 | 50 | $value='"'.$value.'"'; |
| 51 | 51 | } |
| 52 | - return trim($value,"%"); |
|
| 52 | + return trim($value, "%"); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public static function prep_jquery_selector($value){ |
|
| 56 | - if(JString::startswith($value, '$(')===false){ |
|
| 55 | + public static function prep_jquery_selector($value) { |
|
| 56 | + if (JString::startswith($value, '$(')===false) { |
|
| 57 | 57 | return '$('.self::prep_value($value).')'; |
| 58 | 58 | } |
| 59 | 59 | return $value; |
@@ -31,23 +31,23 @@ discard block |
||
| 31 | 31 | * @property boolean $_edition |
| 32 | 32 | * @property mixed _modelInstance |
| 33 | 33 | */ |
| 34 | -trait FieldAsTrait{ |
|
| 34 | +trait FieldAsTrait { |
|
| 35 | 35 | |
| 36 | - abstract protected function _getFieldIdentifier($prefix,$name=""); |
|
| 37 | - abstract public function setValueFunction($index,$callback); |
|
| 36 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
| 37 | + abstract public function setValueFunction($index, $callback); |
|
| 38 | 38 | abstract protected function _getFieldName($index); |
| 39 | 39 | abstract protected function _getFieldCaption($index); |
| 40 | - abstract protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
|
| 40 | + abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @param HtmlFormField $element |
| 44 | 44 | * @param array $attributes |
| 45 | 45 | */ |
| 46 | - protected function _applyAttributes(BaseHtml $element,&$attributes,$index,$instance=null){ |
|
| 47 | - if(isset($attributes["jsCallback"])){ |
|
| 46 | + protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance=null) { |
|
| 47 | + if (isset($attributes["jsCallback"])) { |
|
| 48 | 48 | $callback=$attributes["jsCallback"]; |
| 49 | - if(\is_callable($callback)){ |
|
| 50 | - $callback($element,$instance,$index,InstanceViewer::$index); |
|
| 49 | + if (\is_callable($callback)) { |
|
| 50 | + $callback($element, $instance, $index, InstanceViewer::$index); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | unset($attributes["rules"]); |
@@ -56,43 +56,43 @@ discard block |
||
| 56 | 56 | $element->fromArray($attributes); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - private function _getLabelField($caption,$icon=NULL){ |
|
| 60 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
| 59 | + private function _getLabelField($caption, $icon=NULL) { |
|
| 60 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
| 61 | 61 | return $label; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
| 65 | - protected function _addRules(HtmlFormField $element,&$attributes){ |
|
| 66 | - if(isset($attributes["rules"])){ |
|
| 65 | + protected function _addRules(HtmlFormField $element, &$attributes) { |
|
| 66 | + if (isset($attributes["rules"])) { |
|
| 67 | 67 | $rules=$attributes["rules"]; |
| 68 | - if(\is_array($rules)){ |
|
| 68 | + if (\is_array($rules)) { |
|
| 69 | 69 | $element->addRules($rules); |
| 70 | 70 | } |
| 71 | - else{ |
|
| 71 | + else { |
|
| 72 | 72 | $element->addRule($rules); |
| 73 | 73 | } |
| 74 | 74 | unset($attributes["rules"]); |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - protected function _prepareFormFields(HtmlFormField &$field,$name,&$attributes){ |
|
| 78 | + protected function _prepareFormFields(HtmlFormField &$field, $name, &$attributes) { |
|
| 79 | 79 | $field->setName($name); |
| 80 | 80 | $this->_addRules($field, $attributes); |
| 81 | 81 | return $field; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){ |
|
| 85 | - $this->setValueFunction($index,function($value,$instance,$index,$rowIndex) use (&$attributes,$elementCallback,$prefix){ |
|
| 84 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
| 85 | + $this->setValueFunction($index, function($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix){ |
|
| 86 | 86 | $caption=$this->_getFieldCaption($index); |
| 87 | 87 | $name=$this->_getFieldName($index); |
| 88 | - $id=$this->_getFieldIdentifier($prefix,$name); |
|
| 89 | - if(isset($attributes["name"])){ |
|
| 88 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
| 89 | + if (isset($attributes["name"])) { |
|
| 90 | 90 | $name=$attributes["name"]; |
| 91 | 91 | unset($attributes["name"]); |
| 92 | 92 | } |
| 93 | - $element=$elementCallback($id,$name,$value,$caption); |
|
| 94 | - if(\is_array($attributes)){ |
|
| 95 | - $this->_applyAttributes($element, $attributes,$index,$instance); |
|
| 93 | + $element=$elementCallback($id, $name, $value, $caption); |
|
| 94 | + if (\is_array($attributes)) { |
|
| 95 | + $this->_applyAttributes($element, $attributes, $index, $instance); |
|
| 96 | 96 | } |
| 97 | 97 | $element->setDisabled(!$this->_edition); |
| 98 | 98 | return $element; |
@@ -101,205 +101,205 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | |
| 104 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
| 105 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
| 106 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
| 104 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
| 105 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
| 106 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
| 107 | 107 | return $pb; |
| 108 | 108 | }); |
| 109 | 109 | return $this; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
| 113 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
| 114 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
| 112 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
| 113 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
| 114 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
| 115 | 115 | return $rating; |
| 116 | 116 | }); |
| 117 | 117 | return $this; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - public function fieldAsLabel($index,$icon=NULL,$attributes=NULL){ |
|
| 121 | - return $this->_fieldAs(function($id,$name,$value) use($icon){ |
|
| 122 | - $lbl=new HtmlLabel($id,$value); |
|
| 123 | - if(isset($icon)) |
|
| 120 | + public function fieldAsLabel($index, $icon=NULL, $attributes=NULL) { |
|
| 121 | + return $this->_fieldAs(function($id, $name, $value) use($icon){ |
|
| 122 | + $lbl=new HtmlLabel($id, $value); |
|
| 123 | + if (isset($icon)) |
|
| 124 | 124 | $lbl->addIcon($icon); |
| 125 | 125 | return $lbl; |
| 126 | - }, $index,$attributes,"label"); |
|
| 126 | + }, $index, $attributes, "label"); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
| 130 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
| 131 | - $header=new HtmlHeader($id,$niveau,$value); |
|
| 132 | - if(isset($icon)) |
|
| 129 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
| 130 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
| 131 | + $header=new HtmlHeader($id, $niveau, $value); |
|
| 132 | + if (isset($icon)) |
|
| 133 | 133 | $header->asIcon($icon, $value); |
| 134 | 134 | return $header; |
| 135 | - }, $index,$attributes,"header"); |
|
| 135 | + }, $index, $attributes, "header"); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
| 139 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
| 140 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
| 141 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
| 139 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
| 140 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
| 141 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
| 142 | 142 | return $image; |
| 143 | 143 | }); |
| 144 | 144 | return $this; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - public function fieldAsFlag($index){ |
|
| 148 | - $this->setValueFunction($index,function($flag){ |
|
| 149 | - $flag=new HtmlFlag($this->_getFieldIdentifier("flag"),$flag); |
|
| 147 | + public function fieldAsFlag($index) { |
|
| 148 | + $this->setValueFunction($index, function($flag) { |
|
| 149 | + $flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
| 150 | 150 | return $flag; |
| 151 | 151 | }); |
| 152 | 152 | return $this; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - public function fieldAsIcon($index){ |
|
| 156 | - $this->setValueFunction($index,function($icon){ |
|
| 157 | - $icon=new HtmlIcon($this->_getFieldIdentifier("icon"),$icon); |
|
| 155 | + public function fieldAsIcon($index) { |
|
| 156 | + $this->setValueFunction($index, function($icon) { |
|
| 157 | + $icon=new HtmlIcon($this->_getFieldIdentifier("icon"), $icon); |
|
| 158 | 158 | return $icon; |
| 159 | 159 | }); |
| 160 | 160 | return $this; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
| 164 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 165 | - $img=new HtmlImage($id,$value); |
|
| 163 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
| 164 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 165 | + $img=new HtmlImage($id, $value); |
|
| 166 | 166 | $img->asAvatar(); |
| 167 | 167 | return $img; |
| 168 | - }, $index,$attributes,"avatar"); |
|
| 168 | + }, $index, $attributes, "avatar"); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
| 172 | - return $this->_fieldAs(function($id,$name,$value) use($attributes){ |
|
| 173 | - $input= new HtmlFormRadio($id,$name,$value,$value); |
|
| 171 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
| 172 | + return $this->_fieldAs(function($id, $name, $value) use($attributes){ |
|
| 173 | + $input=new HtmlFormRadio($id, $name, $value, $value); |
|
| 174 | 174 | return $this->_prepareFormFields($input, $name, $attributes); |
| 175 | - }, $index,$attributes,"radio"); |
|
| 175 | + }, $index, $attributes, "radio"); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
| 179 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){ |
|
| 180 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
| 181 | - }, $index,$attributes,"radios"); |
|
| 178 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
| 179 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){ |
|
| 180 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
| 181 | + }, $index, $attributes, "radios"); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - public function fieldAsList($index,$classNames="",$attributes=NULL){ |
|
| 185 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($classNames){ |
|
| 186 | - $result= new HtmlList($name,$value); |
|
| 184 | + public function fieldAsList($index, $classNames="", $attributes=NULL) { |
|
| 185 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($classNames){ |
|
| 186 | + $result=new HtmlList($name, $value); |
|
| 187 | 187 | $result->addClass($classNames); |
| 188 | 188 | return $result; |
| 189 | - }, $index,$attributes,"list"); |
|
| 189 | + }, $index, $attributes, "list"); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - public function fieldAsInput($index,$attributes=NULL){ |
|
| 193 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
| 194 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
| 192 | + public function fieldAsInput($index, $attributes=NULL) { |
|
| 193 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
| 194 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
| 195 | 195 | return $this->_prepareFormFields($input, $name, $attributes); |
| 196 | - }, $index,$attributes,"input"); |
|
| 196 | + }, $index, $attributes, "input"); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
| 200 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
| 201 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
| 199 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
| 200 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
| 201 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
| 202 | 202 | return $this->_prepareFormFields($textarea, $name, $attributes); |
| 203 | - }, $index,$attributes,"textarea"); |
|
| 203 | + }, $index, $attributes, "textarea"); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - public function fieldAsElement($index,$tagName="div",$baseClass="",$attributes=NULL){ |
|
| 207 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes,$tagName,$baseClass){ |
|
| 208 | - $div=new HtmlSemDoubleElement($id,$tagName,$baseClass); |
|
| 206 | + public function fieldAsElement($index, $tagName="div", $baseClass="", $attributes=NULL) { |
|
| 207 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass){ |
|
| 208 | + $div=new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
| 209 | 209 | $div->setContent(\htmlentities($value)); |
| 210 | - $textarea=new HtmlFormField("field-".$id, $div,$caption); |
|
| 210 | + $textarea=new HtmlFormField("field-".$id, $div, $caption); |
|
| 211 | 211 | return $this->_prepareFormFields($textarea, $name, $attributes); |
| 212 | - }, $index,$attributes,"element"); |
|
| 212 | + }, $index, $attributes, "element"); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | |
| 216 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
| 217 | - if(!\is_array($attributes)){ |
|
| 216 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
| 217 | + if (!\is_array($attributes)) { |
|
| 218 | 218 | $attributes=[]; |
| 219 | 219 | } |
| 220 | 220 | $attributes["inputType"]="hidden"; |
| 221 | 221 | $attributes["style"]="display:none;"; |
| 222 | - return $this->fieldAsInput($index,$attributes); |
|
| 222 | + return $this->fieldAsInput($index, $attributes); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
| 226 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($attributes){ |
|
| 227 | - if($caption===null || $caption==="") |
|
| 225 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
| 226 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($attributes){ |
|
| 227 | + if ($caption===null || $caption==="") |
|
| 228 | 228 | $caption=""; |
| 229 | - $input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier()); |
|
| 229 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
| 230 | 230 | $input->setChecked(JString::isBooleanTrue($value)); |
| 231 | 231 | return $this->_prepareFormFields($input, $name, $attributes); |
| 232 | - }, $index,$attributes,"ck"); |
|
| 232 | + }, $index, $attributes, "ck"); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
| 236 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple,$attributes){ |
|
| 237 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value); |
|
| 238 | - $dd->asSelect($name,$multiple); |
|
| 235 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
| 236 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple, $attributes){ |
|
| 237 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value); |
|
| 238 | + $dd->asSelect($name, $multiple); |
|
| 239 | 239 | return $this->_prepareFormFields($dd, $name, $attributes); |
| 240 | - }, $index,$attributes,"dd"); |
|
| 240 | + }, $index, $attributes, "dd"); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
| 244 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 245 | - $mess= new HtmlMessage("message-".$id,$caption); |
|
| 243 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
| 244 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 245 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
| 246 | 246 | $mess->addHeader($value); |
| 247 | 247 | return $mess; |
| 248 | - }, $index,$attributes,"message"); |
|
| 248 | + }, $index, $attributes, "message"); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - public function fieldAsLink($index,$attributes=NULL){ |
|
| 252 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 253 | - $lnk= new HtmlLink("message-".$id,"#",$caption); |
|
| 251 | + public function fieldAsLink($index, $attributes=NULL) { |
|
| 252 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 253 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
| 254 | 254 | return $lnk; |
| 255 | - }, $index,$attributes,"link"); |
|
| 255 | + }, $index, $attributes, "link"); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /**Change fields type |
| 259 | 259 | * @param array $types an array or associative array $type=>$attributes |
| 260 | 260 | */ |
| 261 | - public function fieldsAs(array $types){ |
|
| 261 | + public function fieldsAs(array $types) { |
|
| 262 | 262 | $i=0; |
| 263 | - if(JArray::isAssociative($types)){ |
|
| 264 | - foreach ($types as $type=>$attributes){ |
|
| 265 | - if(\is_int($type)) |
|
| 266 | - $this->fieldAs($i++,$attributes,[]); |
|
| 267 | - else{ |
|
| 268 | - $type=preg_replace('/\d/', '', $type ); |
|
| 269 | - $this->fieldAs($i++,$type,$attributes); |
|
| 263 | + if (JArray::isAssociative($types)) { |
|
| 264 | + foreach ($types as $type=>$attributes) { |
|
| 265 | + if (\is_int($type)) |
|
| 266 | + $this->fieldAs($i++, $attributes, []); |
|
| 267 | + else { |
|
| 268 | + $type=preg_replace('/\d/', '', $type); |
|
| 269 | + $this->fieldAs($i++, $type, $attributes); |
|
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | - }else{ |
|
| 273 | - foreach ($types as $type){ |
|
| 274 | - $this->fieldAs($i++,$type); |
|
| 272 | + } else { |
|
| 273 | + foreach ($types as $type) { |
|
| 274 | + $this->fieldAs($i++, $type); |
|
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - public function fieldAs($index,$type,$attributes=NULL){ |
|
| 279 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
| 280 | 280 | $method="fieldAs".\ucfirst($type); |
| 281 | - if(\method_exists($this, $method)){ |
|
| 282 | - if(!\is_array($attributes)){ |
|
| 281 | + if (\method_exists($this, $method)) { |
|
| 282 | + if (!\is_array($attributes)) { |
|
| 283 | 283 | $attributes=[$index]; |
| 284 | - }else{ |
|
| 284 | + } else { |
|
| 285 | 285 | \array_unshift($attributes, $index); |
| 286 | 286 | } |
| 287 | - \call_user_func_array([$this,$method], $attributes); |
|
| 287 | + \call_user_func_array([$this, $method], $attributes); |
|
| 288 | 288 | } |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
| 292 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
|
| 293 | - $button=new HtmlButton($id,$caption,$cssStyle); |
|
| 294 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]); |
|
| 291 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
| 292 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){ |
|
| 293 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
| 294 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]); |
|
| 295 | 295 | return $button; |
| 296 | - }, $index,$attributes,"submit"); |
|
| 296 | + }, $index, $attributes, "submit"); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){ |
|
| 300 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
| 301 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 299 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 300 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
| 301 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 302 | 302 | return $button; |
| 303 | - }, $index,$attributes,"button"); |
|
| 303 | + }, $index, $attributes, "button"); |
|
| 304 | 304 | } |
| 305 | 305 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | use Ajax\semantic\html\modules\HtmlModal; |
| 21 | 21 | |
| 22 | 22 | abstract class Widget extends HtmlDoubleElement { |
| 23 | - use FieldAsTrait,FormTrait; |
|
| 23 | + use FieldAsTrait, FormTrait; |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @var string classname |
@@ -53,17 +53,17 @@ discard block |
||
| 53 | 53 | protected $_generated; |
| 54 | 54 | |
| 55 | 55 | |
| 56 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 56 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 57 | 57 | parent::__construct($identifier); |
| 58 | 58 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
| 59 | 59 | $this->setModel($model); |
| 60 | - if(isset($modelInstance)){ |
|
| 60 | + if (isset($modelInstance)) { |
|
| 61 | 61 | $this->show($modelInstance); |
| 62 | 62 | } |
| 63 | 63 | $this->_generated=false; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - protected function _init($instanceViewer,$contentKey,$content,$edition){ |
|
| 66 | + protected function _init($instanceViewer, $contentKey, $content, $edition) { |
|
| 67 | 67 | $this->_instanceViewer=$instanceViewer; |
| 68 | 68 | $this->content=[$contentKey=>$content]; |
| 69 | 69 | $this->_self=$content; |
@@ -75,31 +75,31 @@ discard block |
||
| 75 | 75 | * @param int|string $fieldName |
| 76 | 76 | * @return int|string|boolean |
| 77 | 77 | */ |
| 78 | - protected function _getIndex($fieldName){ |
|
| 78 | + protected function _getIndex($fieldName) { |
|
| 79 | 79 | $index=$fieldName; |
| 80 | - if(\is_string($fieldName)){ |
|
| 80 | + if (\is_string($fieldName)) { |
|
| 81 | 81 | $fields=$this->_instanceViewer->getVisibleProperties(); |
| 82 | 82 | $index=\array_search($fieldName, $fields); |
| 83 | 83 | } |
| 84 | 84 | return $index; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
| 87 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
| 88 | 88 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - protected function _getFieldName($index){ |
|
| 91 | + protected function _getFieldName($index) { |
|
| 92 | 92 | return $this->_instanceViewer->getFieldName($index); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - protected function _getFieldCaption($index){ |
|
| 95 | + protected function _getFieldCaption($index) { |
|
| 96 | 96 | return $this->_instanceViewer->getCaption($index); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - abstract protected function _setToolbarPosition($table,$captions=NULL); |
|
| 99 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
| 100 | 100 | |
| 101 | - public function show($modelInstance){ |
|
| 102 | - if(\is_array($modelInstance)){ |
|
| 101 | + public function show($modelInstance) { |
|
| 102 | + if (\is_array($modelInstance)) { |
|
| 103 | 103 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
| 104 | 104 | } |
| 105 | 105 | $this->_modelInstance=$modelInstance; |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | abstract public function getHtmlComponent(); |
| 127 | 127 | |
| 128 | - public function setAttached($value=true){ |
|
| 128 | + public function setAttached($value=true) { |
|
| 129 | 129 | return $this->getHtmlComponent()->setAttached($value); |
| 130 | 130 | } |
| 131 | 131 | |
@@ -136,65 +136,65 @@ discard block |
||
| 136 | 136 | * @param callable $callback function called after the field compilation |
| 137 | 137 | * @return Widget |
| 138 | 138 | */ |
| 139 | - public function afterCompile($index,$callback){ |
|
| 139 | + public function afterCompile($index, $callback) { |
|
| 140 | 140 | $index=$this->_getIndex($index); |
| 141 | 141 | $this->_instanceViewer->afterCompile($index, $callback); |
| 142 | 142 | return $this; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - public function setColor($color){ |
|
| 145 | + public function setColor($color) { |
|
| 146 | 146 | return $this->getHtmlComponent()->setColor($color); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
| 150 | - public function setCaptions($captions){ |
|
| 150 | + public function setCaptions($captions) { |
|
| 151 | 151 | $this->_instanceViewer->setCaptions($captions); |
| 152 | 152 | return $this; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - public function setCaption($index,$caption){ |
|
| 155 | + public function setCaption($index, $caption) { |
|
| 156 | 156 | $this->_instanceViewer->setCaption($this->_getIndex($index), $caption); |
| 157 | 157 | return $this; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function setFields($fields){ |
|
| 160 | + public function setFields($fields) { |
|
| 161 | 161 | $this->_instanceViewer->setVisibleProperties($fields); |
| 162 | 162 | return $this; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - public function addField($field,$key=null){ |
|
| 166 | - $this->_instanceViewer->addField($field,$key); |
|
| 165 | + public function addField($field, $key=null) { |
|
| 166 | + $this->_instanceViewer->addField($field, $key); |
|
| 167 | 167 | return $this; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - public function addFields($fields){ |
|
| 170 | + public function addFields($fields) { |
|
| 171 | 171 | $this->_instanceViewer->addFields($fields); |
| 172 | 172 | return $this; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - public function countFields(){ |
|
| 175 | + public function countFields() { |
|
| 176 | 176 | return $this->_instanceViewer->visiblePropertiesCount(); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - public function addMessage($attributes=NULL,$fieldName="message"){ |
|
| 179 | + public function addMessage($attributes=NULL, $fieldName="message") { |
|
| 180 | 180 | $this->_instanceViewer->addField($fieldName); |
| 181 | 181 | $count=$this->_instanceViewer->visiblePropertiesCount(); |
| 182 | - return $this->fieldAsMessage($count-1,$attributes); |
|
| 182 | + return $this->fieldAsMessage($count-1, $attributes); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - public function addErrorMessage(){ |
|
| 186 | - return $this->addMessage(["error"=>true],"message"); |
|
| 185 | + public function addErrorMessage() { |
|
| 186 | + return $this->addMessage(["error"=>true], "message"); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - public function insertField($index,$field,$key=null){ |
|
| 189 | + public function insertField($index, $field, $key=null) { |
|
| 190 | 190 | $index=$this->_getIndex($index); |
| 191 | - $this->_instanceViewer->insertField($index, $field,$key); |
|
| 191 | + $this->_instanceViewer->insertField($index, $field, $key); |
|
| 192 | 192 | return $this; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - public function insertInField($index,$field,$key=null){ |
|
| 195 | + public function insertInField($index, $field, $key=null) { |
|
| 196 | 196 | $index=$this->_getIndex($index); |
| 197 | - $this->_instanceViewer->insertInField($index, $field,$key); |
|
| 197 | + $this->_instanceViewer->insertInField($index, $field, $key); |
|
| 198 | 198 | return $this; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -204,13 +204,13 @@ discard block |
||
| 204 | 204 | * @param callable $callback function parameters are : $value : the field value, $instance : the active instance of model, $fieldIndex : the field index, $rowIndex : the row index |
| 205 | 205 | * @return Widget |
| 206 | 206 | */ |
| 207 | - public function setValueFunction($index,$callback){ |
|
| 207 | + public function setValueFunction($index, $callback) { |
|
| 208 | 208 | $index=$this->_getIndex($index); |
| 209 | 209 | $this->_instanceViewer->setValueFunction($index, $callback); |
| 210 | 210 | return $this; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - public function setIdentifierFunction($callback){ |
|
| 213 | + public function setIdentifierFunction($callback) { |
|
| 214 | 214 | $this->_instanceViewer->setIdentifierFunction($callback); |
| 215 | 215 | return $this; |
| 216 | 216 | } |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | /** |
| 219 | 219 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
| 220 | 220 | */ |
| 221 | - public function getToolbar(){ |
|
| 222 | - if(isset($this->_toolbar)===false){ |
|
| 221 | + public function getToolbar() { |
|
| 222 | + if (isset($this->_toolbar)===false) { |
|
| 223 | 223 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
| 224 | 224 | } |
| 225 | 225 | return $this->_toolbar; |
@@ -231,15 +231,15 @@ discard block |
||
| 231 | 231 | * @param callable $callback function to call on $element |
| 232 | 232 | * @return \Ajax\common\html\HtmlDoubleElement |
| 233 | 233 | */ |
| 234 | - public function addInToolbar($element,$callback=NULL){ |
|
| 234 | + public function addInToolbar($element, $callback=NULL) { |
|
| 235 | 235 | $tb=$this->getToolbar(); |
| 236 | - if($element instanceof BaseWidget){ |
|
| 237 | - if($element->getIdentifier()===""){ |
|
| 236 | + if ($element instanceof BaseWidget) { |
|
| 237 | + if ($element->getIdentifier()==="") { |
|
| 238 | 238 | $element->setIdentifier("tb-item-".$this->identifier."-".$tb->count()); |
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | - if(isset($callback)){ |
|
| 242 | - if(\is_callable($callback)){ |
|
| 241 | + if (isset($callback)) { |
|
| 242 | + if (\is_callable($callback)) { |
|
| 243 | 243 | $callback($element); |
| 244 | 244 | } |
| 245 | 245 | } |
@@ -252,9 +252,9 @@ discard block |
||
| 252 | 252 | * @param callable $callback function($element) |
| 253 | 253 | * @return \Ajax\common\html\HtmlDoubleElement |
| 254 | 254 | */ |
| 255 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
| 256 | - $result=$this->addInToolbar($caption,$callback); |
|
| 257 | - if(isset($icon) && method_exists($result, "addIcon")) |
|
| 255 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
| 256 | + $result=$this->addInToolbar($caption, $callback); |
|
| 257 | + if (isset($icon) && method_exists($result, "addIcon")) |
|
| 258 | 258 | $result->addIcon($icon); |
| 259 | 259 | return $result; |
| 260 | 260 | } |
@@ -264,14 +264,14 @@ discard block |
||
| 264 | 264 | * @param callable $callback function($element) |
| 265 | 265 | * @return \Ajax\common\Widget |
| 266 | 266 | */ |
| 267 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
| 268 | - if(JArray::isAssociative($items)){ |
|
| 269 | - foreach ($items as $icon=>$item){ |
|
| 270 | - $this->addItemInToolbar($item,$icon,$callback); |
|
| 267 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
| 268 | + if (JArray::isAssociative($items)) { |
|
| 269 | + foreach ($items as $icon=>$item) { |
|
| 270 | + $this->addItemInToolbar($item, $icon, $callback); |
|
| 271 | 271 | } |
| 272 | - }else{ |
|
| 273 | - foreach ($items as $item){ |
|
| 274 | - $this->addItemInToolbar($item,null,$callback); |
|
| 272 | + } else { |
|
| 273 | + foreach ($items as $item) { |
|
| 274 | + $this->addItemInToolbar($item, null, $callback); |
|
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | 277 | return $this; |
@@ -283,12 +283,12 @@ discard block |
||
| 283 | 283 | * @param callable $callback function($element) |
| 284 | 284 | * @return \Ajax\common\html\HtmlDoubleElement |
| 285 | 285 | */ |
| 286 | - public function addDropdownInToolbar($value,$items,$callback=NULL){ |
|
| 286 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
| 287 | 287 | $dd=$value; |
| 288 | 288 | if (\is_string($value)) { |
| 289 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
| 289 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
| 290 | 290 | } |
| 291 | - return $this->addInToolbar($dd,$callback); |
|
| 291 | + return $this->addInToolbar($dd, $callback); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -297,9 +297,9 @@ discard block |
||
| 297 | 297 | * @param callable $callback function($element) |
| 298 | 298 | * @return \Ajax\common\html\HtmlDoubleElement |
| 299 | 299 | */ |
| 300 | - public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){ |
|
| 301 | - $bt=new HtmlButton("bt-".$caption,$caption,$cssStyle); |
|
| 302 | - return $this->addInToolbar($bt,$callback); |
|
| 300 | + public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) { |
|
| 301 | + $bt=new HtmlButton("bt-".$caption, $caption, $cssStyle); |
|
| 302 | + return $this->addInToolbar($bt, $callback); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -308,9 +308,9 @@ discard block |
||
| 308 | 308 | * @param callable $callback function($element) |
| 309 | 309 | * @return \Ajax\common\html\HtmlDoubleElement |
| 310 | 310 | */ |
| 311 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
| 312 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
| 313 | - return $this->addInToolbar($bts,$callback); |
|
| 311 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
| 312 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
| 313 | + return $this->addInToolbar($bts, $callback); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -320,15 +320,15 @@ discard block |
||
| 320 | 320 | * @param boolean $labeled |
| 321 | 321 | * @return \Ajax\common\html\HtmlDoubleElement |
| 322 | 322 | */ |
| 323 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
| 324 | - $bt=new HtmlButton("",$caption); |
|
| 325 | - $bt->addIcon($icon,$before,$labeled); |
|
| 323 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
| 324 | + $bt=new HtmlButton("", $caption); |
|
| 325 | + $bt->addIcon($icon, $before, $labeled); |
|
| 326 | 326 | return $this->addInToolbar($bt); |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
| 330 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
| 331 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters); |
|
| 329 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
| 330 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
| 331 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters); |
|
| 332 | 332 | return $this->addInToolbar($button); |
| 333 | 333 | } |
| 334 | 334 | |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model |
| 359 | 359 | * @return \Ajax\common\Widget |
| 360 | 360 | */ |
| 361 | - public function setDefaultValueFunction($defaultValueFunction){ |
|
| 361 | + public function setDefaultValueFunction($defaultValueFunction) { |
|
| 362 | 362 | $this->_instanceViewer->setDefaultValueFunction($defaultValueFunction); |
| 363 | 363 | return $this; |
| 364 | 364 | } |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | /** |
| 367 | 367 | * @return callable |
| 368 | 368 | */ |
| 369 | - public function getDefaultValueFunction(){ |
|
| 369 | + public function getDefaultValueFunction() { |
|
| 370 | 370 | return $this->_instanceViewer->getDefaultValueFunction(); |
| 371 | 371 | } |
| 372 | 372 | |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | * @param string|boolean $disable |
| 375 | 375 | * @return string |
| 376 | 376 | */ |
| 377 | - public function jsDisabled($disable=true){ |
|
| 377 | + public function jsDisabled($disable=true) { |
|
| 378 | 378 | return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
| 379 | 379 | } |
| 380 | 380 | |
@@ -383,12 +383,12 @@ discard block |
||
| 383 | 383 | * @param callable $callback function($element) |
| 384 | 384 | * @return \Ajax\common\html\HtmlDoubleElement |
| 385 | 385 | */ |
| 386 | - public function addEditButtonInToolbar($caption,$callback=NULL){ |
|
| 387 | - $bt=new HtmlButton($this->identifier."-editBtn",$caption); |
|
| 386 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
| 387 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
| 388 | 388 | $bt->setToggle(); |
| 389 | 389 | $bt->setActive($this->_edition); |
| 390 | 390 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
| 391 | - return $this->addInToolbar($bt,$callback); |
|
| 391 | + return $this->addInToolbar($bt, $callback); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | public function setToolbar(HtmlMenu $_toolbar) { |
@@ -402,34 +402,34 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | public function getForm() { |
| 405 | - if(!isset($this->_form)){ |
|
| 405 | + if (!isset($this->_form)) { |
|
| 406 | 406 | $this->_form=new HtmlForm("frm-".$this->identifier); |
| 407 | 407 | $this->setEdition(true); |
| 408 | 408 | } |
| 409 | 409 | return $this->_form; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - public function run(JsUtils $js){ |
|
| 412 | + public function run(JsUtils $js) { |
|
| 413 | 413 | parent::run($js); |
| 414 | - if(isset($this->_form)){ |
|
| 414 | + if (isset($this->_form)) { |
|
| 415 | 415 | $this->runForm($js); |
| 416 | 416 | } |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - protected function runForm(JsUtils $js){ |
|
| 419 | + protected function runForm(JsUtils $js) { |
|
| 420 | 420 | $fields=$this->getContentInstances(HtmlFormField::class); |
| 421 | - foreach ($fields as $field){ |
|
| 421 | + foreach ($fields as $field) { |
|
| 422 | 422 | $this->_form->addField($field); |
| 423 | 423 | } |
| 424 | 424 | return $this->_form->run($js); |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - protected function _compileForm(){ |
|
| 428 | - if(isset($this->_form)){ |
|
| 427 | + protected function _compileForm() { |
|
| 428 | + if (isset($this->_form)) { |
|
| 429 | 429 | $noValidate=""; |
| 430 | - if(\sizeof($this->_form->getValidationParams())>0) |
|
| 430 | + if (\sizeof($this->_form->getValidationParams())>0) |
|
| 431 | 431 | $noValidate="novalidate"; |
| 432 | - $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>"); |
|
| 432 | + $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>"); |
|
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | |
@@ -444,32 +444,32 @@ discard block |
||
| 444 | 444 | return $this; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - public function moveFieldTo($from,$to){ |
|
| 447 | + public function moveFieldTo($from, $to) { |
|
| 448 | 448 | return $this->_instanceViewer->moveFieldTo($from, $to); |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | - public function swapFields($index1,$index2){ |
|
| 451 | + public function swapFields($index1, $index2) { |
|
| 452 | 452 | $index1=$this->_getIndex($index1); |
| 453 | 453 | $index2=$this->_getIndex($index2); |
| 454 | 454 | return $this->_instanceViewer->swapFields($index1, $index2); |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - public function removeField($index){ |
|
| 457 | + public function removeField($index) { |
|
| 458 | 458 | $index=$this->_getIndex($index); |
| 459 | 459 | $this->_instanceViewer->removeField($index); |
| 460 | 460 | return $this; |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - public function asModal($header=null){ |
|
| 464 | - $modal=new HtmlModal("modal-".$this->identifier,$header); |
|
| 463 | + public function asModal($header=null) { |
|
| 464 | + $modal=new HtmlModal("modal-".$this->identifier, $header); |
|
| 465 | 465 | $modal->setContent($this); |
| 466 | - if(isset($this->_form)){ |
|
| 466 | + if (isset($this->_form)) { |
|
| 467 | 467 | $this->_form->onSuccess($modal->jsHide()); |
| 468 | 468 | } |
| 469 | 469 | return $modal; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | public function addToProperty($name, $value, $separator=" ") { |
| 473 | - return $this->getHtmlComponent()->addToProperty($name,$value,$separator); |
|
| 473 | + return $this->getHtmlComponent()->addToProperty($name, $value, $separator); |
|
| 474 | 474 | } |
| 475 | 475 | } |
@@ -17,10 +17,10 @@ discard block |
||
| 17 | 17 | protected $ajaxLoader="<div class=\"ui active centered inline text loader\">Loading</div>"; |
| 18 | 18 | |
| 19 | 19 | abstract public function getUrl($url); |
| 20 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
| 20 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
| 21 | 21 | |
| 22 | - protected function _ajax($method,$url,$responseElement="",$parameters=[]) { |
|
| 23 | - if(isset($this->params["ajax"])){ |
|
| 22 | + protected function _ajax($method, $url, $responseElement="", $parameters=[]) { |
|
| 23 | + if (isset($this->params["ajax"])) { |
|
| 24 | 24 | extract($this->params["ajax"]); |
| 25 | 25 | } |
| 26 | 26 | extract($parameters); |
@@ -30,109 +30,109 @@ discard block |
||
| 30 | 30 | $originalSelector=$responseElement; |
| 31 | 31 | $responseElement=$this->_getResponseElement($responseElement); |
| 32 | 32 | $retour.="var self=this;\n"; |
| 33 | - if($hasLoader===true && JString::isNotNull($responseElement)){ |
|
| 34 | - $this->addLoading($retour, $responseElement,$ajaxLoader); |
|
| 35 | - }elseif($hasLoader==="internal"){ |
|
| 33 | + if ($hasLoader===true && JString::isNotNull($responseElement)) { |
|
| 34 | + $this->addLoading($retour, $responseElement, $ajaxLoader); |
|
| 35 | + }elseif ($hasLoader==="internal") { |
|
| 36 | 36 | $retour.="\n$(this).addClass('loading');"; |
| 37 | 37 | } |
| 38 | - $ajaxParameters=["url"=>"url","method"=>"'".\strtoupper($method)."'"]; |
|
| 38 | + $ajaxParameters=["url"=>"url", "method"=>"'".\strtoupper($method)."'"]; |
|
| 39 | 39 | |
| 40 | - $ajaxParameters["async"]=($async?"true":"false"); |
|
| 40 | + $ajaxParameters["async"]=($async ? "true" : "false"); |
|
| 41 | 41 | |
| 42 | - if(isset($params)){ |
|
| 42 | + if (isset($params)) { |
|
| 43 | 43 | $ajaxParameters["data"]=self::_correctParams($params); |
| 44 | 44 | } |
| 45 | - if(isset($headers)){ |
|
| 45 | + if (isset($headers)) { |
|
| 46 | 46 | $ajaxParameters["headers"]=$headers; |
| 47 | 47 | } |
| 48 | 48 | $this->createAjaxParameters($ajaxParameters, $parameters); |
| 49 | 49 | $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n"; |
| 50 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback,$hasLoader,($historize?$originalSelector:null))."});\n"; |
|
| 51 | - $retour=$this->_addJsCondition($jsCondition,$retour); |
|
| 50 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null))."});\n"; |
|
| 51 | + $retour=$this->_addJsCondition($jsCondition, $retour); |
|
| 52 | 52 | if ($immediatly) |
| 53 | 53 | $this->jquery_code_for_compile[]=$retour; |
| 54 | 54 | return $retour; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - protected function createAjaxParameters(&$original,$parameters){ |
|
| 58 | - $validParameters=["dataType"=>"'%value%'","beforeSend"=>"function(jqXHR,settings){%value%}","complete"=>"function(jqXHR){%value%}"]; |
|
| 59 | - foreach ($validParameters as $param=>$mask){ |
|
| 60 | - if(isset($parameters[$param])){ |
|
| 57 | + protected function createAjaxParameters(&$original, $parameters) { |
|
| 58 | + $validParameters=["dataType"=>"'%value%'", "beforeSend"=>"function(jqXHR,settings){%value%}", "complete"=>"function(jqXHR){%value%}"]; |
|
| 59 | + foreach ($validParameters as $param=>$mask) { |
|
| 60 | + if (isset($parameters[$param])) { |
|
| 61 | 61 | $original[$param]=\str_replace("%value%", $parameters[$param], $mask); |
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - protected function implodeAjaxParameters($ajaxParameters){ |
|
| 67 | - $s = ''; foreach ($ajaxParameters as $k=>$v) { if ($s !== '') { $s .= ','; } $s .= "'{$k}':{$v}"; } |
|
| 66 | + protected function implodeAjaxParameters($ajaxParameters) { |
|
| 67 | + $s=''; foreach ($ajaxParameters as $k=>$v) { if ($s!=='') { $s.=','; } $s.="'{$k}':{$v}"; } |
|
| 68 | 68 | return $s; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - protected function _addJsCondition($jsCondition,$jsSource){ |
|
| 72 | - if(isset($jsCondition)){ |
|
| 71 | + protected function _addJsCondition($jsCondition, $jsSource) { |
|
| 72 | + if (isset($jsCondition)) { |
|
| 73 | 73 | return "if(".$jsCondition."){\n".$jsSource."\n}"; |
| 74 | 74 | } |
| 75 | 75 | return $jsSource; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
| 79 | - protected function _getAjaxUrl($url,$attr){ |
|
| 79 | + protected function _getAjaxUrl($url, $attr) { |
|
| 80 | 80 | $url=$this->_correctAjaxUrl($url); |
| 81 | 81 | $retour="url='".$url."';"; |
| 82 | 82 | $slash="/"; |
| 83 | - if(JString::endswith($url, "/")===true){ |
|
| 83 | + if (JString::endswith($url, "/")===true) { |
|
| 84 | 84 | $slash=""; |
| 85 | 85 | } |
| 86 | - if(JString::isNotNull($attr)){ |
|
| 87 | - if ($attr==="value"){ |
|
| 86 | + if (JString::isNotNull($attr)) { |
|
| 87 | + if ($attr==="value") { |
|
| 88 | 88 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
| 89 | - }elseif ($attr==="html"){ |
|
| 89 | + }elseif ($attr==="html") { |
|
| 90 | 90 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
| 91 | - }elseif(\substr($attr, 0,3)==="js:"){ |
|
| 91 | + }elseif (\substr($attr, 0, 3)==="js:") { |
|
| 92 | 92 | $retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n"; |
| 93 | - }elseif($attr!==null && $attr!=="") |
|
| 93 | + }elseif ($attr!==null && $attr!=="") |
|
| 94 | 94 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
| 95 | 95 | } |
| 96 | 96 | return $retour; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - protected function onPopstate(){ |
|
| 99 | + protected function onPopstate() { |
|
| 100 | 100 | return "window.onpopstate = function(e){if(e.state){var target=e.state.jqueryDone;$(e.state.selector)[target](e.state.html);}};"; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - protected function autoActiveLinks($previousURL="window.location.href"){ |
|
| 104 | - $result= "\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}"; |
|
| 103 | + protected function autoActiveLinks($previousURL="window.location.href") { |
|
| 104 | + $result="\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}"; |
|
| 105 | 105 | $result.="\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;"; |
| 106 | 106 | return $result; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback,$hasLoader=false,$history=null){ |
|
| 110 | - $retour="";$call=null; |
|
| 109 | + protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader=false, $history=null) { |
|
| 110 | + $retour=""; $call=null; |
|
| 111 | 111 | if (JString::isNotNull($responseElement)) { |
| 112 | - if(isset($ajaxTransition)){ |
|
| 112 | + if (isset($ajaxTransition)) { |
|
| 113 | 113 | $call=$this->setAjaxDataCall($ajaxTransition); |
| 114 | - }elseif(isset($this->ajaxTransition)){ |
|
| 114 | + }elseif (isset($this->ajaxTransition)) { |
|
| 115 | 115 | $call=$this->ajaxTransition; |
| 116 | 116 | } |
| 117 | - if(\is_callable($call)) |
|
| 118 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
| 117 | + if (\is_callable($call)) |
|
| 118 | + $retour="\t".$call($responseElement, $jqueryDone).";\n"; |
|
| 119 | 119 | else |
| 120 | 120 | $retour="\t{$responseElement}.{$jqueryDone}( data );\n"; |
| 121 | 121 | } |
| 122 | - if(isset($history)){ |
|
| 123 | - if($this->params["autoActiveLinks"]){ |
|
| 122 | + if (isset($history)) { |
|
| 123 | + if ($this->params["autoActiveLinks"]) { |
|
| 124 | 124 | $retour.=$this->autoActiveLinks("url"); |
| 125 | 125 | } |
| 126 | 126 | $retour.="\nwindow.history.pushState({'html':data,'selector':".Javascript::prep_value($history).",'jqueryDone':'{$jqueryDone}'},'', url);"; |
| 127 | 127 | } |
| 128 | - if($hasLoader==="internal"){ |
|
| 128 | + if ($hasLoader==="internal") { |
|
| 129 | 129 | $retour.="\n$(self).removeClass('loading');"; |
| 130 | 130 | } |
| 131 | 131 | $retour.="\t".$jsCallback."\n"; |
| 132 | 132 | return $retour; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - protected function _getResponseElement($responseElement){ |
|
| 135 | + protected function _getResponseElement($responseElement) { |
|
| 136 | 136 | if (JString::isNotNull($responseElement)) { |
| 137 | 137 | $responseElement=Javascript::prep_jquery_selector($responseElement); |
| 138 | 138 | } |
@@ -142,33 +142,33 @@ discard block |
||
| 142 | 142 | protected function _correctAjaxUrl($url) { |
| 143 | 143 | if ($url!=="/" && JString::endsWith($url, "/")===true) |
| 144 | 144 | $url=substr($url, 0, strlen($url)-1); |
| 145 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
| 145 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
| 146 | 146 | $url=$this->getUrl($url); |
| 147 | 147 | } |
| 148 | 148 | return $url; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - public static function _correctParams($params){ |
|
| 152 | - if(JString::isNull($params)){ |
|
| 151 | + public static function _correctParams($params) { |
|
| 152 | + if (JString::isNull($params)) { |
|
| 153 | 153 | return ""; |
| 154 | 154 | } |
| 155 | - if(\preg_match("@^\{.*?\}$@", $params)){ |
|
| 155 | + if (\preg_match("@^\{.*?\}$@", $params)) { |
|
| 156 | 156 | return '$.param('.$params.')'; |
| 157 | 157 | } |
| 158 | 158 | return $params; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - public static function _implodeParams($parameters){ |
|
| 161 | + public static function _implodeParams($parameters) { |
|
| 162 | 162 | $allParameters=[]; |
| 163 | - foreach ($parameters as $params){ |
|
| 164 | - if(isset($params)) |
|
| 163 | + foreach ($parameters as $params) { |
|
| 164 | + if (isset($params)) |
|
| 165 | 165 | $allParameters[]=self::_correctParams($params); |
| 166 | 166 | } |
| 167 | 167 | return \implode("+'&'+", $allParameters); |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - protected function addLoading(&$retour, $responseElement,$ajaxLoader=null) { |
|
| 171 | - if(!isset($ajaxLoader)){ |
|
| 170 | + protected function addLoading(&$retour, $responseElement, $ajaxLoader=null) { |
|
| 171 | + if (!isset($ajaxLoader)) { |
|
| 172 | 172 | $ajaxLoader=$this->ajaxLoader; |
| 173 | 173 | } |
| 174 | 174 | $loading_notifier='<div class="ajax-loader">'.$ajaxLoader.'</div>'; |
@@ -176,19 +176,19 @@ discard block |
||
| 176 | 176 | $retour.="\t\t{$responseElement}.prepend('{$loading_notifier}');\n"; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - protected function setAjaxDataCall($params){ |
|
| 179 | + protected function setAjaxDataCall($params) { |
|
| 180 | 180 | $result=null; |
| 181 | - if(!\is_callable($params)){ |
|
| 182 | - $result=function ($responseElement,$jqueryDone="html") use($params){ |
|
| 183 | - return AjaxTransition::{$params}($responseElement,$jqueryDone); |
|
| 181 | + if (!\is_callable($params)) { |
|
| 182 | + $result=function($responseElement, $jqueryDone="html") use($params){ |
|
| 183 | + return AjaxTransition::{$params}($responseElement, $jqueryDone); |
|
| 184 | 184 | }; |
| 185 | 185 | } |
| 186 | 186 | return $result; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - protected function setDefaultParameters(&$parameters,$default){ |
|
| 190 | - foreach ($default as $k=>$v){ |
|
| 191 | - if(!isset($parameters[$k])) |
|
| 189 | + protected function setDefaultParameters(&$parameters, $default) { |
|
| 190 | + foreach ($default as $k=>$v) { |
|
| 191 | + if (!isset($parameters[$k])) |
|
| 192 | 192 | $parameters[$k]=$v; |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | * @param string $url The url of the request |
| 203 | 203 | * @param string $responseElement selector of the HTML element displaying the answer |
| 204 | 204 | */ |
| 205 | - private function _get($url, $responseElement="",$parameters=[]) { |
|
| 206 | - return $this->_ajax("get", $url,$responseElement,$parameters); |
|
| 205 | + private function _get($url, $responseElement="", $parameters=[]) { |
|
| 206 | + return $this->_ajax("get", $url, $responseElement, $parameters); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | * @param string $responseElement selector of the HTML element displaying the answer |
| 213 | 213 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
| 214 | 214 | */ |
| 215 | - public function get($url, $responseElement="",$parameters=[]) { |
|
| 215 | + public function get($url, $responseElement="", $parameters=[]) { |
|
| 216 | 216 | $parameters["immediatly"]=true; |
| 217 | - return $this->_get($url,$responseElement,$parameters); |
|
| 217 | + return $this->_get($url, $responseElement, $parameters); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | * @param string $responseElement selector of the HTML element displaying the answer |
| 225 | 225 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
| 226 | 226 | */ |
| 227 | - public function ajax($method,$url, $responseElement="", $parameters=[]) { |
|
| 227 | + public function ajax($method, $url, $responseElement="", $parameters=[]) { |
|
| 228 | 228 | $parameters["immediatly"]=true; |
| 229 | - return $this->_ajax($method,$url,$responseElement,$parameters); |
|
| 229 | + return $this->_ajax($method, $url, $responseElement, $parameters); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -236,9 +236,9 @@ discard block |
||
| 236 | 236 | * @param string $responseElement selector of the HTML element displaying the answer |
| 237 | 237 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
| 238 | 238 | */ |
| 239 | - public function ajaxDeferred($method,$url, $responseElement="", $parameters=[]) { |
|
| 239 | + public function ajaxDeferred($method, $url, $responseElement="", $parameters=[]) { |
|
| 240 | 240 | $parameters["immediatly"]=false; |
| 241 | - return $this->_ajax($method,$url,$responseElement,$parameters); |
|
| 241 | + return $this->_ajax($method, $url, $responseElement, $parameters); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -247,15 +247,15 @@ discard block |
||
| 247 | 247 | * @param string $method Method used |
| 248 | 248 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false) |
| 249 | 249 | */ |
| 250 | - private function _json($url, $method="get",$parameters=[]) { |
|
| 251 | - $parameters=\array_merge($parameters,["hasLoader"=>false]); |
|
| 250 | + private function _json($url, $method="get", $parameters=[]) { |
|
| 251 | + $parameters=\array_merge($parameters, ["hasLoader"=>false]); |
|
| 252 | 252 | $jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
| 253 | 253 | $context=isset($parameters['context']) ? $parameters['context'] : "document"; |
| 254 | 254 | $retour="\tdata=($.isPlainObject(data))?data:JSON.parse(data);\t".$jsCallback.";\n\tfor(var key in data){" |
| 255 | 255 | ."if($('#'+key,".$context.").length){ if($('#'+key,".$context.").is('[value]')) { $('#'+key,".$context.").val(data[key]);} else { $('#'+key,".$context.").html(data[key]); }}};\n"; |
| 256 | 256 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 257 | 257 | $parameters["jsCallback"]=$retour; |
| 258 | - return $this->_ajax($method, $url,null,$parameters); |
|
| 258 | + return $this->_ajax($method, $url, null, $parameters); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false) |
| 266 | 266 | */ |
| 267 | 267 | public function json($url, $method="get", $parameters=[]) { |
| 268 | - return $this->_json($url,$method,$parameters); |
|
| 268 | + return $this->_json($url, $method, $parameters); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -276,9 +276,9 @@ discard block |
||
| 276 | 276 | * @param string $method default get |
| 277 | 277 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
| 278 | 278 | */ |
| 279 | - public function jsonOn($event,$element, $url,$method="get",$parameters=array()) { |
|
| 280 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]); |
|
| 281 | - return $this->_add_event($element, $this->jsonDeferred($url,$method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
| 279 | + public function jsonOn($event, $element, $url, $method="get", $parameters=array()) { |
|
| 280 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]); |
|
| 281 | + return $this->_add_event($element, $this->jsonDeferred($url, $method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | */ |
| 290 | 290 | public function jsonDeferred($url, $method="get", $parameters=[]) { |
| 291 | 291 | $parameters["immediatly"]=false; |
| 292 | - return $this->_json($url,$method,$parameters); |
|
| 292 | + return $this->_json($url, $method, $parameters); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -300,27 +300,27 @@ discard block |
||
| 300 | 300 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json") |
| 301 | 301 | */ |
| 302 | 302 | private function _jsonArray($maskSelector, $url, $method="get", $parameters=[]) { |
| 303 | - $parameters=\array_merge($parameters,["hasLoader"=>false]); |
|
| 303 | + $parameters=\array_merge($parameters, ["hasLoader"=>false]); |
|
| 304 | 304 | $rowClass=isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json"; |
| 305 | 305 | $jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
| 306 | 306 | $context=isset($parameters['context']) ? $parameters['context'] : null; |
| 307 | - if($context===null){ |
|
| 307 | + if ($context===null) { |
|
| 308 | 308 | $parent="$('".$maskSelector."').parent()"; |
| 309 | - $newElm = "$('#'+newId)"; |
|
| 310 | - }else{ |
|
| 309 | + $newElm="$('#'+newId)"; |
|
| 310 | + } else { |
|
| 311 | 311 | $parent=$context; |
| 312 | - $newElm = $context.".find('#'+newId)"; |
|
| 312 | + $newElm=$context.".find('#'+newId)"; |
|
| 313 | 313 | } |
| 314 | 314 | $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
| 315 | 315 | $retour=$parent.".find('.{$rowClass}').remove();"; |
| 316 | 316 | $retour.="\tdata=($.isPlainObject(data)||$.isArray(data))?data:JSON.parse(data);\n$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone(); |
| 317 | 317 | newElm.attr('id',newId);\n;newElm.addClass('{$rowClass}').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n"; |
| 318 | - $retour.= $appendTo; |
|
| 318 | + $retour.=$appendTo; |
|
| 319 | 319 | $retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('__'+key+'__')>-1){\n"."\t\t\t\tcontent=$(html.split('__'+key+'__').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n"; |
| 320 | 320 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 321 | 321 | $retour.="\t".$jsCallback; |
| 322 | 322 | $parameters["jsCallback"]=$retour; |
| 323 | - return $this->_ajax($method, $url,null,$parameters); |
|
| 323 | + return $this->_ajax($method, $url, null, $parameters); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json") |
| 332 | 332 | */ |
| 333 | 333 | public function jsonArray($maskSelector, $url, $method="get", $parameters=[]) { |
| 334 | - return $this->_jsonArray($maskSelector, $url,$method,$parameters); |
|
| 334 | + return $this->_jsonArray($maskSelector, $url, $method, $parameters); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -354,9 +354,9 @@ discard block |
||
| 354 | 354 | * @param string $method Method used, default : get |
| 355 | 355 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true) |
| 356 | 356 | */ |
| 357 | - public function jsonArrayOn($event,$element,$maskSelector, $url,$method="get",$parameters=array()) { |
|
| 358 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]); |
|
| 359 | - return $this->_add_event($element, $this->jsonArrayDeferred($maskSelector,$url,$method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
| 357 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $method="get", $parameters=array()) { |
|
| 358 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]); |
|
| 359 | + return $this->_add_event($element, $this->jsonArrayDeferred($maskSelector, $url, $method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | */ |
| 369 | 369 | public function getDeferred($url, $responseElement="", $parameters=[]) { |
| 370 | 370 | $parameters["immediatly"]=false; |
| 371 | - return $this->_get($url, $responseElement,$parameters); |
|
| 371 | + return $this->_get($url, $responseElement, $parameters); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | /** |
@@ -381,8 +381,8 @@ discard block |
||
| 381 | 381 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false) |
| 382 | 382 | */ |
| 383 | 383 | public function getOn($event, $element, $url, $responseElement="", $parameters=array()) { |
| 384 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]); |
|
| 385 | - return $this->_add_event($element, $this->getDeferred($url,$responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
| 384 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]); |
|
| 385 | + return $this->_add_event($element, $this->getDeferred($url, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -395,8 +395,8 @@ discard block |
||
| 395 | 395 | * @param array $parameters default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
| 396 | 396 | */ |
| 397 | 397 | public function ajaxOn($event, $element, $url, $responseElement="", $parameters=array()) { |
| 398 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true,"method"=>"get"]); |
|
| 399 | - return $this->_add_event($element, $this->ajaxDeferred($parameters["method"],$url,$responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
| 398 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true, "method"=>"get"]); |
|
| 399 | + return $this->_add_event($element, $this->ajaxDeferred($parameters["method"], $url, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /** |
@@ -430,15 +430,15 @@ discard block |
||
| 430 | 430 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true) |
| 431 | 431 | * @return $this |
| 432 | 432 | */ |
| 433 | - public function getHref($element,$responseElement="",$parameters=array()){ |
|
| 433 | + public function getHref($element, $responseElement="", $parameters=array()) { |
|
| 434 | 434 | $parameters["attr"]="href"; |
| 435 | - if(JString::isNull($responseElement)){ |
|
| 435 | + if (JString::isNull($responseElement)) { |
|
| 436 | 436 | $responseElement='%$(self).attr("data-target")%'; |
| 437 | 437 | } |
| 438 | - if(!isset($parameters["historize"])){ |
|
| 438 | + if (!isset($parameters["historize"])) { |
|
| 439 | 439 | $parameters["historize"]=true; |
| 440 | 440 | } |
| 441 | - return $this->getOnClick($element, "",$responseElement,$parameters); |
|
| 441 | + return $this->getOnClick($element, "", $responseElement, $parameters); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | /** |
@@ -448,20 +448,20 @@ discard block |
||
| 448 | 448 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
| 449 | 449 | * @return $this |
| 450 | 450 | */ |
| 451 | - public function postHref($element,$responseElement="",$parameters=array()){ |
|
| 451 | + public function postHref($element, $responseElement="", $parameters=array()) { |
|
| 452 | 452 | $parameters["attr"]="href"; |
| 453 | - if(JString::isNull($responseElement)){ |
|
| 453 | + if (JString::isNull($responseElement)) { |
|
| 454 | 454 | $responseElement='%$(this).attr("data-target")%'; |
| 455 | 455 | } |
| 456 | - if(!isset($parameters["historize"])){ |
|
| 456 | + if (!isset($parameters["historize"])) { |
|
| 457 | 457 | $parameters["historize"]=true; |
| 458 | 458 | } |
| 459 | - return $this->postOnClick($element, "","{}",$responseElement,$parameters); |
|
| 459 | + return $this->postOnClick($element, "", "{}", $responseElement, $parameters); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | - private function _post($url, $params="{}",$responseElement="", $parameters=[]) { |
|
| 462 | + private function _post($url, $params="{}", $responseElement="", $parameters=[]) { |
|
| 463 | 463 | $parameters["params"]=$params; |
| 464 | - return $this->_ajax("POST", $url,$responseElement,$parameters); |
|
| 464 | + return $this->_ajax("POST", $url, $responseElement, $parameters); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | /** |
@@ -471,8 +471,8 @@ discard block |
||
| 471 | 471 | * @param string $params JSON parameters |
| 472 | 472 | * @param array $parameters default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
| 473 | 473 | */ |
| 474 | - public function post($url, $params="{}",$responseElement="", $parameters=[]) { |
|
| 475 | - return $this->_post($url, $params,$responseElement, $parameters); |
|
| 474 | + public function post($url, $params="{}", $responseElement="", $parameters=[]) { |
|
| 475 | + return $this->_post($url, $params, $responseElement, $parameters); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | /** |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | * @param string $responseElement selector of the HTML element displaying the answer |
| 484 | 484 | * @param array $parameters default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
| 485 | 485 | */ |
| 486 | - public function postDeferred($url, $params="{}",$responseElement="", $parameters=[]) { |
|
| 486 | + public function postDeferred($url, $params="{}", $responseElement="", $parameters=[]) { |
|
| 487 | 487 | $parameters["immediatly"]=false; |
| 488 | 488 | return $this->_post($url, $params, $responseElement, $parameters); |
| 489 | 489 | } |
@@ -499,8 +499,8 @@ discard block |
||
| 499 | 499 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false) |
| 500 | 500 | */ |
| 501 | 501 | public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
| 502 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]); |
|
| 503 | - return $this->_add_event($element, $this->postDeferred($url, $params, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
| 502 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]); |
|
| 503 | + return $this->_add_event($element, $this->postDeferred($url, $params, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /** |
@@ -517,33 +517,33 @@ discard block |
||
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | private function _postForm($url, $form, $responseElement, $parameters=[]) { |
| 520 | - if(isset($this->params["ajax"])){ |
|
| 520 | + if (isset($this->params["ajax"])) { |
|
| 521 | 521 | extract($this->params["ajax"]); |
| 522 | 522 | } |
| 523 | - $params="{}";$validation=false; |
|
| 523 | + $params="{}"; $validation=false; |
|
| 524 | 524 | \extract($parameters); |
| 525 | - $async=($async)?"true":"false"; |
|
| 525 | + $async=($async) ? "true" : "false"; |
|
| 526 | 526 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 527 | 527 | $retour=$this->_getAjaxUrl($url, $attr); |
| 528 | 528 | $retour.="\n$('#".$form."').trigger('ajaxSubmit');"; |
| 529 | 529 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
| 530 | - if(isset($params)){ |
|
| 530 | + if (isset($params)) { |
|
| 531 | 531 | $retour.="params+='&'+".self::_correctParams($params).";\n"; |
| 532 | 532 | } |
| 533 | 533 | $responseElement=$this->_getResponseElement($responseElement); |
| 534 | 534 | $retour.="var self=this;\n"; |
| 535 | - if($hasLoader===true){ |
|
| 536 | - $this->addLoading($retour, $responseElement,$ajaxLoader); |
|
| 537 | - }elseif($hasLoader==="internal"){ |
|
| 535 | + if ($hasLoader===true) { |
|
| 536 | + $this->addLoading($retour, $responseElement, $ajaxLoader); |
|
| 537 | + }elseif ($hasLoader==="internal") { |
|
| 538 | 538 | $retour.="\n$(this).addClass('loading');"; |
| 539 | 539 | } |
| 540 | - $ajaxParameters=["url"=>"url","method"=>"'POST'","data"=>"params","async"=>$async]; |
|
| 541 | - if(isset($headers)){ |
|
| 540 | + $ajaxParameters=["url"=>"url", "method"=>"'POST'", "data"=>"params", "async"=>$async]; |
|
| 541 | + if (isset($headers)) { |
|
| 542 | 542 | $ajaxParameters["headers"]=$headers; |
| 543 | 543 | } |
| 544 | 544 | $this->createAjaxParameters($ajaxParameters, $parameters); |
| 545 | 545 | $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data ) {\n"; |
| 546 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback,$hasLoader)."});\n"; |
|
| 546 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader)."});\n"; |
|
| 547 | 547 | |
| 548 | 548 | if ($validation) { |
| 549 | 549 | $retour="$('#".$form."').validate({submitHandler: function(form) { |
@@ -593,8 +593,8 @@ discard block |
||
| 593 | 593 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false) |
| 594 | 594 | */ |
| 595 | 595 | public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
| 596 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]); |
|
| 597 | - return $this->_add_event($element, $this->postFormDeferred($url, $form, $responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
| 596 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]); |
|
| 597 | + return $this->_add_event($element, $this->postFormDeferred($url, $form, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | /** |
@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | * @property string identifier |
| 12 | 12 | * @property BaseHtml _self |
| 13 | 13 | */ |
| 14 | -trait BaseHtmlEventsTrait{ |
|
| 14 | +trait BaseHtmlEventsTrait { |
|
| 15 | 15 | |
| 16 | - protected $_events=array (); |
|
| 16 | + protected $_events=array(); |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * @param string $event |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | * @return BaseHtml |
| 24 | 24 | */ |
| 25 | 25 | public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
| 26 | - if ($stopPropagation === true) { |
|
| 27 | - $jsCode=Javascript::$stopPropagation . $jsCode; |
|
| 26 | + if ($stopPropagation===true) { |
|
| 27 | + $jsCode=Javascript::$stopPropagation.$jsCode; |
|
| 28 | 28 | } |
| 29 | - if ($preventDefault === true) { |
|
| 30 | - $jsCode=Javascript::$preventDefault . $jsCode; |
|
| 29 | + if ($preventDefault===true) { |
|
| 30 | + $jsCode=Javascript::$preventDefault.$jsCode; |
|
| 31 | 31 | } |
| 32 | 32 | return $this->_addEvent($event, $jsCode); |
| 33 | 33 | } |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | public function _addEvent($event, $jsCode) { |
| 41 | 41 | if (array_key_exists($event, $this->_events)) { |
| 42 | 42 | if (\is_array($this->_events[$event])) { |
| 43 | - if(array_search($jsCode, $this->_events[$event])===false){ |
|
| 43 | + if (array_search($jsCode, $this->_events[$event])===false) { |
|
| 44 | 44 | $this->_events[$event][]=$jsCode; |
| 45 | 45 | } |
| 46 | 46 | } else { |
| 47 | - $this->_events[$event]=array ($this->_events[$event],$jsCode ); |
|
| 47 | + $this->_events[$event]=array($this->_events[$event], $jsCode); |
|
| 48 | 48 | } |
| 49 | 49 | } else { |
| 50 | 50 | $this->_events[$event]=$jsCode; |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | return $this->onClick($jsCode); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function onCreate($jsCode){ |
|
| 75 | - if(isset($this->_events["_create"])){ |
|
| 74 | + public function onCreate($jsCode) { |
|
| 75 | + if (isset($this->_events["_create"])) { |
|
| 76 | 76 | $this->_events["_create"][]=$jsCode; |
| 77 | - }else{ |
|
| 77 | + } else { |
|
| 78 | 78 | $this->_events["_create"]=[$jsCode]; |
| 79 | 79 | } |
| 80 | 80 | return $this; |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | public function addEventsOnRun(JsUtils $js=NULL) { |
| 84 | 84 | $this->_eventsOnCreate($js); |
| 85 | 85 | if (isset($this->_bsComponent)) { |
| 86 | - foreach ( $this->_events as $event => $jsCode ) { |
|
| 86 | + foreach ($this->_events as $event => $jsCode) { |
|
| 87 | 87 | $code=$jsCode; |
| 88 | 88 | if (\is_array($jsCode)) { |
| 89 | 89 | $code=""; |
| 90 | - foreach ( $jsCode as $jsC ) { |
|
| 90 | + foreach ($jsCode as $jsC) { |
|
| 91 | 91 | if ($jsC instanceof AjaxCall) { |
| 92 | - $code.="\n" . $jsC->compile($js); |
|
| 92 | + $code.="\n".$jsC->compile($js); |
|
| 93 | 93 | } else { |
| 94 | - $code.="\n" . $jsC; |
|
| 94 | + $code.="\n".$jsC; |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | } elseif ($jsCode instanceof AjaxCall) { |
@@ -99,20 +99,20 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | $this->_bsComponent->addEvent($event, $code); |
| 101 | 101 | } |
| 102 | - $this->_events=array (); |
|
| 102 | + $this->_events=array(); |
|
| 103 | 103 | return $this->_bsComponent->getScript(); |
| 104 | 104 | } |
| 105 | 105 | return ""; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - protected function _eventsOnCreate(JsUtils $js=NULL){ |
|
| 109 | - if(isset($this->_events["_create"])){ |
|
| 108 | + protected function _eventsOnCreate(JsUtils $js=NULL) { |
|
| 109 | + if (isset($this->_events["_create"])) { |
|
| 110 | 110 | $create=$this->_events["_create"]; |
| 111 | - if(\is_array($create)){ |
|
| 111 | + if (\is_array($create)) { |
|
| 112 | 112 | $create=\implode("", $create); |
| 113 | 113 | } |
| 114 | - if(isset($js) && $create!=="") |
|
| 115 | - $js->exec($create,true); |
|
| 114 | + if (isset($js) && $create!=="") |
|
| 115 | + $js->exec($create, true); |
|
| 116 | 116 | unset($this->_events["_create"]); |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @return $this |
| 127 | 127 | */ |
| 128 | 128 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
| 129 | - $params=array ("url" => $url,"responseElement" => $responseElement ); |
|
| 129 | + $params=array("url" => $url, "responseElement" => $responseElement); |
|
| 130 | 130 | $params=array_merge($params, $parameters); |
| 131 | 131 | $this->_addEvent($event, new AjaxCall($operation, $params)); |
| 132 | 132 | return $this; |
@@ -169,10 +169,10 @@ discard block |
||
| 169 | 169 | **/ |
| 170 | 170 | public function postOn($event, $url, $params="{}", $responseElement="", $parameters=array()) { |
| 171 | 171 | $allParameters=[]; |
| 172 | - if(isset($parameters["params"])){ |
|
| 172 | + if (isset($parameters["params"])) { |
|
| 173 | 173 | $allParameters[]=JsUtils::_correctParams($parameters["params"]); |
| 174 | 174 | } |
| 175 | - if(isset($params)){ |
|
| 175 | + if (isset($params)) { |
|
| 176 | 176 | $allParameters[]=JsUtils::_correctParams($params); |
| 177 | 177 | } |
| 178 | 178 | $parameters["params"]=\implode("+'&'+", $allParameters); |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | public function jsDoJquery($jqueryCall, $param="") { |
| 222 | - return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . Javascript::prep_value($param) . ");"; |
|
| 222 | + return "$('#".$this->identifier."').".$jqueryCall."(".Javascript::prep_value($param).");"; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | public function executeOnRun($jsCode) { |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | public function jsToggle($value) { |
| 242 | - return $this->jsDoJquery("toggle",$value); |
|
| 242 | + return $this->jsDoJquery("toggle", $value); |
|
| 243 | 243 | } |
| 244 | 244 | /** |
| 245 | 245 | * @return multitype: |