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 --- start.php | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 start.php (limited to 'start.php') 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; +} -- cgit v1.2.3