diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2014-03-15 15:04:14 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2014-03-15 15:04:14 -0300 |
commit | 4a86fa9b2e63b9d6bb0a07333d4c7d59df621270 (patch) | |
tree | 5770bd548bc70a10dbd5c24aee13c3449bf428a9 | |
parent | d7317abf01cc1f5a6e4ee54f25664e51d23217b9 (diff) | |
parent | 66dd3f3f5f14bb0ba6d2c7ef83b5b612d5ee2e30 (diff) | |
download | elgg-4a86fa9b2e63b9d6bb0a07333d4c7d59df621270.tar.gz elgg-4a86fa9b2e63b9d6bb0a07333d4c7d59df621270.tar.bz2 |
Merge commit '66dd3f3f5f14bb0ba6d2c7ef83b5b612d5ee2e30' as 'mod/lightbox'
29 files changed, 1255 insertions, 0 deletions
diff --git a/mod/lightbox/actions/lightbox/edit.php b/mod/lightbox/actions/lightbox/edit.php new file mode 100644 index 000000000..6ee49e671 --- /dev/null +++ b/mod/lightbox/actions/lightbox/edit.php @@ -0,0 +1,91 @@ +<?php +/** + * Elgg album create/edit action + * + * @package ElggLightbox + */ + +elgg_load_library('elgg:lightbox'); + +// Get variables +$title = get_input("title"); +$desc = get_input("description"); +$access_id = (int) get_input("access_id"); +$container_guid = (int) get_input('container_guid', 0); +$guid = (int) get_input('guid'); +$tags = get_input("tags"); +$images = lightbox_get_image_inputs(); + +if ($container_guid == 0) { + $container_guid = elgg_get_logged_in_user_guid(); +} + +elgg_make_sticky_form('lightbox:album'); + +// check whether this is a new album or an edit +$new_album = true; +if ($guid > 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/mod/lightbox/classes/LightboxPluginAlbum.php b/mod/lightbox/classes/LightboxPluginAlbum.php new file mode 100644 index 000000000..de272d981 --- /dev/null +++ b/mod/lightbox/classes/LightboxPluginAlbum.php @@ -0,0 +1,31 @@ +<?php + +/** + * Override the ElggObject + */ +class LightboxPluginAlbum extends ElggObject { + protected function initializeAttributes() { + parent::initializeAttributes(); + + $this->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/mod/lightbox/classes/LightboxPluginImage.php b/mod/lightbox/classes/LightboxPluginImage.php new file mode 100644 index 000000000..6d2b6bbea --- /dev/null +++ b/mod/lightbox/classes/LightboxPluginImage.php @@ -0,0 +1,31 @@ +<?php + +/** + * Override the ElggFile + */ +class LightboxPluginImage extends ElggFile { + protected function initializeAttributes() { + parent::initializeAttributes(); + + $this->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/mod/lightbox/graphics/defaultmedium.jpg b/mod/lightbox/graphics/defaultmedium.jpg Binary files differnew file mode 100644 index 000000000..23494eff2 --- /dev/null +++ b/mod/lightbox/graphics/defaultmedium.jpg diff --git a/mod/lightbox/graphics/defaultsmall.jpg b/mod/lightbox/graphics/defaultsmall.jpg Binary files differnew file mode 100644 index 000000000..2d8745bb6 --- /dev/null +++ b/mod/lightbox/graphics/defaultsmall.jpg diff --git a/mod/lightbox/graphics/defaulttiny.jpg b/mod/lightbox/graphics/defaulttiny.jpg Binary files differnew file mode 100644 index 000000000..2a656fe23 --- /dev/null +++ b/mod/lightbox/graphics/defaulttiny.jpg diff --git a/mod/lightbox/languages/en.php b/mod/lightbox/languages/en.php new file mode 100644 index 000000000..4c85d916b --- /dev/null +++ b/mod/lightbox/languages/en.php @@ -0,0 +1,76 @@ +<?php +/** + * Elgg lightbox plugin language pack + * + * @package ElggLightbox + */ + +$english = array( + + /** + * Menu items and titles + */ + 'lightbox' => "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/mod/lightbox/lib/lightbox.php b/mod/lightbox/lib/lightbox.php new file mode 100644 index 000000000..6b557d241 --- /dev/null +++ b/mod/lightbox/lib/lightbox.php @@ -0,0 +1,107 @@ +<?php +/** + * Lightbox helper functions + * + * @package ElggLightbox + */ + +/** + * Save uploaded images and return an array of its entities + * + * @return array of LightboxPluginImages + */ +function lightbox_get_image_inputs() { + + $files = array(); + $file = new ElggFile(); + + // check if upload failed + foreach($_FILES as $key => $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/mod/lightbox/manifest.xml b/mod/lightbox/manifest.xml new file mode 100644 index 000000000..9c28ec859 --- /dev/null +++ b/mod/lightbox/manifest.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8"> + <name>Lightbox</name> + <author>Lorea developers</author> + <version>0.1</version> + <category>bundled</category> + <category>media</category> + <category>widget</category> + <description>Lightbox Photo Gallery</description> + <website>https://lorea.cc/</website> + <copyright>(C) Lorea 2011</copyright> + <license>GNU General Public License version 2</license> + <requires> + <type>elgg_release</type> + <version>1.8</version> + </requires> + <activate_on_install>true</activate_on_install> +</plugin_manifest> diff --git a/mod/lightbox/pages/lightbox/friends.php b/mod/lightbox/pages/lightbox/friends.php new file mode 100644 index 000000000..6b0bbb03e --- /dev/null +++ b/mod/lightbox/pages/lightbox/friends.php @@ -0,0 +1,34 @@ +<?php +/** + * Friends albums + * + * @package ElggLightbox + */ + +$owner = elgg_get_page_owner_entity(); +if (!$owner) { + forward('photos/all'); +} + +elgg_push_breadcrumb(elgg_echo('lightbox'), "photos/all"); +elgg_push_breadcrumb($owner->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/mod/lightbox/pages/lightbox/new.php b/mod/lightbox/pages/lightbox/new.php new file mode 100644 index 000000000..117aba293 --- /dev/null +++ b/mod/lightbox/pages/lightbox/new.php @@ -0,0 +1,37 @@ +<?php +/** + * Create a new album + * + * @package ElggLightbox + */ + +//elgg_load_library('elgg:lightbox'); + +$owner = elgg_get_page_owner_entity(); + +gatekeeper(); +group_gatekeeper(); + +$title = elgg_echo('photos:add'); + +// set up breadcrumbs +elgg_push_breadcrumb(elgg_echo('lightbox'), "photos/all"); +if (elgg_instanceof($owner, 'user')) { + elgg_push_breadcrumb($owner->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/mod/lightbox/pages/lightbox/owner.php b/mod/lightbox/pages/lightbox/owner.php new file mode 100644 index 000000000..536790906 --- /dev/null +++ b/mod/lightbox/pages/lightbox/owner.php @@ -0,0 +1,55 @@ +<?php +/** + * Individual's or group's albums + * + * @package ElggLightbox + */ + +// access check for closed groups +group_gatekeeper(); + +$owner = elgg_get_page_owner_entity(); +if (!$owner) { + forward('photos/all'); +} + +elgg_push_breadcrumb(elgg_echo('lightbox'), "photos/all"); +elgg_push_breadcrumb($owner->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/mod/lightbox/pages/lightbox/view.php b/mod/lightbox/pages/lightbox/view.php new file mode 100644 index 000000000..6fa703895 --- /dev/null +++ b/mod/lightbox/pages/lightbox/view.php @@ -0,0 +1,39 @@ +<?php +/** + * View an album or an image + * + * @package ElggLightbox + */ + +$entity = get_entity(get_input('guid')); + +$owner = $entity->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/mod/lightbox/pages/lightbox/world.php b/mod/lightbox/pages/lightbox/world.php new file mode 100644 index 000000000..6262faa1e --- /dev/null +++ b/mod/lightbox/pages/lightbox/world.php @@ -0,0 +1,33 @@ +<?php +/** + * All albums + * + * @package ElggLightbox + */ + +elgg_push_breadcrumb(elgg_echo('lightbox')); + +elgg_register_title_button(); + +$limit = get_input("limit", 10); + +$title = elgg_echo('lightbox:all'); + +$content = elgg_list_entities(array( + 'types' => '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/mod/lightbox/start.php b/mod/lightbox/start.php new file mode 100644 index 000000000..c79ab100b --- /dev/null +++ b/mod/lightbox/start.php @@ -0,0 +1,190 @@ +<?php +/** + * Elgg lightbox plugin + * + * @package ElggLightbox + */ + +elgg_register_event_handler('init', 'system', 'lightbox_init'); + +/** + * Initialize the lightbox plugin. + */ +function lightbox_init() { + + elgg_register_library('elgg:lightbox', elgg_get_plugins_path() . 'lightbox/lib/lightbox.php'); + + // register group entities for search + elgg_register_entity_type('object', 'image', 'LightboxPluginImage'); + elgg_register_entity_type('object', 'album', 'LightboxPluginAlbum'); + + // Set up the menu + $item = new ElggMenuItem('lightbox', elgg_echo('lightbox'), 'photos/all'); + elgg_register_menu_item('site', $item); + + // Register a page handler, so we can have nice URLs + elgg_register_page_handler('photos', 'lightbox_page_handler'); + + // Register URL handlers for groups + elgg_register_entity_url_handler('object', 'image', 'lightbox_url'); + elgg_register_entity_url_handler('object', 'album', 'lightbox_url'); + elgg_register_plugin_hook_handler('entity:icon:url', 'object', 'lightbox_icon_url_override'); + + // Register some actions + $action_base = elgg_get_plugins_path() . 'lightbox/actions/lightbox'; + elgg_register_action("lightbox/edit", "$action_base/edit.php"); + elgg_register_action("lightbox/delete", "$action_base/delete.php"); + + $action_base .= '/images'; + elgg_register_action("lightbox/albums/edit", "$action_base/edit.php"); + elgg_register_action("lightbox/albums/delete", "$action_base/delete.php"); + + // Add some widgets + elgg_register_widget_type('lightbox', elgg_echo('lightbox:widget'), elgg_echo('groups:widgets:description')); + + // add group photos tool option + add_group_tool_option('lightbox', elgg_echo('groups:enablelightbox'), true); + elgg_extend_view('groups/tool_latest', 'groups/profile/lightbox_module'); + + // add link to owner block + elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'lightbox_owner_block_menu'); + + // photo and album entity menu + elgg_register_plugin_hook_handler('register', 'menu:entity', 'lightbox_entity_menu_setup'); + + //extend some views + elgg_extend_view('css/elgg', 'lightbox/css'); + elgg_extend_view('js/elgg', 'lightbox/js'); + + // Register vendors libraries + elgg_register_css('jquery.lightbox', 'mod/lightbox/vendors/lightbox/jquery.lightbox-0.5.css'); + elgg_register_js('jquery.lightbox', 'mod/lightbox/vendors/lightbox/jquery.lightbox-0.5.min.js'); + + $album_js = elgg_get_simplecache_url('js', 'lightbox/album'); + elgg_register_js('lightbox.album', $album_js); + +} + +/** + * Dispatches photo and album pages. + * URLs take the form of + * All albums: photos/all + * User's albums: photos/owner/<username> + * Friends' albums: photos/friends/<username> + * View album: photos/album/<guid>/<title> + * 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/mod/lightbox/thumbnail.php b/mod/lightbox/thumbnail.php new file mode 100644 index 000000000..aa6675f21 --- /dev/null +++ b/mod/lightbox/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/mod/lightbox/vendors/lightbox/images/lightbox-blank.gif b/mod/lightbox/vendors/lightbox/images/lightbox-blank.gif Binary files differnew file mode 100644 index 000000000..1d11fa9ad --- /dev/null +++ b/mod/lightbox/vendors/lightbox/images/lightbox-blank.gif diff --git a/mod/lightbox/vendors/lightbox/images/lightbox-btn-close.gif b/mod/lightbox/vendors/lightbox/images/lightbox-btn-close.gif Binary files differnew file mode 100644 index 000000000..33bcf517a --- /dev/null +++ b/mod/lightbox/vendors/lightbox/images/lightbox-btn-close.gif diff --git a/mod/lightbox/vendors/lightbox/images/lightbox-btn-next.gif b/mod/lightbox/vendors/lightbox/images/lightbox-btn-next.gif Binary files differnew file mode 100644 index 000000000..a0d4fcf84 --- /dev/null +++ b/mod/lightbox/vendors/lightbox/images/lightbox-btn-next.gif diff --git a/mod/lightbox/vendors/lightbox/images/lightbox-btn-prev.gif b/mod/lightbox/vendors/lightbox/images/lightbox-btn-prev.gif Binary files differnew file mode 100644 index 000000000..040ee5992 --- /dev/null +++ b/mod/lightbox/vendors/lightbox/images/lightbox-btn-prev.gif diff --git a/mod/lightbox/vendors/lightbox/images/lightbox-ico-loading.gif b/mod/lightbox/vendors/lightbox/images/lightbox-ico-loading.gif Binary files differnew file mode 100644 index 000000000..4f1429c06 --- /dev/null +++ b/mod/lightbox/vendors/lightbox/images/lightbox-ico-loading.gif diff --git a/mod/lightbox/vendors/lightbox/jquery.lightbox-0.5.css b/mod/lightbox/vendors/lightbox/jquery.lightbox-0.5.css new file mode 100644 index 000000000..c7c3d1cb1 --- /dev/null +++ b/mod/lightbox/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/mod/lightbox/vendors/lightbox/jquery.lightbox-0.5.min.js b/mod/lightbox/vendors/lightbox/jquery.lightbox-0.5.min.js new file mode 100644 index 000000000..ef59d295c --- /dev/null +++ b/mod/lightbox/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/mod/lightbox/views/default/forms/lightbox/edit.php b/mod/lightbox/views/default/forms/lightbox/edit.php new file mode 100644 index 000000000..b7f33e86a --- /dev/null +++ b/mod/lightbox/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/mod/lightbox/views/default/forms/lightbox/images/edit.php b/mod/lightbox/views/default/forms/lightbox/images/edit.php new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/mod/lightbox/views/default/forms/lightbox/images/edit.php diff --git a/mod/lightbox/views/default/js/lightbox/album.php b/mod/lightbox/views/default/js/lightbox/album.php new file mode 100644 index 000000000..19d5dbc04 --- /dev/null +++ b/mod/lightbox/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/mod/lightbox/views/default/lightbox/image.php b/mod/lightbox/views/default/lightbox/image.php new file mode 100644 index 000000000..28d82e2be --- /dev/null +++ b/mod/lightbox/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/mod/lightbox/views/default/object/album.php b/mod/lightbox/views/default/object/album.php new file mode 100644 index 000000000..676488702 --- /dev/null +++ b/mod/lightbox/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/mod/lightbox/views/default/object/image.php b/mod/lightbox/views/default/object/image.php new file mode 100644 index 000000000..06a50202a --- /dev/null +++ b/mod/lightbox/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); +} |