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, 2 months ago) by roma7
Branches: MAIN
CVS tags: HEAD
mdash in print version

<?php

require_once(dirname(__FILE__)."/DbField/DbFieldQuestion.class.php");

class DbField {
  private $field;
  protected $value; 
  private $number;
  private $html;
  public function __construct($field, $value, $number = false) {
    $this->field = $field;
    $this->value = $value;
    $this->number = $number;
    $this->getHtml();
  }

  
  public function getHtml() {
    if ($this->html) {
      return $this->html;
    }    
    $this->html = $this->value;
    $this->formatHtml();
    return $this->html;
  }
  
  public function formatHtml() {
    $this->html = preg_replace('/(\s+)-+(\s+)/','\1&mdash;$2', $this->html);
  
    $this->html = preg_replace('/\[Раздаточный материал:(.*?)\]\s*\n/sm',
        "<div class=\"razdatka\"><div class=\"razdatka_header\">Раздаточный материал</div> \\1</div>\n",
         $this->html  );
    $this->html = preg_replace('/^\s*<раздатка>(.*?)<\/раздатка>/sm',
        "<div class=\"razdatka\"><div class=\"razdatka_header\">Раздаточный материал</div> \\1</div>\n",
         $this->html  );

    $this->html = preg_replace('/^\s+/m', "<br>\n&nbsp;&nbsp;&nbsp;&nbsp;", $this->html);  

    if (!preg_match('/^\|/m',$this->html)) {
      $this->html = preg_replace('/\s+\&#0150/m','&nbsp;\&#0150', $this->html);
    } 
    $this->html = preg_replace('/\(pic: ([^\)]*)\)/','<p><img src="/images/db/$1"></p>', $this->html);
    
  }
  
  public function getName() {
    return $this->field;
  }

  public function getNumber() {
    return $this->number;
  }

  public function isEmpty() {
    return $this->value === NULL || $this->value==='';
  } 
  
  public function getValue() {
    return $this->value;
  }
}

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