[RC1] Align Right BBcode

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Post Reply
Amezis
Registered User
Posts: 116
Joined: Sun Jul 24, 2005 9:10 am
Location: Oslo, Norway
Contact:

[RC1] Align Right BBcode

Post by Amezis »

Align Right BBcode
This is just a simple mod that adds a [right] and [/right] BBCode tag for aligning the text to the right when posting.

For [center] BBcode tags, check this topic.

Code: Select all

##############################################################
## MOD Title: Align Right BBcode
## MOD Author: Amezis < N/A > (N/A) http://forum.global-rs.com
## MOD Description: Adds a [right] and [/right] BBCode tag for aligning the text to the right when posting.
## MOD Version: 1.0.0
##
## 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 and newer phpBB versions, but should
## work on older versions too.
##
##############################################################
## MOD History:
##
##   2005-11-20 - Version 1.0.0
##      - 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 Right BBCode MOD --------
   //
   $text = str_replace("[right:$uid]", '<div style="text-align: right;">', $text);
   $text = str_replace("[/right:$uid]", '</div>', $text);
   //
   // END Right BBCode MOD --------
   //

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

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

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

   //
   // BEGIN Right BBCode MOD --------
   //
   $text = preg_replace("#\[right\](.*?)\[/right\]#si", "[right:$uid]\\1[/right:$uid]", $text);
   //
   // END Right 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 ]---------------------------------
#
,'[right]','[/right]'

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
Last edited by Amezis on Wed Feb 08, 2006 7:02 pm, edited 1 time in total.
Amezis

Wise men talk because they have something to say; fools, because they have to say something. -Plato

babydoll2u
Registered User
Posts: 214
Joined: Sun Sep 18, 2005 11:26 pm
Contact:

Post by babydoll2u »

yaaaaaaaaayyyyy!!! I've been waiting for this! :D
Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience

Amezis
Registered User
Posts: 116
Joined: Sun Jul 24, 2005 9:10 am
Location: Oslo, Norway
Contact:

Post by Amezis »

Thanks! :)
Amezis

Wise men talk because they have something to say; fools, because they have to say something. -Plato

babydoll2u
Registered User
Posts: 214
Joined: Sun Sep 18, 2005 11:26 pm
Contact:

Post by babydoll2u »

I hope to do it this afternoon... I'll post back here ;)
Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience

babydoll2u
Registered User
Posts: 214
Joined: Sun Sep 18, 2005 11:26 pm
Contact:

Post by babydoll2u »

for whatever reason, this isn't working for me....

here's the code I have:


includes/bbcode.php:

//
  • and
    • for (un)ordered lists.
      // unordered lists
      $text = str_replace("[list:$uid]", $bbcode_tpl['ulist_open'], $text);
      // li tags
      $text = str_replace("[*:$uid]", $bbcode_tpl['listitem'], $text);
      // ending tags
      $text = str_replace("[/list:u:$uid]", $bbcode_tpl['ulist_close'], $text);
      $text = str_replace("[/list:o:$uid]", $bbcode_tpl['olist_close'], $text);
      // Ordered lists
      $text = preg_replace("/\
      • ):$uid\]/si", $bbcode_tpl['olist_open'], $text);

        // colours
        $text = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+):$uid\]/si", $bbcode_tpl['color_open'], $text);
        $text = str_replace("[/color:$uid]", $bbcode_tpl['color_close'], $text);

        // size
        $text = preg_replace("/\[size=([1-2]?[0-9]):$uid\]/si", $bbcode_tpl['size_open'], $text);
        $text = str_replace("[/size:$uid]", $bbcode_tpl['size_close'], $text);

        // and for bolding text.
        $text = str_replace("[b:$uid]", $bbcode_tpl['b_open'], $text);
        $text = str_replace("[/b:$uid]", $bbcode_tpl['b_close'], $text);

        // and for underlining text.
        $text = str_replace("[u:$uid]", $bbcode_tpl['u_open'], $text);
        $text = str_replace("[/u:$uid]", $bbcode_tpl['u_close'], $text);

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

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


        // Patterns and replacements for URL and email tags..
        $patterns = array();
        $replacements = array();

        and....


        //
        • and
          • for (un)ordered lists.
            // unordered lists
            $text = str_replace("[list:$uid]", $bbcode_tpl['ulist_open'], $text);
            // li tags
            $text = str_replace("[*:$uid]", $bbcode_tpl['listitem'], $text);
            // ending tags
            $text = str_replace("[/list:u:$uid]", $bbcode_tpl['ulist_close'], $text);
            $text = str_replace("[/list:o:$uid]", $bbcode_tpl['olist_close'], $text);
            // Ordered lists
            $text = preg_replace("/\
            • ):$uid\]/si", $bbcode_tpl['olist_open'], $text);

              // colours
              $text = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+):$uid\]/si", $bbcode_tpl['color_open'], $text);
              $text = str_replace("[/color:$uid]", $bbcode_tpl['color_close'], $text);

              // size
              $text = preg_replace("/\[size=([1-2]?[0-9]):$uid\]/si", $bbcode_tpl['size_open'], $text);
              $text = str_replace("[/size:$uid]", $bbcode_tpl['size_close'], $text);

              // and for bolding text.
              $text = str_replace("[b:$uid]", $bbcode_tpl['b_open'], $text);
              $text = str_replace("[/b:$uid]", $bbcode_tpl['b_close'], $text);

              // and for underlining text.
              $text = str_replace("[u:$uid]", $bbcode_tpl['u_open'], $text);
              $text = str_replace("[/u:$uid]", $bbcode_tpl['u_close'], $text);

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

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


              // Patterns and replacements for URL and email tags..
              $patterns = array();
              $replacements = array();


              and in subsilver/posting_body.tpl:

              '[img]','[/img]','','','[right]','[/right]');


              any idea why it's not working?
Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience

babydoll2u
Registered User
Posts: 214
Joined: Sun Sep 18, 2005 11:26 pm
Contact:

Post by babydoll2u »

ok one thing that you didn't do was add the code for a button. I would definitely want a button up there 8O
Never, ever, argue with an idiot. They'll drag you down to their level and beat you with experience

Mystre
Registered User
Posts: 19
Joined: Mon Jan 02, 2006 10:36 pm

Post by Mystre »

Now, don't ask me why, but for some reason I was not expecting this to affect the img bbcode, and it does, I THINK this is a good thing.

So now with the img=left|right with text wrap mod, and this mod, I get A LOT of layout control.

Amezis
Registered User
Posts: 116
Joined: Sun Jul 24, 2005 9:10 am
Location: Oslo, Norway
Contact:

Post by Amezis »

Well, do you have any problems with the mod...?
Amezis

Wise men talk because they have something to say; fools, because they have to say something. -Plato

Mystre
Registered User
Posts: 19
Joined: Mon Jan 02, 2006 10:36 pm

Post by Mystre »

works fine

Amezis
Registered User
Posts: 116
Joined: Sun Jul 24, 2005 9:10 am
Location: Oslo, Norway
Contact:

Post by Amezis »

Ok, good :D
Amezis

Wise men talk because they have something to say; fools, because they have to say something. -Plato

Post Reply

Return to “[2.0.x] MODs in Development”