Welcome to Geeklog, Anonymous Sunday, December 22 2024 @ 01:53 am EST
Geeklog Forums
upage mini-update
Status: offline
amckay
Forum User
Full Member
Registered: 03/23/02
Posts: 180
for anyone who wants to be able to page images instead of showing them all all the time, replace the function UPAGE_tableSQL in /path/to/geeklog/plugins/upage/functions.inc with the below
function UPAGE_tableSQL( $sql, $func, $cols=0, $rows=0 )
//
// execute the given SQL query, then for each row in
// the result, call the passed function
{
global $PHP_SELF;
global $paginate;
global $QUERY_STRING;
global $_CONF;
global $LANG_UPAGE;
// set to defaults from config.php if not specified by caller
if ( empty( $cols ) )
$cols = $_CONF['upic_cols'];
if ( empty( $rows ) )
$rows = $_CONF['upic_rows'];
// this bit probably wants to be drawn into a function eventually
// it does the pagination. Note it relies on the query string
// variable "paginate" being used universally by all callers
$limit = $cols * $rows;
if ( ! empty( $limit ) ) {
// first set out lower and upper limits for the SQL query
$limlo = $paginate * $limit;
$limhi = $paginate * $limit + $limit;
// here is where we have to manipulate the query string
// parse out the query string by & and then =
// to get all variables that are found within
$qarr = split( "&", $QUERY_STRING );
while ( list( $key, $value ) = each( $qarr ) ) {
list( $qvar, $qval ) = split( "=", $value );
$qnew[$qvar] = $qval;
}
// if the pageinate variable was not specified (e.g. first page)
// then we have to set it.
if ( empty( $qnew['paginate'] ) )
$qnew['paginate'] = 0;
// now reassemble 2 new query strings, one for 'next' and 'prev'
$qnext = "";
$qprev = "";
while ( list( $key, $value ) = each( $qnew ) ) {
if ( ! empty( $qnext ) )
$qnext .= "&";
if ( $key == "paginate" )
$qnext .= $key . "=" . ($value + 1);
else
$qnext .= $key . "=" . $value;
if ( ! empty( $qprev ) )
$qprev .= "&";
if ( $key == "paginate" )
$qprev .= $key . "=" . ($value - 1);
else
$qprev .= $key . "=" . $value;
}
$sql .= " LIMIT " . $limlo . ", " . $limit;
$pageit .= ""
. "<tr>"
. "<td colspan=$cols align=center>"
. "<table align=center width=100% border=0 cellpadding=0 cellspacing=0>"
. "<tr>"
. "<td width=30% align=left>"
. "";
if ( ! empty( $paginate ) )
$pageit .= "<a href='" . $PHP_SELF . "?" . $qprev . "'>prev</a>";
$pageit .= ""
. "</td>"
. "<td width=40% align=right> "
. "</td>"
. "<td width=30% align=right>"
. "<a href='" . $PHP_SELF . "?" . $qnext . "'>next</a>"
. "</td>"
. "</td>"
. "</tr>"
. "</table>"
. "</td>"
. "</tr>";
// once we drop out here, the $pageit variable can be used to display
// the paging information. Note below it's included in the top and
// bottom of the table
}
// try to execute the passed in query
if ( ! $result = DB_query( $sql ) ) {
$retr = $LANG_UPAGE['err_db_generic'];
return $retr;
}
// woogy!
$retr = ""
. "<!-- woogy -->"
. "<table width=100% align=center border=0>"
. $pageit
. "";
// we have to count which column we are in
$myCol = 1;
// column width depends on number of columns
$cwid = floor(100/$cols);
// loop through each record of the result, keeping track
// of what column and row we are in, as well as calling
// the passed in function for each record
while ( $ROW = DB_fetchArray( $result ) ) {
switch ( $myCol ) {
case 1 :
$retr .= "<tr>";
break;
case $cols+1 :
$retr .= "</tr>";
// column width depends on number of columns
$cwid = floor(100/$cols);
// loop through each record of the result, keeping track
// of what column and row we are in, as well as calling
// the passed in function for each record
while ( $ROW = DB_fetchArray( $result ) ) {
switch ( $myCol ) {
case 1 :
$retr .= "<tr>";
break;
case $cols+1 :
$retr .= "</tr>";
$myCol = 1;
break;
}
$retr .= "<td width=" . $cwid . "% valign=top align=center>";
if ( function_exists( $func ) )
$retr .= $func( $ROW );
else
$retr .= $LANG_UPAGE['err_no_func'];
$retr .= "</td>";
$myCol++;
}
// if we didn't end up in the last column because of an odd
// number of entries, then we have to finish off the row
if ( $myCol <= $cols )
{
while ( $myCol++ <= $cols )
$retr .= "<td width=" . $cwid . "% valign=top align=center> </td>";
$retr .= "</tr>";
}
$retr .= $pageit
. "</table>";
return $retr;
}
Text Formatted Code
function UPAGE_tableSQL( $sql, $func, $cols=0, $rows=0 )
//
// execute the given SQL query, then for each row in
// the result, call the passed function
{
global $PHP_SELF;
global $paginate;
global $QUERY_STRING;
global $_CONF;
global $LANG_UPAGE;
// set to defaults from config.php if not specified by caller
if ( empty( $cols ) )
$cols = $_CONF['upic_cols'];
if ( empty( $rows ) )
$rows = $_CONF['upic_rows'];
// this bit probably wants to be drawn into a function eventually
// it does the pagination. Note it relies on the query string
// variable "paginate" being used universally by all callers
$limit = $cols * $rows;
if ( ! empty( $limit ) ) {
// first set out lower and upper limits for the SQL query
$limlo = $paginate * $limit;
$limhi = $paginate * $limit + $limit;
// here is where we have to manipulate the query string
// parse out the query string by & and then =
// to get all variables that are found within
$qarr = split( "&", $QUERY_STRING );
while ( list( $key, $value ) = each( $qarr ) ) {
list( $qvar, $qval ) = split( "=", $value );
$qnew[$qvar] = $qval;
}
// if the pageinate variable was not specified (e.g. first page)
// then we have to set it.
if ( empty( $qnew['paginate'] ) )
$qnew['paginate'] = 0;
// now reassemble 2 new query strings, one for 'next' and 'prev'
$qnext = "";
$qprev = "";
while ( list( $key, $value ) = each( $qnew ) ) {
if ( ! empty( $qnext ) )
$qnext .= "&";
if ( $key == "paginate" )
$qnext .= $key . "=" . ($value + 1);
else
$qnext .= $key . "=" . $value;
if ( ! empty( $qprev ) )
$qprev .= "&";
if ( $key == "paginate" )
$qprev .= $key . "=" . ($value - 1);
else
$qprev .= $key . "=" . $value;
}
$sql .= " LIMIT " . $limlo . ", " . $limit;
$pageit .= ""
. "<tr>"
. "<td colspan=$cols align=center>"
. "<table align=center width=100% border=0 cellpadding=0 cellspacing=0>"
. "<tr>"
. "<td width=30% align=left>"
. "";
if ( ! empty( $paginate ) )
$pageit .= "<a href='" . $PHP_SELF . "?" . $qprev . "'>prev</a>";
$pageit .= ""
. "</td>"
. "<td width=40% align=right> "
. "</td>"
. "<td width=30% align=right>"
. "<a href='" . $PHP_SELF . "?" . $qnext . "'>next</a>"
. "</td>"
. "</td>"
. "</tr>"
. "</table>"
. "</td>"
. "</tr>";
// once we drop out here, the $pageit variable can be used to display
// the paging information. Note below it's included in the top and
// bottom of the table
}
// try to execute the passed in query
if ( ! $result = DB_query( $sql ) ) {
$retr = $LANG_UPAGE['err_db_generic'];
return $retr;
}
// woogy!
$retr = ""
. "<!-- woogy -->"
. "<table width=100% align=center border=0>"
. $pageit
. "";
// we have to count which column we are in
$myCol = 1;
// column width depends on number of columns
$cwid = floor(100/$cols);
// loop through each record of the result, keeping track
// of what column and row we are in, as well as calling
// the passed in function for each record
while ( $ROW = DB_fetchArray( $result ) ) {
switch ( $myCol ) {
case 1 :
$retr .= "<tr>";
break;
case $cols+1 :
$retr .= "</tr>";
// column width depends on number of columns
$cwid = floor(100/$cols);
// loop through each record of the result, keeping track
// of what column and row we are in, as well as calling
// the passed in function for each record
while ( $ROW = DB_fetchArray( $result ) ) {
switch ( $myCol ) {
case 1 :
$retr .= "<tr>";
break;
case $cols+1 :
$retr .= "</tr>";
$myCol = 1;
break;
}
$retr .= "<td width=" . $cwid . "% valign=top align=center>";
if ( function_exists( $func ) )
$retr .= $func( $ROW );
else
$retr .= $LANG_UPAGE['err_no_func'];
$retr .= "</td>";
$myCol++;
}
// if we didn't end up in the last column because of an odd
// number of entries, then we have to finish off the row
if ( $myCol <= $cols )
{
while ( $myCol++ <= $cols )
$retr .= "<td width=" . $cwid . "% valign=top align=center> </td>";
$retr .= "</tr>";
}
$retr .= $pageit
. "</table>";
return $retr;
}
15
8
Quote
duvide
Anonymous
I am just wondering where to download the upage plugin, I am not able to find it anywhere.
Thank you/Frank
Thank you/Frank
13
17
Quote
Status: offline
newblogger
Forum User
Regular Poster
Registered: 08/22/04
Posts: 107
Location:Virginia Beach
i'm looking for it also
Got Hot wheels? http://www.dcmotoring.com
Got Hot wheels? http://www.dcmotoring.com
13
11
Quote
Status: offline
newblogger
Forum User
Regular Poster
Registered: 08/22/04
Posts: 107
Location:Virginia Beach
here you go buddy just got done downloading the tarball
you can get it here
have fun
Got Hot wheels? http://www.dcmotoring.com
you can get it here
have fun
Got Hot wheels? http://www.dcmotoring.com
18
10
Quote
duvide
Anonymous
thank you, I managed do download although the link should be like this: https://secure.neap.net/download/upage.tar.Z
Frank
Frank
15
13
Quote
All times are EST. The time is now 01:53 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content