Ahhaaaaa. Something else to add to the docs though! Probably should be a note in the extension description, that it works on a per-user basis. Good implementation, though.
To be multilingual compatible I modified this script a little so that it always uses the first usable letter in a word. I found it usefull, if others find think so too, here's my code:
<?php /* Extension Name: Quick Keys Extension Url: http://lussumo.com/docs/ Description: Allows users to use ALT+[KeyCode] to access various pages of Vanilla. Version: 1.0 Author: Mark O'Sullivan Author Url: http://www.markosullivan.ca/
Copyright 2003 - 2005 Mark O'Sullivan This file is part of Vanilla. Vanilla is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Vanilla is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Vanilla; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA The latest source code for Vanilla is available at www.lussumo.com Contact Mark O'Sullivan at mark [at] lussumo [dot] com
You should cut & paste these language definitions into your conf/your_language.php file (replace "your_language" with your chosen language, of course): */ $Context->Dictionary['MenuOptions'] = 'Menu Options'; $Context->Dictionary['UseQuickKeys'] = 'Use quick-keys to access common forum pages';
if (in_array($Context->SelfUrl, array('account.php', 'categories.php', 'comments.php', 'index.php', 'post.php', 'search.php', 'settings.php')) && $Context->Session->UserID > 0) { $usedkeys = array(); if (@$Menu && @$Context->Session->User) { if ($Context->Session->User->Preference('UseQuickKeys')) { foreach ($Menu->Tabs as $key => $tab) { for ($i=0;$iTabs[$key]['Text'] = substr($tab['Text'], 0, $i).''.substr($tab['Text'], $i, $i+1).''.substr($tab['Text'], $i+1); $Menu->Tabs[$key]['Attributes'] = 'accesskey="'.$char.'"'; break; } } }
//$Menu->AddTab($Context->GetDefinition('Account_QuickKey'), 'account', GetUrl($Configuration, 'account.php'), 'accesskey=\'a\''); // Add a hidden tab $text = $Context->GetDefinition('StartANewDiscussion'); for ($i=0;$iContext->Dictionary['StartANewDiscussion_accesskey'] = substr($text, 0, $i).''.substr($text, $i, $i+1).''.substr($text, $i+1);
break;
}
}
$Menu->AddTab($Panel->Context->Dictionary['StartANewDiscussion_accesskey'], 'post', GetUrl($Configuration, 'post.php', 'category/', 'CategoryID', ForceIncomingInt('CategoryID',0)), 'accesskey="'.$char.'" class="Invisible"');
// alter the start a new discussion button in the panel
function Panel_AlterStartDefinition(&$Panel) {
$Panel->Context->Dictionary['StartANewDiscussion'] = $Panel->Context->Dictionary['StartANewDiscussion_accesskey'];
}
$Context->AddToDelegate('Panel',
'PreRender',
'Panel_AlterStartDefinition');
}
}
}
// Add the QuickKeys setting to the forum preferences form
if ($Context->SelfUrl == 'account.php' && $Context->Session->UserID > 0) {
$PostBackAction = ForceIncomingString('PostBackAction', '');
if ($PostBackAction == 'Functionality') {
function PreferencesForm_AddQuickKeysPreference(&$PreferencesForm) {
$PreferencesForm->AddPreference('MenuOptions', 'UseQuickKeys', 'UseQuickKeys', 1);
}
$Context->AddToDelegate('PreferencesForm',
'Constructor',
'PreferencesForm_AddQuickKeysPreference');
}
}
?>
Comments
<a href="..."><strong><span title="Accesskey: d">D</span></strong>iscussions<a>
And then applying styles like underlining via the CSS
edit // Although I can see an advantage of using <u>: It highlights it even when CSS is off.
The element, per HTML 4.01, is deprecated, but allowed in XHTML transitional. In strict and beyond, it is removed.
The preferred method of doing this is with an inline element, such as:
Key
and CSS:
~d
<?php
/*
Extension Name: Quick Keys
Extension Url: http://lussumo.com/docs/
Description: Allows users to use ALT+[KeyCode] to access various pages of Vanilla.
Version: 1.0
Author: Mark O'Sullivan
Author Url: http://www.markosullivan.ca/
Copyright 2003 - 2005 Mark O'Sullivan
This file is part of Vanilla.
Vanilla is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Vanilla is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Vanilla; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
The latest source code for Vanilla is available at www.lussumo.com
Contact Mark O'Sullivan at mark [at] lussumo [dot] com
You should cut & paste these language definitions into your
conf/your_language.php file (replace "your_language" with your chosen language,
of course):
*/
$Context->Dictionary['MenuOptions'] = 'Menu Options';
$Context->Dictionary['UseQuickKeys'] = 'Use quick-keys to access common forum pages';
if (in_array($Context->SelfUrl, array('account.php', 'categories.php', 'comments.php', 'index.php', 'post.php', 'search.php', 'settings.php')) && $Context->Session->UserID > 0) {
$usedkeys = array();
if (@$Menu && @$Context->Session->User) {
if ($Context->Session->User->Preference('UseQuickKeys')) {
foreach ($Menu->Tabs as $key => $tab)
{
for ($i=0;$iTabs[$key]['Text'] = substr($tab['Text'], 0, $i).''.substr($tab['Text'], $i, $i+1).''.substr($tab['Text'], $i+1);
$Menu->Tabs[$key]['Attributes'] = 'accesskey="'.$char.'"';
break;
}
}
}
//$Menu->AddTab($Context->GetDefinition('Account_QuickKey'), 'account', GetUrl($Configuration, 'account.php'), 'accesskey=\'a\'');
// Add a hidden tab
$text = $Context->GetDefinition('StartANewDiscussion');
for ($i=0;$iContext->Dictionary['StartANewDiscussion_accesskey'] = substr($text, 0, $i).''.substr($text, $i, $i+1).''.substr($text, $i+1); break; } } $Menu->AddTab($Panel->Context->Dictionary['StartANewDiscussion_accesskey'], 'post', GetUrl($Configuration, 'post.php', 'category/', 'CategoryID', ForceIncomingInt('CategoryID',0)), 'accesskey="'.$char.'" class="Invisible"'); // alter the start a new discussion button in the panel function Panel_AlterStartDefinition(&$Panel) { $Panel->Context->Dictionary['StartANewDiscussion'] = $Panel->Context->Dictionary['StartANewDiscussion_accesskey']; } $Context->AddToDelegate('Panel', 'PreRender', 'Panel_AlterStartDefinition'); } } } // Add the QuickKeys setting to the forum preferences form if ($Context->SelfUrl == 'account.php' && $Context->Session->UserID > 0) { $PostBackAction = ForceIncomingString('PostBackAction', ''); if ($PostBackAction == 'Functionality') { function PreferencesForm_AddQuickKeysPreference(&$PreferencesForm) { $PreferencesForm->AddPreference('MenuOptions', 'UseQuickKeys', 'UseQuickKeys', 1); } $Context->AddToDelegate('PreferencesForm', 'Constructor', 'PreferencesForm_AddQuickKeysPreference'); } } ?>