×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: RC1 removes line breaks when UBB code is off

RC1 removes line breaks when UBB code is off 14 years 10 months ago #8921

  • Chong Kai Xiong
  • Chong Kai Xiong's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 0
The title should be quite self-explanatory. When UBB code is disabled, line breaks in comments get 'eaten up'.

For example, the following sample text:
This is line 1.
This is line 2.
Would appear as:
This is line 1. This is line 2.

Looking at the code path for this, I also noticed that character and word size limits are not being respected. The problem has to do with comments being processed only when UBB code is on.

Attached is a quick and dirty hack to fix this problem. It pretty much mimics the behaviour of JOSC_ubbcode::initUbbParsing(), without the processing of UBB code tags.

ubbcode_newlines_limits_patch.txt

RC1 removes line breaks when UBB code is off 14 years 10 months ago #8939

  • JonusC
  • JonusC's Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 785
  • Thank you received: 48
Thanks for the report and code example! Will be very helpful until the next release. *Stickied*

RC1 removes line breaks when UBB code is off 14 years 10 months ago #8947

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Ah Chong, you are a saver! I think that this is the reason why the module isn't working as it should for some people! Thank you!

RC1 removes line breaks when UBB code is off 14 years 10 months ago #8972

  • Chong Kai Xiong
  • Chong Kai Xiong's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 0
You're welcome guys. Thank you for the wonderful extension :)

I'm looking to add a few enhancements and will post up my private patches here in this board for your consideration.

RC1 removes line breaks when UBB code is off 14 years 9 months ago #9043

  • Joom Laner
  • Joom Laner's Avatar
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 23
  • Thank you received: 0
Hi Chong Kai Xiong,

it is good to know that there is already a solution to solve this issue. What I don't understand is how I can implement this patch into the component. Could you also provide such an instruction?

Thanks! :)

RC1 removes line breaks when UBB code is off 14 years 9 months ago #9115

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hey there,
Find the function ubbcodeparse() and change it to this
	function ubbcode_parse() {
		$html = $this->_comment;
 
		if ($this->_support_UBBcode) {
			$html = $this->initUbbParsing($html);
		} else {
			// Fix line breaks; respect character and word limits
 
			$html = nl2br(JOSC_ubbcode::convertlinebreaks($html));
 
			$maxlength_word = ($this->_maxlength_word!=-1) ? $this->_maxlength_word : 999999;
			$maxlength_text = ($this->_maxlength_text!=-1) ? $this->_maxlength_text : 999999;
 
			$html = JOSC_utils::setMaxLength($html, $maxlength_text);
			$html = JOSC_utils::wrapWord($html, $maxlength_word);
 		}
 
		if ($this->_support_emoticons) {
			$html = $this->parseEmoticons($html);
		}
 
		if ($this->_hide) {
			$html = "<span class='hide'>$html</span>";
		}
		return $html;
	}
 

this should be all.

@Chong - thank you very much for the help!!!!

RC1 removes line breaks when UBB code is off 14 years 9 months ago #9123

  • Joom Laner
  • Joom Laner's Avatar
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 23
  • Thank you received: 0
...and where do I find the function ubbcodeparse()?

RC1 removes line breaks when UBB code is off 14 years 9 months ago #9124

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
components/com_comment/joscomment/comment.class.php around line 2500 (I'm not exactly sure about the line)

RC1 removes line breaks when UBB code is off 14 years 9 months ago #9126

  • Joom Laner
  • Joom Laner's Avatar
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 23
  • Thank you received: 0
It's line 2609. I know this now exactly because my browser tells me:

Parse error: syntax error, unexpected T_CLASS, expecting T_FUNCTION in /var/www/.../html/components/com_comment/joscomment/comment.class.php on line 2609

First I have tried to implement your code, and I received this error message in the frontend. Then I have implemented Chong's code, and I received the same message.

RC1 removes line breaks when UBB code is off 14 years 9 months ago #9127

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
You've deleted something (a point, a { or so). If you are unable to find it please give me ftp access to your website. PM of course.

RC1 removes line breaks when UBB code is off 14 years 9 months ago #9129

  • Joom Laner
  • Joom Laner's Avatar
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 23
  • Thank you received: 0
Now I have tried again the Chong version and deleted the "+". And it works! Thank you, Chong, thank you Daniel! :)

By the way, I realized that the Chong code is quite different from the Daniel code. What would be the result in the function?

RC1 removes line breaks when UBB code is off 14 years 9 months ago #9131

  • Chong Kai Xiong
  • Chong Kai Xiong's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 0
Hey Joom, sorry I didn't make things clear in this thread. My patch was generated using a Unix software tool called 'diff' and is fed into its complement 'patch'.

(Too much of a Linux user and coder I am :p)

The patch file format is compact and should be quite straightforward to understand:

Wherever there are code changes to be made, there is a set of lines prefixed with '-' and '+'. '-' indicates lines to be removed and '+' for lines to be added (replaced).

So if you see this:
- $var = 1;
+ $var = 2;

It means you should replace the line:
$var = 1;
with:
$var = 2;

RC1 removes line breaks when UBB code is off 14 years 9 months ago #9147

  • JonusC
  • JonusC's Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 785
  • Thank you received: 48
Joom Laner wrote:

By the way, I realized that the Chong code is quite different from the Daniel code. What would be the result in the function?


There isn't much difference, the code Chong gave us is just much more simple because it doesn't need to do the UBB stuff as well. From what I can tell, the new patch is similar to how beta2 handled it.

Word limiting and wrapping still sucks in 4.0, hopefully we can make it all much better in 4.1.

RC1 removes line breaks when UBB code is off 14 years 9 months ago #9148

  • Joom Laner
  • Joom Laner's Avatar
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 23
  • Thank you received: 0
So I will keep the Chong code. UBB doesn't work with my system anyway. :whistle:

@Chong: Thanks a lot for explanation. I am no programmer. But I simply had such a feeling, that the "+" shouldn't stay in the code. ;)
  • Page:
  • 1
Time to create page: 0.137 seconds