| @@ -37,8 +37,7 @@ discard block | ||
| 37 | 37 |      { | 
| 38 | 38 |          if (($col = filter_input(INPUT_GET, 'col', FILTER_VALIDATE_INT))) { | 
| 39 | 39 | return isset(self::$cols[$col][2]['sort']) ? | 
| 40 | - self::$cols[$col][2]['sort'] : | |
| 41 | - self::$cols[$col][1]; | |
| 40 | + self::$cols[$col][2]['sort'] : self::$cols[$col][1]; | |
| 42 | 41 | } | 
| 43 | 42 | return self::$t['order']['col']; | 
| 44 | 43 | } | 
| @@ -47,8 +46,7 @@ discard block | ||
| 47 | 46 |      { | 
| 48 | 47 | $reset = filter_has_var(INPUT_GET, 'col') ? 'asc' : null; | 
| 49 | 48 | return in_array(filter_input(INPUT_GET, 'ord'), ['asc', 'desc']) ? | 
| 50 | - filter_input(INPUT_GET, 'ord') : | |
| 51 | - ($reset ?: self::$t['order']['dir']); | |
| 49 | + filter_input(INPUT_GET, 'ord') : ($reset ?: self::$t['order']['dir']); | |
| 52 | 50 | } | 
| 53 | 51 | |
| 54 | 52 | private static function requestExport() | 
| @@ -60,7 +58,6 @@ discard block | ||
| 60 | 58 | private static function requestPage() | 
| 61 | 59 |      { | 
| 62 | 60 | return filter_has_var(INPUT_GET, 'pg') && self::$export == false ? | 
| 63 | - (int) filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) : | |
| 64 | - self::$t['page']; | |
| 61 | + (int)filter_input(INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT) : self::$t['page']; | |
| 65 | 62 | } | 
| 66 | 63 | } | 
| @@ -25,8 +25,7 @@ discard block | ||
| 25 | 25 | public static function prepare($setOrCheck = false) | 
| 26 | 26 |      { | 
| 27 | 27 | //@see http://php.net/manual/es/function.filter-input.php#77307 | 
| 28 | - $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?: | |
| 29 | - filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL); | |
| 28 | + $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL) ?: filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL); | |
| 30 | 29 | |
| 31 | 30 | $extension = pathinfo(strtok($uri, '?'), PATHINFO_EXTENSION); | 
| 32 | 31 | |
| @@ -79,7 +78,7 @@ discard block | ||
| 79 | 78 | |
| 80 | 79 | $filter = self::requestFilter(); | 
| 81 | 80 | $order = [self::$t['order']['col'] => self::$t['order']['dir']]; | 
| 82 | - $offset = (self::$t['page'] - 1) * self::$t['paging']; | |
| 81 | + $offset = (self::$t['page'] - 1)*self::$t['paging']; | |
| 83 | 82 | $limit = [$offset, self::$t['paging']]; | 
| 84 | 83 | self::$t['q'] = self::q($q, $filter, $order, $limit, true); | 
| 85 | 84 | |
| @@ -14,13 +14,12 @@ discard block | ||
| 14 | 14 | |
| 15 | 15 | $limit = 10; | 
| 16 | 16 | |
| 17 | - $v['start'] = $v['page'] > ($limit / 2) ? | |
| 18 | - ($v['page'] - $limit / 2) : | |
| 19 | - 1; | |
| 17 | + $v['start'] = $v['page'] > ($limit/2) ? | |
| 18 | + ($v['page'] - $limit/2) : 1; | |
| 20 | 19 | |
| 21 | -            if ($v['page'] > ($v['pages'] - ($limit / 2))) { | |
| 20 | +            if ($v['page'] > ($v['pages'] - ($limit/2))) { | |
| 22 | 21 | $v['final'] = $v['pages']; | 
| 23 | -            } else if ($v['page'] > ($limit / 2)) { | |
| 22 | +            } else if ($v['page'] > ($limit/2)) { | |
| 24 | 23 | $v['final'] = $v['start'] + $limit; | 
| 25 | 24 |              } else { | 
| 26 | 25 | $v['final'] = $limit; | 
| @@ -44,12 +43,11 @@ discard block | ||
| 44 | 43 | $add = '<li class="jump"><a>' . self::jumps($m, $direction) . '</a></li>'; | 
| 45 | 44 | |
| 46 | 45 | $jump_exists = $direction === '-' ? | 
| 47 | - (self::$t['page'] - $m) > 0 : | |
| 48 | - (self::$t['page'] + $m) <= self::$t['pages']; | |
| 46 | + (self::$t['page'] - $m) > 0 : (self::$t['page'] + $m) <= self::$t['pages']; | |
| 49 | 47 | |
| 50 | 48 |          if ($jump_exists) { | 
| 51 | 49 | $html = $direction === '-' ? $add . $html : $html . $add; | 
| 52 | - return self::pagingJumps($html, ($m * 10)); | |
| 50 | + return self::pagingJumps($html, ($m*10)); | |
| 53 | 51 | } | 
| 54 | 52 | |
| 55 | 53 | return $html; | 
| @@ -58,9 +56,9 @@ discard block | ||
| 58 | 56 | private static function jumps($m, $direction) | 
| 59 | 57 |      { | 
| 60 | 58 |          if ($m >= 1000000) { | 
| 61 | - return ($direction . ($m / 1000000) . "M"); | |
| 59 | + return ($direction . ($m/1000000) . "M"); | |
| 62 | 60 |          } else if ($m >= 1000) { | 
| 63 | - return ($direction . ($m / 1000) . "K"); | |
| 61 | + return ($direction . ($m/1000) . "K"); | |
| 64 | 62 |          } else { | 
| 65 | 63 | return ($direction . $m); | 
| 66 | 64 | } | 
| @@ -46,8 +46,7 @@ discard block | ||
| 46 | 46 | private static function tagAttributes($tag, $items) | 
| 47 | 47 |      { | 
| 48 | 48 | $attr = $tag === 'div' ? | 
| 49 | - ['id' => $items . '-list', 'class' => 'table'] : | |
| 50 | - ['id' => $items . '-table', 'data-table' => 'js']; | |
| 49 | + ['id' => $items . '-list', 'class' => 'table'] : ['id' => $items . '-table', 'data-table' => 'js']; | |
| 51 | 50 |          if (array_key_exists($tag, self::$attributes)) { | 
| 52 | 51 | $attr += self::$attributes[$tag]; | 
| 53 | 52 | } | 
| @@ -82,8 +81,7 @@ discard block | ||
| 82 | 81 |          if (isset($arg['width'])) { // Width attribute -> style | 
| 83 | 82 | $width = 'width:' . $arg['width'] . ';'; | 
| 84 | 83 | $arg['style'] = isset($arg['style']) ? | 
| 85 | - $width . $arg['style'] : | |
| 86 | - $width; | |
| 84 | + $width . $arg['style'] : $width; | |
| 87 | 85 | } | 
| 88 | 86 | |
| 89 | 87 |          if (($del = isset($arg['type']) && $arg['type'] == 'delete')) { | 
| @@ -92,7 +90,7 @@ discard block | ||
| 92 | 90 | $sort = isset($arg['sort']) ? $arg['sort'] : $col; | 
| 93 | 91 | } | 
| 94 | 92 | |
| 95 | - return array_diff_key((array) $arg, ['sort', 'type', 'width']); | |
| 93 | + return array_diff_key((array)$arg, ['sort', 'type', 'width']); | |
| 96 | 94 | } | 
| 97 | 95 | |
| 98 | 96 | private static function th($i, $attr, $sort, $del, $lbl) | 
| @@ -104,8 +102,7 @@ discard block | ||
| 104 | 102 |          if (!$del) { | 
| 105 | 103 |              if ($sort == self::$t['order']['col']) { | 
| 106 | 104 | $span = self::$t['order']['dir'] === 'desc' ? | 
| 107 | -                        self::config('UTF8_DESC_SYMBOL') : | |
| 108 | -                        self::config('UTF8_ASC_SYMBOL'); | |
| 105 | +                        self::config('UTF8_DESC_SYMBOL') : self::config('UTF8_ASC_SYMBOL'); | |
| 109 | 106 |              } else { | 
| 110 | 107 | $span = ""; | 
| 111 | 108 | } | 
| @@ -48,16 +48,14 @@ discard block | ||
| 48 | 48 | $rows = [$header]; | 
| 49 | 49 | |
| 50 | 50 | $data = self::$exportDataAsDisplayed ? | 
| 51 | - self::$data : | |
| 52 | - self::select(self::$t['q']); | |
| 51 | + self::$data : self::select(self::$t['q']); | |
| 53 | 52 | |
| 54 | 53 |          if (count($data) > 0) { | 
| 55 | 54 |              foreach ($data as $row) { | 
| 56 | 55 | $cells = []; | 
| 57 | -                foreach($columns as $column){ | |
| 56 | +                foreach ($columns as $column) { | |
| 58 | 57 | $cells[] = is_array($row[$column]) ? | 
| 59 | - $row[$column][0] : | |
| 60 | - $row[$column]; | |
| 58 | + $row[$column][0] : $row[$column]; | |
| 61 | 59 | } | 
| 62 | 60 | $rows[] = $cells; | 
| 63 | 61 | } | 
| @@ -95,8 +93,7 @@ discard block | ||
| 95 | 93 |                  if (($output = fopen('php://output', 'w'))) { | 
| 96 | 94 |                      foreach ($eData as $v) { | 
| 97 | 95 | self::$export === 'CSV' ? | 
| 98 | - fputcsv($output, $v) : | |
| 99 | -                                        fputs($output, implode("\t", array_map($escape, $v)) . "\r\n"); | |
| 96 | +                                        fputcsv($output, $v) : fputs($output, implode("\t", array_map($escape, $v)) . "\r\n"); | |
| 100 | 97 | } | 
| 101 | 98 | fclose($output); | 
| 102 | 99 | } | 
| @@ -38,12 +38,11 @@ discard block | ||
| 38 | 38 |              $q = 'SELECT COUNT(*) FROM (' . self::$t['qAll'] . ') AS dt'; | 
| 39 | 39 | self::$t['rows'] = self::select($q); | 
| 40 | 40 | } | 
| 41 | - self::$t['pages'] = ceil(self::$t['rows'] / self::$t['paging']); | |
| 41 | + self::$t['pages'] = ceil(self::$t['rows']/self::$t['paging']); | |
| 42 | 42 | |
| 43 | - $v['from'] = ($pageNo - 1) * self::$t['paging'] + 1; | |
| 44 | - $v['upto'] = ($pageNo * self::$t['paging'] < self::$t['rows']) ? | |
| 45 | - $pageNo * self::$t['paging'] : | |
| 46 | - self::$t['rows']; | |
| 43 | + $v['from'] = ($pageNo - 1)*self::$t['paging'] + 1; | |
| 44 | + $v['upto'] = ($pageNo*self::$t['paging'] < self::$t['rows']) ? | |
| 45 | + $pageNo*self::$t['paging'] : self::$t['rows']; | |
| 47 | 46 | |
| 48 | 47 | $v["total"] = self::$t['rows']; | 
| 49 | 48 | $v["items"] = self::$t['items']; | 
| @@ -69,9 +68,8 @@ discard block | ||
| 69 | 68 | $select = static::$select; | 
| 70 | 69 | $res = $select($expression, $bindings); | 
| 71 | 70 | //if result is single cell value ($res[0]->value), return the value | 
| 72 | - return (count($res) === 1 && count((array) $res[0]) === 1) ? | |
| 73 | - reset($res[0]) : | |
| 74 | - $res; | |
| 71 | + return (count($res) === 1 && count((array)$res[0]) === 1) ? | |
| 72 | + reset($res[0]) : $res; | |
| 75 | 73 |          } else { | 
| 76 | 74 |              throw new Exception('ERROR: table::$select is not a closure. '); | 
| 77 | 75 | } | 
| @@ -46,7 +46,7 @@ discard block | ||
| 46 | 46 |              switch (gettype($c)) { | 
| 47 | 47 | case 'array'; | 
| 48 | 48 |                      foreach ($c as $k => $v) { | 
| 49 | - self::$config[$k] = self::getValid((string) $k, $v); | |
| 49 | + self::$config[$k] = self::getValid((string)$k, $v); | |
| 50 | 50 | } | 
| 51 | 51 | break; | 
| 52 | 52 | case 'string': | 
| @@ -163,7 +163,7 @@ discard block | ||
| 163 | 163 | extract($vars); | 
| 164 | 164 | ob_start(); | 
| 165 | 165 | require $template; | 
| 166 | - return (string) ob_get_clean(); | |
| 166 | + return (string)ob_get_clean(); | |
| 167 | 167 | } | 
| 168 | 168 | /* * Makes code radey for the next table | 
| 169 | 169 | * @param type $tableId |