[TYPO3-core] RFC #1957: Feature: When deleting a record in the BE, MsgBox should show the record label
Rob Vonk
typo3 at robvonk.com
Fri Aug 29 20:45:57 CEST 2008
Martin Kutschker wrote:
>
> You htmlspecialchars() the title twice. Once after you get it and a
> second time when adding it to the attribute onclick.
I can explain why i did that :)
I copied the code from the function 'getRecordTitlePrep' in class.t3lib_befunc.php. I posted the code at the end of the message.
I wasn't sure why they did do that but thought it wouldn't mind so i just copied it.
I needed only the cropping from the function and not the 'adding span' part. That function can be cleaned as well i guess.
> Also you forgot to escape the string for a JS string. Any ' in the tile
> will break the JS code. I think there was some code for that in t3lib_div.
There's indeed a function for that: slashJS but the htmlentities will take care of the quotes:
http://php.nederland.net/manual/en/function.htmlentities.php
I verified by adding a ' to a title and it works as expected.
> Otherwise I think that this patch can go into 4.2. For 4.3 I'd like to
> see a patch that shows the title in the message (as suggested) and also
> translates the reference count message (with two new labels).
>
> Masi
Who can/may add these to the local language core?
Regards, Rob
Code:
public static function getRecordTitlePrep($title, $titleLength = 0) {
// If $titleLength is not a valid positive integer, use BE_USER->uc['titleLen']:
if (!$titleLength || !t3lib_div::testInt($titleLength) || $titleLength < 0) {
$titleLength = $GLOBALS['BE_USER']->uc['titleLen'];
}
$titleOrig = htmlspecialchars($title);
$title = htmlspecialchars(t3lib_div::fixed_lgd_cs($title, $titleLength));
// If title was cropped, offer a tooltip:
if ($titleOrig != $title) {
$title = '<span title="'.$titleOrig.'">'.$title.'</span>';
}
return $title;
}
More information about the TYPO3-team-core
mailing list