4 class Renderer_Console extends Renderer
6 protected $httpContentType = 'text/plain; charset=utf-8';
9 * Use ANSI color codes for output coloring
16 * @var \Console_Color2
20 public function render($arEvents)
24 $this->cc = new \Console_Color2();
27 $tbl = new \Console_Table(
28 CONSOLE_TABLE_ALIGN_LEFT,
29 array('intersection' => '', 'horizontal' => '-', 'vertical' => ''),
32 $tbl->setAlign(0, CONSOLE_TABLE_ALIGN_RIGHT);
33 $tbl->setAlign(1, CONSOLE_TABLE_ALIGN_RIGHT);
37 array('Days', 'Age', 'Name', 'Event', 'Date', 'Day'),
41 $tbl->setBorderVisibility(
51 foreach ($arEvents as $event) {
53 if ($event->days == 0) {
61 wordwrap($event->title, 30, "\n", true),
62 wordwrap($event->type, 20, "\n", true),
63 $this->getLocalDate($event->date),
64 strftime('%a', strtotime($event->localDate))
70 return $tbl->getTable();
73 protected function ansiWrap($data, $colorCode = null)
75 if (!$this->ansi || $colorCode === null) {
79 foreach ($data as $k => &$value) {
80 $value = $this->cc->convert(
81 $colorCode . $value . '%n'
87 protected function loadConfig()
89 if (isset($this->config->ansi)) {
90 $this->ansi = $this->config->ansi;