From f52949345f914896410b0671a54e31785ef51fb8 Mon Sep 17 00:00:00 2001 From: jerel Date: Thu, 8 Dec 2011 12:11:59 -0600 Subject: [PATCH] Initial commit --- config/routes.php | 29 ++ controllers/admin.php | 455 ++++++++++++++++++ controllers/galleries.php | 105 ++++ css/galleries.css | 103 ++++ details.php | 140 ++++++ img/album.png | Bin 0 -> 2733 bytes img/jcrop.gif | Bin 0 -> 329 bytes js/jcrop.js | 7 + js/jcrop_init.js | 31 ++ js/manage.js | 98 ++++ language/arabic/galleries_lang.php | 58 +++ language/arabic/gallery_images_lang.php | 26 + language/brazilian/galleries_lang.php | 58 +++ language/brazilian/gallery_images_lang.php | 26 + .../chinese_traditional/galleries_lang.php | 58 +++ .../gallery_images_lang.php | 26 + language/czech/galleries_lang.php | 60 +++ language/czech/gallery_images_lang.php | 26 + language/dutch/galleries_lang.php | 58 +++ language/dutch/gallery_images_lang.php | 26 + language/english/galleries_lang.php | 60 +++ language/english/gallery_images_lang.php | 26 + language/finnish/galleries_lang.php | 68 +++ language/finnish/gallery_images_lang.php | 34 ++ language/french/galleries_lang.php | 58 +++ language/french/gallery_images_lang.php | 26 + language/german/galleries_lang.php | 58 +++ language/german/gallery_images_lang.php | 26 + language/greek/galleries_lang.php | 59 +++ language/greek/gallery_images_lang.php | 26 + language/italian/galleries_lang.php | 58 +++ language/italian/gallery_images_lang.php | 26 + language/lithuanian/galleries_lang.php | 58 +++ language/lithuanian/gallery_images_lang.php | 26 + language/polish/galleries_lang.php | 58 +++ language/polish/gallery_images_lang.php | 26 + language/russian/galleries_lang.php | 69 +++ language/russian/gallery_images_lang.php | 37 ++ language/slovenian/galleries_lang.php | 59 +++ language/slovenian/gallery_images_lang.php | 26 + language/spanish/galleries_lang.php | 61 +++ language/spanish/gallery_images_lang.php | 29 ++ models/gallery_image_m.php | 226 +++++++++ models/gallery_m.php | 150 ++++++ plugin.php | 78 +++ views/admin/form.php | 164 +++++++ views/admin/image/preview.php | 11 + views/admin/index.php | 60 +++ views/admin/preview.php | 11 + views/gallery.php | 53 ++ views/image.php | 19 + views/index.php | 29 ++ 52 files changed, 3165 insertions(+) create mode 100644 config/routes.php create mode 100644 controllers/admin.php create mode 100644 controllers/galleries.php create mode 100644 css/galleries.css create mode 100644 details.php create mode 100644 img/album.png create mode 100644 img/jcrop.gif create mode 100644 js/jcrop.js create mode 100644 js/jcrop_init.js create mode 100644 js/manage.js create mode 100644 language/arabic/galleries_lang.php create mode 100644 language/arabic/gallery_images_lang.php create mode 100644 language/brazilian/galleries_lang.php create mode 100644 language/brazilian/gallery_images_lang.php create mode 100644 language/chinese_traditional/galleries_lang.php create mode 100644 language/chinese_traditional/gallery_images_lang.php create mode 100644 language/czech/galleries_lang.php create mode 100644 language/czech/gallery_images_lang.php create mode 100644 language/dutch/galleries_lang.php create mode 100644 language/dutch/gallery_images_lang.php create mode 100644 language/english/galleries_lang.php create mode 100644 language/english/gallery_images_lang.php create mode 100644 language/finnish/galleries_lang.php create mode 100644 language/finnish/gallery_images_lang.php create mode 100644 language/french/galleries_lang.php create mode 100644 language/french/gallery_images_lang.php create mode 100644 language/german/galleries_lang.php create mode 100644 language/german/gallery_images_lang.php create mode 100644 language/greek/galleries_lang.php create mode 100644 language/greek/gallery_images_lang.php create mode 100644 language/italian/galleries_lang.php create mode 100644 language/italian/gallery_images_lang.php create mode 100644 language/lithuanian/galleries_lang.php create mode 100644 language/lithuanian/gallery_images_lang.php create mode 100644 language/polish/galleries_lang.php create mode 100644 language/polish/gallery_images_lang.php create mode 100644 language/russian/galleries_lang.php create mode 100644 language/russian/gallery_images_lang.php create mode 100644 language/slovenian/galleries_lang.php create mode 100644 language/slovenian/gallery_images_lang.php create mode 100644 language/spanish/galleries_lang.php create mode 100644 language/spanish/gallery_images_lang.php create mode 100644 models/gallery_image_m.php create mode 100644 models/gallery_m.php create mode 100644 plugin.php create mode 100644 views/admin/form.php create mode 100644 views/admin/image/preview.php create mode 100644 views/admin/index.php create mode 100644 views/admin/preview.php create mode 100644 views/gallery.php create mode 100644 views/image.php create mode 100644 views/index.php diff --git a/config/routes.php b/config/routes.php new file mode 100644 index 0000000..03724ee --- /dev/null +++ b/config/routes.php @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/controllers/admin.php b/controllers/admin.php new file mode 100644 index 0000000..825eafa --- /dev/null +++ b/controllers/admin.php @@ -0,0 +1,455 @@ + 'title', + 'label' => 'lang:galleries.title_label', + 'rules' => 'trim|max_length[255]|required' + ), + 'slug' => array( + 'field' => 'slug', + 'label' => 'lang:galleries.slug_label', + 'rules' => 'trim|max_length[255]|required|callback__check_slug' + ), + array( + 'field' => 'folder_id', + 'label' => 'lang:galleries.folder_label', + 'rules' => 'trim|numeric|required|callback__check_folder' + ), + array( + 'field' => 'description', + 'label' => 'lang:galleries.description_label', + 'rules' => 'trim' + ), + array( + 'field' => 'enable_comments', + 'label' => 'lang:galleries.comments_label', + 'rules' => 'trim' + ), + array( + 'field' => 'published', + 'label' => 'lang:galleries.published_label', + 'rules' => 'trim' + ), + array( + 'field' => 'gallery_thumbnail', + 'label' => 'lang:galleries.thumbnail_label', + 'rules' => 'trim' + ), + array( + 'field' => 'css', + 'label' => 'lang:galleries.css_label', + 'rules' => 'trim' + ), + array( + 'field' => 'js', + 'label' => 'lang:galleries.js_label', + 'rules' => 'trim' + ) + ); + + /** + * Validation rules for uploading photos + * + * @var array + * @access private + */ + private $image_validation_rules = array( + array( + 'field' => 'title', + 'label' => 'lang:gallery_images.title_label', + 'rules' => 'trim|max_length[255]|required' + ), + array( + 'field' => 'userfile', + 'label' => 'lang:gallery_images.image_label', + 'rules' => 'trim' + ), + array( + 'field' => 'gallery_id', + 'label' => 'lang:gallery_images.gallery_label', + 'rules' => 'trim|integer|required' + ), + array( + 'field' => 'description', + 'label' => 'lang:gallery_images.description_label', + 'rules' => 'trim' + ) + ); + + public function __construct() + { + parent::__construct(); + + // Load all the required classes + $this->load->model('gallery_m'); + $this->load->model('gallery_image_m'); + $this->load->library('form_validation'); + $this->lang->load('galleries'); + $this->lang->load('gallery_images'); + + $this->load->helper('html'); + $this->load->model('files/file_folders_m'); + } + + /** + * List all existing albums + * + * @access public + * @return void + */ + public function index() + { + // Get all the galleries + $galleries = $this->gallery_m->get_all(); + + // Get aux. folders + $this->load->model('file_folders_m'); + $folders = $this->file_folders_m->get_folders(); + + // Load the view + $this->template + ->title($this->module_details['name']) + ->set('galleries', $galleries) + ->set('folders', $folders) + ->build('admin/index'); + } + + /** + * Create a new gallery + * + * @access public + * @return void + */ + public function create() + { + $file_folders = $this->file_folders_m->get_folders(); + $folders_tree = array(); + foreach ($file_folders as $folder) + { + $indent = repeater('» ', $folder->depth); + $folders_tree[$folder->id] = $indent.$folder->name; + } + + // Set the validation rules + $this->form_validation->set_rules($this->gallery_validation_rules); + + if ($this->form_validation->run() ) + { + if ($id = $this->gallery_m->insert($this->input->post())) + { + // Everything went ok.. + $this->session->set_flashdata('success', lang('galleries.create_success')); + + // Redirect back to the form or main page + $this->input->post('btnAction') == 'save_exit' + ? redirect('admin/galleries') + : redirect('admin/galleries/manage/'.$id); + } + + // Something went wrong.. + else + { + $this->session->set_flashdata('error', lang('galleries.create_error')); + redirect('admin/galleries/create'); + } + } + + // Required for validation + foreach ($this->gallery_validation_rules as $rule) + { + $gallery->{$rule['field']} = $this->input->post($rule['field']); + } + + $this->template + ->title($this->module_details['name'], lang('galleries.new_gallery_label')) + ->append_metadata( css('galleries.css', 'galleries') ) + ->append_metadata( js('manage.js', 'galleries') ) + ->append_metadata( $this->load->view('fragments/wysiwyg', $this->data, TRUE) ) + ->set('gallery', $gallery) + ->set('folders_tree', $folders_tree) + ->build('admin/form'); + } + + /** + * Manage an existing gallery + * + * @access public + * @param int $id The ID of the gallery to manage + * @return void + */ + public function manage($id) + { + $file_folders = $this->file_folders_m->get_folders(); + $folders_tree = array(); + foreach($file_folders as $folder) + { + $indent = repeater('» ', $folder->depth); + $folders_tree[$folder->id] = $indent.$folder->name; + } + + $this->form_validation->set_rules(array_merge($this->gallery_validation_rules, array( + 'slug' => array( + 'field' => 'slug', + 'label' => 'lang:galleries.slug_label', + 'rules' => 'trim|max_length[255]|required|callback__check_slug['.$id.']' + ), + ))); + + // Get the gallery and all images + $galleries = $this->gallery_m->get_all(); + $gallery = $this->gallery_m->get($id); + $gallery_images = $this->gallery_image_m->get_images_by_gallery($id); + + if (empty($gallery)) + { + $this->session->set_flashdata('error', lang('galleries.exists_error')); + redirect('admin/galleries'); + } + + // Valid form data? + if ($this->form_validation->run()) + { + // Try to update the gallery + if ($this->gallery_m->update($id, $this->input->post()) === TRUE ) + { + $this->session->set_flashdata('success', lang('galleries.update_success')); + + // Redirect back to the form or main page + $this->input->post('btnAction') == 'save_exit' + ? redirect('admin/galleries') + : redirect('admin/galleries/manage/'.$id); + } + else + { + $this->session->set_flashdata('error', lang('galleries.update_error')); + redirect('admin/galleries/manage/'.$id); + } + } + + // Required for validation + foreach ($this->gallery_validation_rules as $rule) + { + if ($this->input->post($rule['field'])) + { + $gallery->{$rule['field']} = $this->input->post($rule['field']); + } + } + + $this->template + ->title($this->module_details['name'], sprintf(lang('galleries.manage_gallery_label'), $gallery->title)) + ->append_metadata( css('galleries.css', 'galleries') ) + ->append_metadata( js('manage.js', 'galleries') ) + ->append_metadata( $this->load->view('fragments/wysiwyg', $this->data, TRUE) ) + ->set('gallery', $gallery) + ->set('galleries', $galleries) + ->set('gallery_images', $gallery_images) + ->set('folders_tree', $folders_tree) + ->build('admin/form'); + } + + /** + * Show a gallery preview + * @access public + * @param int $id The ID of the gallery + * @return void + */ + public function preview($id = 0) + { + $data->gallery = $this->gallery_m->get($id); + + $this->template->set_layout('modal', 'admin'); + $this->template->build('admin/preview', $data); + } + + /** + * Delete an existing gallery + * + * @access public + * @param int $id The ID of the gallery to delete + * @return void + */ + public function delete($id = NULL) + { + $id_array = array(); + + // Multiple IDs or just a single one? + if ($_POST ) + { + $id_array = $_POST['action_to']; + } + else + { + if ($id !== NULL ) + { + $id_array[0] = $id; + } + } + + if ( empty($id_array) ) + { + $this->session->set_flashdata('error', lang('galleries.id_error')); + redirect('admin/galleries'); + } + + // Loop through each ID + foreach ( $id_array as $id) + { + // Get the gallery + $gallery = $this->gallery_m->get($id); + + // Does the gallery exist? + if ( !empty($gallery) ) + { + + // Delete the gallery along with all the images from the database + if ($this->gallery_m->delete($id) AND $this->gallery_image_m->delete_by('gallery_id', $id) ) + { + $this->session->set_flashdata('error', sprintf( lang('galleries.folder_error'), $gallery->title)); + redirect('admin/galleries'); + } + else + { + $this->session->set_flashdata('error', sprintf( lang('galleries.delete_error'), $gallery->title)); + redirect('admin/galleries'); + } + } + } + + $this->session->set_flashdata('success', lang('galleries.delete_success')); + redirect('admin/galleries'); + } + + /** + * Show a gallery image preview + * @access public + * @param int $id The ID of the gallery image + * @return void + */ + public function image_preview($id = 0) + { + $data->image = $this->gallery_image_m->get($id); + + $this->template->set_layout('modal', 'admin'); + $this->template->build('admin/image/preview', $data); + } + + /** + * Sort images in an existing gallery + * + * @access public + */ + public function ajax_update_order() + { + $ids = explode(',', $this->input->post('order')); + + $i = 1; + foreach ($ids as $id) + { + $this->gallery_image_m->update($id, array( + 'order' => $i + )); + + if ($i === 1) + { + $preview = $this->gallery_image_m->get($id); + + if ($preview) + { + $this->db->where('id', $preview->gallery_id); + $this->db->update('galleries', array( + 'preview' => $preview->filename + )); + } + } + ++$i; + } + } + + public function ajax_select_folder($folder_id) + { + $folder = $this->file_folders_m->get($folder_id); + + if (isset($folder->id)) + { + $folder->images = $this->gallery_image_m->get_images_by_file_folder($folder->id); + + return $this->template->build_json($folder); + } + + echo FALSE; + } + + /** + * Callback method that checks the slug of the gallery + * @access public + * @param string title The slug to check + * @return bool + */ + public function _check_slug($slug = '', $id = NULL) + { + $this->form_validation->set_message('_check_slug', sprintf(lang('galleries.already_exist_error'), $slug)); + + return ! $this->gallery_m->check_slug($slug, $id); + } + + /** + * Callback method that checks the file folder of the gallery + * @access public + * @param int id The id to check if file folder exists or prep to create new folder + * @return bool + */ + public function _check_folder($id = 0) + { + // Is not creating or folder exist.. Nothing to do. + if ($this->method !== 'create') + { + return $id; + } + elseif ($this->file_folders_m->exists($id)) + { + if ($this->gallery_m->count_by('folder_id', $id) > 0) + { + $this->form_validation->set_message('_check_folder', lang('galleries.folder_duplicated_error')); + + return FALSE; + } + + return $id; + } + + $folder_name = $this->input->post('title'); + $folder_slug = url_title(strtolower($folder_name)); + + // Check if folder already exist, rename if necessary. + $i = 0; + $counter = ''; + while ( ((int) $this->file_folders_m->count_by('slug', $folder_slug.$counter) > 0)) + { + $counter = '-'.++$i; + } + + // Return data to create a new folder to this gallery. + return array( + 'name' => $folder_name.($i > 0 ? ' ('.$i.')' : ''), + 'slug' => $folder_slug.$counter + ); + } +} diff --git a/controllers/galleries.php b/controllers/galleries.php new file mode 100644 index 0000000..6017de7 --- /dev/null +++ b/controllers/galleries.php @@ -0,0 +1,105 @@ +load->model('gallery_m'); + $this->load->model('gallery_image_m'); + $this->lang->load('galleries'); + $this->lang->load('gallery_images'); + $this->load->helper('html'); + } + + /** + * Index method + * + * @access public + * @return void + */ + public function index() + { + $data->galleries = $this->gallery_m->get_all_with_filename(); + + $this->template + ->title($this->module_details['name']) + ->build('index', $data); + } + + /** + * View a single gallery + * + * @author Yorick Peterse - PyroCMS Dev Team + * @access public + * @param string $slug The slug of the gallery + */ + public function gallery($slug = NULL) + { + $slug or show_404(); + + $gallery = $this->gallery_m->get_by('slug', $slug) or show_404(); + $gallery_images = $this->gallery_image_m->get_images_by_gallery($gallery->id); + $sub_galleries = $this->gallery_m->get_all_with_filename('parent_id', $gallery->folder_id); + if($gallery->css) { + $this->template->append_metadata(''); + } + if($gallery->js) { + $this->template->append_metadata(''); + } + + $this->template->build('gallery', array( + 'gallery' => $gallery, + 'gallery_images' => $gallery_images, + 'sub_galleries' => $sub_galleries + )); + } + + /** + * View a single image + * + * @author Yorick Peterse - PyroCMS Dev Team + * @access public + * @param + */ + public function image($gallery_slug = NULL, $image_id = NULL) + { + // Got the required variables? + if ( empty($gallery_slug) OR empty($image_id) ) + { + show_404(); + } + + $gallery = $this->gallery_m->get_by('slug', $gallery_slug); + $gallery_image = $this->gallery_image_m->get($image_id); + + // Do the gallery and the image ID match? + if ( ! $gallery OR ($gallery->id != $gallery_image->gallery_id)) + { + show_404(); + } + + $this->template->build('image', array( + 'gallery' => $gallery, + 'gallery_image' => $gallery_image + )); + } +} \ No newline at end of file diff --git a/css/galleries.css b/css/galleries.css new file mode 100644 index 0000000..5f7f39a --- /dev/null +++ b/css/galleries.css @@ -0,0 +1,103 @@ + /*** + * Galleries module styling + * @author Jerel Unruh - PyroCMS Dev Team + ***/ + +/*Give the js file upload a height so everything will float properly*/ + +.uploader_file_input +{ + height: 28px; +} + +/*make the uniform file input usable */ + +form.crud ul li div +{ + width: auto; +} + +/*Style the manage page thumbnails*/ + +#gallery_images_list +{ + margin-left:50px; + list-style:none; +} + +#gallery_images_list li +{ + float: left; + margin: 5px; + padding: 5px; + height: 100px; +} + +#gallery_images_list img +{ + border: 1px solid #9c9fa1; +} + +#gallery_images_list img:hover +{ + border: 1px solid #3A4043; + cursor: pointer; +} + +.images-placeholder #gallery_images_list img:hover +{ + border: 1px solid #9c9fa1; + cursor: default; +} + +/* JCROP */ + +.jcrop-holder +{ + background: none!important; + text-align: left; +} + +.jcrop-vline, .jcrop-hline +{ + font-size: 0; + position: absolute; + background: white url('../img/jcrop.gif') top left repeat; +} + +.jcrop-vline +{ + height: 100%; + width: 1px !important; +} + +.jcrop-hline +{ + width: 100%; + height: 1px !important; +} + +.jcrop-handle +{ + font-size: 1px; + width: 7px !important; + height: 7px !important; + border: 1px #eee solid; + background-color: #333; + *width: 9px; + *height: 9px; +} + +.jcrop-tracker +{ + width: 100%; + height: 100%; +} + +.custom .jcrop-handle +{ + border-color: black; + background-color: #C7BB00; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; +} diff --git a/details.php b/details.php new file mode 100644 index 0000000..699b789 --- /dev/null +++ b/details.php @@ -0,0 +1,140 @@ + array( + 'sl' => 'Galerija', + 'en' => 'Galleries', + 'el' => 'Γκαλερί', + 'de' => 'Galerien', + 'nl' => 'Gallerijen', + 'fr' => 'Galeries', + 'zh' => '畫廊', + 'it' => 'Gallerie', + 'ru' => 'Галереи', + 'ar' => 'معارض الصّور', + 'br' => 'Galerias', + 'cs' => 'Galerie', + 'es' => 'Galerías', + 'fi' => 'Galleriat', + 'lt' => 'Galerijos' + ), + 'description' => array( + 'sl' => 'Modul galerije vam omogoča da ustvarite albume vaših slik.', + 'en' => 'The galleries module is a powerful module that lets users create image galleries.', + 'el' => 'Παρέχει την δυνατότητα στους χρήστες να δημιουργούν άλμπουμ εικόνων.', + 'de' => 'Mit dem Galerie Modul kannst du Bildergalerien anlegen.', + 'nl' => 'De gallerij module die gebruikers in staat stelt afbeeldingsgallerijen te maken.', + 'fr' => 'Galerie est une puissante extension permettant de créer des galeries d\'images.', + 'zh' => '這是一個功能完整的畫廊模組,可以讓用戶建立自己的畫本或相簿。', + 'it' => 'Il modulo gallerie è un potente modulo che permette agli utenti di creare gallerie di immagini.', + 'ru' => 'Галереи - мощный модуль, который даёт пользователям возможность создавать галереи изображений.', + 'ar' => 'هذه الوحدة تمُكّنك من إنشاء معارض الصّور بسهولة.', + 'br' => 'O módulo de galerias é um poderoso módulo que permite aos usuários criar galerias de imagens.', + 'cs' => 'Silný modul pro vytváření a správu galerií obrázků.', + 'es' => 'Galerías es un potente módulo que permite a los usuarios crear galerías de imágenes.', + 'fi' => 'Galleria moduuli antaa käyttäjien luoda kuva gallerioita.', + 'lt' => 'Galerijos modulis leidžia vartotojams kurti nuotraukų galerijas' + ), + 'frontend' => TRUE, + 'backend' => TRUE, + 'menu' => 'content', + + 'shortcuts' => array( + array( + 'name' => 'galleries.new_gallery_label', + 'uri' => 'admin/galleries/create', + 'class' => 'add' + ), + ), + ); + } + + public function install() + { + $this->dbforge->drop_table('galleries'); + $this->dbforge->drop_table('gallery_images'); + + $galleries = " + CREATE TABLE ".$this->db->dbprefix('galleries')." ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `title` varchar(255) NOT NULL, + `slug` varchar(255) NOT NULL, + `folder_id` int(11) NOT NULL, + `thumbnail_id` int(11) DEFAULT NULL, + `description` text, + `updated_on` int(15) NOT NULL, + `preview` varchar(255) DEFAULT NULL, + `enable_comments` int(1) DEFAULT NULL, + `published` int(1) DEFAULT NULL, + `css` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci, + `js` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci, + PRIMARY KEY (`id`), + UNIQUE KEY `slug` (`slug`), + UNIQUE KEY `thumbnail_id` (`thumbnail_id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 + "; + + $gallery_images = " + CREATE TABLE ".$this->db->dbprefix('gallery_images')." ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `file_id` int(11) NOT NULL, + `gallery_id` int(11) NOT NULL, + `order` int(11) DEFAULT '0', + PRIMARY KEY (`id`), + KEY `gallery_id` (`gallery_id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 + "; + + if($this->db->query($galleries) && $this->db->query($gallery_images)) + { + return TRUE; + } + } + + public function uninstall() + { + if($this->dbforge->drop_table('galleries') && + $this->dbforge->drop_table('gallery_images')) + { + return TRUE; + } + } + + + public function upgrade($old_version) + { + // Your Upgrade Logic + return TRUE; + } + + public function help() + { + // Return a string containing help info + // You could include a file and return it here. + return "

Overview

+

The galleries module is a basic photo management tool. Features include drag & drop sorting and sub galleries.

+

Creating Galleries

+

To create a gallery go to Content->Files and create a new folder. Come back to Galleries and click \"Create a new gallery\" and select the folder of images that you just created in the File manager. + Fill out the title, slug, and the (optional) Description. (The Description shows + beside the gallery thumbnail at http://example.com/galleries). Choose whether you want to enable comments for this gallery or not + and select Publish if you wish for the gallery to show in the list of galleries. Note: selecting Unpublish does not disable the gallery, it just + removes it from the list at http://example.com/galleries. You can still create a navigation link directly to it and the + gallery will be viewable. For example: http://example.com/galleries/gallery-title

+

Uploading Images

+

For instructions on how to upload images refer to the Files documentation.

+

Manage Gallery

+

Click on List Galleries->Manage. Here you may change the gallery's title, slug, description, etc. If you want a thumbnail to represent this + gallery in the gallery list you may choose one from the dropdown and click Save. To change the order that the images are displayed in on the front-end + simply grab the images and drag them into the proper order.

+

Editing an Image

+

From the Manage page click on the image that you would like to edit. A modal window will appear and you may change + the title and the description of the image. You may also move the image to a different folder.

"; + } +} +/* End of file details.php */ \ No newline at end of file diff --git a/img/album.png b/img/album.png new file mode 100644 index 0000000000000000000000000000000000000000..bcb644d305f72d25038506b281e01660307c57f7 GIT binary patch literal 2733 zcmV;e3R3lnP)M?{dpk z#Xmq0NJs_*f*TqNj*v(T+LTt76H26H?Rsrz?X~x9W}fG~{C-@_*hwJW*kcnsVSmyy zFPhPrIiK_Wy`AU4q5c0hc~AqHnTUv;J$tr3bLLD0cikZXI8~ETo-h0d-=S==KgHNBDf%i@=0gzYy@~fKB5I(j2$(ZdFW^E5IOi}R#Yo$> zQB}88^=gc1Lp85AO|za-y12i;e`RlP@A~fU?*881-Z1Cfy!6sb>2CgacwoUqCM=I0 zJ*og9geQX!%S}owbvtf-^Sb!ou;k`d0&OK{p#I_}+G*&G)N-kG&(aR~d@5C4{uC1+YoH}*tZ$2>qw`I7s zwN(I|b6;>y25Km!_*+r=QCKn8JHmo9e93fjVbBx?v@Futl2cjqjzMs)>%Fh5fDb`J z2qw;(h$L0hq6G|`_r4P81@E75&OPCrf8I1eEYj!ue!Z&g}Oc>&Ld7HUzdXiGaz7mWvSws&pgI( zG@=st>vuLe-&tj`-^I-E-l=omyoh-3rb2fHP*lYxV4xH#%~orsr%4tpv52uG%90mb za4-m7f_HSfy-92lvAVAP!a{#`1^7B^wPvbLAmu~{gbBG`! zrXqp}<|sH3e77rZVHqjeXj@#9N!}q~B7g%Yf)nUe6{TRSRmDoTwo=r5U1O%#?+buV z*HeLGKU(9~U8F&?N&WHYBP(>DdWxb3Vr-2fThSmDyeJVzM<&1GoEJ<@L~xxhP7CGT z^Vszb!s-dCC%!mQV4IK-a8nO-7!ISDus0g>nG)&vE^0;)p%lG(UjT|tu57}E8#~D6 z#$5q0gj2ux^O%8YAzR_SQDQg4LM}8~XvLB18u2xFCq6bf?{Itj*8byPFn;44&IiOf z7M}k#`oH?yI3IAaLEPlG#0MNIHNvQgECdMNkqrrEq?9k;7l5orQKP7`_oc6*S1ukn zke3Ot3Z-7{p{AJgG%;~?6xk^~LYruvkj3CXzK?tR2gt&rq-VbZM^7kke23 zzqmrVwJGsCe`R*!3)Ij2GQD5D{K7I>3o=-yjP@8^{7>T3r|_vDX^87DASt4ykaEGdV~&K10!~fIZRXW$!*BlX z-@oxqjd450<{N+fJE#BT-eSO10baqdk5B#>1*5B(o`X^fz2Mj#CpJczZD2{1u|$?H zy-nP_j63!@xUqq}`ENAO{yMd*DQ$~}2B|x+zl~HKQdaDH-zNX?pOM}I^89b0pZjTw z7xqi$c*!i+9Sp%a&#)xMp-(;Nk=y2o8m|EN2A~up7sD4r?Bkm&6Hqf2$W$T|b&gk3PxG?h1p?{tTV|5~PHL8fzQ;Q_qlNM9=*t zY+nb>_`MzSZ~h)U`WSn|F(*S|xeim+c}8jsLkA~Z)dn7Nz7!ZW=~=d;H<)UyyrJfcU_2 zzt5MBAE6E&M3DcTy_5&pjlciOj8V+|)5cB2k7g-^gj*SYuwQV&eZ-<053`vWF)Bqo z#bg!$peAfa!>c{?6aL6KWJ3{(%~A*zBb(tAv?%jvrjV!COr>znhTN_M=g@Ro$(92a z@W47CsUk%uRnA-zFp^FRx_btYic+af^0CdS3z*(n$eCh5nmUj;<}?N4>f=?s|ysxJ_P{EEHNMz#bw3jIR==L^E8&t0zk^7 zshDd8=!`CqisC;73Mg4;s{?W|qAGsQ6;Nia1JX1Fx;Y1+vu1&m70ZVI6u3Z|$pzG4 z+DOc^0&Lc1s3}UAW`el}pn70Ce_$5SqR5=PfaMt#kjkWrLg!ZjZkh#bmKe~KNep0m zgJT{|Y*GWrENO74lK>Kn;^!2Ap9VoUiwg|PbTh3ec}@Xf6BWxWE->8|oRT<-{Rdq+!WRX|qoWsU)q_ZRV=0pv2dd|__$pcY66-x)bT z0R?gfmnR2+WX>R%LCKKQ0Is=K+}AgqTj-KaFcVwlZng2Fa6soP;CMs#cyzE nhjwU(c4&uoXoq%aAGZGj&TQ|W0G5LH00000NkvXXu0mjfi|aL; literal 0 HcmV?d00001 diff --git a/img/jcrop.gif b/img/jcrop.gif new file mode 100644 index 0000000000000000000000000000000000000000..72ea7ccb5321d5384d70437cfaac73011237901e GIT binary patch literal 329 zcmZ?wbhEHb9b#5NV>2k zBC~b@b~P=nNfWAe-b%_i6tS^-1y(h@EsB~1TqDA_h@fkxG$bHgvj}VxE1JLgr!*!^ ILUxTc0Q$^Q5C8xG literal 0 HcmV?d00001 diff --git a/js/jcrop.js b/js/jcrop.js new file mode 100644 index 0000000..0960b74 --- /dev/null +++ b/js/jcrop.js @@ -0,0 +1,7 @@ +/** + * Jcrop v.0.9.8 (minimized) + * (c) 2008 Kelly Hallman and DeepLiquid.com + * More information: http://deepliquid.com/content/Jcrop.html + * Released under MIT License - this header must remain with code + */ +(function($){$.Jcrop=function(obj,opt){var obj=obj,opt=opt;if(typeof(obj)!=="object"){obj=$(obj)[0]}if(typeof(opt)!=="object"){opt={}}if(!("trackDocument" in opt)){opt.trackDocument=$.browser.msie?false:true;if($.browser.msie&&$.browser.version.split(".")[0]=="8"){opt.trackDocument=true}}if(!("keySupport" in opt)){opt.keySupport=$.browser.msie?false:true}var defaults={trackDocument:false,baseClass:"jcrop",addClass:null,bgColor:"black",bgOpacity:0.6,borderOpacity:0.4,handleOpacity:0.5,handlePad:5,handleSize:9,handleOffset:5,edgeMargin:14,aspectRatio:0,keySupport:true,cornerHandles:true,sideHandles:true,drawBorders:true,dragEdges:true,boxWidth:0,boxHeight:0,boundary:8,animationDelay:20,swingSpeed:3,allowSelect:true,allowMove:true,allowResize:true,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){}};var options=defaults;setOptions(opt);var $origimg=$(obj);var $img=$origimg.clone().removeAttr("id").css({position:"absolute"});$img.width($origimg.width());$img.height($origimg.height());$origimg.after($img).hide();presize($img,options.boxWidth,options.boxHeight);var boundx=$img.width(),boundy=$img.height(),$div=$("
").width(boundx).height(boundy).addClass(cssClass("holder")).css({position:"relative",backgroundColor:options.bgColor}).insertAfter($origimg).append($img);if(options.addClass){$div.addClass(options.addClass)}var $img2=$("").attr("src",$img.attr("src")).css("position","absolute").width(boundx).height(boundy);var $img_holder=$("
").width(pct(100)).height(pct(100)).css({zIndex:310,position:"absolute",overflow:"hidden"}).append($img2);var $hdl_holder=$("
").width(pct(100)).height(pct(100)).css("zIndex",320);var $sel=$("
").css({position:"absolute",zIndex:300}).insertBefore($img).append($img_holder,$hdl_holder);var bound=options.boundary;var $trk=newTracker().width(boundx+(bound*2)).height(boundy+(bound*2)).css({position:"absolute",top:px(-bound),left:px(-bound),zIndex:290}).mousedown(newSelection);var xlimit,ylimit,xmin,ymin;var xscale,yscale,enabled=true;var docOffset=getPos($img),btndown,lastcurs,dimmed,animating,shift_down;var Coords=function(){var x1=0,y1=0,x2=0,y2=0,ox,oy;function setPressed(pos){var pos=rebound(pos);x2=x1=pos[0];y2=y1=pos[1]}function setCurrent(pos){var pos=rebound(pos);ox=pos[0]-x2;oy=pos[1]-y2;x2=pos[0];y2=pos[1]}function getOffset(){return[ox,oy]}function moveOffset(offset){var ox=offset[0],oy=offset[1];if(0>x1+ox){ox-=ox+x1}if(0>y1+oy){oy-=oy+y1}if(boundyboundx){xx=boundx;h=Math.abs((xx-x1)/aspect);yy=rh<0?y1-h:h+y1}}}else{xx=x2;h=rwa/aspect;yy=rh<0?y1-h:y1+h;if(yy<0){yy=0;w=Math.abs((yy-y1)*aspect);xx=rw<0?x1-w:w+x1}else{if(yy>boundy){yy=boundy;w=Math.abs(yy-y1)*aspect;xx=rw<0?x1-w:w+x1}}}if(xx>x1){if(xx-x1max_x){xx=x1+max_x}}if(yy>y1){yy=y1+(xx-x1)/aspect}else{yy=y1-(xx-x1)/aspect}}else{if(xxmax_x){xx=x1-max_x}}if(yy>y1){yy=y1+(x1-xx)/aspect}else{yy=y1-(x1-xx)/aspect}}}if(xx<0){x1-=xx;xx=0}else{if(xx>boundx){x1-=xx-boundx;xx=boundx}}if(yy<0){y1-=yy;yy=0}else{if(yy>boundy){y1-=yy-boundy;yy=boundy}}return last=makeObj(flipCoords(x1,y1,xx,yy))}function rebound(p){if(p[0]<0){p[0]=0}if(p[1]<0){p[1]=0}if(p[0]>boundx){p[0]=boundx}if(p[1]>boundy){p[1]=boundy}return[p[0],p[1]]}function flipCoords(x1,y1,x2,y2){var xa=x1,xb=x2,ya=y1,yb=y2;if(x2xlimit)){x2=(xsize>0)?(x1+xlimit):(x1-xlimit)}if(ylimit&&(Math.abs(ysize)>ylimit)){y2=(ysize>0)?(y1+ylimit):(y1-ylimit)}if(ymin&&(Math.abs(ysize)0)?(y1+ymin):(y1-ymin)}if(xmin&&(Math.abs(xsize)0)?(x1+xmin):(x1-xmin)}if(x1<0){x2-=x1;x1-=x1}if(y1<0){y2-=y1;y1-=y1}if(x2<0){x1-=x2;x2-=x2}if(y2<0){y1-=y2;y2-=y2}if(x2>boundx){var delta=x2-boundx;x1-=delta;x2-=delta}if(y2>boundy){var delta=y2-boundy;y1-=delta;y2-=delta}if(x1>boundx){var delta=x1-boundy;y2-=delta;y1-=delta}if(y1>boundy){var delta=y1-boundy;y2-=delta;y1-=delta}return makeObj(flipCoords(x1,y1,x2,y2))}function makeObj(a){return{x:a[0],y:a[1],x2:a[2],y2:a[3],w:a[2]-a[0],h:a[3]-a[1]}}return{flipCoords:flipCoords,setPressed:setPressed,setCurrent:setCurrent,getOffset:getOffset,moveOffset:moveOffset,getCorner:getCorner,getFixed:getFixed}}();var Selection=function(){var start,end,dragmode,awake,hdep=370;var borders={};var handle={};var seehandles=false;var hhs=options.handleOffset;if(options.drawBorders){borders={top:insertBorder("hline").css("top",$.browser.msie?px(-1):px(0)),bottom:insertBorder("hline"),left:insertBorder("vline"),right:insertBorder("vline")}}if(options.dragEdges){handle.t=insertDragbar("n");handle.b=insertDragbar("s");handle.r=insertDragbar("e");handle.l=insertDragbar("w")}options.sideHandles&&createHandles(["n","s","e","w"]);options.cornerHandles&&createHandles(["sw","nw","ne","se"]);function insertBorder(type){var jq=$("
").css({position:"absolute",opacity:options.borderOpacity}).addClass(cssClass(type));$img_holder.append(jq);return jq}function dragDiv(ord,zi){var jq=$("
").mousedown(createDragger(ord)).css({cursor:ord+"-resize",position:"absolute",zIndex:zi});$hdl_holder.append(jq);return jq}function insertHandle(ord){return dragDiv(ord,hdep++).css({top:px(-hhs+1),left:px(-hhs+1),opacity:options.handleOpacity}).addClass(cssClass("handle"))}function insertDragbar(ord){var s=options.handleSize,o=hhs,h=s,w=s,t=o,l=o;switch(ord){case"n":case"s":w=pct(100);break;case"e":case"w":h=pct(100);break}return dragDiv(ord,hdep++).width(w).height(h).css({top:px(-t+1),left:px(-l+1)})}function createHandles(li){for(i in li){handle[li[i]]=insertHandle(li[i])}}function moveHandles(c){var midvert=Math.round((c.h/2)-hhs),midhoriz=Math.round((c.w/2)-hhs),north=west=-hhs+1,east=c.w-hhs,south=c.h-hhs,x,y;"e" in handle&&handle.e.css({top:px(midvert),left:px(east)})&&handle.w.css({top:px(midvert)})&&handle.s.css({top:px(south),left:px(midhoriz)})&&handle.n.css({left:px(midhoriz)});"ne" in handle&&handle.ne.css({left:px(east)})&&handle.se.css({top:px(south),left:px(east)})&&handle.sw.css({top:px(south)});"b" in handle&&handle.b.css({top:px(south)})&&handle.r.css({left:px(east)})}function moveto(x,y){$img2.css({top:px(-y),left:px(-x)});$sel.css({top:px(y),left:px(x)})}function resize(w,h){$sel.width(w).height(h)}function refresh(){var c=Coords.getFixed();Coords.setPressed([c.x,c.y]);Coords.setCurrent([c.x2,c.y2]);updateVisible()}function updateVisible(){if(awake){return update()}}function update(){var c=Coords.getFixed();resize(c.w,c.h);moveto(c.x,c.y);options.drawBorders&&borders.right.css({left:px(c.w-1)})&&borders.bottom.css({top:px(c.h-1)});seehandles&&moveHandles(c);awake||show();options.onChange(unscale(c))}function show(){$sel.show();$img.css("opacity",options.bgOpacity);awake=true}function release(){disableHandles();$sel.hide();$img.css("opacity",1);awake=false}function showHandles(){if(seehandles){moveHandles(Coords.getFixed());$hdl_holder.show()}}function enableHandles(){seehandles=true;if(options.allowResize){moveHandles(Coords.getFixed());$hdl_holder.show();return true}}function disableHandles(){seehandles=false;$hdl_holder.hide()}function animMode(v){(animating=v)?disableHandles():enableHandles()}function done(){animMode(false);refresh()}var $track=newTracker().mousedown(createDragger("move")).css({cursor:"move",position:"absolute",zIndex:360});$img_holder.append($track);disableHandles();return{updateVisible:updateVisible,update:update,release:release,refresh:refresh,setCursor:function(cursor){$track.css("cursor",cursor)},enableHandles:enableHandles,enableOnly:function(){seehandles=true},showHandles:showHandles,disableHandles:disableHandles,animMode:animMode,done:done}}();var Tracker=function(){var onMove=function(){},onDone=function(){},trackDoc=options.trackDocument;if(!trackDoc){$trk.mousemove(trackMove).mouseup(trackUp).mouseout(trackUp)}function toFront(){$trk.css({zIndex:450});if(trackDoc){$(document).mousemove(trackMove).mouseup(trackUp)}}function toBack(){$trk.css({zIndex:290});if(trackDoc){$(document).unbind("mousemove",trackMove).unbind("mouseup",trackUp)}}function trackMove(e){onMove(mouseAbs(e))}function trackUp(e){e.preventDefault();e.stopPropagation();if(btndown){btndown=false;onDone(mouseAbs(e));options.onSelect(unscale(Coords.getFixed()));toBack();onMove=function(){};onDone=function(){}}return false}function activateHandlers(move,done){btndown=true;onMove=move;onDone=done;toFront();return false}function setCursor(t){$trk.css("cursor",t)}$img.before($trk);return{activateHandlers:activateHandlers,setCursor:setCursor}}();var KeyManager=function(){var $keymgr=$('').css({position:"absolute",left:"-30px"}).keypress(parseKey).blur(onBlur),$keywrap=$("
").css({position:"absolute",overflow:"hidden"}).append($keymgr);function watchKeys(){if(options.keySupport){$keymgr.show();$keymgr.focus()}}function onBlur(e){$keymgr.hide()}function doNudge(e,x,y){if(options.allowMove){Coords.moveOffset([x,y]);Selection.updateVisible()}e.preventDefault();e.stopPropagation()}function parseKey(e){if(e.ctrlKey){return true}shift_down=e.shiftKey?true:false;var nudge=shift_down?10:1;switch(e.keyCode){case 37:doNudge(e,-nudge,0);break;case 39:doNudge(e,nudge,0);break;case 38:doNudge(e,0,-nudge);break;case 40:doNudge(e,0,nudge);break;case 27:Selection.release();break;case 9:return true}return nothing(e)}if(options.keySupport){$keywrap.insertBefore($img)}return{watchKeys:watchKeys}}();function px(n){return""+parseInt(n)+"px"}function pct(n){return""+parseInt(n)+"%"}function cssClass(cl){return options.baseClass+"-"+cl}function getPos(obj){var pos=$(obj).offset();return[pos.left,pos.top]}function mouseAbs(e){return[(e.pageX-docOffset[0]),(e.pageY-docOffset[1])]}function myCursor(type){if(type!=lastcurs){Tracker.setCursor(type);lastcurs=type}}function startDragMode(mode,pos){docOffset=getPos($img);Tracker.setCursor(mode=="move"?mode:mode+"-resize");if(mode=="move"){return Tracker.activateHandlers(createMover(pos),doneSelect)}var fc=Coords.getFixed();var opp=oppLockCorner(mode);var opc=Coords.getCorner(oppLockCorner(opp));Coords.setPressed(Coords.getCorner(opp));Coords.setCurrent(opc);Tracker.activateHandlers(dragmodeHandler(mode,fc),doneSelect)}function dragmodeHandler(mode,f){return function(pos){if(!options.aspectRatio){switch(mode){case"e":pos[1]=f.y2;break;case"w":pos[1]=f.y2;break;case"n":pos[0]=f.x2;break;case"s":pos[0]=f.x2;break}}else{switch(mode){case"e":pos[1]=f.y+1;break;case"w":pos[1]=f.y+1;break;case"n":pos[0]=f.x+1;break;case"s":pos[0]=f.x+1;break}}Coords.setCurrent(pos);Selection.update()}}function createMover(pos){var lloc=pos;KeyManager.watchKeys();return function(pos){Coords.moveOffset([pos[0]-lloc[0],pos[1]-lloc[1]]);lloc=pos;Selection.update()}}function oppLockCorner(ord){switch(ord){case"n":return"sw";case"s":return"nw";case"e":return"nw";case"w":return"ne";case"ne":return"sw";case"nw":return"se";case"se":return"nw";case"sw":return"ne"}}function createDragger(ord){return function(e){if(options.disabled){return false}if((ord=="move")&&!options.allowMove){return false}btndown=true;startDragMode(ord,mouseAbs(e));e.stopPropagation();e.preventDefault();return false}}function presize($obj,w,h){var nw=$obj.width(),nh=$obj.height();if((nw>w)&&w>0){nw=w;nh=(w/$obj.width())*$obj.height()}if((nh>h)&&h>0){nh=h;nw=(h/$obj.height())*$obj.width()}xscale=$obj.width()/nw;yscale=$obj.height()/nh;$obj.width(nw).height(nh)}function unscale(c){return{x:parseInt(c.x*xscale),y:parseInt(c.y*yscale),x2:parseInt(c.x2*xscale),y2:parseInt(c.y2*yscale),w:parseInt(c.w*xscale),h:parseInt(c.h*yscale)}}function doneSelect(pos){var c=Coords.getFixed();if(c.w>options.minSelect[0]&&c.h>options.minSelect[1]){Selection.enableHandles();Selection.done()}else{Selection.release()}Tracker.setCursor(options.allowSelect?"crosshair":"default")}function newSelection(e){if(options.disabled){return false}if(!options.allowSelect){return false}btndown=true;docOffset=getPos($img);Selection.disableHandles();myCursor("crosshair");var pos=mouseAbs(e);Coords.setPressed(pos);Tracker.activateHandlers(selectDrag,doneSelect);KeyManager.watchKeys();Selection.update();e.stopPropagation();e.preventDefault();return false}function selectDrag(pos){Coords.setCurrent(pos);Selection.update()}function newTracker(){var trk=$("
").addClass(cssClass("tracker"));$.browser.msie&&trk.css({opacity:0,backgroundColor:"white"});return trk}function animateTo(a){var x1=a[0]/xscale,y1=a[1]/yscale,x2=a[2]/xscale,y2=a[3]/yscale;if(animating){return}var animto=Coords.flipCoords(x1,y1,x2,y2);var c=Coords.getFixed();var animat=initcr=[c.x,c.y,c.x2,c.y2];var interv=options.animationDelay;var x=animat[0];var y=animat[1];var x2=animat[2];var y2=animat[3];var ix1=animto[0]-initcr[0];var iy1=animto[1]-initcr[1];var ix2=animto[2]-initcr[2];var iy2=animto[3]-initcr[3];var pcent=0;var velocity=options.swingSpeed;Selection.animMode(true);var animator=function(){return function(){pcent+=(100-pcent)/velocity;animat[0]=x+((pcent/100)*ix1);animat[1]=y+((pcent/100)*iy1);animat[2]=x2+((pcent/100)*ix2);animat[3]=y2+((pcent/100)*iy2);if(pcent<100){animateStart()}else{Selection.done()}if(pcent>=99.8){pcent=100}setSelectRaw(animat)}}();function animateStart(){window.setTimeout(animator,interv)}animateStart()}function setSelect(rect){setSelectRaw([rect[0]/xscale,rect[1]/yscale,rect[2]/xscale,rect[3]/yscale])}function setSelectRaw(l){Coords.setPressed([l[0],l[1]]);Coords.setCurrent([l[2],l[3]]);Selection.update()}function setOptions(opt){if(typeof(opt)!="object"){opt={}}options=$.extend(options,opt);if(typeof(options.onChange)!=="function"){options.onChange=function(){}}if(typeof(options.onSelect)!=="function"){options.onSelect=function(){}}}function tellSelect(){return unscale(Coords.getFixed())}function tellScaled(){return Coords.getFixed()}function setOptionsNew(opt){setOptions(opt);interfaceUpdate()}function disableCrop(){options.disabled=true;Selection.disableHandles();Selection.setCursor("default");Tracker.setCursor("default")}function enableCrop(){options.disabled=false;interfaceUpdate()}function cancelCrop(){Selection.done();Tracker.activateHandlers(null,null)}function destroy(){$div.remove();$origimg.show()}function interfaceUpdate(alt){options.allowResize?alt?Selection.enableOnly():Selection.enableHandles():Selection.disableHandles();Tracker.setCursor(options.allowSelect?"crosshair":"default");Selection.setCursor(options.allowMove?"move":"default");$div.css("backgroundColor",options.bgColor);if("setSelect" in options){setSelect(opt.setSelect);Selection.done();delete (options.setSelect)}if("trueSize" in options){xscale=options.trueSize[0]/boundx;yscale=options.trueSize[1]/boundy}xlimit=options.maxSize[0]||0;ylimit=options.maxSize[1]||0;xmin=options.minSize[0]||0;ymin=options.minSize[1]||0;if("outerImage" in options){$img.attr("src",options.outerImage);delete (options.outerImage)}Selection.refresh()}$hdl_holder.hide();interfaceUpdate(true);var api={animateTo:animateTo,setSelect:setSelect,setOptions:setOptionsNew,tellSelect:tellSelect,tellScaled:tellScaled,disable:disableCrop,enable:enableCrop,cancel:cancelCrop,focus:KeyManager.watchKeys,getBounds:function(){return[boundx*xscale,boundy*yscale]},getWidgetSize:function(){return[boundx,boundy]},release:Selection.release,destroy:destroy};$origimg.data("Jcrop",api);return api};$.fn.Jcrop=function(options){function attachWhenDone(from){var loadsrc=options.useImg||from.src;var img=new Image();img.onload=function(){$.Jcrop(from,options)};img.src=loadsrc}if(typeof(options)!=="object"){options={}}this.each(function(){if($(this).data("Jcrop")){if(options=="api"){return $(this).data("Jcrop")}else{$(this).data("Jcrop").setOptions(options)}}else{attachWhenDone(this)}});return this}})(jQuery); \ No newline at end of file diff --git a/js/jcrop_init.js b/js/jcrop_init.js new file mode 100644 index 0000000..9512f74 --- /dev/null +++ b/js/jcrop_init.js @@ -0,0 +1,31 @@ +jQuery(function($){ + + // Show the preview using colorbox + $('a.colorbox').colorbox({ + 'maxHeight': '100%', + 'photo': true, + 'scalePhotos': true, + 'scrolling': false, + 'opacity': 0.8, + 'onComplete': show_jcrop + }); + + // Function to add the height, width and position to the hidden fields + function show_coords(c){ + $('#thumb_width').val(c.w); + $('#thumb_height').val(c.h); + $('#thumb_x').val(c.x); + $('#thumb_y').val(c.y); + //get the scaled image dimensions + $('#scaled_height').val($('#cboxLoadedContent').height()); + }; + function show_jcrop(){ + $('#cboxPhoto').Jcrop({ + onSelect: show_coords, + onChange: show_coords + }); + + //this shows the Options: after crop dimensions are set + $('.crop_options').show() + } +}); \ No newline at end of file diff --git a/js/manage.js b/js/manage.js new file mode 100644 index 0000000..894e124 --- /dev/null +++ b/js/manage.js @@ -0,0 +1,98 @@ +jQuery(function($){ + + // generate a slug when the user types a title in + pyro.generate_slug('input[name="title"]', 'input[name="slug"]'); + + $('.images-manage ul#gallery_images_list').sortable({ + handle: 'img', + start: function(event, ui) { + ui.helper.find('a').unbind('click').die('click'); + }, + update: function() { + order = new Array(); + $('li', this).each(function(){ + order.push( $(this).find('input[name="action_to[]"]').val() ); + }); + order = order.join(','); + + $.post(SITE_URL + 'admin/galleries/ajax_update_order', { order: order }); + } + + }).disableSelection(); + + // edit images with ajax + $(document).bind('cbox_complete',function(){ + $.colorbox.resize(); + $('#cboxLoadedContent form').bind('submit',function(){ + var action = $(this).attr('action'); + if(action.search(/admin\/files\/edit/) > -1){ + $.ajax({ + url: action, + type:'POST', + data:$(this).serialize(), + success: function(data){ + if(data.status){ + $(window).bind('notification-closed.editfile',function(e){ + console.log('winning!'); + $.colorbox.resize(); + $(window).unbind('notification-closed.editfile'); + }); + $('#cboxLoadedContent h2').after(data.message) + window.delayint = window.setInterval(function(){ + $.colorbox.resize(); + console.log('delay'); + clearInterval(window.delayint); + },120); + } + } + }); + } + return false; + }) + }) + + + // update the folder images preview when folder selection changes + $('select#folder_id').change(function(){ + + $.get(SITE_URL + 'admin/galleries/ajax_select_folder/' + $(this).val(), function(data) { + + if (data) { + $('input[name=title]').val(data.name); + $('input[name=slug]').val(data.slug); + + // remove images from last selection + $('#gallery_images_list').empty(); + $('#gallery_thumbnail optgroup, .images-manage').remove(); + + if (data.images) { + + $('#gallery_thumbnail').append( + ''+ + ''+ + '' + ); + + $.each(data.images, function(i, image){ + $('#gallery_images_list').append( + '
  • ' + + '' + image.name + '' + ); + + $('#gallery_thumbnail optgroup[label="Thumbnails"]').append( + '' + ); + }); + $('.images-placeholder').slideDown(); + } + } + else { + $('input[name=title]').val(''); + $('input[name=slug]').val(''); + $('.images-placeholder').hide(); + } + + }, 'json'); + }); +}); diff --git a/language/arabic/galleries_lang.php b/language/arabic/galleries_lang.php new file mode 100644 index 0000000..af78d41 --- /dev/null +++ b/language/arabic/galleries_lang.php @@ -0,0 +1,58 @@ + + * @date 09.02.2011 + * @version 1.0.3 + */ + +// Success notifications +$lang['galleries.create_success'] = 'Galleria luotiin onnistuneesti.'; +$lang['galleries.update_success'] = 'Galleria päivitettii onnistuneesti.'; +$lang['galleries.delete_success'] = 'Kaikki galleriat poistettiin onnistuneesti.'; +$lang['galleries.install_success'] = 'Moduuli asennettiin onnistuneesti.'; + +// Error notifications +$lang['galleries.create_error'] = 'Galleriaa ei voitu luoda.'; +$lang['galleries.exists_error'] = 'Valittua galleriaa ei löydy.'; +$lang['galleries.update_error'] = 'Galleriaa ei voitu päivittää.'; +$lang['galleries.id_error'] = 'Yhtään ID:tä ei ole määritelty.'; +$lang['galleries.folder_error'] = 'Gallerian "%s" kansioita ei voitu poistaa.'; +$lang['galleries.delete_error'] = 'Galleriaa "%s" ei voitu poistaa.'; +$lang['galleries.no_galleries_error'] = 'Yhtään galleiaa ei ole luotu vielä.'; +$lang['galleries.install_error'] = 'Moduulia ei voitu asentaa.'; +$lang['galleries.already_exist_error'] = 'Galleria polkutunnuksella "%s" on jo olemassa.'; +$lang['galleries.folder_duplicated_error'] = 'Virhe on tapahtunut! Kansio kuuluu jo gallerialle.'; +$lang['galleries.no_gallery_description'] = 'Kuvausta ei ole vielä lisätty.'; + +// Labels +$lang['galleries.galleries_label'] = 'Galleriat'; +$lang['galleries.manage_gallery_label'] = 'Hallitse galleriaa'; + +$lang['galleries.gallery_label'] = 'Albumi'; +$lang['galleries.num_photos_label'] = 'Kuvia'; +$lang['galleries.updated_label'] = 'Viimeksi päivitetty'; +$lang['galleries.view_label'] = 'Katso'; +$lang['galleries.manage_label'] = 'Hallitse'; +$lang['galleries.comments_enabled_label'] = 'Kyllä'; +$lang['galleries.comments_disabled_label'] = 'Ei'; +$lang['galleries.published_yes_label'] = 'Kyllä'; +$lang['galleries.published_no_label'] = 'Ei'; +$lang['galleries.css_label'] = 'CSS'; +$lang['galleries.js_label'] = 'JavaScript'; + +// General labels $lang['galleries.preview_label'] = 'Folder Images Preview'; $lang['galleries.no_thumb_label'] = 'No Thumbnail'; +$lang['galleries.title_label'] = 'Otsikko'; +$lang['galleries.slug_label'] = 'Polkutunnus'; +$lang['galleries.parent_label'] = 'Yläkohta'; +$lang['galleries.none_label'] = '-- Ei mikään --'; +$lang['galleries.description_label'] = 'Albumin kuvaus'; +$lang['galleries.thumbnail_label'] = 'Esikatselu'; +$lang['galleries.comments_label'] = 'Kommentit päälle'; +$lang['galleries.published_label'] = 'Julkaistu'; +$lang['galleries.current_label'] = 'Nykyiset kuvat (raahaa järjestelläksesi, klikkaa muokataksesi)'; + +// Sidebar labels +$lang['galleries.list_label'] = 'Listaa galleriat'; +$lang['galleries.new_gallery_label'] = 'Luo uusi galleria'; +$lang['galleries.upload_label'] = 'Lisää kuva'; + +// Frontend labels +$lang['galleries.sub-galleries_label'] = 'Ala galleriat'; + +// tabs +$lang['galleries.content_label'] = 'Gallerian sisältö'; +$lang['galleries.design_label'] = 'Design'; +$lang['galleries.script_label'] = 'Script'; +?> diff --git a/language/finnish/gallery_images_lang.php b/language/finnish/gallery_images_lang.php new file mode 100644 index 0000000..2ce91cf --- /dev/null +++ b/language/finnish/gallery_images_lang.php @@ -0,0 +1,34 @@ + + * @date 09.02.2011 + * @version 1.0.3 + */ + +// Success messages +$lang['gallery_images.upload_success'] = 'Kuva lisättiin onnistuneesti.'; +$lang['gallery_images.delete_success'] = 'Kuva poistettiin.'; +$lang['gallery_images.changes_success'] = 'Muutokset tallennettiin.'; + +// Errors +$lang['gallery_images.upload_error'] = 'Kuvaa ei voitu lisätä.'; +$lang['gallery_images.exists_error'] = 'Valittua kuvaa ei löydy.'; +$lang['gallery_images.delete_error'] = 'Kuvaa ei voitu poistaa.'; +$lang['gallery_images.changes_error'] = 'Muutoksia ei voitu tallentaa.'; + +// Labels +$lang['gallery_images.upload_label'] = 'Lisää kuva'; +$lang['gallery_images.edit_image_label'] = 'Muokkaa kuvaa'; +$lang['gallery_images.thumbnail_label'] = 'Esikatselu'; +$lang['gallery_images.crop_label'] = 'Rajaa kuva'; +$lang['gallery_images.recreate_label'] = 'Luo esikatselu kuva uudelleen'; +$lang['gallery_images.title_label'] = 'Otsikko'; +$lang['gallery_images.image_label'] = 'Kuva'; +$lang['gallery_images.description_label'] = 'Kuvateksti'; +$lang['gallery_images.gallery_label'] = 'Galleria'; +$lang['gallery_images.no_images_label'] = 'Kuvia ei vielä ole lisätty'; +$lang['gallery_images.ratio_label'] = 'Säilytä kuvasuhde'; +$lang['gallery_images.options_label'] = 'Asetukset:'; +$lang['gallery_images.crop.save_label'] = 'Tallenna rajaus'; \ No newline at end of file diff --git a/language/french/galleries_lang.php b/language/french/galleries_lang.php new file mode 100644 index 0000000..f7044c0 --- /dev/null +++ b/language/french/galleries_lang.php @@ -0,0 +1,58 @@ +set_new_image_files($id); + + // Clear old files on images + $this->unset_old_image_files($id); + + if (isset($options['offset'])) + { + $this->db->offset($options['offset']); + } + + if (isset($options['limit'])) + { + $this->db->limit($options['limit']); + } + + // Grand finale, do what you gotta do!! + $images = $this->db + // Select fields on gallery images table + ->select('gallery_images.*, files.name, files.filename, files.extension, files.description, files.name as title, galleries.folder_id, galleries.slug as gallery_slug, galleries.title as gallery_title') + // Set my gallery by id + ->where('galleries.id', $id) + // Filter images from my gallery + ->join('galleries', 'galleries.id = gallery_images.gallery_id', 'left') + // Filter from my images + ->join('files', 'files.id = gallery_images.file_id', 'left') + // Filter files type image + ->where('files.type', 'i') + // Order by user order + ->order_by('`order`', 'asc') + // Get all! + ->get('gallery_images') + ->result(); + + return $images; + } + + public function set_new_image_files($gallery_id = 0) + { + $this->db + // Select fields on files table + ->select('files.id as file_id, galleries.id as gallery_id') + ->from('files') + // Set my gallery by id + ->where('galleries.id', $gallery_id) + // Filter from my gallery folder + ->join('galleries', 'galleries.folder_id = files.folder_id', 'left') + // Filter files type image + ->where('files.type', 'i') + // Not require image from my gallery in gallery images, prevent duplication + ->ar_where[] = "AND `" . $this->db->dbprefix('files') . "`.`id` NOT IN (SELECT file_id FROM (" . $this->db->dbprefix('gallery_images') . ") WHERE `gallery_id` = '$gallery_id')"; + + // Already updated, nothing to do here.. + if ( ! $new_images = $this->db->get()->result()) + { + return FALSE; + } + + // Get the last position of order count + $last_image = $this->db + ->select('`order`') + ->order_by('`order`', 'desc') + ->limit(1) + ->get_where('gallery_images', array('gallery_id' => $gallery_id)) + ->row(); + + $order = isset($last_image->order) ? $last_image->order + 1: 1; + + // Insert new images, increasing the order + foreach ($new_images as $new_image) + { + $this->db->insert('gallery_images', array( + 'gallery_id' => $new_image->gallery_id, + 'file_id' => $new_image->file_id, + '`order`' => $order++ + )); + } + + return TRUE; + } + + public function unset_old_image_files($gallery_id = 0) + { + $not_in = array(); + + // Get all image from folder of my gallery... + $images = $this->db + ->select('files.id') + ->from('files') + ->join('galleries', 'galleries.folder_id = files.folder_id') + ->where('files.type', 'i') + ->where('galleries.id', $gallery_id) + ->get() + ->result(); + + if (count($images) > 0) + { + foreach ($images AS $item) + { + $not_in[] = $item->id; + } + + $this->db + // Select fields on gallery images table + ->select('gallery_images.id') + ->from('gallery_images') + // Set my gallery by id + ->where('galleries.id', $gallery_id) + // Filter images from my gallery + ->join('galleries', 'galleries.id = gallery_images.gallery_id') + // Get all images that are no longer in a gallery + ->where_not_in('file_id', $not_in); + + // Already updated, nothing to do here.. + if ( ! $old_images = $this->db->get()->result()) + { + return FALSE; + } + + // Remove missing files images + foreach ($old_images as $old_image) + { + $this->gallery_image_m->delete($old_image->id); + } + } + + return TRUE; + } + + /** + * Preview images from folder + * + * @author Jerel Unruh - PyroCMS Dev Team + * @access public + * @param int $id The ID of the folder + * @param array $options Options + * @return mixed + */ + public function get_images_by_file_folder($id, $options = array()) + { + + if (isset($options['offset'])) + { + $this->db->limit($options['offset']); + } + + if (isset($options['limit'])) + { + $this->db->limit($options['limit']); + } + + // Grand finale, do what you gotta do!! + $images = $this->db + ->select('files.*') + ->where('folder_id', $id) + ->where('files.type', 'i') + ->get('files') + ->result(); + + return $images; + } + + /** + * Get an image along with the gallery slug + * + * @author PyroCMS Dev Team + * @access public + * @param int $id The ID of the image + * @return mixed + */ + public function get($id) + { + $query = $this->db + ->select('gallery_images.*, files.name, files.filename, files.extension, files.description, files.name as title, galleries.folder_id, galleries.slug as gallery_slug') + ->join('galleries', 'gallery_images.gallery_id = galleries.id', 'left') + ->join('files', 'files.id = gallery_images.file_id', 'left') + ->where('gallery_images.id', $id) + ->get('gallery_images'); + + if ( $query->num_rows() > 0 ) + { + return $query->row(); + } + else + { + return FALSE; + } + } + +} \ No newline at end of file diff --git a/models/gallery_m.php b/models/gallery_m.php new file mode 100644 index 0000000..0bf08f2 --- /dev/null +++ b/models/gallery_m.php @@ -0,0 +1,150 @@ +db + ->select('galleries.*, file_folders.slug as folder_slug, file_folders.name as folder_name') + ->join('file_folders', 'file_folders.id = galleries.folder_id', 'left'); + + $galleries = parent::get_all(); + $results = array(); + + // Loop through each gallery and add the count of photos to the results + foreach ($galleries as $gallery) + { + $count = $this->db + ->select('files.id') + ->join('galleries', 'galleries.folder_id = files.folder_id', 'left') + ->where('files.type', 'i') + ->where('galleries.id', $gallery->id) + ->count_all_results('files'); + + $gallery->photo_count = $count; + $results[] = $gallery; + } + + // Return the results + return $results; + } + + /** + * Get all galleries along with the thumbnail's filename and extension + * + * @access public + * @return mixed + */ + public function get_all_with_filename($where = NULL, $value = NULL) + { + $this->db + ->select('galleries.*, files.filename, files.extension, files.id as file_id, file_folders.parent_id as parent') + ->from('galleries') + ->join('gallery_images', 'gallery_images.file_id = galleries.thumbnail_id', 'left') + ->join('files', 'files.id = gallery_images.file_id', 'left') + ->join('file_folders', 'file_folders.id = galleries.folder_id', 'left') + ->where('galleries.published', '1'); + + // Where clause provided? + if ( ! empty($where) AND ! empty($value)) + { + $this->db->where($where, $value); + } + + return $this->db->get()->result(); + } + + /** + * Insert a new gallery into the database + * + * @author PyroCMS Dev Team + * @access public + * @param array $input The data to insert (a copy of $_POST) + * @return bool + */ + public function insert($input) + { + if (is_array($input['folder_id'])) + { + $folder = $input['folder_id']; + + $input['folder_id'] = $this->file_folders_m->insert(array( + 'name' => $folder['name'], + 'parent_id' => 0, + 'slug' => $folder['slug'], + 'date_added' => now() + )); + } + + return (int) parent::insert(array( + 'title' => $input['title'], + 'slug' => $input['slug'], + 'folder_id' => $input['folder_id'], + 'thumbnail_id' => ! empty($input['gallery_thumbnail']) ? (int) $input['gallery_thumbnail'] : NULL, + 'description' => $input['description'], + 'enable_comments' => $input['enable_comments'], + 'published' => $input['published'], + 'updated_on' => time(), + 'css' => $input['css'], + 'js' => $input['js'] + )); + } + + /** + * Update an existing gallery + * + * @author PyroCMS Dev Team + * @access public + * @param int $id The ID of the row to update + * @param array $input The data to use for updating the DB record + * @return bool + */ + public function update($id, $input) + { + return parent::update($id, array( + 'title' => $input['title'], + 'slug' => $input['slug'], + 'folder_id' => $input['folder_id'], + 'description' => $input['description'], + 'enable_comments' => $input['enable_comments'], + 'thumbnail_id' => ! empty($input['gallery_thumbnail']) ? (int) $input['gallery_thumbnail'] : NULL, + 'published' => $input['published'], + 'updated_on' => time(), + 'css' => $input['css'], + 'js' => $input['js'] + )); + } + + /** + * Callback method for validating the slug + * @access public + * @param string $slug The slug to validate + * @param int $id The id of gallery + * @return bool + */ + public function check_slug($slug = '', $id = 0) + { + return parent::count_by(array( + 'id !=' => $id, + 'slug' => $slug) + ) > 0; + } + +} \ No newline at end of file diff --git a/plugin.php b/plugin.php new file mode 100644 index 0000000..89fb470 --- /dev/null +++ b/plugin.php @@ -0,0 +1,78 @@ + + * {{ description }} + * + * {{ /galleries:images }} + * + * The following is a list of tags that are available to use from this method + * + * {{ file_id }} + * {{ folder_id }} + * {{ gallery_id }} + * {{ gallery_slug }} + * {{ title }} + * {{ order }} + * {{ name }} + * {{ filename }} + * {{ description }} + * {{ extension }} + * + * @return array + */ + function images() + { + $limit = $this->attribute('limit'); + $slug = $this->attribute('slug'); + $offset = $this->attribute('offset'); + + $this->load->model(array( + 'gallery_m', + 'gallery_image_m' + )); + + $gallery = $this->gallery_m->get_by('slug', $slug); + + return $gallery ? $this->gallery_image_m->get_images_by_gallery($gallery->id, array( + 'limit' => $limit, + 'offset' => $offset + )) : array(); + } + + /** + * Gallery exists + * + * Check if a gallery exists + * + * @return int 0 or 1 + */ + function exists() + { + $slug = $this->attribute('slug'); + + $this->load->model('gallery_m'); + + return (int) ($slug ? $this->gallery_m->count_by('slug', $slug) > 0 : FALSE); + } +} + +/* End of file plugin.php */ \ No newline at end of file diff --git a/views/admin/form.php b/views/admin/form.php new file mode 100644 index 0000000..b8c4624 --- /dev/null +++ b/views/admin/form.php @@ -0,0 +1,164 @@ +
    + method === 'create'): ?> +

    + +

    title); ?>

    + +
    + +
    + + $gallery->folder_id)); ?> + +
    + +
      +
    • +
    • +
    • +
    + + + + + + + + + +
    + +
    + load->view('admin/partials/buttons', array('buttons' => array('save', 'save_exit', 'cancel') )); ?> +
    + + + + +
    \ No newline at end of file diff --git a/views/admin/image/preview.php b/views/admin/image/preview.php new file mode 100644 index 0000000..10c909b --- /dev/null +++ b/views/admin/image/preview.php @@ -0,0 +1,11 @@ +

    title; ?>

    + +

    + gallery_slug . '/' . $image->id, NULL, 'target="_blank"'); ?> +

    + +

    + gallery_id, lang('galleries.manage_label'), ' target="_parent"'); ?> +

    + + \ No newline at end of file diff --git a/views/admin/index.php b/views/admin/index.php new file mode 100644 index 0000000..19522e1 --- /dev/null +++ b/views/admin/index.php @@ -0,0 +1,60 @@ +
    +

    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    'action_to_all', 'class' => 'check-all'));?>
    +
    load->view('admin/partials/pagination'); ?>
    +
    id); ?>id, $gallery->title, 'target="_blank" class="modal-large"'); ?>photo_count; ?>updated_on); ?> + folder_id && isset($folders[$gallery->folder_id]) && $path = $folders[$gallery->folder_id]->virtual_path): ?> + + + id, lang('galleries.manage_label'), 'class="button"'); ?> + id, lang('global:delete'), array('class'=>'confirm button delete')); ?> +
    + +
    + load->view('admin/partials/buttons', array('buttons' => array('delete') )); ?> +
    + + +
    +
    + 'No Galleries')); ?> + +
    +
    + + + +
    \ No newline at end of file diff --git a/views/admin/preview.php b/views/admin/preview.php new file mode 100644 index 0000000..556f6a4 --- /dev/null +++ b/views/admin/preview.php @@ -0,0 +1,11 @@ +

    title; ?>

    + +

    + slug, NULL, 'target="_blank"'); ?> +

    + +

    + id, lang('galleries.manage_label'), ' target="_parent"'); ?> +

    + + \ No newline at end of file diff --git a/views/gallery.php b/views/gallery.php new file mode 100644 index 0000000..efb66eb --- /dev/null +++ b/views/gallery.php @@ -0,0 +1,53 @@ +

    title; ?>

    + + +
    + +

    + +
    + + + +
    + +
    + +enable_comments == 1): ?> + id);?> + \ No newline at end of file diff --git a/views/image.php b/views/image.php new file mode 100644 index 0000000..04c65b5 --- /dev/null +++ b/views/image.php @@ -0,0 +1,19 @@ +

    name; ?>

    + + +enable_comments == 1): ?> + id, 'gallery-image'); ?> + \ No newline at end of file diff --git a/views/index.php b/views/index.php new file mode 100644 index 0000000..5feb991 --- /dev/null +++ b/views/index.php @@ -0,0 +1,29 @@ +

    + + \ No newline at end of file