Browse Source

Fixed php 5.4+ Exception in Console helper

tags/2.0.0-beta
Suralc 12 years ago
parent
commit
ded4ccd778
  1. 116
      framework/helpers/base/Console.php

116
framework/helpers/base/Console.php

@ -316,76 +316,76 @@ class Console
$styleA = array(); $styleA = array();
foreach (explode(';', $ansi) as $controlCode) { foreach (explode(';', $ansi) as $controlCode) {
switch ($controlCode) { switch ($controlCode) {
case static::FG_BLACK: case self::FG_BLACK:
$style = array('color' => '#000000'); $style = array('color' => '#000000');
break; break;
case static::FG_BLUE: case self::FG_BLUE:
$style = array('color' => '#000078'); $style = array('color' => '#000078');
break; break;
case static::FG_CYAN: case self::FG_CYAN:
$style = array('color' => '#007878'); $style = array('color' => '#007878');
break; break;
case static::FG_GREEN: case self::FG_GREEN:
$style = array('color' => '#007800'); $style = array('color' => '#007800');
break; break;
case static::FG_GREY: case self::FG_GREY:
$style = array('color' => '#787878'); $style = array('color' => '#787878');
break; break;
case static::FG_PURPLE: case self::FG_PURPLE:
$style = array('color' => '#780078'); $style = array('color' => '#780078');
break; break;
case static::FG_RED: case self::FG_RED:
$style = array('color' => '#780000'); $style = array('color' => '#780000');
break; break;
case static::FG_YELLOW: case self::FG_YELLOW:
$style = array('color' => '#787800'); $style = array('color' => '#787800');
break; break;
case static::BG_BLACK: case self::BG_BLACK:
$style = array('background-color' => '#000000'); $style = array('background-color' => '#000000');
break; break;
case static::BG_BLUE: case self::BG_BLUE:
$style = array('background-color' => '#000078'); $style = array('background-color' => '#000078');
break; break;
case static::BG_CYAN: case self::BG_CYAN:
$style = array('background-color' => '#007878'); $style = array('background-color' => '#007878');
break; break;
case static::BG_GREEN: case self::BG_GREEN:
$style = array('background-color' => '#007800'); $style = array('background-color' => '#007800');
break; break;
case static::BG_GREY: case self::BG_GREY:
$style = array('background-color' => '#787878'); $style = array('background-color' => '#787878');
break; break;
case static::BG_PURPLE: case self::BG_PURPLE:
$style = array('background-color' => '#780078'); $style = array('background-color' => '#780078');
break; break;
case static::BG_RED: case self::BG_RED:
$style = array('background-color' => '#780000'); $style = array('background-color' => '#780000');
break; break;
case static::BG_YELLOW: case self::BG_YELLOW:
$style = array('background-color' => '#787800'); $style = array('background-color' => '#787800');
break; break;
case static::BOLD: case self::BOLD:
$style = array('font-weight' => 'bold'); $style = array('font-weight' => 'bold');
break; break;
case static::ITALIC: case self::ITALIC:
$style = array('font-style' => 'italic'); $style = array('font-style' => 'italic');
break; break;
case static::UNDERLINE: case self::UNDERLINE:
$style = array('text-decoration' => array('underline')); $style = array('text-decoration' => array('underline'));
break; break;
case static::OVERLINED: case self::OVERLINED:
$style = array('text-decoration' => array('overline')); $style = array('text-decoration' => array('overline'));
break; break;
case static::CROSSED_OUT: case self::CROSSED_OUT:
$style = array('text-decoration' => array('line-through')); $style = array('text-decoration' => array('line-through'));
break; break;
case static::BLINK: case self::BLINK:
$style = array('text-decoration' => array('blink')); $style = array('text-decoration' => array('blink'));
break; break;
case static::NEGATIVE: // ??? case self::NEGATIVE: // ???
case static::CONCEALED: case self::CONCEALED:
case static::ENCIRCLED: case self::ENCIRCLED:
case static::FRAMED: case self::FRAMED:
// TODO allow resetting codes // TODO allow resetting codes
break; break;
case 0: // ansi reset case 0: // ansi reset
@ -456,39 +456,39 @@ class Console
public static function renderColoredString($string, $colored = true) public static function renderColoredString($string, $colored = true)
{ {
static $conversions = array( static $conversions = array(
'%y' => array(static::FG_YELLOW), '%y' => array(self::FG_YELLOW),
'%g' => array(static::FG_GREEN), '%g' => array(self::FG_GREEN),
'%b' => array(static::FG_BLUE), '%b' => array(self::FG_BLUE),
'%r' => array(static::FG_RED), '%r' => array(self::FG_RED),
'%p' => array(static::FG_PURPLE), '%p' => array(self::FG_PURPLE),
'%m' => array(static::FG_PURPLE), '%m' => array(self::FG_PURPLE),
'%c' => array(static::FG_CYAN), '%c' => array(self::FG_CYAN),
'%w' => array(static::FG_GREY), '%w' => array(self::FG_GREY),
'%k' => array(static::FG_BLACK), '%k' => array(self::FG_BLACK),
'%n' => array(0), // reset '%n' => array(0), // reset
'%Y' => array(static::FG_YELLOW, static::BOLD), '%Y' => array(self::FG_YELLOW, self::BOLD),
'%G' => array(static::FG_GREEN, static::BOLD), '%G' => array(self::FG_GREEN, self::BOLD),
'%B' => array(static::FG_BLUE, static::BOLD), '%B' => array(self::FG_BLUE, self::BOLD),
'%R' => array(static::FG_RED, static::BOLD), '%R' => array(self::FG_RED, self::BOLD),
'%P' => array(static::FG_PURPLE, static::BOLD), '%P' => array(self::FG_PURPLE, self::BOLD),
'%M' => array(static::FG_PURPLE, static::BOLD), '%M' => array(self::FG_PURPLE, self::BOLD),
'%C' => array(static::FG_CYAN, static::BOLD), '%C' => array(self::FG_CYAN, self::BOLD),
'%W' => array(static::FG_GREY, static::BOLD), '%W' => array(self::FG_GREY, self::BOLD),
'%K' => array(static::FG_BLACK, static::BOLD), '%K' => array(self::FG_BLACK, self::BOLD),
'%N' => array(0, static::BOLD), '%N' => array(0, self::BOLD),
'%3' => array(static::BG_YELLOW), '%3' => array(self::BG_YELLOW),
'%2' => array(static::BG_GREEN), '%2' => array(self::BG_GREEN),
'%4' => array(static::BG_BLUE), '%4' => array(self::BG_BLUE),
'%1' => array(static::BG_RED), '%1' => array(self::BG_RED),
'%5' => array(static::BG_PURPLE), '%5' => array(self::BG_PURPLE),
'%6' => array(static::BG_PURPLE), '%6' => array(self::BG_PURPLE),
'%7' => array(static::BG_CYAN), '%7' => array(self::BG_CYAN),
'%0' => array(static::BG_GREY), '%0' => array(self::BG_GREY),
'%F' => array(static::BLINK), '%F' => array(self::BLINK),
'%U' => array(static::UNDERLINE), '%U' => array(self::UNDERLINE),
'%8' => array(static::NEGATIVE), '%8' => array(self::NEGATIVE),
'%9' => array(static::BOLD), '%9' => array(self::BOLD),
'%_' => array(static::BOLD) '%_' => array(self::BOLD)
); );
if ($colored) { if ($colored) {

Loading…
Cancel
Save