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, 3 months ago) by roma7
Branches: MAIN
CVS tags: HEAD
issue http://db.chgk.info/v2/node/10

    1: <?php
    2: require_once(dirname(__FILE__)."/DbQuestion.class.php");
    3: require_once(dirname(__FILE__)."/DbFactory.class.php");
    4: 
    5: class DbQuestionFactory extends DbFactory {
    6:   protected $prefix = 'DbQuestion';
    7:   private $field;
    8:   private $value; 
    9:   private $map = array(
   10:     'Я' => 'Jeopardy'
   11:   );
   12: 
   13:   public function getQuestion($row) {
   14:     $this->row = $row;
   15:     if ($this->classExists()) {
   16:       $ref = new ReflectionClass($this->getClassName());
   17:       $result = $ref->newInstance($row);
   18:     } else {
   19:       $result = new DbQuestion($row);
   20:     }
   21:     return $result;
   22:   }
   23:   
   24:   protected function getClassName() {
   25: 
   26:     if (!(isset($this->map[$this->row->Type]))) return 'DbQuestion';
   27: 
   28:     return 'DbQuestion'.$this->map[$this->row->Type];
   29:   }
   30: }

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