File:  [Local Repository] / db / prgsrc / drupal / modules / chgk_db / classes / DbQuestion.class.php
Revision 1.3: 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__)."/DbFieldFactory.class.php");

class DbQuestion {
  private $question;
  private $fieldFactory;
  public $fields;
  private $typeMap = array(
    'Я' => 'Jeopardy'
  );
  
  public function __construct($row) {
    $this->question = $row;
    $this->fieldFactory = new DbFieldFactory();
    $this->setFields();
  }
  
  public function getHtml() {
    return theme('chgk_db_question', $this);  
  }
  
  public function getField($name) {
    return $this->fields[$name];
  }
  
  public function getNumber() {
    return $this->question->Number;
  }
  protected function setFields() {
    $this->setQuestionField();

    $fields = array('Answer', 'PassCriteria', 'Comments', 'Sources', 'Authors');
    foreach ($fields as $field) {
      $this->setField($field);
    }
  }
  
  private function setQuestionField() {
    $this->fields['Question'] = $this->fieldFactory->getField(
      'Question', 
      $this->question->Question, 
      $this->question->Number);
  }
  
  private function setField($field) {  
    $f = $this->fieldFactory->getField(
      $field, 
      $this->question->{$field}
    );
    if ($f->isEmpty()) {
      return;
    }
    $this->fields[$field] = $f;
  }
  
  
}

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