<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

class DBStructureInfo
{
  private $structure;

  public function __construct()
  {
    $this->structure = new DBStructureInfoCurrent();
  }

  public function getVersion()
  {
    return $this->structure->getVersion();
  }

  public function getHash()
  {
    $str = '';
    $str .= $this->getExceptionsTxt();
    $str .= $this->getFieldsTxt();
    $str .= $this->getTablesTxt();
    $str .= $this->getMysqlStrukturTxt();
    $str .= $this->getMysqlStrukturCodeTxt();
    $str .= $this->getMysqlStrukturHlGrundsys();
    $str .= $this->getMysqlStrukturTablesPk();

    return md5($str);
  }

  public function getExceptionsTxt()
  {
    return $this->structure->getExceptionsTxt();
  }

  public function getFieldsTxt()
  {
    return $this->structure->getFieldsTxt();
  }

  public function getTablesTxt()
  {
    return $this->structure->getTablesTxt();
  }

  public function getWinbasysTxt()
  {
    return $this->structure->getWinbasysTxt();
  }

  public function getMysqlStrukturTxt()
  {
    return $this->structure->getMysqlStrukturTxt();
  }

  public function getMysqlStrukturCodeTxt()
  {
    return $this->structure->getMysqlStrukturCodeTxt();
  }

  public function getMysqlStrukturHlGrundsys()
  {
    return $this->structure->getMysqlStrukturHlGrundsys();
  }

  public function getMysqlStrukturTablesPk()
  {
    return $this->structure->getMysqlStrukturTablesPk();
  }
}

class DBStructureInfoCurrent extends DBStructureInfo
{
  private $structurePath;

  public function __construct()
  {
    $this->structurePath = BASEDIR . 'classes' . DIRECTORY_SEPARATOR . 'db' . DIRECTORY_SEPARATOR . 'structure' . DIRECTORY_SEPARATOR;
  }

  public function getVersion()
  {
    return VERSION;
  }

  public function getExceptionsTxt()
  {
    include $this->structurePath . 'exceptions.php';

    return $content;
  }

  public function getFieldsTxt()
  {
    include $this->structurePath . 'fields.php';

    return $content;
  }

  public function getTablesTxt()
  {
    include $this->structurePath . 'tables.php';

    return $content;
  }

  public function getWinbasysTxt()
  {
    include $this->structurePath . 'winbasys.php';

    return $content;
  }

  public function getMysqlStrukturTxt()
  {
    include $this->structurePath . 'mysqlstruktur.php';

    return $content;
  }

  public function getMysqlStrukturCodeTxt()
  {
    include $this->structurePath . 'mysqlstrukturcode.php';

    return $content;
  }

  public function getMysqlStrukturHlgrundsys()
  {
    include $this->structurePath . 'hlgrundsys.php';

    return $content;
  }

  public function getMysqlStrukturTablesPk()
  {
    include $this->structurePath . 'tablespk.php';

    return $content;
  }
}