[turba] Letter "Pager"
Mike Bydalek
mbydalek at zivix.com
Tue Mar 9 12:43:46 PST 2004
One thing that has really frustrated me about the paging system at the
bottom is
that, how the heck do I find someone named "Smith" easily? Is he on
page 10, or
page 14? When browsing, page numbers seem silly to me, which is why I have the
attached patches.
Instead of pages, there's an A-Z listing. You can also modify your search to
include $page in it to help your query time (why get A-Z when you just want
R?). When searching, pages still exist, since it just makes sense to me.
Enjoy!
-Mike
-------------- next part --------------
*** browse.php.orig Tue Mar 9 15:31:49 2004
--- browse.php Tue Mar 9 14:25:10 2004
***************
*** 331,359 ****
'key' => Util::getFormData('key'),
'source' => Util::getFormData('source')
));
- $numitem = $results->count();
- $maxpage = $prefs->getValue('maxpage');
- $perpage = $prefs->getValue('perpage');
-
- $min = $page * $perpage;
- while ($min > $numitem) {
- $page--;
$min = $page * $perpage;
! }
! $max = $min + $perpage;
! $start = ($page * $perpage) + 1;
! $end = min($numitem, $start + $perpage - 1);
!
! $numDisplayed = $display->display($min, $max);
!
! $vars = &Variables::getDefaultVariables();
! $pager = &new Horde_UI_Pager('page', $vars, array('num' => $numDisplayed,
! 'url' => $viewurl,
! 'page_count' => $maxpage,
! 'perpage' => $perpage));
require TURBA_TEMPLATES . '/browse/column_footers.inc';
}
--- 332,370 ----
'key' => Util::getFormData('key'),
'source' => Util::getFormData('source')
));
+ if (Util::getFormData ('key') == '**search')
+ {
+ require_once HORDE_LIBS . 'Horde/UI/Pager.php';
+ $pager = &new Horde_UI_Pager();
+ $page = Util::getFormData ('page', 0);
+
+ $numitem = $results->count();
+ $maxpage = $prefs->getValue('maxpage');
+ $perpage = $prefs->getValue('perpage');
$min = $page * $perpage;
! while ($min > $numitem) {
! $page--;
! $min = $page * $perpage;
! }
! $max = $min + $perpage;
! $start = ($page * $perpage) + 1;
! $end = min($numitem, $start + $perpage - 1);
+ $numDisplayed = $display->display($min, $max);
+ }
+ else
+ {
+ $page = Util::getFormData('page', 'a');
+ if (empty ($page) || !preg_match ('/^[A-Za-z]$/', $page))
+ $page = 'a';
+
+ $stats = $display->display_alpha($page);
+ $start = $stats['start'];
+ $end = $stats['end'];
+ $numDisplayed = $results->count();
+ }
require TURBA_TEMPLATES . '/browse/column_footers.inc';
}
-------------- next part --------------
*** ListView.php.orig Tue Mar 9 15:32:15 2004
--- ListView.php Tue Mar 9 14:28:35 2004
***************
*** 56,60 ****
--- 56,89 ----
}
return $i;
}
+
+ function display_alpha ($alpha)
+ {
+ $this->list->reset ();
+ $stats = array ();
+ $i = 0;
+ while ($ob = $this->list->next ())
+ {
+ $name = Turba::formatName ($ob->getValue ('name'));
+ if (strtolower ($name{0}) == strtolower ($alpha))
+ break;
+ $i++;
+ }
+ $stats['start'] = $i + 1;
+
+ if ($ob)
+ {
+ do
+ {
+ $name = Turba::formatName ($ob->getValue ('name'));
+ if (strtolower ($name{0}) != strtolower ($alpha))
+ break;
+ include $this->template;
+ $i++;
+ } while ($ob = $this->list->next ());
+ }
+ $stats['end'] = $i;
+ return $stats;
+ }
}
More information about the turba
mailing list