<?php

include_once(dirname(__FILE__).'/../Base/Output.php');

class CustomOutput extends Output
{
  var $Load = '';
  var $Unload = '';
  var $Document;
  var $Title = '';
  var $FullPage = true;

  function Header()
  {
    $Tag = new XMLTag('div');
    $Tag->Attributes = array('class' => 'Header');
    $Tag->SubElements = ' ';
    return($Tag);
  }

  function Footer()
  {
    $Time = round($this->System->GetMicrotime() - $this->System->TimeStart, 2);
    $Tag = new XMLTag('ul');
    $Tag->Attributes = array('class' => 'Footer');
    $AdminTag = new XMLTag('li');
    $AdminTag->SubElements = $this->Config['System']['Admin'];
    $EmailTag = new XMLTag('li');
    $EmailTag->SubElements = $this->Config['System']['AdminEmail'];
    $Tag->SubElements = array($AdminTag, $EmailTag);
    if($this->Config['System']['ShowRuntimeInfo'] == true)
    {
      $ExecutionTimeTag = new XMLTag('li');
      $ExecutionTimeTag->SubElements = 'Doba generování: '.$Time.' s / '.ini_get('max_execution_time').' s';
      $Tag->SubElements[] = $ExecutionTimeTag;
      $UsedMemoryTag = new XMLTag('li');
      $PrefixMultiplier = new PrefixMultiplier();
      $UsedMemoryTag->SubElements = 'Použitá paměť: '.$PrefixMultiplier->Add(memory_get_peak_usage(FALSE), 'B').' / '.ini_get('memory_limit').'B';
      $Tag->SubElements[] = $UsedMemoryTag;
    }
    return($Tag);
  }

  function Show($Content)
  {
    if($this->FullPage)
    {
      $this->Document = new XHTMLDocument();
      $BodyParam = '';
      if($this->Load != '') $BodyParam .= ' onload="'.$this->Load.'"';
      if($this->Unload != '') $BodyParam .= ' onunload="'.$this->Unload.'"';
      $this->Document->Encoding = $this->Config['System']['Charset'];
      $this->Document->Formated = $this->Config['System']['FormatHTML'];
      $Style = new XMLTag('link');
      $Style->Attributes = array('rel' => 'stylesheet', 'href' => 'Application/Style/'.$this->Config['System']['Style'].'/Style.css',
        'type' => 'text/css', 'media' => 'all');
      $this->Document->HeadTag->SubElements[] = $Style;
      $JavaScript = new XMLTag('script');
      $JavaScript->Attributes = array('type' => 'text/javascript', 'src' => 'Application/Style/'.$this->Config['System']['Style'].'/Global.js');
      $JavaScript->ShringEmpty = false;
      $this->Document->HeadTag->SubElements[] = $JavaScript;
      $JavaScript = new XMLTag('script');
      $JavaScript->Attributes = array('type' => 'text/javascript', 'src' => 'Base/Style/jquery.js');
      $JavaScript->ShringEmpty = false;
      $this->Document->HeadTag->SubElements[] = $JavaScript;
      $this->Document->TitleTag->SubElements = $this->Config['System']['Title'].' - '.$this->Title;
      $this->Document->BodyTag->SubElements = array($this->Header(), $Content, $this->Footer());
      echo($this->Document->GetOutput());
    } else echo($Content);
  }

  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>');
  }
}
