@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | if (isset($r[0][1], $r[0][1]['class']) && |
32 | 32 | $r[0][1]['class'] === 'no-results' |
33 | 33 | ) { |
34 | - $trs .= '<tr><td'.self::attributes($r[0][1]).'>' |
|
35 | - .$r[0][0].'</td></tr>'; |
|
34 | + $trs .= '<tr><td' . self::attributes($r[0][1]) . '>' |
|
35 | + .$r[0][0] . '</td></tr>'; |
|
36 | 36 | } else { |
37 | - $trs .= '<tr><td>'.implode('</td><td>', $r) |
|
37 | + $trs .= '<tr><td>' . implode('</td><td>', $r) |
|
38 | 38 | .'</td></tr>'; |
39 | 39 | } |
40 | 40 | } |
@@ -49,16 +49,14 @@ discard block |
||
49 | 49 | $rows = [$header]; |
50 | 50 | |
51 | 51 | $data = self::$exportDataAsDisplayed ? |
52 | - self::$data : |
|
53 | - self::select(self::$t['q']); |
|
52 | + self::$data : self::select(self::$t['q']); |
|
54 | 53 | |
55 | 54 | if (count($data) > 0) { |
56 | 55 | foreach ($data as $row) { |
57 | 56 | $cells = []; |
58 | 57 | foreach ($columns as $column) { |
59 | 58 | $cells[] = is_array($row[$column]) ? |
60 | - $row[$column][0] : |
|
61 | - $row[$column]; |
|
59 | + $row[$column][0] : $row[$column]; |
|
62 | 60 | } |
63 | 61 | $rows[] = $cells; |
64 | 62 | } |
@@ -87,21 +85,20 @@ discard block |
||
87 | 85 | switch (self::$export) { |
88 | 86 | case 'Excel': |
89 | 87 | case 'CSV': |
90 | - $escape = function ($value) { |
|
88 | + $escape = function($value) { |
|
91 | 89 | return str_replace("\t", '	', $value); |
92 | 90 | }; |
93 | 91 | |
94 | 92 | if (($output = fopen('php://output', 'w'))) { |
95 | 93 | if (substr($filename, -2) !== '()') { //4 testing |
96 | 94 | header('Content-Type:application/csv'); |
97 | - header('Content-Disposition:attachment; filename='. |
|
98 | - $filename.'.csv'); |
|
95 | + header('Content-Disposition:attachment; filename=' . |
|
96 | + $filename . '.csv'); |
|
99 | 97 | } |
100 | 98 | foreach ($eData as $v) { |
101 | 99 | self::$export === 'CSV' ? |
102 | - fputcsv($output, $v) : |
|
103 | - fwrite($output, |
|
104 | - implode("\t", array_map($escape, $v))."\r\n"); |
|
100 | + fputcsv($output, $v) : fwrite($output, |
|
101 | + implode("\t", array_map($escape, $v)) . "\r\n"); |
|
105 | 102 | } |
106 | 103 | return fclose($output); |
107 | 104 | } |
@@ -115,7 +112,7 @@ discard block |
||
115 | 112 | $fnReplace[':app'] = self::config('APP'); |
116 | 113 | $fnReplace[':items'] = self::$t['items']; |
117 | 114 | $format = str_replace(':', '.', '%d.%m.%Y %H:%i:%s'); |
118 | - $timeQuery = 'SELECT DATE_FORMAT(Now(), "'.$format.'") AS `now`;'; |
|
115 | + $timeQuery = 'SELECT DATE_FORMAT(Now(), "' . $format . '") AS `now`;'; |
|
119 | 116 | $fnReplace[':datetime'] = self::select($timeQuery); |
120 | 117 | |
121 | 118 | return strtr((string) self::config('EXPORT_FILE_NAME'), $fnReplace); |
@@ -38,8 +38,7 @@ discard block |
||
38 | 38 | public static function prepare($setOrCheck = false) |
39 | 39 | { |
40 | 40 | //@see http://php.net/manual/es/function.filter-input.php#77307 |
41 | - $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?: |
|
42 | - filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL); |
|
41 | + $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?: filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL); |
|
43 | 42 | |
44 | 43 | $extension = pathinfo(strtok($uri, '?'), PATHINFO_EXTENSION); |
45 | 44 | |
@@ -73,9 +72,9 @@ discard block |
||
73 | 72 | self::$t['order']['col'] = $orderBy; |
74 | 73 | $dir = strtolower($orderDir); |
75 | 74 | self::$t['order']['dir'] = in_array($dir, ['asc', 'desc']) ? |
76 | - $dir : self::error('Invalid orderDir (Asc/Desc): '.$orderDir); |
|
75 | + $dir : self::error('Invalid orderDir (Asc/Desc): ' . $orderDir); |
|
77 | 76 | self::$t['paging'] = ($num = abs($paging)) >= 10 ? |
78 | - $num : self::error('Invalid paging (<10): '.$paging); |
|
77 | + $num : self::error('Invalid paging (<10): ' . $paging); |
|
79 | 78 | } |
80 | 79 | |
81 | 80 | /** |
@@ -94,7 +93,7 @@ discard block |
||
94 | 93 | self::$t = self::request(self::$export); |
95 | 94 | |
96 | 95 | $order = [self::$t['order']['col'] => self::$t['order']['dir']]; |
97 | - $offset = (self::$t['page'] - 1) * self::$t['paging']; |
|
96 | + $offset = (self::$t['page'] - 1)*self::$t['paging']; |
|
98 | 97 | $limit = [$offset, self::$t['paging']]; |
99 | 98 | self::$t['q'] = self::query($query, self::$t['filter'], $order, $limit, true); |
100 | 99 | |
@@ -107,7 +106,7 @@ discard block |
||
107 | 106 | try { |
108 | 107 | self::$data = self::select($q); |
109 | 108 | } catch (Exception $e) { |
110 | - self::error('ERROR: '.$q.'<br />'.$e->getMessage()); |
|
109 | + self::error('ERROR: ' . $q . '<br />' . $e->getMessage()); |
|
111 | 110 | } |
112 | 111 | } |
113 | 112 | |
@@ -121,7 +120,7 @@ discard block |
||
121 | 120 | } else { |
122 | 121 | $tableId = filter_input(INPUT_GET, 'table-id') ?: //4 testing |
123 | 122 | filter_var($_GET['table-id'], FILTER_SANITIZE_STRING); |
124 | - if ($tableId === self::$t['items'].'-table') { |
|
123 | + if ($tableId === self::$t['items'] . '-table') { |
|
125 | 124 | //ob_get_clean(); |
126 | 125 | //ob_start('ob_gzhandler'); |
127 | 126 | if (!self::$export) { |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | } else { |
29 | 29 | $filterBy = self::$cols[$filterBy][1]; |
30 | 30 | } |
31 | - $filterBy = 'CONCAT(" ",'.$filterBy.', " ")'; |
|
31 | + $filterBy = 'CONCAT(" ",' . $filterBy . ', " ")'; |
|
32 | 32 | if (self::config('FILTER_CASE_SENSITIVE') !== true) { |
33 | - $filterBy .= ' COLLATE '.self::config('DB_COLLATION_CI'); |
|
33 | + $filterBy .= ' COLLATE ' . self::config('DB_COLLATION_CI'); |
|
34 | 34 | } |
35 | - $filter = $filterBy.' LIKE '.'"%'.$filter.'%"'; |
|
35 | + $filter = $filterBy . ' LIKE ' . '"%' . $filter . '%"'; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | return $filter; |
@@ -45,18 +45,17 @@ discard block |
||
45 | 45 | if (isset($v[2]['sort']) && $v[2]['sort'] === false) { |
46 | 46 | continue; |
47 | 47 | } |
48 | - $all[] = 'IFNULL('.$v[1].', "")'; |
|
48 | + $all[] = 'IFNULL(' . $v[1] . ', "")'; |
|
49 | 49 | } |
50 | 50 | |
51 | - return 'CONCAT('.implode(',', $all).')'; |
|
51 | + return 'CONCAT(' . implode(',', $all) . ')'; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | private static function orderCol() |
55 | 55 | { |
56 | 56 | if (($col = filter_input(INPUT_GET, 'col', FILTER_VALIDATE_INT))) { |
57 | 57 | return isset(self::$cols[$col][2]['sort']) ? |
58 | - self::$cols[$col][2]['sort'] : |
|
59 | - self::$cols[$col][1]; |
|
58 | + self::$cols[$col][2]['sort'] : self::$cols[$col][1]; |
|
60 | 59 | } |
61 | 60 | |
62 | 61 | return self::$t['order']['col']; |
@@ -67,14 +66,12 @@ discard block |
||
67 | 66 | $reset = filter_has_var(INPUT_GET, 'col') ? 'asc' : null; |
68 | 67 | |
69 | 68 | return in_array(filter_input(INPUT_GET, 'ord'), ['asc', 'desc']) ? |
70 | - filter_input(INPUT_GET, 'ord') : |
|
71 | - ($reset ?: self::$t['order']['dir']); |
|
69 | + filter_input(INPUT_GET, 'ord') : ($reset ?: self::$t['order']['dir']); |
|
72 | 70 | } |
73 | 71 | |
74 | 72 | private static function setExport() |
75 | 73 | { |
76 | - $exp = filter_input(INPUT_GET, 'export', FILTER_SANITIZE_STRING) ?: |
|
77 | - filter_var(@$_GET['export'], FILTER_SANITIZE_STRING); //4 testing |
|
74 | + $exp = filter_input(INPUT_GET, 'export', FILTER_SANITIZE_STRING) ?: filter_var(@$_GET['export'], FILTER_SANITIZE_STRING); //4 testing |
|
78 | 75 | |
79 | 76 | return in_array($exp, self::config('SAVES')) ? $exp : false; |
80 | 77 | } |
@@ -82,7 +79,6 @@ discard block |
||
82 | 79 | private static function page() |
83 | 80 | { |
84 | 81 | return filter_has_var(INPUT_GET, 'pg') && self::$export == false ? |
85 | - (int) filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) : |
|
86 | - self::$t['page']; |
|
82 | + (int) filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) : self::$t['page']; |
|
87 | 83 | } |
88 | 84 | } |