include-recherche-pagination.xslt 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl cd67" xmlns:cd67 ="http://my.functions" >
  4. <xsl:strip-space elements ="a"/>
  5. <xsl:template match="result" mode="pagination">
  6. <xsl:if test="$recordsPerPage &lt; $numberOfRecords">
  7. <xsl:if test="$pageNumber &gt; 1">
  8. <xsl:choose>
  9. <xsl:when test ="$query='*:*'">
  10. <a class="numeroPagination" href="?start={($pageNumber - 2) * $recordsPerPage}">
  11. &#9665; précédent"
  12. </a> |
  13. </xsl:when>
  14. <xsl:otherwise>
  15. <a class="numeroPagination" href="?term={$query}&amp;start={($pageNumber - 2) * $recordsPerPage}">
  16. &#9665; précédent
  17. </a> |
  18. </xsl:otherwise>
  19. </xsl:choose>
  20. </xsl:if>
  21. <xsl:call-template name="numerosPaginas">
  22. <xsl:with-param name="current" select="$pageNumber"/>
  23. <xsl:with-param name="max">
  24. <xsl:choose>
  25. <xsl:when test="(($pageNumber + $cantPages) &gt; $endPage) or ($endPage &lt;= 9)">
  26. <xsl:value-of select="$endPage" />
  27. </xsl:when>
  28. <xsl:otherwise>
  29. <xsl:value-of select="($pageNumber + $cantPages)" />
  30. </xsl:otherwise>
  31. </xsl:choose>
  32. </xsl:with-param>
  33. <xsl:with-param name="number">
  34. <xsl:choose>
  35. <xsl:when test="(($pageNumber - $cantPages) &lt; 1) or ($endPage &lt;= 9)">
  36. <xsl:value-of select="1" />
  37. </xsl:when>
  38. <xsl:otherwise>
  39. <xsl:value-of select="($pageNumber - $cantPages)" />
  40. </xsl:otherwise>
  41. </xsl:choose>
  42. </xsl:with-param>
  43. </xsl:call-template>
  44. <xsl:if test="(($pageNumber ) * $recordsPerPage) &lt; ($numberOfRecords)">
  45. <xsl:choose>
  46. <xsl:when test ="$query='*:*'">
  47. | <a href="?start={($pageNumber) * $recordsPerPage}">
  48. suivant &#9655;
  49. </a>
  50. </xsl:when>
  51. <xsl:otherwise>
  52. | <a href="?term={$query}&amp;start={($pageNumber) * $recordsPerPage}">
  53. suivant &#9655;
  54. </a>
  55. </xsl:otherwise>
  56. </xsl:choose>
  57. </xsl:if>
  58. (Nombre de resultats <xsl:value-of select="$numberOfRecords" />)
  59. </xsl:if>
  60. </xsl:template>
  61. <xsl:template name="numerosPaginas">
  62. <xsl:param name="current"/>
  63. <xsl:param name="number"/>
  64. <xsl:param name="max"/>
  65. <xsl:choose>
  66. <xsl:when test="$number = $current">
  67. <!-- la page courante n'est pas un lien -->
  68. <span class="currentPagination">
  69. <xsl:value-of select="$number"/>
  70. </span>
  71. </xsl:when>
  72. <xsl:otherwise>
  73. <xsl:choose>
  74. <xsl:when test ="$query='*:*'">
  75. <!--<a class="numeroPagination" href="?start={($number - 1) * $recordsPerPage}">-->
  76. <a class="numeroPagination">
  77. <xsl:attribute name="href">
  78. ?<xsl:value-of select="$paramrecherche" />=<xsl:value-of select="$recherche" /><xsl:value-of select="$extend" />&amp;start=<xsl:value-of select="(($number - 1) * $recordsPerPage)"/>&amp;rows=<xsl:value-of select="$recordsPerPage" /><xsl:apply-templates select="//descendant-or-self::str[@name='fq']|//descendant-or-self::arr[@name='fq']/str" mode="facet" />
  79. </xsl:attribute>
  80. <xsl:value-of select="$number"/>
  81. </a>
  82. </xsl:when>
  83. <xsl:otherwise>
  84. <!--<a class="numeroPagination" href="?q={$query}&amp;start={($number - 1) * $recordsPerPage}&amp;rows={$recordsPerPage}">
  85. <xsl:value-of select="$number"/>
  86. </a>-->
  87. <a class="numeroPagination">
  88. <xsl:attribute name="href">
  89. ?<xsl:value-of select="$paramrecherche" />=<xsl:value-of select="$recherche" /><xsl:value-of select="$extend" />&amp;start=<xsl:value-of select="(($number - 1) * $recordsPerPage)"/>&amp;rows=<xsl:value-of select="$recordsPerPage" /><xsl:apply-templates select="//descendant-or-self::str[@name='fq']|//descendant-or-self::arr[@name='fq']/str" mode="facet" />
  90. </xsl:attribute>
  91. <xsl:value-of select="$number"/>
  92. </a>
  93. </xsl:otherwise>
  94. </xsl:choose>
  95. </xsl:otherwise>
  96. </xsl:choose>
  97. <!-- Appel recursif jusqu'a nb max de page -->
  98. <xsl:if test="$number &lt; $max">
  99. <xsl:call-template name="numerosPaginas">
  100. <xsl:with-param name="current" select="$current"/>
  101. <xsl:with-param name="number" select="$number+1"/>
  102. <xsl:with-param name="max" select="$max"/>
  103. </xsl:call-template>
  104. </xsl:if>
  105. </xsl:template>
  106. <xsl:template name="paginateur">
  107. <xsl:if test="$recordsPerPage &lt; $numberOfRecords">
  108. <div class="pagination">
  109. <span>
  110. <xsl:if test="$pageNumber &gt; 1">
  111. <xsl:choose>
  112. <xsl:when test ="$query='*:*'">
  113. <a class="firstPagination" href="?start={($pageNumber - 2) * $recordsPerPage}">
  114. &#9665; précédent
  115. </a>
  116. </xsl:when>
  117. <xsl:otherwise>
  118. <a class="firstPagination" >
  119. <xsl:attribute name="href">?<xsl:value-of select="$paramrecherche" />=<xsl:value-of select="$recherche" /><xsl:value-of select="$extend" />&amp;start=<xsl:value-of select="($pageNumber - 2) * $recordsPerPage"/>&amp;rows=<xsl:value-of select="$recordsPerPage" /><xsl:apply-templates select="//descendant-or-self::str[@name='fq']|//descendant-or-self::arr[@name='fq']/str" mode="facet" />
  120. </xsl:attribute>
  121. &#9665; précédent
  122. </a>
  123. </xsl:otherwise>
  124. </xsl:choose>
  125. </xsl:if>
  126. <xsl:call-template name="numerosPaginas">
  127. <xsl:with-param name="current" select="$pageNumber"/>
  128. <xsl:with-param name="max">
  129. <xsl:choose>
  130. <xsl:when test="(($pageNumber + $cantPages) &gt; $endPage) or ($endPage &lt;= 9)">
  131. <xsl:value-of select="$endPage" />
  132. </xsl:when>
  133. <xsl:otherwise>
  134. <xsl:value-of select="($pageNumber + $cantPages)" />
  135. </xsl:otherwise>
  136. </xsl:choose>
  137. </xsl:with-param>
  138. <xsl:with-param name="number">
  139. <xsl:choose>
  140. <xsl:when test="(($pageNumber - $cantPages) &lt; 1) or ($endPage &lt;= 9)">
  141. <xsl:value-of select="1" />
  142. </xsl:when>
  143. <xsl:otherwise>
  144. <xsl:value-of select="($pageNumber - $cantPages)" />
  145. </xsl:otherwise>
  146. </xsl:choose>
  147. </xsl:with-param>
  148. </xsl:call-template>
  149. <xsl:if test="(($pageNumber ) * $recordsPerPage) &lt; ($numberOfRecords)">
  150. <xsl:choose>
  151. <xsl:when test ="$query='*:*'">
  152. <a class="lastPagination">
  153. <xsl:attribute name="href">
  154. ?<xsl:value-of select="$paramrecherche" />=<xsl:value-of select="$recherche" /><xsl:value-of select="$extend" />&amp;start=<xsl:value-of select="($pageNumber * $recordsPerPage)"/>&amp;rows=<xsl:value-of select="$recordsPerPage" /><xsl:apply-templates select="//descendant-or-self::str[@name='fq']|//descendant-or-self::arr[@name='fq']/str" mode="facet" />
  155. </xsl:attribute>
  156. suivant &#9655;
  157. </a>
  158. </xsl:when>
  159. <xsl:otherwise>
  160. <a class="lastPagination">
  161. <xsl:attribute name="href">
  162. ?<xsl:value-of select="$paramrecherche" />=<xsl:value-of select="$recherche" /><xsl:value-of select="$extend" />&amp;start=<xsl:value-of select="($pageNumber * $recordsPerPage)"/>&amp;rows=<xsl:value-of select="$recordsPerPage" /><xsl:apply-templates select="//descendant-or-self::str[@name='fq']|//descendant-or-self::arr[@name='fq']/str" mode="facet" />
  163. </xsl:attribute>
  164. suivant &#9655;
  165. </a>
  166. </xsl:otherwise>
  167. </xsl:choose>
  168. </xsl:if>
  169. </span>
  170. </div>
  171. </xsl:if>
  172. </xsl:template>
  173. </xsl:stylesheet>