File:  [Local Repository] / db / prgsrc / drupal / modules / chgk_db / classes / DbQuestionFactory.class.php
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Sat Mar 20 17:23:42 2010 UTC (14 years, 1 month ago) by roma7
Branches: MAIN
CVS tags: HEAD
issue http://db.chgk.info/v2/node/10

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

class DbQuestionFactory extends DbFactory {
  protected $prefix = 'DbQuestion';
  private $field;
  private $value; 
  private $map = array(
    'Я' => 'Jeopardy'
  );

  public function getQuestion($row) {
    $this->row = $row;
    if ($this->classExists()) {
      $ref = new ReflectionClass($this->getClassName());
      $result = $ref->newInstance($row);
    } else {
      $result = new DbQuestion($row);
    }
    return $result;
  }
  
  protected function getClassName() {

    if (!(isset($this->map[$this->row->Type]))) return 'DbQuestion';

    return 'DbQuestion'.$this->map[$this->row->Type];
  }
}

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