Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F537668
PhabricatorHelpKeyboardShortcutController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
PhabricatorHelpKeyboardShortcutController.php
View Options
<?php
final
class
PhabricatorHelpKeyboardShortcutController
extends
PhabricatorHelpController
{
public
function
shouldAllowPublic
()
{
return
true
;
}
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$keys
=
$request
->
getStr
(
'keys'
);
try
{
$keys
=
phutil_json_decode
(
$keys
);
}
catch
(
PhutilJSONParserException
$ex
)
{
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.'
),
'group'
=>
'global'
,
);
$groups
=
array
(
'default'
=>
array
(
'name'
=>
pht
(
'Page Shortcuts'
),
'icon'
=>
'fa-keyboard-o'
,
),
'diff-nav'
=>
array
(
'name'
=>
pht
(
'Diff Navigation'
),
'icon'
=>
'fa-arrows'
,
),
'diff-vis'
=>
array
(
'name'
=>
pht
(
'Hiding Content'
),
'icon'
=>
'fa-eye-slash'
,
),
'inline'
=>
array
(
'name'
=>
pht
(
'Editing Inline Comments'
),
'icon'
=>
'fa-pencil'
,
),
'xactions'
=>
array
(
'name'
=>
pht
(
'Comments'
),
'icon'
=>
'fa-comments-o'
,
),
'global'
=>
array
(
'name'
=>
pht
(
'Global Shortcuts'
),
'icon'
=>
'fa-globe'
,
),
);
$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"
,
);
$row_maps
=
array
();
foreach
(
$keys
as
$shortcut
)
{
$keystrokes
=
array
();
foreach
(
$shortcut
[
'keys'
]
as
$stroke
)
{
$stroke
=
idx
(
$stroke_map
,
$stroke
,
$stroke
);
$keystrokes
[]
=
phutil_tag
(
'span'
,
array
(
'class'
=>
'keyboard-shortcut-key'
,
),
$stroke
);
}
$keystrokes
=
phutil_implode_html
(
' or '
,
$keystrokes
);
$group_key
=
idx
(
$shortcut
,
'group'
);
if
(!
isset
(
$groups
[
$group_key
]))
{
$group_key
=
'default'
;
}
$row
=
phutil_tag
(
'tr'
,
array
(),
array
(
phutil_tag
(
'th'
,
array
(),
$keystrokes
),
phutil_tag
(
'td'
,
array
(),
$shortcut
[
'description'
]),
));
$row_maps
[
$group_key
][]
=
$row
;
}
$tab_group
=
id
(
new
PHUITabGroupView
())
->
setVertical
(
true
);
foreach
(
$groups
as
$key
=>
$group
)
{
$rows
=
idx
(
$row_maps
,
$key
);
if
(!
$rows
)
{
continue
;
}
$icon
=
id
(
new
PHUIIconView
())
->
setIcon
(
$group
[
'icon'
]);
$tab
=
id
(
new
PHUITabView
())
->
setKey
(
$key
)
->
setName
(
$group
[
'name'
])
->
setIcon
(
$icon
);
$table
=
phutil_tag
(
'table'
,
array
(
'class'
=>
'keyboard-shortcut-help'
),
$rows
);
$tab
->
appendChild
(
$table
);
$tab_group
->
addTab
(
$tab
);
}
return
$this
->
newDialog
()
->
setTitle
(
pht
(
'Keyboard Shortcuts'
))
->
setWidth
(
AphrontDialogView
::
WIDTH_FULL
)
->
setFlush
(
true
)
->
appendChild
(
$tab_group
)
->
addCancelButton
(
'#'
,
pht
(
'Close'
));
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 8:15 AM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
114092
Default Alt Text
PhabricatorHelpKeyboardShortcutController.php (3 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment