PDA

View Full Version : Solved If thread title is exceeded by insertion of langtitle things break



tavenger5
12-09-11, 22:24
I noticed that if someone posts a thread in another language that is just under the min characters for thread title, and the langtitle tags go over this limit, this screws up the display of the thread in forumdisplay, search results, and on the thread page itself. The same goes if a thread title is translated, someone replies to the thread, and 'Re:' sends the post title over its character limit.

I can't show an example of this because I had to fix it on my forum. I'm sure if can be replicated here if you enter a title just under the thread title character limit that is translated from the default language.

r.dziadusz
13-09-11, 11:04
Could you please show us a problem, because i can hardly understand when the problem appears

tavenger5
13-09-11, 16:44
The problem is when 'langtitle' is inserted into the thread title, it is not recognizing the thread title character limit. If the tag gets cut off and isn't closed properly, it breaks the page where the title appears.

r.dziadusz
14-09-11, 10:05
Ok, but i cannot reproduce this problem on my test forum, my [ langtitle] is never cut.
Could you please send me detailed information about this problem. What is your langtitle lenght limit, and how long the tittle supposed to be(in what language) to break the line?

tavenger5
17-09-11, 19:46
my title length limit was 85, but I increased it to 100. So, for example, if the user inserted a title that was 95 characters, then then langtitle tags would send it over the limit. The system truncated the closing langtitle tag which results in breaking the layout.

r.dziadusz
18-09-11, 20:01
Ok we were able to reproduce this problem, and now we are working on it

vBET
20-09-11, 08:41
Hi. I was able to reproduce it. It was really hard to reproduce and I made it accidentally working on something else. It was hard, because it is vBulletin bug. vBET uses vBulletin function vbchop, which suppose to cut string according to desired length in safe way (keeping in mind encoded characters). Unfortunately vBulletin has bug there and for messages which are encoded to safe UTF-8 (characters like &#CODE;) gives wrong results.

We send bug report to vBulletin (vBulletin bug (http://tracker.vbulletin.com/browse/VBIV-13177)) and created quick fix on vBET side. So right now vBET detects if vbchop returned longer result and cuts it to desired one. Also we have simple detection to check does letter encoded in format &#CODE; was not cut in the middle and if yes, then last word is also cut (simply by finding last space). Please see quick fix below.

Quick Fix:

Open /includes/vbenterprisetranslator_functions_detection.php
Find:

$title = vbchop($title, $vbulletin->options['titlemaxchars'] - 12).'[/langtitle]';
Replace by:


$desiredLength = $vbulletin->options['titlemaxchars'] - 12;
$title = vbchop($title, $desiredLength);
if (strlen($title) > $desiredLength) {
$title = substr($title, 0, $desiredLength);
$lastOpen = strrpos($title,'&');
$lastSpace = strrpos($title, ' ');
$lastClose = strrpos($title,';');
if ($lastOpen!==false && $lastSpace!==false && $lastClose!==false && ($lastSpace < $lastOpen) && ($lastOpen > $lastClose)) {
$title = substr($title, 0, $lastSpace);
}
}
$title .= '[/langtitle]';



This will be included in next release.

vBET
20-09-11, 23:02
Please note that previous post was edited to provide more sophisticated quick fix (solving issue of cut in the middle letter in format &#CODE;). So if you already apply previous solution you can consider to use actual one, or just wait for new release :)

tavenger5
22-09-11, 01:49
Thanks Michal - I knew something was up. Does the quick fix also account for replies as well? Sometimes the 're:' sent it over the limit.

vBET
22-09-11, 09:34
We didn't check it. If you will find that issue still exists in such case, please contact us here and we will handle this :)

AfrikaansAlbanianArabicBelarusianBulgarianCatalanChineseCroatianCzechDanishDutchEnglishEstonianFilipinoFinnishFrenchGalicianGermanGreekHaitian CreoleHebrewHindiHungarianIcelandicIndonesianIrishItalianJapaneseKoreanLatvianLithuanianMacedonianMalayMalteseNorwegianPersianPolishPortugueseRomanianRussianSerbianSlovakSlovenianSpanishSwahiliSwedishTaiwaneseThaiTurkishUkrainianVietnameseWelshYiddish
Translated to other languages supported by vBET Translator 4.10.1