@@ -57,8 +57,7 @@ |
||
| 57 | 57 | $orderBy, |
| 58 | 58 | $orderDir = 'asc', |
| 59 | 59 | $paging = 10 |
| 60 | - ) |
|
| 61 | - { |
|
| 60 | + ) { |
|
| 62 | 61 | self::reset((self::$t['items'] = (string) $items)); |
| 63 | 62 | self::prepare(true); |
| 64 | 63 | self::$t['order']['col'] = $orderBy; |
@@ -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,20 +85,19 @@ 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 | { |
| 92 | 90 | return str_replace("\t", '	', $value); |
| 93 | 91 | }; |
| 94 | 92 | header('Content-Type:application/csv'); |
| 95 | - header('Content-Disposition:attachment; filename='. |
|
| 96 | - $filename.'.csv'); |
|
| 93 | + header('Content-Disposition:attachment; filename=' . |
|
| 94 | + $filename . '.csv'); |
|
| 97 | 95 | |
| 98 | 96 | if (($output = fopen('php://output', 'w'))) { |
| 99 | 97 | foreach ($eData as $v) { |
| 100 | 98 | self::$export === 'CSV' ? |
| 101 | - fputcsv($output, $v) : |
|
| 102 | - fwrite($output, |
|
| 103 | - implode("\t", array_map($escape, $v))."\r\n"); |
|
| 99 | + fputcsv($output, $v) : fwrite($output, |
|
| 100 | + implode("\t", array_map($escape, $v)) . "\r\n"); |
|
| 104 | 101 | } |
| 105 | 102 | fclose($output); |
| 106 | 103 | } |
@@ -114,7 +111,7 @@ discard block |
||
| 114 | 111 | $fnReplace[':app'] = self::config('APP'); |
| 115 | 112 | $fnReplace[':items'] = self::$t['items']; |
| 116 | 113 | $format = str_replace(':', '.', '%d.%m.%Y %H:%i:%s'); |
| 117 | - $timeQuery = 'SELECT DATE_FORMAT(Now(), "'.$format.'") AS `now`;'; |
|
| 114 | + $timeQuery = 'SELECT DATE_FORMAT(Now(), "' . $format . '") AS `now`;'; |
|
| 118 | 115 | $fnReplace[':datetime'] = self::select($timeQuery); |
| 119 | 116 | |
| 120 | 117 | return strtr((string) self::config('EXPORT_FILE_NAME'), $fnReplace); |
@@ -87,8 +87,7 @@ |
||
| 87 | 87 | switch (self::$export) { |
| 88 | 88 | case 'Excel': |
| 89 | 89 | case 'CSV': |
| 90 | - $escape = function ($value) |
|
| 91 | - { |
|
| 90 | + $escape = function ($value) { |
|
| 92 | 91 | return str_replace("\t", '	', $value); |
| 93 | 92 | }; |
| 94 | 93 | header('Content-Type:application/csv'); |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | $vars = []; |
| 18 | 18 | self::showingMessageVars($vars); |
| 19 | 19 | if (self::$exportActive === true) { |
| 20 | - $url = strtok(self::$t['slug'], '?&').'.json?table='. |
|
| 21 | - self::$t['items'].'&export='; |
|
| 20 | + $url = strtok(self::$t['slug'], '?&') . '.json?table=' . |
|
| 21 | + self::$t['items'] . '&export='; |
|
| 22 | 22 | $vars['export']['url'] = $url; |
| 23 | 23 | $vars['export']['types'] = self::config('SAVES'); |
| 24 | 24 | } |
@@ -38,15 +38,14 @@ discard block |
||
| 38 | 38 | //Skips total count query |
| 39 | 39 | self::$t['rows'] = count(self::$data); |
| 40 | 40 | } else { |
| 41 | - $query = 'SELECT COUNT(*) FROM ('.self::$t['qAll'].') AS dt'; |
|
| 41 | + $query = 'SELECT COUNT(*) FROM (' . self::$t['qAll'] . ') AS dt'; |
|
| 42 | 42 | self::$t['rows'] = self::select($query); |
| 43 | 43 | } |
| 44 | - self::$t['pages'] = ceil(self::$t['rows'] / self::$t['paging']); |
|
| 44 | + self::$t['pages'] = ceil(self::$t['rows']/self::$t['paging']); |
|
| 45 | 45 | |
| 46 | - $vars['from'] = ($pageNo - 1) * self::$t['paging'] + 1; |
|
| 47 | - $vars['upto'] = ($pageNo * self::$t['paging'] < self::$t['rows']) ? |
|
| 48 | - $pageNo * self::$t['paging'] : |
|
| 49 | - self::$t['rows']; |
|
| 46 | + $vars['from'] = ($pageNo - 1)*self::$t['paging'] + 1; |
|
| 47 | + $vars['upto'] = ($pageNo*self::$t['paging'] < self::$t['rows']) ? |
|
| 48 | + $pageNo*self::$t['paging'] : self::$t['rows']; |
|
| 50 | 49 | |
| 51 | 50 | $vars['total'] = self::$t['rows']; |
| 52 | 51 | $vars['items'] = self::$t['items']; |
@@ -57,11 +56,11 @@ discard block |
||
| 57 | 56 | $trs = ''; |
| 58 | 57 | if (self::$t['rows'] > 0) { |
| 59 | 58 | $ftr = self::jsonTfoot()[0][0]; |
| 60 | - $trs .= '<tr><td'.self::attributes($ftr[1]).'>' |
|
| 61 | - .$ftr[0].'</td></tr>'; |
|
| 59 | + $trs .= '<tr><td' . self::attributes($ftr[1]) . '>' |
|
| 60 | + .$ftr[0] . '</td></tr>'; |
|
| 62 | 61 | } elseif (count(self::$errors) > 0) { |
| 63 | - $trs .= '<tr><td colspan="'.count(self::$cols).'">'. |
|
| 64 | - self::error().'</td></tr>'; |
|
| 62 | + $trs .= '<tr><td colspan="' . count(self::$cols) . '">' . |
|
| 63 | + self::error() . '</td></tr>'; |
|
| 65 | 64 | } |
| 66 | 65 | |
| 67 | 66 | return $trs; |
@@ -74,8 +73,7 @@ discard block |
||
| 74 | 73 | $res = $select($expression, $bindings); |
| 75 | 74 | //if result is single cell value ($res[0]->value), return the value |
| 76 | 75 | return (count($res) === 1 && count((array) $res[0]) === 1) ? |
| 77 | - reset($res[0]) : |
|
| 78 | - $res; |
|
| 76 | + reset($res[0]) : $res; |
|
| 79 | 77 | } else { |
| 80 | 78 | throw new Exception('ERROR: table::$select is not a closure. '); |
| 81 | 79 | } |