1. kriegj
  2. Contribute to JEvents
  3. Saturday, 06 February 2010
Hi all,

I am an experienced web developer (several years of Perl, PHP and Java experience) but relatively new to Joomla and JEvents. It's all been a fairly good experience so far. This is my first bug report; the bug applies to JEvents v1.5.3 (and possibly earlier versions).

Executive summary (detailed description below):

In the various calendar_cell.php view scripts, suggest replacing:

                if( JString::strlen( $this->title ) >= $cfg->get('com_calCutTitle',50)){
$tmpTitle = JString::substr( $this->title, 0, $cfg->get('com_calCutTitle',50) ) . ' ...';
}


...with:

// Fix #1
if( JString::strlen( $this->title ) > $cfg->get('com_calCutTitle',50) ){
$tmpTitle = JString::substr( $this->title, 0, $cfg->get('com_calCutTitle',50) - 3 ) . ' ...';
}


...or:

// Fix #2
if( JString::strlen( $this->title ) > $cfg->get('com_calCutTitle',50) + 3 ){
$tmpTitle = JString::substr( $this->title, 0, $cfg->get('com_calCutTitle',50) ) . ' ...';
}


Similar bug (& fix) applies for helpers/defaultvieweventrownew.php. (With so many files affected, perhaps there is also a case here for factoring this code out into a subroutine in a utility package. Maybe this could go in the Joomla core somewhere? This is probably the sort of function that is likely to be useful to other Joomla component developers. Anyway, this is probably an issue that can be dealt with separately.)

Detailed bug description follows.

One of the things that I noticed with the monthly view of the Calendar is that it had a nifty trick of truncating the titles and replacing the chopped text with an ellipsis ("...";). I have called this "ellipsisification", for lack of a better word. This does a pretty good job of saving space in a cluttered display with long titles.

However, I noted that while the idea is a good one, there seems to be a minor quirk with the implementation. I had titles that were displayed complete (no truncation) and yet they still had an ellipsis appended to them.

Suspecting that this was an easy bug to fix I dug into the PHP code and found the following offending lines in the various implementations of calendar_cell.php:

                if( JString::strlen( $this->title ) >= $cfg->get('com_calCutTitle',50)){
$tmpTitle = JString::substr( $this->title, 0, $cfg->get('com_calCutTitle',50) ) . ' ...';
}


One solution to the problem was simply to replace the ">=" in the conditional with a ">". This fixed my problem but on closer inspection I realised that there could be other, similar quirks. For example, if the "cut title" length was 50 characters and I had a title that was 51 characters long, then my title would first be truncated to 50 characters and then have an additional three characters appended to it ("...";), for a total of 53 characters - two characters longer than the original title. So not only is the "ellipsisification" making the title slightly more difficult to read (and slightly more ugly), it is also actually making the title longer than it was originally (and thus being counter-productive as to what it was intended).

So my potential revised solutions are as per the beginning of this post - basically, to take the additional length of the ellipsis into account when deciding when to "ellipsisify". The difference is that the first one actually adheres to specs and keeps the displayed title length strictly <= to the specified number of characters, however there is a minor risk of having unpredictable behaviour if the "cut title" parameter is set to a value < 3 (this could be worked around with suitable defensive programming & parameter input validation). The second one, while not strictly adhering to the spec (ie, it will cut title lengths to (cut_title + 3) chars rather than to cut title chars), avoids the potential for the above bug. (It should be pointed out that the drawback of the second fix (ie, making titles slightly longer than specified) actually applies to the existing implementation also, so at least this would be backwards compatible.) Both fixes achieve the desired goal of only "ellipsisifying" if the ellipsisified title is actually shorter than the un-ellipsisified title.

I have already implemented the first fix in my local copy of JEvents. I will leave it to the JEvents developer community to decide which (if any) of the two suggested fixes it decides to incorporate into the next version of JEvents.

Regards,

-Jeremy
geraint
Support Team
Accepted Answer Pending Moderation
0
Votes
Undo
WOW what a detailed bug report :D .

This is a good point and I'll look to incorporate this into JEvents 1.5.5

Geraint
JEvents Club members can get priority forum support at the Support Forum. As well as access to a variety of custom JEvents addons and benefits. Join the JEvents club today!
  1. more than a month ago
  2. Contribute to JEvents
  3. # 1
Accepted Answer Pending Moderation
0
Votes
Undo
Oops, I just realised that the suffix is four characters (' ...'), not three ('...'), so that + 3/- 3 in my proposed fix needed to be a +/- 4.

And I think I posted this in the wrong forum, did I? Should have been in the JEvents 1.5 forum?
  1. more than a month ago
  2. Contribute to JEvents
  3. # 2
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!

Members Area

Show your support

Unlike many Joomla calendars we do not charge to download JEvents - please show your support for this project by becoming a member of the JEvents Club Club members get access to early releases, exclusive member support forums, and Silver and Gold members can use many exciting JEvents addons

Your membership will ensure that JEvents continues to be the best events calendar for Joomla.