<?php

class BaseView extends View
{
  function SystemMessage($Title, $Text)
  {
    return '<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div></td></tr></table>';
  }

  function ShowPage($Content)
  {
    global $ReleaseTime, $Revision;

    $Output = '<?xml version="1.0" encoding="'.Core::Cast($this->System)->Config['Web']['Charset'].'"?>'."\n".
    '<!DOCTYPE html>'.
    '<html>'.
    '<head>'.
    '<meta http-equiv="Content-Language" content="cs"/>'.
    '<meta http-equiv="content-type" content="text/html; charset='.Core::Cast($this->System)->Config['Web']['Charset'].'" />'.
    '<meta name="robots" content="all" />'.
    '<title>'.Core::Cast($this->System)->Config['Web']['Title'].'</title>'.
    '<link rel="StyleSheet" href="'.$this->System->Link('/style/basic/style.css').'" type="text/css" media="all"/>'.
    implode("\n", Core::Cast($this->System)->HeadItems).
    '</head><body>';
    $Output .= $this->ShowHeader();
    $Output .= $Content;
    $Output .= '<br/><div style="text-align: center; font-size: small;">Verze: '.$Revision.' ('.HumanDate($ReleaseTime).')'.
      ' &nbsp; <a href="https://app.zdechov.net/open2ride/browser/trunk">Zdrojový kód</a> &nbsp; '.
      '<a href="https://app.zdechov.net/open2ride/log/trunk?verbose=on">Historie změn</a></div>';
    $Output .= '</body></html>';
    echo($Output);
  }

  function ShowHeader()
  {
    $Output = '<div>';
    $Output .= '<div class="MenuItem">';
    $Bar = '';
    foreach (Core::Cast($this->System)->Bars['TopLeft'] as $BarItem)
      $Bar .= call_user_func($BarItem);
    if (trim($Bar) != '') $Output .= $Bar;
      else $Output .= '&nbsp;';
    $Output .= '</div><div class="MenuItem2">';
    $Bar = '';
    foreach (Core::Cast($this->System)->Bars['Top'] as $BarItem)
      $Bar .= call_user_func($BarItem);
    if (trim($Bar) != '') $Output .= $Bar;
      else $Output .= '&nbsp;';
    $Output .= '</div></div>';
    return $Output;
  }

  function GetOutput($Page)
  {
    $Page->OnSystemMessage = array(Core::Cast($this->System)->BaseView, 'SystemMessage');
    $Output = $this->ShowPage($Page->Show());
    return $Output;
  }
}

