PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/joomla/templates/protostar/html/pagination.php

https://gitlab.com/ricardosanchez/prueba
PHP | 229 lines | 102 code | 23 blank | 104 comment | 32 complexity | b5ac98878090b96be99b0bc193ad65aa MD5 | raw file
  1. <?php
  2. /**
  3. * @package Joomla.Site
  4. * @subpackage Templates.protostar
  5. *
  6. * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9. defined('_JEXEC') or die;
  10. /**
  11. * This is a file to add template specific chrome to pagination rendering.
  12. *
  13. * pagination_list_footer
  14. * Input variable $list is an array with offsets:
  15. * $list[limit] : int
  16. * $list[limitstart] : int
  17. * $list[total] : int
  18. * $list[limitfield] : string
  19. * $list[pagescounter] : string
  20. * $list[pageslinks] : string
  21. *
  22. * pagination_list_render
  23. * Input variable $list is an array with offsets:
  24. * $list[all]
  25. * [data] : string
  26. * [active] : boolean
  27. * $list[start]
  28. * [data] : string
  29. * [active] : boolean
  30. * $list[previous]
  31. * [data] : string
  32. * [active] : boolean
  33. * $list[next]
  34. * [data] : string
  35. * [active] : boolean
  36. * $list[end]
  37. * [data] : string
  38. * [active] : boolean
  39. * $list[pages]
  40. * [{PAGE}][data] : string
  41. * [{PAGE}][active] : boolean
  42. *
  43. * pagination_item_active
  44. * Input variable $item is an object with fields:
  45. * $item->base : integer
  46. * $item->link : string
  47. * $item->text : string
  48. *
  49. * pagination_item_inactive
  50. * Input variable $item is an object with fields:
  51. * $item->base : integer
  52. * $item->link : string
  53. * $item->text : string
  54. *
  55. * This gives template designers ultimate control over how pagination is rendered.
  56. *
  57. * NOTE: If you override pagination_item_active OR pagination_item_inactive you MUST override them both
  58. */
  59. /**
  60. * Renders the pagination footer
  61. *
  62. * @param array $list Array containing pagination footer
  63. *
  64. * @return string HTML markup for the full pagination footer
  65. *
  66. * @since 3.0
  67. */
  68. function pagination_list_footer($list)
  69. {
  70. $html = "<div class=\"pagination\">\n";
  71. $html .= $list['pageslinks'];
  72. $html .= "\n<input type=\"hidden\" name=\"" . $list['prefix'] . "limitstart\" value=\"" . $list['limitstart'] . "\" />";
  73. $html .= "\n</div>";
  74. return $html;
  75. }
  76. /**
  77. * Renders the pagination list
  78. *
  79. * @param array $list Array containing pagination information
  80. *
  81. * @return string HTML markup for the full pagination object
  82. *
  83. * @since 3.0
  84. */
  85. function pagination_list_render($list)
  86. {
  87. // Calculate to display range of pages
  88. $currentPage = 1;
  89. $range = 1;
  90. $step = 5;
  91. foreach ($list['pages'] as $k => $page)
  92. {
  93. if (!$page['active'])
  94. {
  95. $currentPage = $k;
  96. }
  97. }
  98. if ($currentPage >= $step)
  99. {
  100. if ($currentPage % $step == 0)
  101. {
  102. $range = ceil($currentPage / $step) + 1;
  103. }
  104. else
  105. {
  106. $range = ceil($currentPage / $step);
  107. }
  108. }
  109. $html = '<ul class="pagination-list">';
  110. $html .= $list['start']['data'];
  111. $html .= $list['previous']['data'];
  112. foreach ($list['pages'] as $k => $page)
  113. {
  114. if (in_array($k, range($range * $step - ($step + 1), $range * $step)))
  115. {
  116. if (($k % $step == 0 || $k == $range * $step - ($step + 1)) && $k != $currentPage && $k != $range * $step - $step)
  117. {
  118. $page['data'] = preg_replace('#(<a.*?>).*?(</a>)#', '$1...$2', $page['data']);
  119. }
  120. }
  121. $html .= $page['data'];
  122. }
  123. $html .= $list['next']['data'];
  124. $html .= $list['end']['data'];
  125. $html .= '</ul>';
  126. return $html;
  127. }
  128. /**
  129. * Renders an active item in the pagination block
  130. *
  131. * @param JPaginationObject $item The current pagination object
  132. *
  133. * @return string HTML markup for active item
  134. *
  135. * @since 3.0
  136. */
  137. function pagination_item_active(&$item)
  138. {
  139. $class = '';
  140. // Check for "Start" item
  141. if ($item->text == JText::_('JLIB_HTML_START'))
  142. {
  143. $display = '<span class="icon-first"></span>';
  144. }
  145. // Check for "Prev" item
  146. if ($item->text == JText::_('JPREV'))
  147. {
  148. $display = '<span class="icon-previous"></span>';
  149. }
  150. // Check for "Next" item
  151. if ($item->text == JText::_('JNEXT'))
  152. {
  153. $display = '<span class="icon-next"></span>';
  154. }
  155. // Check for "End" item
  156. if ($item->text == JText::_('JLIB_HTML_END'))
  157. {
  158. $display = '<span class="icon-last"></span>';
  159. }
  160. // If the display object isn't set already, just render the item with its text
  161. if (!isset($display))
  162. {
  163. $display = $item->text;
  164. $class = ' class="hidden-phone"';
  165. }
  166. return '<li' . $class . '><a title="' . $item->text . '" href="' . $item->link . '" class="pagenav">' . $display . '</a></li>';
  167. }
  168. /**
  169. * Renders an inactive item in the pagination block
  170. *
  171. * @param JPaginationObject $item The current pagination object
  172. *
  173. * @return string HTML markup for inactive item
  174. *
  175. * @since 3.0
  176. */
  177. function pagination_item_inactive(&$item)
  178. {
  179. // Check for "Start" item
  180. if ($item->text == JText::_('JLIB_HTML_START'))
  181. {
  182. return '<li class="disabled"><a><span class="icon-first"></span></a></li>';
  183. }
  184. // Check for "Prev" item
  185. if ($item->text == JText::_('JPREV'))
  186. {
  187. return '<li class="disabled"><a><span class="icon-previous"></span></a></li>';
  188. }
  189. // Check for "Next" item
  190. if ($item->text == JText::_('JNEXT'))
  191. {
  192. return '<li class="disabled"><a><span class="icon-next"></span></a></li>';
  193. }
  194. // Check for "End" item
  195. if ($item->text == JText::_('JLIB_HTML_END'))
  196. {
  197. return '<li class="disabled"><a><span class="icon-last"></span></a></li>';
  198. }
  199. // Check if the item is the active page
  200. if (isset($item->active) && ($item->active))
  201. {
  202. return '<li class="active hidden-phone"><a>' . $item->text . '</a></li>';
  203. }
  204. // Doesn't match any other condition, render a normal item
  205. return '<li class="disabled hidden-phone"><a>' . $item->text . '</a></li>';
  206. }