From 66dd3f3f5f14bb0ba6d2c7ef83b5b612d5ee2e30 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 15 Mar 2014 15:04:14 -0300 Subject: Squashed 'mod/lightbox/' content from commit a83b8d8 git-subtree-dir: mod/lightbox git-subtree-split: a83b8d89691c31b4568f47790fb40d0bc962aca5 --- actions/lightbox/edit.php | 91 +++++++++++ classes/LightboxPluginAlbum.php | 31 ++++ classes/LightboxPluginImage.php | 31 ++++ graphics/defaultmedium.jpg | Bin 0 -> 7036 bytes graphics/defaultsmall.jpg | Bin 0 -> 2393 bytes graphics/defaulttiny.jpg | Bin 0 -> 1733 bytes languages/en.php | 76 +++++++++ lib/lightbox.php | 107 +++++++++++++ manifest.xml | 18 +++ pages/lightbox/friends.php | 34 ++++ pages/lightbox/new.php | 37 +++++ pages/lightbox/owner.php | 55 +++++++ pages/lightbox/view.php | 39 +++++ pages/lightbox/world.php | 33 ++++ start.php | 190 +++++++++++++++++++++++ thumbnail.php | 55 +++++++ vendors/lightbox/images/lightbox-blank.gif | Bin 0 -> 43 bytes vendors/lightbox/images/lightbox-btn-close.gif | Bin 0 -> 700 bytes vendors/lightbox/images/lightbox-btn-next.gif | Bin 0 -> 812 bytes vendors/lightbox/images/lightbox-btn-prev.gif | Bin 0 -> 832 bytes vendors/lightbox/images/lightbox-ico-loading.gif | Bin 0 -> 3990 bytes vendors/lightbox/jquery.lightbox-0.5.css | 101 ++++++++++++ vendors/lightbox/jquery.lightbox-0.5.min.js | 42 +++++ views/default/forms/lightbox/edit.php | 74 +++++++++ views/default/forms/lightbox/images/edit.php | 0 views/default/js/lightbox/album.php | 8 + views/default/lightbox/image.php | 16 ++ views/default/object/album.php | 117 ++++++++++++++ views/default/object/image.php | 100 ++++++++++++ 29 files changed, 1255 insertions(+) create mode 100644 actions/lightbox/edit.php create mode 100644 classes/LightboxPluginAlbum.php create mode 100644 classes/LightboxPluginImage.php create mode 100644 graphics/defaultmedium.jpg create mode 100644 graphics/defaultsmall.jpg create mode 100644 graphics/defaulttiny.jpg create mode 100644 languages/en.php create mode 100644 lib/lightbox.php create mode 100644 manifest.xml create mode 100644 pages/lightbox/friends.php create mode 100644 pages/lightbox/new.php create mode 100644 pages/lightbox/owner.php create mode 100644 pages/lightbox/view.php create mode 100644 pages/lightbox/world.php create mode 100644 start.php create mode 100644 thumbnail.php create mode 100644 vendors/lightbox/images/lightbox-blank.gif create mode 100644 vendors/lightbox/images/lightbox-btn-close.gif create mode 100644 vendors/lightbox/images/lightbox-btn-next.gif create mode 100644 vendors/lightbox/images/lightbox-btn-prev.gif create mode 100644 vendors/lightbox/images/lightbox-ico-loading.gif create mode 100644 vendors/lightbox/jquery.lightbox-0.5.css create mode 100644 vendors/lightbox/jquery.lightbox-0.5.min.js create mode 100644 views/default/forms/lightbox/edit.php create mode 100644 views/default/forms/lightbox/images/edit.php create mode 100644 views/default/js/lightbox/album.php create mode 100644 views/default/lightbox/image.php create mode 100644 views/default/object/album.php create mode 100644 views/default/object/image.php diff --git a/actions/lightbox/edit.php b/actions/lightbox/edit.php new file mode 100644 index 000000000..6ee49e671 --- /dev/null +++ b/actions/lightbox/edit.php @@ -0,0 +1,91 @@ + 0) { + $new_album = false; +} + +if ($new_album) { + + $album = new LightboxPluginAlbum(); + +} else { + // load original album object + $album = new LightboxPluginAlbum($guid); + + // user must be able to edit album + if (!$album->guid || !$album->canEdit()) { + register_error(elgg_echo('lightbox:noaccess')); + forward(REFERER); + } + + if (!$title) { + // user blanked title, but we need one + $title = $album->title; + } +} + +$album->title = $title; +$album->description = $desc; +$album->access_id = $access_id; +$album->container_guid = $container_guid; +$album->tags = string_to_tag_array($tags); + +$guid = $album->save(); + +// lightbox saved so clear sticky form +elgg_clear_sticky_form('lightbox:album'); + + +// handle results differently for new albums and album updates +if ($new_album) { + if ($guid && $album->attachImages($images)) { + system_message(elgg_echo("lightbox:saved")); + add_to_river('river/object/album/create', 'create', elgg_get_logged_in_user_guid(), $album->guid); + forward("photos/edit/images/$guid"); + } else { + // failed to save album object - nothing we can do about this + lightbox_delete_image_inputs($images); + register_error(elgg_echo("lightbox:save:failed")); + if (get_entity($container_guid)->getType() == 'group') { + forward("photos/group/$container->guid/all"); + } else { + forward("photos/owner/$container->username"); + } + } + + + +} else { + if ($guid) { + system_message(elgg_echo("lightbox:saved")); + } else { + lightbox_delete_image_inputs($images); + register_error(elgg_echo("lightbox:save:failed")); + } + + forward($album->getURL()); +} diff --git a/classes/LightboxPluginAlbum.php b/classes/LightboxPluginAlbum.php new file mode 100644 index 000000000..de272d981 --- /dev/null +++ b/classes/LightboxPluginAlbum.php @@ -0,0 +1,31 @@ +attributes['subtype'] = "album"; + } + + public function __construct($guid = null) { + parent::__construct($guid); + } + + public function attachImages($images) { + foreach($images as $image) { + if($image instanceof LightboxPluginImage) { + $this->addRelationship($image->guid, 'in_album'); + } else { + return false; + } + } + return true; + } + + public function delete() { + return parent::delete(); + } +} diff --git a/classes/LightboxPluginImage.php b/classes/LightboxPluginImage.php new file mode 100644 index 000000000..6d2b6bbea --- /dev/null +++ b/classes/LightboxPluginImage.php @@ -0,0 +1,31 @@ +attributes['subtype'] = "image"; + } + + public function __construct($guid = null) { + parent::__construct($guid); + } + + public function delete() { + + $thumbnails = array($this->thumbnail, $this->smallthumb, $this->largethumb); + foreach ($thumbnails as $thumbnail) { + if ($thumbnail) { + $delfile = new ElggFile(); + $delfile->owner_guid = $this->owner_guid; + $delfile->setFilename($thumbnail); + $delfile->delete(); + } + } + + return parent::delete(); + } +} diff --git a/graphics/defaultmedium.jpg b/graphics/defaultmedium.jpg new file mode 100644 index 000000000..23494eff2 Binary files /dev/null and b/graphics/defaultmedium.jpg differ diff --git a/graphics/defaultsmall.jpg b/graphics/defaultsmall.jpg new file mode 100644 index 000000000..2d8745bb6 Binary files /dev/null and b/graphics/defaultsmall.jpg differ diff --git a/graphics/defaulttiny.jpg b/graphics/defaulttiny.jpg new file mode 100644 index 000000000..2a656fe23 Binary files /dev/null and b/graphics/defaulttiny.jpg differ diff --git a/languages/en.php b/languages/en.php new file mode 100644 index 000000000..4c85d916b --- /dev/null +++ b/languages/en.php @@ -0,0 +1,76 @@ + "Albums", + 'lightbox:user' => "%s's albums", + 'lightbox:friends' => "Friends' albums", + 'lightbox:all' => "All site albums", + 'lightbox:edit' => "Edit album info", + 'lightbox:more' => "More albums", + 'lightbox:group' => "Group albums", + 'lightbox:num_albums' => "Number of albums to display", + 'lightbox:via' => 'via images', + 'photos:add' => "Create new album", + + 'lightbox:title' => "Title", + 'lightbox:description' => "Description", + 'lightbox:tags' => "Tags", + + 'lightbox:image:upload' => 'Upload and image', + 'lightbox:image:upload:another' => 'Upload another image', + 'lightbox:image:replace' => 'Replace image content (leave blank to not change image)', + 'lightbox:image:title' => 'Title', + 'lightbox:image:description' => 'Description', + + + 'lightbox:widget' => "Albums widget", + 'lightbox:widget:description' => "Showcase your albums", + + 'groups:enablelightbox' => 'Enable group albums', + + 'lightbox:download' => "Download this", + + 'lightbox:delete:confirm' => "Are you sure you want to delete this album and all it's images?", + + 'lightbox:display:number' => "Number of albums to display", + + 'river:create:object:album' => '%s created the album %s', + 'river:comment:object:album' => '%s commented on the album %s', + 'river:comment:object:image' => '%s commented on the image %s', + + 'item:object:image' => 'Images', + 'item:object:album' => 'Image albums', + + /** + * Status messages + */ + + 'lightbox:saved' => "Your album was successfully saved.", + 'lightbox:image:saved' => "Your image was successfully saved.", + + 'lightbox:deleted' => "Your album was successfully deleted.", + 'lightbox:image:deleted' => "This image was successfully deleted.", + + + /** + * Error messages + */ + + 'lightbox:none' => "No albums.", + 'lightbox:image:none' => "No images on this album.", + 'lightbox:save:failed' => "Sorry; we could not save your album.", + 'lightbox:delete:failed' => "Your album could not be deleted at this time.", + 'lightbox:noaccess' => "You do not have permissions to change this album", + 'lightbox:nofile' => "You must select an image", +); + +add_translation("en", $english); diff --git a/lib/lightbox.php b/lib/lightbox.php new file mode 100644 index 000000000..6b557d241 --- /dev/null +++ b/lib/lightbox.php @@ -0,0 +1,107 @@ + $sent_file) { + if (empty($sent_file['name'])) { + continue; + } + if($sent_file['error'] != 0) { + register_error(elgg_echo('file:cannotload')); + forward(REFERER); + } + $mime_type = $file->detectMimeType($sent_file['tmp_name'], $sent_file['type']); + if(file_get_simple_type($mime_type) != "image"){ + register_error(elgg_echo('lightbox:noimage')); + forward(REFERER); + } + } + + foreach($_FILES as $key => $sent_file) { + + if (empty($sent_file['name'])) { + continue; + } + + $file = new LightboxPluginImage(); + + $prefix = "image/"; + $filestorename = elgg_strtolower(time().$sent_file['name']); + + $mime_type = $file->detectMimeType($sent_file['tmp_name'], $sent_file['type']); + $file->setFilename($prefix . $filestorename); + $file->setMimeType($mime_type); + $file->originalfilename = $sent_file['name']; + $file->simpletype = "image"; + + // Open the file to guarantee the directory exists + $file->open("write"); + $file->close(); + move_uploaded_file($sent_file['tmp_name'], $file->getFilenameOnFilestore()); + + // We need to create thumbnails (this should be moved into a function) + if ($file->save()) { + $thumbnail = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),60,60, true); + if ($thumbnail) { + $thumb = new ElggFile(); + $thumb->setMimeType($_FILES['upload']['type']); + + $thumb->setFilename($prefix."thumb".$filestorename); + $thumb->open("write"); + $thumb->write($thumbnail); + $thumb->close(); + + $file->thumbnail = $prefix."thumb".$filestorename; + unset($thumbnail); + } + + $thumbsmall = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),153,153, true); + if ($thumbsmall) { + $thumb->setFilename($prefix."smallthumb".$filestorename); + $thumb->open("write"); + $thumb->write($thumbsmall); + $thumb->close(); + $file->smallthumb = $prefix."smallthumb".$filestorename; + unset($thumbsmall); + } + + $thumblarge = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),600,600, false); + if ($thumblarge) { + $thumb->setFilename($prefix."largethumb".$filestorename); + $thumb->open("write"); + $thumb->write($thumblarge); + $thumb->close(); + $file->largethumb = $prefix."largethumb".$filestorename; + unset($thumblarge); + } + + $files[$file->guid] = $file; + } + } + + return $files; +} + +/** + * Delete uploaded images if album creation fails + * + * @params array $images Array of LightboxPluginImages + * @return null + */ +function lightbox_delete_image_inputs($images) { + //TODO +} diff --git a/manifest.xml b/manifest.xml new file mode 100644 index 000000000..9c28ec859 --- /dev/null +++ b/manifest.xml @@ -0,0 +1,18 @@ + + + Lightbox + Lorea developers + 0.1 + bundled + media + widget + Lightbox Photo Gallery + https://lorea.cc/ + (C) Lorea 2011 + GNU General Public License version 2 + + elgg_release + 1.8 + + true + diff --git a/pages/lightbox/friends.php b/pages/lightbox/friends.php new file mode 100644 index 000000000..6b0bbb03e --- /dev/null +++ b/pages/lightbox/friends.php @@ -0,0 +1,34 @@ +name, "photos/owner/$owner->username"); +elgg_push_breadcrumb(elgg_echo('friends')); + +elgg_register_title_button(); + +$title = elgg_echo("lightbox:friends"); + +// offset is grabbed in list_user_friends_objects +$content = list_user_friends_objects($owner->guid, 'albums', 10, false); +if (!$content) { + $content = elgg_echo("lightbox:none"); +} + +$body = elgg_view_layout('content', array( + 'filter_context' => 'friends', + 'content' => $content, + 'title' => $title, + 'sidebar' => $sidebar, +)); + +echo elgg_view_page($title, $body); diff --git a/pages/lightbox/new.php b/pages/lightbox/new.php new file mode 100644 index 000000000..117aba293 --- /dev/null +++ b/pages/lightbox/new.php @@ -0,0 +1,37 @@ +name, "photos/owner/$owner->username"); +} else { + elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all"); +} +elgg_push_breadcrumb($title); + +// create form +$form_vars = array('enctype' => 'multipart/form-data'); +$body_vars = array(); +$content = elgg_view_form('lightbox/edit', $form_vars, $body_vars); + +$body = elgg_view_layout('content', array( + 'content' => $content, + 'title' => $title, + 'filter' => '', +)); + +echo elgg_view_page($title, $body); diff --git a/pages/lightbox/owner.php b/pages/lightbox/owner.php new file mode 100644 index 000000000..536790906 --- /dev/null +++ b/pages/lightbox/owner.php @@ -0,0 +1,55 @@ +name); + +elgg_register_title_button(); + +$params = array(); + +if ($owner->guid == elgg_get_logged_in_user_guid()) { + // user looking at own albums + $params['filter_context'] = 'mine'; +} else if (elgg_instanceof($owner, 'user')) { + // someone else's albums + // do not show select a tab when viewing someone else's posts + $params['filter_context'] = 'none'; +} else { + // group albums + $params['filter'] = ''; +} + +$title = elgg_echo("lightbox:user", array($owner->name)); + +// List albums +$content = elgg_list_entities(array( + 'types' => 'object', + 'subtypes' => 'album', + 'container_guid' => $owner->guid, + 'limit' => 10, + 'full_view' => FALSE, +)); +if (!$content) { + $content = elgg_echo("lightbox:none"); +} + +$params['content'] = $content; +$params['title'] = $title; +$params['sidebar'] = elgg_view('lightbox/sidebar'); + +$body = elgg_view_layout('content', $params); + +echo elgg_view_page($title, $body); diff --git a/pages/lightbox/view.php b/pages/lightbox/view.php new file mode 100644 index 000000000..6fa703895 --- /dev/null +++ b/pages/lightbox/view.php @@ -0,0 +1,39 @@ +getContainerEntity(); + +elgg_push_breadcrumb(elgg_echo('lightbox'), 'photos/all'); + +$crumbs_title = $owner->name; +if (elgg_instanceof($owner, 'group')) { + elgg_push_breadcrumb($crumbs_title, "photos/group/$owner->guid/all"); +} else { + elgg_push_breadcrumb($crumbs_title, "photos/owner/$owner->username"); +} + +if($entity->countEntitiesFromRelationship('in_album', true) > 0) { + $album = $entity->getEntitiesFromRelationship('in_album', true, 1); + elgg_push_breadcrumb($album[0]->title, $album[0]->getURL()); +} + +$title = $entity->title; + +elgg_push_breadcrumb($title); + +$content = elgg_view_entity($entity, array('full_view' => true)); +$content .= elgg_view_comments($entity); + +$body = elgg_view_layout('content', array( + 'content' => $content, + 'title' => $title, + 'filter' => '', +)); + +echo elgg_view_page($title, $body); diff --git a/pages/lightbox/world.php b/pages/lightbox/world.php new file mode 100644 index 000000000..6262faa1e --- /dev/null +++ b/pages/lightbox/world.php @@ -0,0 +1,33 @@ + 'object', + 'subtypes' => 'album', + 'limit' => $limit, + 'full_view' => FALSE, +)); +if (!$content) { + $content = elgg_echo('lightbox:none'); +} + +$body = elgg_view_layout('content', array( + 'filter_context' => 'all', + 'content' => $content, + 'title' => $title, + 'sidebar' => elgg_view('lightbox/sidebar'), +)); + +echo elgg_view_page($title, $body); diff --git a/start.php b/start.php new file mode 100644 index 000000000..c79ab100b --- /dev/null +++ b/start.php @@ -0,0 +1,190 @@ + + * Friends' albums: photos/friends/ + * View album: photos/album// + * View photo: photos/view/<guid>/<title> + * New album: photos/add/<guid> + * Edit album: photos/edit/<guid> + * Group albums: photos/group/<guid>/all + * Download: photos/download/<guid> + * + * Title is ignored + * + * @param array $page + * @return bool + */ +function lightbox_page_handler($page) { + + if (!isset($page[0])) { + $page[0] = 'all'; + } + + $pages_dir = elgg_get_plugins_path() . 'lightbox/pages/lightbox'; + + $page_type = $page[0]; + switch ($page_type) { + case 'owner': + include "$pages_dir/owner.php"; + break; + case 'friends': + include "$pages_dir/friends.php"; + break; + case 'album': + case 'view': + set_input('guid', $page[1]); + include "$pages_dir/view.php"; + break; + case 'add': + include "$pages_dir/new.php"; + break; + case 'edit': + set_input('guid', $page[1]); + include "$pages_dir/edit.php"; + break; + case 'group': + include "$pages_dir/owner.php"; + break; + case 'all': + include "$pages_dir/world.php"; + break; + case 'download': + set_input('guid', $page[1]); + include "$pages_dir/download.php"; + break; + default: + return false; + } + return true; +} + +/** + * Populates the ->getUrl() method for photo and album objects + * + * @param ElggEntity $entity Photo or album entity + * @return string Photo or album URL + */ +function lightbox_url($entity) { + $title = elgg_get_friendly_title($entity->name); + + if($entity->getSubtype() == 'album') { + return "photos/album/{$entity->guid}/$title"; + } else { + return "photos/view/{$entity->guid}/$title"; + } +} + +/** + * Override the default entity icon for photos and albums + * + * @return string Relative URL + */ +function lightbox_icon_url_override($hook, $type, $returnvalue, $params) { + + $entity = $params['entity']; + $size = $params['size']; + + if(in_array($entity->getSubtype(), array('image', 'album'))) { + if (isset($entity->thumbnail) || isset($entity->cover)) { + // return thumbnail + return "mod/lightbox/thumbnail.php?guid=$entity->guid&size=$size"; + } + + return "mod/lightbox/graphics/default{$size}.jpg"; + } +} + +/** + * Add a menu item to the user ownerblock + */ +function lightbox_owner_block_menu($hook, $type, $return, $params) { + if (elgg_instanceof($params['entity'], 'user')) { + $url = "photos/owner/{$params['entity']->username}"; + $item = new ElggMenuItem('lightbox', elgg_echo('lightbox'), $url); + $return[] = $item; + } else { + if ($params['entity']->lightbox_enable != "no") { + $url = "photos/group/{$params['entity']->guid}/all"; + $item = new ElggMenuItem('lightbox', elgg_echo('lightbox:group'), $url); + $return[] = $item; + } + } + + return $return; +} + +/** + * Add links/info to entity menu particular to group entities + */ +function lightbox_entity_menu_setup($hook, $type, $return, $params) { + return $return; +} diff --git a/thumbnail.php b/thumbnail.php new file mode 100644 index 000000000..aa6675f21 --- /dev/null +++ b/thumbnail.php @@ -0,0 +1,55 @@ +<?php +/** + * Elgg image thumbnail + * + * @package ElggLightbox + */ + +// Get engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Get entity GUID +$guid = (int) get_input('guid', 0); + +// Get thumbnail size +$size = get_input('size', 'small'); + +// Get image or album cover +$entity = new LightboxPluginImage($guid); +if (!$entity->guid) { + exit; +} + + +// Get entity thumbnail +switch ($size) { + case "small": + $thumb = $entity->thumbnail; + break; + case "medium": + $thumb = $entity->smallthumb; + break; + case "large": + default: + $thumb = $entity->largethumb; + break; +} + +// Grab the file +if ($thumb && !empty($thumb)) { + $readfile = new ElggFile(); + $readfile->owner_guid = $entity->owner_guid; + $readfile->setFilename($thumb); + $mime = $entity->getMimeType(); + $contents = $readfile->grabFile(); + + // caching images for 10 days + header("Content-type: $mime"); + header('Expires: ' . date('r',time() + 864000)); + header("Pragma: public", true); + header("Cache-Control: public", true); + header("Content-Length: " . strlen($contents)); + + echo $contents; + exit; +} diff --git a/vendors/lightbox/images/lightbox-blank.gif b/vendors/lightbox/images/lightbox-blank.gif new file mode 100644 index 000000000..1d11fa9ad Binary files /dev/null and b/vendors/lightbox/images/lightbox-blank.gif differ diff --git a/vendors/lightbox/images/lightbox-btn-close.gif b/vendors/lightbox/images/lightbox-btn-close.gif new file mode 100644 index 000000000..33bcf517a Binary files /dev/null and b/vendors/lightbox/images/lightbox-btn-close.gif differ diff --git a/vendors/lightbox/images/lightbox-btn-next.gif b/vendors/lightbox/images/lightbox-btn-next.gif new file mode 100644 index 000000000..a0d4fcf84 Binary files /dev/null and b/vendors/lightbox/images/lightbox-btn-next.gif differ diff --git a/vendors/lightbox/images/lightbox-btn-prev.gif b/vendors/lightbox/images/lightbox-btn-prev.gif new file mode 100644 index 000000000..040ee5992 Binary files /dev/null and b/vendors/lightbox/images/lightbox-btn-prev.gif differ diff --git a/vendors/lightbox/images/lightbox-ico-loading.gif b/vendors/lightbox/images/lightbox-ico-loading.gif new file mode 100644 index 000000000..4f1429c06 Binary files /dev/null and b/vendors/lightbox/images/lightbox-ico-loading.gif differ diff --git a/vendors/lightbox/jquery.lightbox-0.5.css b/vendors/lightbox/jquery.lightbox-0.5.css new file mode 100644 index 000000000..c7c3d1cb1 --- /dev/null +++ b/vendors/lightbox/jquery.lightbox-0.5.css @@ -0,0 +1,101 @@ +/** + * jQuery lightBox plugin + * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/) + * and adapted to me for use like a plugin from jQuery. + * @name jquery-lightbox-0.5.css + * @author Leandro Vieira Pinho - http://leandrovieira.com + * @version 0.5 + * @date April 11, 2008 + * @category jQuery plugin + * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com) + * @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US + * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin + */ +#jquery-overlay { + position: absolute; + top: 0; + left: 0; + z-index: 90; + width: 100%; + height: 500px; +} +#jquery-lightbox { + position: absolute; + top: 0; + left: 0; + width: 100%; + z-index: 100; + text-align: center; + line-height: 0; +} +#jquery-lightbox a img { border: none; } +#lightbox-container-image-box { + position: relative; + background-color: #fff; + width: 250px; + height: 250px; + margin: 0 auto; +} +#lightbox-container-image { padding: 10px; } +#lightbox-loading { + position: absolute; + top: 40%; + left: 0%; + height: 25%; + width: 100%; + text-align: center; + line-height: 0; +} +#lightbox-nav { + position: absolute; + top: 0; + left: 0; + height: 100%; + width: 100%; + z-index: 10; +} +#lightbox-container-image-box > #lightbox-nav { left: 0; } +#lightbox-nav a { outline: none;} +#lightbox-nav-btnPrev, #lightbox-nav-btnNext { + width: 49%; + height: 100%; + zoom: 1; + display: block; +} +#lightbox-nav-btnPrev { + left: 0; + float: left; +} +#lightbox-nav-btnNext { + right: 0; + float: right; +} +#lightbox-container-image-data-box { + font: 10px Verdana, Helvetica, sans-serif; + background-color: #fff; + margin: 0 auto; + line-height: 1.4em; + overflow: auto; + width: 100%; + padding: 0 10px 0; +} +#lightbox-container-image-data { + padding: 0 10px; + color: #666; +} +#lightbox-container-image-data #lightbox-image-details { + width: 70%; + float: left; + text-align: left; +} +#lightbox-image-details-caption { font-weight: bold; } +#lightbox-image-details-currentNumber { + display: block; + clear: left; + padding-bottom: 1.0em; +} +#lightbox-secNav-btnClose { + width: 66px; + float: right; + padding-bottom: 0.7em; +} \ No newline at end of file diff --git a/vendors/lightbox/jquery.lightbox-0.5.min.js b/vendors/lightbox/jquery.lightbox-0.5.min.js new file mode 100644 index 000000000..ef59d295c --- /dev/null +++ b/vendors/lightbox/jquery.lightbox-0.5.min.js @@ -0,0 +1,42 @@ +/** + * jQuery lightBox plugin + * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/) + * and adapted to me for use like a plugin from jQuery. + * @name jquery-lightbox-0.5.js + * @author Leandro Vieira Pinho - http://leandrovieira.com + * @version 0.5 + * @date April 11, 2008 + * @category jQuery plugin + * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com) + * @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US + * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin + */ +(function($){$.fn.lightBox=function(settings){settings=jQuery.extend({overlayBgColor:'#000',overlayOpacity:0.8,fixedNavigation:false,imageLoading:'/mod/lightbox/vendors/lightbox/images/lightbox-ico-loading.gif',imageBtnPrev:'/mod/lightbox/vendors/lightbox/images/lightbox-btn-prev.gif',imageBtnNext:'/mod/lightbox/vendors/lightbox/images/lightbox-btn-next.gif',imageBtnClose:'/mod/lightbox/vendors/lightbox/images/lightbox-btn-close.gif',imageBlank:'/mod/lightbox/vendors/lightbox/images/lightbox-blank.gif',containerBorderSize:10,containerResizeSpeed:400,txtImage:'Image',txtOf:'of',keyToClose:'c',keyToPrev:'p',keyToNext:'n',imageArray:[],activeImage:0},settings);var jQueryMatchedObj=this;function _initialize(){_start(this,jQueryMatchedObj);return false;} +function _start(objClicked,jQueryMatchedObj){$('embed, object, select').css({'visibility':'hidden'});_set_interface();settings.imageArray.length=0;settings.activeImage=0;if(jQueryMatchedObj.length==1){settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));}else{for(var i=0;i<jQueryMatchedObj.length;i++){settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));}} +while(settings.imageArray[settings.activeImage][0]!=objClicked.getAttribute('href')){settings.activeImage++;} +_set_image_to_view();} +function _set_interface(){$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+settings.imageLoading+'"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="'+settings.imageBtnClose+'"></a></div></div></div></div>');var arrPageSizes=___getPageSize();$('#jquery-overlay').css({backgroundColor:settings.overlayBgColor,opacity:settings.overlayOpacity,width:arrPageSizes[0],height:arrPageSizes[1]}).fadeIn();var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]}).show();$('#jquery-overlay,#jquery-lightbox').click(function(){_finish();});$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function(){_finish();return false;});$(window).resize(function(){var arrPageSizes=___getPageSize();$('#jquery-overlay').css({width:arrPageSizes[0],height:arrPageSizes[1]});var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]});});} +function _set_image_to_view(){$('#lightbox-loading').show();if(settings.fixedNavigation){$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}else{$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();} +var objImagePreloader=new Image();objImagePreloader.onload=function(){$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);objImagePreloader.onload=function(){};};objImagePreloader.src=settings.imageArray[settings.activeImage][0];};function _resize_container_image_box(intImageWidth,intImageHeight){var intCurrentWidth=$('#lightbox-container-image-box').width();var intCurrentHeight=$('#lightbox-container-image-box').height();var intWidth=(intImageWidth+(settings.containerBorderSize*2));var intHeight=(intImageHeight+(settings.containerBorderSize*2));var intDiffW=intCurrentWidth-intWidth;var intDiffH=intCurrentHeight-intHeight;$('#lightbox-container-image-box').animate({width:intWidth,height:intHeight},settings.containerResizeSpeed,function(){_show_image();});if((intDiffW==0)&&(intDiffH==0)){if($.browser.msie){___pause(250);}else{___pause(100);}} +$('#lightbox-container-image-data-box').css({width:intImageWidth});$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({height:intImageHeight+(settings.containerBorderSize*2)});};function _show_image(){$('#lightbox-loading').hide();$('#lightbox-image').fadeIn(function(){_show_image_data();_set_navigation();});_preload_neighbor_images();};function _show_image_data(){$('#lightbox-container-image-data-box').slideDown('fast');$('#lightbox-image-details-caption').hide();if(settings.imageArray[settings.activeImage][1]){$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();} +if(settings.imageArray.length>1){$('#lightbox-image-details-currentNumber').html(settings.txtImage+' '+(settings.activeImage+1)+' '+settings.txtOf+' '+settings.imageArray.length).show();}} +function _set_navigation(){$('#lightbox-nav').show();$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({'background':'transparent url('+settings.imageBlank+') no-repeat'});if(settings.activeImage!=0){if(settings.fixedNavigation){$('#lightbox-nav-btnPrev').css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnPrev').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}} +if(settings.activeImage!=(settings.imageArray.length-1)){if(settings.fixedNavigation){$('#lightbox-nav-btnNext').css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnNext').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}} +_enable_keyboard_navigation();} +function _enable_keyboard_navigation(){$(document).keydown(function(objEvent){_keyboard_action(objEvent);});} +function _disable_keyboard_navigation(){$(document).unbind();} +function _keyboard_action(objEvent){if(objEvent==null){keycode=event.keyCode;escapeKey=27;}else{keycode=objEvent.keyCode;escapeKey=objEvent.DOM_VK_ESCAPE;} +key=String.fromCharCode(keycode).toLowerCase();if((key==settings.keyToClose)||(key=='x')||(keycode==escapeKey)){_finish();} +if((key==settings.keyToPrev)||(keycode==37)){if(settings.activeImage!=0){settings.activeImage=settings.activeImage-1;_set_image_to_view();_disable_keyboard_navigation();}} +if((key==settings.keyToNext)||(keycode==39)){if(settings.activeImage!=(settings.imageArray.length-1)){settings.activeImage=settings.activeImage+1;_set_image_to_view();_disable_keyboard_navigation();}}} +function _preload_neighbor_images(){if((settings.imageArray.length-1)>settings.activeImage){objNext=new Image();objNext.src=settings.imageArray[settings.activeImage+1][0];} +if(settings.activeImage>0){objPrev=new Image();objPrev.src=settings.imageArray[settings.activeImage-1][0];}} +function _finish(){$('#jquery-lightbox').remove();$('#jquery-overlay').fadeOut(function(){$('#jquery-overlay').remove();});$('embed, object, select').css({'visibility':'visible'});} +function ___getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;} +var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;} +windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;} +if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;} +if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;} +arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight);return arrayPageSize;};function ___getPageScroll(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;} +arrayPageScroll=new Array(xScroll,yScroll);return arrayPageScroll;};function ___pause(ms){var date=new Date();curDate=null;do{var curDate=new Date();} +while(curDate-date<ms);};return this.unbind('click').click(_initialize);};})(jQuery); diff --git a/views/default/forms/lightbox/edit.php b/views/default/forms/lightbox/edit.php new file mode 100644 index 000000000..b7f33e86a --- /dev/null +++ b/views/default/forms/lightbox/edit.php @@ -0,0 +1,74 @@ +<?php +/** + * Elgg album create/edit form + * + * @package ElggLightbox + */ + +// once elgg_view stops throwing all sorts of junk into $vars, we can use +$title = elgg_extract('title', $vars, ''); +$desc = elgg_extract('description', $vars, ''); +$tags = elgg_extract('tags', $vars, ''); +$access_id = elgg_extract('access_id', $vars, ACCESS_DEFAULT); +$container_guid = elgg_extract('container_guid', $vars); +if (!$container_guid) { + $container_guid = elgg_get_logged_in_user_guid(); +} +$guid = elgg_extract('guid', $vars, null); +?> +<div> + <label><?php echo elgg_echo('lightbox:title'); ?></label><br /> + <?php echo elgg_view('input/text', array('name' => 'title', 'value' => $title)); ?> +</div> + +<div> + <label><?php echo elgg_echo('lightbox:image:upload'); ?></label><br /> + <?php echo elgg_view('input/file', array('name' => 'upload0')); ?> +</div> +<div> + <label><?php echo elgg_echo('lightbox:image:upload:another'); ?></label><br /> + <?php echo elgg_view('input/file', array('name' => 'upload1')); ?> +</div> +<div> + <label><?php echo elgg_echo('lightbox:image:upload:another'); ?></label><br /> + <?php echo elgg_view('input/file', array('name' => 'upload2')); ?> +</div> + +<?php if($guid): ?> + +<div> + <label><?php echo elgg_echo('lightbox:description'); ?></label> + <?php echo elgg_view('input/longtext', array('name' => 'description', 'value' => $desc)); ?> +</div> + +<?php endif; ?> + +<div> + <label><?php echo elgg_echo('lightbox:tags'); ?></label> + <?php echo elgg_view('input/tags', array('name' => 'tags', 'value' => $tags)); ?> +</div> +<?php + +$categories = elgg_view('input/categories', $vars); +if ($categories) { + echo $categories; +} + +?> +<div> + <label><?php echo elgg_echo('access'); ?></label><br /> + <?php echo elgg_view('input/access', array('name' => 'access_id', 'value' => $access_id)); ?> +</div> +<div class="elgg-foot"> +<?php + +echo elgg_view('input/hidden', array('name' => 'container_guid', 'value' => $container_guid)); + +if ($guid) { + echo elgg_view('input/hidden', array('name' => 'guid', 'value' => $guid)); +} + +echo elgg_view('input/submit', array('value' => elgg_echo('save'))); + +?> +</div> diff --git a/views/default/forms/lightbox/images/edit.php b/views/default/forms/lightbox/images/edit.php new file mode 100644 index 000000000..e69de29bb diff --git a/views/default/js/lightbox/album.php b/views/default/js/lightbox/album.php new file mode 100644 index 000000000..19d5dbc04 --- /dev/null +++ b/views/default/js/lightbox/album.php @@ -0,0 +1,8 @@ +$(function(){ + $images = $('.elgg-gallery .lightbox-photo .album-gallery-item a'); + $.each($images, function(i, a) { + a.href = $(a).children().first().attr('src').replace(/size=[^&]*/, "size=full"); + }); + $images.lightBox({txtImage: 'Imagem', + txtOf: 'de'}); +}); diff --git a/views/default/lightbox/image.php b/views/default/lightbox/image.php new file mode 100644 index 000000000..28d82e2be --- /dev/null +++ b/views/default/lightbox/image.php @@ -0,0 +1,16 @@ +<?php +/** + * Display an image + */ + +$image_url = elgg_get_site_url() . "mod/lightbox/thumbnail.php?guid={$vars['entity']->getGUID()}&size=large"; +$image_url = elgg_format_url($image_url); +$download_url = elgg_get_site_url() . "mod/lightbox/thumbnail.php?guid={$vars['entity']->getGUID()}&size=full"; + +if ($vars['full_view'] && $smallthumb = $vars['entity']->smallthumb) { + echo <<<HTML + <div class="file-photo"> + <a href="$download_url"><img class="elgg-photo" src="$image_url" /></a> + </div> +HTML; +} diff --git a/views/default/object/album.php b/views/default/object/album.php new file mode 100644 index 000000000..676488702 --- /dev/null +++ b/views/default/object/album.php @@ -0,0 +1,117 @@ +<?php +/** + * Album renderer. + * + * @package ElggLightbox + */ + +elgg_load_js('jquery.lightbox'); +elgg_load_css('jquery.lightbox'); +elgg_load_js('lightbox.album'); + +$full = elgg_extract('full_view', $vars, FALSE); +$entity = elgg_extract('entity', $vars, FALSE); + +if (!$entity) { + return TRUE; +} + +$owner = $entity->getOwnerEntity(); +$container = $entity->getContainerEntity(); +$categories = elgg_view('output/categories', $vars); +$excerpt = elgg_get_excerpt($entity->description); + +$owner_link = elgg_view('output/url', array( + 'href' => "photos/owner/$owner->username", + 'text' => $owner->name, + 'is_trusted' => true, +)); +$author_text = elgg_echo('byline', array($owner_link)); + +$icon = elgg_view_entity_icon($entity, 'small'); + +$tags = elgg_view('output/tags', array('tags' => $entity->tags)); +$date = elgg_view_friendly_time($entity->time_created); + +$comments_count = $entity->countComments(); +//only display if there are commments +if ($comments_count != 0) { + $text = elgg_echo("comments") . " ($comments_count)"; + $comments_link = elgg_view('output/url', array( + 'href' => $entity->getURL() . '#album-comments', + 'text' => $text, + 'is_trusted' => true, + )); +} else { + $comments_link = ''; +} + +$metadata = elgg_view_menu('entity', array( + 'entity' => $vars['entity'], + 'handler' => 'album', + 'sort_by' => 'priority', + 'class' => 'elgg-menu-hz', +)); + +$subtitle = "$author_text $date $comments_link $categories"; + +// do not show the metadata and controls in widget view +if (elgg_in_context('widgets')) { + $metadata = ''; +} + +if ($full && !elgg_in_context('gallery')) { + + $params = array( + 'entity' => $entity, + 'metadata' => $metadata, + 'subtitle' => $subtitle, + 'tags' => $tags, + ); + $params = $params + $vars; + $summary = elgg_view('object/elements/summary', $params); + + $gallery = elgg_list_entities_from_relationship(array( + 'type' => 'object', + 'subtype' => 'image', + 'relationship' => 'in_album', + 'relationship_guid' => $entity->guid, + 'inverse_relationship' => false, + 'list_type' => 'gallery', + 'item_class' => 'elgg-photo lightbox-photo', + 'full_view' => false, + + )); + + $text = elgg_view('output/longtext', array('value' => $entity->description)); + $body = "$text $gallery"; + + echo elgg_view('object/elements/full', array( + 'entity' => $entity, + 'title' => false, + 'icon' => $icon, + 'summary' => $summary, + 'body' => $body, + )); + +} elseif (elgg_in_context('gallery')) { + echo '<div class="album-gallery-item">'; + echo "<h3>" . $entity->title . "</h3>"; + echo elgg_view_entity_icon($entity, 'medium'); + echo "<p class='subtitle'>$owner_link $date</p>"; + echo '</div>'; +} else { + // brief view + + $params = array( + 'entity' => $entity, + 'metadata' => $metadata, + 'subtitle' => $subtitle, + 'tags' => $tags, + 'content' => $excerpt, + ); + $params = $params + $vars; + $list_body = elgg_view('object/elements/summary', $params); + + echo elgg_view_image_block($icon, $list_body); +} diff --git a/views/default/object/image.php b/views/default/object/image.php new file mode 100644 index 000000000..06a50202a --- /dev/null +++ b/views/default/object/image.php @@ -0,0 +1,100 @@ +<?php +/** + * Image renderer. + * + * @package ElggLightbox + */ + +$full = elgg_extract('full_view', $vars, FALSE); +$entity = elgg_extract('entity', $vars, FALSE); + +if (!$entity) { + return TRUE; +} + +$owner = $entity->getOwnerEntity(); +$container = $entity->getContainerEntity(); +$categories = elgg_view('output/categories', $vars); +$excerpt = elgg_get_excerpt($entity->description); + +$owner_link = elgg_view('output/url', array( + 'href' => "photos/owner/$owner->username", + 'text' => $owner->name, + 'is_trusted' => true, +)); +$author_text = elgg_echo('byline', array($owner_link)); + +$icon = elgg_view_entity_icon($entity, 'small'); + +$tags = elgg_view('output/tags', array('tags' => $entity->tags)); +$date = elgg_view_friendly_time($entity->time_created); + +$comments_count = $entity->countComments(); +//only display if there are commments +if ($comments_count != 0) { + $text = elgg_echo("comments") . " ($comments_count)"; + $comments_link = elgg_view('output/url', array( + 'href' => $entity->getURL() . '#album-comments', + 'text' => $text, + 'is_trusted' => true, + )); +} else { + $comments_link = ''; +} + +$metadata = elgg_view_menu('entity', array( + 'entity' => $vars['entity'], + 'handler' => 'album', + 'sort_by' => 'priority', + 'class' => 'elgg-menu-hz', +)); + +$subtitle = "$author_text $date $comments_link $categories"; + +// do not show the metadata and controls in widget view +if (elgg_in_context('widgets')) { + $metadata = ''; +} + +if ($full && !elgg_in_context('gallery')) { + + $params = array( + 'entity' => $entity, + 'metadata' => $metadata, + 'subtitle' => $subtitle, + 'tags' => $tags, + ); + $params = $params + $vars; + $summary = elgg_view('object/elements/summary', $params); + + $body = elgg_view('lightbox/image' , $vars) + . elgg_view('output/longtext', array('value' => $entity->description)); + + echo elgg_view('object/elements/full', array( + 'entity' => $entity, + 'title' => false, + 'icon' => $icon, + 'summary' => $summary, + 'body' => $body, + )); + +} elseif (elgg_in_context('gallery')) { + echo '<div class="album-gallery-item">'; + echo "<h3>" . $entity->title . "</h3>"; + echo elgg_view_entity_icon($entity, 'medium'); + echo '</div>'; +} else { + // brief view + + $params = array( + 'entity' => $entity, + 'metadata' => $metadata, + 'subtitle' => $subtitle, + 'tags' => $tags, + 'content' => $excerpt, + ); + $params = $params + $vars; + $list_body = elgg_view('object/elements/summary', $params); + + echo elgg_view_image_block($icon, $list_body); +} -- cgit v1.2.3