- 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
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
class BbCod{
function BbCod(){
}
static function BbB($text){
if (is_array($text)) {
$text = '<b>'.$text[1].'</b>';
}
return preg_replace_callback("~\[b]((?:[^[]|\[(?!/?b])|(?R))+)\[/b]~is", "BbCod::BbB" , $text);
}
static function BbI($text){
if (is_array($text)) {
$text = '<i>'.$text[1].'</i>';
}
return preg_replace_callback("~\[i]((?:[^[]|\[(?!/?i])|(?R))+)\[/i]~is", "BbCod::BbI" , $text);
}
// ...
function Bb($text, $param = array()){
if(!isset($param['b']) || $param['b'] !== false) $text = $this->BbB($text);
if(!isset($param['i']) || $param['i'] !== false) $text = $this->BbI($text);
if(!isset($param['u']) || $param['u'] !== false) $text = $this->BbU($text);
if(!isset($param['ol']) || $param['ol'] !== false) $text = $this->BbOl($text);
if(!isset($param['ul']) || $param['ul'] !== false) $text = $this->BbUl($text);
if(!isset($param['li']) || $param['li'] !== false) $text = $this->BbLi($text);
if(!isset($param['quote']) || $param['quote'] !== false) $text = $this->BbQuote($text);
if(!isset($param['left']) || $param['left'] !== false) $text = $this->BbLeft($text);
if(!isset($param['right']) || $param['right'] !== false) $text = $this->BbRight($text);
if(!isset($param['center']) || $param['center'] !== false) $text = $this->BbCenter($text);
if(!isset($param['justify']) || $param['justify'] !== false) $text = $this->BbJustify($text);
if(!isset($param['size']) || $param['size'] !== false) $text = $this->BbSize($text);
if(!isset($param['color']) || $param['color'] !== false) $text = $this->BbColor($text);
if(!isset($param['fright']) || $param['fright'] !== false) $text = $this->BbFRight($text);
if(!isset($param['fleft']) || $param['fleft'] !== false) $text = $this->BbFLeft($text);
if(!isset($param['table']) || $param['table'] !== false) $text = $this->BbTable($text);
if(!isset($param['td']) || $param['td'] !== false) $text = $this->BbTd($text);
if(!isset($param['th']) || $param['th'] !== false) $text = $this->BbTh($text);
if(!isset($param['tr']) || $param['tr'] !== false) $text = $this->BbTr($text);
if(!isset($param['br']) || $param['br'] !== false) $text = $this->BbBr($text);
if(!isset($param['hr']) || $param['hr'] !== false) $text = $this->BbHr($text);
if(!isset($param['youtube']) || $param['youtube'] !== false) $text = $this->BbYoutube($text);
if(!isset($param['img']) || $param['img'] !== false) $text = $this->BbIms($text);
if(!isset($param['src']) || $param['src'] !== false) $text = $this->BbSrc($text);
if(!isset($param['mail']) || $param['mail'] !== false) $text = $this->BbMail($text);
return $text;
}
}
// end class
Писал в само начале осваивания ООП в php. И причем такое ощущения что бухой писал)