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

1.1       roma7       1: <?php
                      2: 
                      3: require_once(dirname(__FILE__)."/DbField/DbFieldQuestion.class.php");
                      4: 
                      5: class DbField {
                      6:   private $field;
1.3       roma7       7:   protected $value; 
1.1       roma7       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.4     ! roma7      28:     $this->html = preg_replace('/(\s+)-+(\s+)/','\1&mdash;$2', $this->html);
        !            29:   
1.2       roma7      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: 
1.1       roma7      37:     $this->html = preg_replace('/^\s+/m', "<br>\n&nbsp;&nbsp;&nbsp;&nbsp;", $this->html);  
                     38: 
1.2       roma7      39:     if (!preg_match('/^\|/m',$this->html)) {
1.1       roma7      40:       $this->html = preg_replace('/\s+\&#0150/m','&nbsp;\&#0150', $this->html);
1.2       roma7      41:     } 
1.1       roma7      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==='';
1.3       roma7      56:   } 
                     57:   
                     58:   public function getValue() {
                     59:     return $this->value;
                     60:   }
1.1       roma7      61: }

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