1
AndreyRa
X2 Core: [code] tag's output correction
  • 2003/6/23 22:42

  • AndreyRa

  • Just popping in

  • Posts: 17

  • Since: 2003/3/16


This and other hacks available to download here: Some useful hacks

Tested with XOOPS 2.0.3

Subject: In tag [ code] there is a serious defect because of which to use this tag it is impossible.
For an example:
Try to copy and paste through buffer this text (in Notepad for example):
This is a first line.
And 
this is a second.
...


If you were not too lazy - you have understood that I had in view of. For lazy I explain: you in a notepad will not see any of line-breaks. The text will be in one line.

Second issue:
Example:
[url=xoops.org]I want to write a sample of my code...[/url]

I post where just [ url=xoops.org]I want to write a sample of my code...[ /url]. Some of my previous hacks comprised a part of an code of a Xoops. To avoid retranslation them in various XOOPS codes I had to go on some shifts.
This hack completely solve this problem. Not so it is beautiful as it might make itself Onokazu, but it is quite correct.

1. File \class\module.textsanitizer.php, this file will be one during all hack. line 151, line
$replacements[] = "'<div class="xoopsCode"><code><pre>'.stripslashes(wordwrap(MyTextSanitizer::htmlSpecialChars('\1'), 100)).'</pre></code></div>'";
replace for:
Quote:
//Begin hack: [ code] tag content output correction
$replacements[] = "'<div class=\"xoopsCode\"><code><pre>'.stripslashes(wordwrap(MyTextSanitizer::htmlSpecialCharsCode('\\1'), 100)).'</pre></code></div>'";
//End hack: [ code] tag content output correction


2. line 216, under function &nl2Br, add 2 new functions:
Quote:

//Begin hack: [ code] tag content output correction
//copy of htmlSpecialChars function but adopted for [ code] content (thats may content other xoops's codes and required for unchanged linebreaks (for corrected html <pre> tag work))
//masking all \n and \r symbols from nl2Br function
//masking '[' and ']' symbols for comatibility with XOOPS codes which may be in a brought code.
function &htmlSpecialCharsCode($text)
{
return preg_replace(array("/&/i", "/&nbsp;/i", "/\[/", "/\]/","/(\015\012)|(\015)|(\012)/"), array('&', '&nbsp;', "[" ,"]",'[xoops_code_nl]'), htmlspecialchars($text, ENT_QUOTES));
}
//copy of nl2Br function that's awaiting internal '[xoops_code_nl]' tags for reverting its to the originals \n.
function &nl2BrCode($text)
{
return preg_replace("/\[xoops_code_nl\]/","\n",$text);
}
//End hack: [ code] tag content output correction


3. line 319, after
if ($br != 0) {
            
$text =& $this->nl2Br($text);
        }
add:
Quote:

//Begin hack: [ code] tag content output correction
if ($xcode != 0) {
$text =& $this->nl2BrCode($text);
}
//End hack: [ code] tag content output correction


4. line 363, after
if ($br != 0) {
            
$text =& $this->nl2Br($text);
        }
add:
Quote:
//Begin hack: [ code] tag content output correction
if ($xcode != 0) {
$text =& $this->nl2BrCode($text);
}
//End hack: [ code] tag content output correction


5. line 426, after
$text $this->nl2Br($text);
add:
Quote:
//Begin hack: [ code] tag content output correction
if ($bbcode == 1) {
$text =& $this->nl2BrCode($text);
}
//End hack: [ code] tag content output correction


6. line 453, after
$text $this->nl2Br($text);
add:
Quote:

//Begin hack: [code] tag content output correction
if ($bbcode == 1) {
$text =& $this->nl2BrCode($text);
}
//End hack: [code] tag content output correction


that's all!

2
meme
Re: X2 Core: [code] tag's output correction
  • 2003/6/23 23:20

  • meme

  • Quite a regular

  • Posts: 271

  • Since: 2002/12/10


thanks andre
i think i will use all ur hacks hehehehe

note :
but plz dont forget to upgrade this hacks after release new version of XOOPS

btw can you help me with this topic
click here

its about newbb you can test the views count to make sure

3
_masi
Re: X2 Core: [code] tag's output correction
  • 2003/6/24 7:01

  • _masi

  • Just popping in

  • Posts: 19

  • Since: 2003/3/28


Andrey, I get multiple lines if i paste your first in example into notepade (using Mozilla and Win98 SE). But I believe you that there are situations where a problem might arise.

My problem with pasting code was that it will be automatically line-wrapped! Argh, I do use long lines with all the indenting and commenting. Your hack/fix also does a line-wrapping at 100.

And if your hacks are really bug fixes, consider submitting them to the Sourceforge bug tracker! Perhaps Ono finds some time and merges your patches.

4
meme
Re: X2 Core: [code] tag's output correction
  • 2003/6/24 7:29

  • meme

  • Quite a regular

  • Posts: 271

  • Since: 2002/12/10


copy the code then paste into frontpage if you have it then copy from the frontpage then paste it into php file
that what i do when andrey post his best hacks

5
GIJOE
Re: X2 Core: [code] tag's output correction
  • 2003/11/20 3:09

  • GIJOE

  • Quite a regular

  • Posts: 265

  • Since: 2003/8/13


This serious bug about the [ code] tag still remains in 2.0.5 or the recent CVS.

In 2.0.5, stripslashes() has been removed from $replacements for inside [ code].
But no essential improvement.
This cause more escape " inside [ code] under 'HTML allowed'.

Mr.Ryuji examined the operation of /e modifier of preg_replace(),
and he has finally discovered the best method.

See B-wiki of XOOPS Hackers 2 in Japan.

Of course, these hack codes also solve following problems about [ code] tag:
- Destroying 'newline' - this makes to fail Copy & Paste (IE).
- Influenced by makeClickable() - this destroys some kind of php codes.

I strongly insist that Ryuji's hack codes should be taken into XOOPS CORE CVS.

Thanks!

6
Aine
Re: X2 Core: [code] tag's output correction
  • 2004/1/14 9:50

  • Aine

  • Just popping in

  • Posts: 21

  • Since: 2002/7/10


The code bug is still in the latest release.
I'm getting backslashes all over the place.
Anyone got an already corrected version on-hand?

*Edit : nevermind, I went and got the hacks myself. And they work perfect. Please hack the release version so people don't have to keep going to get the code to fix it.

Login

Who's Online

270 user(s) are online (164 user(s) are browsing Support Forums)


Members: 0


Guests: 270


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits