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