File:  [Local Repository] / db / prgsrc / drupal / modules / chgk_db / classes / DbPackage / DbPackageTour.class.php
Revision 1.4: download - view: text, annotated - select for diffs - revision graph
Sun Mar 21 18:06:04 2010 UTC (14 years, 3 months ago) by roma7
Branches: MAIN
CVS tags: HEAD
FB2 export

<?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>