Passed
Branchmaster (a3945e)
by Plamen
02:34
created
table_getter.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     public static $pageExt;
19 19
 
20 20
     protected static function ths() {
21
-		if (self::$cols) {
21
+        if (self::$cols) {
22 22
             $ths = [];
23 23
             for ($i = 0; $i < sizeof(self::$cols); $i++) {
24 24
                 list($lbl, $col, $arg) = array_pad(self::$cols[$i], 3, null);
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
                 $ths[] = $th;
75 75
             }
76 76
             return implode('', $ths);
77
-		}
78
-	}
77
+        }
78
+    }
79 79
 
80 80
     /** Adds conditions, orderBy and Limits to query.
81 81
      * @param string $q
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                 '';
104 104
 
105 105
         return $q . $c . $o . $l;
106
-	}
106
+    }
107 107
 
108 108
     protected static function exportData(){
109 109
         $data = self::$exportDataAsDisplayed ?
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 
201 201
             if(self::$exportActive === true){
202 202
                 $url = strtok(self::$t['slug'],"?&") . ".json?table=" .
203
-                       self::$t['items'] . "&export=";
203
+                        self::$t['items'] . "&export=";
204 204
                 $v["export"] = ["url"=>$url, "types"=>self::config('SAVES')];
205 205
             }
206 206
 
Please login to merge, or discard this patch.
Spacing   +57 added lines, -66 removed lines patch added patch discarded remove patch
@@ -23,51 +23,48 @@  discard block
 block discarded – undo
23 23
             for ($i = 0; $i < sizeof(self::$cols); $i++) {
24 24
                 list($lbl, $col, $arg) = array_pad(self::$cols[$i], 3, null);
25 25
 
26
-                if(is_null($col)){ $arg['sort']=false;}
26
+                if (is_null($col)) { $arg['sort'] = false; }
27 27
 
28 28
                 $sortable = !isset($arg['sort']) || $arg['sort'] !== false;
29 29
 
30 30
                 $sort = $sortable ?
31
-                        (isset($arg['sort']) ? $arg['sort'] : $col) :
32
-                        null;
31
+                        (isset($arg['sort']) ? $arg['sort'] : $col) : null;
33 32
 
34
-                if(($del = isset($arg['type']) && $arg['type'] == 'delete')){
33
+                if (($del = isset($arg['type']) && $arg['type'] == 'delete')) {
35 34
                     $sortable = false;
36
-                    if(!isset($arg['width']) &&
35
+                    if (!isset($arg['width']) &&
37 36
                         false === strpos($arg['width'], 'width:')
38 37
                     ) {
39 38
                         $arg['width'] = '1%';
40 39
                     }
41 40
                 }
42 41
 
43
-                if(isset($arg['width'])) { // Width attribute -> style
42
+                if (isset($arg['width'])) { // Width attribute -> style
44 43
                     $width = 'width:' . $arg['width'] . ';';
45 44
                     $arg['style'] = isset($arg['style']) ?
46
-                                    $width . $arg['style'] :
47
-                                    $width;
45
+                                    $width . $arg['style'] : $width;
48 46
                 }
49 47
 
50 48
                 $attr = array_diff_key((array)$arg, ['sort', 'type', 'width']);
51 49
 
52 50
                 $th = '<th' . self::attributes($attr) . '>';
53
-                if($sortable){
51
+                if ($sortable) {
54 52
                     $th .= '<a onclick="table.Sort(' . $i . ',this);">';
55 53
                 }
56 54
                 if (!$del) {
57
-                    if($sort == self::$t['order']['col']) {
55
+                    if ($sort == self::$t['order']['col']) {
58 56
                         $span = self::$t['order']['dir'] === 'desc' ?
59
-                                self::config('UTF8_DESC_SYMBOL') :
60
-                                self::config('UTF8_ASC_SYMBOL');
57
+                                self::config('UTF8_DESC_SYMBOL') : self::config('UTF8_ASC_SYMBOL');
61 58
                     } else {
62 59
                         $span = "";
63 60
                     }
64 61
                     $th .= '<span>' . $span . '</span>' . $lbl;
65 62
                 } else {					
66
-                    $th .=  '<input id="'.self::$t['items'].'CheckDeleteAll"' .
63
+                    $th .= '<input id="' . self::$t['items'] . 'CheckDeleteAll"' .
67 64
                             ' onclick=\"checkAllDeleteCheckboxes(this,' .
68
-                            ' \''.self::$t['items'].'\')" type="checkbox"/>';
65
+                            ' \'' . self::$t['items'] . '\')" type="checkbox"/>';
69 66
                 }
70
-                if($sortable){
67
+                if ($sortable) {
71 68
                     $th .= '</a>';
72 69
                 }
73 70
                 $th .= '</th>';
@@ -84,11 +81,10 @@  discard block
 block discarded – undo
84 81
      * @param int|arr $limit -> 5 or [$start, $count]
85 82
      * @param bool $h Having flag - to use HAVING instead of WHERE
86 83
      * @return (string) */
87
-    protected static function q($q, $cond=null, $order=[], $limit=0, $h=false){
84
+    protected static function q($q, $cond = null, $order = [], $limit = 0, $h = false) {
88 85
         //Condition: '' | '(HAVING|WHERE|AND) ' . $cond
89
-        $c = !empty($cond) && !strpos($q, ($cl = !$h  ? 'WHERE' : 'HAVING')) ?
90
-                (' ' . (!strpos($q, $cl) ? $cl : ' AND ') .' ' . $cond ) :
91
-                '';
86
+        $c = !empty($cond) && !strpos($q, ($cl = !$h ? 'WHERE' : 'HAVING')) ?
87
+                (' ' . (!strpos($q, $cl) ? $cl : ' AND ') . ' ' . $cond) : '';
92 88
         //Order: '' | 'ORDER BY ' . array_keys($order)[0] . ' ' . $order[0]
93 89
         $o = !empty($order) ?
94 90
                 ' ORDER BY ' . implode(', ',
@@ -99,35 +95,33 @@  discard block
 block discarded – undo
99 95
                 '';
100 96
         //Limit: '' | ' LIMIT ' . '(20, 40|20)'
101 97
         $l = !empty($limit) ?
102
-                (' LIMIT ' . (is_array($limit) ? implode(', ',$limit) : $limit)) :
103
-                '';
98
+                (' LIMIT ' . (is_array($limit) ? implode(', ', $limit) : $limit)) : '';
104 99
 
105 100
         return $q . $c . $o . $l;
106 101
 	}
107 102
 
108
-    protected static function exportData(){
103
+    protected static function exportData() {
109 104
         $data = self::$exportDataAsDisplayed ?
110
-                self::$data :
111
-                self::select(self::$t['q']);
105
+                self::$data : self::select(self::$t['q']);
112 106
         $fnReplace = [];
113
-        $fnReplace[':app']= self::$app;
114
-        $fnReplace[':items']= self::$t['items'];
107
+        $fnReplace[':app'] = self::$app;
108
+        $fnReplace[':items'] = self::$t['items'];
115 109
         $format = str_replace(':', ' ', GLOBAL_MYSQL_DATETIME_LONG);
116 110
         $timeQuery = 'SELECT DATE_FORMAT(Now(), "' . $format . '") AS `now`;';
117 111
         $fnReplace[':datetime'] = self::select($timeQuery);
118 112
         $outFilename = strtr(self::config('EXPORT_FILE_NAME'), $fnReplace);
119 113
         $outColumns = [];
120
-        foreach(self::$cols as $c){
121
-            if(isset($c[2]['sort']) && $c[2]['sort']===false){continue;}
114
+        foreach (self::$cols as $c) {
115
+            if (isset($c[2]['sort']) && $c[2]['sort'] === false) {continue; }
122 116
             $outColumns[] = $c[1];
123 117
             $outHeader[] = $c[0];
124 118
         }
125 119
         $eData = [$outHeader];
126
-        if(count($data) > 0) {
127
-            foreach($data as $k => $row){
120
+        if (count($data) > 0) {
121
+            foreach ($data as $k => $row) {
128 122
                 $rowData = [];
129
-                foreach($row as $dbName => $value){
130
-                    if(in_array($dbName,$outColumns)){
123
+                foreach ($row as $dbName => $value) {
124
+                    if (in_array($dbName, $outColumns)) {
131 125
                         $rowData[] = is_array($value) ? $value[0] : $value;
132 126
                     }
133 127
                 }
@@ -135,71 +129,69 @@  discard block
 block discarded – undo
135 129
             }
136 130
         }
137 131
 
138
-        switch(self::$export){
132
+        switch (self::$export) {
139 133
             case 'Excel':
140 134
             case 'CSV':
141
-                $escape = function($v){ return str_replace("\t", "&#9;" ,$v); };
135
+                $escape = function($v) { return str_replace("\t", "&#9;", $v); };
142 136
                 header('Content-Type:application/csv');
143 137
                 header('Content-Disposition:attachment; filename=' .
144 138
                         $outFilename . '.csv');
145
-                $output = fopen('php://output','w')
139
+                $output = fopen('php://output', 'w')
146 140
                           or die('Can\'t open php://output');
147
-                foreach($eData as $v){
141
+                foreach ($eData as $v) {
148 142
                     self::$export === 'CSV' ?
149
-                    fputcsv($output, $v) :
150
-                    fputs($output, implode("\t",array_map($escape, $v))."\r\n");
143
+                    fputcsv($output, $v) : fputs($output, implode("\t", array_map($escape, $v)) . "\r\n");
151 144
                 }
152 145
                 fclose($output) or die('Can\'t close php://output');
153 146
                 break;
154 147
         }
155 148
     }
156 149
 
157
-    protected static function jsonGetBodyData(){
150
+    protected static function jsonGetBodyData() {
158 151
         $json = $outColumns = [];
159
-        foreach(self::$cols as $c){
152
+        foreach (self::$cols as $c) {
160 153
             $outColumns[] = isset($c[1]) ? $c[1] : null;
161 154
         }
162
-        if((self::$t['rows'] = count(self::$data)) > 0) {
163
-            foreach(self::$data as $row){
155
+        if ((self::$t['rows'] = count(self::$data)) > 0) {
156
+            foreach (self::$data as $row) {
164 157
                 $rowData = [];
165
-                foreach($outColumns as $dbName){
158
+                foreach ($outColumns as $dbName) {
166 159
                         $rowData[] = array_key_exists($dbName, $row) ?
167 160
                                      $row[$dbName] : '';
168 161
                 }
169 162
                 $json[] = $rowData;
170 163
             }
171 164
         } else {
172
-            $attr = ['colspan'=>count(self::$cols),'class'=>'no-results'];
165
+            $attr = ['colspan'=>count(self::$cols), 'class'=>'no-results'];
173 166
             $json[] = [[self::config('EMPTY_TABLE_MSG'), $attr]];
174 167
         }
175 168
         return $json;
176 169
     }
177 170
 
178
-    protected static function jsonGetFooterData(){
171
+    protected static function jsonGetFooterData() {
179 172
         $jsonArrFooter = [];
180
-        if(count(self::$data) > 0) {
173
+        if (count(self::$data) > 0) {
181 174
             $pageNo = self::$t['page'];
182
-            if($pageNo === 1 && count(self::$data) < self::$t['paging'] ){
175
+            if ($pageNo === 1 && count(self::$data) < self::$t['paging']) {
183 176
                 //Skips total count query
184 177
                 self::$t['rows'] = count(self::$data);
185 178
             } else {
186
-                $q = 'SELECT COUNT(*) FROM ('. self::$t['qAll'] .') AS dt';
179
+                $q = 'SELECT COUNT(*) FROM (' . self::$t['qAll'] . ') AS dt';
187 180
                 self::$t['rows'] = self::select($q);
188 181
             }
189 182
             self::$t['pages'] = ceil(self::$t['rows']/self::$t['paging']);
190 183
 
191 184
             $v = [];
192 185
 
193
-            $v['from'] = ($pageNo-1) * self::$t['paging'] + 1;
186
+            $v['from'] = ($pageNo - 1)*self::$t['paging'] + 1;
194 187
             $v['upto'] = ($pageNo*self::$t['paging'] < self::$t['rows']) ?
195
-                         $pageNo*self::$t['paging'] :
196
-                         self::$t['rows'];
188
+                         $pageNo*self::$t['paging'] : self::$t['rows'];
197 189
 
198 190
             $v["total"] = self::$t['rows'];
199 191
             $v["items"] = self::$t['items'];
200 192
 
201
-            if(self::$exportActive === true){
202
-                $url = strtok(self::$t['slug'],"?&") . ".json?table=" .
193
+            if (self::$exportActive === true) {
194
+                $url = strtok(self::$t['slug'], "?&") . ".json?table=" .
203 195
                        self::$t['items'] . "&export=";
204 196
                 $v["export"] = ["url"=>$url, "types"=>self::config('SAVES')];
205 197
             }
@@ -208,7 +200,7 @@  discard block
 block discarded – undo
208 200
 
209 201
             $html = self::view('views/table.footer.html', $v);
210 202
 
211
-            $jsonArrFooter[] = [[$html,["colspan"=>count(self::$cols)]]];
203
+            $jsonArrFooter[] = [[$html, ["colspan"=>count(self::$cols)]]];
212 204
         }
213 205
         return $jsonArrFooter;
214 206
     }
@@ -217,20 +209,20 @@  discard block
 block discarded – undo
217 209
         $items = self::$t['items'];
218 210
         $v = ['items' => $items];
219 211
         $div_attr = ['id'=>$items . '-list', 'class'=>'table'];
220
-        if(array_key_exists('div', self::$attributes)){
212
+        if (array_key_exists('div', self::$attributes)) {
221 213
             $div_attr += self::$attributes['div'];
222 214
         }
223
-        if(isset(self::$attributes['div']['class'])){
215
+        if (isset(self::$attributes['div']['class'])) {
224 216
             $div_attr['class'] .= ' ' . self::$attributes['div']['class'];
225 217
         }
226 218
         $v['div_attributes'] = self::attributes($div_attr);
227 219
 
228
-        if(self::$filterActive){
220
+        if (self::$filterActive) {
229 221
             self::filterValues($v['f_value'], $v['f_options']);
230 222
         }
231 223
 
232 224
         $tbl_attr = ['id'=>$items . '-table', 'data-table'=>'js'];
233
-        if(array_key_exists('table', self::$attributes)){
225
+        if (array_key_exists('table', self::$attributes)) {
234 226
             $tbl_attr += self::$attributes['table'];
235 227
         }
236 228
         $v['table_attributes'] = self::attributes($tbl_attr);
@@ -259,7 +251,7 @@  discard block
 block discarded – undo
259 251
                             . '</td></tr>';
260 252
                 }
261 253
             }
262
-        } else if($for === 'footer') {
254
+        } else if ($for === 'footer') {
263 255
             if (self::$t['rows'] > 0) {
264 256
                 $ftr = self::jsonGetFooterData()[0][0];
265 257
                 $trs .= '<tr><td' . self::attributes($ftr[1]) . '>'
@@ -269,8 +261,8 @@  discard block
 block discarded – undo
269 261
         return $trs;
270 262
     }
271 263
 
272
-    protected static function reset($tableId){
273
-        if(!in_array($tableId, self::$t["tables"])){
264
+    protected static function reset($tableId) {
265
+        if (!in_array($tableId, self::$t["tables"])) {
274 266
             self::$t["tables"][] = $tableId;
275 267
             self::$cols = [];
276 268
             self::$t['rows'] = null;
@@ -279,17 +271,16 @@  discard block
 block discarded – undo
279 271
         }
280 272
     }
281 273
 
282
-    static function select(string $expression, array $bindings = []){
283
-        if(is_object(static::$select) && (static::$select instanceof Closure)){
274
+    static function select(string $expression, array $bindings = []) {
275
+        if (is_object(static::$select) && (static::$select instanceof Closure)) {
284 276
             $select = static::$select;
285 277
             $res = $select($expression, $bindings);
286 278
             //if result is single cell value ($res[0]->value), return the value
287 279
             return (count($res) === 1 && count((array)$res[0]) === 1) ?
288
-                    reset($res[0]) :
289
-                    $res;
280
+                    reset($res[0]) : $res;
290 281
         } else {
291 282
             die('ERROR: table::$select is not a valid closure. '
292
-                .__METHOD__.'() #'.__LINE__);
283
+                .__METHOD__ . '() #' . __LINE__);
293 284
         }
294 285
     }
295 286
 }
Please login to merge, or discard this patch.
table_setter.php 1 patch
Spacing   +44 added lines, -47 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
     /** @param array Re-settable values for current table call*/
13 13
     protected static $config;
14 14
 
15
-    static function assets($path = "/public/table"){
15
+    static function assets($path = "/public/table") {
16 16
         return  "<script src=\"{$path}/table.js\"></script>\n\t" .
17 17
                 "<link href=\"{$path}/table.css\" rel=\"stylesheet\">\n";
18 18
     }
19 19
 
20
-    public static function config($c){
20
+    public static function config($c) {
21 21
         self::$config = self::$config ?: [
22 22
             'DB_COLLATION_CI' => 'utf8mb4_general_ci', //UTF8_GENERAL_CI
23 23
             'EMPTY_TABLE_MSG' => 'No results found.',
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
             'UTF8_LEFT_SYMBOL' => '&lsaquo;',
30 30
             'UTF8_RIGHT_SYMBOL' => '&rsaquo;'
31 31
         ];
32
-        switch(gettype($c)){
32
+        switch (gettype($c)) {
33 33
             case 'array';
34
-                foreach($c as $k => $v){
34
+                foreach ($c as $k => $v) {
35 35
                     self::$config[$k] = $v;
36 36
                 }
37 37
                 break;
@@ -43,36 +43,36 @@  discard block
 block discarded – undo
43 43
     /** Converts array to space separated key value list
44 44
      * @param array $attributes
45 45
      * @return string */
46
-    protected static function attributes(array $attributes){
46
+    protected static function attributes(array $attributes) {
47 47
         $list = [];
48
-        foreach($attributes as $key => $value){
49
-            if(is_bool($value)) {
50
-                if((bool)$value){
48
+        foreach ($attributes as $key => $value) {
49
+            if (is_bool($value)) {
50
+                if ((bool)$value) {
51 51
                     $list[] = $key;
52 52
                 }
53 53
             } else if (empty($value) && !is_int($value)) {
54 54
                 $list[] = $key;
55 55
             } else {
56
-                $list[] = $key.'="'.$value.'"';
56
+                $list[] = $key . '="' . $value . '"';
57 57
             }
58 58
         }
59
-        return (count($list)>0 ? ' ': '') . join(' ', $list);
59
+        return (count($list) > 0 ? ' ' : '') . join(' ', $list);
60 60
     }
61 61
 
62 62
     /** Parses view to string
63 63
      * @param string $template
64 64
      * @param array $vars
65 65
      * @return string */
66
-    protected static function view($template, $vars = []){
66
+    protected static function view($template, $vars = []) {
67 67
         extract($vars);
68 68
         ob_start();
69 69
         require $template;
70
-        return (string) ob_get_clean();
70
+        return (string)ob_get_clean();
71 71
     }
72 72
 
73 73
     protected static function paging(&$v) {
74
-        if(self::$t['pages'] > 1){
75
-            $v['pages']= self::$t['pages'];
74
+        if (self::$t['pages'] > 1) {
75
+            $v['pages'] = self::$t['pages'];
76 76
             $v['page'] = self::$t['page'];
77 77
             $v['jumpL'] = self::pagingJumps();
78 78
             $v['jumpR'] = self::pagingJumps();
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
 
82 82
             $limit = 10;
83 83
 
84
-            $v['start'] =  $v['page'] > ($limit/2) ? ($v['page']-$limit/2) : 1;
84
+            $v['start'] = $v['page'] > ($limit/2) ? ($v['page'] - $limit/2) : 1;
85 85
 
86
-            if($v['page'] > ($v['pages']-($limit/2))){
86
+            if ($v['page'] > ($v['pages'] - ($limit/2))) {
87 87
                 $v['final'] = $v['pages'];
88
-            } else if($v['page'] > ($limit/2)){
88
+            } else if ($v['page'] > ($limit/2)) {
89 89
                 $v['final'] = $v['start'] + $limit;
90 90
             } else {
91 91
                 $v['final'] = $limit;
@@ -100,58 +100,58 @@  discard block
 block discarded – undo
100 100
     protected static function pagingJumps($html = '', $m = null) {
101 101
         static $direction;
102 102
 
103
-        if(is_null($m)){ //on self::createPaginationLinks() calls only
103
+        if (is_null($m)) { //on self::createPaginationLinks() calls only
104 104
             $direction = !isset($direction) ? '-' : '+';
105 105
             $m = 100;
106 106
         }
107 107
         $jump2show = function($m) use ($direction){
108
-            if(    $m>=1000000){    return ($direction . ($m/1000000)."M");
109
-            } else if($m>=1000){    return ($direction . ($m/1000)."K");
108
+            if ($m >= 1000000) {    return ($direction . ($m/1000000) . "M");
109
+            } else if ($m >= 1000) {    return ($direction . ($m/1000) . "K");
110 110
             } else {                return ($direction . $m); }
111 111
         };
112 112
         $add = '<li class="jump"><a>' . $jump2show($m) . '</a></li>';
113 113
 
114
-        if($direction === '-'){
114
+        if ($direction === '-') {
115 115
             $jump_exists = (self::$t['page'] - $m) > 0;
116 116
         } else {
117 117
             $jump_exists = (self::$t['page'] + $m) <= self::$t['pages'];
118 118
         }
119 119
 
120
-        if($jump_exists){
120
+        if ($jump_exists) {
121 121
             $html = $direction === '-' ? $add . $html : $html . $add;
122 122
         }
123 123
 
124
-        return $jump_exists ? self::pagingJumps($html, ($m * 10)) : $html;
124
+        return $jump_exists ? self::pagingJumps($html, ($m*10)) : $html;
125 125
     }
126 126
 
127
-    protected static function filterValues(&$f, &$opts=[]){
127
+    protected static function filterValues(&$f, &$opts = []) {
128 128
         $f = filter_input(INPUT_GET, 'filter', FILTER_SANITIZE_STRING) ?: null;
129 129
 
130 130
         $by = filter_input(INPUT_GET, 'filter-by', FILTER_VALIDATE_INT);
131
-        foreach(self::$cols as $k => $v){
132
-            if(isset($v[2]['sort']) && $v[2]['sort']===false){continue;}
133
-            if(empty($v)){ $v=[null]; } // fix for column requested as []
131
+        foreach (self::$cols as $k => $v) {
132
+            if (isset($v[2]['sort']) && $v[2]['sort'] === false) {continue; }
133
+            if (empty($v)) { $v = [null]; } // fix for column requested as []
134 134
             $selected = $by === $k ? ' selected' : null;
135 135
             $opts[] = "<option value=\"{$k}\"{$selected}>{$v[0]}</option>";
136 136
         }
137 137
     }
138 138
 
139
-    protected static function requestFilter(){
139
+    protected static function requestFilter() {
140 140
         $filter = filter_input(INPUT_GET, 'filter') ?: false;
141
-        if($filter){
141
+        if ($filter) {
142 142
             $by = filter_input(INPUT_GET, 'filter-by', FILTER_VALIDATE_INT);
143
-            if($by === false || is_null($by)){
143
+            if ($by === false || is_null($by)) {
144 144
                 $by = [];
145
-                foreach(self::$cols as $v){
146
-                    if(isset($v[2]['sort']) && $v[2]['sort']===false){continue;}
145
+                foreach (self::$cols as $v) {
146
+                    if (isset($v[2]['sort']) && $v[2]['sort'] === false) {continue; }
147 147
                     $by[] = 'IFNULL(' . $v[1] . ', "")';
148 148
                 }
149
-                $by = 'CONCAT('.implode(',',$by).')';
149
+                $by = 'CONCAT(' . implode(',', $by) . ')';
150 150
             } else {
151 151
                 $by = self::$cols[$by][1];
152 152
             }
153
-            $by = 'CONCAT(" ",'.$by.', " ")';
154
-            if(self::config('FILTER_CASE_SENSITIVE') !== true) {
153
+            $by = 'CONCAT(" ",' . $by . ', " ")';
154
+            if (self::config('FILTER_CASE_SENSITIVE') !== true) {
155 155
                 $by .= ' COLLATE ' . self::config('DB_COLLATION_CI');
156 156
             }
157 157
             $filter = $by . ' LIKE ' . '"%' . $filter . '%"';
@@ -159,30 +159,27 @@  discard block
 block discarded – undo
159 159
         return $filter;
160 160
     }
161 161
 
162
-    protected static function requestOrderCol(){
163
-        if(($col = filter_input(INPUT_GET, 'col', FILTER_VALIDATE_INT))){
162
+    protected static function requestOrderCol() {
163
+        if (($col = filter_input(INPUT_GET, 'col', FILTER_VALIDATE_INT))) {
164 164
             return  isset(self::$cols[$col][2]['sort']) ?
165
-                    self::$cols[$col][2]['sort'] :
166
-                    self::$cols[$col][1];
165
+                    self::$cols[$col][2]['sort'] : self::$cols[$col][1];
167 166
         }
168 167
         return self::$t['order']['col'];
169 168
     }
170 169
 
171
-    protected static function requestOrderDir(){
170
+    protected static function requestOrderDir() {
172 171
         $reset = filter_has_var(INPUT_GET, 'col') ? 'asc' : null;
173 172
         return  in_array(filter_input(INPUT_GET, 'ord'), ['asc', 'desc']) ?
174
-                filter_input(INPUT_GET, 'ord') :
175
-                ($reset ?: self::$t['order']['dir']);
173
+                filter_input(INPUT_GET, 'ord') : ($reset ?: self::$t['order']['dir']);
176 174
     }
177 175
 
178
-    protected static function requestExport(){
179
-        $exp = filter_input(INPUT_GET,'export', FILTER_SANITIZE_STRING);
176
+    protected static function requestExport() {
177
+        $exp = filter_input(INPUT_GET, 'export', FILTER_SANITIZE_STRING);
180 178
         return  in_array($exp, self::config('SAVES')) ? $exp : false;
181 179
     }
182 180
 
183
-    protected static function requestPage(){
181
+    protected static function requestPage() {
184 182
         return filter_has_var(INPUT_GET, 'pg') && self::$export == false ?
185
-                (int)filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) :
186
-                self::$t['page'];
183
+                (int)filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) : self::$t['page'];
187 184
     }
188 185
 }
Please login to merge, or discard this patch.
table.php 1 patch
Spacing   +4 added lines, -7 removed lines patch added patch discarded remove patch
@@ -33,10 +33,8 @@  discard block
 block discarded – undo
33 33
         self::prepare(true);
34 34
         self::$t['order']['col'] = $orderBy;
35 35
         $dir = strtolower($orderDir);
36
-        self::$t['order']['dir'] = in_array($dir, ['asc', 'desc']) ? $dir :
37
-                die('Invalid orderDir(Asc/Desc): ' . $orderDir);
38
-        self::$t['paging'] = ($p = abs($paging)) > 10 ? $p :
39
-                die('Invalid paging(>10): ' . $paging);
36
+        self::$t['order']['dir'] = in_array($dir, ['asc', 'desc']) ? $dir : die('Invalid orderDir(Asc/Desc): ' . $orderDir);
37
+        self::$t['paging'] = ($p = abs($paging)) > 10 ? $p : die('Invalid paging(>10): ' . $paging);
40 38
     }
41 39
 
42 40
     /** #2. Execute (queries)
@@ -55,7 +53,7 @@  discard block
 block discarded – undo
55 53
 
56 54
         $filter = self::requestFilter();
57 55
         $order = [self::$t['order']['col'] => self::$t['order']['dir']];
58
-        $offset = (self::$t['page'] - 1) * self::$t['paging'];
56
+        $offset = (self::$t['page'] - 1)*self::$t['paging'];
59 57
         $limit = [$offset, self::$t['paging']];
60 58
         self::$t['q'] = self::q($q, $filter, $order, $limit, true);
61 59
 
@@ -99,8 +97,7 @@  discard block
 block discarded – undo
99 97
     public static function prepare($setOrCheck = false)
100 98
     {
101 99
         //@see  http://php.net/manual/es/function.filter-input.php#77307
102
-        $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?:
103
-                filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL);
100
+        $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?: filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL);
104 101
 
105 102
         $extension = pathinfo(strtok($uri, '?'), PATHINFO_EXTENSION);
106 103
 
Please login to merge, or discard this patch.