Annotation of db/prgsrc/drupal/modules/chgk_db/classes/DbQuestion.class.php, revision 1.5
1.1 roma7 1: <?php
2: require_once(dirname(__FILE__)."/DbFieldFactory.class.php");
3:
4: class DbQuestion {
5: private $question;
6: private $fieldFactory;
1.5 ! roma7 7: protected $tour;
! 8: protected $searchString;
1.1 roma7 9: public $fields;
1.3 roma7 10: private $typeMap = array(
11: 'Я' => 'Jeopardy'
12: );
1.1 roma7 13:
1.5 ! roma7 14: public function __construct($row, $tour = null) {
1.1 roma7 15: $this->question = $row;
1.5 ! roma7 16: $this->tour = $tour;
! 17: if (!$tour && $row->tourId) {
! 18: $this->tour = DbPackage::newFromQuestionRow($row,'tour');
! 19: $this->tournament = DbPackage::newFromQuestionRow($row,'tournament');
! 20: $this->tour->setParent($this->tournament);
! 21: }
1.1 roma7 22: $this->fieldFactory = new DbFieldFactory();
23: $this->setFields();
24: }
25:
1.3 roma7 26: public function getHtml() {
27: return theme('chgk_db_question', $this);
28: }
1.4 roma7 29:
30: public function getFb2() {
31: return theme('chgk_db_question_fb2', $this);
32: }
33:
34: public function getImages() {
35: $this->images = array();
36: foreach ($this->fields as $f) {
37: $this->images = array_merge($this->images, $f->getImages());
38: }
39: return $this->images;
40: }
41:
42:
1.3 roma7 43: public function getField($name) {
44: return $this->fields[$name];
45: }
46:
47: public function getNumber() {
48: return $this->question->Number;
49: }
50: protected function setFields() {
1.1 roma7 51: $this->setQuestionField();
1.2 roma7 52: $fields = array('Answer', 'PassCriteria', 'Comments', 'Sources', 'Authors');
1.1 roma7 53: foreach ($fields as $field) {
54: $this->setField($field);
55: }
56: }
57:
58: private function setQuestionField() {
59: $this->fields['Question'] = $this->fieldFactory->getField(
60: 'Question',
61: $this->question->Question,
1.5 ! roma7 62: $this->question->Number,
! 63: $this
! 64: );
! 65: }
! 66: public function setSearchString($string) {
! 67: $this->searchString =$string;
! 68: }
! 69:
! 70: public function getSearchString() {
! 71: return $this->searchString;
1.1 roma7 72: }
73: private function setField($field) {
74: $f = $this->fieldFactory->getField(
75: $field,
1.5 ! roma7 76: $this->question->{$field},
! 77: false,
! 78: $this
1.1 roma7 79: );
80: if ($f->isEmpty()) {
81: return;
82: }
1.5 ! roma7 83: if ($this->searchString) {
! 84: $f->setSearchString( $this->searchString );
! 85: }
1.1 roma7 86: $this->fields[$field] = $f;
1.5 ! roma7 87: }
! 88:
! 89: public function getUrl() {
! 90: return url($this->tour->getLink());
! 91: }
! 92:
! 93: public function getSearchTitle() {
! 94: return $this->tour->getFullTitle();
! 95: }
1.1 roma7 96: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>