From 4ce532cf65896d8e62bf0f26b07c426ee27900ff Mon Sep 17 00:00:00 2001 From: atomaka Date: Sun, 6 Nov 2011 02:34:41 -0500 Subject: [PATCH] Add simple gallery. --- application/controllers/gallery.php | 31 +++++++++++++++++++++++++++++ application/controllers/upload.php | 4 ++-- application/models/fileupload.php | 6 ++++++ application/views/gallery.php | 9 +++++++++ css/style.css | 18 +++++++++++++++++ 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 application/controllers/gallery.php create mode 100644 application/views/gallery.php diff --git a/application/controllers/gallery.php b/application/controllers/gallery.php new file mode 100644 index 0000000..87dc8da --- /dev/null +++ b/application/controllers/gallery.php @@ -0,0 +1,31 @@ +load->model('fileupload'); + $this->load->library('pagination'); + + $page_count = 20; + $start = $this->uri->segment($this->uri->total_segments(), 1); + + if($start == 'index') $start = 1; + + + + $config = array( + 'base_url' => base_url('/gallery/index/'), + 'total_rows' => $this->fileupload->count_uploads(), + 'per_page' => $page_count + ); + + $this->pagination->initialize($config); + + $this->data['pagination'] = $this->pagination->create_links(); + $this->data['uploads'] = $this->fileupload->get_uploads($start, $page_count); + + $this->template->load('template', 'gallery', $this->data); + } +} + + +?> \ No newline at end of file diff --git a/application/controllers/upload.php b/application/controllers/upload.php index df82ac0..7fc2c70 100644 --- a/application/controllers/upload.php +++ b/application/controllers/upload.php @@ -34,13 +34,13 @@ class Upload extends CI_Controller { 'create_thumb' => true, 'maintain_ratio' => true, 'width' => 175, - 'height' => 50, + 'height' => 175, 'new_image' => './thumbs/' . $file_name . $upload['file_ext'], 'thumb_marker' => '', ); $this->load->library('image_lib',$config); - + if($this->image_lib->resize() != true) echo 'dead to me.'; echo $this->image_lib->display_errors(); diff --git a/application/models/fileupload.php b/application/models/fileupload.php index 61dd5af..e45b994 100644 --- a/application/models/fileupload.php +++ b/application/models/fileupload.php @@ -32,6 +32,12 @@ class Fileupload extends CI_Model { function add_view($id) { $this->db->query("UPDATE uploads SET views = views + 1 WHERE id = $id"); } + + function get_uploads($start = false, $count = false) { + $query = $this->db->get('uploads', $count, $start); + + return $query->result(); + } } ?> \ No newline at end of file diff --git a/application/views/gallery.php b/application/views/gallery.php new file mode 100644 index 0000000..00fe8d6 --- /dev/null +++ b/application/views/gallery.php @@ -0,0 +1,9 @@ + + +
+ +
+ +
+ +
\ No newline at end of file diff --git a/css/style.css b/css/style.css index 8591320..5c2c944 100644 --- a/css/style.css +++ b/css/style.css @@ -262,6 +262,7 @@ h1{ --------------------------*/ + #left { position: absolute; left: 0; @@ -284,4 +285,21 @@ h1{ display: block; height: 50px; width: 50px; +} + + + +/*------------------------- + Gallery +--------------------------*/ + + + +#galleryContainer { + width: 175px; + height: 175px; + float: left; + margin: 5px; + position: relative; + text-align: center; } \ No newline at end of file