Mixin_NextGen_Basic_Pagination

Contains function(s) to generate a basic pagination widget.

Defined (1)

The class is defined in the following location(s).

/products/photocrati_nextgen/modules/nextgen_pagination/package.module.nextgen_pagination.php  
  1. class Mixin_NextGen_Basic_Pagination extends Mixin 
  2. /** 
  3. * Returns a formatted HTML string of a pagination widget 
  4. * @param mixed $page 
  5. * @param int $totalElement 
  6. * @param int $maxElement 
  7. * @return array Of data holding prev & next url locations and a formatted HTML string 
  8. */ 
  9. public function create_pagination($page, $totalElement, $maxElement = 0, $current_url = NULL) 
  10. $prev_symbol = apply_filters('ngg_prev_symbol', '◄'); 
  11. $next_symbol = apply_filters('ngg_next_symbol', '►'); 
  12. if (empty($current_url)) { 
  13. $current_url = $this->object->get_routed_url(TRUE); 
  14. if (is_archive()) { 
  15. $id = get_the_ID(); 
  16. if ($id == null) { 
  17. global $post; 
  18. $id = $post ? $post->ID : null; 
  19. if ($id != null && in_the_loop()) { 
  20. $current_url = get_permalink($id); 
  21. $return = array('prev' => '', 'next' => '', 'output' => ''); 
  22. if ($maxElement <= 0) { 
  23. $return['output'] = "<div class='ngg-clear'></div>"; 
  24. return $return; 
  25. $total = $totalElement; 
  26. // create navigation 
  27. if ($total > $maxElement) { 
  28. $r = ''; 
  29. if (1 < $page) { 
  30. $newpage = 1 == $page - 1 ? 1 : $page - 1; 
  31. $return['prev'] = $this->object->set_param_for($current_url, 'nggpage', $newpage); 
  32. $r .= '<a class="prev" data-pageid="' . $newpage . '" id="ngg-prev-' . $newpage . '" href="' . $return['prev'] . '">' . $prev_symbol . '</a>'; 
  33. $total_pages = ceil($total / $maxElement); 
  34. if ($total_pages > 1) { 
  35. for ($page_num = 1; $page_num <= $total_pages; $page_num++) { 
  36. if ($page == $page_num) { 
  37. $r .= '<span class="current">' . $page_num . '</span>'; 
  38. } else { 
  39. if ($page_num < 3 || $page_num >= $page - 3 && $page_num <= $page + 3 || $page_num > $total_pages - 3) { 
  40. $newpage = 1 == $page_num ? 1 : $page_num; 
  41. $link = $this->object->set_param_for($current_url, 'nggpage', $newpage); 
  42. $r .= '<a class="page-numbers" data-pageid="' . $newpage . '" href="' . $link . '">' . $page_num . '</a>'; 
  43. if ($page * $maxElement < $total || -1 == $total) { 
  44. $newpage = $page + 1; 
  45. $return['next'] = $this->object->set_param_for($current_url, 'nggpage', $newpage); 
  46. $r .= '<a class="next" data-pageid="' . $newpage . '" id="ngg-next-' . $newpage . '" href="' . $return['next'] . '">' . $next_symbol . '</a>'; 
  47. $return['output'] = "<div class='ngg-navigation'>{$r}</div>"; 
  48. } else { 
  49. $return['output'] = "<div class='ngg-clear'></div>"; 
  50. return $return;