Add shortkey browsing
authorx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Sat, 19 Aug 2006 16:58:44 +0000 (16:58 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 4 Jan 2008 23:35:09 +0000 (00:35 +0100)
u => next unread
p => new post
r => reply
c => cancel
a => previous post
z => next post
q => previous thread
s => next thread

Do not hesitate to change the shortkeys if you have better :p

git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@138 9869982d-c50d-0410-be91-f2a2ec7c7c7b

Changelog
banana/misc.inc.php
banana/post.inc.php
banana/spool.inc.php

index c5c117f..dade110 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,7 @@
+Sat, 19 Aug 2006                                       Florent Bruneau <florent.bruneau@m4x.org>
+
+       * Add shortkey browsing
+
 Sat, 05 Aug 2006                    Florent Bruneau <florent.bruneau@m4x.org>
 
        * Allow browsing through unread messages
index fe76cd9..48c8081 100644 (file)
@@ -83,12 +83,15 @@ function makeLink($params)
 /** Format a link to be use in a link
  * @ref makeLink
  */
-function makeHREF($params, $text = null, $popup = null, $class = null)
+function makeHREF($params, $text = null, $popup = null, $class = null, $accesskey = null)
 {
     $link = makeLink($params);
     if (is_null($text)) {
         $text = $link;
     }
+    if (!is_null($accesskey)) {
+        $popup .= ' (raccourci : ' . $accesskey . ')';
+    }
     if (!is_null($popup)) {
         $popup = ' title="' . $popup . '"';
     }
@@ -99,7 +102,13 @@ function makeHREF($params, $text = null, $popup = null, $class = null)
     if (isset($params['action']) && $params['action'] == 'view') {
         $target = ' target="_blank"';
     }
-    return '<a href="' . htmlentities($link) .'"' . $target . $popup . $class . '>' . $text . '</a>';
+    if (!is_null($accesskey)) {
+        $accesskey = ' accesskey="' . $accesskey . '"';
+    }
+
+    return '<a href="' . htmlentities($link) . '"' 
+          . $target . $popup . $class . $accesskey
+          . '>' . $text . '</a>';
 }
 
 /** Format tree images links
@@ -133,12 +142,13 @@ function makeImg($img, $alt, $height = null, $width = null)
 
 /** Make a link using an image
  */
-function makeImgLink($params, $img, $alt, $height = null, $width = null, $class = null)
+function makeImgLink($params, $img, $alt, $height = null, $width = null, $class = null, $accesskey = null)
 {
     return makeHREF($params,
                     makeImg($img, ' [' . $alt . ']', $height, $width),
                     $alt,
-                    $class);
+                    $class,
+                    $accesskey);
 }
 
 /********************************************************************************
index 3ee59cf..3db1818 100644 (file)
@@ -360,18 +360,20 @@ class BananaPost
     {
         global $banana;
         $ret = '<div class="banana_menu">';
-        $actions = Array('nextUnread' => Array('next_unread', _b_('Message non-lu suivant')),
-                         'prevPost'   => Array('prev',        _b_('Article précédent')),
-                         'nextPost'   => Array('next',        _b_('Article suivant')),
-                         'prevThread' => Array('prev_thread', _b_('Discussion précédente')),
-                         'nextThread' => Array('next_thread', _b_('Discussion suivante')));
+        $actions = Array('nextUnread' => Array('next_unread', _b_('Message non-lu suivant'), 'u'),
+                         'prevPost'   => Array('prev',        _b_('Article précédent'), 'a'),
+                         'nextPost'   => Array('next',        _b_('Article suivant'), 'z'),
+                         'prevThread' => Array('prev_thread', _b_('Discussion précédente'), 'q'),
+                         'nextThread' => Array('next_thread', _b_('Discussion suivante'), 's'));
         foreach ($actions as $method=>$params) {
             $id = $banana->spool->$method($this->id);
             if (!is_null($id)) {
                 $ret .= makeImgLink(Array('group' => $banana->state['group'],
                                           'artid' => $id),
                                     $params[0] . '.gif',
-                                    $params[1]);
+                                    $params[1],
+                                    null, null, null,
+                                    $params[2]);
             }
         }
         return $ret . '</div>';
@@ -416,19 +418,19 @@ class BananaPost
              . makeImgLink(Array('group'  => $banana->state['group'],
                                  'action' => 'new'),
                            'post.gif',
-                           _b_('Nouveau message')) . '&nbsp;'
+                           _b_('Nouveau message'), null, null, null, 'p') . '&nbsp;'
              . makeImgLink(Array('group'  => $banana->state['group'],
                                  'artid'  => $this->id,
                                  'action' => 'new'),
                            'reply.gif',
-                           _b_('Répondre'));
+                           _b_('Répondre'), null, null, null, 'r');
         if ($this->checkCancel()) {
             $res .= '&nbsp;'
                   . makeImgLink(Array('group'  => $banana->state['group'],
                                       'artid'  => $this->id,
                                       'action' => 'cancel'),
                                 'cancel.gif',
-                                _b_('Annuler'));
+                                _b_('Annuler'), null, null, null, 'c');
         }
         $res .= '</div>'
              . formatDisplayHeader('subject', $this->headers['subject'])
index 9b634a0..de4e598 100644 (file)
@@ -397,13 +397,6 @@ class BananaSpool
     {
         $res  = '<table class="bicol banana_thread" cellpadding="0" cellspacing="0">';
        
-        $new  = '<div class="banana_action">'
-              . makeImgLink(Array('group'  => $this->group,
-                                  'action' => 'new'),
-                            'post.gif',
-                            _b_('Nouveau message'));
-        $new .= '</div>';
-        
         if (is_null($_ref)) {
             $next = $this->nextUnread();
             if (!is_null($next)) {
@@ -411,14 +404,14 @@ class BananaSpool
                       . makeImgLink(Array('group' => $this->group,
                                           'artid' => $next),
                                     'next_unread.gif',
-                                    _b_('Message non-lu suivant'))
+                                    _b_('Message non-lu suivant'), null, null, null, 'u')
                       . '</div>';
             }
             $new  = '<div class="banana_action">'
                   . makeImgLink(Array('group'  => $this->group,
                                       'action' => 'new'),
                                 'post.gif',
-                                _b_('Nouveau message'))
+                                _b_('Nouveau message'), null, null, null, 'p')
                   . '</div>';
 
             $res .= '<tr><th>' . $next . _b_('Date') . '</th>';