Changeset 1529

Show
Ignore:
Timestamp:
05/23/08 06:27:24 (5 years ago)
Author:
lmajano
Message:

Update to paging plugin

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • coldbox/trunk/CodeDepot/plugins/com/ortussolutions/ui/paging.cfc

    r1506 r1529  
    5555                setpluginVersion("1.0"); 
    5656                setpluginDescription("Paging plugin"); 
    57                 //My own Constructor code here 
     57                 
     58                /* Paging properties */ 
     59                setPagingMaxRows( getSetting("PagingMaxRows") ); 
     60                setPagingBandGap( getSetting('PagingBandGap') ); 
    5861                 
    5962                //Return instance 
     
    6467<!------------------------------------------- PUBLIC ------------------------------------------->        
    6568         
     69        <!--- Get/Set paging max rows ---> 
     70        <cffunction name="getPagingMaxRows" access="public" returntype="numeric" hint="Get the paging max rows setting" output="false"> 
     71                <cfreturn instance.pagingMaxRows> 
     72        </cffunction> 
     73        <cffunction name="setPagingMaxRows" access="public" returntype="void" hint="Set the paging max rows setting" output="false"> 
     74                <cfargument name="pagingMaxRows" required="true" type="numeric"> 
     75                <cfset instance.pagingMaxRows = arguments.pagingMaxRows> 
     76        </cffunction> 
     77         
     78        <!--- Get/Set paging band gap ---> 
     79        <cffunction name="getPagingBandGap" access="public" returntype="numeric" hint="Get the paging carrousel band gap" output="false"> 
     80                <cfreturn instance.PagingBandGap> 
     81        </cffunction> 
     82        <cffunction name="setPagingMaxRows" access="public" returntype="void" hint="Set the paging max rows setting" output="false"> 
     83                <cfargument name="pagingMaxRows" required="true" type="numeric"> 
     84                <cfset instance.pagingMaxRows = arguments.pagingMaxRows> 
     85        </cffunction> 
     86         
    6687        <!--- Get boundaries ---> 
    6788        <cffunction name="getboundaries" access="public" returntype="struct" hint="Calculate the startrow and maxrow" output="false" > 
    68                 <cfargument name="page" required="true" type="numeric" hint="The page you are on."> 
     89                <cfargument name="PagingMaxRows" required="false" type="numeric" hint="You can override the paging max rows here."> 
    6990                <cfscript> 
    7091                        var boundaries = structnew(); 
     92                        var event = getController().getRequestService().getContext(); 
     93                        var maxRows = getPagingMaxRows(); 
    7194                         
    72                         boundaries.startrow = ((arguments.page * getSetting("PagingMaxRows")) - getSetting("PagingMaxRows"))+1; 
    73                         boundaries.maxrow = boundaries.startrow + getSetting("PagingMaxRows") - 1; 
     95                        /* Check for Override */ 
     96                        if( structKeyExists(arguments,"PagingMaxRows") ){ 
     97                                maxRows = arguments.pagingMaxRows; 
     98                        } 
     99                                                 
     100                        boundaries.startrow = ((event.getValue("page",1) * maxrows - maxRows)+1; 
     101                        boundaries.maxrow = boundaries.startrow + maxRows - 1; 
    74102                 
    75103                        return boundaries; 
     
    82110                <cfargument name="FoundRows"    required="true"  type="numeric" hint="The found rows to page"> 
    83111                <cfargument name="link"                 required="true"  type="string"  hint="The link to use, you must place the @page@ place holder so the link ca be created correctly"> 
     112                <cfargument name="PagingMaxRows" required="false" type="numeric" hint="You can override the paging max rows here."> 
    84113                <!--- ***************************************************************** ---> 
    85114                <cfset var event = getController().getRequestService().getContext()> 
    86115                <cfset var pagingTabs = ""> 
    87                 <cfset var maxRows = getSetting('PagingMaxRows')> 
    88                 <cfset var bandGap = getSetting('PagingBandGap')> 
     116                <cfset var maxRows = getPagingMaxRows()> 
     117                <cfset var bandGap = getPagingBandGap()> 
    89118                <cfset var totalPages = 0> 
    90119                <cfset var theLink = arguments.link> 
    91120                <!--- Paging vars ---> 
    92                 <cfset var currentPage = event.getValue("page")> 
     121                <cfset var currentPage = event.getValue("page",1)> 
    93122                <cfset var pageFrom = 0> 
    94123                <cfset var pageTo = 0> 
     124                 
     125                <!--- Override ---> 
     126                <cfif structKeyExists(arguments, "pagingMaxRows")> 
     127                        <cfset maxRows = arguments.pagingMaxRows> 
     128                </cfif> 
    95129                 
    96130                <!--- Only page if records found --->