- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
<?php
class WikiParser{
private $p;
function __construct($p){
$this->p=$p;
}
function parse(){
$this->p = preg_replace('/\[\[([^\/"?[=|]+?)\]\]/siu', '<a href="link.php?sea=$1">$1</a>', $this->p);
$this->p = preg_replace('/\[\[([^\/"?[=|]+?)\|(.+?)\]\]/siu', '<a href="link.php?sea=$1">$2</a>', $this->p);
$this->p = preg_replace('/\[\[([a-z]+?:\/\/[^"|]*?)\|([^"?[=|]+?)\]\]/siu', '<a href="$1">$2</a>', $this->p);
$this->p = preg_replace('/\[\[([a-z]+?:\/\/[^"|]*?)\]\]/siu', '<a href="$1">$1</a>', $this->p);
$this->p = preg_replace('/<<([^\/"?[=|]+?)>>/siu', '<a href="link.php?sea=$1">$1</a>', $this->p);
$this->p = preg_replace('/<<([^\/"?[=|]+?)\|(.+?)>>/siu', '<a href="link.php?sea=$1">$2</a>', $this->p);
$this->p = preg_replace('/<<([a-z]+?:\/\/[^"|]*?)\|([^"?[=|]+?)>>/siu', '<a href="$1">$2</a>', $this->p);
$this->p = preg_replace('/<<([a-z]+?:\/\/[^"|]*?)>>/siu', '<a href="$1">$1</a>', $this->p);
$this->p = preg_replace('/\*\*\*?([^"?=#%]+?)\*\*\*?/siu', '<b>$1</b>', $this->p);
$this->p = preg_replace('/\-\-\-?([^"?=#%]+?)\-\-\-?/siu', '<s>$1</s>', $this->p);
$this->p = preg_replace('/\/\/\/?([^"?=#%]+?)\/\/\/?/siu', '<i>$1</i>', $this->p);
$this->p = preg_replace('/\r?\n\r?\n/', '</p><p>', $this->p);
$this->p = preg_replace('/\n/', '<br/>', $this->p);
$this->p = preg_replace('/\{\{locked\}\}/', '<table style="clear: both; width: 90%; border-color:#333333; border-style: solid; border-width: 1px 1px 1px 2px; padding: 2px; margin: 1px auto 1px auto; vertical-align: center; background-color: #fefefe; text-align: left;"><tr><td style="vertical-align: middle">Статья огорожена от <a href="link.php?sea=вапераст">ваперастов</a></td></tr></table>', $this->p);
$this->p = preg_replace('/\{\{locked\|(.*?)\}\}/', '<table style="clear: both; width: 90%; border-color:#333333; border-style: solid; border-width: 1px 1px 1px 2px; padding: 2px; margin: 1px auto 1px auto; vertical-align: center; background-color: #fefefe; text-align: left;"><tr><td style="vertical-align: middle">Статья огорожена от $1</td></tr></table>', $this->p);
$this->p = preg_replace('/\{\{недопись\}\}/siu', '<table style="clear: both; width: 90%; border-color:#333333; border-style: solid; border-width: 1px 1px 1px 2px; padding: 2px; margin: 1px auto 1px auto; vertical-align: center; background-color: #fefefe; text-align: left;"><tr><td style="vertical-align: middle"><b>Недопись</b><br>Ваша статья - Гавно. Короткая, тупая и малоинформативная</td></tr></table>', $this->p);
$this->p = preg_replace('/\{\{недопись\|([^|]*?)\}\}/siu', '<table style="clear: both; width: 90%; border-color:#333333; border-style: solid; border-width: 1px 1px 1px 2px; padding: 2px; margin: 1px auto 1px auto; vertical-align: center; background-color: #fefefe; text-align: left;"><tr><td style="vertical-align: middle">Недопись<br>Ваша статья - $1</td></tr></table>', $this->p);
$this->p = preg_replace('/\{\{moved\|(.*?)\}\}/', '<table style="clear: both; width: 90%; border-color:#333333; border-style: solid; border-width: 1px 1px 1px 2px; padding: 2px; margin: 1px auto 1px auto; vertical-align: center; background-color: #fefefe; text-align: left;"><tr><td style="vertical-align: middle"><b>Статья перемещена</b><br>-->$1</td></tr></table>', $this->p);
$this->p = preg_replace('/[[<]#[]>]/', '', $this->p);
if(!preg_match('#^<p>.*</p>$#siu', $this->p)) $this->p='<p>'.$this->p.'</p>';
$this->p = preg_replace('/<p><\/p>/siu', '', $this->p);
}
function get(){return $this->p;}
}
?>