mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 13:28:55 +00:00
[ticket/11150] Fix Html output formatter
PHPBB3-11150
This commit is contained in:
parent
317c90cf48
commit
972f3a7ff4
3 changed files with 61 additions and 7 deletions
|
@ -97,7 +97,7 @@ class extension_manager extends manager
|
||||||
{
|
{
|
||||||
if ($this->enable_on_install)
|
if ($this->enable_on_install)
|
||||||
{
|
{
|
||||||
$io->writeError(['ENABLING_EXTENSIONS', [], 1], true);
|
$io->writeError([['ENABLING_EXTENSIONS', [], 1]], true);
|
||||||
foreach ($packages as $package)
|
foreach ($packages as $package)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -121,7 +121,7 @@ class extension_manager extends manager
|
||||||
*/
|
*/
|
||||||
protected function pre_update(array $packages, IOInterface $io = null)
|
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 = [];
|
$this->enabled_extensions = [];
|
||||||
foreach ($packages as $package)
|
foreach ($packages as $package)
|
||||||
{
|
{
|
||||||
|
@ -149,7 +149,7 @@ class extension_manager extends manager
|
||||||
*/
|
*/
|
||||||
protected function post_update(array $packages, IOInterface $io = null)
|
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)
|
foreach ($this->enabled_extensions as $package)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -190,7 +190,7 @@ class extension_manager extends manager
|
||||||
{
|
{
|
||||||
if ($this->purge_on_remove)
|
if ($this->purge_on_remove)
|
||||||
{
|
{
|
||||||
$io->writeError(['DISABLING_EXTENSIONS', [], 1], true, 1);
|
$io->writeError([['DISABLING_EXTENSIONS', [], 1]], true, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($packages as $package)
|
foreach ($packages as $package)
|
||||||
|
@ -239,7 +239,7 @@ class extension_manager extends manager
|
||||||
if ($this->extension_manager->is_enabled($package))
|
if ($this->extension_manager->is_enabled($package))
|
||||||
{
|
{
|
||||||
$enabled = true;
|
$enabled = true;
|
||||||
$io->writeError('DISABLING_EXTENSION', true, 1);
|
$io->writeError([['DISABLING_EXTENSIONS', [], 1]], true, 1);
|
||||||
$this->extension_manager->disable($package);
|
$this->extension_manager->disable($package);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ class extension_manager extends manager
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$io->writeError('ENABLING_EXTENSION', true, 1);
|
$io->writeError([['ENABLING_EXTENSIONS', [], 1]], true, 1);
|
||||||
$this->extension_manager->enable($package);
|
$this->extension_manager->enable($package);
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
|
|
|
@ -15,6 +15,36 @@ namespace phpbb\composer\io;
|
||||||
|
|
||||||
class html_output_formatter extends \Composer\Console\HtmlOutputFormatter
|
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}
|
* {@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);
|
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>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ trait translate_composer_trait
|
||||||
$parameters = [];
|
$parameters = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = trim($this->strip_format($message), "\n\r");
|
$message = trim($this->strip_format($lang_key), "\n\r");
|
||||||
|
|
||||||
if (strpos($message, ' Problem ') === 0)
|
if (strpos($message, ' Problem ') === 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue