Parcourir la source

Make compact paginator work on search results

pdontthink il y a 18 ans
Parent
commit
a24a217d02
2 fichiers modifiés avec 23 ajouts et 7 suppressions
  1. 1 1
      functions/template/paginator_util.php
  2. 22 6
      src/search.php

+ 1 - 1
functions/template/paginator_util.php

@@ -129,7 +129,7 @@ function get_compact_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll,
         if ($page_selector) {
         if ($page_selector) {
             $options = array();
             $options = array();
             for ($p = 0; $p < $tot_pgs; $p++) {
             for ($p = 0; $p < $tot_pgs; $p++) {
-                $options[(($p*$iLimit)+1)] = ($p+1) . "/$tot_pgs";
+                $options[(($p*$iLimit)+1) . '_' . $box] = ($p+1) . "/$tot_pgs";
             }
             }
             $result .= $spc . addSelect('startMessage_' . $display_iterations, 
             $result .= $spc . addSelect('startMessage_' . $display_iterations, 
                                         $options, 
                                         $options, 

+ 22 - 6
src/search.php

@@ -991,6 +991,7 @@ if ($search_advanced) {
  * @global string $submit
  * @global string $submit
  */
  */
 $searchpressed = false;
 $searchpressed = false;
+//FIXME: Why is there so much access to $_GET in this file?  What's wrong with sqGetGlobalVar?
 if (isset($_GET['submit'])) {
 if (isset($_GET['submit'])) {
     $submit = strip_tags($_GET['submit']);
     $submit = strip_tags($_GET['submit']);
 }
 }
@@ -998,9 +999,17 @@ if (isset($_GET['submit'])) {
 /** Searched mailboxes
 /** Searched mailboxes
  * @global array $mailbox_array
  * @global array $mailbox_array
  */
  */
-if (isset($_GET['mailbox'])) {
-    $mailbox_array = $_GET['mailbox'];
-    $targetmailbox = $_GET['mailbox'];
+/* when using compact paginator, mailbox might be indicated in $startMessage, so look for it now ($startMessage is then processed farther below) */
+$mailbox = '';
+$startMessage = '';
+if (sqGetGlobalVarMultiple('startMessage', $temp, 'paginator_submit', SQ_FORM)) {
+    if (strstr($temp, '_')) list($startMessage, $mailbox) = explode('_', $temp);
+    else $startMessage = $temp;
+}
+if (empty($mailbox)) sqGetGlobalVar('mailbox', $mailbox, SQ_GET, '');
+if (!empty($mailbox)) {
+    $mailbox_array = $mailbox;
+    $targetmailbox = $mailbox;
     if (!is_array($mailbox_array)) {
     if (!is_array($mailbox_array)) {
         $mailbox_array = array($mailbox_array);
         $mailbox_array = array($mailbox_array);
     }
     }
@@ -1029,6 +1038,7 @@ $aConfig = array(
 /** Binary operators
 /** Binary operators
  * @global array $biop_array
  * @global array $biop_array
  */
  */
+//FIXME: Why is there so much access to $_GET in this file?  What's wrong with sqGetGlobalVar?
 if (isset($_GET['biop'])) {
 if (isset($_GET['biop'])) {
     $biop_array = $_GET['biop'];
     $biop_array = $_GET['biop'];
     if (!is_array($biop_array))
     if (!is_array($biop_array))
@@ -1039,6 +1049,7 @@ if (isset($_GET['biop'])) {
 /** Unary operators
 /** Unary operators
  * @global array $unop_array
  * @global array $unop_array
  */
  */
+//FIXME: Why is there so much access to $_GET in this file?  What's wrong with sqGetGlobalVar?
 if (isset($_GET['unop'])) {
 if (isset($_GET['unop'])) {
     $unop_array = $_GET['unop'];
     $unop_array = $_GET['unop'];
     if (!is_array($unop_array))
     if (!is_array($unop_array))
@@ -1049,6 +1060,7 @@ if (isset($_GET['unop'])) {
 /** Where to search
 /** Where to search
  * @global array $where_array
  * @global array $where_array
  */
  */
+//FIXME: Why is there so much access to $_GET in this file?  What's wrong with sqGetGlobalVar?
 if (isset($_GET['where'])) {
 if (isset($_GET['where'])) {
     $where_array = $_GET['where'];
     $where_array = $_GET['where'];
     if (!is_array($where_array)) {
     if (!is_array($where_array)) {
@@ -1060,6 +1072,7 @@ if (isset($_GET['where'])) {
 /** What to search
 /** What to search
  * @global array $what_array
  * @global array $what_array
  */
  */
+//FIXME: Why is there so much access to $_GET in this file?  What's wrong with sqGetGlobalVar?
 if (isset($_GET['what'])) {
 if (isset($_GET['what'])) {
     $what_array = $_GET['what'];
     $what_array = $_GET['what'];
     if (!is_array($what_array)) {
     if (!is_array($what_array)) {
@@ -1071,6 +1084,7 @@ if (isset($_GET['what'])) {
 /** Whether to exclude this criteria from search
 /** Whether to exclude this criteria from search
  * @global array $exclude_array
  * @global array $exclude_array
  */
  */
+//FIXME: Why is there so much access to $_GET in this file?  What's wrong with sqGetGlobalVar?
 if (isset($_GET['exclude'])) {
 if (isset($_GET['exclude'])) {
     $exclude_array = $_GET['exclude'];
     $exclude_array = $_GET['exclude'];
 } else {
 } else {
@@ -1079,6 +1093,7 @@ if (isset($_GET['exclude'])) {
 /** Search within subfolders
 /** Search within subfolders
  * @global array $sub_array
  * @global array $sub_array
  */
  */
+//FIXME: Why is there so much access to $_GET in this file?  What's wrong with sqGetGlobalVar?
 if (isset($_GET['sub'])) {
 if (isset($_GET['sub'])) {
     $sub_array = $_GET['sub'];
     $sub_array = $_GET['sub'];
 } else {
 } else {
@@ -1086,6 +1101,7 @@ if (isset($_GET['sub'])) {
 }
 }
 /** Row number used by recent and saved stuff
 /** Row number used by recent and saved stuff
  */
  */
+//FIXME: Why is there so much access to $_GET in this file?  What's wrong with sqGetGlobalVar?
 if (isset($_GET['rownum'])) {
 if (isset($_GET['rownum'])) {
     $submit_rownum = strip_tags($_GET['rownum']);
     $submit_rownum = strip_tags($_GET['rownum']);
 }
 }
@@ -1096,9 +1112,9 @@ if (sqgetGlobalVar('srt', $temp, SQ_GET)) {
     asearch_edit_last(1);
     asearch_edit_last(1);
 //    asearch_push_recent($mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array);
 //    asearch_push_recent($mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array);
 }
 }
-//FIXME: the following gets the right startMessage value, but there is no indication of what form it came from (thus what mailbox folder needs to be paginated), so when using the compact paginator without javascript turned on, pagination is broken
-if (sqGetGlobalVarMultiple('startMessage', $temp, 'paginator_submit', SQ_FORM)) {
-    $startMessage = (int) $temp;
+/* already retrieved startMessage above */
+if (!empty($startMessage)) {
+    $startMessage = (int) $startMessage;
     asearch_edit_last(1);
     asearch_edit_last(1);
 //    asearch_push_recent($mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array);
 //    asearch_push_recent($mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array);
 }
 }