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

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() {
        !            28:     $this->html = preg_replace('/^\s+/m', "<br>\n&nbsp;&nbsp;&nbsp;&nbsp;", $this->html);  
        !            29: 
        !            30:     if (!preg_match('/^\|/m')) {
        !            31:       $this->html = preg_replace('/\s+\&#0150/m','&nbsp;\&#0150', $this->html);
        !            32:     }
        !            33:     
        !            34:     $this->html = preg_replace('/\(pic: ([^\)]*)\)/','<p><img src="/images/db/$1"></p>', $this->html);
        !            35:     
        !            36:     
        !            37:   }
        !            38:   
        !            39:   public function getName() {
        !            40:     return $this->field;
        !            41:   }
        !            42: 
        !            43:   public function getNumber() {
        !            44:     return $this->number;
        !            45:   }
        !            46: 
        !            47:   public function isEmpty() {
        !            48:     return $this->value === NULL || $this->value==='';
        !            49:   }  
        !            50: }

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