Page 1 of 2

[RC1] Center BBcode

Posted: Sat Nov 19, 2005 12:18 pm
by Amezis
CENTER BBCODE
This is just a simple BBcode that will center the text for you. Nothing special, but can be quite useful. Very easy to install :)

SCREENSHOT
http://img512.imageshack.us/img512/1843/centered2li.gif

Also, a similar mod aligning the text to the right can be found here.

Code: Select all

##############################################################
## MOD Title: Center BBcode
## MOD Author: Amezis < N/A > (N/A) http://forum.global-rs.com
## MOD Description: Adds a [center] and [/center] BBCode tag for centering text when posting.
## MOD Version: 0.0.1
##
## Installation Level: Easy
## Installation Time: 1 Minute
## Files To Edit: 	includes/bbcode.php
#					templates/subSilver/posting_body.tpl										
## Included Files: n/a
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2 
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
############################################################## 
## Author Notes:
## 
## Only tested with phpBB 2.0.18, but should work on older versions too.
##
##############################################################
## MOD History:
##
##   2005-11-19 - Version 0.0.1
##      - MOD completed
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]------------------------------------------
#

includes/bbcode.php

#
#-----[ FIND ]------------------------------------------
#

	// [i] and [/i] for italicizing text.
	$text = str_replace("[i:$uid]", $bbcode_tpl['i_open'], $text);
	$text = str_replace("[/i:$uid]", $bbcode_tpl['i_close'], $text);

#
#-----[ AFTER, ADD ]------------------------------------------
#

	//
	// BEGIN Center BBCode MOD --------
	//
	$text = str_replace("[center:$uid]", '<div style="text-align: center;">', $text);
	$text = str_replace("[/center:$uid]", '</div>', $text);
	//
	// END CENTER BBCode MOD --------
	//

#
#-----[ FIND ]------------------------------------------
#

	// [i] and [/i] for italicizing text.
	$text = preg_replace("#\[i\](.*?)\[/i\]#si", "[i:$uid]\\1[/i:$uid]", $text);

#
#-----[ AFTER, ADD ]------------------------------------------
#

	//
	// BEGIN Center BBCode MOD --------
	//
	$text = preg_replace("#\[center\](.*?)\[/center\]#si", "[center:$uid]\\1[/center:$uid]", $text);
	//
	// END CENTER BBCode MOD --------
	//
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/posting_body.tpl

#
#-----[ FIND ]---------------------------------
#
# NOTE: the actual line to find is MUCH longer, containing all the bbcode tags
#
bbtags = new Array(

#
#-----[ IN-LINE FIND ]---------------------------------
#
'[url]','[/url]'

#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
,'[center]','[/center]'

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM 
Known bugs
None

Posted: Sat Nov 19, 2005 12:30 pm
by okada1314
have demo?

Posted: Sat Nov 19, 2005 12:33 pm
by Amezis
No, but you can look at the screenshot. It's just a simple BBCode mod ;)

Posted: Sun Nov 20, 2005 4:33 am
by babydoll2u
I added it and it works GREAT! thank you :D


edited: I'm sorry, it was a center MOD from another author that I added and that works great. But yours seems to be missing the code to place a button with the other bb buttons :?

Posted: Sun Nov 20, 2005 10:03 am
by Amezis
Thank you! :D

I'll make another one which will put the text on the right, too.

Posted: Tue Nov 22, 2005 6:14 am
by babydoll2u
-----------------------------

Posted: Tue Nov 29, 2005 8:42 pm
by JSchwage
Works wonderfully! :D

Posted: Wed Nov 30, 2005 8:48 pm
by A920
Your modification does not follow bbcode standardization guidelines.
http://www.phpbb.com/kb/article.php?article_id=147

Posted: Sat Feb 11, 2006 5:47 am
by $unny
:D great

it work

Thank U

Posted: Thu Feb 16, 2006 10:11 am
by BabyDreams
Worked great for me too!

But is there a way to add a button for the code?

:D

Posted: Thu Feb 23, 2006 11:36 am
by Matt22
Hi, this mod looks great but I'm looking for a sort of indentation, like one tab-space from the left. Is there anyway I could achive this?

Also how can I get bullet points?

Example (this is a Vbullitin board): http://totalbf2.com/forums/showthread.php?t=58391

Posted: Sun Mar 26, 2006 6:37 pm
by happyjoy2
I'm also wondering why I can't get the bbcode button to show on the posting screen next to the other bbcode tags. Any ideas?

Posted: Sun Jul 09, 2006 10:07 am
by RamEEz
working perfectly fine

Posted: Sun Jul 23, 2006 8:14 pm
by neten
If you want a button... you have to do that:


Code: Select all

# 
#-----[ OPEN ]------------------------------------------ 
#
# languages/lang_english/lang_main.php
# 
#-----[ FIND ]------------------------------------------ 
#
$lang['bbcode_f_help'] = 'Font size: [size=x-small]small text[/size]';

# 
#-----[ ADD BELOW ]------------------------------------------ 
#
$lang['bbcode_y_help'] = 'Font Center: [center]text[/center] (alt+y)';



# 
#-----[ OPEN ]------------------------------------------ 
#
# templates/xxx/bbcode.tpl
# 
#-----[ FIND ]------------------------------------------ 
#
	<!-- BEGIN i_open --><span style="font-style: italic"><!-- END i_open -->
	<!-- BEGIN i_close --></span><!-- END i_close -->

# 
#-----[ ADD BELOW ]------------------------------------------ 
#
	<!-- BEGIN center_open --><div align="center"><!-- END center_open -->
	<!-- BEGIN center_close --></div><!-- END center_close -->



# 
#-----[ OPEN ]------------------------------------------ 
#
# templates/xxx/posting_body.tpl
# 
#-----[ FIND ]------------------------------------------ 
#
f_help = "{L_BBCODE_F_HELP}";

# 
#-----[ ADD BELOW ]------------------------------------------ 
#
y_help = "{L_BBCODE_Y_HELP}";


# 
#-----[ FIND ]------------------------------------------ 
#
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','
','
  • ','
','
  • ','
','[img]','[/img]','','');

#
#-----[ IN-LINE FIND ]------------------------------------------
#
'',''

#
#-----[ IN-LINE ADD ]------------------------------------------
#
,'[center]','[/center]'


#
#-----[ FIND ]------------------------------------------
#
<input type="button" class="button" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline; width: 40px" onClick="bbstyle(16)" onMouseOver="helpline('w')" />
</span></td>

#
#-----[ ADD BELOW ]------------------------------------------
#
# see "Note" at the beginning of this guide

<td><span class="genmed">
<input type="button" class="button" accesskey="y" name="addbbcode18" value=" Center " style="width: 60px" onClick="bbstyle(18)" onMouseOver="helpline('y')" />
</span></td>

#
#-----[ FIND ]------------------------------------------
#
<select name="addbbcode18" onChange="bbfontstyle('[color=' + this.form.addbbcode18.options[this.form.addbbcode18.selectedIndex].value + ']', '[/color]')" onMouseOver="helpline('s')">

#
#-----[ REPLACE WITH ]--------------------------------------------------
#
# see "Note" at the beginning of this guide

<select name="addbbcode20" onChange="bbfontstyle('[color=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/color]')" onMouseOver="helpline('s')">

#
#-----[ FIND ]------------------------------------------
#
</select> &nbsp;{L_FONT_SIZE}:<select name="addbbcode20" onChange="bbfontstyle('[size=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/size]')" onMouseOver="helpline('f')">

#
#-----[ REPLACE WITH ]--------------------------------------------------
#
# see "Note" at the beginning of this guide

</select> &nbsp;{L_FONT_SIZE}:<select name="addbbcode22" onChange="bbfontstyle('[size=' + this.form.addbbcode22.options[this.form.addbbcode22.selectedIndex].value + ']', '[/size]')" onMouseOver="helpline('f')">[/code]

EnJoY :wink: 8)

Posted: Thu Aug 10, 2006 1:03 pm
by sancarloscity
tnx. it works.

but... do i hav to do this every time i install new template/s?