Passed
Push — main ( 25bffa...46a53d )
by Peter
07:23
created
rawassets/components/data-table/examples/server_side/scripts/jsonp.php 1 patch
Spacing   +14 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,22 +29,22 @@  discard block
 block discarded – undo
29 29
 // parameter represents the DataTables column identifier. In this case simple
30 30
 // indexes
31 31
 $columns = array(
32
-	array( 'db' => 'first_name', 'dt' => 0 ),
33
-	array( 'db' => 'last_name',  'dt' => 1 ),
34
-	array( 'db' => 'position',   'dt' => 2 ),
35
-	array( 'db' => 'office',     'dt' => 3 ),
32
+	array('db' => 'first_name', 'dt' => 0),
33
+	array('db' => 'last_name', 'dt' => 1),
34
+	array('db' => 'position', 'dt' => 2),
35
+	array('db' => 'office', 'dt' => 3),
36 36
 	array(
37 37
 		'db'        => 'start_date',
38 38
 		'dt'        => 4,
39
-		'formatter' => function( $d, $row ) {
40
-			return date( 'jS M y', strtotime($d));
39
+		'formatter' => function($d, $row) {
40
+			return date('jS M y', strtotime($d));
41 41
 		}
42 42
 	),
43 43
 	array(
44 44
 		'db'        => 'salary',
45 45
 		'dt'        => 5,
46
-		'formatter' => function( $d, $row ) {
47
-			return '$'.number_format($d);
46
+		'formatter' => function($d, $row) {
47
+			return '$' . number_format($d);
48 48
 		}
49 49
 	)
50 50
 );
@@ -61,16 +61,15 @@  discard block
 block discarded – undo
61 61
  * If you just want to use the basic configuration for DataTables with PHP
62 62
  * server-side, there is no need to edit below this line.
63 63
  */
64
-require( 'ssp.class.php' );
64
+require('ssp.class.php');
65 65
 
66 66
 // Validate the JSONP to make use it is an okay Javascript function to execute
67 67
 $jsonp = preg_match('/^[$A-Z_][0-9A-Z_$]*$/i', $_GET['callback']) ?
68
-	$_GET['callback'] :
69
-	false;
68
+	$_GET['callback'] : false;
70 69
 
71
-if ( $jsonp ) {
72
-	echo $jsonp.'('.json_encode(
73
-		SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
74
-	).');';
70
+if ($jsonp) {
71
+	echo $jsonp . '(' . json_encode(
72
+		SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns)
73
+	) . ');';
75 74
 }
76 75
 
Please login to merge, or discard this patch.
rawassets/components/data-table/examples/server_side/scripts/ids-arrays.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,29 +32,29 @@  discard block
 block discarded – undo
32 32
 	array(
33 33
 		'db' => 'id',
34 34
 		'dt' => 'DT_RowId',
35
-		'formatter' => function( $d, $row ) {
35
+		'formatter' => function($d, $row) {
36 36
 			// Technically a DOM id cannot start with an integer, so we prefix
37 37
 			// a string. This can also be useful if you have multiple tables
38 38
 			// to ensure that the id is unique with a different prefix
39
-			return 'row_'.$d;
39
+			return 'row_' . $d;
40 40
 		}
41 41
 	),
42
-	array( 'db' => 'first_name', 'dt' => 0 ),
43
-	array( 'db' => 'last_name',  'dt' => 1 ),
44
-	array( 'db' => 'position',   'dt' => 2 ),
45
-	array( 'db' => 'office',     'dt' => 3 ),
42
+	array('db' => 'first_name', 'dt' => 0),
43
+	array('db' => 'last_name', 'dt' => 1),
44
+	array('db' => 'position', 'dt' => 2),
45
+	array('db' => 'office', 'dt' => 3),
46 46
 	array(
47 47
 		'db'        => 'start_date',
48 48
 		'dt'        => 4,
49
-		'formatter' => function( $d, $row ) {
50
-			return date( 'jS M y', strtotime($d));
49
+		'formatter' => function($d, $row) {
50
+			return date('jS M y', strtotime($d));
51 51
 		}
52 52
 	),
53 53
 	array(
54 54
 		'db'        => 'salary',
55 55
 		'dt'        => 5,
56
-		'formatter' => function( $d, $row ) {
57
-			return '$'.number_format($d);
56
+		'formatter' => function($d, $row) {
57
+			return '$' . number_format($d);
58 58
 		}
59 59
 	)
60 60
 );
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
  * server-side, there is no need to edit below this line.
74 74
  */
75 75
 
76
-require( 'ssp.class.php' );
76
+require('ssp.class.php');
77 77
 
78 78
 echo json_encode(
79
-	SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
79
+	SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns)
80 80
 );
81 81
 
Please login to merge, or discard this patch.
rawassets/components/data-table/examples/server_side/scripts/post.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -29,22 +29,22 @@  discard block
 block discarded – undo
29 29
 // parameter represents the DataTables column identifier. In this case object
30 30
 // parameter names
31 31
 $columns = array(
32
-	array( 'db' => 'first_name', 'dt' => 'first_name' ),
33
-	array( 'db' => 'last_name',  'dt' => 'last_name' ),
34
-	array( 'db' => 'position',   'dt' => 'position' ),
35
-	array( 'db' => 'office',     'dt' => 'office' ),
32
+	array('db' => 'first_name', 'dt' => 'first_name'),
33
+	array('db' => 'last_name', 'dt' => 'last_name'),
34
+	array('db' => 'position', 'dt' => 'position'),
35
+	array('db' => 'office', 'dt' => 'office'),
36 36
 	array(
37 37
 		'db'        => 'start_date',
38 38
 		'dt'        => 'start_date',
39
-		'formatter' => function( $d, $row ) {
40
-			return date( 'jS M y', strtotime($d));
39
+		'formatter' => function($d, $row) {
40
+			return date('jS M y', strtotime($d));
41 41
 		}
42 42
 	),
43 43
 	array(
44 44
 		'db'        => 'salary',
45 45
 		'dt'        => 'salary',
46
-		'formatter' => function( $d, $row ) {
47
-			return '$'.number_format($d);
46
+		'formatter' => function($d, $row) {
47
+			return '$' . number_format($d);
48 48
 		}
49 49
 	)
50 50
 );
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
  * server-side, there is no need to edit below this line.
64 64
  */
65 65
 
66
-require( 'ssp.class.php' );
66
+require('ssp.class.php');
67 67
 
68 68
 echo json_encode(
69
-	SSP::simple( $_POST, $sql_details, $table, $primaryKey, $columns )
69
+	SSP::simple($_POST, $sql_details, $table, $primaryKey, $columns)
70 70
 );
71 71
 
Please login to merge, or discard this patch.
components/data-table/examples/server_side/scripts/server_processing.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -29,22 +29,22 @@  discard block
 block discarded – undo
29 29
 // parameter represents the DataTables column identifier. In this case simple
30 30
 // indexes
31 31
 $columns = array(
32
-	array( 'db' => 'first_name', 'dt' => 0 ),
33
-	array( 'db' => 'last_name',  'dt' => 1 ),
34
-	array( 'db' => 'position',   'dt' => 2 ),
35
-	array( 'db' => 'office',     'dt' => 3 ),
32
+	array('db' => 'first_name', 'dt' => 0),
33
+	array('db' => 'last_name', 'dt' => 1),
34
+	array('db' => 'position', 'dt' => 2),
35
+	array('db' => 'office', 'dt' => 3),
36 36
 	array(
37 37
 		'db'        => 'start_date',
38 38
 		'dt'        => 4,
39
-		'formatter' => function( $d, $row ) {
40
-			return date( 'jS M y', strtotime($d));
39
+		'formatter' => function($d, $row) {
40
+			return date('jS M y', strtotime($d));
41 41
 		}
42 42
 	),
43 43
 	array(
44 44
 		'db'        => 'salary',
45 45
 		'dt'        => 5,
46
-		'formatter' => function( $d, $row ) {
47
-			return '$'.number_format($d);
46
+		'formatter' => function($d, $row) {
47
+			return '$' . number_format($d);
48 48
 		}
49 49
 	)
50 50
 );
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
  * server-side, there is no need to edit below this line.
64 64
  */
65 65
 
66
-require( 'ssp.class.php' );
66
+require('ssp.class.php');
67 67
 
68 68
 echo json_encode(
69
-	SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
69
+	SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns)
70 70
 );
71 71
 
72 72
 
Please login to merge, or discard this patch.
rawassets/components/data-table/examples/server_side/scripts/ssp.class.php 1 patch
Spacing   +103 added lines, -107 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
 
18 18
 
19 19
 // REMOVE THIS BLOCK - used for DataTables test environment only!
20
-$file = $_SERVER['DOCUMENT_ROOT'].'/datatables/mysql.php';
21
-if ( is_file( $file ) ) {
22
-	include( $file );
20
+$file = $_SERVER['DOCUMENT_ROOT'] . '/datatables/mysql.php';
21
+if (is_file($file)) {
22
+	include($file);
23 23
 }
24 24
 
25 25
 
@@ -31,22 +31,22 @@  discard block
 block discarded – undo
31 31
 	 *  @param  array $data    Data from the SQL get
32 32
 	 *  @return array          Formatted data in a row based format
33 33
 	 */
34
-	static function data_output ( $columns, $data )
34
+	static function data_output($columns, $data)
35 35
 	{
36 36
 		$out = array();
37 37
 
38
-		for ( $i=0, $ien=count($data) ; $i<$ien ; $i++ ) {
38
+		for ($i = 0, $ien = count($data); $i < $ien; $i++) {
39 39
 			$row = array();
40 40
 
41
-			for ( $j=0, $jen=count($columns) ; $j<$jen ; $j++ ) {
41
+			for ($j = 0, $jen = count($columns); $j < $jen; $j++) {
42 42
 				$column = $columns[$j];
43 43
 
44 44
 				// Is there a formatter?
45
-				if ( isset( $column['formatter'] ) ) {
46
-					$row[ $column['dt'] ] = $column['formatter']( $data[$i][ $column['db'] ], $data[$i] );
45
+				if (isset($column['formatter'])) {
46
+					$row[$column['dt']] = $column['formatter']($data[$i][$column['db']], $data[$i]);
47 47
 				}
48 48
 				else {
49
-					$row[ $column['dt'] ] = $data[$i][ $columns[$j]['db'] ];
49
+					$row[$column['dt']] = $data[$i][$columns[$j]['db']];
50 50
 				}
51 51
 			}
52 52
 
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
 	 *     * pass - user password
71 71
 	 *  @return resource PDO connection
72 72
 	 */
73
-	static function db ( $conn )
73
+	static function db($conn)
74 74
 	{
75
-		if ( is_array( $conn ) ) {
76
-			return self::sql_connect( $conn );
75
+		if (is_array($conn)) {
76
+			return self::sql_connect($conn);
77 77
 		}
78 78
 
79 79
 		return $conn;
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
 	 *  @param  array $columns Column information array
90 90
 	 *  @return string SQL limit clause
91 91
 	 */
92
-	static function limit ( $request, $columns )
92
+	static function limit($request, $columns)
93 93
 	{
94 94
 		$limit = '';
95 95
 
96
-		if ( isset($request['start']) && $request['length'] != -1 ) {
97
-			$limit = "LIMIT ".intval($request['start']).", ".intval($request['length']);
96
+		if (isset($request['start']) && $request['length'] != -1) {
97
+			$limit = "LIMIT " . intval($request['start']) . ", " . intval($request['length']);
98 98
 		}
99 99
 
100 100
 		return $limit;
@@ -110,32 +110,31 @@  discard block
 block discarded – undo
110 110
 	 *  @param  array $columns Column information array
111 111
 	 *  @return string SQL order by clause
112 112
 	 */
113
-	static function order ( $request, $columns )
113
+	static function order($request, $columns)
114 114
 	{
115 115
 		$order = '';
116 116
 
117
-		if ( isset($request['order']) && count($request['order']) ) {
117
+		if (isset($request['order']) && count($request['order'])) {
118 118
 			$orderBy = array();
119
-			$dtColumns = self::pluck( $columns, 'dt' );
119
+			$dtColumns = self::pluck($columns, 'dt');
120 120
 
121
-			for ( $i=0, $ien=count($request['order']) ; $i<$ien ; $i++ ) {
121
+			for ($i = 0, $ien = count($request['order']); $i < $ien; $i++) {
122 122
 				// Convert the column index into the column data property
123 123
 				$columnIdx = intval($request['order'][$i]['column']);
124 124
 				$requestColumn = $request['columns'][$columnIdx];
125 125
 
126
-				$columnIdx = array_search( $requestColumn['data'], $dtColumns );
127
-				$column = $columns[ $columnIdx ];
126
+				$columnIdx = array_search($requestColumn['data'], $dtColumns);
127
+				$column = $columns[$columnIdx];
128 128
 
129
-				if ( $requestColumn['orderable'] == 'true' ) {
129
+				if ($requestColumn['orderable'] == 'true') {
130 130
 					$dir = $request['order'][$i]['dir'] === 'asc' ?
131
-						'ASC' :
132
-						'DESC';
131
+						'ASC' : 'DESC';
133 132
 
134
-					$orderBy[] = '`'.$column['db'].'` '.$dir;
133
+					$orderBy[] = '`' . $column['db'] . '` ' . $dir;
135 134
 				}
136 135
 			}
137 136
 
138
-			$order = 'ORDER BY '.implode(', ', $orderBy);
137
+			$order = 'ORDER BY ' . implode(', ', $orderBy);
139 138
 		}
140 139
 
141 140
 		return $order;
@@ -157,57 +156,56 @@  discard block
 block discarded – undo
157 156
 	 *    sql_exec() function
158 157
 	 *  @return string SQL where clause
159 158
 	 */
160
-	static function filter ( $request, $columns, &$bindings )
159
+	static function filter($request, $columns, &$bindings)
161 160
 	{
162 161
 		$globalSearch = array();
163 162
 		$columnSearch = array();
164
-		$dtColumns = self::pluck( $columns, 'dt' );
163
+		$dtColumns = self::pluck($columns, 'dt');
165 164
 
166
-		if ( isset($request['search']) && $request['search']['value'] != '' ) {
165
+		if (isset($request['search']) && $request['search']['value'] != '') {
167 166
 			$str = $request['search']['value'];
168 167
 
169
-			for ( $i=0, $ien=count($request['columns']) ; $i<$ien ; $i++ ) {
168
+			for ($i = 0, $ien = count($request['columns']); $i < $ien; $i++) {
170 169
 				$requestColumn = $request['columns'][$i];
171
-				$columnIdx = array_search( $requestColumn['data'], $dtColumns );
172
-				$column = $columns[ $columnIdx ];
170
+				$columnIdx = array_search($requestColumn['data'], $dtColumns);
171
+				$column = $columns[$columnIdx];
173 172
 
174
-				if ( $requestColumn['searchable'] == 'true' ) {
175
-					$binding = self::bind( $bindings, '%'.$str.'%', PDO::PARAM_STR );
176
-					$globalSearch[] = "`".$column['db']."` LIKE ".$binding;
173
+				if ($requestColumn['searchable'] == 'true') {
174
+					$binding = self::bind($bindings, '%' . $str . '%', PDO::PARAM_STR);
175
+					$globalSearch[] = "`" . $column['db'] . "` LIKE " . $binding;
177 176
 				}
178 177
 			}
179 178
 		}
180 179
 
181 180
 		// Individual column filtering
182
-		for ( $i=0, $ien=count($request['columns']) ; $i<$ien ; $i++ ) {
181
+		for ($i = 0, $ien = count($request['columns']); $i < $ien; $i++) {
183 182
 			$requestColumn = $request['columns'][$i];
184
-			$columnIdx = array_search( $requestColumn['data'], $dtColumns );
185
-			$column = $columns[ $columnIdx ];
183
+			$columnIdx = array_search($requestColumn['data'], $dtColumns);
184
+			$column = $columns[$columnIdx];
186 185
 
187 186
 			$str = $requestColumn['search']['value'];
188 187
 
189
-			if ( $requestColumn['searchable'] == 'true' &&
190
-			 $str != '' ) {
191
-				$binding = self::bind( $bindings, '%'.$str.'%', PDO::PARAM_STR );
192
-				$columnSearch[] = "`".$column['db']."` LIKE ".$binding;
188
+			if ($requestColumn['searchable'] == 'true' &&
189
+			 $str != '') {
190
+				$binding = self::bind($bindings, '%' . $str . '%', PDO::PARAM_STR);
191
+				$columnSearch[] = "`" . $column['db'] . "` LIKE " . $binding;
193 192
 			}
194 193
 		}
195 194
 
196 195
 		// Combine the filters into a single string
197 196
 		$where = '';
198 197
 
199
-		if ( count( $globalSearch ) ) {
200
-			$where = '('.implode(' OR ', $globalSearch).')';
198
+		if (count($globalSearch)) {
199
+			$where = '(' . implode(' OR ', $globalSearch) . ')';
201 200
 		}
202 201
 
203
-		if ( count( $columnSearch ) ) {
202
+		if (count($columnSearch)) {
204 203
 			$where = $where === '' ?
205
-				implode(' AND ', $columnSearch) :
206
-				$where .' AND '. implode(' AND ', $columnSearch);
204
+				implode(' AND ', $columnSearch) : $where . ' AND ' . implode(' AND ', $columnSearch);
207 205
 		}
208 206
 
209
-		if ( $where !== '' ) {
210
-			$where = 'WHERE '.$where;
207
+		if ($where !== '') {
208
+			$where = 'WHERE ' . $where;
211 209
 		}
212 210
 
213 211
 		return $where;
@@ -228,19 +226,19 @@  discard block
 block discarded – undo
228 226
 	 *  @param  array $columns Column information array
229 227
 	 *  @return array          Server-side processing response array
230 228
 	 */
231
-	static function simple ( $request, $conn, $table, $primaryKey, $columns )
229
+	static function simple($request, $conn, $table, $primaryKey, $columns)
232 230
 	{
233 231
 		$bindings = array();
234
-		$db = self::db( $conn );
232
+		$db = self::db($conn);
235 233
 
236 234
 		// Build the SQL query string from the request
237
-		$limit = self::limit( $request, $columns );
238
-		$order = self::order( $request, $columns );
239
-		$where = self::filter( $request, $columns, $bindings );
235
+		$limit = self::limit($request, $columns);
236
+		$order = self::order($request, $columns);
237
+		$where = self::filter($request, $columns, $bindings);
240 238
 
241 239
 		// Main query to actually get the data
242
-		$data = self::sql_exec( $db, $bindings,
243
-			"SELECT SQL_CALC_FOUND_ROWS `".implode("`, `", self::pluck($columns, 'db'))."`
240
+		$data = self::sql_exec($db, $bindings,
241
+			"SELECT SQL_CALC_FOUND_ROWS `" . implode("`, `", self::pluck($columns, 'db')) . "`
244 242
 			 FROM `$table`
245 243
 			 $where
246 244
 			 $order
@@ -248,13 +246,13 @@  discard block
 block discarded – undo
248 246
 		);
249 247
 
250 248
 		// Data set length after filtering
251
-		$resFilterLength = self::sql_exec( $db,
249
+		$resFilterLength = self::sql_exec($db,
252 250
 			"SELECT FOUND_ROWS()"
253 251
 		);
254 252
 		$recordsFiltered = $resFilterLength[0][0];
255 253
 
256 254
 		// Total data set length
257
-		$resTotalLength = self::sql_exec( $db,
255
+		$resTotalLength = self::sql_exec($db,
258 256
 			"SELECT COUNT(`{$primaryKey}`)
259 257
 			 FROM   `$table`"
260 258
 		);
@@ -265,10 +263,10 @@  discard block
 block discarded – undo
265 263
 		 * Output
266 264
 		 */
267 265
 		return array(
268
-			"draw"            => intval( $request['draw'] ),
269
-			"recordsTotal"    => intval( $recordsTotal ),
270
-			"recordsFiltered" => intval( $recordsFiltered ),
271
-			"data"            => self::data_output( $columns, $data )
266
+			"draw"            => intval($request['draw']),
267
+			"recordsTotal"    => intval($recordsTotal),
268
+			"recordsFiltered" => intval($recordsFiltered),
269
+			"data"            => self::data_output($columns, $data)
272 270
 		);
273 271
 	}
274 272
 
@@ -296,39 +294,37 @@  discard block
 block discarded – undo
296 294
 	 *  @param  string $whereAll WHERE condition to apply to all queries
297 295
 	 *  @return array          Server-side processing response array
298 296
 	 */
299
-	static function complex ( $request, $conn, $table, $primaryKey, $columns, $whereResult=null, $whereAll=null )
297
+	static function complex($request, $conn, $table, $primaryKey, $columns, $whereResult = null, $whereAll = null)
300 298
 	{
301 299
 		$bindings = array();
302
-		$db = self::db( $conn );
300
+		$db = self::db($conn);
303 301
 		$localWhereResult = array();
304 302
 		$localWhereAll = array();
305 303
 		$whereAllSql = '';
306 304
 
307 305
 		// Build the SQL query string from the request
308
-		$limit = self::limit( $request, $columns );
309
-		$order = self::order( $request, $columns );
310
-		$where = self::filter( $request, $columns, $bindings );
306
+		$limit = self::limit($request, $columns);
307
+		$order = self::order($request, $columns);
308
+		$where = self::filter($request, $columns, $bindings);
311 309
 
312
-		$whereResult = self::_flatten( $whereResult );
313
-		$whereAll = self::_flatten( $whereAll );
310
+		$whereResult = self::_flatten($whereResult);
311
+		$whereAll = self::_flatten($whereAll);
314 312
 
315
-		if ( $whereResult ) {
313
+		if ($whereResult) {
316 314
 			$where = $where ?
317
-				$where .' AND '.$whereResult :
318
-				'WHERE '.$whereResult;
315
+				$where . ' AND ' . $whereResult : 'WHERE ' . $whereResult;
319 316
 		}
320 317
 
321
-		if ( $whereAll ) {
318
+		if ($whereAll) {
322 319
 			$where = $where ?
323
-				$where .' AND '.$whereAll :
324
-				'WHERE '.$whereAll;
320
+				$where . ' AND ' . $whereAll : 'WHERE ' . $whereAll;
325 321
 
326
-			$whereAllSql = 'WHERE '.$whereAll;
322
+			$whereAllSql = 'WHERE ' . $whereAll;
327 323
 		}
328 324
 
329 325
 		// Main query to actually get the data
330
-		$data = self::sql_exec( $db, $bindings,
331
-			"SELECT SQL_CALC_FOUND_ROWS `".implode("`, `", self::pluck($columns, 'db'))."`
326
+		$data = self::sql_exec($db, $bindings,
327
+			"SELECT SQL_CALC_FOUND_ROWS `" . implode("`, `", self::pluck($columns, 'db')) . "`
332 328
 			 FROM `$table`
333 329
 			 $where
334 330
 			 $order
@@ -336,15 +332,15 @@  discard block
 block discarded – undo
336 332
 		);
337 333
 
338 334
 		// Data set length after filtering
339
-		$resFilterLength = self::sql_exec( $db,
335
+		$resFilterLength = self::sql_exec($db,
340 336
 			"SELECT FOUND_ROWS()"
341 337
 		);
342 338
 		$recordsFiltered = $resFilterLength[0][0];
343 339
 
344 340
 		// Total data set length
345
-		$resTotalLength = self::sql_exec( $db, $bindings,
341
+		$resTotalLength = self::sql_exec($db, $bindings,
346 342
 			"SELECT COUNT(`{$primaryKey}`)
347
-			 FROM   `$table` ".
343
+			 FROM   `$table` " .
348 344
 			$whereAllSql
349 345
 		);
350 346
 		$recordsTotal = $resTotalLength[0][0];
@@ -353,10 +349,10 @@  discard block
 block discarded – undo
353 349
 		 * Output
354 350
 		 */
355 351
 		return array(
356
-			"draw"            => intval( $request['draw'] ),
357
-			"recordsTotal"    => intval( $recordsTotal ),
358
-			"recordsFiltered" => intval( $recordsFiltered ),
359
-			"data"            => self::data_output( $columns, $data )
352
+			"draw"            => intval($request['draw']),
353
+			"recordsTotal"    => intval($recordsTotal),
354
+			"recordsFiltered" => intval($recordsFiltered),
355
+			"data"            => self::data_output($columns, $data)
360 356
 		);
361 357
 	}
362 358
 
@@ -372,20 +368,20 @@  discard block
 block discarded – undo
372 368
 	 *     * pass - user password
373 369
 	 * @return resource Database connection handle
374 370
 	 */
375
-	static function sql_connect ( $sql_details )
371
+	static function sql_connect($sql_details)
376 372
 	{
377 373
 		try {
378 374
 			$db = @new PDO(
379 375
 				"mysql:host={$sql_details['host']};dbname={$sql_details['db']}",
380 376
 				$sql_details['user'],
381 377
 				$sql_details['pass'],
382
-				array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION )
378
+				array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
383 379
 			);
384 380
 		}
385 381
 		catch (PDOException $e) {
386 382
 			self::fatal(
387
-				"An error occurred while connecting to the database. ".
388
-				"The error reported by the server was: ".$e->getMessage()
383
+				"An error occurred while connecting to the database. " .
384
+				"The error reported by the server was: " . $e->getMessage()
389 385
 			);
390 386
 		}
391 387
 
@@ -403,21 +399,21 @@  discard block
 block discarded – undo
403 399
 	 * @param  string   $sql SQL query to execute.
404 400
 	 * @return array         Result from the query (all rows)
405 401
 	 */
406
-	static function sql_exec ( $db, $bindings, $sql=null )
402
+	static function sql_exec($db, $bindings, $sql = null)
407 403
 	{
408 404
 		// Argument shifting
409
-		if ( $sql === null ) {
405
+		if ($sql === null) {
410 406
 			$sql = $bindings;
411 407
 		}
412 408
 
413
-		$stmt = $db->prepare( $sql );
409
+		$stmt = $db->prepare($sql);
414 410
 		//echo $sql;
415 411
 
416 412
 		// Bind parameters
417
-		if ( is_array( $bindings ) ) {
418
-			for ( $i=0, $ien=count($bindings) ; $i<$ien ; $i++ ) {
413
+		if (is_array($bindings)) {
414
+			for ($i = 0, $ien = count($bindings); $i < $ien; $i++) {
419 415
 				$binding = $bindings[$i];
420
-				$stmt->bindValue( $binding['key'], $binding['val'], $binding['type'] );
416
+				$stmt->bindValue($binding['key'], $binding['val'], $binding['type']);
421 417
 			}
422 418
 		}
423 419
 
@@ -426,7 +422,7 @@  discard block
 block discarded – undo
426 422
 			$stmt->execute();
427 423
 		}
428 424
 		catch (PDOException $e) {
429
-			self::fatal( "An SQL error occurred: ".$e->getMessage() );
425
+			self::fatal("An SQL error occurred: " . $e->getMessage());
430 426
 		}
431 427
 
432 428
 		// Return all
@@ -446,11 +442,11 @@  discard block
 block discarded – undo
446 442
 	 *
447 443
 	 * @param  string $msg Message to send to the client
448 444
 	 */
449
-	static function fatal ( $msg )
445
+	static function fatal($msg)
450 446
 	{
451
-		echo json_encode( array( 
447
+		echo json_encode(array( 
452 448
 			"error" => $msg
453
-		) );
449
+		));
454 450
 
455 451
 		exit(0);
456 452
 	}
@@ -465,9 +461,9 @@  discard block
 block discarded – undo
465 461
 	 * @return string       Bound key to be used in the SQL where this parameter
466 462
 	 *   would be used.
467 463
 	 */
468
-	static function bind ( &$a, $val, $type )
464
+	static function bind(&$a, $val, $type)
469 465
 	{
470
-		$key = ':binding_'.count( $a );
466
+		$key = ':binding_' . count($a);
471 467
 
472 468
 		$a[] = array(
473 469
 			'key' => $key,
@@ -487,11 +483,11 @@  discard block
 block discarded – undo
487 483
 	 *  @param  string $prop Property to read
488 484
 	 *  @return array        Array of property values
489 485
 	 */
490
-	static function pluck ( $a, $prop )
486
+	static function pluck($a, $prop)
491 487
 	{
492 488
 		$out = array();
493 489
 
494
-		for ( $i=0, $len=count($a) ; $i<$len ; $i++ ) {
490
+		for ($i = 0, $len = count($a); $i < $len; $i++) {
495 491
 			$out[] = $a[$i][$prop];
496 492
 		}
497 493
 
@@ -506,13 +502,13 @@  discard block
 block discarded – undo
506 502
 	 * @param  string $join Glue for the concatenation
507 503
 	 * @return string Joined string
508 504
 	 */
509
-	static function _flatten ( $a, $join = ' AND ' )
505
+	static function _flatten($a, $join = ' AND ')
510 506
 	{
511
-		if ( ! $a ) {
507
+		if (!$a) {
512 508
 			return '';
513 509
 		}
514
-		else if ( $a && is_array($a) ) {
515
-			return implode( $join, $a );
510
+		else if ($a && is_array($a)) {
511
+			return implode($join, $a);
516 512
 		}
517 513
 		return $a;
518 514
 	}
Please login to merge, or discard this patch.
rawassets/components/data-table/examples/server_side/scripts/objects.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,22 +15,22 @@  discard block
 block discarded – undo
15 15
 // parameter represents the DataTables column identifier. In this case object
16 16
 // parameter names
17 17
 $columns = array(
18
-	array( 'db' => 'first_name', 'dt' => 'first_name' ),
19
-	array( 'db' => 'last_name',  'dt' => 'last_name' ),
20
-	array( 'db' => 'position',   'dt' => 'position' ),
21
-	array( 'db' => 'office',     'dt' => 'office' ),
18
+	array('db' => 'first_name', 'dt' => 'first_name'),
19
+	array('db' => 'last_name', 'dt' => 'last_name'),
20
+	array('db' => 'position', 'dt' => 'position'),
21
+	array('db' => 'office', 'dt' => 'office'),
22 22
 	array(
23 23
 		'db'        => 'start_date',
24 24
 		'dt'        => 'start_date',
25
-		'formatter' => function( $d, $row ) {
26
-			return date( 'jS M y', strtotime($d));
25
+		'formatter' => function($d, $row) {
26
+			return date('jS M y', strtotime($d));
27 27
 		}
28 28
 	),
29 29
 	array(
30 30
 		'db'        => 'salary',
31 31
 		'dt'        => 'salary',
32
-		'formatter' => function( $d, $row ) {
33
-			return '$'.number_format($d);
32
+		'formatter' => function($d, $row) {
33
+			return '$' . number_format($d);
34 34
 		}
35 35
 	)
36 36
 );
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
  * server-side, there is no need to edit below this line.
50 50
  */
51 51
 
52
-require( 'ssp.class.php' );
52
+require('ssp.class.php');
53 53
 
54 54
 echo json_encode(
55
-	SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
55
+	SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns)
56 56
 );
57 57
 
Please login to merge, or discard this patch.
components/data-table/examples/server_side/scripts/ids-objects.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,29 +32,29 @@  discard block
 block discarded – undo
32 32
 	array(
33 33
 		'db' => 'id',
34 34
 		'dt' => 'DT_RowId',
35
-		'formatter' => function( $d, $row ) {
35
+		'formatter' => function($d, $row) {
36 36
 			// Technically a DOM id cannot start with an integer, so we prefix
37 37
 			// a string. This can also be useful if you have multiple tables
38 38
 			// to ensure that the id is unique with a different prefix
39
-			return 'row_'.$d;
39
+			return 'row_' . $d;
40 40
 		}
41 41
 	),
42
-	array( 'db' => 'first_name', 'dt' => 'first_name' ),
43
-	array( 'db' => 'last_name',  'dt' => 'last_name' ),
44
-	array( 'db' => 'position',   'dt' => 'position' ),
45
-	array( 'db' => 'office',     'dt' => 'office' ),
42
+	array('db' => 'first_name', 'dt' => 'first_name'),
43
+	array('db' => 'last_name', 'dt' => 'last_name'),
44
+	array('db' => 'position', 'dt' => 'position'),
45
+	array('db' => 'office', 'dt' => 'office'),
46 46
 	array(
47 47
 		'db'        => 'start_date',
48 48
 		'dt'        => 'start_date',
49
-		'formatter' => function( $d, $row ) {
50
-			return date( 'jS M y', strtotime($d));
49
+		'formatter' => function($d, $row) {
50
+			return date('jS M y', strtotime($d));
51 51
 		}
52 52
 	),
53 53
 	array(
54 54
 		'db'        => 'salary',
55 55
 		'dt'        => 'salary',
56
-		'formatter' => function( $d, $row ) {
57
-			return '$'.number_format($d);
56
+		'formatter' => function($d, $row) {
57
+			return '$' . number_format($d);
58 58
 		}
59 59
 	)
60 60
 );
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
  * server-side, there is no need to edit below this line.
73 73
  */
74 74
 
75
-require( 'ssp.class.php' );
75
+require('ssp.class.php');
76 76
 
77 77
 echo json_encode(
78
-	SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
78
+	SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns)
79 79
 );
80 80
 
Please login to merge, or discard this patch.
resources/rawassets/components/data-table/examples/resources/examples.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( isset( $_POST['src'] ) && preg_match( '/scripts\/[a-zA-Z_\-_]+\.php/', $_POST['src'] ) !== 0 ) {
4
-	echo htmlspecialchars( file_get_contents( '../server_side/'.$_POST['src'] ) );
3
+if (isset($_POST['src']) && preg_match('/scripts\/[a-zA-Z_\-_]+\.php/', $_POST['src']) !== 0) {
4
+	echo htmlspecialchars(file_get_contents('../server_side/' . $_POST['src']));
5 5
 }
6 6
 else {
7 7
 	echo '';
Please login to merge, or discard this patch.
rawassets/components/data-table/extensions/Scroller/examples/data/ssp.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
 // parameter represents the DataTables column identifier. In this case simple
30 30
 // indexes
31 31
 $columns = array(
32
-	array( 'db' => 'id',         'dt' => 0 ),
33
-	array( 'db' => 'firstname',  'dt' => 1 ),
34
-	array( 'db' => 'surname',    'dt' => 2 ),
35
-	array( 'db' => 'zip',        'dt' => 3 ),
36
-	array( 'db' => 'country',    'dt' => 4 )
32
+	array('db' => 'id', 'dt' => 0),
33
+	array('db' => 'firstname', 'dt' => 1),
34
+	array('db' => 'surname', 'dt' => 2),
35
+	array('db' => 'zip', 'dt' => 3),
36
+	array('db' => 'country', 'dt' => 4)
37 37
 );
38 38
 
39 39
 // SQL server connection information
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
  * server-side, there is no need to edit below this line.
51 51
  */
52 52
 
53
-require( '../../../../examples/server_side/scripts/ssp.class.php' );
53
+require('../../../../examples/server_side/scripts/ssp.class.php');
54 54
 
55 55
 echo json_encode(
56
-	SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
56
+	SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns)
57 57
 );
58 58
 
Please login to merge, or discard this patch.