version 1.2, 2010/03/09 21:08:33
|
version 1.5, 2010/04/24 21:45:50
|
Line 4 require_once(dirname(__FILE__)."/DbField
|
Line 4 require_once(dirname(__FILE__)."/DbField
|
class DbQuestion { |
class DbQuestion { |
private $question; |
private $question; |
private $fieldFactory; |
private $fieldFactory; |
|
protected $tour; |
|
protected $searchString; |
public $fields; |
public $fields; |
|
private $typeMap = array( |
|
'Я' => 'Jeopardy' |
|
); |
|
|
public function __construct($row) { |
public function __construct($row, $tour = null) { |
$this->question = $row; |
$this->question = $row; |
|
$this->tour = $tour; |
|
if (!$tour && $row->tourId) { |
|
$this->tour = DbPackage::newFromQuestionRow($row,'tour'); |
|
$this->tournament = DbPackage::newFromQuestionRow($row,'tournament'); |
|
$this->tour->setParent($this->tournament); |
|
} |
$this->fieldFactory = new DbFieldFactory(); |
$this->fieldFactory = new DbFieldFactory(); |
$this->setFields(); |
$this->setFields(); |
} |
} |
|
|
private function setFields() { |
public function getHtml() { |
$this->setQuestionField(); |
return theme('chgk_db_question', $this); |
|
} |
|
|
|
public function getFb2() { |
|
return theme('chgk_db_question_fb2', $this); |
|
} |
|
|
|
public function getImages() { |
|
$this->images = array(); |
|
foreach ($this->fields as $f) { |
|
$this->images = array_merge($this->images, $f->getImages()); |
|
} |
|
return $this->images; |
|
} |
|
|
|
|
|
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'); |
$fields = array('Answer', 'PassCriteria', 'Comments', 'Sources', 'Authors'); |
foreach ($fields as $field) { |
foreach ($fields as $field) { |
$this->setField($field); |
$this->setField($field); |
Line 25 class DbQuestion {
|
Line 59 class DbQuestion {
|
$this->fields['Question'] = $this->fieldFactory->getField( |
$this->fields['Question'] = $this->fieldFactory->getField( |
'Question', |
'Question', |
$this->question->Question, |
$this->question->Question, |
$this->question->Number); |
$this->question->Number, |
|
$this |
|
); |
|
} |
|
public function setSearchString($string) { |
|
$this->searchString =$string; |
|
} |
|
|
|
public function getSearchString() { |
|
return $this->searchString; |
} |
} |
|
|
private function setField($field) { |
private function setField($field) { |
$f = $this->fieldFactory->getField( |
$f = $this->fieldFactory->getField( |
$field, |
$field, |
$this->question->{$field} |
$this->question->{$field}, |
|
false, |
|
$this |
); |
); |
if ($f->isEmpty()) { |
if ($f->isEmpty()) { |
return; |
return; |
} |
} |
|
if ($this->searchString) { |
|
$f->setSearchString( $this->searchString ); |
|
} |
$this->fields[$field] = $f; |
$this->fields[$field] = $f; |
} |
} |
|
|
|
public function getUrl() { |
|
return url($this->tour->getLink()); |
|
} |
|
|
|
public function getSearchTitle() { |
|
return $this->tour->getFullTitle(); |
|
} |
} |
} |