<?php

namespace Modules;

class CEvent extends ContentType {

    public $keys = array(
        'DATE' => 'date',
        'LEFT01' => 'left01',
        'LEFT02' => 'left02',
        'LEFT03' => 'left03',
        'RIGHT01' => 'right01',
        'RIGHT02' => 'right02',
        'RIGHT03' => 'right03'
    );
    public $values;
    protected $layout;
    protected $layouts = array(
        'toc' => 'view_in_toc',
    );
    
    function __construct($keys,$config) {
        parent::__construct($keys,$config);
    }

    

    function view_in_toc() {
        $v = (object) $this->values;
        $TS = strtotime($v->date);
        $href = $this->href;
        
        $date = sprintf("<span class=\"month\">%s</span>"
                        ."<span class=\"day-of-month\">%s</span>",
                        $this->month_name(date('n',$TS)),
                        date('d', $TS)
        );

        if (is_object($v->left02)) {
            $v->left02->set_layout('name_as_link');
        }
        
        $left = sprintf("<h4>%s</h4>"
                        ."<h3>%s</h3>"
                        ."<footer>%s</footer>",
                        $v->left01,
                        $v->left02,
                        $v->left03
        );

        $right = sprintf("<h6>%s</h6>"
                         ."<span class=\"right02\">%s</span><br>"
                         ."<span class=\"right03\">%s</span>",
                         $v->right01,
                         $v->right02,
                         $v->right03
        );
        
        return sprintf("<div class=\"entry\">"
                       ."<div class=\"date\">%s</div>"
                       ."<div class=\"left\">%s</div>"
                       ."<div class=\"right\">%s</div>"
                       ."</div>",
                       $date,
                       $left,
                       $right
        );
    }
    

}
