Passed
Push — master ( d463f7...97a77b )
by Jean-Christophe
02:20
created
Ajax/semantic/components/validation/FieldValidation.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Ajax/semantic/components/validation/Rule.php 2 patches
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -59,10 +59,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
Ajax/service/Javascript.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -3,36 +3,36 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
Ajax/common/Widget.php 2 patches
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 use Ajax\common\html\traits\BaseHooksTrait;
21 21
 
22 22
 abstract class Widget extends HtmlDoubleElement {
23
-	use FieldAsTrait,FormTrait,BaseHooksTrait;
23
+	use FieldAsTrait, FormTrait, BaseHooksTrait;
24 24
 
25 25
 	/**
26 26
 	 *
@@ -66,27 +66,27 @@  discard block
 block discarded – undo
66 66
 
67 67
 	protected $_hasRules;
68 68
 
69
-	public function __construct($identifier, $model, $modelInstance = NULL) {
69
+	public function __construct($identifier, $model, $modelInstance=NULL) {
70 70
 		parent::__construct($identifier);
71
-		$this->_template = "%wrapContentBefore%%content%%wrapContentAfter%";
71
+		$this->_template="%wrapContentBefore%%content%%wrapContentAfter%";
72 72
 		$this->setModel($model);
73 73
 		if (isset($modelInstance)) {
74 74
 			if (\is_object($modelInstance)) {
75
-				$this->_model = \get_class($modelInstance);
75
+				$this->_model=\get_class($modelInstance);
76 76
 			}
77 77
 			$this->show($modelInstance);
78 78
 		}
79
-		$this->_generated = false;
79
+		$this->_generated=false;
80 80
 	}
81 81
 
82 82
 	protected function _init($instanceViewer, $contentKey, $content, $edition) {
83
-		$this->_instanceViewer = $instanceViewer;
84
-		$this->content = [
83
+		$this->_instanceViewer=$instanceViewer;
84
+		$this->content=[
85 85
 			$contentKey => $content
86 86
 		];
87
-		$this->_self = $content;
88
-		$this->_toolbarPosition = PositionInTable::BEFORETABLE;
89
-		$this->_edition = $edition;
87
+		$this->_self=$content;
88
+		$this->_toolbarPosition=PositionInTable::BEFORETABLE;
89
+		$this->_edition=$edition;
90 90
 	}
91 91
 
92 92
 	/**
@@ -95,16 +95,16 @@  discard block
 block discarded – undo
95 95
 	 * @return int|string|boolean
96 96
 	 */
97 97
 	protected function _getIndex($fieldName) {
98
-		$index = $fieldName;
98
+		$index=$fieldName;
99 99
 		if (\is_string($fieldName)) {
100
-			$fields = $this->_instanceViewer->getVisibleProperties();
101
-			$index = \array_search($fieldName, $fields);
100
+			$fields=$this->_instanceViewer->getVisibleProperties();
101
+			$index=\array_search($fieldName, $fields);
102 102
 		}
103 103
 		return $index;
104 104
 	}
105 105
 
106
-	protected function _getFieldIdentifier($prefix, $name = "") {
107
-		return $this->identifier . "-{$prefix}-" . $this->_instanceViewer->getIdentifier();
106
+	protected function _getFieldIdentifier($prefix, $name="") {
107
+		return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier();
108 108
 	}
109 109
 
110 110
 	protected function _getFieldName($index) {
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 		return $this->_instanceViewer->getCaption($index);
116 116
 	}
117 117
 
118
-	abstract protected function _setToolbarPosition($table, $captions = NULL);
118
+	abstract protected function _setToolbarPosition($table, $captions=NULL);
119 119
 
120 120
 	public function show($modelInstance) {
121 121
 		if (\is_array($modelInstance)) {
122
-			$modelInstance = \json_decode(\json_encode($modelInstance), FALSE);
122
+			$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
123 123
 		}
124
-		$this->_modelInstance = $modelInstance;
124
+		$this->_modelInstance=$modelInstance;
125 125
 	}
126 126
 
127 127
 	public function getModel() {
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	}
130 130
 
131 131
 	public function setModel($_model) {
132
-		$this->_model = $_model;
132
+		$this->_model=$_model;
133 133
 		return $this;
134 134
 	}
135 135
 
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 	}
139 139
 
140 140
 	public function setInstanceViewer($_instanceViewer) {
141
-		$this->_instanceViewer = $_instanceViewer;
141
+		$this->_instanceViewer=$_instanceViewer;
142 142
 		return $this;
143 143
 	}
144 144
 
145 145
 	abstract public function getHtmlComponent();
146 146
 
147
-	public function setAttached($value = true) {
147
+	public function setAttached($value=true) {
148 148
 		return $this->getHtmlComponent()->setAttached($value);
149 149
 	}
150 150
 
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	 * @return Widget
160 160
 	 */
161 161
 	public function afterCompile($index, $callback) {
162
-		$index = $this->_getIndex($index);
163
-		if ($index !== false) {
162
+		$index=$this->_getIndex($index);
163
+		if ($index!==false) {
164 164
 			$this->_instanceViewer->afterCompile($index, $callback);
165 165
 		}
166 166
 		return $this;
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		return $this;
186 186
 	}
187 187
 
188
-	public function addField($field, $key = null) {
188
+	public function addField($field, $key=null) {
189 189
 		$this->_instanceViewer->addField($field, $key);
190 190
 		return $this;
191 191
 	}
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 		return $this->_instanceViewer->visiblePropertiesCount();
200 200
 	}
201 201
 
202
-	public function addMessage($attributes = NULL, $fieldName = "message") {
202
+	public function addMessage($attributes=NULL, $fieldName="message") {
203 203
 		$this->_instanceViewer->addField($fieldName);
204
-		$count = $this->_instanceViewer->visiblePropertiesCount();
205
-		return $this->fieldAsMessage($count - 1, $attributes);
204
+		$count=$this->_instanceViewer->visiblePropertiesCount();
205
+		return $this->fieldAsMessage($count-1, $attributes);
206 206
 	}
207 207
 
208 208
 	public function addErrorMessage() {
@@ -211,15 +211,15 @@  discard block
 block discarded – undo
211 211
 		], "message");
212 212
 	}
213 213
 
214
-	public function insertField($index, $field, $key = null) {
215
-		$index = $this->_getIndex($index);
214
+	public function insertField($index, $field, $key=null) {
215
+		$index=$this->_getIndex($index);
216 216
 		$this->_instanceViewer->insertField($index, $field, $key);
217 217
 		return $this;
218 218
 	}
219 219
 
220
-	public function insertInField($index, $field, $key = null) {
221
-		$index = $this->_getIndex($index);
222
-		if ($index !== false) {
220
+	public function insertInField($index, $field, $key=null) {
221
+		$index=$this->_getIndex($index);
222
+		if ($index!==false) {
223 223
 			$this->_instanceViewer->insertInField($index, $field, $key);
224 224
 		}
225 225
 		return $this;
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 	 * @return Widget
236 236
 	 */
237 237
 	public function setValueFunction($index, $callback) {
238
-		$index = $this->_getIndex($index);
239
-		if ($index !== false) {
238
+		$index=$this->_getIndex($index);
239
+		if ($index!==false) {
240 240
 			$this->_instanceViewer->setValueFunction($index, $callback);
241 241
 		}
242 242
 		return $this;
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	 * @return \Ajax\semantic\html\collections\menus\HtmlMenu
253 253
 	 */
254 254
 	public function getToolbar() {
255
-		if (isset($this->_toolbar) === false) {
256
-			$this->_toolbar = new HtmlMenu("toolbar-" . $this->identifier);
255
+		if (isset($this->_toolbar)===false) {
256
+			$this->_toolbar=new HtmlMenu("toolbar-".$this->identifier);
257 257
 		}
258 258
 		return $this->_toolbar;
259 259
 	}
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 	 *        	function to call on $element
267 267
 	 * @return \Ajax\common\html\HtmlDoubleElement
268 268
 	 */
269
-	public function addInToolbar($element, $callback = NULL) {
270
-		$tb = $this->getToolbar();
269
+	public function addInToolbar($element, $callback=NULL) {
270
+		$tb=$this->getToolbar();
271 271
 		if ($element instanceof BaseWidget) {
272
-			if ($element->getIdentifier() === "") {
273
-				$element->setIdentifier("tb-item-" . $this->identifier . "-" . $tb->count());
272
+			if ($element->getIdentifier()==="") {
273
+				$element->setIdentifier("tb-item-".$this->identifier."-".$tb->count());
274 274
 			}
275 275
 		}
276 276
 		if (isset($callback)) {
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 	 *        	function($element)
290 290
 	 * @return \Ajax\common\html\HtmlDoubleElement
291 291
 	 */
292
-	public function addItemInToolbar($caption, $icon = NULL, $callback = NULL) {
293
-		$result = $this->addInToolbar($caption, $callback);
292
+	public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) {
293
+		$result=$this->addInToolbar($caption, $callback);
294 294
 		if (isset($icon) && method_exists($result, "addIcon"))
295 295
 			$result->addIcon($icon);
296 296
 		return $result;
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 	 *        	function($element)
304 304
 	 * @return \Ajax\common\Widget
305 305
 	 */
306
-	public function addItemsInToolbar(array $items, $callback = NULL) {
306
+	public function addItemsInToolbar(array $items, $callback=NULL) {
307 307
 		if (JArray::isAssociative($items)) {
308 308
 			foreach ($items as $icon => $item) {
309 309
 				$this->addItemInToolbar($item, $icon, $callback);
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 	 *        	function($element)
325 325
 	 * @return \Ajax\common\html\HtmlDoubleElement
326 326
 	 */
327
-	public function addDropdownInToolbar($value, $items, $callback = NULL) {
328
-		$dd = $value;
327
+	public function addDropdownInToolbar($value, $items, $callback=NULL) {
328
+		$dd=$value;
329 329
 		if (\is_string($value)) {
330
-			$dd = new HtmlDropdown("dropdown-" . $this->identifier . "-" . $value, $value, $items);
330
+			$dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items);
331 331
 		}
332 332
 		return $this->addInToolbar($dd, $callback);
333 333
 	}
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
 	 *        	function($element)
341 341
 	 * @return \Ajax\common\html\HtmlDoubleElement
342 342
 	 */
343
-	public function addButtonInToolbar($caption, $cssStyle = null, $callback = NULL) {
344
-		$bt = new HtmlButton("bt-" . $caption, $caption, $cssStyle);
343
+	public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) {
344
+		$bt=new HtmlButton("bt-".$caption, $caption, $cssStyle);
345 345
 		return $this->addInToolbar($bt, $callback);
346 346
 	}
347 347
 
@@ -353,8 +353,8 @@  discard block
 block discarded – undo
353 353
 	 *        	function($element)
354 354
 	 * @return \Ajax\common\html\HtmlDoubleElement
355 355
 	 */
356
-	public function addButtonsInToolbar(array $captions, $asIcon = false, $callback = NULL) {
357
-		$bts = new HtmlButtonGroups("", $captions, $asIcon);
356
+	public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) {
357
+		$bts=new HtmlButtonGroups("", $captions, $asIcon);
358 358
 		return $this->addInToolbar($bts, $callback);
359 359
 	}
360 360
 
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
 	 * @param boolean $labeled
367 367
 	 * @return \Ajax\common\html\HtmlDoubleElement
368 368
 	 */
369
-	public function addLabelledIconButtonInToolbar($caption, $icon, $before = true, $labeled = false) {
370
-		$bt = new HtmlButton("", $caption);
369
+	public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) {
370
+		$bt=new HtmlButton("", $caption);
371 371
 		$bt->addIcon($icon, $before, $labeled);
372 372
 		return $this->addInToolbar($bt);
373 373
 	}
374 374
 
375
-	public function addSubmitInToolbar($identifier, $value, $cssStyle = NULL, $url = NULL, $responseElement = NULL, $parameters = NULL) {
376
-		$button = new HtmlButton($identifier, $value, $cssStyle);
375
+	public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) {
376
+		$button=new HtmlButton($identifier, $value, $cssStyle);
377 377
 		$this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters);
378 378
 		return $this->addInToolbar($button);
379 379
 	}
@@ -396,8 +396,8 @@  discard block
 block discarded – undo
396 396
 	 * @param boolean $_edition
397 397
 	 * @return \Ajax\common\Widget
398 398
 	 */
399
-	public function setEdition($_edition = true) {
400
-		$this->_edition = $_edition;
399
+	public function setEdition($_edition=true) {
400
+		$this->_edition=$_edition;
401 401
 		return $this;
402 402
 	}
403 403
 
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
 	 * @param string|boolean $disable
427 427
 	 * @return string
428 428
 	 */
429
-	public function jsDisabled($disable = true) {
430
-		return "$('#" . $this->identifier . " .ui.input,#" . $this->identifier . " .ui.dropdown,#" . $this->identifier . " .ui.checkbox').toggleClass('disabled'," . $disable . ");";
429
+	public function jsDisabled($disable=true) {
430
+		return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");";
431 431
 	}
432 432
 
433 433
 	/**
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 	 *        	function($element)
438 438
 	 * @return \Ajax\common\html\HtmlDoubleElement
439 439
 	 */
440
-	public function addEditButtonInToolbar($caption, $callback = NULL) {
441
-		$bt = new HtmlButton($this->identifier . "-editBtn", $caption);
440
+	public function addEditButtonInToolbar($caption, $callback=NULL) {
441
+		$bt=new HtmlButton($this->identifier."-editBtn", $caption);
442 442
 		$bt->setToggle();
443 443
 		$bt->setActive($this->_edition);
444 444
 		$bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')")));
@@ -446,18 +446,18 @@  discard block
 block discarded – undo
446 446
 	}
447 447
 
448 448
 	public function setToolbar(HtmlMenu $_toolbar) {
449
-		$this->_toolbar = $_toolbar;
449
+		$this->_toolbar=$_toolbar;
450 450
 		return $this;
451 451
 	}
452 452
 
453 453
 	public function setToolbarPosition($_toolbarPosition) {
454
-		$this->_toolbarPosition = $_toolbarPosition;
454
+		$this->_toolbarPosition=$_toolbarPosition;
455 455
 		return $this;
456 456
 	}
457 457
 
458 458
 	public function getForm() {
459
-		if (! isset($this->_form)) {
460
-			$this->_form = new HtmlForm("frm-" . $this->identifier);
459
+		if (!isset($this->_form)) {
460
+			$this->_form=new HtmlForm("frm-".$this->identifier);
461 461
 			$this->setEdition(true);
462 462
 		}
463 463
 		return $this->_form;
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	}
472 472
 
473 473
 	protected function runForm(JsUtils $js) {
474
-		$fields = $this->getContentInstances(HtmlFormField::class);
474
+		$fields=$this->getContentInstances(HtmlFormField::class);
475 475
 		foreach ($fields as $field) {
476 476
 			$this->_form->addField($field);
477 477
 		}
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
 
481 481
 	protected function _compileForm() {
482 482
 		if (isset($this->_form)) {
483
-			$noValidate = "";
484
-			if (\sizeof($this->_form->getValidationParams()) > 0)
485
-				$noValidate = "novalidate";
486
-			$this->wrapContent("<form class='" . $this->_form->getProperty('class') . "' id='frm-" . $this->identifier . "' name='frm-" . $this->identifier . "' " . $noValidate . ">", "</form>");
483
+			$noValidate="";
484
+			if (\sizeof($this->_form->getValidationParams())>0)
485
+				$noValidate="novalidate";
486
+			$this->wrapContent("<form class='".$this->_form->getProperty('class')."' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>");
487 487
 		}
488 488
 	}
489 489
 
@@ -505,21 +505,21 @@  discard block
 block discarded – undo
505 505
 	}
506 506
 
507 507
 	public function swapFields($index1, $index2) {
508
-		$index1 = $this->_getIndex($index1);
509
-		$index2 = $this->_getIndex($index2);
508
+		$index1=$this->_getIndex($index1);
509
+		$index2=$this->_getIndex($index2);
510 510
 		return $this->_instanceViewer->swapFields($index1, $index2);
511 511
 	}
512 512
 
513 513
 	public function removeField($index) {
514
-		$index = $this->_getIndex($index);
515
-		if ($index !== false) {
514
+		$index=$this->_getIndex($index);
515
+		if ($index!==false) {
516 516
 			$this->_instanceViewer->removeField($index);
517 517
 		}
518 518
 		return $this;
519 519
 	}
520 520
 
521
-	public function asModal($header = null) {
522
-		$modal = new HtmlModal("modal-" . $this->identifier, $header);
521
+	public function asModal($header=null) {
522
+		$modal=new HtmlModal("modal-".$this->identifier, $header);
523 523
 		$modal->setContent($this);
524 524
 		if (isset($this->_form)) {
525 525
 			$this->_form->onSuccess($modal->jsHide());
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 		return $modal;
528 528
 	}
529 529
 
530
-	public function addToProperty($name, $value, $separator = " ") {
530
+	public function addToProperty($name, $value, $separator=" ") {
531 531
 		return $this->getHtmlComponent()->addToProperty($name, $value, $separator);
532 532
 	}
533 533
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -291,8 +291,9 @@  discard block
 block discarded – undo
291 291
 	 */
292 292
 	public function addItemInToolbar($caption, $icon = NULL, $callback = NULL) {
293 293
 		$result = $this->addInToolbar($caption, $callback);
294
-		if (isset($icon) && method_exists($result, "addIcon"))
295
-			$result->addIcon($icon);
294
+		if (isset($icon) && method_exists($result, "addIcon")) {
295
+					$result->addIcon($icon);
296
+		}
296 297
 		return $result;
297 298
 	}
298 299
 
@@ -481,8 +482,9 @@  discard block
 block discarded – undo
481 482
 	protected function _compileForm() {
482 483
 		if (isset($this->_form)) {
483 484
 			$noValidate = "";
484
-			if (\sizeof($this->_form->getValidationParams()) > 0)
485
-				$noValidate = "novalidate";
485
+			if (\sizeof($this->_form->getValidationParams()) > 0) {
486
+							$noValidate = "novalidate";
487
+			}
486 488
 			$this->wrapContent("<form class='" . $this->_form->getProperty('class') . "' id='frm-" . $this->identifier . "' name='frm-" . $this->identifier . "' " . $noValidate . ">", "</form>");
487 489
 		}
488 490
 	}
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlFormField.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -19,38 +19,38 @@  discard block
 block discarded – undo
19 19
 
20 20
 	protected $_validation;
21 21
 
22
-	public function __construct($identifier, $field, $label = NULL) {
22
+	public function __construct($identifier, $field, $label=NULL) {
23 23
 		parent::__construct($identifier, "div", "field");
24
-		$this->content = array();
25
-		$this->_states = [
24
+		$this->content=array();
25
+		$this->_states=[
26 26
 			State::ERROR,
27 27
 			State::DISABLED
28 28
 		];
29
-		if (isset($label) && $label !== "")
29
+		if (isset($label) && $label!=="")
30 30
 			$this->setLabel($label);
31 31
 		$this->setField($field);
32
-		$this->_validation = NULL;
32
+		$this->_validation=NULL;
33 33
 	}
34 34
 
35
-	public function addPointingLabel($label, $pointing = Direction::NONE) {
36
-		$labelO = new HtmlLabel("", $label);
35
+	public function addPointingLabel($label, $pointing=Direction::NONE) {
36
+		$labelO=new HtmlLabel("", $label);
37 37
 		$labelO->setPointing($pointing);
38
-		$this->addContent($labelO, $pointing === "below" || $pointing === "right");
38
+		$this->addContent($labelO, $pointing==="below" || $pointing==="right");
39 39
 		return $labelO;
40 40
 	}
41 41
 
42 42
 	public function setLabel($label) {
43
-		$labelO = $label;
43
+		$labelO=$label;
44 44
 		if (\is_string($label)) {
45
-			$labelO = new HtmlSemDoubleElement("", "label", "");
45
+			$labelO=new HtmlSemDoubleElement("", "label", "");
46 46
 			$labelO->setContent($label);
47 47
 			$labelO->setProperty("for", \str_replace("field-", "", $this->identifier));
48 48
 		}
49
-		$this->content["label"] = $labelO;
49
+		$this->content["label"]=$labelO;
50 50
 	}
51 51
 
52 52
 	public function setField($field) {
53
-		$this->content["field"] = $field;
53
+		$this->content["field"]=$field;
54 54
 	}
55 55
 
56 56
 	/**
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	 * puts the label before or behind
86 86
 	 */
87 87
 	public function swapLabel() {
88
-		$label = $this->getLabel();
88
+		$label=$this->getLabel();
89 89
 		unset($this->content["label"]);
90
-		$this->content["label"] = $label;
90
+		$this->content["label"]=$label;
91 91
 	}
92 92
 
93 93
 	/**
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	public function setWidth($width) {
100 100
 		if (\is_int($width)) {
101
-			$width = Wide::getConstants()["W" . $width];
101
+			$width=Wide::getConstants()["W".$width];
102 102
 		}
103 103
 		$this->addToPropertyCtrl("class", $width, Wide::getConstants());
104 104
 		if (isset($this->_container)) {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	}
128 128
 
129 129
 	public function setContainer($_container) {
130
-		$this->_container = $_container;
130
+		$this->_container=$_container;
131 131
 		return $this;
132 132
 	}
133 133
 
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
 		$this->getDataField()->setProperty("readonly", "");
136 136
 	}
137 137
 
138
-	public function addRule($type, $prompt = NULL, $value = NULL) {
139
-		$field = $this->getDataField();
138
+	public function addRule($type, $prompt=NULL, $value=NULL) {
139
+		$field=$this->getDataField();
140 140
 		if (isset($field)) {
141
-			if (! isset($this->_validation)) {
142
-				$this->_validation = new FieldValidation($field->getIdentifier());
141
+			if (!isset($this->_validation)) {
142
+				$this->_validation=new FieldValidation($field->getIdentifier());
143 143
 			}
144
-			if($type instanceof Rule){
145
-				if($type->getType()=='empty'){
144
+			if ($type instanceof Rule) {
145
+				if ($type->getType()=='empty') {
146 146
 					$this->addToProperty('class', 'required');
147 147
 				}
148
-			}elseif ($type === 'empty' || ($type['type'] ?? '') === 'empty') {
148
+			}elseif ($type==='empty' || ($type['type'] ?? '')==='empty') {
149 149
 				$this->addToProperty('class', 'required');
150 150
 			}
151 151
 			$this->_validation->addRule($type, $prompt, $value);
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 		return $this;
154 154
 	}
155 155
 
156
-	public function setOptional($optional = true) {
157
-		$field = $this->getDataField();
156
+	public function setOptional($optional=true) {
157
+		$field=$this->getDataField();
158 158
 		if (isset($field)) {
159
-			if (! isset($this->_validation)) {
160
-				$this->_validation = new FieldValidation($field->getIdentifier());
159
+			if (!isset($this->_validation)) {
160
+				$this->_validation=new FieldValidation($field->getIdentifier());
161 161
 			}
162 162
 			$this->_validation->setOptional($optional);
163 163
 		}
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
 	}
172 172
 
173 173
 	public function setRules(array $rules) {
174
-		$this->_validation = null;
174
+		$this->_validation=null;
175 175
 		return $this->addRules($rules);
176 176
 	}
177 177
 
178
-	public function addIcon($icon, $direction = Direction::LEFT) {
179
-		$field = $this->getField();
178
+	public function addIcon($icon, $direction=Direction::LEFT) {
179
+		$field=$this->getField();
180 180
 		return $field->addIcon($icon, $direction);
181 181
 	}
182 182
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,8 +26,9 @@  discard block
 block discarded – undo
26 26
 			State::ERROR,
27 27
 			State::DISABLED
28 28
 		];
29
-		if (isset($label) && $label !== "")
30
-			$this->setLabel($label);
29
+		if (isset($label) && $label !== "") {
30
+					$this->setLabel($label);
31
+		}
31 32
 		$this->setField($field);
32 33
 		$this->_validation = NULL;
33 34
 	}
@@ -59,8 +60,9 @@  discard block
 block discarded – undo
59 60
 	 * @return mixed
60 61
 	 */
61 62
 	public function getLabel() {
62
-		if (\array_key_exists("label", $this->content))
63
-			return $this->content["label"];
63
+		if (\array_key_exists("label", $this->content)) {
64
+					return $this->content["label"];
65
+		}
64 66
 	}
65 67
 
66 68
 	/**
@@ -145,7 +147,7 @@  discard block
 block discarded – undo
145 147
 				if($type->getType()=='empty'){
146 148
 					$this->addToProperty('class', 'required');
147 149
 				}
148
-			}elseif ($type === 'empty' || ($type['type'] ?? '') === 'empty') {
150
+			} elseif ($type === 'empty' || ($type['type'] ?? '') === 'empty') {
149 151
 				$this->addToProperty('class', 'required');
150 152
 			}
151 153
 			$this->_validation->addRule($type, $prompt, $value);
Please login to merge, or discard this patch.