Annotation of db/prgsrc/drupal/modules/chgk_db/classes/DbField.class.php, revision 1.2

1.1       roma7       1: <?php
                      2: 
                      3: require_once(dirname(__FILE__)."/DbField/DbFieldQuestion.class.php");
                      4: 
                      5: class DbField {
                      6:   private $field;
                      7:   private $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() {
1.2     ! roma7      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: 
1.1       roma7      35:     $this->html = preg_replace('/^\s+/m', "<br>\n&nbsp;&nbsp;&nbsp;&nbsp;", $this->html);  
                     36: 
1.2     ! roma7      37:     if (!preg_match('/^\|/m',$this->html)) {
1.1       roma7      38:       $this->html = preg_replace('/\s+\&#0150/m','&nbsp;\&#0150', $this->html);
1.2     ! roma7      39:     } 
1.1       roma7      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: }

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