mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-11-28 02:20:41 +00:00
use table helper
This commit is contained in:
parent
98cb3b042d
commit
799b870f9a
|
|
@ -6,6 +6,7 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Helper\Table;
|
||||||
|
|
||||||
use Seeddms\Seeddms\Settings;
|
use Seeddms\Seeddms\Settings;
|
||||||
use Seeddms\Seeddms\Translator;
|
use Seeddms\Seeddms\Translator;
|
||||||
|
|
@ -48,36 +49,39 @@ class ListcacheCommand extends Command
|
||||||
$outformat = '%-20s %-40s %15s %7d';
|
$outformat = '%-20s %-40s %15s %7d';
|
||||||
require_once('inc/inc.DBInit.php');
|
require_once('inc/inc.DBInit.php');
|
||||||
|
|
||||||
$cachedir = $settings->_cacheDir;
|
$cachedir = $settings->_cacheDir;
|
||||||
$totalc = 0;
|
$totalc = 0;
|
||||||
$totalspace = 0;
|
$totalspace = 0;
|
||||||
// Preview for png, pdf, and txt */
|
$tabledata = [];
|
||||||
foreach(['png', 'pdf', 'txt'] as $t) {
|
// Preview for png, pdf, and txt */
|
||||||
$path = addDirSep($cachedir).$t;
|
foreach(['png', 'pdf', 'txt'] as $t) {
|
||||||
if(file_exists($path)) {
|
$path = addDirSep($cachedir).$t;
|
||||||
$space = dskspace($path);
|
if(file_exists($path)) {
|
||||||
$fi = new FilesystemIterator($path, FilesystemIterator::SKIP_DOTS);
|
$space = dskspace($path);
|
||||||
$c = iterator_count($fi);
|
$fi = new FilesystemIterator($path, FilesystemIterator::SKIP_DOTS);
|
||||||
} else {
|
$c = iterator_count($fi);
|
||||||
$space = $c = 0;
|
} else {
|
||||||
}
|
$space = $c = 0;
|
||||||
$totalc += $c;
|
}
|
||||||
$totalspace += $space;
|
$totalc += $c;
|
||||||
$output->writeln(sprintf($outformat, 'preview'.$t, $translator->translate('preview_'.$t), SeedDMS_Core_File::format_filesize($space), $c));
|
$totalspace += $space;
|
||||||
}
|
// $output->writeln(sprintf($outformat, 'preview'.$t, $translator->translate('preview_'.$t), SeedDMS_Core_File::format_filesize($space), $c));
|
||||||
|
$tabledata[] = ['preview'.$t, $translator->translate('preview_'.$t), SeedDMS_Core_File::format_filesize($space), $c];
|
||||||
|
}
|
||||||
|
|
||||||
/* Javascript */
|
/* Javascript */
|
||||||
$path = addDirSep($cachedir).'js';
|
$path = addDirSep($cachedir).'js';
|
||||||
if(file_exists($path)) {
|
if(file_exists($path)) {
|
||||||
$space = dskspace($path);
|
$space = dskspace($path);
|
||||||
$fi = new FilesystemIterator($path, FilesystemIterator::SKIP_DOTS);
|
$fi = new FilesystemIterator($path, FilesystemIterator::SKIP_DOTS);
|
||||||
$c = iterator_count($fi);
|
$c = iterator_count($fi);
|
||||||
} else {
|
} else {
|
||||||
$space = $c = 0;
|
$space = $c = 0;
|
||||||
}
|
}
|
||||||
$totalc += $c;
|
$totalc += $c;
|
||||||
$totalspace += $space;
|
$totalspace += $space;
|
||||||
$output->writeln(sprintf($outformat, 'js', $translator->translate('temp_jscode'), SeedDMS_Core_File::format_filesize($space), $c));
|
// $output->writeln(sprintf($outformat, 'js', $translator->translate('temp_jscode'), SeedDMS_Core_File::format_filesize($space), $c));
|
||||||
|
$tabledata[] = ['js', $translator->translate('temp_jscode'), SeedDMS_Core_File::format_filesize($space), $c];
|
||||||
|
|
||||||
$caches = [];
|
$caches = [];
|
||||||
/* Create a dummy view for passing it to additionalCache() */
|
/* Create a dummy view for passing it to additionalCache() */
|
||||||
|
|
@ -90,8 +94,14 @@ class ListcacheCommand extends Command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach($caches as $cache) {
|
foreach($caches as $cache) {
|
||||||
$output->writeln(sprintf($outformat, $cache[0], $cache[1], SeedDMS_Core_File::format_filesize($cache[2]), $cache[3]));
|
// $output->writeln(sprintf($outformat, $cache[0], $cache[1], SeedDMS_Core_File::format_filesize($cache[2]), $cache[3]));
|
||||||
|
$tabledata[] = [$cache[0], $cache[1], SeedDMS_Core_File::format_filesize($cache[2]), $cache[3]];
|
||||||
}
|
}
|
||||||
|
$table = new Table($output);
|
||||||
|
$table
|
||||||
|
->setHeaders(['Cache', 'Name', 'Size', 'Count'])
|
||||||
|
->setRows($tabledata);
|
||||||
|
$table->render();
|
||||||
// print_r($caches);
|
// print_r($caches);
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user