[2.0.12] Hide BBcode MOD

The cleanup is complete. This forum is now read only.

Rating:

Excellent!
42
72%
Very Good
3
5%
Good
8
14%
Fair
0
No votes
Poor
5
9%
 
Total votes: 58

User avatar
thewizard
Registered User
Posts: 356
Joined: Sun Sep 29, 2002 7:46 am

Post by thewizard »

I changed the Bbcode.tpl to this and it works now. Great mod.

Code: Select all

<!-- BEGIN hide_open -->
<script language="javascript1.2" type="text/javascript">

   hideBBCode.open('{L_HIDE}');

</script>
<!-- END hide_open -->

<!-- BEGIN hide_owntext_open -->
<script language="javascript1.2" type="text/javascript">

   hideBBCode.open('{L_HIDE}');

</script>
<!-- END hide_owntext_open -->

<!-- BEGIN hide_close -->
<script language="javascript1.2" type="text/javascript">

   hideBBCode.close();

</script>
<!-- END hide_close -->

markus_petrux
Former Team Member
Posts: 1887
Joined: Wed Apr 23, 2003 7:11 am
Location: Girona, Catalunya (Spain)
Contact:

Post by markus_petrux »

thewizard: Don't forget the lines marked below in red. They are there to prevent browsers with no javascript support (or javascript disabled) to display javascript code in the middle of the page. :wink:
<!-- BEGIN hide_open -->
<script language="javascript1.2" type="text/javascript">
<!--

hideBBCode.open('{L_HIDE}');

//-->
</script>
<!-- END hide_open -->
<!-- BEGIN hide_owntext_open -->
<script language="javascript1.2" type="text/javascript">
<!--

hideBBCode.open('{L_HIDE}');

//-->
</script>
<!-- END hide_owntext_open -->
<!-- BEGIN hide_close -->
<script language="javascript1.2" type="text/javascript">
<!--

hideBBCode.close();

//-->
</script>
<!-- END hide_close -->
EasyMOD Standards | MOD Template Actions | MODs in Development Rules
Useful information for MOD Authors | MOD Queue Stats | Search MODs
Write SQL/DDL portable to all SQL servers supported by phpBB!
Get EasyMOD 0.3.0! | Suport al phpBB en Català!
8)

EGIS
Registered User
Posts: 60
Joined: Sat Apr 24, 2004 3:37 am
Location: Norway
Contact:

Post by EGIS »

I fully agree with you markus_petrux.
I know i shouldn't have suggested to remove those lines, I told him to try adding more linebreaks first. But of some reason his board remove the lines.

I think you should do like markus_petrux said thewizard, forget what I said about removing those lines ;)
My mod: [Hide BBcode MOD]

markus_petrux
Former Team Member
Posts: 1887
Joined: Wed Apr 23, 2003 7:11 am
Location: Girona, Catalunya (Spain)
Contact:

Post by markus_petrux »

TBH, I didn't read your full answer, EGIS. :oops: I just saw thewizard comment and posted. It was an impulse. :)


.
EasyMOD Standards | MOD Template Actions | MODs in Development Rules
Useful information for MOD Authors | MOD Queue Stats | Search MODs
Write SQL/DDL portable to all SQL servers supported by phpBB!
Get EasyMOD 0.3.0! | Suport al phpBB en Català!
8)

User avatar
thewizard
Registered User
Posts: 356
Joined: Sun Sep 29, 2002 7:46 am

Post by thewizard »

That's the problem for me. If i include the

Code: Select all

<!--
and

Code: Select all

//-->
Then It no longer works. However if i remove them it works. This was tested in both FireFox 0.9.3 and the latest version of IE.

markus_petrux
Former Team Member
Posts: 1887
Joined: Wed Apr 23, 2003 7:11 am
Location: Girona, Catalunya (Spain)
Contact:

Post by markus_petrux »

thewizard wrote: That's the problem for me. If i include the

Code: Select all

<!--
and

Code: Select all

//-->
Then It no longer works. However if i remove them it works. This was tested in both FireFox 0.9.3 and the latest version of IE.

You should use line-breaks (check out MOD changes in bbcode.tpl). Otherwise the javascript code is considered an HTML comment by the browsers. Follow? :)
EasyMOD Standards | MOD Template Actions | MODs in Development Rules
Useful information for MOD Authors | MOD Queue Stats | Search MODs
Write SQL/DDL portable to all SQL servers supported by phpBB!
Get EasyMOD 0.3.0! | Suport al phpBB en Català!
8)

EGIS
Registered User
Posts: 60
Joined: Sat Apr 24, 2004 3:37 am
Location: Norway
Contact:

Post by EGIS »

markus_petrux wrote: You should use line-breaks (check out MOD changes in bbcode.tpl). Otherwise the javascript code is considered an HTML comment by the browsers. Follow? :)
As you see here he has two line-breaks in his bbcode.tpl file but this is not in the output here. It seems to be some problems with the board that removes those line-breaks.
My mod: [Hide BBcode MOD]

markus_petrux
Former Team Member
Posts: 1887
Joined: Wed Apr 23, 2003 7:11 am
Location: Girona, Catalunya (Spain)
Contact:

Post by markus_petrux »

EGIS wrote: As you see here he has two line-breaks in his bbcode.tpl file but this is not in the output here. It seems to be some problems with the board that removes those line-breaks.
8O I have never seen this before. The bbcode.tpl seems to use line-feeds only (unix default). This should be no problem, I believe. However, as you said EGIS, something is removing those line-feeds when loading the bbcode.tpl file to parse the BBCodes.

I don't know the reason for this. :cry:
EasyMOD Standards | MOD Template Actions | MODs in Development Rules
Useful information for MOD Authors | MOD Queue Stats | Search MODs
Write SQL/DDL portable to all SQL servers supported by phpBB!
Get EasyMOD 0.3.0! | Suport al phpBB en Català!
8)

User avatar
thewizard
Registered User
Posts: 356
Joined: Sun Sep 29, 2002 7:46 am

Post by thewizard »

Any other ideas guys?

EGIS
Registered User
Posts: 60
Joined: Sat Apr 24, 2004 3:37 am
Location: Norway
Contact:

Post by EGIS »

[EDIT] Se markus_petrux post
Last edited by EGIS on Mon Sep 20, 2004 1:53 pm, edited 1 time in total.
My mod: [Hide BBcode MOD]

markus_petrux
Former Team Member
Posts: 1887
Joined: Wed Apr 23, 2003 7:11 am
Location: Girona, Catalunya (Spain)
Contact:

Post by markus_petrux »

Hi!

I believe I found the cause for removing line-feeds. It is function load_bbcode_template() located in includes/bbcode.php, this line:

Code: Select all

$tpl  = str_replace("\n", '', $tpl);
This is because, all line-feeds are replaced by <br /> in viewtopic.php:

Code: Select all

$message = str_replace("\n", "\n<br />\n", $message);
So, removing line-feeds in bbcode.php avoids potential problems if an additional <br /> is placed within the scope of a BBCode.

Well, knowing the cause, let's see what happens. If bbcode.tpl is saved with line-feeds only (default unix text format), then the whole open/close tags of the BBCode are rendered without line-breaks. This fact invalidates the Hide BBCode as its javascript code (placed on a single line) is considered an HTML comment by the browser. Bang!

This is not the case if the bbcode.tpl file is saved with carriage-returns + line-feeds (default text format in windows). Reason is, while all line-feeds are removed, carriage-returns remain. That seems to be enough for the browser to break the lines. Follow?

ok, knowing the cause and the reason why, I believe I've found a workaround:

Code: Select all

#
# ---[ OPEN ]----------
#
includes/bbcode.php
#
# ---[ FIND ]----------
#
   $bbcode_tpl['hide_open'] = str_replace('{L_HIDE}', $lang['Hide'], $bbcode_tpl['hide_open']); 
   $bbcode_tpl['hide_owntext_open'] = str_replace('{L_HIDE}', '\\1', $bbcode_tpl['hide_owntext_open']); 
#
# ---[ AFTER, ADD ]----------
#
	$patterns = array('<!--', '//-->');
	$replacements = array("\r<!--\r", "\r//-->\r");
	$bbcode_tpl['hide_open']  = str_replace($patterns, $replacements, $bbcode_tpl['hide_open']);
	$bbcode_tpl['hide_owntext_open']  = str_replace($patterns, $replacements, $bbcode_tpl['hide_owntext_open']);
	$bbcode_tpl['hide_close']  = str_replace($patterns, $replacements, $bbcode_tpl['hide_close']);
#
# ---[ SAVE ]----------
#
So, we're are adding carriage returns for the Hide BBCode strings loaded from bbcode.tpl, which should be safe in whatever environment. I think. :)
EasyMOD Standards | MOD Template Actions | MODs in Development Rules
Useful information for MOD Authors | MOD Queue Stats | Search MODs
Write SQL/DDL portable to all SQL servers supported by phpBB!
Get EasyMOD 0.3.0! | Suport al phpBB en Català!
8)

EGIS
Registered User
Posts: 60
Joined: Sat Apr 24, 2004 3:37 am
Location: Norway
Contact:

Post by EGIS »

Thanks for working this out for me, I will submit an update right away. I have tested it on my board and it's working in all major browsers.
My mod: [Hide BBcode MOD]

markus_petrux
Former Team Member
Posts: 1887
Joined: Wed Apr 23, 2003 7:11 am
Location: Girona, Catalunya (Spain)
Contact:

Post by markus_petrux »

Glad to be of help. I couldn't resist. :)


.
EasyMOD Standards | MOD Template Actions | MODs in Development Rules
Useful information for MOD Authors | MOD Queue Stats | Search MODs
Write SQL/DDL portable to all SQL servers supported by phpBB!
Get EasyMOD 0.3.0! | Suport al phpBB en Català!
8)

User avatar
thewizard
Registered User
Posts: 356
Joined: Sun Sep 29, 2002 7:46 am

Post by thewizard »

That works great. >_< Kinda ashamed I hadn't thought of that before.

planneroftowns
Registered User
Posts: 16
Joined: Tue Jul 06, 2004 1:55 pm

Post by planneroftowns »

EDIT - The mod works just great. Ignore this post!
Last edited by planneroftowns on Thu Sep 23, 2004 10:50 am, edited 1 time in total.

Post Reply

Return to “[2.0.x] MOD Database Cleanup”