Ferreteria/v0.6/clade/IO/O/View/TTY/List
Jump to navigation
Jump to search
|
The item documented here has been removed and is no longer in use.
|
| ||||||||||||
Pages
Code
Entire contents of file, as deleted on 2026-01-26:
<?php namespace Woozalia\Ferret\IO\O\View\TTY;
/**
* PURPOSE: knows how to render all the pieces of a bullet-list in a TTY environment
* THINKING:
* 2025-02-05 I *think* this is kind of like an MVC Controller.
* Model: Array?
* View: Style/Lists/...
* HISTORY:
* 2024-10-17 created
* 2024-10-19 moved Render() here from LayoutClass, because if
* definitely did not belong there.
* 2024-10-20 moved from [WF]IO\O\Screen\Render\TTY -> IO\O\Render\TTY
* 2025-02-04 renamed Indent -> List
*/
/* ElemIface */ use Woozalia\Ferret\IO\O\Data\iElement as ElemIface;
/* Base* [ca,i] */ use Woozalia\Ferret\IO\O\Data\Element\Branch\{ caList as BaseClass, iList as BaseIface };
/* StyleIface */ use Woozalia\Ferret\IO\O\Style\TTY\iList as StyleIface;
/* StyleClass */ use Woozalia\Ferret\IO\O\Style\TTY\List\cWooz as StyleClass; // DEFAULT (2025-02-05 TODO: make this configurable)
interface iList extends BaseIface {}
class cList extends BaseClass implements iList {
// ++ CONFIG ++ //
protected function ItemClass() : string { return List\aux\cItem::class; }
protected function StyleClass() : string { return StyleClass::class; }
// -- CONFIG -- //
// ++ SETTINGS ++ //
private $oStyle = NULL;
protected function Style(?StyleIface $o=NULL) : StyleIface {
return is_object($o)
? ($this->oStyle = $o)
: ($this->oStyle ?? $this->UseDefaultStyle());
}
protected function UseDefaultStyle() : StyleIface { return ($this->oStyle = new ($this->StyleClass())); }
// -- SETTINGS -- //
// ++ OUTPUT ++ //
protected function RenderBefore() : string { return $this->Style()->ListPrefix(); }
protected function RenderAfter() : string { return $this->Style()->ListSuffix(); }
protected function RenderElement(ElemIface $oElem) : string {
$sStr = $oElem->Render();
if (count($oElem->Elements()) === 0) {
$sInd = $this->RenderIndentation();
} else {
$sInd = ''; // sub-elements will handle their own indentation
}
return $sInd.$sStr;
}
// CEMENT: Element
public function Render() : string {
$ar = $this->Elements();
$sOut = '';
if (count($ar) > 0) {
foreach ($ar as $oElem) {
$sOut .= $this->RenderElement($oElem);
}
}
return $sOut;
}
public function RenderIndentation() : string {
$sInd = $this->Style()->IndentText();
$sPfx = $this->OHolder()->RenderIndentation();
return $sPfx.$sInd;
}
// -- OUTPUT -- //
}