version 1.8, 2010/04/24 18:04:15
|
version 1.9, 2010/04/24 21:45:50
|
Line 11 class DbField {
|
Line 11 class DbField {
|
protected $fb2; |
protected $fb2; |
protected $poems; |
protected $poems; |
protected $codes; |
protected $codes; |
|
protected $searchString; |
|
protected $parent; |
|
|
public function __construct($field, $value, $number = false) { |
public function __construct($field, $value, $number = false, $parent = null) { |
$this->field = $field; |
$this->field = $field; |
$this->value = $value; |
$this->value = $value; |
$this->number = $number; |
$this->number = $number; |
$this->getHtml(); |
$this->parent = $parent; |
} |
} |
|
|
|
|
public function getHtml() { |
public function getHtml() { |
|
|
if ($this->html) { |
if ($this->html) { |
return $this->html; |
return $this->html; |
} |
} |
|
|
$this->html = $this->value; |
$this->html = $this->value; |
$this->formatHtml(); |
$this->formatHtml(); |
return $this->html; |
return $this->html; |
Line 91 class DbField {
|
Line 95 class DbField {
|
|
|
} |
} |
$this->fb2 = $result; |
$this->fb2 = $result; |
$this->fb2 = preg_replace('/ -+(\s+)/',' —$1', $this->fb2); |
// $this->fb2 = preg_replace('/ -+(\s+)/',' —$1', $this->fb2); |
$this->fb2 = preg_replace('/\(pic: ([^\)]*)\)/','<image l:href="#$1" />', $this->fb2); |
$this->fb2 = preg_replace('/\(pic: ([^\)]*)\)/','<image l:href="#$1" />', $this->fb2); |
return $this->fb2; |
return $this->fb2; |
} |
} |
Line 165 class DbField {
|
Line 169 class DbField {
|
$this->html = preg_replace('/\s+\–/m',' \–', $this->html); |
$this->html = preg_replace('/\s+\–/m',' \–', $this->html); |
} |
} |
$this->html = preg_replace('/\(pic: ([^\)]*)\)/','<p><img src="/images/db/$1"></p>', $this->html); |
$this->html = preg_replace('/\(pic: ([^\)]*)\)/','<p><img src="/images/db/$1"></p>', $this->html); |
|
|
|
if ($this->getSearchString()) { |
|
$this->highLight(); |
|
} |
} |
} |
|
|
|
protected function highLight() { |
|
$sstr = $this->getSearchString(); |
|
setlocale(LC_ALL, 'ru_RU.utf8'); |
|
preg_match_all('/[\wа-я]{4,}\*?/iu', $sstr, $matchs); |
|
$terms= $matchs[0]; |
|
foreach ($terms as $term) { |
|
if ( preg_match('/\*$/', $term) ) { |
|
$letters=preg_replace('/\*/', '', $term); |
|
$this->html = preg_replace("/{$letters}[\wа-я]*/iu", |
|
'<strong>$0</strong>', $this->html); |
|
} else { |
|
$this->html = str_replace($term, '<strong>'.$term."</strong>", $this->html); |
|
} |
|
} |
|
} |
|
|
public function getName() { |
public function getName() { |
return $this->field; |
return $this->field; |
} |
} |
Line 190 class DbField {
|
Line 213 class DbField {
|
$this->images = $matches[1]; |
$this->images = $matches[1]; |
return $this->images; |
return $this->images; |
} |
} |
|
|
|
public function getSearchString() { |
|
if (!$this->parent) { |
|
return ''; |
|
} |
|
return $this->parent->getSearchString(); |
|
} |
} |
} |