home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2002 December / INTERNET97.ISO / pc / software / windows / building / scriptworx / n4932.exe / cfnav.slf < prev    next >
Encoding:
Text File  |  2001-03-23  |  3.9 KB  |  127 lines

  1. <cfset Recordset_NumRows = 0>
  2. <cfset Recordset_Index = 1>
  3. <cfscript>
  4.  
  5. Recordset_total = Recordset1.RecordCount;
  6.  
  7. If (Recordset_NumRows LT 0  OR  Recordset_NumRows GTE Recordset_total) {
  8.   Recordset_NumRows = Recordset_total;
  9. } Else If (Recordset_NumRows EQ 0) {
  10.   Recordset_NumRows = 1;
  11. }
  12.  
  13. Recordset_first = Min(1, Recordset_total);
  14. Recordset_last  = Min(Recordset_NumRows, Recordset_total);
  15. </cfscript>
  16. <cfscript> DTBA_paramName = "";
  17. </cfscript>
  18. <cfscript>
  19.  
  20. DTBA_rs        = Recordset1;
  21. DTBA_rsCount   = Recordset_total;
  22. DTBA_size      = Recordset_NumRows;
  23. DTBA_uniqueCol = "";
  24. DTBA_paramName = "";
  25. DTBA_offset = 1;
  26. DTBA_atTotal = false;
  27. DTBA_paramIsDefined = false;
  28. If (DTBA_paramName NEQ "") DTBA_paramIsDefined = IsDefined(DTBA_paramName);
  29. </cfscript>
  30. <cfscript>
  31.  
  32. If (NOT DTBA_paramIsDefined AND DTBA_rsCount NEQ 0) {
  33.  
  34.   // use index parameter if defined, otherwise use offset parameter
  35.   If (IsDefined("index")) {
  36.     DTBA_offset = index;
  37.   } Else If (IsDefined("offset")) {
  38.     DTBA_offset = offset;
  39.   }
  40.  
  41.   // check if we are past the end of the recordset
  42.   If (DTBA_offset GT DTBA_rsCount OR DTBA_offset EQ 0) {       // past end or move last
  43.     If ((DTBA_rsCount MOD DTBA_size) NEQ 0) {    // last page not a full repeat region
  44.       DTBA_offset = DTBA_rsCount - (DTBA_rsCount MOD DTBA_size) + 1;
  45.     } Else {
  46.       DTBA_offset = DTBA_rsCount - DTBA_size + 1;
  47.     }
  48.   }
  49. }
  50. </cfscript>
  51. <cfscript>
  52.  
  53. If (DTBA_size EQ 1) {
  54.  
  55.   // create a new query with one row
  56.   DTBA_newQuery = QueryNew(DTBA_rs.ColumnList);
  57.   QueryAddRow(DTBA_newQuery, 1);
  58.  
  59.   DTBA_columns = ListToArray(DTBA_rs.ColumnList,",");
  60.   For (i=1; i LTE ArrayLen(DTBA_columns); i=i+1) {
  61.     QuerySetCell(DTBA_newQuery, DTBA_columns[i], DTBA_rs[DTBA_columns[i]][DTBA_offset], 1);
  62.   }
  63.  
  64.   Recordset1 = DTBA_newQuery;
  65. }
  66. </cfscript>
  67. <cfscript>
  68.  
  69. Recordset_first = Min(DTBA_offset, DTBA_rsCount);
  70. Recordset_last  = Min(DTBA_offset + DTBA_size - 1, DTBA_rsCount);
  71.  
  72. Recordset_Index = DTBA_offset;
  73.  
  74. DTBA_atTotal = (DTBA_offset + DTBA_size - 1 GTE DTBA_rsCount);
  75. </cfscript>
  76. <cfscript>
  77.  
  78. DTBA_removeList = "&index=";
  79. If (DTBA_paramName NEQ "") DTBA_removeList = DTBA_removeList & "&" & DTBA_paramName & "=";
  80. DTBA_keepURL=""; DTBA_keepForm=""; DTBA_keepBoth=""; DTBA_keepNone="";
  81.  
  82. DTBA_params=ListToArray(CGI.QUERY_STRING,"&");
  83. For (i=1; i LTE ArrayLen(DTBA_params); i=i+1) {
  84.   If (FindNoCase("&" & GetToken(DTBA_params[i],1,"=") & "=",DTBA_removeList) Is 0)
  85.     DTBA_keepURL = DTBA_keepURL & "&" & DTBA_params[i];
  86. }
  87.  
  88. If (IsDefined("FORM.FieldNames")) {
  89.   DTBA_params=ListToArray(FORM.FieldNames,",");
  90.   For (i=1; i LTE ArrayLen(DTBA_params); i=i+1) {
  91.     If (FindNoCase("&" & DTBA_params[i] & "=",DTBA_removeList) Is 0)
  92.       DTBA_keepForm = DTBA_keepForm & "&" & LCase(DTBA_params[i]) & "=" & URLEncodedFormat(Evaluate("FORM." & DTBA_params[i]));
  93.   }
  94. }
  95.  
  96. DTBA_keepBoth = DTBA_keepURL & DTBA_keepForm;
  97. If (DTBA_keepURL NEQ "") DTBA_keepURL = RemoveChars(DTBA_keepURL,1,1);
  98. If (DTBA_keepForm NEQ "") DTBA_keepForm = RemoveChars(DTBA_keepForm,1,1);
  99. If (DTBA_keepBoth NEQ "") DTBA_keepBoth = RemoveChars(DTBA_keepBoth,1,1);
  100. </cfscript>
  101. <cfscript>
  102.  
  103. DTBA_keepMove = DTBA_keepBoth;
  104. DTBA_moveParam = "index";
  105.  
  106. if (DTBA_size GT 1) {
  107.   DTBA_moveParam = "offset";
  108.   DTBA_params = ListToArray(DTBA_keepMove,"&");
  109.   DTBA_keepMove = "";
  110.   For (i=1; i LTE ArrayLen(DTBA_params); i=i+1) {
  111.     If (CompareNoCase(GetToken(DTBA_params[i],1,"="),DTBA_moveParam) IS NOT 0) {
  112.       DTBA_keepMove = DTBA_keepMove & "&" & DTBA_params[i];
  113.     }
  114.   }
  115.   If (DTBA_keepMove NEQ "") {
  116.     DTBA_keepMove = RemoveChars(DTBA_keepMove,1,1);
  117.   }
  118. }
  119.  
  120. if (DTBA_keepMove NEQ "") DTBA_keepMove = DTBA_keepMove & "&";
  121. urlStr = CGI.SCRIPT_NAME & "?" & DTBA_keepMove & DTBA_moveParam & "=";
  122. DTBA_moveFirst = urlStr & "1";
  123. DTBA_moveLast  = urlStr & "0";
  124. DTBA_moveNext  = urlStr & (DTBA_offset + DTBA_size);
  125. DTBA_movePrev  = urlStr & Max(DTBA_offset-DTBA_size,1);
  126. </cfscript>
  127.