PHP Web Host - Quality Web Hosting For All PHP Applications Clan Themes! We make clans look good!!
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
floppydrivez
Involved
Involved


Joined: Feb 26, 2006
Posts: 337
Location: Jackson, Mississippi

PostPosted: Tue Jun 09, 2009 2:08 am Reply with quote Back to top

So I am using a pagination class from
Only registered users can see links on this board!
Get registered or login to the forums!
and it works fine. However, I believe because the urls are formed in the class it will not let me tap it.

Examples
Only registered users can see links on this board!
Get registered or login to the forums!

Only registered users can see links on this board!
Get registered or login to the forums!


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('&', '&amp;', $queryString);
       
        if(!empty($queryString)){
            $queryString.= '&amp;';
        }

        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('&laquo; Back','&nbsp;&nbsp;','Next &raquo;');
        $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();
?>
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9136
Location: Arizona

PostPosted: Wed Jun 10, 2009 6:26 pm Reply with quote Back to top

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. Wink
View user's profile Send private message Visit poster's website
floppydrivez
Involved
Involved


Joined: Feb 26, 2006
Posts: 337
Location: Jackson, Mississippi

PostPosted: Wed Jun 10, 2009 6:31 pm Reply with quote Back to top

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. Wink


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('&', '&amp;', $queryString);
       
        if(!empty($queryString)){
            $queryString.= '&amp;';
        }

        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&amp;op=download&amp;fid=([0-9]*)&amp;title=([a-zA-Z0-9_-]*)'",
"'(?<!/)modules.php\?name=Club&amp;op=members&amp;cid=([0-9]*)&amp;title=([a-zA-Z0-9_-]*)'",
"'(?<!/)modules.php\?name=Club&amp;op=members&amp;cid=([0-9]*)&amp;page=([0-9]*)'",
"'(?<!/)modules.php\?name=Club&amp;op=members&amp;cid=([0-9]*)'",
"'(?<!/)modules.php\?name=Club&amp;op=get&amp;fid=([0-9]*)'",
"'(?<!/)modules.php\?name=Club&amp;op=gfx&amp;fid=([0-9]*)'",
"'(?<!/)modules.php\?name=Club&amp;op=gfx&amp;download=1'",
"'(?<!/)modules.php\?name=Club&amp;op=subscribe'",
"'(?<!/)modules.php\?name=Club&amp;op=search'",
"'(?<!/)modules.php\?name=Club&amp;op=members'",
"'(?<!/)modules.php\?name=Club&amp;op=paypal_return'",
"'(?<!/)modules.php\?name=Club&amp;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"
);
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
sexycoder
Spammer and overall low life


Joined: Feb 02, 2009
Posts: 82

PostPosted: Wed Jun 10, 2009 7:20 pm Reply with quote Back to top

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.
View user's profile Send private message
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9136
Location: Arizona

PostPosted: Wed Jun 10, 2009 7:28 pm Reply with quote Back to top

floppydrivez, how is this class file being included. Actually, that is really "where is it included"?
View user's profile Send private message Visit poster's website
floppydrivez
Involved
Involved


Joined: Feb 26, 2006
Posts: 337
Location: Jackson, Mississippi

PostPosted: Wed Jun 10, 2009 7:29 pm Reply with quote Back to top

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);
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
floppydrivez
Involved
Involved


Joined: Feb 26, 2006
Posts: 337
Location: Jackson, Mississippi

PostPosted: Wed Jun 10, 2009 7:32 pm Reply with quote Back to top

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
Only registered users can see links on this board!
Get registered or login to the forums!


Thanks for the compliment.
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
sexycoder
Spammer and overall low life


Joined: Feb 02, 2009
Posts: 82

PostPosted: Wed Jun 10, 2009 7:38 pm Reply with quote Back to top

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.
View user's profile Send private message
floppydrivez
Involved
Involved


Joined: Feb 26, 2006
Posts: 337
Location: Jackson, Mississippi

PostPosted: Wed Jun 10, 2009 7:40 pm Reply with quote Back to top

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.
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9136
Location: Arizona

PostPosted: Sat Jun 13, 2009 8:40 am Reply with quote Back to top

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.
View user's profile Send private message Visit poster's website
floppydrivez
Involved
Involved


Joined: Feb 26, 2006
Posts: 337
Location: Jackson, Mississippi

PostPosted: Thu Jun 18, 2009 9:29 pm Reply with quote Back to top

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.
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
floppydrivez
Involved
Involved


Joined: Feb 26, 2006
Posts: 337
Location: Jackson, Mississippi

PostPosted: Thu Jun 18, 2009 10:27 pm Reply with quote Back to top

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.
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum