Changeset 1529
- Timestamp:
- 05/23/08 06:27:24 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
coldbox/trunk/CodeDepot/plugins/com/ortussolutions/ui/paging.cfc
r1506 r1529 55 55 setpluginVersion("1.0"); 56 56 setpluginDescription("Paging plugin"); 57 //My own Constructor code here 57 58 /* Paging properties */ 59 setPagingMaxRows( getSetting("PagingMaxRows") ); 60 setPagingBandGap( getSetting('PagingBandGap') ); 58 61 59 62 //Return instance … … 64 67 <!------------------------------------------- PUBLIC -------------------------------------------> 65 68 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 66 87 <!--- Get boundaries ---> 67 88 <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."> 69 90 <cfscript> 70 91 var boundaries = structnew(); 92 var event = getController().getRequestService().getContext(); 93 var maxRows = getPagingMaxRows(); 71 94 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; 74 102 75 103 return boundaries; … … 82 110 <cfargument name="FoundRows" required="true" type="numeric" hint="The found rows to page"> 83 111 <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."> 84 113 <!--- ***************************************************************** ---> 85 114 <cfset var event = getController().getRequestService().getContext()> 86 115 <cfset var pagingTabs = ""> 87 <cfset var maxRows = get Setting('PagingMaxRows')>88 <cfset var bandGap = get Setting('PagingBandGap')>116 <cfset var maxRows = getPagingMaxRows()> 117 <cfset var bandGap = getPagingBandGap()> 89 118 <cfset var totalPages = 0> 90 119 <cfset var theLink = arguments.link> 91 120 <!--- Paging vars ---> 92 <cfset var currentPage = event.getValue("page" )>121 <cfset var currentPage = event.getValue("page",1)> 93 122 <cfset var pageFrom = 0> 94 123 <cfset var pageTo = 0> 124 125 <!--- Override ---> 126 <cfif structKeyExists(arguments, "pagingMaxRows")> 127 <cfset maxRows = arguments.pagingMaxRows> 128 </cfif> 95 129 96 130 <!--- Only page if records found --->
