Guest User

Untitled

a guest
Feb 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. function view_images($display,$listing_id,$per_page=10,$offset=0,$record=0) {
  2.  
  3. $data = array(
  4. 'listing_id' => $listing_id,
  5. 'offset' => $offset,
  6. 'per_page' => $per_page,
  7. 'display' => $display,
  8. 'image_record' => $record,
  9. 'images' => $this->admin_model->get_listing_images($listing_id,$per_page,$offset),
  10. 'image_count' => $this->admin_model->get_listing_count($listing_id)
  11. );
  12.  
  13. $data['record'] = $data['image_record'];
  14.  
  15. $data['next']['record'] = $data['record'] + 1;
  16. $data['prev']['record'] = $data['record'] - 1;
  17. $data['prev']['offset'] = $data['offset'];
  18. $data['next']['offset'] = $data['offset'];
  19.  
  20. if($data['next']['record'] > 4) {
  21. $data['next']['record'] = 0;
  22. }
  23.  
  24. if($data['prev']['record'] == -1) {
  25. $data['prev']['record'] = 4;
  26.  
  27. $data['prev']['offset'] = $data['offset'] - $data['per_page'];
  28. }
  29.  
  30. if($data['record'] == 4) {
  31. $data['next']['offset'] = $offset + $per_page;
  32. }
  33. if($data['prev']['offset'] < 0) {
  34. $data['prev']['offset'] = false;
  35. }
  36.  
  37. $x = $data['image_count'] - $data['offset'];
  38. $x -= $x;
  39.  
  40. if($x < $data['per_page'] && $data['record'] >= $x) {
  41. $data['next']['offset'] = false;
  42. }
  43.  
  44. if(!$data['image_count']) {
  45. $data['error']['no_images'] = true;
  46. $this->load->view('listing_manager/admin/includes/messages',$data);
  47. } elseif($data['image_count'] > $per_page) {
  48.  
  49. $config = array(
  50. 'base_url' => site_url().'listing_manager/admin/view_images/'.$display.'/'.$listing_id.'/'.$per_page.'/',
  51. 'total_rows' => $data['image_count'],
  52. 'per_page' => $per_page,
  53. 'uri_segment' => 7
  54. );
  55. $this->load->library('pagination',$config);
  56.  
  57. if($data['offset'] > $this->pagination->total_rows) {
  58. show_404();
  59. }
  60.  
  61. $data['pagination'] = $this->pagination->create_links();
  62. $this->load->view('listing_manager/admin/view_images',$data);
  63. } else {
  64. $this->load->view('listing_manager/admin/view_images',$data);
  65. }
  66. }
Add Comment
Please, Sign In to add comment