File:  [Local Repository] / db / prgsrc / drupal / modules / chgk_db / classes / DbEditor.class.php
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Sun May 23 09:31:39 2010 UTC (14 years, 1 month ago) by roma7
Branches: MAIN
CVS tags: HEAD
Editors changes

    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: 
   18:   private function loadTours() {
   19:     $res = $this->db->editorToursRes($this->id);
   20:     $this->tours = array();
   21:     while ( $tourRow = db_fetch_object($res) ) {
   22:       $this->tours[] =DbPackage::newFromRow($tourRow);
   23:     }
   24:   }
   25: 
   26:     private function sortByYear() {
   27:       foreach ($this->tours as $tour) {
   28:         $this->years[$tour->getYear()][] = $tour;
   29:       }
   30:     }
   31: 
   32:   public function getHtmlPage() {
   33:     $this->loadTours();
   34:     $this->sortByYear();
   35:     $output = '';
   36:     foreach ($this->years as $year=>$tours) {
   37:       $output .= "<h3>".$year."</h3>\n";
   38:       $output .= '<ul>';
   39:       foreach ($tours as $t) {
   40:         $output.="<li>".l($t->getFullTitle(),$t->getLink())."</li>\n";
   41:       }
   42:       $output .= '</ul>';
   43:     }
   44: 
   45:     return $output;
   46:   }
   47:   private function setId() {
   48:       $this->id = $this->person->CharId;
   49:   }
   50: 
   51:   private function loadFromDatabase() {
   52:       $this->person = $this->db->getPersonById($this->id);
   53:   }
   54: 
   55:   public function newFromRow($row) {
   56:       return new self($row);
   57:   }
   58: 
   59:   public function getLink() {
   60:       return l($this->getFullName(),'editors/'.$this->id);
   61:   }
   62: 
   63:   public function getFullName() {
   64:       return $this->person->Name. " ". $this->person->Surname;
   65:   }
   66: 
   67:   public function getBreadcrumb() {
   68:     $breadcrumb = array(
   69:       l('Редакторы','editors')
   70:     );
   71:     return $breadcrumb;
   72:   }
   73: }

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