1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-03-23 09:00:48 +01:00

[ticket/11150] Fix Html output formatter

PHPBB3-11150
This commit is contained in:
Tristan Darricau 2015-09-16 15:12:37 +02:00 committed by Tristan Darricau
parent 317c90cf48
commit 972f3a7ff4
No known key found for this signature in database
GPG Key ID: 817043C2E29DB881
3 changed files with 61 additions and 7 deletions

View File

@ -97,7 +97,7 @@ class extension_manager extends manager
{
if ($this->enable_on_install)
{
$io->writeError(['ENABLING_EXTENSIONS', [], 1], true);
$io->writeError([['ENABLING_EXTENSIONS', [], 1]], true);
foreach ($packages as $package)
{
try
@ -121,7 +121,7 @@ class extension_manager extends manager
*/
protected function pre_update(array $packages, IOInterface $io = null)
{
$io->writeError(['DISABLING_EXTENSIONS', [], 1], true, 1);
$io->writeError([['DISABLING_EXTENSIONS', [], 1]], true, 1);
$this->enabled_extensions = [];
foreach ($packages as $package)
{
@ -149,7 +149,7 @@ class extension_manager extends manager
*/
protected function post_update(array $packages, IOInterface $io = null)
{
$io->writeError(['ENABLING_EXTENSIONS', [], 1], true, 1);
$io->writeError([['ENABLING_EXTENSIONS', [], 1]], true, 1);
foreach ($this->enabled_extensions as $package)
{
try
@ -190,7 +190,7 @@ class extension_manager extends manager
{
if ($this->purge_on_remove)
{
$io->writeError(['DISABLING_EXTENSIONS', [], 1], true, 1);
$io->writeError([['DISABLING_EXTENSIONS', [], 1]], true, 1);
}
foreach ($packages as $package)
@ -239,7 +239,7 @@ class extension_manager extends manager
if ($this->extension_manager->is_enabled($package))
{
$enabled = true;
$io->writeError('DISABLING_EXTENSION', true, 1);
$io->writeError([['DISABLING_EXTENSIONS', [], 1]], true, 1);
$this->extension_manager->disable($package);
}
@ -274,7 +274,7 @@ class extension_manager extends manager
{
try
{
$io->writeError('ENABLING_EXTENSION', true, 1);
$io->writeError([['ENABLING_EXTENSIONS', [], 1]], true, 1);
$this->extension_manager->enable($package);
}
catch (\Exception $e)

View File

@ -15,6 +15,36 @@ namespace phpbb\composer\io;
class html_output_formatter extends \Composer\Console\HtmlOutputFormatter
{
protected static $availableForegroundColors = [
30 => 'black',
31 => 'red',
32 => 'green',
33 => 'yellow',
34 => 'blue',
35 => 'magenta',
36 => 'cyan',
37 => 'white'
];
protected static $availableBackgroundColors = [
40 => 'black',
41 => 'red',
42 => 'green',
43 => 'yellow',
44 => 'blue',
45 => 'magenta',
46 => 'cyan',
47 => 'white'
];
protected static $availableOptions = [
1 => 'bold',
4 => 'underscore',
//5 => 'blink',
//7 => 'reverse',
//8 => 'conceal'
];
/**
* {@inheritdoc}
*/
@ -24,4 +54,28 @@ class html_output_formatter extends \Composer\Console\HtmlOutputFormatter
return preg_replace_callback("{[\033\e]\[([0-9;]+)m(.*?)[\033\e]\[[0-9;]+m}s", array($this, 'formatHtml'), $formatted);
}
protected function formatHtml($matches)
{
$out = '<span style="';
foreach (explode(';', $matches[1]) as $code) {
if (isset(self::$availableForegroundColors[$code])) {
$out .= 'color:'.self::$availableForegroundColors[$code].';';
} elseif (isset(self::$availableBackgroundColors[$code])) {
$out .= 'background-color:'.self::$availableBackgroundColors[$code].';';
} elseif (isset(self::$availableOptions[$code])) {
switch (self::$availableOptions[$code]) {
case 'bold':
$out .= 'font-weight:bold;';
break;
case 'underscore':
$out .= 'text-decoration:underline;';
break;
}
}
}
return $out.'">'.$matches[2].'</span>';
}
}

View File

@ -114,7 +114,7 @@ trait translate_composer_trait
$parameters = [];
}
$message = trim($this->strip_format($message), "\n\r");
$message = trim($this->strip_format($lang_key), "\n\r");
if (strpos($message, ' Problem ') === 0)
{