diff options
Diffstat (limited to 'phpBB/phpbb/console/command/thumbnail')
-rw-r--r-- | phpBB/phpbb/console/command/thumbnail/delete.php | 63 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/thumbnail/generate.php | 64 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/thumbnail/recreate.php | 5 |
3 files changed, 86 insertions, 46 deletions
diff --git a/phpBB/phpbb/console/command/thumbnail/delete.php b/phpBB/phpbb/console/command/thumbnail/delete.php index fb63f7c510..e8e4cf568e 100644 --- a/phpBB/phpbb/console/command/thumbnail/delete.php +++ b/phpBB/phpbb/console/command/thumbnail/delete.php @@ -14,6 +14,7 @@ namespace phpbb\console\command\thumbnail; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; class delete extends \phpbb\console\command\command { @@ -68,6 +69,10 @@ class delete extends \phpbb\console\command\command */ protected function execute(InputInterface $input, OutputInterface $output) { + $io = new SymfonyStyle($input, $output); + + $io->section($this->user->lang('CLI_THUMBNAIL_DELETING')); + $sql = 'SELECT COUNT(*) AS nb_missing_thumbnails FROM ' . ATTACHMENTS_TABLE . ' WHERE thumbnail = 1'; @@ -77,7 +82,7 @@ class delete extends \phpbb\console\command\command if ($nb_missing_thumbnails === 0) { - $output->writeln('<info>' . $this->user->lang('CLI_THUMBNAIL_NOTHING_TO_DELETE') . '</info>'); + $io->warning($this->user->lang('CLI_THUMBNAIL_NOTHING_TO_DELETE')); return 0; } @@ -86,12 +91,37 @@ class delete extends \phpbb\console\command\command WHERE thumbnail = 1'; $result = $this->db->sql_query($sql); - if (!$input->getOption('verbose')) + $progress = $io->createProgressBar($nb_missing_thumbnails); + if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) + { + $progress->setFormat('<info>[%percent:3s%%]</info> %message%'); + $progress->setOverwrite(false); + } + else if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) + { + $progress->setFormat('<info>[%current:s%/%max:s%]</info><comment>[%elapsed%/%estimated%][%memory%]</comment> %message%'); + $progress->setOverwrite(false); + } + else + { + $io->newLine(2); + $progress->setFormat( + " %current:s%/%max:s% %bar% %percent:3s%%\n" . + " %elapsed:6s%/%estimated:-6s% %memory:6s%\n"); + $progress->setBarWidth(60); + } + + if (!defined('PHP_WINDOWS_VERSION_BUILD')) { - $progress = $this->getHelper('progress'); - $progress->start($output, $nb_missing_thumbnails); + $progress->setEmptyBarCharacter('░'); // light shade character \u2591 + $progress->setProgressCharacter(''); + $progress->setBarCharacter('▓'); // dark shade character \u2593 } + $progress->setMessage($this->user->lang('CLI_THUMBNAIL_DELETING')); + + $progress->start(); + $thumbnail_deleted = array(); $return = 0; while ($row = $this->db->sql_fetchrow($result)) @@ -108,24 +138,15 @@ class delete extends \phpbb\console\command\command $thumbnail_deleted = array(); } - if ($input->getOption('verbose')) - { - $output->writeln($this->user->lang('CLI_THUMBNAIL_DELETED', $row['real_filename'], $row['physical_filename'])); - } + $progress->setMessage($this->user->lang('CLI_THUMBNAIL_DELETED', $row['real_filename'], $row['physical_filename'])); } else { - if ($input->getOption('verbose')) - { - $return = 1; - $output->writeln('<error>' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '</error>'); - } + $return = 1; + $progress->setMessage('<error>' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '</error>'); } - if (!$input->getOption('verbose')) - { - $progress->advance(); - } + $progress->advance(); } $this->db->sql_freeresult($result); @@ -134,10 +155,10 @@ class delete extends \phpbb\console\command\command $this->commit_changes($thumbnail_deleted); } - if (!$input->getOption('verbose')) - { - $progress->finish(); - } + $progress->finish(); + + $io->newLine(2); + $io->success($this->user->lang('CLI_THUMBNAIL_DELETING_DONE')); return $return; } diff --git a/phpBB/phpbb/console/command/thumbnail/generate.php b/phpBB/phpbb/console/command/thumbnail/generate.php index 0f4a40bd9f..e677db3a97 100644 --- a/phpBB/phpbb/console/command/thumbnail/generate.php +++ b/phpBB/phpbb/console/command/thumbnail/generate.php @@ -10,10 +10,12 @@ * the docs/CREDITS.txt file. * */ + namespace phpbb\console\command\thumbnail; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; class generate extends \phpbb\console\command\command { @@ -84,6 +86,10 @@ class generate extends \phpbb\console\command\command */ protected function execute(InputInterface $input, OutputInterface $output) { + $io = new SymfonyStyle($input, $output); + + $io->section($this->user->lang('CLI_THUMBNAIL_GENERATING')); + $sql = 'SELECT COUNT(*) AS nb_missing_thumbnails FROM ' . ATTACHMENTS_TABLE . ' WHERE thumbnail = 0'; @@ -93,7 +99,7 @@ class generate extends \phpbb\console\command\command if ($nb_missing_thumbnails === 0) { - $output->writeln('<info>' . $this->user->lang('CLI_THUMBNAIL_NOTHING_TO_GENERATE') . '</info>'); + $io->warning($this->user->lang('CLI_THUMBNAIL_NOTHING_TO_GENERATE')); return 0; } @@ -109,11 +115,36 @@ class generate extends \phpbb\console\command\command require($this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext); } - if (!$input->getOption('verbose')) + $progress = $io->createProgressBar($nb_missing_thumbnails); + if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) { - $progress = $this->getHelper('progress'); - $progress->start($output, $nb_missing_thumbnails); + $progress->setFormat('<info>[%percent:3s%%]</info> %message%'); + $progress->setOverwrite(false); } + else if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) + { + $progress->setFormat('<info>[%current:s%/%max:s%]</info><comment>[%elapsed%/%estimated%][%memory%]</comment> %message%'); + $progress->setOverwrite(false); + } + else + { + $io->newLine(2); + $progress->setFormat( + " %current:s%/%max:s% %bar% %percent:3s%%\n" . + " %elapsed:6s%/%estimated:-6s% %memory:6s%\n"); + $progress->setBarWidth(60); + } + + if (!defined('PHP_WINDOWS_VERSION_BUILD')) + { + $progress->setEmptyBarCharacter('░'); // light shade character \u2591 + $progress->setProgressCharacter(''); + $progress->setBarCharacter('▓'); // dark shade character \u2593 + } + + $progress->setMessage($this->user->lang('CLI_THUMBNAIL_GENERATING')); + + $progress->start(); $thumbnail_created = array(); while ($row = $this->db->sql_fetchrow($result)) @@ -127,30 +158,21 @@ class generate extends \phpbb\console\command\command { $thumbnail_created[] = (int) $row['attach_id']; - if (sizeof($thumbnail_created) === 250) + if (count($thumbnail_created) === 250) { $this->commit_changes($thumbnail_created); $thumbnail_created = array(); } - if ($input->getOption('verbose')) - { - $output->writeln($this->user->lang('CLI_THUMBNAIL_GENERATED', $row['real_filename'], $row['physical_filename'])); - } + $progress->setMessage($this->user->lang('CLI_THUMBNAIL_GENERATED', $row['real_filename'], $row['physical_filename'])); } else { - if ($input->getOption('verbose')) - { - $output->writeln('<info>' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '</info>'); - } + $progress->setMessage('<info>' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '</info>'); } } - if (!$input->getOption('verbose')) - { - $progress->advance(); - } + $progress->advance(); } $this->db->sql_freeresult($result); @@ -159,10 +181,10 @@ class generate extends \phpbb\console\command\command $this->commit_changes($thumbnail_created); } - if (!$input->getOption('verbose')) - { - $progress->finish(); - } + $progress->finish(); + + $io->newLine(2); + $io->success($this->user->lang('CLI_THUMBNAIL_GENERATING_DONE')); return 0; } diff --git a/phpBB/phpbb/console/command/thumbnail/recreate.php b/phpBB/phpbb/console/command/thumbnail/recreate.php index 5d3edbd699..382da290bf 100644 --- a/phpBB/phpbb/console/command/thumbnail/recreate.php +++ b/phpBB/phpbb/console/command/thumbnail/recreate.php @@ -49,12 +49,11 @@ class recreate extends \phpbb\console\command\command if ($input->getOption('verbose')) { - $parameters['-v'] = true; + $parameters['-' . str_repeat('v', $output->getVerbosity() - 1)] = true; } $this->getApplication()->setAutoExit(false); - $output->writeln('<comment>' . $this->user->lang('CLI_THUMBNAIL_DELETING') . '</comment>'); $input_delete = new ArrayInput($parameters); $return = $this->getApplication()->run($input_delete, $output); @@ -62,8 +61,6 @@ class recreate extends \phpbb\console\command\command { $parameters['command'] = 'thumbnail:generate'; - $output->writeln(''); - $output->writeln('<comment>' . $this->user->lang('CLI_THUMBNAIL_GENERATING') . '</comment>'); $input_create = new ArrayInput($parameters); $return = $this->getApplication()->run($input_create, $output); } |