@@ -19,8 +19,9 @@ discard block |
||
| 19 | 19 | * @param mixed $view |
| 20 | 20 | */ |
| 21 | 21 | protected function _compileLibrary(BaseGui $library, &$view = NULL) { |
| 22 | - if (isset($view)) |
|
| 23 | - $library->compileHtml($this, $view); |
|
| 22 | + if (isset($view)) { |
|
| 23 | + $library->compileHtml($this, $view); |
|
| 24 | + } |
|
| 24 | 25 | if ($library->isAutoCompile()) { |
| 25 | 26 | $library->compile(true); |
| 26 | 27 | } |
@@ -39,8 +40,9 @@ discard block |
||
| 39 | 40 | } |
| 40 | 41 | |
| 41 | 42 | protected function minify($input) { |
| 42 | - if (trim($input) === "") |
|
| 43 | - return $input; |
|
| 43 | + if (trim($input) === "") { |
|
| 44 | + return $input; |
|
| 45 | + } |
|
| 44 | 46 | $input = preg_replace(array( |
| 45 | 47 | // Remove comment(s) |
| 46 | 48 | '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
@@ -5,12 +5,12 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | trait JsUtilsInternalTrait { |
| 7 | 7 | |
| 8 | - protected $jquery_code_for_compile = array(); |
|
| 8 | + protected $jquery_code_for_compile=array(); |
|
| 9 | 9 | |
| 10 | - protected $jquery_code_for_compile_at_last = array(); |
|
| 10 | + protected $jquery_code_for_compile_at_last=array(); |
|
| 11 | 11 | |
| 12 | 12 | protected function _addToCompile($jsScript) { |
| 13 | - $this->jquery_code_for_compile[] = $jsScript; |
|
| 13 | + $this->jquery_code_for_compile[]=$jsScript; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @param BaseGui $library |
| 19 | 19 | * @param mixed $view |
| 20 | 20 | */ |
| 21 | - protected function _compileLibrary(BaseGui $library, &$view = NULL) { |
|
| 21 | + protected function _compileLibrary(BaseGui $library, &$view=NULL) { |
|
| 22 | 22 | if (isset($view)) |
| 23 | 23 | $library->compileHtml($this, $view); |
| 24 | 24 | if ($library->isAutoCompile()) { |
@@ -27,21 +27,21 @@ discard block |
||
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | protected function defer($script) { |
| 30 | - $result = "(function(){window.defer=function (method) {if (window.jQuery) method(); else setTimeout(function() { window.defer(method); }, 50);};"; |
|
| 31 | - $result .= "window.defer(function(){" . $script . "})})()"; |
|
| 30 | + $result="(function(){window.defer=function (method) {if (window.jQuery) method(); else setTimeout(function() { window.defer(method); }, 50);};"; |
|
| 31 | + $result.="window.defer(function(){".$script."})})()"; |
|
| 32 | 32 | return $result; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | protected function ready($script) { |
| 36 | - $result = '$(function() {' . "\n"; |
|
| 37 | - $result .= $script . '});'; |
|
| 36 | + $result='$(function() {'."\n"; |
|
| 37 | + $result.=$script.'});'; |
|
| 38 | 38 | return $result; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | protected function minify($input) { |
| 42 | - if (trim($input) === "") |
|
| 42 | + if (trim($input)==="") |
|
| 43 | 43 | return $input; |
| 44 | - $input = preg_replace(array( |
|
| 44 | + $input=preg_replace(array( |
|
| 45 | 45 | // Remove comment(s) |
| 46 | 46 | '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
| 47 | 47 | // Remove white-space(s) outside the string and regex |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | '$1$3', |
| 60 | 60 | '$1.$3' |
| 61 | 61 | ), $input); |
| 62 | - $input = str_replace("}$", "};$", $input); |
|
| 62 | + $input=str_replace("}$", "};$", $input); |
|
| 63 | 63 | return $input; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | * @param string $src |
| 70 | 70 | * @return string |
| 71 | 71 | */ |
| 72 | - protected function _open_script($src = '') { |
|
| 73 | - $str = '<script '; |
|
| 74 | - $str .= ($src == '') ? '>' : ' src="' . $src . '">'; |
|
| 72 | + protected function _open_script($src='') { |
|
| 73 | + $str='<script '; |
|
| 74 | + $str.=($src=='') ? '>' : ' src="'.$src.'">'; |
|
| 75 | 75 | return $str; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param string $extra |
| 82 | 82 | * @return string |
| 83 | 83 | */ |
| 84 | - protected function _close_script($extra = "\n") { |
|
| 84 | + protected function _close_script($extra="\n") { |
|
| 85 | 85 | return "</script>$extra"; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | protected $customRules; |
| 32 | 32 | |
| 33 | - protected $hasCustomRules = false; |
|
| 33 | + protected $hasCustomRules=false; |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | protected $optional; |
| 42 | 42 | |
| 43 | 43 | public function __construct($identifier) { |
| 44 | - $this->identifier = $identifier; |
|
| 45 | - $this->rules = []; |
|
| 44 | + $this->identifier=$identifier; |
|
| 45 | + $this->rules=[]; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public function getIdentifier() { |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function setIdentifier($identifier) { |
| 53 | - $this->identifier = $identifier; |
|
| 53 | + $this->identifier=$identifier; |
|
| 54 | 54 | return $this; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -65,47 +65,47 @@ discard block |
||
| 65 | 65 | * @param string $value |
| 66 | 66 | * @return Rule |
| 67 | 67 | */ |
| 68 | - public function addRule($type, $prompt = NULL, $value = NULL) { |
|
| 68 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
| 69 | 69 | if ($type instanceof Rule) { |
| 70 | - $rule = $type; |
|
| 70 | + $rule=$type; |
|
| 71 | 71 | if ($type instanceof CustomRule) { |
| 72 | - $this->customRules[] = $type; |
|
| 73 | - $this->hasCustomRules = true; |
|
| 72 | + $this->customRules[]=$type; |
|
| 73 | + $this->hasCustomRules=true; |
|
| 74 | 74 | } |
| 75 | 75 | } elseif (\is_array($type)) { |
| 76 | - $value = JArray::getValue($type, "value", 2); |
|
| 77 | - $prompt = JArray::getValue($type, "prompt", 1); |
|
| 78 | - $type = JArray::getValue($type, "type", 0); |
|
| 79 | - $rule = new Rule($type, $prompt, $value); |
|
| 76 | + $value=JArray::getValue($type, "value", 2); |
|
| 77 | + $prompt=JArray::getValue($type, "prompt", 1); |
|
| 78 | + $type=JArray::getValue($type, "type", 0); |
|
| 79 | + $rule=new Rule($type, $prompt, $value); |
|
| 80 | 80 | } else { |
| 81 | - $rule = new Rule($type, $prompt, $value); |
|
| 81 | + $rule=new Rule($type, $prompt, $value); |
|
| 82 | 82 | } |
| 83 | - $this->rules[] = $rule; |
|
| 83 | + $this->rules[]=$rule; |
|
| 84 | 84 | return $rule; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | #[\ReturnTypeWillChange] |
| 88 | 88 | public function jsonSerialize() { |
| 89 | - $result = [ |
|
| 89 | + $result=[ |
|
| 90 | 90 | "identifier" => $this->identifier, |
| 91 | 91 | "rules" => $this->rules |
| 92 | 92 | ]; |
| 93 | 93 | if ($this->optional) { |
| 94 | - $result["optional"] = true; |
|
| 94 | + $result["optional"]=true; |
|
| 95 | 95 | } |
| 96 | 96 | if (isset($this->depends)) { |
| 97 | - $result["depends"] = $this->depends; |
|
| 97 | + $result["depends"]=$this->depends; |
|
| 98 | 98 | } |
| 99 | 99 | return $result; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | public function setDepends($depends) { |
| 103 | - $this->depends = $depends; |
|
| 103 | + $this->depends=$depends; |
|
| 104 | 104 | return $this; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | public function setOptional($optional) { |
| 108 | - $this->optional = $optional; |
|
| 108 | + $this->optional=$optional; |
|
| 109 | 109 | return $this; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -59,10 +59,12 @@ discard block |
||
| 59 | 59 | #[\ReturnTypeWillChange] |
| 60 | 60 | public function jsonSerialize() { |
| 61 | 61 | $result= ["type"=>$this->type]; |
| 62 | - if(isset($this->prompt)) |
|
| 63 | - $result["prompt"]=$this->prompt; |
|
| 64 | - if(isset($this->value)) |
|
| 65 | - $result["value"]=$this->value; |
|
| 62 | + if(isset($this->prompt)) { |
|
| 63 | + $result["prompt"]=$this->prompt; |
|
| 64 | + } |
|
| 65 | + if(isset($this->value)) { |
|
| 66 | + $result["value"]=$this->value; |
|
| 67 | + } |
|
| 66 | 68 | return $result; |
| 67 | 69 | } |
| 68 | 70 | |
@@ -94,8 +96,9 @@ discard block |
||
| 94 | 96 | * @return \Ajax\semantic\components\validation\Rule |
| 95 | 97 | */ |
| 96 | 98 | public static function integer($min=NULL,$max=NULL,$prompt=NULL){ |
| 97 | - if(\is_int($min) && \is_int($max)) |
|
| 98 | - return new Rule("integer[{$min}..{$max}]",$prompt); |
|
| 99 | + if(\is_int($min) && \is_int($max)) { |
|
| 100 | + return new Rule("integer[{$min}..{$max}]",$prompt); |
|
| 101 | + } |
|
| 99 | 102 | return new Rule("integer",$prompt); |
| 100 | 103 | } |
| 101 | 104 | |
@@ -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; |
@@ -58,10 +58,10 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | #[\ReturnTypeWillChange] |
| 60 | 60 | public function jsonSerialize() { |
| 61 | - $result= ["type"=>$this->type]; |
|
| 62 | - if(isset($this->prompt)) |
|
| 61 | + $result=["type"=>$this->type]; |
|
| 62 | + if (isset($this->prompt)) |
|
| 63 | 63 | $result["prompt"]=$this->prompt; |
| 64 | - if(isset($this->value)) |
|
| 64 | + if (isset($this->value)) |
|
| 65 | 65 | $result["value"]=$this->value; |
| 66 | 66 | return $result; |
| 67 | 67 | } |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | * @param string $prompt |
| 73 | 73 | * @return \Ajax\semantic\components\validation\Rule |
| 74 | 74 | */ |
| 75 | - public static function match($name,$prompt=NULL){ |
|
| 76 | - return new Rule("match[".$name."]",$prompt); |
|
| 75 | + public static function match($name, $prompt=NULL){ |
|
| 76 | + return new Rule("match[".$name."]", $prompt); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | * @param string $prompt |
| 83 | 83 | * @return \Ajax\semantic\components\validation\Rule |
| 84 | 84 | */ |
| 85 | - public static function different($name,$prompt=NULL){ |
|
| 86 | - return new Rule("different[".$name."]",$prompt); |
|
| 85 | + public static function different($name, $prompt=NULL) { |
|
| 86 | + return new Rule("different[".$name."]", $prompt); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -93,82 +93,82 @@ discard block |
||
| 93 | 93 | * @param string $prompt |
| 94 | 94 | * @return \Ajax\semantic\components\validation\Rule |
| 95 | 95 | */ |
| 96 | - public static function integer($min=NULL,$max=NULL,$prompt=NULL){ |
|
| 97 | - if(\is_int($min) && \is_int($max)) |
|
| 98 | - return new Rule("integer[{$min}..{$max}]",$prompt); |
|
| 99 | - return new Rule("integer",$prompt); |
|
| 96 | + public static function integer($min=NULL, $max=NULL, $prompt=NULL) { |
|
| 97 | + if (\is_int($min) && \is_int($max)) |
|
| 98 | + return new Rule("integer[{$min}..{$max}]", $prompt); |
|
| 99 | + return new Rule("integer", $prompt); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - public static function decimal($prompt=NULL){ |
|
| 103 | - return new Rule("decimal",$prompt); |
|
| 102 | + public static function decimal($prompt=NULL) { |
|
| 103 | + return new Rule("decimal", $prompt); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - public static function number($prompt=NULL){ |
|
| 107 | - return new Rule("number",$prompt); |
|
| 106 | + public static function number($prompt=NULL) { |
|
| 107 | + return new Rule("number", $prompt); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public static function is($value,$prompt=NULL){ |
|
| 111 | - return new Rule("is[".$value."]",$prompt); |
|
| 110 | + public static function is($value, $prompt=NULL) { |
|
| 111 | + return new Rule("is[".$value."]", $prompt); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - public static function isExactly($value,$prompt=NULL){ |
|
| 115 | - return new Rule("isExactly[".$value."]",$prompt); |
|
| 114 | + public static function isExactly($value, $prompt=NULL) { |
|
| 115 | + return new Rule("isExactly[".$value."]", $prompt); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - public static function not($value,$prompt=NULL){ |
|
| 119 | - return new Rule("not[".$value."]",$prompt); |
|
| 118 | + public static function not($value, $prompt=NULL) { |
|
| 119 | + return new Rule("not[".$value."]", $prompt); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public static function notExactly($value,$prompt=NULL){ |
|
| 123 | - return new Rule("notExactly[".$value."]",$prompt); |
|
| 122 | + public static function notExactly($value, $prompt=NULL) { |
|
| 123 | + return new Rule("notExactly[".$value."]", $prompt); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public static function contains($value,$prompt=NULL){ |
|
| 127 | - return new Rule("contains[".$value."]",$prompt); |
|
| 126 | + public static function contains($value, $prompt=NULL) { |
|
| 127 | + return new Rule("contains[".$value."]", $prompt); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public static function containsExactly($value,$prompt=NULL){ |
|
| 131 | - return new Rule("containsExactly[".$value."]",$prompt); |
|
| 130 | + public static function containsExactly($value, $prompt=NULL) { |
|
| 131 | + return new Rule("containsExactly[".$value."]", $prompt); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - public static function doesntContain($value,$prompt=NULL){ |
|
| 135 | - return new Rule("doesntContain[".$value."]",$prompt); |
|
| 134 | + public static function doesntContain($value, $prompt=NULL) { |
|
| 135 | + return new Rule("doesntContain[".$value."]", $prompt); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - public static function doesntContainExactly($value,$prompt=NULL){ |
|
| 139 | - return new Rule("doesntContainExactly[".$value."]",$prompt); |
|
| 138 | + public static function doesntContainExactly($value, $prompt=NULL) { |
|
| 139 | + return new Rule("doesntContainExactly[".$value."]", $prompt); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - public static function minCount($value,$prompt=NULL){ |
|
| 143 | - return new Rule("minCount[".$value."]",$prompt); |
|
| 142 | + public static function minCount($value, $prompt=NULL) { |
|
| 143 | + return new Rule("minCount[".$value."]", $prompt); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - public static function maxCount($value,$prompt=NULL){ |
|
| 147 | - return new Rule("maxCount[".$value."]",$prompt); |
|
| 146 | + public static function maxCount($value, $prompt=NULL) { |
|
| 147 | + return new Rule("maxCount[".$value."]", $prompt); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - public static function exactCount($value,$prompt=NULL){ |
|
| 151 | - return new Rule("exactCount[".$value."]",$prompt); |
|
| 150 | + public static function exactCount($value, $prompt=NULL) { |
|
| 151 | + return new Rule("exactCount[".$value."]", $prompt); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - public static function email($prompt=NULL){ |
|
| 155 | - return new Rule("email",$prompt); |
|
| 154 | + public static function email($prompt=NULL) { |
|
| 155 | + return new Rule("email", $prompt); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - public static function url($prompt=NULL){ |
|
| 159 | - return new Rule("url",$prompt); |
|
| 158 | + public static function url($prompt=NULL) { |
|
| 159 | + return new Rule("url", $prompt); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - public static function regExp($value,$prompt=NULL){ |
|
| 163 | - return new Rule("regExp",$prompt,$value); |
|
| 162 | + public static function regExp($value, $prompt=NULL) { |
|
| 163 | + return new Rule("regExp", $prompt, $value); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - public static function custom($name,$jsFunction){ |
|
| 167 | - return "$.fn.form.settings.rules.".$name." =".$jsFunction ; |
|
| 166 | + public static function custom($name, $jsFunction) { |
|
| 167 | + return "$.fn.form.settings.rules.".$name." =".$jsFunction; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - public static function ajax(JsUtils $js,$name,$url,$params,$jsCallback,$method="post",$parameters=[]){ |
|
| 171 | - $parameters=\array_merge(["async"=>false,"url"=>$url,"params"=>$params,"hasLoader"=>false,"jsCallback"=>$jsCallback,"dataType"=>"json","stopPropagation"=>false,"preventDefault"=>false,"responseElement"=>null],$parameters); |
|
| 170 | + public static function ajax(JsUtils $js, $name, $url, $params, $jsCallback, $method="post", $parameters=[]) { |
|
| 171 | + $parameters=\array_merge(["async"=>false, "url"=>$url, "params"=>$params, "hasLoader"=>false, "jsCallback"=>$jsCallback, "dataType"=>"json", "stopPropagation"=>false, "preventDefault"=>false, "responseElement"=>null], $parameters); |
|
| 172 | 172 | $ajax=new AjaxCall($method, $parameters); |
| 173 | 173 | return self::custom($name, "function(value,ruleValue){var result=true;".$ajax->compile($js)."return result;}"); |
| 174 | 174 | } |
@@ -3,36 +3,36 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | class Javascript { |
| 5 | 5 | |
| 6 | - public static $preventDefault = "\nif(event && event.preventDefault) event.preventDefault();\n"; |
|
| 6 | + public static $preventDefault="\nif(event && event.preventDefault) event.preventDefault();\n"; |
|
| 7 | 7 | |
| 8 | - public static $stopPropagation = "\nif(event && event.stopPropagation) event.stopPropagation();\n"; |
|
| 8 | + public static $stopPropagation="\nif(event && event.stopPropagation) event.stopPropagation();\n"; |
|
| 9 | 9 | |
| 10 | - public static function draggable($attr = "id") { |
|
| 11 | - return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;dt.setData("text/plain",JSON.stringify({id:$(event.target).attr("id"),data:$(event.target).attr("' . $attr . '")}));'; |
|
| 10 | + public static function draggable($attr="id") { |
|
| 11 | + return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;dt.setData("text/plain",JSON.stringify({id:$(event.target).attr("id"),data:$(event.target).attr("'.$attr.'")}));'; |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public static function dropZone($jqueryDone, $jsCallback = "") { |
|
| 15 | - $done = ($jqueryDone != null) ? '$(event.target).' . $jqueryDone . '($("#"+_data.id));' : ''; |
|
| 16 | - return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;var _data=JSON.parse(dt.getData("text/plain"));' . $done . 'var data=_data.data;' . $jsCallback; |
|
| 14 | + public static function dropZone($jqueryDone, $jsCallback="") { |
|
| 15 | + $done=($jqueryDone!=null) ? '$(event.target).'.$jqueryDone.'($("#"+_data.id));' : ''; |
|
| 16 | + return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;var _data=JSON.parse(dt.getData("text/plain"));'.$done.'var data=_data.data;'.$jsCallback; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public static function fileDropZone($jsCallback = "") { |
|
| 20 | - $done = 'event.target.upload=formData;$(event.target).trigger("upload");'; |
|
| 21 | - return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;var files=dt.files;var formData = new FormData();for (var i = 0; i < files.length; i++) {formData.append("file-"+i,files[i]);}' . $done . $jsCallback; |
|
| 19 | + public static function fileDropZone($jsCallback="") { |
|
| 20 | + $done='event.target.upload=formData;$(event.target).trigger("upload");'; |
|
| 21 | + return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;var files=dt.files;var formData = new FormData();for (var i = 0; i < files.length; i++) {formData.append("file-"+i,files[i]);}'.$done.$jsCallback; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public static function containsCode($expression) { |
| 25 | - if ($expression == null) { |
|
| 25 | + if ($expression==null) { |
|
| 26 | 26 | return false; |
| 27 | 27 | } |
| 28 | - return \strrpos($expression, 'this') !== false || \strrpos($expression, 'event') !== false || \strrpos($expression, 'self') !== false; |
|
| 28 | + return \strrpos($expression, 'this')!==false || \strrpos($expression, 'event')!==false || \strrpos($expression, 'self')!==false; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public static function isFunction($jsCode) { |
| 32 | 32 | return JString::startswith($jsCode, "function"); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public static function fileUploadBehavior($id = '') { |
|
| 35 | + public static function fileUploadBehavior($id='') { |
|
| 36 | 36 | return "$('input:text, .ui.button', '#{$id}').on('click', function (e) {e.preventDefault();\$('input:file', '#{$id}').click();}); |
| 37 | 37 | $('input:file', '#{$id}').on('change', function (e) {if(e.target.files.length){var name = e.target.files[0].name;$('input:text', $(e.target).parent()).val(name);}});"; |
| 38 | 38 | } |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | * @return string |
| 47 | 47 | */ |
| 48 | 48 | public static function prep_element($element) { |
| 49 | - if (self::containsCode($element) === false) { |
|
| 50 | - $element = '"' . addslashes($element ?? '') . '"'; |
|
| 49 | + if (self::containsCode($element)===false) { |
|
| 50 | + $element='"'.addslashes($element ?? '').'"'; |
|
| 51 | 51 | } |
| 52 | 52 | return $element; |
| 53 | 53 | } |
@@ -62,24 +62,24 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public static function prep_value($value) { |
| 64 | 64 | if (\is_array($value)) { |
| 65 | - $value = implode(",", $value); |
|
| 65 | + $value=implode(",", $value); |
|
| 66 | 66 | } |
| 67 | - if (self::containsCode($value) === false) { |
|
| 68 | - $value = \str_replace([ |
|
| 67 | + if (self::containsCode($value)===false) { |
|
| 68 | + $value=\str_replace([ |
|
| 69 | 69 | "\\", |
| 70 | 70 | "\"" |
| 71 | 71 | ], [ |
| 72 | 72 | "\\\\", |
| 73 | 73 | "\\\"" |
| 74 | 74 | ], $value); |
| 75 | - $value = '"' . $value . '"'; |
|
| 75 | + $value='"'.$value.'"'; |
|
| 76 | 76 | } |
| 77 | 77 | return trim($value, "%"); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | public static function prep_jquery_selector($value) { |
| 81 | - if (JString::startswith($value, '$(') === false) { |
|
| 82 | - return '$(' . self::prep_value($value) . ')'; |
|
| 81 | + if (JString::startswith($value, '$(')===false) { |
|
| 82 | + return '$('.self::prep_value($value).')'; |
|
| 83 | 83 | } |
| 84 | 84 | return $value; |
| 85 | 85 | } |
@@ -18,38 +18,38 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | protected $_validation; |
| 20 | 20 | |
| 21 | - public function __construct($identifier, $field, $label = NULL) { |
|
| 21 | + public function __construct($identifier, $field, $label=NULL) { |
|
| 22 | 22 | parent::__construct($identifier, "div", "field"); |
| 23 | - $this->content = array(); |
|
| 24 | - $this->_states = [ |
|
| 23 | + $this->content=array(); |
|
| 24 | + $this->_states=[ |
|
| 25 | 25 | State::ERROR, |
| 26 | 26 | State::DISABLED |
| 27 | 27 | ]; |
| 28 | - if (isset($label) && $label !== "") |
|
| 28 | + if (isset($label) && $label!=="") |
|
| 29 | 29 | $this->setLabel($label); |
| 30 | 30 | $this->setField($field); |
| 31 | - $this->_validation = NULL; |
|
| 31 | + $this->_validation=NULL; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function addPointingLabel($label, $pointing = Direction::NONE) { |
|
| 35 | - $labelO = new HtmlLabel("", $label); |
|
| 34 | + public function addPointingLabel($label, $pointing=Direction::NONE) { |
|
| 35 | + $labelO=new HtmlLabel("", $label); |
|
| 36 | 36 | $labelO->setPointing($pointing); |
| 37 | - $this->addContent($labelO, $pointing === "below" || $pointing === "right"); |
|
| 37 | + $this->addContent($labelO, $pointing==="below" || $pointing==="right"); |
|
| 38 | 38 | return $labelO; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function setLabel($label) { |
| 42 | - $labelO = $label; |
|
| 42 | + $labelO=$label; |
|
| 43 | 43 | if (\is_string($label)) { |
| 44 | - $labelO = new HtmlSemDoubleElement("", "label", ""); |
|
| 44 | + $labelO=new HtmlSemDoubleElement("", "label", ""); |
|
| 45 | 45 | $labelO->setContent($label); |
| 46 | 46 | $labelO->setProperty("for", \str_replace("field-", "", $this->identifier)); |
| 47 | 47 | } |
| 48 | - $this->content["label"] = $labelO; |
|
| 48 | + $this->content["label"]=$labelO; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | public function setField($field) { |
| 52 | - $this->content["field"] = $field; |
|
| 52 | + $this->content["field"]=$field; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | * puts the label before or behind |
| 85 | 85 | */ |
| 86 | 86 | public function swapLabel() { |
| 87 | - $label = $this->getLabel(); |
|
| 87 | + $label=$this->getLabel(); |
|
| 88 | 88 | unset($this->content["label"]); |
| 89 | - $this->content["label"] = $label; |
|
| 89 | + $this->content["label"]=$label; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function setWidth($width) { |
| 99 | 99 | if (\is_int($width)) { |
| 100 | - $width = Wide::getConstants()["W" . $width]; |
|
| 100 | + $width=Wide::getConstants()["W".$width]; |
|
| 101 | 101 | } |
| 102 | 102 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
| 103 | 103 | if (isset($this->_container)) { |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | public function setContainer($_container) { |
| 129 | - $this->_container = $_container; |
|
| 129 | + $this->_container=$_container; |
|
| 130 | 130 | return $this; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -134,13 +134,13 @@ discard block |
||
| 134 | 134 | $this->getDataField()->setProperty("readonly", ""); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - public function addRule($type, $prompt = NULL, $value = NULL) { |
|
| 138 | - $field = $this->getDataField(); |
|
| 137 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
| 138 | + $field=$this->getDataField(); |
|
| 139 | 139 | if (isset($field)) { |
| 140 | - if (! isset($this->_validation)) { |
|
| 141 | - $this->_validation = new FieldValidation($field->getIdentifier()); |
|
| 140 | + if (!isset($this->_validation)) { |
|
| 141 | + $this->_validation=new FieldValidation($field->getIdentifier()); |
|
| 142 | 142 | } |
| 143 | - if ($type === 'empty' || ($type['type'] ?? '') === 'empty') { |
|
| 143 | + if ($type==='empty' || ($type['type'] ?? '')==='empty') { |
|
| 144 | 144 | $this->addToProperty('class', 'required'); |
| 145 | 145 | } |
| 146 | 146 | $this->_validation->addRule($type, $prompt, $value); |
@@ -148,11 +148,11 @@ discard block |
||
| 148 | 148 | return $this; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - public function setOptional($optional = true) { |
|
| 152 | - $field = $this->getDataField(); |
|
| 151 | + public function setOptional($optional=true) { |
|
| 152 | + $field=$this->getDataField(); |
|
| 153 | 153 | if (isset($field)) { |
| 154 | - if (! isset($this->_validation)) { |
|
| 155 | - $this->_validation = new FieldValidation($field->getIdentifier()); |
|
| 154 | + if (!isset($this->_validation)) { |
|
| 155 | + $this->_validation=new FieldValidation($field->getIdentifier()); |
|
| 156 | 156 | } |
| 157 | 157 | $this->_validation->setOptional($optional); |
| 158 | 158 | } |
@@ -166,12 +166,12 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | public function setRules(array $rules) { |
| 169 | - $this->_validation = null; |
|
| 169 | + $this->_validation=null; |
|
| 170 | 170 | return $this->addRules($rules); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - public function addIcon($icon, $direction = Direction::LEFT) { |
|
| 174 | - $field = $this->getField(); |
|
| 173 | + public function addIcon($icon, $direction=Direction::LEFT) { |
|
| 174 | + $field=$this->getField(); |
|
| 175 | 175 | return $field->addIcon($icon, $direction); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -25,8 +25,9 @@ discard block |
||
| 25 | 25 | State::ERROR, |
| 26 | 26 | State::DISABLED |
| 27 | 27 | ]; |
| 28 | - if (isset($label) && $label !== "") |
|
| 29 | - $this->setLabel($label); |
|
| 28 | + if (isset($label) && $label !== "") { |
|
| 29 | + $this->setLabel($label); |
|
| 30 | + } |
|
| 30 | 31 | $this->setField($field); |
| 31 | 32 | $this->_validation = NULL; |
| 32 | 33 | } |
@@ -58,8 +59,9 @@ discard block |
||
| 58 | 59 | * @return mixed |
| 59 | 60 | */ |
| 60 | 61 | public function getLabel() { |
| 61 | - if (\array_key_exists("label", $this->content)) |
|
| 62 | - return $this->content["label"]; |
|
| 62 | + if (\array_key_exists("label", $this->content)) { |
|
| 63 | + return $this->content["label"]; |
|
| 64 | + } |
|
| 63 | 65 | } |
| 64 | 66 | |
| 65 | 67 | /** |