Line limit allows one line more than setting (counts line breaks instead of lines)

Ledo2 - February 21, 2009 - 13:59
Project:Signatures for Forums
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

Now we have to put in BR tags for line breaks. The "Line limit:" feature then count's this line break tags and based on that it calculates number of lines?

I was thinking if it could be done like this. User would input lines with "enter key" press and then we could use custom filter with defoult "Line break converter" option enabled to convert "carriage return" to < br > tags.

But i don't know how hard or if it is evan possible to make it to work like that..

#1

Liam McDermott - February 21, 2009 - 18:27
Status:active» postponed (maintainer needs more info)

I'm not sure what you're asking for here. The line limit feature works by counting line breaks in the signature text, not by counting <br /> tags. The code is:

<?php
substr_count
($edit['signature'], "\n")
?>

which you can see on line 299 of signature_forum.module, in the 6 -dev branch. Maybe it already works the way you expect? :)

#2

Ledo2 - February 22, 2009 - 16:03

There was a problem. I tested too quickly and we both are right in one part but still we both are "wrong" in one part.

To explain:

It has to do with the "carriage return" producing "soft return" \n or "hard return" \r. In FF browsers pressing enter key produces "soft return" \n but in IE pressing enter key produces "hard return" \r. In IE for the line counting feature to work

<?php
substr_count
($edit['signature'], "\n")
?>

We must press Shift + enter to get "soft return". So in IE if user puts in more lines than we set with just enter key the above code will not count it like lines.

#3

Liam McDermott - February 23, 2009 - 00:14

I just tested this in IE and it did count the returns.

There is a problem with what the feature says it does vs. what it actually does though: it's counting returns, instead of the number of lines. So, a signature with two lines of text would be counted as having one return (which is a bug and should be fixed). Maybe this is what's tripping you up?

#4

Ledo2 - February 23, 2009 - 01:24

We are getting there i think. Try this:

Set:

Line limit:

The maximum number of lines allowed in a signature

To let say number 3.

Then in any browser input:

line1
line2
line3

Works fine.

then try:

line1
line2
line3
line4

Works too.

line1
line2
line3
line4
line5

To many lines error.

So bottom line when i first tested this module i put in 4 lines of text in for test. I thought in IE line limit didn't work at all. I assumed it has to to something with hard return. If i would use 5 lines then instead of 4 for testing i probbably would not noticed this at all.

But now i see it works in both browsers the same just number of lines allowed +1 extra line. So this is i think the bottom line of this "feature request". Module allows 1 line of signature more then we set and that now i see confused me of thinking line count didn't work in IE.

#5

Liam McDermott - February 23, 2009 - 02:08
Title:Enter instead of BR tags for line break» Line limit allows one line more than setting (counts line breaks instead of lines)
Category:feature request» bug report
Priority:minor» normal
Status:postponed (maintainer needs more info)» active

Changing status and title. It's not a feature request, because the module should do what you are asking for, I just didn't think the logic through well-enough. :)

#6

Ledo2 - February 23, 2009 - 13:16

All's Well That Ends Well. ;)

 
 

Drupal is a registered trademark of Dries Buytaert.