File:  [Local Repository] / db / prgsrc / drupal / modules / chgk_db / classes / DbFieldFactory.class.php
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Sun Feb 28 20:17:33 2010 UTC (14 years, 2 months ago) by roma7
Branches: MAIN
CVS tags: HEAD
Initial edition of drupal version

<?php
require_once(dirname(__FILE__)."/DbField.class.php");

class DbFieldFactory {
  private $field;
  private $value; 

  public function getField($field, $value, $number = false) {
    $this->field = $field;
    $this->value = $value;
    if ($this->classExists()) {
      $ref = new ReflectionClass($this->getClassName());
      $result = $ref->newInstance($field, $value, $number);
    } else {
      $result = new DbField($field, $value, $number);
    }
    return $result;
  }
  
  private function getClassName() {
    return 'DbField'.$this->field;
  }
  
  private function getFileName() {
    return dirname(__FILE__)."/DbField/".$this->getClassName().".class.php";
  }
  
  private function classExists() {
    if ( $this->fileExists() ) {
      require_once($this->getFileName());      
    }
    return class_exists($this->getClassName());
  }
  
  private function fileExists() {
    return file_exists($this->getFileName());
  }
  
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>