File:  [Local Repository] / db / prgsrc / drupal / modules / chgk_db / classes / DbField.class.php
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Tue Mar 9 21:08:33 2010 UTC (14 years, 3 months ago) by roma7
Branches: MAIN
CVS tags: HEAD
Missing Authors field is added to print version

    1: <?php
    2: 
    3: require_once(dirname(__FILE__)."/DbField/DbFieldQuestion.class.php");
    4: 
    5: class DbField {
    6:   private $field;
    7:   protected $value; 
    8:   private $number;
    9:   private $html;
   10:   public function __construct($field, $value, $number = false) {
   11:     $this->field = $field;
   12:     $this->value = $value;
   13:     $this->number = $number;
   14:     $this->getHtml();
   15:   }
   16: 
   17:   
   18:   public function getHtml() {
   19:     if ($this->html) {
   20:       return $this->html;
   21:     }    
   22:     $this->html = $this->value;
   23:     $this->formatHtml();
   24:     return $this->html;
   25:   }
   26:   
   27:   public function formatHtml() {
   28:     $this->html = preg_replace('/\[Раздаточный материал:(.*?)\]\s*\n/sm',
   29:         "<div class=\"razdatka\"><div class=\"razdatka_header\">Раздаточный материал</div> \\1</div>\n",
   30:          $this->html  );
   31:     $this->html = preg_replace('/^\s*<раздатка>(.*?)<\/раздатка>/sm',
   32:         "<div class=\"razdatka\"><div class=\"razdatka_header\">Раздаточный материал</div> \\1</div>\n",
   33:          $this->html  );
   34: 
   35:     $this->html = preg_replace('/^\s+/m', "<br>\n&nbsp;&nbsp;&nbsp;&nbsp;", $this->html);  
   36: 
   37:     if (!preg_match('/^\|/m',$this->html)) {
   38:       $this->html = preg_replace('/\s+\&#0150/m','&nbsp;\&#0150', $this->html);
   39:     } 
   40:     $this->html = preg_replace('/\(pic: ([^\)]*)\)/','<p><img src="/images/db/$1"></p>', $this->html);
   41:     
   42:   }
   43:   
   44:   public function getName() {
   45:     return $this->field;
   46:   }
   47: 
   48:   public function getNumber() {
   49:     return $this->number;
   50:   }
   51: 
   52:   public function isEmpty() {
   53:     return $this->value === NULL || $this->value==='';
   54:   } 
   55:   
   56:   public function getValue() {
   57:     return $this->value;
   58:   }
   59: }

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