--- db/prgsrc/drupal/modules/chgk_db/classes/DbQuestion.class.php 2010/03/21 18:06:04 1.4 +++ db/prgsrc/drupal/modules/chgk_db/classes/DbQuestion.class.php 2010/04/24 21:45:50 1.5 @@ -4,13 +4,21 @@ require_once(dirname(__FILE__)."/DbField class DbQuestion { private $question; private $fieldFactory; + protected $tour; + protected $searchString; public $fields; private $typeMap = array( 'Я' => 'Jeopardy' ); - public function __construct($row) { + public function __construct($row, $tour = null) { $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->setFields(); } @@ -41,7 +49,6 @@ class DbQuestion { } protected function setFields() { $this->setQuestionField(); - $fields = array('Answer', 'PassCriteria', 'Comments', 'Sources', 'Authors'); foreach ($fields as $field) { $this->setField($field); @@ -52,17 +59,38 @@ class DbQuestion { $this->fields['Question'] = $this->fieldFactory->getField( '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) { $f = $this->fieldFactory->getField( $field, - $this->question->{$field} + $this->question->{$field}, + false, + $this ); if ($f->isEmpty()) { return; } + if ($this->searchString) { + $f->setSearchString( $this->searchString ); + } $this->fields[$field] = $f; - } + } + + public function getUrl() { + return url($this->tour->getLink()); + } + + public function getSearchTitle() { + return $this->tour->getFullTitle(); + } }