Added ANSI parsers and rendering ANSI frames
This commit is contained in:
@@ -35,7 +35,8 @@ use App\Models\CUG;
|
||||
abstract class Frame
|
||||
{
|
||||
protected $frame = NULL;
|
||||
protected $output = NULL;
|
||||
protected $output = '';
|
||||
protected $startline = 1;
|
||||
|
||||
// All this vars should be overridden in the child class
|
||||
/*
|
||||
@@ -71,17 +72,11 @@ abstract class Frame
|
||||
// @todo Move this to the database
|
||||
private $header = RED.'T'.BLUE.'E'.GREEN.'S'.YELLOW.'T'.MAGENTA.'!';
|
||||
|
||||
public function __construct(\App\Models\Frame $o,string $msg=NULL)
|
||||
public function __construct(\App\Models\Frame $o)
|
||||
{
|
||||
$this->frame = $o;
|
||||
|
||||
$this->output = $this->hasFlag('clear') ? CLS : HOME;
|
||||
|
||||
// If we have a message to display on the bottom line.
|
||||
if ($msg)
|
||||
$this->output .= UP.$msg.HOME;
|
||||
|
||||
$startline = 0;
|
||||
$this->output = $this->frame->cls ? CLS : HOME;
|
||||
|
||||
if (! $this->hasFlag('ip') AND (! $this->isCUG(0) OR $this->type() !== self::FRAMETYPE_LOGIN)) {
|
||||
// Set the page header: CUG/Site Name | Page # | Cost
|
||||
@@ -89,12 +84,16 @@ abstract class Frame
|
||||
$this->render_page($this->frame->frame,$this->frame->index).
|
||||
$this->render_cost($this->frame->cost);
|
||||
|
||||
$startline = 1;
|
||||
$this->startline = 2;
|
||||
|
||||
} elseif ($this->isCUG(0) AND $this->type() === self::FRAMETYPE_LOGIN) {
|
||||
$this->startline = 2;
|
||||
$this->output .= str_repeat(DOWN,$this->startline-1);
|
||||
}
|
||||
|
||||
// Calculate fields and render output.
|
||||
$this->fields = collect(); // Fields in this frame.
|
||||
$this->fields($startline);
|
||||
$this->fields = collect(); // Fields in this frame.
|
||||
$this->fields($this->startline);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -403,17 +402,18 @@ abstract class Frame
|
||||
$o->index = 'a';
|
||||
$o->access = 1;
|
||||
$o->closed = 0;
|
||||
$o->cls = 1;
|
||||
|
||||
// Header
|
||||
$sid = R_RED.'T'.R_BLUE.'E'.R_GREEN.'S'.R_YELLOW.'T';
|
||||
$o->content .= substr($sid.'-'.str_repeat('12345678901234567890',4),0,static::$header_length+(strlen($sid)-$so->strlenv($sid))).
|
||||
R_WHITE.'999999999a'.R_RED.sprintf('%07.0f',999).'u';
|
||||
|
||||
$o->content .= str_repeat('+-',18).' '.R_RED.'01';
|
||||
$o->content .= 'Name: '.ESC.str_repeat('u',5).str_repeat('+-',14);
|
||||
$o->content .= 'Date: '.ESC.str_repeat('d',25).str_repeat('+-',4);
|
||||
$o->content .= 'Address: '.ESC.str_repeat('a',19).' '.str_repeat('+-',5);
|
||||
$o->content .= ' : '.ESC.str_repeat('a',19).' '.str_repeat('+-',5);
|
||||
$o->content .= R_WHITE.str_repeat('+-',static::$frame_width/2-3).' '.R_RED.'01';
|
||||
$o->content .= R_WHITE.'Name: '.ESC.str_repeat('u',5).' |'.str_repeat('+-',static::$frame_width/2-8).'|';
|
||||
$o->content .= R_WHITE.'Date: '.ESC.str_repeat('d',17).' |'.str_repeat('+-',static::$frame_width/2-14).'|';
|
||||
$o->content .= R_WHITE.'Address: '.ESC.str_repeat('t',19).' |'.str_repeat('+-',static::$frame_width/2-17).'|';
|
||||
$o->content .= R_WHITE.' : '.ESC.str_repeat('t',19).' |'.str_repeat('+-',static::$frame_width/2-17).'|';
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
Reference in New Issue
Block a user