Completed
Push — master ( 5ec30c...b92773 )
by Jean-Christophe
03:32
created
Ajax/semantic/widgets/datatable/InstanceViewer.php 2 patches
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -12,25 +12,25 @@  discard block
 block discarded – undo
12 12
 	private $afterCompile;
13 13
 	private static $index=0;
14 14
 
15
-	public function __construct($instance=NULL,$captions=NULL){
15
+	public function __construct($instance=NULL, $captions=NULL) {
16 16
 		$this->values=[];
17 17
 		$this->afterCompile=[];
18
-		if(isset($instance))
18
+		if (isset($instance))
19 19
 			$this->setInstance($instance);
20 20
 		$this->setCaptions($captions);
21 21
 	}
22 22
 
23
-	public function getCaption($index){
24
-		if($this->properties[$index] instanceof \ReflectionProperty)
23
+	public function getCaption($index) {
24
+		if ($this->properties[$index] instanceof \ReflectionProperty)
25 25
 			return $this->properties[$index]->getName();
26 26
 		else
27 27
 			return $this->properties[$index];
28 28
 	}
29 29
 
30
-	public function getCaptions(){
31
-		if(isset($this->captions)){
32
-			$result= $this->captions;
33
-			for($i=\sizeof($result);$i<$this->count();$i++){
30
+	public function getCaptions() {
31
+		if (isset($this->captions)) {
32
+			$result=$this->captions;
33
+			for ($i=\sizeof($result); $i<$this->count(); $i++) {
34 34
 				$result[]="";
35 35
 			}
36 36
 			return $result;
@@ -38,122 +38,122 @@  discard block
 block discarded – undo
38 38
 		$captions=[];
39 39
 		$index=0;
40 40
 		$count=$this->count();
41
-		while($index<$count){
41
+		while ($index<$count) {
42 42
 			$captions[]=$this->getCaption($index++);
43 43
 		}
44 44
 		return $captions;
45 45
 	}
46 46
 
47
-	public function getValues(){
47
+	public function getValues() {
48 48
 		$values=[];
49 49
 		$index=0;
50 50
 		$count=$this->count();
51
-		while($index<$count){
51
+		while ($index<$count) {
52 52
 			$values[]=$this->getValue($index++);
53 53
 		}
54 54
 		return $values;
55 55
 	}
56 56
 
57
-	public function getIdentifier(){
57
+	public function getIdentifier() {
58 58
 		$value=self::$index;
59
-		if(isset($this->values["identifier"]))
60
-			$value=$this->values["identifier"](self::$index,$this->instance);
59
+		if (isset($this->values["identifier"]))
60
+			$value=$this->values["identifier"](self::$index, $this->instance);
61 61
 		self::$index++;
62 62
 		return $value;
63 63
 	}
64 64
 
65
-	public function getValue($index){
65
+	public function getValue($index) {
66 66
 		$property=$this->properties[$index];
67 67
 		return $this->_getValue($property, $index);
68 68
 	}
69 69
 
70
-	private function _getValue($property,$index){
71
-		if($property instanceof \ReflectionProperty){
70
+	private function _getValue($property, $index) {
71
+		if ($property instanceof \ReflectionProperty) {
72 72
 			$property->setAccessible(true);
73 73
 			$value=$property->getValue($this->instance);
74
-			if(isset($this->values[$index])){
75
-				$value= $this->values[$index]($value);
74
+			if (isset($this->values[$index])) {
75
+				$value=$this->values[$index]($value);
76 76
 			}
77
-		}else{
78
-			if(\is_callable($property))
77
+		} else {
78
+			if (\is_callable($property))
79 79
 				$value=$property($this->instance);
80
-			elseif(\is_array($property)){
81
-				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property);
80
+			elseif (\is_array($property)) {
81
+				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property);
82 82
 				$value=\implode("", $values);
83
-			}else
83
+			} else
84 84
 				$value=$property;
85 85
 		}
86
-		if(isset($this->afterCompile[$index])){
87
-			if(\is_callable($this->afterCompile[$index])){
88
-				$this->afterCompile[$index]($value,$this->instance,$index);
86
+		if (isset($this->afterCompile[$index])) {
87
+			if (\is_callable($this->afterCompile[$index])) {
88
+				$this->afterCompile[$index]($value, $this->instance, $index);
89 89
 			}
90 90
 		}
91 91
 		return $value;
92 92
 	}
93 93
 
94
-	public function insertField($index,$field){
95
-		array_splice( $this->visibleProperties, $index, 0, $field );
94
+	public function insertField($index, $field) {
95
+		array_splice($this->visibleProperties, $index, 0, $field);
96 96
 		return $this;
97 97
 	}
98 98
 
99
-	public function insertInField($index,$field){
99
+	public function insertInField($index, $field) {
100 100
 		$vb=$this->visibleProperties;
101
-		if(isset($vb[$index])){
102
-			if(\is_array($vb[$index])){
101
+		if (isset($vb[$index])) {
102
+			if (\is_array($vb[$index])) {
103 103
 				$this->visibleProperties[$index][]=$field;
104
-			}else{
105
-				$this->visibleProperties[$index]=[$vb[$index],$field];
104
+			} else {
105
+				$this->visibleProperties[$index]=[$vb[$index], $field];
106 106
 			}
107
-		}else{
107
+		} else {
108 108
 			return $this->insertField($index, $field);
109 109
 		}
110 110
 		return $this;
111 111
 	}
112 112
 
113
-	public function addField($field){
113
+	public function addField($field) {
114 114
 		$this->visibleProperties[]=$field;
115 115
 		return $this;
116 116
 	}
117 117
 
118
-	public function count(){
118
+	public function count() {
119 119
 		return \sizeof($this->properties);
120 120
 	}
121 121
 
122
-	public function visiblePropertiesCount(){
122
+	public function visiblePropertiesCount() {
123 123
 		return \sizeof($this->visibleProperties);
124 124
 	}
125 125
 
126
-	private function showableProperty(\ReflectionProperty $rProperty){
127
-		return JString::startswith($rProperty->getName(),"_")===false;
126
+	private function showableProperty(\ReflectionProperty $rProperty) {
127
+		return JString::startswith($rProperty->getName(), "_")===false;
128 128
 	}
129 129
 
130 130
 	public function setInstance($instance) {
131
-		if(\is_string($instance)){
131
+		if (\is_string($instance)) {
132 132
 			$instance=new $instance();
133 133
 		}
134 134
 		$this->instance=$instance;
135 135
 		$this->properties=[];
136 136
 		$this->reflect=new \ReflectionClass($instance);
137
-		if(\sizeof($this->visibleProperties)===0){
137
+		if (\sizeof($this->visibleProperties)===0) {
138 138
 			$this->properties=$this->getDefaultProperties();
139
-		}else{
140
-			foreach ($this->visibleProperties as $property){
141
-				if(\is_callable($property)){
139
+		} else {
140
+			foreach ($this->visibleProperties as $property) {
141
+				if (\is_callable($property)) {
142 142
 					$this->properties[]=$property;
143
-				}elseif(\is_string($property)){
144
-					try{
143
+				}elseif (\is_string($property)) {
144
+					try {
145 145
 						$rProperty=$this->reflect->getProperty($property);
146 146
 						$this->properties[]=$rProperty;
147
-					}catch(\Exception $e){
147
+					}catch (\Exception $e) {
148 148
 						$this->properties[]=$property;
149 149
 					}
150
-				}elseif(\is_int($property)){
150
+				}elseif (\is_int($property)) {
151 151
 					$props=$this->getDefaultProperties();
152
-					if(isset($props[$property]))
152
+					if (isset($props[$property]))
153 153
 						$this->properties[]=$props[$property];
154 154
 					else
155 155
 						$this->properties[]=$property;
156
-				}else{
156
+				} else {
157 157
 					$this->properties[]=$property;
158 158
 				}
159 159
 			}
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
 		return $this;
162 162
 	}
163 163
 
164
-	private function getDefaultProperties(){
164
+	private function getDefaultProperties() {
165 165
 		$result=[];
166 166
 		$properties=$this->reflect->getProperties();
167
-		foreach ($properties as $property){
167
+		foreach ($properties as $property) {
168 168
 			$showable=$this->showableProperty($property);
169
-			if($showable!==false){
169
+			if ($showable!==false) {
170 170
 				$result[]=$property;
171 171
 			}
172 172
 		}
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
 		return $this;
184 184
 	}
185 185
 
186
-	public function setValueFunction($index,$callback){
186
+	public function setValueFunction($index, $callback) {
187 187
 		$this->values[$index]=$callback;
188 188
 		return $this;
189 189
 	}
190 190
 
191
-	public function setIdentifierFunction($callback){
191
+	public function setIdentifierFunction($callback) {
192 192
 		$this->values["identifier"]=$callback;
193 193
 		return $this;
194 194
 	}
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 * @param callable $callback function called after the field compilation
209 209
 	 * @return \Ajax\semantic\widgets\datatable\InstanceViewer
210 210
 	 */
211
-	public function afterCompile($index,$callback){
211
+	public function afterCompile($index, $callback) {
212 212
 		$this->afterCompile[$index]=$callback;
213 213
 		return $this;
214 214
 	}
Please login to merge, or discard this patch.
Braces   +30 added lines, -25 removed lines patch added patch discarded remove patch
@@ -15,16 +15,18 @@  discard block
 block discarded – undo
15 15
 	public function __construct($instance=NULL,$captions=NULL){
16 16
 		$this->values=[];
17 17
 		$this->afterCompile=[];
18
-		if(isset($instance))
19
-			$this->setInstance($instance);
18
+		if(isset($instance)) {
19
+					$this->setInstance($instance);
20
+		}
20 21
 		$this->setCaptions($captions);
21 22
 	}
22 23
 
23 24
 	public function getCaption($index){
24
-		if($this->properties[$index] instanceof \ReflectionProperty)
25
-			return $this->properties[$index]->getName();
26
-		else
27
-			return $this->properties[$index];
25
+		if($this->properties[$index] instanceof \ReflectionProperty) {
26
+					return $this->properties[$index]->getName();
27
+		} else {
28
+					return $this->properties[$index];
29
+		}
28 30
 	}
29 31
 
30 32
 	public function getCaptions(){
@@ -56,8 +58,9 @@  discard block
 block discarded – undo
56 58
 
57 59
 	public function getIdentifier(){
58 60
 		$value=self::$index;
59
-		if(isset($this->values["identifier"]))
60
-			$value=$this->values["identifier"](self::$index,$this->instance);
61
+		if(isset($this->values["identifier"])) {
62
+					$value=$this->values["identifier"](self::$index,$this->instance);
63
+		}
61 64
 		self::$index++;
62 65
 		return $value;
63 66
 	}
@@ -74,14 +77,15 @@  discard block
 block discarded – undo
74 77
 			if(isset($this->values[$index])){
75 78
 				$value= $this->values[$index]($value);
76 79
 			}
77
-		}else{
78
-			if(\is_callable($property))
79
-				$value=$property($this->instance);
80
-			elseif(\is_array($property)){
80
+		} else{
81
+			if(\is_callable($property)) {
82
+							$value=$property($this->instance);
83
+			} elseif(\is_array($property)){
81 84
 				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property);
82 85
 				$value=\implode("", $values);
83
-			}else
84
-				$value=$property;
86
+			} else {
87
+							$value=$property;
88
+			}
85 89
 		}
86 90
 		if(isset($this->afterCompile[$index])){
87 91
 			if(\is_callable($this->afterCompile[$index])){
@@ -101,10 +105,10 @@  discard block
 block discarded – undo
101 105
 		if(isset($vb[$index])){
102 106
 			if(\is_array($vb[$index])){
103 107
 				$this->visibleProperties[$index][]=$field;
104
-			}else{
108
+			} else{
105 109
 				$this->visibleProperties[$index]=[$vb[$index],$field];
106 110
 			}
107
-		}else{
111
+		} else{
108 112
 			return $this->insertField($index, $field);
109 113
 		}
110 114
 		return $this;
@@ -136,24 +140,25 @@  discard block
 block discarded – undo
136 140
 		$this->reflect=new \ReflectionClass($instance);
137 141
 		if(\sizeof($this->visibleProperties)===0){
138 142
 			$this->properties=$this->getDefaultProperties();
139
-		}else{
143
+		} else{
140 144
 			foreach ($this->visibleProperties as $property){
141 145
 				if(\is_callable($property)){
142 146
 					$this->properties[]=$property;
143
-				}elseif(\is_string($property)){
147
+				} elseif(\is_string($property)){
144 148
 					try{
145 149
 						$rProperty=$this->reflect->getProperty($property);
146 150
 						$this->properties[]=$rProperty;
147
-					}catch(\Exception $e){
151
+					} catch(\Exception $e){
148 152
 						$this->properties[]=$property;
149 153
 					}
150
-				}elseif(\is_int($property)){
154
+				} elseif(\is_int($property)){
151 155
 					$props=$this->getDefaultProperties();
152
-					if(isset($props[$property]))
153
-						$this->properties[]=$props[$property];
154
-					else
155
-						$this->properties[]=$property;
156
-				}else{
156
+					if(isset($props[$property])) {
157
+											$this->properties[]=$props[$property];
158
+					} else {
159
+											$this->properties[]=$property;
160
+					}
161
+				} else{
157 162
 					$this->properties[]=$property;
158 163
 				}
159 164
 			}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/PositionInTable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,5 +3,5 @@
 block discarded – undo
3 3
 use Ajax\common\BaseEnum;
4 4
 
5 5
 abstract class PositionInTable extends BaseEnum {
6
-	const BEFORETABLE="beforeTable",AFTERTABLE="afterTable",HEADER="thead",FOOTER="tfoot",BODY="tbody";
6
+	const BEFORETABLE="beforeTable", AFTERTABLE="afterTable", HEADER="thead", FOOTER="tfoot", BODY="tbody";
7 7
 }
8 8
\ No newline at end of file
Please login to merge, or discard this patch.