File:  [Local Repository] / db / prgsrc / drupal / modules / chgk_db / classes / DbEditor.class.php
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Sat Apr 24 21:45:50 2010 UTC (14 years, 2 months ago) by roma7
Branches: MAIN
CVS tags: HEAD
Version 2 big update

    1: <?php
    2: 
    3: class DbEditor {
    4:   private $db;
    5:   private $person;
    6:   private $id;
    7:   public function __construct($row) {
    8:     $this->db = new DbDatabase();
    9:     if (is_object($row)) {
   10:       $this->person = $row;
   11:       $this->setId();
   12:     } else {
   13:       $this->id = $row;
   14:       $this->loadFromDatabase();
   15:     }
   16:   }
   17:   public function getHtmlPage() {
   18:     $res = $this->db->editorToursRes($this->id);
   19:     $this->tours = array();
   20:     while ( $tourRow = db_fetch_object($res) ) {
   21:       $this->tours[] =DbPackage::newFromRow($tourRow);
   22:     }
   23:     $output = '';
   24:     $output .= '<ul>';
   25:     foreach ($this->tours as $t) {
   26:       $output.="<li>".l($t->getFullTitle(),$t->getLink())."</li>\n";
   27:     }
   28:     $output .= '</ul>';
   29: 
   30:     return $output;
   31:   }
   32:   private function setId() {
   33:       $this->id = $this->person->CharId;
   34:   }
   35: 
   36:   private function loadFromDatabase() {
   37:       $this->person = $this->db->getPersonById($this->id);
   38:   }
   39: 
   40:   public function newFromRow($row) {
   41:       return new self($row);
   42:   }
   43: 
   44:   public function getLink() {
   45:       return l($this->getFullName(),'editors/'.$this->id);
   46:   }
   47: 
   48:   public function getFullName() {
   49:       return $this->person->Name. " ". $this->person->Surname;
   50:   }
   51: 
   52:   public function getBreadcrumb() {
   53:     $breadcrumb = array(
   54:       l('Редакторы','editors')
   55:     );
   56:     return $breadcrumb;
   57:   }
   58: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>