1
This and other hacks available to download here: Some useful hacksTested 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[] = "'xoopsCode">'.stripslashes(wordwrap(MyTextSanitizer::htmlSpecialChars('\1'), 100)).'
'";
replace for:
Quote:
//Begin hack: [ code] tag content output correction
$replacements[] = "''.stripslashes(wordwrap(MyTextSanitizer::htmlSpecialCharsCode('\\1'), 100)).'
'";
//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 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", "/ /i", "/\[/", "/\]/","/(\015\012)|(\015)|(\012)/"), array('&', ' ', "[" ,"]",'[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!