[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/help/controller/ -> PhabricatorHelpKeyboardShortcutController.php (source)

   1  <?php
   2  
   3  final class PhabricatorHelpKeyboardShortcutController
   4    extends PhabricatorHelpController {
   5  
   6    public function shouldAllowPublic() {
   7      return true;
   8    }
   9  
  10    public function processRequest() {
  11      $request = $this->getRequest();
  12      $user = $request->getUser();
  13  
  14      $keys = $request->getStr('keys');
  15      $keys = json_decode($keys, true);
  16      if (!is_array($keys)) {
  17        return new Aphront400Response();
  18      }
  19  
  20      // There have been at least two users asking for a keyboard shortcut to
  21      // close the dialog, so be explicit that escape works since it isn't
  22      // terribly discoverable.
  23      $keys[] = array(
  24        'keys'        => array('esc'),
  25        'description' => pht('Close any dialog, including this one.'),
  26      );
  27  
  28      $stroke_map = array(
  29        'left' => "\xE2\x86\x90",
  30        'right' => "\xE2\x86\x92",
  31        'up' => "\xE2\x86\x91",
  32        'down' => "\xE2\x86\x93",
  33        'return' => "\xE2\x8F\x8E",
  34        'tab' => "\xE2\x87\xA5",
  35        'delete' => "\xE2\x8C\xAB",
  36      );
  37  
  38      $rows = array();
  39      foreach ($keys as $shortcut) {
  40        $keystrokes = array();
  41        foreach ($shortcut['keys'] as $stroke) {
  42          $stroke = idx($stroke_map, $stroke, $stroke);
  43          $keystrokes[] = phutil_tag('kbd', array(), $stroke);
  44        }
  45        $keystrokes = phutil_implode_html(' or ', $keystrokes);
  46        $rows[] = phutil_tag(
  47          'tr',
  48          array(),
  49          array(
  50            phutil_tag('th', array(), $keystrokes),
  51            phutil_tag('td', array(), $shortcut['description']),
  52          ));
  53      }
  54  
  55      $table = phutil_tag(
  56        'table',
  57        array('class' => 'keyboard-shortcut-help'),
  58        $rows);
  59  
  60      $dialog = id(new AphrontDialogView())
  61        ->setUser($user)
  62        ->setTitle(pht('Keyboard Shortcuts'))
  63        ->appendChild($table)
  64        ->addCancelButton('#', pht('Close'));
  65  
  66      return id(new AphrontDialogResponse())
  67        ->setDialog($dialog);
  68    }
  69  
  70  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1