[geeklog-cvs] geeklog-1.3/public_html pollbooth.php,1.27,1.28
dhaun at iowaoutdoors.org
dhaun at iowaoutdoors.org
Wed Aug 11 09:33:38 EDT 2004
Update of /var/cvs/geeklog-1.3/public_html
In directory www:/tmp/cvs-serv29161
Modified Files:
pollbooth.php
Log Message:
Added "Google" paging
Index: pollbooth.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/pollbooth.php,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** pollbooth.php 11 Aug 2004 13:04:25 -0000 1.27
--- pollbooth.php 11 Aug 2004 13:33:34 -0000 1.28
***************
*** 14,17 ****
--- 14,18 ----
// | Mark Limburg - mlimburg at users.sourceforge.net |
// | Jason Whittenburg - jwhitten at securitygeeks.com |
+ // | Dirk Haun - dirk at haun-online.de |
// +---------------------------------------------------------------------------+
// | |
***************
*** 34,38 ****
// $Id$
! require_once('lib-common.php');
/**
--- 35,42 ----
// $Id$
! require_once ('lib-common.php');
!
! // number of polls to list per page
! define ('POLLS_PER_PAGE', 50);
/**
***************
*** 82,91 ****
* List all the polls on the system if no $qid is provided
*
! * @return string HTML for poll listing
*
*/
! function polllist()
{
! global $_TABLES, $_CONF, $_USER, $_GROUPS, $LANG07, $LANG10, $LANG_LOGIN;
if (empty ($_USER['username']) &&
--- 86,100 ----
* List all the polls on the system if no $qid is provided
*
! * @param int $page page to display
! * @return string HTML for poll listing
*
*/
! function polllist ($page = 1)
{
! global $_CONF, $_TABLES, $_USER, $_GROUPS, $LANG07, $LANG10, $LANG_LOGIN;
!
! if ($page < 1) {
! $page = 1;
! }
if (empty ($_USER['username']) &&
***************
*** 103,108 ****
$retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
} else {
$sql = "SELECT qid,question,voters FROM {$_TABLES['pollquestions']}"
! . COM_getPermSQL () . ' ORDER BY date DESC';
$result = DB_query($sql);
$nrows = DB_numRows($result);
--- 112,118 ----
$retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
} else {
+ $limit = (POLLS_PER_PAGE * $page) - POLLS_PER_PAGE;
$sql = "SELECT qid,question,voters FROM {$_TABLES['pollquestions']}"
! . COM_getPermSQL () . " ORDER BY date DESC LIMIT $limit," . POLLS_PER_PAGE;
$result = DB_query($sql);
$nrows = DB_numRows($result);
***************
*** 111,117 ****
$pollitem = new Template($_CONF['path_layout'] . 'pollbooth');
$pollitem->set_file('pollitem', 'polllist.thtml');
! for ($i = 1; $i <= $nrows; $i++) {
$Q = DB_fetchArray($result);
! $pollitem->set_var('item_num', $i);
$pollitem->set_var('poll_url', $_CONF['site_url'].'/pollbooth.php?qid=' . $Q['qid'] . '&aid=-1');
$pollitem->set_var('poll_question', stripslashes($Q['question']));
--- 121,128 ----
$pollitem = new Template($_CONF['path_layout'] . 'pollbooth');
$pollitem->set_file('pollitem', 'polllist.thtml');
! for ($i = 0; $i < $nrows; $i++) {
$Q = DB_fetchArray($result);
! $pcount = (POLLS_PER_PAGE * ($page - 1)) + $i + 1;
! $pollitem->set_var('item_num', $pcount);
$pollitem->set_var('poll_url', $_CONF['site_url'].'/pollbooth.php?qid=' . $Q['qid'] . '&aid=-1');
$pollitem->set_var('poll_question', stripslashes($Q['question']));
***************
*** 126,129 ****
--- 137,149 ----
$retval .= $pollitem->finish($pollitem->get_var('output'));
}
+
+ $result = DB_query ("SELECT COUNT(*) AS count FROM {$_TABLES['pollquestions']}" . COM_getPermSQL ());
+ $A = DB_fetchArray ($result);
+ $numpolls = $A['count'];
+ if ($numpolls > POLLS_PER_PAGE) {
+ $baseurl = $_CONF['site_url'] . '/pollbooth.php';
+ $numpages = ceil ($numpolls / POLLS_PER_PAGE);
+ $retval .= COM_printPageNavigation ($baseurl, $page, $numpages);
+ }
} else {
$retval .= $LANG10[17];
***************
*** 175,179 ****
if (empty($qid)) {
! $display .= COM_siteHeader ('menu', $LANG07[4]) . polllist ();
} else if ($aid == 0) {
$display .= COM_siteHeader();
--- 195,204 ----
if (empty($qid)) {
! if (isset ($HTTP_GET_VARS['page'])) {
! $page = COM_applyFilter ($HTTP_GET_VARS['page'], true);
! } else {
! $page = 1;
! }
! $display .= COM_siteHeader ('menu', $LANG07[4]) . polllist ($page);
} else if ($aid == 0) {
$display .= COM_siteHeader();
More information about the geeklog-cvs
mailing list