Issue Bug Closed

#17639accesskey generation in tslib_menu uses html-tags

Michael Grundkötter 09/29/07, 18:31 updated 06/27/08, 10:53

Description

If I create a menu like this:
1 = HMENU
1 {
entryLevel = 0
1 = TMENU
1 {
expAll = 1
NO {
field = title
ATagTitle.field = abstract // description // title
stdWrap.wrap = |
allWrap =

  • |

  • }
    …
    the accessKey – method in tslib_menu takes this string “MY_MENU_NAME_HERE“ and searches for the first letter. the problem is, if you use html tags, the tag name will contain this letter and the accesskeys for your menu will all be wrong.

    My version:

    function accessKey($title) {
    // The global array ACCESSKEY is used to globally control if letters are already used!!
    $result = Array();

    $title = strip_tags($title);
    $titleLen = strlen($title);
    for ($a=0;$a<$titleLen;$a++) {
    $key = strtoupper(trim(substr($title,$a,1)));
    if (preg_match(‘/[a-zA-Z]/’, $key) && !isset($GLOBALS[‘TSFE’]->accessKey[$key])) {
    $GLOBALS[‘TSFE’]->accessKey[$key]=1;
    $result[‘code’] = ‘ accesskey=”’.$key.’”’;
    $result[‘alt’] = ‘ (ALT+’.$key.’)’;
    break;
    }
    }
    return $result;
    }

    if you just add the strip_tags() function, everything is fine!
    (issue imported from #M6420)

    Reviews 0

    No change resolves or names this issue in its commit message, and no comment links one.