File:  [Local Repository] / db / prgsrc / drupal / modules / chgk_db / classes / DbField.class.php
Revision 1.4: download - view: text, annotated - select for diffs - revision graph
Tue Mar 9 21:17:40 2010 UTC (14 years, 3 months ago) by roma7
Branches: MAIN
CVS tags: HEAD
mdash in 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+)-+(\s+)/','\1&mdash;$2', $this->html);
   29:   
   30:     $this->html = preg_replace('/\[Раздаточный материал:(.*?)\]\s*\n/sm',
   31:         "<div class=\"razdatka\"><div class=\"razdatka_header\">Раздаточный материал</div> \\1</div>\n",
   32:          $this->html  );
   33:     $this->html = preg_replace('/^\s*<раздатка>(.*?)<\/раздатка>/sm',
   34:         "<div class=\"razdatka\"><div class=\"razdatka_header\">Раздаточный материал</div> \\1</div>\n",
   35:          $this->html  );
   36: 
   37:     $this->html = preg_replace('/^\s+/m', "<br>\n&nbsp;&nbsp;&nbsp;&nbsp;", $this->html);  
   38: 
   39:     if (!preg_match('/^\|/m',$this->html)) {
   40:       $this->html = preg_replace('/\s+\&#0150/m','&nbsp;\&#0150', $this->html);
   41:     } 
   42:     $this->html = preg_replace('/\(pic: ([^\)]*)\)/','<p><img src="/images/db/$1"></p>', $this->html);
   43:     
   44:   }
   45:   
   46:   public function getName() {
   47:     return $this->field;
   48:   }
   49: 
   50:   public function getNumber() {
   51:     return $this->number;
   52:   }
   53: 
   54:   public function isEmpty() {
   55:     return $this->value === NULL || $this->value==='';
   56:   } 
   57:   
   58:   public function getValue() {
   59:     return $this->value;
   60:   }
   61: }

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