Source for file bbcode.inc.php
Documentation is available at bbcode.inc.php
* @author Matthias Reuter ($LastChangedBy: matthias $)
* @version $LastChangedDate: 2009-08-26 19:19:41 +0200 (Mi, 26 Aug 2009) $
* @copyright 2007-2010 IPBWI development team
* @link http://ipbwi.com/examples/bbcode.php
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
* @desc Loads and checks different vars when class is initiating
* @author Matthias Reuter
public function __construct($ipbwi){
* @desc converts BBCode to HTML using IPB's native parser.
* @param string $input bbcode-formatted string
* @param bool $smilies set to true to parse smilies, otherwise false
* @return string HTML version of input
* @author Matthias Reuter
* $ipbwi->bbcode->bbcode2html('[b]test[/b]',true);
$this->ipbwi->ips_wrapper->parser->parse_smilies = $smilies;
$this->ipbwi->ips_wrapper->parser->parse_html = 0;
$this->ipbwi->ips_wrapper->parser->parse_bbcode = 1;
$this->ipbwi->ips_wrapper->parser->strip_quotes = 1;
$this->ipbwi->ips_wrapper->parser->parse_nl2br = 1;
$input = @$this->ipbwi->ips_wrapper->parser->preDbParse($input);
// Leave this here in case things go pear-shaped...
$input = $this->ipbwi->ips_wrapper->parser->preDisplayParse($input);
$input = $this->ipbwi->properXHTML($input);
* @desc converts HTML to BBCode using IPB's native parser.
* @param string $input html-formatted string
* @return string BBCode version of input
* @author Matthias Reuter
* $ipbwi->bbcode->html2bbcode('<b>test</b>');
$this->ipbwi->ips_wrapper->parser->parse_html = 0;
$this->ipbwi->ips_wrapper->parser->parse_nl2br = 0;
$this->ipbwi->ips_wrapper->parser->parse_smilies = 1;
$this->ipbwi->ips_wrapper->parser->parse_bbcode = 1;
$this->ipbwi->ips_wrapper->parser->parsing_section = 'myapp_comment';
$input = $this->ipbwi->ips_wrapper->parser->preEditParse($input);
* @desc List emoticons, optional limit the result to clickable emoticons only.
* @param bool $clickable set to true to list clickable emoticons only, otherwise set to false
* @return array Assoc array with Emoticons, keys 'typed', 'image'
* @author Matthias Reuter
* $ipbwi->bbcode->listEmoticons(true);
$this->ipbwi->ips_wrapper->DB->query('SELECT typed, image FROM '. $this->ipbwi->board['sql_tbl_prefix']. 'emoticons WHERE clickable="1"');
$this->ipbwi->ips_wrapper->DB->query('SELECT typed, image FROM '. $this->ipbwi->board['sql_tbl_prefix']. 'emoticons');
while($row = $this->ipbwi->ips_wrapper->DB->fetch()){
$emos[$row['typed']] = $row['image'];
* @desc Print IP.board's built in RichTextEditor (RTE). notice: if your form isn't formatted correctly, please check in your css declaration of tags, e.g. "ul", wether they conflict with IP.board's editor.
* @param string $post a string of content going to be displayed in editor. If empty, a blank editor will be loaded.
* @param string $field a string which defines the name of textarea form field
* @param int $output optional, if 1: output of css & javascript, if 2: output of form, if false: output of both all together
* @param bool $rte optional, if true: force use of rich text editor
* @return string HTML Code of IP.board's RTE
* @author Matthias Reuter
* $ipbwi->bbcode->printTextEditor('post content');
public function printTextEditor($post= '',$field= 'post',$output= false,$rte= false){
$boardURL = str_replace('?','',$this->ipbwi->board['url']);
<link rel="stylesheet" type="text/css" media="screen" href="'. $boardURL. 'public/min/index.php?ipbv=31005&f=public/style_css/css_1/ipb_editor.css" />
list-style:none outside none;
<script type='text/javascript'>
jsDebug = 0; /* Must come before JS includes */
<script type='text/javascript'>
ipb.vars['base_url'] = '{ $boardURL}index.php?&';
ipb.vars['board_url'] = '{ $boardURL}';
ipb.vars['loading_img'] = '{ $boardURL}public/style_images/master/loading.gif';
ipb.vars['active_app'] = 'forums';
ipb.vars['upload_url'] = '{ $boardURL}uploads';
ipb.templates['ajax_loading'] = "<div id='ajax_loading'>" + ipb.lang['loading'] + "</div>";
<script type='text/javascript'>
<script type='text/javascript' src='http://root.pc-intern.com/development/projects.pc-intern.com/public/min/index.php?g=js'></script>
<script type='text/javascript' src='http://root.pc-intern.com/development/projects.pc-intern.com/public/min/index.php?charset=UTF-8&f=public/js/ipb.js,public/js/ips.editor.js' charset='UTF-8'></script>
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_wordwrap = 0;
IPSText::getTextClass('bbcode')->bypass_badwords = true;
IPSText::getTextClass('bbcode')->rte_width = 200;
$rte_post = IPSText::getTextClass('bbcode')->convertForRTE($post);
$form = '<div id="ipboard_body">'.
array('<#EMO_DIR#>','undefined&app=forums'),
array('default',$this->ipbwi->getBoardVar('url'). '/index.php?app=forums'),
@IPSText::getTextClass('editor')->showEditor($rte_post, $field))
// if user has set rich text editor
if($this->ipbwi->member->myInfo['members_editor_choice'] == 'rte' || $rte == true){
return $style. $jscript. $form;
// if user has set standard text editor
IPSText::getTextClass('bbcode')->parse_html = 0;
IPSText::getTextClass('bbcode')->parse_nl2br = 1;
IPSText::getTextClass('bbcode')->parse_smilies = 1;
IPSText::getTextClass('bbcode')->parse_bbcode = 1;
IPSText::getTextClass('bbcode')->parsing_section = 'global';
$std = '<div class="std_emo">';
$std .= '<img onclick="insert(\' '. htmlentities($emoticon). ' \',\' \')" src="'. $this->ipbwi->getBoardVar('emo_url'). $emoFile. '" alt="'. htmlentities($emoticon). '" style="cursor:pointer;" /> ';
$std .= '</div><textarea name="post" class="std_text" cols="40" rows="10">'. IPSText::getTextClass('bbcode')->preEditParse($post). '</textarea>';
|