Completed
Push — master ( 3f2ff8...3555a5 )
by Jean-Christophe
03:49
created
Ajax/semantic/widgets/InstanceViewer.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -10,72 +10,72 @@  discard block
 block discarded – undo
10 10
 	private $visibleProperties;
11 11
 	private $values;
12 12
 
13
-	public function __construct($instance=NULL,$captions=NULL){
13
+	public function __construct($instance=NULL, $captions=NULL) {
14 14
 		$this->values=[];
15
-		if(isset($instance))
15
+		if (isset($instance))
16 16
 			$this->setInstance($instance);
17 17
 		$this->setCaptions($captions);
18 18
 	}
19 19
 
20
-	public function getCaption($index){
20
+	public function getCaption($index) {
21 21
 		return $this->properties[$index]->getName();
22 22
 	}
23 23
 
24
-	public function getCaptions(){
25
-		if(isset($this->captions)){
24
+	public function getCaptions() {
25
+		if (isset($this->captions)) {
26 26
 			return $this->captions;
27 27
 		}
28 28
 		$captions=[];
29 29
 		$index=0;
30 30
 		$count=$this->count();
31
-		while($index<$count){
31
+		while ($index<$count) {
32 32
 			$captions[]=$this->getCaption($index++);
33 33
 		}
34 34
 		return $captions;
35 35
 	}
36 36
 
37
-	public function getValues(){
37
+	public function getValues() {
38 38
 		$values=[];
39 39
 		$index=0;
40 40
 		$count=$this->count();
41
-		while($index<$count){
41
+		while ($index<$count) {
42 42
 			$values[]=$this->getValue($index++);
43 43
 		}
44 44
 		return $values;
45 45
 	}
46 46
 
47
-	public function getValue($index){
47
+	public function getValue($index) {
48 48
 		$this->properties[$index]->setAccessible(true);
49 49
 		$value=$this->properties[$index]->getValue($this->instance);
50
-		if(isset($this->values[$index])){
51
-			$value= $this->values[$index]($value);
50
+		if (isset($this->values[$index])) {
51
+			$value=$this->values[$index]($value);
52 52
 		}
53 53
 		return $value;
54 54
 	}
55 55
 
56
-	public function count(){
56
+	public function count() {
57 57
 		return \sizeof($this->properties);
58 58
 	}
59 59
 
60
-	public function showableProperty(\ReflectionProperty $rProperty){
61
-		if(\is_array($this->visibleProperties)){
60
+	public function showableProperty(\ReflectionProperty $rProperty) {
61
+		if (\is_array($this->visibleProperties)) {
62 62
 			return \array_search($rProperty->getName(), $this->visibleProperties);
63 63
 		}
64
-		return JString::startswith($rProperty->getName(),"_")===false;
64
+		return JString::startswith($rProperty->getName(), "_")===false;
65 65
 	}
66 66
 
67 67
 	public function setInstance($instance) {
68
-		if(\is_string($instance)){
68
+		if (\is_string($instance)) {
69 69
 			$instance=new $instance();
70 70
 		}
71 71
 		$this->instance=$instance;
72 72
 		$this->properties=[];
73 73
 		$this->reflect=new \ReflectionClass($instance);
74 74
 		$properties=$this->reflect->getProperties();
75
-		foreach ($properties as $property){
75
+		foreach ($properties as $property) {
76 76
 			$showable=$this->showableProperty($property);
77
-			if($showable!==false){
78
-				if(\is_int($showable))
77
+			if ($showable!==false) {
78
+				if (\is_int($showable))
79 79
 					$this->properties[$showable]=$property;
80 80
 				else
81 81
 					$this->properties[]=$property;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		return $this;
95 95
 	}
96 96
 
97
-	public function setValueFunction($index,$callback){
97
+	public function setValueFunction($index, $callback) {
98 98
 		$this->values[$index]=$callback;
99 99
 	}
100 100
 
Please login to merge, or discard this patch.
Ajax/semantic/widgets/ListView.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -9,26 +9,26 @@  discard block
 block discarded – undo
9 9
 class ListView extends Widget {
10 10
 
11 11
 
12
-	public function run(JsUtils $js){
12
+	public function run(JsUtils $js) {
13 13
 		parent::run($js);
14 14
 	}
15 15
 
16
-	public function __construct($identifier,$model,$modelInstance=NULL) {
17
-		parent::__construct($identifier, $model,$modelInstance);
16
+	public function __construct($identifier, $model, $modelInstance=NULL) {
17
+		parent::__construct($identifier, $model, $modelInstance);
18 18
 		$this->_instanceViewer=new InstanceViewer();
19 19
 	}
20 20
 
21
-	public function compile(JsUtils $js=NULL,&$view=NULL){
21
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
22 22
 		$this->_instanceViewer->setInstance($this->_model);
23 23
 		$captions=$this->_instanceViewer->getCaptions();
24
-		$table=new HtmlTable($this->identifier,0,\sizeof($captions));
24
+		$table=new HtmlTable($this->identifier, 0, \sizeof($captions));
25 25
 		$table->setHeaderValues($captions);
26
-		$table->fromDatabaseObjects($this->_modelInstance, function($instance){
26
+		$table->fromDatabaseObjects($this->_modelInstance, function($instance) {
27 27
 			$this->_instanceViewer->setInstance($instance);
28 28
 			return $this->_instanceViewer->getValues();
29 29
 		});
30 30
 		$this->content=$table;
31
-		return parent::compile($js,$view);
31
+		return parent::compile($js, $view);
32 32
 	}
33 33
 
34 34
 	public function getInstanceViewer() {
@@ -40,17 +40,17 @@  discard block
 block discarded – undo
40 40
 		return $this;
41 41
 	}
42 42
 
43
-	public function setCaptions($captions){
43
+	public function setCaptions($captions) {
44 44
 		$this->_instanceViewer->setCaptions($captions);
45 45
 		return $this;
46 46
 	}
47 47
 
48
-	public function setFields($fields){
48
+	public function setFields($fields) {
49 49
 		$this->_instanceViewer->setVisibleProperties($fields);
50 50
 		return $this;
51 51
 	}
52 52
 
53
-	public function setValueFunction($index,$callback){
53
+	public function setValueFunction($index, $callback) {
54 54
 		$this->_instanceViewer->setValueFunction($index, $callback);
55 55
 		return $this;
56 56
 	}
Please login to merge, or discard this patch.
Ajax/common/Widget.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@
 block discarded – undo
10 10
 	protected $_modelInstance;
11 11
 	protected $_instanceViewer;
12 12
 
13
-	public function __construct($identifier,$model,$modelInstance=NULL) {
13
+	public function __construct($identifier, $model, $modelInstance=NULL) {
14 14
 		parent::__construct($identifier);
15 15
 		$this->_template="%wrapContentBefore%%content%%wrapContentAfter%";
16 16
 		$this->setModel($model);
17
-		if(isset($modelInstance));
17
+		if (isset($modelInstance));
18 18
 			$this->show($modelInstance);
19 19
 	}
20 20
 
21
-	public function show($modelInstance){
21
+	public function show($modelInstance) {
22 22
 		$this->_modelInstance=$modelInstance;
23 23
 	}
24 24
 
Please login to merge, or discard this patch.
Ajax/common/traits/JqueryAjaxTrait.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>';
16 16
 
17 17
 	public abstract function _prep_value($value);
18
-	public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true);
18
+	public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true);
19 19
 	protected function addLoading(&$retour, $responseElement) {
20 20
 		$loading_notifier='<div class="ajax-loader">';
21 21
 		if ($this->ajaxLoader=='') {
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
 		$retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n";
29 29
 	}
30 30
 
31
-	public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) {
32
-		return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly);
31
+	public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) {
32
+		return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly);
33 33
 	}
34
-	public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) {
35
-		return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly);
34
+	public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) {
35
+		return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly);
36 36
 	}
37 37
 
38
-	protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) {
39
-		if(JString::isNull($params)){$params="{}";}
38
+	protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) {
39
+		if (JString::isNull($params)) {$params="{}"; }
40 40
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
41 41
 		$retour=$this->_getAjaxUrl($url, $attr);
42 42
 		$responseElement=$this->_getResponseElement($responseElement);
43 43
 		$retour.="var self=this;\n";
44
-		if($hasLoader===true){
44
+		if ($hasLoader===true) {
45 45
 			$this->addLoading($retour, $responseElement);
46 46
 		}
47 47
 		$retour.="$.".$method."(url,".$params.").done(function( data ) {\n";
@@ -51,28 +51,28 @@  discard block
 block discarded – undo
51 51
 			return $retour;
52 52
 	}
53 53
 
54
-	protected function _getAjaxUrl($url,$attr){
54
+	protected function _getAjaxUrl($url, $attr) {
55 55
 		$url=$this->_correctAjaxUrl($url);
56 56
 		$retour="url='".$url."';\n";
57 57
 		$slash="/";
58
-		if(JString::endswith($url, "/")===true)
58
+		if (JString::endswith($url, "/")===true)
59 59
 			$slash="";
60
-		if(JString::isNotNull($attr)){
60
+		if (JString::isNotNull($attr)) {
61 61
 			if ($attr=="value")
62 62
 				$retour.="url=url+'".$slash."'+$(this).val();\n";
63
-				else if($attr!=null && $attr!=="")
63
+				else if ($attr!=null && $attr!=="")
64 64
 					$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
65 65
 		}
66 66
 		return $retour;
67 67
 	}
68 68
 
69
-	protected function _getOnAjaxDone($responseElement,$jsCallback){
69
+	protected function _getOnAjaxDone($responseElement, $jsCallback) {
70 70
 		$retour="";
71 71
 		if ($responseElement!=="") {
72
-			if(JString::startswith($responseElement, "-")){
72
+			if (JString::startswith($responseElement, "-")) {
73 73
 				$responseElement=\substr($responseElement, 0);
74 74
 				$retour="\t$({$responseElement}).replaceWith( data );\n";
75
-			}else{
75
+			} else {
76 76
 				$retour="\t$({$responseElement}).html( data );\n";
77 77
 			}
78 78
 		}
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		return $retour;
81 81
 	}
82 82
 
83
-	protected function _getResponseElement($responseElement){
83
+	protected function _getResponseElement($responseElement) {
84 84
 		if ($responseElement!=="") {
85 85
 			$responseElement=$this->_prep_value($responseElement);
86 86
 		}
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	protected function _correctAjaxUrl($url) {
91 91
 		if ($url!=="/" && JString::endsWith($url, "/")===true)
92 92
 			$url=substr($url, 0, strlen($url)-1);
93
-		if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
93
+		if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) {
94 94
 			$url=$this->jsUtils->getUrl($url);
95 95
 		}
96 96
 		return $url;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @param string $jsCallback javascript code to execute after the request
105 105
 	 * @param boolean $immediatly
106 106
 	 */
107
-	public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) {
107
+	public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) {
108 108
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
109 109
 		$retour=$this->_getAjaxUrl($url, $attr);
110 110
 		$retour.="$.{$method}(url,".$params.").done(function( data ) {\n";
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 * @param string $url the request address
126 126
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true)
127 127
 	 */
128
-	public function _jsonOn($event,$element, $url,$parameters=array()) {
128
+	public function _jsonOn($event, $element, $url, $parameters=array()) {
129 129
 		$preventDefault=true;
130 130
 		$stopPropagation=true;
131 131
 		$jsCallback=null;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		$params="{}";
136 136
 		$immediatly=true;
137 137
 		extract($parameters);
138
-		return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly);
138
+		return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly);
139 139
 	}
140 140
 
141 141
 	/**
@@ -147,19 +147,19 @@  discard block
 block discarded – undo
147 147
 	 * @param string $context jquery DOM element, array container.
148 148
 	 * @param boolean $immediatly
149 149
 	 */
150
-	public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$immediatly=false) {
150
+	public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $immediatly=false) {
151 151
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
152 152
 		$retour=$this->_getAjaxUrl($url, $attr);
153
-		if($context===null){
153
+		if ($context===null) {
154 154
 			$appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n";
155
-			$newElm = "$('#'+newId)";
156
-		}else{
155
+			$newElm="$('#'+newId)";
156
+		} else {
157 157
 			$appendTo="\t\tnewElm.appendTo(".$context.");\n";
158
-			$newElm = $context.".find('#'+newId)";
158
+			$newElm=$context.".find('#'+newId)";
159 159
 		}
160 160
 		$retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n";
161 161
 		$retour.="\tdata=$.parseJSON(data);$.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();newElm.attr('id',newId);\n";
162
-		$retour.= $appendTo;
162
+		$retour.=$appendTo;
163 163
 		$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";
164 164
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
165 165
 		$retour.="\t".$jsCallback."\n"."});\n";
@@ -174,26 +174,26 @@  discard block
 block discarded – undo
174 174
 	 * @param string $url the request address
175 175
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null)
176 176
 	 */
177
-	public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) {
177
+	public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) {
178 178
 		$preventDefault=true;
179 179
 		$stopPropagation=true;
180 180
 		$jsCallback=null;
181 181
 		$attr="id";
182 182
 		$method="get";
183
-		$context = null;
183
+		$context=null;
184 184
 		$params="{}";
185 185
 		$immediatly=true;
186 186
 		extract($parameters);
187
-		return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly);
187
+		return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly);
188 188
 	}
189 189
 
190
-	public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) {
190
+	public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) {
191 191
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
192 192
 		$retour=$this->_getAjaxUrl($url, $attr);
193 193
 		$retour.="\nvar params=$('#".$form."').serialize();\n";
194 194
 		$responseElement=$this->_getResponseElement($responseElement);
195 195
 		$retour.="var self=this;\n";
196
-		if($hasLoader===true){
196
+		if ($hasLoader===true) {
197 197
 			$this->addLoading($retour, $responseElement);
198 198
 		}
199 199
 		$retour.="$.post(url,params).done(function( data ) {\n";
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @param string $responseElement
221 221
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true)
222 222
 	 */
223
-	public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) {
223
+	public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) {
224 224
 		$preventDefault=true;
225 225
 		$stopPropagation=true;
226 226
 		$jsCallback=null;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 		$hasLoader=true;
229 229
 		$immediatly=true;
230 230
 		extract($parameters);
231
-		return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly);
231
+		return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly);
232 232
 	}
233 233
 
234 234
 	/**
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 * @param string $responseElement
242 242
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true)
243 243
 	 */
244
-	public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) {
244
+	public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) {
245 245
 		$preventDefault=true;
246 246
 		$stopPropagation=true;
247 247
 		$jsCallback=null;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 		$hasLoader=true;
250 250
 		$immediatly=true;
251 251
 		extract($parameters);
252
-		return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly);
252
+		return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly);
253 253
 	}
254 254
 
255 255
 	/**
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 * @param string $responseElement
263 263
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true)
264 264
 	 */
265
-	public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) {
265
+	public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) {
266 266
 		$preventDefault=true;
267 267
 		$stopPropagation=true;
268 268
 		$validation=false;
@@ -271,6 +271,6 @@  discard block
 block discarded – undo
271 271
 		$hasLoader=true;
272 272
 		$immediatly=true;
273 273
 		extract($parameters);
274
-		return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly);
274
+		return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly);
275 275
 	}
276 276
 }
277 277
\ No newline at end of file
Please login to merge, or discard this patch.