Annotation of db/prgsrc/drupal/modules/chgk_db/classes/DbQuestion.class.php, revision 1.3

1.1       roma7       1: <?php 
                      2: require_once(dirname(__FILE__)."/DbFieldFactory.class.php");
                      3: 
                      4: class DbQuestion {
                      5:   private $question;
                      6:   private $fieldFactory;
                      7:   public $fields;
1.3     ! roma7       8:   private $typeMap = array(
        !             9:     'Я' => 'Jeopardy'
        !            10:   );
1.1       roma7      11:   
                     12:   public function __construct($row) {
                     13:     $this->question = $row;
                     14:     $this->fieldFactory = new DbFieldFactory();
                     15:     $this->setFields();
                     16:   }
                     17:   
1.3     ! roma7      18:   public function getHtml() {
        !            19:     return theme('chgk_db_question', $this);  
        !            20:   }
        !            21:   
        !            22:   public function getField($name) {
        !            23:     return $this->fields[$name];
        !            24:   }
        !            25:   
        !            26:   public function getNumber() {
        !            27:     return $this->question->Number;
        !            28:   }
        !            29:   protected function setFields() {
1.1       roma7      30:     $this->setQuestionField();
                     31: 
1.2       roma7      32:     $fields = array('Answer', 'PassCriteria', 'Comments', 'Sources', 'Authors');
1.1       roma7      33:     foreach ($fields as $field) {
                     34:       $this->setField($field);
                     35:     }
                     36:   }
                     37:   
                     38:   private function setQuestionField() {
                     39:     $this->fields['Question'] = $this->fieldFactory->getField(
                     40:       'Question', 
                     41:       $this->question->Question, 
                     42:       $this->question->Number);
                     43:   }
                     44:   
                     45:   private function setField($field) {  
                     46:     $f = $this->fieldFactory->getField(
                     47:       $field, 
                     48:       $this->question->{$field}
                     49:     );
                     50:     if ($f->isEmpty()) {
                     51:       return;
                     52:     }
                     53:     $this->fields[$field] = $f;
                     54:   }
                     55:   
1.3     ! roma7      56:   
1.1       roma7      57: }

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