Código
[/code]
<?php // ---------------------------------------------------------------------------- // markItUp! BBCode Parser // v 1.0.6 // Dual licensed under the MIT and GPL licenses. // ---------------------------------------------------------------------------- // Copyright (C) 2009 Jay Salvat // http://www.jaysalvat.com/ // http://markitup.jaysalvat.com/ // ---------------------------------------------------------------------------- // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // ---------------------------------------------------------------------------- // Thanks to Arialdo Martini, Mustafa Dindar for feedbacks. // ---------------------------------------------------------------------------- define ("EMOTICONS_DIR", Site::get_url('habari') . "/user/plugins/markup/markitup/parsers/bbcode/images/"); function BBCode2Html($text) { // BBCode [code] function escape($s) { global $text; $code = $s[1]; return '<pre><code>'.$code.'</code></pre>'; } } // Smileys to find... ':D', ':o', ':p', ':(', ';)' ); // And replace them by... '<img alt=":D" src="'.EMOTICONS_DIR.'emoticon-smile.png" />', '<img alt=":o" src="'.EMOTICONS_DIR.'emoticon-surprised.png" />', '<img alt=":p" src="'.EMOTICONS_DIR.'emoticon-tongue.png" />', '<img alt=":(" src="'.EMOTICONS_DIR.'emoticon-unhappy.png" />', '<img alt=";)" src="'.EMOTICONS_DIR.'emoticon-wink.png" />' ); // BBCode to find... '/\[i\](.*?)\[\/i\]/ms', '/\[u\](.*?)\[\/u\]/ms', '/\[img\](.*?)\[\/img\]/ms', '/\[email\](.*?)\[\/email\]/ms', '/\[url\="?(.*?)"?\](.*?)\[\/url\]/ms', '/\[size\="?(.*?)"?\](.*?)\[\/size\]/ms', '/\[color\="?(.*?)"?\](.*?)\[\/color\]/ms', '/\[quote](.*?)\[\/quote\]/ms', '/\[list\=(.*?)\](.*?)\[\/list\]/ms', '/\[list\](.*?)\[\/list\]/ms', '/\[\*\]\s?(.*?)\n/ms' ); // And replace them by... '<em>\1</em>', '<u>\1</u>', '<img src="\1" alt="\1" />', '<a href="mailto:\1">\1</a>', '<a href="\1">\2</a>', '<span style="font-size:\1%">\2</span>', '<span style="color:\1">\2</span>', '<blockquote>\1</blockquote>', '<ol start="\1">\2</ol>', '<ul>\1</ul>', '<li>\1</li>' ); // paragraphs // clean some tags to remain strict // not very elegant, but it works. No time to do better ;) function removeBr($s) { } } return $text; } ?>