Author |
Message |
floppydrivez
Involved


Joined: Feb 26, 2006
Posts: 340
Location: Jackson, Mississippi
|
Posted:
Tue Jun 09, 2009 2:08 am |
|
So I am using a pagination class from http://www.bradyvercher.com/php-pagination-class.html and it works fine. However, I believe because the urls are formed in the class it will not let me tap it.
Examples
http://www.clanthemes.com/club-members-cat-33.html
http://www.clanthemes.com/modules.php?name=Club&op=members&cid=33&page=2
Any thoughts on how I could make this work? Here is the class, slightly modified to accept css styles for the links.
Code:<?php
class PaginateIt {
/*
PaginateIt - A PHP Pagination Class
===================================
Author: Brady Vercher
Version: 1.1.1
URL: http://www.bradyvercher.com/
Copyright And License Information
=================================
Copyright (c) 2005 Brady Vercher
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var $currentPage, $itemCount, $itemsPerPage, $linksHref, $linksToDisplay;
var $pageJumpBack, $pageJumpNext, $pageSeparator;
var $queryString, $queryStringVar, $setclass, $setactiveclass;
function SetCurrentPage($reqCurrentPage){
$this->currentPage = (integer) abs($reqCurrentPage);
}
function SetItemCount($reqItemCount){
$this->itemCount = (integer) abs($reqItemCount);
}
function SetItemsPerPage($reqItemsPerPage){
$this->itemsPerPage = (integer) abs($reqItemsPerPage);
}
function SetLinksHref($reqLinksHref){
$this->linksHref = $reqLinksHref;
}
function SetLinksFormat($reqPageJumpBack, $reqPageSeparator, $reqPageJumpNext){
$this->pageJumpBack = $reqPageJumpBack;
$this->pageSeparator = $reqPageSeparator;
$this->pageJumpNext = $reqPageJumpNext;
}
function SetLinksToDisplay($reqLinksToDisplay){
$this->linksToDisplay = (integer) abs($reqLinksToDisplay);
}
function SetQueryStringVar($reqQueryStringVar){
$this->queryStringVar = $reqQueryStringVar;
}
function SetQueryString($reqQueryString){
$this->queryString = $reqQueryString;
}
function GetCurrentCollection($reqCollection){
if($this->currentPage < 1){
$start = 0;
}
elseif($this->currentPage > $this->GetPageCount()){
$start = $this->GetPageCount() * $this->itemsPerPage - $this->itemsPerPage;
}
else {
$start = $this->currentPage * $this->itemsPerPage - $this->itemsPerPage;
}
return array_slice($reqCollection, $start, $this->itemsPerPage);
}
function SetClass($setclass){
$this->Class = $setclass;
}
function SetActiveClass($setactiveclass){
$this->ActiveClass = $setactiveclass;
}
function GetPageCount(){
return (integer)ceil($this->itemCount/$this->itemsPerPage);
}
function GetPageLinks(){
$strLinks = '';
$pageCount = $this->GetPageCount();
$queryString = $this->GetQueryString();
$linksPad = floor($this->linksToDisplay/2);
if($this->linksToDisplay == -1){
$this->linksToDisplay = $pageCount;
}
if($pageCount == 0){
$strLinks = '1';
}
elseif($this->currentPage - 1 <= $linksPad || ($pageCount - $this->linksToDisplay + 1 == 0) || $this->linksToDisplay > $pageCount){
$start = 1;
}
elseif($pageCount - $this->currentPage <= $linksPad){
$start = $pageCount - $this->linksToDisplay + 1;
}
else {
$start = $this->currentPage - $linksPad;
}
if(isset($start)){
if($start > 1){
if(!empty($this->pageJumpBack)){
$pageNum = $start - $this->linksToDisplay + $linksPad;
if($pageNum < 1){
$pageNum = 1;
}
$strLinks .= '<a href="'.$this->linksHref.$queryString.$pageNum.'" class="'.$this->Class.'">';
$strLinks .= $this->pageJumpBack.'</a>'.$this->pageSeparator;
}
$strLinks .= '<a href="'.$this->linksHref.$queryString.'1" class="'.$this->Class.'">1...</a>'.$this->pageSeparator;
}
if($start + $this->linksToDisplay > $pageCount){
$end = $pageCount;
}
else {
$end = $start + $this->linksToDisplay - 1;
}
for($i = $start; $i <= $end; $i ++){
if($i != $this->currentPage){
$strLinks .= '<a href="'.$this->linksHref.$queryString.($i).'" class="'.$this->Class.'">';
$strLinks .= ($i).'</a>'.$this->pageSeparator;
}
else {
$strLinks .= '<a href="#" class="'.$this->ActiveClass.'">'.$i.'</a>'.$this->pageSeparator;
}
}
$strLinks = substr($strLinks, 0, -strlen($this->pageSeparator));
if($start + $this->linksToDisplay - 1 < $pageCount){
$strLinks .= $this->pageSeparator.'<a href="'.$this->linksHref.$queryString.$pageCount.'" class="'.$this->Class.'">';
$strLinks .= '...'.$pageCount.'</a>'.$this->pageSeparator;
if(!empty($this->pageJumpNext)){
$pageNum = $start + $this->linksToDisplay + $linksPad;
if($pageNum > $pageCount){
$pageNum = $pageCount;
}
$strLinks .= '<a href="'.$this->linksHref.$queryString.$pageNum.'" class="'.$this->Class.'">';
$strLinks .= $this->pageJumpNext.'</a>';
}
}
}
return $strLinks;
}
function GetQueryString(){
$pattern = array('/'.$this->queryStringVar.'=[^&]*&?/', '/&$/');
$replace = array('', '');
$queryString = preg_replace($pattern, $replace, $this->queryString);
$queryString = str_replace('&', '&', $queryString);
if(!empty($queryString)){
$queryString.= '&';
}
return '?'.$queryString.$this->queryStringVar.'=';
}
function GetSqlLimit(){
return ' LIMIT '.($this->currentPage * $this->itemsPerPage - $this->itemsPerPage).', '.$this->itemsPerPage;
}
function PaginateIt(){
$this->SetCurrentPage(1);
$this->SetItemsPerPage(10);
$this->SetItemCount(0);
$this->SetLinksFormat('« Back',' ','Next »');
$this->SetLinksHref($_SERVER['PHP_SELF']);
$this->SetLinksToDisplay(20);
$this->SetQueryStringVar('page');
$this->SetQueryString($_SERVER['QUERY_STRING']);
$this->SetClass('paginate');
$this->SetActiveClass('activepage');
if(isset($_GET[$this->queryStringVar]) && is_numeric($_GET[$this->queryStringVar])){
$this->SetCurrentPage($_GET[$this->queryStringVar]);
}
}
}
$PaginateIt = new PaginateIt();
?>
|
|
_________________ Only registered users can see links on this board! Get registered or login!, Only registered users can see links on this board! Get registered or login!, Only registered users can see links on this board! Get registered or login! |
|
|
 |
montego
Site Admin

Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Wed Jun 10, 2009 6:26 pm |
|
ShortLinks shortens the links AFTER the page is completely built, so I don't understand why they would not be tapped. How is this class included/instantiated? Also, are all your other links still tapped?
Where are you placing the taps? Can you give us an example of one?
Yes, many questions.  |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
 |
floppydrivez

|
Posted:
Wed Jun 10, 2009 6:31 pm |
|
montego wrote: | ShortLinks shortens the links AFTER the page is completely built, so I don't understand why they would not be tapped. How is this class included/instantiated? Also, are all your other links still tapped?
Where are you placing the taps? Can you give us an example of one?
Yes, many questions. |
First yes, all other links tapped. I did manage to get it to work, but only by editing the class. Rigged so to speak.
Code:$PaginateIt = new PaginateIt();
$PaginateIt->SetItemCount($numfiles);
$PaginateIt->SetItemsPerPage(6);
|
Code:$content .= $PaginateIt->GetPageLinks();
|
If you notice in the class it builds the links, then displays them with the above.
The full class is in my first post.
Code: function GetPageLinks(){
$strLinks = '';
$pageCount = $this->GetPageCount();
$queryString = $this->GetQueryString();
$linksPad = floor($this->linksToDisplay/2);
if($this->linksToDisplay == -1){
$this->linksToDisplay = $pageCount;
}
if($pageCount == 0){
$strLinks = '1';
}
elseif($this->currentPage - 1 <= $linksPad || ($pageCount - $this->linksToDisplay + 1 == 0) || $this->linksToDisplay > $pageCount){
$start = 1;
}
elseif($pageCount - $this->currentPage <= $linksPad){
$start = $pageCount - $this->linksToDisplay + 1;
}
else {
$start = $this->currentPage - $linksPad;
}
if(isset($start)){
if($start > 1){
if(!empty($this->pageJumpBack)){
$pageNum = $start - $this->linksToDisplay + $linksPad;
if($pageNum < 1){
$pageNum = 1;
}
$strLinks .= '<a href="'.$this->linksHref.$queryString.$pageNum.'" class="'.$this->Class.'">';
$strLinks .= $this->pageJumpBack.'</a>'.$this->pageSeparator;
}
$strLinks .= '<a href="'.$this->linksHref.$queryString.'1" class="'.$this->Class.'">1...</a>'.$this->pageSeparator;
}
if($start + $this->linksToDisplay > $pageCount){
$end = $pageCount;
}
else {
$end = $start + $this->linksToDisplay - 1;
}
for($i = $start; $i <= $end; $i ++){
if($i != $this->currentPage){
$strLinks .= '<a href="'.$this->linksHref.$queryString.($i).'" class="'.$this->Class.'">';
$strLinks .= ($i).'</a>'.$this->pageSeparator;
}
else {
$strLinks .= '<a href="#" class="'.$this->ActiveClass.'">'.$i.'</a>'.$this->pageSeparator;
}
}
$strLinks = substr($strLinks, 0, -strlen($this->pageSeparator));
if($start + $this->linksToDisplay - 1 < $pageCount){
$strLinks .= $this->pageSeparator.'<a href="'.$this->linksHref.$queryString.$pageCount.'" class="'.$this->Class.'">';
$strLinks .= '...'.$pageCount.'</a>'.$this->pageSeparator;
if(!empty($this->pageJumpNext)){
$pageNum = $start + $this->linksToDisplay + $linksPad;
if($pageNum > $pageCount){
$pageNum = $pageCount;
}
$strLinks .= '<a href="'.$this->linksHref.$queryString.$pageNum.'" class="'.$this->Class.'">';
$strLinks .= $this->pageJumpNext.'</a>';
}
}
}
return $strLinks;
}
function GetQueryString(){
$pattern = array('/'.$this->queryStringVar.'=[^&]*&?/', '/&$/');
$replace = array('', '');
$queryString = preg_replace($pattern, $replace, $this->queryString);
$queryString = str_replace('&', '&', $queryString);
if(!empty($queryString)){
$queryString.= '&';
}
return '?'.$queryString.$this->queryStringVar.'=';
}
|
.htaccess
Code:#Club
RewriteRule ^club-download-file-([0-9]*)-([a-zA-Z0-9_-]*).html modules.php?name=Club&op=download&fid=$1&title=$2 [L]
RewriteRule ^club-members-cat-([0-9]*).html modules.php?name=Club&op=members&cid=$1 [L]
RewriteRule ^club-members-cat-([0-9]*)-page-([0-9]*).html modules.php?name=Club&op=members&cid=$1&page=$2 [L]
RewriteRule ^club-members-cat-([0-9]*).html modules.php?name=Club&op=members&cid=$1 [L]
RewriteRule ^club-get-file-([0-9]*).html modules.php?name=Club&op=get&fid=$1 [L]
RewriteRule ^club-gfx-file-([0-9]*).html modules.php?name=Club&op=gfx&fid=$1 [L]
RewriteRule ^club-gfx-download-1.html modules.php?name=Club&op=gfx&download=1 [L]
RewriteRule ^club-subscribe.html modules.php?name=Club&op=subscribe [L]
RewriteRule ^club-search.html modules.php?name=Club&op=search [L]
RewriteRule ^club-members.html modules.php?name=Club&op=members [L]
RewriteRule ^club-paypal-return.html modules.php?name=Club&op=paypal_return [L]
RewriteRule ^club-top-100-files.html modules.php?name=Club&op=top100 [L]
RewriteRule ^club.html modules.php?name=Club [L]
|
GT-Club.php
Code:$urlin = array(
"'(?<!/)modules.php\?name=Club&op=download&fid=([0-9]*)&title=([a-zA-Z0-9_-]*)'",
"'(?<!/)modules.php\?name=Club&op=members&cid=([0-9]*)&title=([a-zA-Z0-9_-]*)'",
"'(?<!/)modules.php\?name=Club&op=members&cid=([0-9]*)&page=([0-9]*)'",
"'(?<!/)modules.php\?name=Club&op=members&cid=([0-9]*)'",
"'(?<!/)modules.php\?name=Club&op=get&fid=([0-9]*)'",
"'(?<!/)modules.php\?name=Club&op=gfx&fid=([0-9]*)'",
"'(?<!/)modules.php\?name=Club&op=gfx&download=1'",
"'(?<!/)modules.php\?name=Club&op=subscribe'",
"'(?<!/)modules.php\?name=Club&op=search'",
"'(?<!/)modules.php\?name=Club&op=members'",
"'(?<!/)modules.php\?name=Club&op=paypal_return'",
"'(?<!/)modules.php\?name=Club&op=top100'",
"'(?<!/)modules.php\?name=Club'"
);
$urlout = array(
"club-download-file-\\1-\\2.html",
"club-members-cat-\\1-\\2.html",
"club-members-cat-\\1-page-\\2.html",
"club-members-cat-\\1.html",
"club-get-file-\\1.html",
"club-gfx-file-\\1.html",
"club-gfx-download-1.html",
"club-subscribe.html",
"club-search.html",
"club-members.html",
"club-paypal-return.html",
"club-top-100-files.html",
"club.html"
);
|
|
|
|
|
 |
sexycoder
Spammer and overall low life

Joined: Feb 02, 2009
Posts: 82
|
Posted:
Wed Jun 10, 2009 7:20 pm |
|
Hi floppydrivez
Congratulations for the nice mod u made on Club Membership module. Can u share that module to use it on RavenNuke or u have it on the limit download? I dont know but I guess u use part of NSN Download modules. I like the module. |
|
|
|
 |
montego

|
Posted:
Wed Jun 10, 2009 7:28 pm |
|
floppydrivez, how is this class file being included. Actually, that is really "where is it included"? |
|
|
|
 |
floppydrivez

|
Posted:
Wed Jun 10, 2009 7:29 pm |
|
Oh sorry bud, its included in the index using require_once.
Code:<?php
if (!defined('MODULE_FILE')) {
die ("You can't access this file directly...");
}
require_once("mainfile.php");
require_once('classes/PaginateIt.php');
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
|
|
|
|
|
 |
floppydrivez

|
Posted:
Wed Jun 10, 2009 7:32 pm |
|
sexycoder wrote: | Hi floppydrivez
Congratulations for the nice mod u made on Club Membership module. Can u share that module to use it on RavenNuke or u have it on the limit download? I dont know but I guess u use part of NSN Download modules. I like the module. |
Its a very custom copy of http://phpnuke.org/modules.php?name=Club&op=members&cid=28
Thanks for the compliment. |
|
|
|
 |
sexycoder

|
Posted:
Wed Jun 10, 2009 7:38 pm |
|
Do you think of release it or just keep it? I would like to test it on Raven Nuke. I dont like the original from FB. |
|
|
|
 |
floppydrivez

|
Posted:
Wed Jun 10, 2009 7:40 pm |
|
Its on Raven Nuke now, no need to test it. However, I have no plans of releasing it. You can just code your own to suite your needs as I have. |
|
|
|
 |
montego

|
Posted:
Sat Jun 13, 2009 8:40 am |
|
floppydrivez, I see. That is explains it then as it is included prior to header.php. There must still be more code somewhere to make this all work, but since you have it working for you now with your "tweaks", I guess enough said. Well done. |
|
|
|
 |
floppydrivez

|
Posted:
Thu Jun 18, 2009 9:29 pm |
|
montego wrote: | floppydrivez, I see. That is explains it then as it is included prior to header.php. There must still be more code somewhere to make this all work, but since you have it working for you now with your "tweaks", I guess enough said. Well done. |
Sigh, I am such a noob. I will fix it. Thank you sir. |
|
|
|
 |
floppydrivez

|
Posted:
Thu Jun 18, 2009 10:27 pm |
|
Wow, we were both making this harder than it had to be. So I suggest you guys look into using this paging class for raven nuke. I am very impressed. It has tons of options I haven't needed yet.
The problem I believe was this default value.
Code:$this->SetLinksHref($_SERVER['PHP_SELF']);
|
Which returned /modules.php. So integration like this
Code:include('header.php');
require_once('classes/PaginateIt.php');
|
Code:$PaginateIt = new PaginateIt();
$PaginateIt->SetLinksHref('modules.php');//We changed this to make it work
$PaginateIt->SetItemCount($numfiles);//This is the total # of items we want to paginate
$PaginateIt->SetItemsPerPage(6);//Per page
|
Code://Have to tag the end of the query for per page
$result = $db->sql_query("SELECT fid, title, fileimage, md5, description, hits, size, cpoints FROM ".$prefix."_club_files WHERE cid='$cid' ORDER BY title ASC ".$PaginateIt->GetSqlLimit()."");
|
Code://This displays the page numbers and urls
echo $PaginateIt->GetPageLinks();
|
This is good cause we can use it in some other places on the site now. Thanks for your help montego. |
|
|
|
 |
|