Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102797627
PhabricatorHelpKeyboardShortcutController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Feb 24, 07:08
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Feb 26, 07:08 (1 d, 17 h)
Engine
blob
Format
Raw Data
Handle
24427044
Attached To
rPH Phabricator
PhabricatorHelpKeyboardShortcutController.php
View Options
<?php
final
class
PhabricatorHelpKeyboardShortcutController
extends
PhabricatorHelpController
{
public
function
shouldAllowPublic
()
{
return
true
;
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$keys
=
$request
->
getStr
(
'keys'
);
$keys
=
json_decode
(
$keys
,
true
);
if
(!
is_array
(
$keys
))
{
return
new
Aphront400Response
();
}
// There have been at least two users asking for a keyboard shortcut to
// close the dialog, so be explicit that escape works since it isn't
// terribly discoverable.
$keys
[]
=
array
(
'keys'
=>
array
(
'esc'
),
'description'
=>
pht
(
'Close any dialog, including this one.'
),
);
$stroke_map
=
array
(
'left'
=>
"
\x
E2
\x
86
\x
90"
,
'right'
=>
"
\x
E2
\x
86
\x
92"
,
'up'
=>
"
\x
E2
\x
86
\x
91"
,
'down'
=>
"
\x
E2
\x
86
\x
93"
,
'return'
=>
"
\x
E2
\x
8F
\x
8E"
,
'tab'
=>
"
\x
E2
\x
87
\x
A5"
,
'delete'
=>
"
\x
E2
\x
8C
\x
AB"
,
);
$rows
=
array
();
foreach
(
$keys
as
$shortcut
)
{
$keystrokes
=
array
();
foreach
(
$shortcut
[
'keys'
]
as
$stroke
)
{
$stroke
=
idx
(
$stroke_map
,
$stroke
,
$stroke
);
$keystrokes
[]
=
phutil_tag
(
'kbd'
,
array
(),
$stroke
);
}
$keystrokes
=
phutil_implode_html
(
' or '
,
$keystrokes
);
$rows
[]
=
phutil_tag
(
'tr'
,
array
(),
array
(
phutil_tag
(
'th'
,
array
(),
$keystrokes
),
phutil_tag
(
'td'
,
array
(),
$shortcut
[
'description'
]),
));
}
$table
=
phutil_tag
(
'table'
,
array
(
'class'
=>
'keyboard-shortcut-help'
),
$rows
);
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$user
)
->
setTitle
(
pht
(
'Keyboard Shortcuts'
))
->
appendChild
(
$table
)
->
addCancelButton
(
'#'
,
pht
(
'Close'
));
return
id
(
new
AphrontDialogResponse
())
->
setDialog
(
$dialog
);
}
}
Event Timeline
Log In to Comment