Wie gesagt, in der Dragonslayer-Version isses drin. Siehe Code weiter unten. Muss diese Funktion $hotkey sein. Aber wie ich die in meine function addnav reinfriemel, is mir nicht ganz klar...
PHP:
function addnav($text,$link=false,$priv=false,$pop=false,$newwin=false,$hotkey=true)
{
global $nav,$session,$accesskeys,$REQUEST_URI,$quickkeys;
if ($link===false)
{
$nav.=templatereplace('navhead',array('title'=>appoencode($text,$priv)));
}
elseif (empty($link))
{
$nav.=templatereplace('navhelp',array('text'=>appoencode($text,$priv)));
}
else
{
if (!empty($text))
{
$extra='';
if ($newwin===false)
{
if (strpos($link,'?'))
{
$extra='&c='.$session['counter'];
}
else
{
$extra='?c='.$session['counter'];
}
}
if ($newwin===false)
{
$extra.='-'.date('His');
}
//$link = str_replace(" ","%20",$link);
//hotkey for the link.
if($hotkey) {
$key='';
if (substr($text,1,1)=='?')
{
// check to see if a key was specified up front.
if ($accesskeys[strtolower(substr($text, 0, 1))]==1)
{
// output ("key ".substr($text,0,1)." already taken`n");
$text = substr($text,2);
}
else
{
$key = substr($text,0,1);
$text = substr($text,2);
//output("key set to $key`n");
$found=false;
$int_strlen = strlen($text);
for ($i=0;$i<$int_strlen; $i++)
{
$char = substr($text,$i,1);
if ($ignoreuntil == $char)
{
$ignoreuntil='';
}
else
{
if ($ignoreuntil<>'')
{
if ($char=='<') $ignoreuntil='>';
if ($char=='&') $ignoreuntil=';';
if ($char=='`') $ignoreuntil=substr($text,$i+1,1);
}
else
{
if ($char==$key)
{
$found=true;
break;
}
}
}
}
if ($found==false)
{
if (strpos($text, '__') !== false)
{
$text=str_replace('__', '('.$key.') ', $text);
}
else
{
$text='('.strtoupper($key).') '.$text;
}
$i=strpos($text, $key);
// output("Not found`n");
}
}
}
if (empty($key))
{
$int_strlen = strlen($text);
for ($i=0;$i<$int_strlen; $i++)
{
$char = substr($text,$i,1);
if ($ignoreuntil == $char)
{
$ignoreuntil='';
}
else
{
if (($accesskeys[strtolower($char)]==1) || (strpos('abcdefghijklmnopqrstuvwxyz0123456789', strtolower($char)) === false) || $ignoreuntil<>'')
{
if ($char=='<') $ignoreuntil='>';
if ($char=='&') $ignoreuntil=';';
if ($char=='`') $ignoreuntil=substr($text,$i+1,1);
}
else
{
break;
}
}
}
}
if ($i<strlen($text))
{
$key=substr($text,$i,1);
$accesskeys[strtolower($key)]=1;
$keyrep=' accesskey="'.$key.'" ';
}
else
{
$key='';
$keyrep='';
}
//output("Key is $key for $text`n");
if ($key!='')
{
$text=substr($text,0,strpos($text,$key)).'`H'.$key.'`H'.substr($text,strpos($text,$key)+1);
if ($pop)
{
$quickkeys[$key]=popup($link.$extra);
}
else
{
$quickkeys[$key]="window.location='$link$extra'";
}
}
}
$nav.=templatereplace('navitem',array(
"text"=>appoencode($text,$priv),
"link"=>HTMLEntities($link.$extra),
"accesskey"=>$keyrep,
"popup"=>($pop==true ? "target='_blank' onClick=\"".popup($link.$extra)."; return false;\"" : ($newwin==true?"target='_blank'":""))
));
//$nav.="<a href=\"".HTMLEntities($link.$extra)."\" $keyrep class='nav'>".appoencode($text,$priv)."<br></a>";
}
$session['allowednavs'][$link.$extra]=true;
$session['allowednavs'][str_replace(' ', '%20', $link).$extra]=true;
$session['allowednavs'][str_replace(' ', '+', $link).$extra]=true;
return($link.$extra);
}
}
Hier zum Vergleich meine function addnav:
$this->bbcode_second_pass_code('', '
function addnav($text,$link=false,$priv=false,$pop=false,$newwin=false){
global $nav,$session,$accesskeys,$REQUEST_URI,$quickkeys;
$text = translate($text);
/*
if (date("m-d")=="04-01"){
$text = borkalize($text);
}
*/
if ($link===false){
$nav.=templatereplace("navhead",array("title"=>appoencode($text,$priv)));
}elseif ($link === "") {
$nav.=templatereplace("navhelp",array("text"=>appoencode($text,$priv)));
}else{
if ($text!=""){
$extra="";
if ($newwin===false) {
if (strpos($link,"?")){
$extra="&c=$session[counter]";
}else{
$extra="?c=$session[counter]";
}
}
if ($newwin===false) $extra.="-".date("His");
//$link = str_replace(" ","%20",$link);
//hotkey for the link.
$key="";
if (substr($text,1,1)=="?") {
// check to see if a key was specified up front.
if ($accesskeys[strtolower(substr($text, 0, 1))]==1){
// output ("key ".substr($text,0,1)." already taken`n");
$text = substr($text,2);
}else{
$key = substr($text,0,1);
$text = substr($text,2);
//output("key set to $key`n");
$found=false;
for ($i=0;$i<strlen($text); $i++){
$char = substr($text,$i,1);
if ($ignoreuntil == $char){
$ignoreuntil="";
}else{
if ($ignoreuntil<>""){
if ($char=="<") $ignoreuntil=">";
if ($char=="&") $ignoreuntil=";";
if ($char=="`") $ignoreuntil=substr($text,$i+1,1);
}else{
if ($char==$key) {
$found=true;
break;
}
}
}
}
if ($found==false) {
if (strpos($text, "__") !== false)
$text=str_replace("__", "(".$key.") ", $text);
else
$text="(".strtoupper($key).") ".$text;
$i=strpos($text, $key);
// output("Not found`n");
}
}
//
}
if ($key==""){
for ($i=0;$i<strlen($text); $i++){
$char = substr($text,$i,1);
if ($ignoreuntil == $char) {
$ignoreuntil="";
}else{
if (($accesskeys[strtolower($char)]==1) || (strpos("abcdefghijklmnopqrstuvwxyz0123456789", strtolower($char)) === false) || $ignoreuntil<>"") {
if ($char=="<") $ignoreuntil=">";
if ($char=="&") $ignoreuntil=";";
if ($char=="`") $ignoreuntil=substr($text,$i+1,1);
}else{
break;
}
}
}
}
if ($i<strlen($text)){
$key=substr($text,$i,1);
$accesskeys[strtolower($key)]=1;
$keyrep=" accesskey=\"$key\" ";
}else{
$key="";
$keyrep="";
}
//output("Key is $key for $text`n");
if ($key==""){
//$nav.="<a href=\"".HTMLEntities($link.$extra)."\" class='nav'>".appoencode($text,$priv)."<br></a>";
//$key==""; // This is useless
}else{
$text=substr($text,0,strpos($text,$key))."`H".$key."`H".substr($text,strpos($text,$key)+1);
if ($pop){
$quickkeys[$key]=popup($link.$extra);
}else{
$quickkeys[$key]="window.location='$link$extra';";
}
}
$nav.=templatereplace("navitem",array(
"text"=>appoencode($text,$priv),
"link"=>HTMLEntities($link.$extra),
"accesskey"=>$keyrep,
"popup"=>($pop==true ? "target='_blank' onClick=\"".popup($link.$extra)."; return false;\"" : ($newwin==true?"target='_blank'":""))
));
//$nav.="<a href=\"".HTMLEntities($link.$extra)."\" $keyrep class='nav'>".appoencode($text,$priv)."<br></a>";
}
$session[allowednavs][$link.$extra]=true;
$session[allowednavs][str_replace(" ", "%20", $link).$extra]=true;
$session[allowednavs][str_replace(" ", "+", $link).$extra]=true;
}
}
')