%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php Class Gallery_Model extends CI_Model{ protected $album_table_name = 'SH_GalleryAlbums'; protected $category_table_name = 'SH_GalleryCategories'; protected $photo_table_name = 'SH_GalleryPhotos'; protected $primary_key = 'GalleryAlbumID'; protected $photo_primary_key = 'GalleryPhotoID'; protected $order_by = 'GalleryAlbumPriorityOrder DESC, GalleryPhotoPriorityOrder DESC'; //Fields to fetch for all album details including photo details - used for Add/Update Page, Album listing page. protected $fields_album_detail = 'GalleryAlbumID, GalleryAlbumName, GalleryAlbumCategory, GalleryAlbumCover, GalleryAlbumDescription, GROUP_CONCAT(GalleryPhotoID) as GalleryPhotoIDs, GROUP_CONCAT(GalleryPhotoTitle) as GalleryPhotoTitles, GROUP_CONCAT(GalleryPhotoCaption) as AlbumPhotoCaptions, GROUP_CONCAT(GalleryPhotoPageURL) as AlbumPhotoPageURLs, GROUP_CONCAT(GalleryPhotoAlternateName) as GalleryPhotoAlternateNames, GROUP_CONCAT(GalleryPhotoPriorityOrder) as GalleryPhotoPriorityOrders, GalleryAlbumPriorityOrder, GalleryAlbumPageURL, SH_GalleryAlbums.Status'; //Fields to fetch for all album details including photo details - used for Add/Update Page, Album listing page. // protected $fields_album_detail = 'GalleryAlbumID, GalleryAlbumName, GalleryAlbumCategory, GalleryAlbumCover, // GalleryAlbumDescription, GalleryAlbumPriorityOrder, GalleryAlbumPageURL, Status'; //Fields to fetch for all photo details - used for Albums Page protected $fields_photo_detail = 'GalleryPhotoID, GalleryPhotoTitle, GalleryPhotoAlbum, SH_GalleryAlbums.GalleryAlbumName ,GalleryPhotoAlternateName, GalleryPhotoCaption, GalleryPhotoPageURL, GalleryPhotoPriorityOrder, SH_GalleryPhotos.Status'; //Fields to fetch for summary of albums - used for gallery page protected $fields_album_summary = 'GalleryAlbumID, GalleryAlbumName, GalleryAlbumCategory, GalleryCategoryName, GalleryAlbumCover, GalleryAlbumDescription, GalleryAlbumPageURL, GalleryAlbumPriorityOrder, SH_GalleryAlbums.Status' ; Public function __construct() { parent::__construct(); } //Album Summary for given AlbumID function get_gallery_album($album_id){ $this->db->select($this->fields_album_summary); $this->db->join($this->category_table_name, $this->album_table_name.'.GalleryAlbumCategory='.$this->category_table_name.'.GalleryCategoryID'); $result = $this->db->get_where($this->album_table_name, array($this->primary_key => $album_id))->row_array(); return $result; } //Album Details with Photos for given AlbumID function get_gallery_album_details($album_id){ $this->db->select($this->fields_album_detail); $this->db->group_by($this->primary_key); $this->db->where($this->primary_key, $album_id); $this->db->join($this->photo_table_name, $this->album_table_name.'.GalleryAlbumID='.$this->photo_table_name.'.GalleryPhotoAlbum'); $Query = $this->db->get($this->album_table_name); $result = $Query->row_array(); $Query->free_result(); return $result; } //Album Summary for given Album Slug function get_gallery_album_by_slug($slug){ $this->db->select($this->fields_album_summary); return $this->db->get_where($this->album_table_name, array('GalleryAlbumPageURL' => $slug))->row(); } //Album Summary for given Album Name function get_gallery_album_by_name($name){ $this->db->select($this->fields_album_summary); return $this->db->get_where($this->album_table_name, array('GalleryAlbumTitle' => $name))->result_array(); } function get_photo($id){ $this->db->select($this->fields_photo_detail); $this->db->join($this->album_table_name, $this->album_table_name.'.GalleryAlbumID='.$this->photo_table_name.'.GalleryPhotoAlbum'); return $this->db->get_where($this->photo_table_name,array('GalleryPhotoID' => $id))->row_array(); } function get_gallery_photos($status=''){ $this->db->select($this->fields_photo_detail); if ($status != '') { $this->db->where('Status', $status); } $this->db->join($this->album_table_name, $this->album_table_name.'.GalleryAlbumID='.$this->photo_table_name.'.GalleryPhotoAlbum'); return $this->db->get($this->photo_table_name)->result_array(); } //Photo Details for given AlbumID function get_album_photos($album_id, $status=''){ $this->db->select($this->fields_photo_detail); if ($status != '') { $this->db->where($this->photo_table_name.'.Status', $status); } $this->db->join($this->album_table_name, $this->album_table_name.'.GalleryAlbumID='.$this->photo_table_name.'.GalleryPhotoAlbum'); return $this->db->get_where($this->photo_table_name, array('GalleryPhotoAlbum' => $album_id))->result_array(); } function get_gallery_albums($fields = '', $department_id = '', $category_id = '', $where = array(), $order_by = '', $status = ''){ if ($fields != '') { $this->db->select($fields); } else{ $this->db->select($this->fields_album_detail); } if($order_by != ''){ $this->db->order_by($order_by); } else{ $this->db->order_by($this->order_by); } if ($status != '') { $this->db->where($this->album_table_name.'.Status', $status); } if (count($where)) { $this->db->where($where); } if($department_id){ $this->db->where('FIND_IN_SET('.$department_id.', GalleryAlbumDepartment)!=',0); } if($category_id){ $this->db->where('GalleryAlbumCategory', $category_id); } $this->db->group_by($this->primary_key); $this->db->join($this->photo_table_name, $this->album_table_name.'.GalleryAlbumID='.$this->photo_table_name.'.GalleryPhotoAlbum'); $Query = $this->db->get($this->album_table_name); $result = $Query->result_array(); $Query->free_result(); return $result; } function get_gallery_albums_summary($fields = '', $department_id = '', $category_id = '', $where = array(), $order_by = '', $status = '', $limit = ''){ if ($fields != '') { $this->db->select($fields); } else{ $this->db->select($this->fields_album_summary); } if($order_by != ''){ $this->db->order_by($order_by); } else{ $this->db->order_by('GalleryAlbumPriorityOrder DESC'); } if ($status != '') { $this->db->where($this->album_table_name.'.Status', $status); } if ($limit != ''){ $this->db->limit($limit); } if (count($where)) { $this->db->where($where); } if($department_id){ $this->db->where('FIND_IN_SET('.$department_id.', GalleryAlbumDepartment)!=',0); } if($category_id){ $this->db->where('GalleryAlbumCategory', $category_id); } $this->db->join($this->category_table_name, $this->album_table_name.'.GalleryAlbumCategory='.$this->category_table_name.'.GalleryCategoryID'); $Query = $this->db->get($this->album_table_name); $result = $Query->result_array(); $Query->free_result(); return $result; } /////////////////////////////Albums////////////////////////////////////// //Insert Album function insert_gallery_album($data){ $data['CreationDate'] = $data['UpdationDate'] = date('Y-m-d H:i:s'); $success = $this->db->insert($this->album_table_name, $data); if ($success) { return $this->db->insert_id(); } else { return FALSE; } } //Update Album public function update_gallery_album($data, $album_id) { $data['UpdationDate'] = date('Y-m-d H:i:s'); $this->db->where($this->primary_key, $album_id); return $this->db->update($this->album_table_name, $data); } //Delete Album - only delete album if no corresponding photos in photo table public function delete_gallery_album($album_id) { $photos = $this->db->get_where($this->photo_table_name, array('GalleryPhotoAlbum' => $album_id))->result_array(); if(!count($photos)){ $this->db->where($this->primary_key, $album_id); return $this->db->delete($this->album_table_name); } return false; } /////////////////////////////Photos////////////////////////////////////// //Insert Photo function insert_album_photo($data){ $data['CreationDate'] = $data['UpdationDate'] = date('Y-m-d H:i:s'); $success = $this->db->insert($this->photo_table_name, $data); if ($success) { return $this->db->insert_id(); } else { return FALSE; } } //Update Photo public function update_album_photo($data, $photo_id) { $data['UpdationDate'] = date('Y-m-d H:i:s'); $this->db->where($this->photo_primary_key, $photo_id); return $this->db->update($this->photo_table_name, $data); } //Delete Photo public function delete_album_photo($photo_id) { $this->db->where($this->photo_primary_key, $photo_id); return $this->db->delete($this->photo_table_name); } } ?>