<?php

class PageView extends View
{
  var $TimeStart;
  var $ShortTitle;
  var $FullTitle;
  var $Load;
  var $Unload;
  var $Content;

  function ShowHeader($Title, $Path)
  {
    $BodyParam = '';
    if($this->Load != '') $BodyParam .= ' onload="'.$this->Load.'"';
    if($this->Unload != '') $BodyParam .= ' onunload="'.$this->Unload.'"';
    $Output = '<?xml version="1.0" encoding="'.$this->Config['Web']['Charset'].'"?>'."\n".
    '<!DOCTYPE html>'.
    '<html>'.
    '<head><link rel="stylesheet" href="Application/Style/Style.css" type="text/css" media="all" />'.
    '<meta http-equiv="content-type" content="text/html; charset='.$this->Config['Web']['Charset'].'" />'.
    '<script type="text/javascript" src="Application/Style/Global.js"></script>'.
    '<title>'.$this->Config['Web']['Title'].' - '.$Path.'</title>
    </head><body'.$BodyParam.'>';
    return($Output);
  }

  function ShowFooter()
  {
    global $ScriptTimeStart;

    $Time = round($this->System->GetMicrotime() - $ScriptTimeStart, 2);
    $Output = '<div class="Footer">
   <ul><li>Založeno na projektu <a href="http://svn.zdechov.net/trac/statistic/">Statistika</a></li>'.
   '<li><a href="http://svn.zdechov.net/trac/statistic/browser">Zdrojové kódy</a></li>'.
   '<li><a href="http://svn.zdechov.net/trac/statistic/log?verbose=on">Novinky</a></li>'.
   '<li>Správce: '.$this->Config['Web']['Admin'].'</li>'.
   '<li>E-mail: '.$this->Config['Web']['AdminEmail'].'</li>';
    if($this->Config['Web']['ShowRuntimeInfo'] == true) $Output .= '<li>Doba generování: '.$Time.' s / '.ini_get('max_execution_time').' s</li><li>Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B</li>';
  $Output .= '</ul></div></body></html>';
    return($Output);
  }

  function GetOutput($Content)
  {
    global $Config;

    $Output = $this->ShowHeader($this->FullTitle, $this->ShortTitle).$Content;
    $Output .= $this->ShowFooter();
    $Html = new Html();
    if($Config['Web']['FormatHTML'] == true) echo($Html->FormatOutput($Output));
      else echo($Output);
  }

  function SystemMessage($Text)
  {
    return('<table align="center"><tr><td><div class="SystemMessage"><h3>Systémová zpráva</h3><div>'.$Text.'</div></div</td></tr></table>');
    //ShowFooter();
    //die();
  }

  function AccessDenied()
  {
    return($this->GetOutput($this->SystemMessage($this->System->Translate('AccessDenied'))));
  }
}
