N°3524 Add keyboard shortcuts to global actions

This commit is contained in:
Stephen Abello
2021-03-17 10:56:18 +01:00
parent 8dd8f98b61
commit a8ede8b857
26 changed files with 345 additions and 33 deletions

View File

@@ -2771,4 +2771,28 @@ HTML;
return $aMatchingClasses;
}
/**
* Return keyboard shortcuts config as an array
*
* @return array
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
* @since 3.0.0
*/
public static function GetKeyboardShortcutPref(): array
{
$aResultPref = [];
$aShortcutPrefs = appUserPreferences::GetPref('keyboard_shortcuts', []);
$aShortcutClasses = utils::GetClassesForInterface('iKeyboardShortcut','', array('/lib/', 'node_modules', 'test'));
foreach($aShortcutClasses as $cShortcutPlugin) {
$sTriggeredElement = $cShortcutPlugin::GetShortcutTriggeredElementSelector();
foreach ($cShortcutPlugin::GetShortcutKeys() as $aShortcutKey) {
$sKey = isset($aShortcutPrefs[$aShortcutKey['id']]) ? $aShortcutPrefs[$aShortcutKey['id']] : $aShortcutKey['key'];
$aResultPref[$aShortcutKey['id']] = ['key' => $sKey, 'label' => $aShortcutKey['label'], 'event' => $aShortcutKey['event'], 'triggered_element_selector' => $sTriggeredElement];
}
}
return $aResultPref;
}
}