<?php
class DbEditor {
private $db;
private $person;
private $id;
public function __construct($row) {
$this->db = new DbDatabase();
if (is_object($row)) {
$this->person = $row;
$this->setId();
} else {
$this->id = $row;
$this->loadFromDatabase();
}
}
private function loadTours() {
$res = $this->db->editorToursRes($this->id);
$this->tours = array();
while ( $tourRow = db_fetch_object($res) ) {
$this->tours[] =DbPackage::newFromRow($tourRow);
}
}
private function sortByYear() {
foreach ($this->tours as $tour) {
$this->years[$tour->getYear()][] = $tour;
}
}
public function getHtmlPage() {
$this->loadTours();
$this->sortByYear();
$output = '';
foreach ($this->years as $year=>$tours) {
$output .= "<h3>".$year."</h3>\n";
$output .= '<ul>';
foreach ($tours as $t) {
$output.="<li>".l($t->getFullTitle(),$t->getLink())."</li>\n";
}
$output .= '</ul>';
}
return $output;
}
private function setId() {
$this->id = $this->person->CharId;
}
private function loadFromDatabase() {
$this->person = $this->db->getPersonById($this->id);
}
public function newFromRow($row) {
return new self($row);
}
public function getLink() {
return l($this->getFullName(),'editors/'.$this->id);
}
public function getFullName() {
return $this->person->Name. " ". $this->person->Surname;
}
public function getBreadcrumb() {
$breadcrumb = array(
l('Редакторы','editors')
);
return $breadcrumb;
}
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>