* 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; }