<?php

// Grafic user interface class
// Date: 2012-06-13

class Gui
{
  private $Config;
  private $Messages;
  private $ActivePage = 'home';
  private $Links = array();
  private $Pages = array();
  private $Language;

  function __construct($User)
  {
    $this->Config = new Config();  
	$this->Messages = new Messages();
	$this->Language = new Language();
	
	$this->InitLinks();
	$this->InitPages();
	
	//have to be after inicialization of pages
	$this->Feedback($User);
  }
  
//init links
  private function InitLinks() {
	  $this->Links['SourceCode'] = new Link('Zdrojové kódy','http://svn.zdechov.net/svn/phpvpsadmin/','');  
	  
  }

//init Pages
  private function InitPages() {
	  $this->Pages['home'] = new PageHome($this->Language);  
	  
  }

//gets feedback from post and get 
  private function Feedback($User) {
	$this->Messages->RegMess($User);
	$this->ActivePage = $this->Messages->WhichPage($this->Pages);
  }	  

//shows page concent 
  public function ShowPage() {
	$this->ShowHeader();
	
	//generate and shows active page
	$this->Pages[$this->ActivePage]->Show();
	
	$this->ShowFooter();
  }


//shows header of web page
  private function ShowHeader()
  {
  
  echo('<?xml version="1.0" encoding="'.$this->Config->Web['Charset'].'"?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cz">'.
'<head>'.
'<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$this->Config->Web['Charset'].'" />'.
'<meta name="keywords" content="virtualizace, virtuální, server, hosting, webhosting, web, virtualization" />'.
'<meta name="description" content="'.$this->Config->Web['Title'].'" />'.
'<meta name="robots" content="all" />'.
'<link rel="stylesheet" href="'.$this->Config->Web['Style'].'" type="text/css" media="all" />'.
'<script type="text/javascript" src="'.$this->Config->Web['Script'].'"></script>'.
'<link rel="shortcut icon" href="'.$this->Config->Web['Icon'].'" />');
  echo('<title>'.$this->Config->Web['Title'].'</title></head><body><table><tr><td>');

  }

//shows footer of webpage
  private function ShowFooter()
  {
    echo('</td>'.
  '</tr><tr>'.
  '<td colspan="4" class="page-bottom">'.$this->Language->Texts['autors'].': '.$this->Config->Web['Authors'].' &nbsp; '.$this->Links['SourceCode']->Get().'');

    echo('</td></tr>');
    echo('</table>'.
      '</body>'.
      '</html>'); 
  }

}
?>
