Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- * Description of BBCode
- *
- * @author fabi0
- */
- namespace Models;
- class Bb {
- private static $_search = array(
- '~\[hr\]~s',
- '~\[b\](.*?)\[/b\]~s',
- '~\[i\](.*?)\[/i\]~s',
- '~\[u\](.*?)\[/u\]~s',
- '~\[quote\](.*?)\[/quote\]~s',
- '~\[size=(.*?)\](.*?)\[/size\]~s',
- '~\[color=(.*?)\](.*?)\[/color\]~s',
- '~\[url\]((?:ftp|https?)://.*?)\[/url\]~s',
- '~\[img\](https?://.*?\.(?:jpg|jpeg|gif|png|bmp))\[/img\]~s',
- '~\[p\](.*?)\[/p\]~s'
- );
- private static $_replace = array(
- '<hr/>',
- '<b>$1</b>',
- '<i>$1</i>',
- '<span style="text-decoration:underline;">$1</span>',
- '<pre>$1</pre>',
- '<span style="font-size:$1px;">$2</span>',
- '<span style="color:$1;">$2</span>',
- '<a href="$1">$1</a>',
- '<img src="$1" alt="" />',
- '<p>$1</p>'
- );
- public static function parse($code) {
- return preg_replace(self::$_search, self::$_replace, $code);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement