From d17008560036f91fd7327b17ad68cbadc3f7a8ac Mon Sep 17 00:00:00 2001
From: svncommit <devs@roundcube.net>
Date: Tue, 21 Nov 2006 03:02:48 -0500
Subject: [PATCH] Add first and last buttons.

---
 skins/default/templates/mail.html          |    2 ++
 skins/default/images/buttons/last_sel.png  |    0 
 skins/default/images/buttons/first_act.png |    0 
 skins/default/images/buttons/last_act.png  |    0 
 program/localization/en_US/labels.inc      |    4 ++++
 skins/default/images/buttons/first_sel.png |    0 
 program/steps/mail/show.inc                |   10 +++++++++-
 skins/default/images/buttons/last_pas.png  |    0 
 skins/default/templates/addressbook.html   |    2 ++
 skins/default/templates/message.html       |    2 ++
 skins/default/images/buttons/first_pas.png |    0 
 program/js/app.js                          |   30 ++++++++++++++++++++++++++++++
 12 files changed, 49 insertions(+), 1 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index ae68ea8..6485a98 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -141,9 +141,15 @@
           {
           this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', 'viewsource', 'print', 'load-attachment', true);
           if (this.env.next_uid)
+            {
             this.enable_command('nextmessage', true);
+            this.enable_command('lastmessage', true);
+            }
           if (this.env.prev_uid)
+            {
             this.enable_command('previousmessage', true);
+            this.enable_command('firstmessage', true);
+            }
           }
 
         if (this.env.action=='show' && this.env.blockedobjects)
@@ -478,8 +484,16 @@
         this.list_page('next');
         break;
 
+      case 'lastpage':
+        this.list_page('last');
+        break;
+
       case 'previouspage':
         this.list_page('prev');
+        break;
+
+      case 'firstpage':
+        this.list_page('first');
         break;
 
       case 'expunge':
@@ -656,9 +670,19 @@
           this.show_message(this.env.next_uid);
         break;
 
+	  case 'lastmessage':
+        if (this.env.last_uid)
+          this.show_message(this.env.last_uid);
+        break;
+
       case 'previousmessage':
         if (this.env.prev_uid)
           this.show_message(this.env.prev_uid);
+        break;
+
+      case 'firstmessage':
+        if (this.env.first_uid)
+          this.show_message(this.env.first_uid);
         break;
       
       case 'checkmail':
@@ -1095,8 +1119,12 @@
     {
     if (page=='next')
       page = this.env.current_page+1;
+    if (page=='last')
+      page = this.env.pagecount;
     if (page=='prev' && this.env.current_page>1)
       page = this.env.current_page-1;
+    if (page=='first' && this.env.current_page>1)
+      page = 1;
       
     if (page > 0 && page <= this.env.pagecount)
       {
@@ -2634,7 +2662,9 @@
   this.set_page_buttons = function()
     {
     this.enable_command('nextpage', (this.env.pagecount > this.env.current_page));
+    this.enable_command('lastpage', (this.env.pagecount > this.env.current_page));
     this.enable_command('previouspage', (this.env.current_page > 1));
+    this.enable_command('firstpage', (this.env.current_page > 1));
     }
 
 
diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index b27c179..8b18362 100644
--- a/program/localization/en_US/labels.inc
+++ b/program/localization/en_US/labels.inc
@@ -98,7 +98,9 @@
 $labels['deletemessage']    = 'Move message to trash';
 $labels['printmessage']     = 'Print this message';
 $labels['previousmessages'] = 'Show previous set of messages';
+$labels['firstmessages']    = 'Show first set of messages';
 $labels['nextmessages']     = 'Show next set of messages';
+$labels['lastmessages']     = 'Show last set of messages';
 $labels['backtolist']       = 'Back to message list';
 $labels['viewsource']       = 'Show source';
 
@@ -171,7 +173,9 @@
 $labels['export']         = 'Export';
 
 $labels['previouspage']   = 'Show previous set';
+$labels['firstpage']      = 'Show first set';
 $labels['nextpage']       = 'Show next set';
+$labels['lastpage']       = 'Show last set';
 
 
 // LDAP search
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 51633fa..c8e4937 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -60,7 +60,7 @@
   $javascript .= sprintf("%s.set_env('safemode', '%b');", $JS_OBJECT_NAME, $_GET['_safe']);
 
   $next = $prev = -1;
-  // get previous and next message UID
+  // get previous, first, next and last message UID
   if (!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') && 
       $IMAP->get_capability('sort')) 
     {
@@ -69,21 +69,29 @@
  
     $MESSAGE['index'] = array_search((string)$MESSAGE['UID'], $a_msg_index, TRUE);
     $prev = isset($a_msg_index[$MESSAGE['index']-1]) ? $a_msg_index[$MESSAGE['index']-1] : -1 ;
+    $first = count($a_msg_index)>0 ? $a_msg_index[0] : -1;
     $next = isset($a_msg_index[$MESSAGE['index']+1]) ? $a_msg_index[$MESSAGE['index']+1] : -1 ;
+    $last = count($a_msg_index)>0 ? $a_msg_index[count($a_msg_index)-1] : -1;
     }
   else
     {
     // this assumes that we are sorted by date_DESC
     $seq = $IMAP->get_id($MESSAGE['UID']);
     $prev = $IMAP->get_uid($seq + 1);
+    $first = $IMAP->get_uid($IMAP->messagecount());
     $next = $IMAP->get_uid($seq - 1);
+    $last = $IMAP->get_uid(1);
     $MESSAGE['index'] = $IMAP->messagecount() - $seq;
     }
   
   if ($prev > 0)
     $javascript .= sprintf("\n%s.set_env('prev_uid', '%s');", $JS_OBJECT_NAME, $prev);
+  if ($first >0)
+    $javascript .= sprintf("\n%s.set_env('first_uid', '%s');", $JS_OBJECT_NAME, $first);
   if ($next > 0)
     $javascript .= sprintf("\n%s.set_env('next_uid', '%s');", $JS_OBJECT_NAME, $next);
+  if ($last >0)
+    $javascript .= sprintf("\n%s.set_env('last_uid', '%s');", $JS_OBJECT_NAME, $last);
 
   $OUTPUT->add_script($javascript);
   }
diff --git a/skins/default/images/buttons/first_act.png b/skins/default/images/buttons/first_act.png
new file mode 100644
index 0000000..8322fd1
--- /dev/null
+++ b/skins/default/images/buttons/first_act.png
Binary files differ
diff --git a/skins/default/images/buttons/first_pas.png b/skins/default/images/buttons/first_pas.png
new file mode 100644
index 0000000..0934cd1
--- /dev/null
+++ b/skins/default/images/buttons/first_pas.png
Binary files differ
diff --git a/skins/default/images/buttons/first_sel.png b/skins/default/images/buttons/first_sel.png
new file mode 100644
index 0000000..6bc1d9f
--- /dev/null
+++ b/skins/default/images/buttons/first_sel.png
Binary files differ
diff --git a/skins/default/images/buttons/last_act.png b/skins/default/images/buttons/last_act.png
new file mode 100644
index 0000000..3967fa4
--- /dev/null
+++ b/skins/default/images/buttons/last_act.png
Binary files differ
diff --git a/skins/default/images/buttons/last_pas.png b/skins/default/images/buttons/last_pas.png
new file mode 100644
index 0000000..e18d37a
--- /dev/null
+++ b/skins/default/images/buttons/last_pas.png
Binary files differ
diff --git a/skins/default/images/buttons/last_sel.png b/skins/default/images/buttons/last_sel.png
new file mode 100644
index 0000000..0d608ea
--- /dev/null
+++ b/skins/default/images/buttons/last_sel.png
Binary files differ
diff --git a/skins/default/templates/addressbook.html b/skins/default/templates/addressbook.html
index dcf9656..1cbdc84 100644
--- a/skins/default/templates/addressbook.html
+++ b/skins/default/templates/addressbook.html
@@ -20,9 +20,11 @@
 </div>
 
 <div id="abookcountbar">
+<roundcube:button command="firstpage" imageSel="/images/buttons/first_sel.png" imageAct="/images/buttons/first_act.png" imagePas="/images/buttons/first_pas.png" width="11" height="11" title="firstpage" />
 <roundcube:button command="previouspage" imageSel="/images/buttons/previous_sel.png" imageAct="/images/buttons/previous_act.png" imagePas="/images/buttons/previous_pas.png" width="11" height="11" title="previouspage" />
 &nbsp;<roundcube:object name="recordsCountDisplay" />&nbsp;
 <roundcube:button command="nextpage" imageSel="/images/buttons/next_sel.png" imageAct="/images/buttons/next_act.png" imagePas="/images/buttons/next_pas.png" width="11" height="11" title="nextpage" />
+<roundcube:button command="lastpage" imageSel="/images/buttons/last_sel.png" imageAct="/images/buttons/last_act.png" imagePas="/images/buttons/last_pas.png" width="11" height="11" title="lastpage" />
 </div>
 
 <div id="addresslist">
diff --git a/skins/default/templates/mail.html b/skins/default/templates/mail.html
index 663fdfd..6d95d60 100644
--- a/skins/default/templates/mail.html
+++ b/skins/default/templates/mail.html
@@ -25,9 +25,11 @@
 </div>
 
 <div id="messagecountbar">
+<roundcube:button command="firstpage" imageSel="/images/buttons/first_sel.png" imageAct="/images/buttons/first_act.png" imagePas="/images/buttons/first_pas.png" width="11" height="11" title="firstmessages" />
 <roundcube:button command="previouspage" imageSel="/images/buttons/previous_sel.png" imageAct="/images/buttons/previous_act.png" imagePas="/images/buttons/previous_pas.png" width="11" height="11" title="previousmessages" />
 &nbsp;<roundcube:object name="messageCountDisplay" />&nbsp;
 <roundcube:button command="nextpage" imageSel="/images/buttons/next_sel.png" imageAct="/images/buttons/next_act.png" imagePas="/images/buttons/next_pas.png" width="11" height="11" title="nextmessages" />
+<roundcube:button command="lastpage" imageSel="/images/buttons/last_sel.png" imageAct="/images/buttons/last_act.png" imagePas="/images/buttons/last_pas.png" width="11" height="11" title="lastmessages" />
 </div>
 
 <div id="mailboxlist-header"><roundcube:label name="mailboxlist" /></div>
diff --git a/skins/default/templates/message.html b/skins/default/templates/message.html
index f802b5a..2ce8046 100644
--- a/skins/default/templates/message.html
+++ b/skins/default/templates/message.html
@@ -11,9 +11,11 @@
 <roundcube:include file="/includes/header.html" />
 
 <div id="messagecountbar">
+<roundcube:button command="firstmessage" imageSel="/images/buttons/first_sel.png" imageAct="/images/buttons/first_act.png" imagePas="/images/buttons/first_pas.png" width="11" height="11" title="firstmessages" />
 <roundcube:button command="previousmessage" imageSel="/images/buttons/previous_sel.png" imageAct="/images/buttons/previous_act.png" imagePas="/images/buttons/previous_pas.png" width="11" height="11" title="previousmessages" />
 &nbsp;<roundcube:object name="messageCountDisplay" />&nbsp;
 <roundcube:button command="nextmessage" imageSel="/images/buttons/next_sel.png" imageAct="/images/buttons/next_act.png" imagePas="/images/buttons/next_pas.png" width="11" height="11" title="nextmessages" />
+<roundcube:button command="lastmessage" imageSel="/images/buttons/last_sel.png" imageAct="/images/buttons/last_act.png" imagePas="/images/buttons/last_pas.png" width="11" height="11" title="lastmessages" />
 </div>
 
 <div id="messagetoolbar">

--
Gitblit v1.9.1