<?php
require_once(dirname(__FILE__)."/../DbQuestionFactory.class.php");
class DbPackageTour extends DbPackage {
public $questions;
private $parent;
public function __construct($row, $parent = FALSE) {
parent::__construct($row);
$this->setParent($parent);
}
public function getAll() {
$this->loadQuestions();
return $this;
}
public function getPrintVersion() {
$this->loadQuestions();
$content = theme('chgk_db_tour', $this);
return theme('chgk_db_print', $this->getLongTitle(), $content);
}
public function loadQuestions() {
if (isset($this->questions)) return;
$this->questions = array();
$res = $this->db->getQuestionsRes($this->getDbId());
$factory = new DbQuestionFactory();
while ($row = $this->db->fetch_row($res)) {
$this->questions[$row->Number] = $factory->getQuestion($row);
}
}
public function setParent($parent = FALSE) {
if ($parent) {
$this->parent = $parent;
} else {
$this->parent = new DbPackageChamp($this->tour->ParentId);
}
}
public function getParent() {
if ($this->parent) {
return $this->parent;
}
return FALSE;
}
public function getLongTitle() {
return $this-> getParent()->getTitle(). ' '. $this->getTitle();
}
public function getParentInfo() {
return $this->parent->getInfo();
}
public function getParentEditor() {
return $this->parent->getEditor();
}
public function getImages() {
$this->images = array();
foreach ($this->questions as $q) {
$this->images = array_merge($this->images, $q->getImages());
}
return $this->images;
}
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>